Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 140 additions & 0 deletions docs/generated/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,27 @@
},
"releaseTag": "Public",
"name": "PubSub"
},
{
"kind": "EnumMember",
"canonicalReference": "@openfunction/functions-framework!ComponentType.State:member",
"docComment": "/**\n * The state type\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "State = "
},
{
"kind": "Content",
"text": "\"state\""
}
],
"initializerTokenRange": {
"startIndex": 1,
"endIndex": 2
},
"releaseTag": "Public",
"name": "State"
}
]
},
Expand Down Expand Up @@ -826,6 +847,54 @@
],
"isOptional": false,
"name": "IsPubSubComponent"
},
{
"kind": "Method",
"canonicalReference": "@openfunction/functions-framework!ContextUtils.IsStateComponent:member(1)",
"docComment": "/**\n * Checks if the component is a state component.\n *\n * @param component - The component to check.\n *\n * @returns A boolean value.\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "static IsStateComponent(component: "
},
{
"kind": "Reference",
"text": "OpenFunctionComponent",
"canonicalReference": "@openfunction/functions-framework!OpenFunctionComponent:interface"
},
{
"kind": "Content",
"text": "): "
},
{
"kind": "Content",
"text": "boolean"
},
{
"kind": "Content",
"text": ";"
}
],
"isStatic": true,
"returnTypeTokenRange": {
"startIndex": 3,
"endIndex": 4
},
"releaseTag": "Public",
"isProtected": false,
"overloadIndex": 1,
"parameters": [
{
"parameterName": "component",
"parameterTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
},
"isOptional": false
}
],
"isOptional": false,
"name": "IsStateComponent"
}
],
"implementsTokenRanges": []
Expand Down Expand Up @@ -2051,6 +2120,47 @@
"endIndex": 12
}
},
{
"kind": "PropertySignature",
"canonicalReference": "@openfunction/functions-framework!OpenFunctionContext#states:member",
"docComment": "/**\n * Optional state store config;\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "states?: "
},
{
"kind": "Reference",
"text": "Record",
"canonicalReference": "!Record:type"
},
{
"kind": "Content",
"text": "<string, "
},
{
"kind": "Reference",
"text": "OpenFunctionComponent",
"canonicalReference": "@openfunction/functions-framework!OpenFunctionComponent:interface"
},
{
"kind": "Content",
"text": ">"
},
{
"kind": "Content",
"text": ";"
}
],
"isReadonly": false,
"isOptional": true,
"releaseTag": "Public",
"name": "states",
"propertyTypeTokenRange": {
"startIndex": 1,
"endIndex": 5
}
},
{
"kind": "PropertySignature",
"canonicalReference": "@openfunction/functions-framework!OpenFunctionContext#version:member",
Expand Down Expand Up @@ -2635,6 +2745,36 @@
"isStatic": false,
"isProtected": false
},
{
"kind": "Property",
"canonicalReference": "@openfunction/functions-framework!OpenFunctionRuntime#state:member",
"docComment": "/**\n * The promise that handle data by state store.\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "abstract get state(): "
},
{
"kind": "Reference",
"text": "StateOperations",
"canonicalReference": "@openfunction/functions-framework!~StateOperations:interface"
},
{
"kind": "Content",
"text": ";"
}
],
"isReadonly": true,
"isOptional": false,
"releaseTag": "Public",
"name": "state",
"propertyTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
},
"isStatic": false,
"isProtected": false
},
{
"kind": "Property",
"canonicalReference": "@openfunction/functions-framework!OpenFunctionRuntime#trigger:member",
Expand Down
9 changes: 8 additions & 1 deletion docs/generated/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@

import { CloudEventV1 as CloudEvent } from 'cloudevents';
import { IndexedFieldWithPossiblyUndefined } from 'lodash';
import { KeyValueType } from '@dapr/dapr/types/KeyValue.type';
import { ParamsDictionary } from 'express-serve-static-core';
import { ParsedQs } from 'qs';
import { Request as Request_3 } from 'express';
import { Response as Response_2 } from 'express';
import { StateQueryResponseType } from '@dapr/dapr/types/state/StateQueryResponse.type';

export { CloudEvent }

Expand Down Expand Up @@ -44,7 +46,8 @@ export interface CloudFunctionsContext {
// @public
export enum ComponentType {
Binding = "bindings",
PubSub = "pubsub"
PubSub = "pubsub",
State = "state"
}

// @public
Expand All @@ -56,6 +59,7 @@ export class ContextUtils {
static IsBindingComponent(component: OpenFunctionComponent): boolean;
static IsKnativeRuntime(context: OpenFunctionContext): boolean;
static IsPubSubComponent(component: OpenFunctionComponent): boolean;
static IsStateComponent(component: OpenFunctionComponent): boolean;
}

// @public
Expand Down Expand Up @@ -136,6 +140,7 @@ export interface OpenFunctionContext {
postPlugins?: string[];
prePlugins?: string[];
runtime: `${RuntimeType}` | `${Capitalize<RuntimeType>}` | `${Uppercase<RuntimeType>}`;
states?: Record<string, OpenFunctionComponent>;
version: string;
}

Expand All @@ -156,6 +161,8 @@ export abstract class OpenFunctionRuntime {
HTTP: string;
GRPC: string;
};
// Warning: (ae-forgotten-export) The symbol "StateOperations" needs to be exported by the entry point index.d.ts
abstract get state(): StateOperations;
// Warning: (ae-forgotten-export) The symbol "OpenFunctionTrigger" needs to be exported by the entry point index.d.ts
protected trigger?: OpenFunctionTrigger;
static WrapUserFunction(userFunction: OpenFunction, context: OpenFunctionContext | OpenFunctionRuntime): (data: any) => Promise<void>;
Expand Down
16 changes: 16 additions & 0 deletions src/openfunction/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export interface OpenFunctionContext {
* Optional output binding object.
*/
outputs?: Record<string, OpenFunctionComponent>;
/**
* Optional state store config;
*/
states?: Record<string, OpenFunctionComponent>;
/**
* Optional plugins to be executed before user function.
*/
Expand Down Expand Up @@ -99,6 +103,10 @@ export enum ComponentType {
* The pubsub type.
*/
PubSub = 'pubsub',
/**
* The state type
*/
State = 'state',
}

/**
Expand Down Expand Up @@ -139,6 +147,14 @@ export class ContextUtils {
static IsPubSubComponent(component: OpenFunctionComponent): boolean {
return component?.componentType.split('.')[0] === ComponentType.PubSub;
}
/**
* Checks if the component is a state component.
* @param component - The component to check.
* @returns A boolean value.
*/
static IsStateComponent(component: OpenFunctionComponent): boolean {
return component?.componentType.split('.')[0] === ComponentType.State;
}
}

/**
Expand Down
Loading