Skip to content

feat: enable plugin mechanism for async func #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
56ff7ad
✨ feat: enable asycn function plugin
YADROOKIE Jul 20, 2022
10c240f
♻️ refactor enable aysnc function plugin
YADROOKIE Jul 22, 2022
7034730
Merge branch 'OpenFunction:master' into feature/plugin-async
YADROOKIE Jul 22, 2022
be20c3f
Merge branch 'feature/plugin-async' of https://github.com/YADROOKIE/f…
YADROOKIE Jul 22, 2022
c2146ee
🎨 formate code
YADROOKIE Jul 22, 2022
7c1d9e8
🎨 improve aysnc function plugin code
YADROOKIE Jul 23, 2022
c844496
🎨 rename test file gi
YADROOKIE Jul 23, 2022
af1ac61
🎨 improve & formate code
YADROOKIE Jul 25, 2022
4bb5ad6
🎨 format code
YADROOKIE Jul 25, 2022
0d5ceb3
🎨 extract common test data into a separate file for reuse & use Reco…
YADROOKIE Jul 25, 2022
184c2a9
🎨 delete test data
YADROOKIE Jul 25, 2022
eae45d8
🎨 test data in common file
YADROOKIE Jul 27, 2022
a95dad2
🎨 remove annotation
YADROOKIE Jul 27, 2022
b6d1c50
Merge branch 'OpenFunction:master' into feature/plugin-async
YADROOKIE Jul 27, 2022
1c9b4a8
Merge branch 'OpenFunction:master' into feature/plugin-async
YADROOKIE Jul 28, 2022
48946da
Merge branch 'OpenFunction:master' into feature/plugin-async
YADROOKIE Jul 29, 2022
a2f2db7
🎨 improve the codegit
YADROOKIE Aug 3, 2022
fa7c1f5
🎨 imporove plugin loader
YADROOKIE Aug 3, 2022
37a91af
process conflict
YADROOKIE Aug 3, 2022
c1074ad
Merge branch 'OpenFunction:master' into feature/plugin-async
YADROOKIE Aug 3, 2022
75d2422
resolve conflict
YADROOKIE Aug 3, 2022
8403803
add api docs
YADROOKIE Aug 4, 2022
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/node_modules
build/
test/data/esm_*
test/data/plugins
docs/
310 changes: 310 additions & 0 deletions docs/generated/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -1913,6 +1913,88 @@
"endIndex": 2
}
},
{
"kind": "PropertySignature",
"canonicalReference": "@openfunction/functions-framework!OpenFunctionContext#postPlugins:member",
"docComment": "/**\n * Optional post function exec plugins.\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "postPlugins?: "
},
{
"kind": "Reference",
"text": "Array",
"canonicalReference": "!Array:interface"
},
{
"kind": "Content",
"text": "<string | "
},
{
"kind": "Reference",
"text": "Plugin",
"canonicalReference": "@openfunction/functions-framework!Plugin:class"
},
{
"kind": "Content",
"text": " | undefined>"
},
{
"kind": "Content",
"text": ";"
}
],
"isReadonly": false,
"isOptional": true,
"releaseTag": "Public",
"name": "postPlugins",
"propertyTypeTokenRange": {
"startIndex": 1,
"endIndex": 5
}
},
{
"kind": "PropertySignature",
"canonicalReference": "@openfunction/functions-framework!OpenFunctionContext#prePlugins:member",
"docComment": "/**\n * Optional pre function exec plugins.\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "prePlugins?: "
},
{
"kind": "Reference",
"text": "Array",
"canonicalReference": "!Array:interface"
},
{
"kind": "Content",
"text": "<string | "
},
{
"kind": "Reference",
"text": "Plugin",
"canonicalReference": "@openfunction/functions-framework!Plugin:class"
},
{
"kind": "Content",
"text": " | undefined>"
},
{
"kind": "Content",
"text": ";"
}
],
"isReadonly": false,
"isOptional": true,
"releaseTag": "Public",
"name": "prePlugins",
"propertyTypeTokenRange": {
"startIndex": 1,
"endIndex": 5
}
},
{
"kind": "PropertySignature",
"canonicalReference": "@openfunction/functions-framework!OpenFunctionContext#runtime:member",
Expand Down Expand Up @@ -2489,6 +2571,234 @@
],
"implementsTokenRanges": []
},
{
"kind": "Class",
"canonicalReference": "@openfunction/functions-framework!Plugin_2:class",
"docComment": "/**\n * The OpenFunction's plugin template.\n *\n * @public\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "export declare class Plugin "
}
],
"releaseTag": "Public",
"name": "Plugin_2",
"preserveMemberOrder": false,
"members": [
{
"kind": "Method",
"canonicalReference": "@openfunction/functions-framework!Plugin_2#execPostHook:member(1)",
"docComment": "/**\n * post main function exec.\n *\n * @param ctx - The openfunction runtime .\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "execPostHook(ctx?: "
},
{
"kind": "Reference",
"text": "OpenFunctionRuntime",
"canonicalReference": "@openfunction/functions-framework!OpenFunctionRuntime:class"
},
{
"kind": "Content",
"text": "): "
},
{
"kind": "Reference",
"text": "Promise",
"canonicalReference": "!Promise:interface"
},
{
"kind": "Content",
"text": "<void>"
},
{
"kind": "Content",
"text": ";"
}
],
"isStatic": false,
"returnTypeTokenRange": {
"startIndex": 3,
"endIndex": 5
},
"releaseTag": "Public",
"isProtected": false,
"overloadIndex": 1,
"parameters": [
{
"parameterName": "ctx",
"parameterTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
},
"isOptional": true
}
],
"isOptional": false,
"name": "execPostHook"
},
{
"kind": "Method",
"canonicalReference": "@openfunction/functions-framework!Plugin_2#execPreHook:member(1)",
"docComment": "/**\n * pre main function exec.\n *\n * @param ctx - The openfunction runtime .\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "execPreHook(ctx?: "
},
{
"kind": "Reference",
"text": "OpenFunctionRuntime",
"canonicalReference": "@openfunction/functions-framework!OpenFunctionRuntime:class"
},
{
"kind": "Content",
"text": "): "
},
{
"kind": "Reference",
"text": "Promise",
"canonicalReference": "!Promise:interface"
},
{
"kind": "Content",
"text": "<void>"
},
{
"kind": "Content",
"text": ";"
}
],
"isStatic": false,
"returnTypeTokenRange": {
"startIndex": 3,
"endIndex": 5
},
"releaseTag": "Public",
"isProtected": false,
"overloadIndex": 1,
"parameters": [
{
"parameterName": "ctx",
"parameterTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
},
"isOptional": true
}
],
"isOptional": false,
"name": "execPreHook"
},
{
"kind": "Method",
"canonicalReference": "@openfunction/functions-framework!Plugin_2#get:member(1)",
"docComment": "/**\n * get instance filed value.\n *\n * @param filedName - the instace filedName\n *\n * @returns filed value.\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "get(filedName: "
},
{
"kind": "Content",
"text": "string"
},
{
"kind": "Content",
"text": "): "
},
{
"kind": "Content",
"text": "string"
},
{
"kind": "Content",
"text": ";"
}
],
"isStatic": false,
"returnTypeTokenRange": {
"startIndex": 3,
"endIndex": 4
},
"releaseTag": "Public",
"isProtected": false,
"overloadIndex": 1,
"parameters": [
{
"parameterName": "filedName",
"parameterTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
},
"isOptional": false
}
],
"isOptional": false,
"name": "get"
},
{
"kind": "Property",
"canonicalReference": "@openfunction/functions-framework!Plugin_2.OFN_PLUGIN_NAME:member",
"docComment": "",
"excerptTokens": [
{
"kind": "Content",
"text": "static OFN_PLUGIN_NAME: "
},
{
"kind": "Content",
"text": "string"
},
{
"kind": "Content",
"text": ";"
}
],
"isReadonly": false,
"isOptional": false,
"releaseTag": "Public",
"name": "OFN_PLUGIN_NAME",
"propertyTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
},
"isStatic": true,
"isProtected": false
},
{
"kind": "Property",
"canonicalReference": "@openfunction/functions-framework!Plugin_2.OFN_PLUGIN_VERSION:member",
"docComment": "",
"excerptTokens": [
{
"kind": "Content",
"text": "static OFN_PLUGIN_VERSION: "
},
{
"kind": "Content",
"text": "string"
},
{
"kind": "Content",
"text": ";"
}
],
"isReadonly": false,
"isOptional": false,
"releaseTag": "Public",
"name": "OFN_PLUGIN_VERSION",
"propertyTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
},
"isStatic": true,
"isProtected": false
}
],
"implementsTokenRanges": []
},
{
"kind": "Interface",
"canonicalReference": "@openfunction/functions-framework!Request_2:interface",
Expand Down
14 changes: 14 additions & 0 deletions docs/generated/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ export interface OpenFunctionContext {
name: string;
outputs?: OpenFunctionBinding;
port?: string;
postPlugins?: Array<string | Plugin_2 | undefined>;
prePlugins?: Array<string | Plugin_2 | undefined>;
runtime: `${RuntimeType}` | `${Capitalize<RuntimeType>}` | `${Uppercase<RuntimeType>}`;
version: string;
}
Expand All @@ -158,6 +160,18 @@ export abstract class OpenFunctionRuntime {
protected trigger?: OpenFunctionTrigger;
}

// @public
class Plugin_2 {
execPostHook(ctx?: OpenFunctionRuntime): Promise<void>;
execPreHook(ctx?: OpenFunctionRuntime): Promise<void>;
get(filedName: string): string;
// (undocumented)
static OFN_PLUGIN_NAME: string;
// (undocumented)
static OFN_PLUGIN_VERSION: string;
}
export { Plugin_2 as Plugin }

// @public (undocumented)
interface Request_2 extends Request_3 {
rawBody?: Buffer;
Expand Down
Loading