@dxos/plugin-automation 0.7.0 → 0.7.1-staging.599df14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{PromptContainer-3GUENQHE.mjs → PromptContainer-6CBNCUKQ.mjs} +3 -3
- package/dist/lib/browser/{chunk-J4SYTP4Y.mjs → chunk-B3Z4NQC2.mjs} +2 -2
- package/dist/lib/browser/{chunk-J4SYTP4Y.mjs.map → chunk-B3Z4NQC2.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-2FOJUVYG.mjs → chunk-CJMV64XO.mjs} +2 -2
- package/dist/lib/browser/index.mjs +299 -213
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node/{PromptContainer-74ZRO4HK.cjs → PromptContainer-7RCGCU3K.cjs} +7 -7
- package/dist/lib/node/{chunk-XS53UP75.cjs → chunk-SUMUWFZA.cjs} +4 -4
- package/dist/lib/node/{chunk-XS53UP75.cjs.map → chunk-SUMUWFZA.cjs.map} +1 -1
- package/dist/lib/node/{chunk-4TMTUB4X.cjs → chunk-YGRHTCOX.cjs} +16 -16
- package/dist/lib/node/index.cjs +322 -240
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types/index.cjs +6 -6
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/{PromptContainer-5OK4GWIR.mjs → PromptContainer-4SCHQV5C.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-FN6DOJZP.mjs → chunk-62AB5HXX.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-AAUSG7OA.mjs → chunk-PYT2WY4B.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-AAUSG7OA.mjs.map → chunk-PYT2WY4B.mjs.map} +1 -1
- package/dist/lib/node-esm/index.mjs +299 -213
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +4 -3
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +1 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/meta.d.ts.map +1 -1
- package/dist/types/src/hooks/email.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/{components/TriggerEditor/invokation-handler.d.ts → hooks/invocation-handler.d.ts} +1 -1
- package/dist/types/src/hooks/invocation-handler.d.ts.map +1 -0
- package/dist/types/src/hooks/useLocalTriggerManager.d.ts +3 -0
- package/dist/types/src/hooks/useLocalTriggerManager.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/{chain.d.ts → schema.d.ts} +1 -1
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/package.json +35 -34
- package/src/AutomationPlugin.tsx +0 -3
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +4 -3
- package/src/components/TriggerEditor/TriggerEditor.tsx +69 -86
- package/src/components/TriggerEditor/meta.tsx +1 -0
- package/src/hooks/index.ts +5 -0
- package/src/{components/TriggerEditor/invokation-handler.ts → hooks/invocation-handler.ts} +4 -2
- package/src/hooks/useLocalTriggerManager.ts +84 -0
- package/src/types/index.ts +1 -1
- package/dist/types/src/components/TriggerEditor/email.d.ts.map +0 -1
- package/dist/types/src/components/TriggerEditor/invokation-handler.d.ts.map +0 -1
- package/dist/types/src/types/chain.d.ts.map +0 -1
- /package/dist/lib/browser/{PromptContainer-3GUENQHE.mjs.map → PromptContainer-6CBNCUKQ.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-2FOJUVYG.mjs.map → chunk-CJMV64XO.mjs.map} +0 -0
- /package/dist/lib/node/{PromptContainer-74ZRO4HK.cjs.map → PromptContainer-7RCGCU3K.cjs.map} +0 -0
- /package/dist/lib/node/{chunk-4TMTUB4X.cjs.map → chunk-YGRHTCOX.cjs.map} +0 -0
- /package/dist/lib/node-esm/{PromptContainer-5OK4GWIR.mjs.map → PromptContainer-4SCHQV5C.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-FN6DOJZP.mjs.map → chunk-62AB5HXX.mjs.map} +0 -0
- /package/dist/types/src/{components/TriggerEditor → hooks}/email.d.ts +0 -0
- /package/src/{components/TriggerEditor → hooks}/email.ts +0 -0
- /package/src/types/{chain.ts → schema.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutomationPlugin.d.ts","sourceRoot":"","sources":["../../../src/AutomationPlugin.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,gBAAgB,EAA8C,MAAM,qBAAqB,CAAC;AAUxG,OAAO,EAAoB,KAAK,wBAAwB,EAA8B,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"AutomationPlugin.d.ts","sourceRoot":"","sources":["../../../src/AutomationPlugin.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,gBAAgB,EAA8C,MAAM,qBAAqB,CAAC;AAUxG,OAAO,EAAoB,KAAK,wBAAwB,EAA8B,MAAM,SAAS,CAAC;AAEtG,eAAO,MAAM,gBAAgB,QAAO,gBAAgB,CAAC,wBAAwB,CAwI5E,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { FunctionTrigger } from '@dxos/functions/types';
|
|
2
|
+
import { type FunctionTrigger } from '@dxos/functions/types';
|
|
3
3
|
import { type Space } from '@dxos/react-client/echo';
|
|
4
|
-
export
|
|
4
|
+
export type TriggerEditorProps = {
|
|
5
5
|
space: Space;
|
|
6
6
|
trigger: FunctionTrigger;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
|
+
export declare const TriggerEditor: ({ space, trigger }: TriggerEditorProps) => React.JSX.Element;
|
|
8
9
|
//# sourceMappingURL=TriggerEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TriggerEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/TriggerEditor/TriggerEditor.tsx"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"TriggerEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/TriggerEditor/TriggerEditor.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA+D,MAAM,OAAO,CAAC;AAEpF,OAAO,EAGL,KAAK,eAAe,EAOrB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAU,KAAK,KAAK,EAAY,MAAM,yBAAyB,CAAC;AAYvE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,eAAe,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,aAAa,uBAAwB,kBAAkB,sBA2LnE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TriggerEditor.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/TriggerEditor/TriggerEditor.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAmD7C,eAAO,MAAM,OAAO,IAAK,CAAC;AAE1B,QAAA,MAAM,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"TriggerEditor.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/TriggerEditor/TriggerEditor.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAmD7C,eAAO,MAAM,OAAO,IAAK,CAAC;AAE1B,QAAA,MAAM,IAAI,EAAE,IAqBX,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../../../src/components/TriggerEditor/meta.tsx"],"names":[],"mappings":"AAIA,OAAc,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI7D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AActD,KAAK,SAAS,GAAG,MAAM,CAAC;AAgBxB,eAAO,MAAM,KAAK;aALX,GAAG,EAAE;oBACY,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC;EAI4B,CAAC;AAO3E,KAAK,SAAS,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzD,KAAK,aAAa,CAAC,CAAC,IAAI;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC,CAAC;IACvB,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;CAC7B,CAAC;AAIF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,YAC1B,eAAe,WACf,UAAU,KAClB,aAAa,CAAC,GAAG,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../../../src/components/TriggerEditor/meta.tsx"],"names":[],"mappings":"AAIA,OAAc,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI7D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AActD,KAAK,SAAS,GAAG,MAAM,CAAC;AAgBxB,eAAO,MAAM,KAAK;aALX,GAAG,EAAE;oBACY,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC;EAI4B,CAAC;AAO3E,KAAK,SAAS,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzD,KAAK,aAAa,CAAC,CAAC,IAAI;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC,CAAC;IACvB,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;CAC7B,CAAC;AAIF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,YAC1B,eAAe,WACf,UAAU,KAClB,aAAa,CAAC,GAAG,CAAC,GAAG,SAWvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../../../src/hooks/email.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,KAAK,EAAU,MAAM,yBAAyB,CAAC;AAE7D,eAAO,MAAM,SAAS,iCAAiC,CAAC;AAExD,eAAO,MAAM,WAAW,UAAiB,KAAK,QAAQ,GAAG,oBAmCxD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAIA,cAAc,0BAA0B,CAAC"}
|
|
@@ -2,4 +2,4 @@ import { type FunctionTrigger } from '@dxos/functions';
|
|
|
2
2
|
import { type Client } from '@dxos/react-client';
|
|
3
3
|
import { type Space } from '@dxos/react-client/echo';
|
|
4
4
|
export declare const invokeFunction: (client: Client, space: Space, trigger: FunctionTrigger, data: any) => Promise<number>;
|
|
5
|
-
//# sourceMappingURL=
|
|
5
|
+
//# sourceMappingURL=invocation-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invocation-handler.d.ts","sourceRoot":"","sources":["../../../../src/hooks/invocation-handler.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAKvD,OAAO,EAAE,KAAK,MAAM,EAAe,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAkCrD,eAAO,MAAM,cAAc,WAAkB,MAAM,SAAS,KAAK,WAAW,eAAe,QAAQ,GAAG,oBA4BrG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLocalTriggerManager.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useLocalTriggerManager.ts"],"names":[],"mappings":"AAaA,OAAO,EAAU,KAAK,KAAK,EAAY,MAAM,yBAAyB,CAAC;AAMvE,eAAO,MAAM,sBAAsB,UAAW,KAAK,SAgElD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAIA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/types/schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAE,CAAC,EAAe,MAAM,mBAAmB,CAAC;AAGxD,oBAAY,cAAc;IACxB,KAAK,IAAI;IACT,YAAY,IAAI;IAChB,SAAS,IAAI;IACb,QAAQ,IAAI;IACZ,KAAK,IAAI;IACT,QAAQ,IAAI;IACZ,OAAO,IAAI;IACX,MAAM,IAAI;CACX;AAED,eAAO,MAAM,gBAAgB;;;;GAM5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;AAEhE,qBAAa,eAAgB,SAAQ,oBAInC;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEL,qBAAa,SAAU,SAAQ,cAG7B;CAAG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-automation",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1-staging.599df14",
|
|
4
4
|
"description": "Prompt chain plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -44,34 +44,35 @@
|
|
|
44
44
|
"@codemirror/search": "^6.5.6",
|
|
45
45
|
"@codemirror/state": "^6.4.1",
|
|
46
46
|
"@codemirror/view": "^6.34.1",
|
|
47
|
-
"@effect/schema": "^0.75.
|
|
47
|
+
"@effect/schema": "^0.75.5",
|
|
48
48
|
"@preact/signals-core": "^1.6.0",
|
|
49
49
|
"lodash.get": "^4.4.2",
|
|
50
|
-
"@dxos/app-framework": "0.7.
|
|
51
|
-
"@dxos/async": "0.7.
|
|
52
|
-
"@dxos/chain": "0.7.
|
|
53
|
-
"@dxos/context": "0.7.
|
|
54
|
-
"@dxos/echo-db": "0.7.
|
|
55
|
-
"@dxos/echo-schema": "0.7.
|
|
56
|
-
"@dxos/functions": "0.7.
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/plugin-chess": "0.7.
|
|
61
|
-
"@dxos/plugin-client": "0.7.
|
|
62
|
-
"@dxos/plugin-deck": "0.7.
|
|
63
|
-
"@dxos/plugin-
|
|
64
|
-
"@dxos/plugin-
|
|
65
|
-
"@dxos/plugin-ipfs": "0.7.
|
|
66
|
-
"@dxos/plugin-
|
|
67
|
-
"@dxos/plugin-sketch": "0.7.
|
|
68
|
-
"@dxos/plugin-
|
|
69
|
-
"@dxos/plugin-
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/react-ui-
|
|
73
|
-
"@dxos/react-ui-
|
|
74
|
-
"@dxos/util": "0.7.
|
|
50
|
+
"@dxos/app-framework": "0.7.1-staging.599df14",
|
|
51
|
+
"@dxos/async": "0.7.1-staging.599df14",
|
|
52
|
+
"@dxos/chain": "0.7.1-staging.599df14",
|
|
53
|
+
"@dxos/context": "0.7.1-staging.599df14",
|
|
54
|
+
"@dxos/echo-db": "0.7.1-staging.599df14",
|
|
55
|
+
"@dxos/echo-schema": "0.7.1-staging.599df14",
|
|
56
|
+
"@dxos/functions": "0.7.1-staging.599df14",
|
|
57
|
+
"@dxos/invariant": "0.7.1-staging.599df14",
|
|
58
|
+
"@dxos/keys": "0.7.1-staging.599df14",
|
|
59
|
+
"@dxos/log": "0.7.1-staging.599df14",
|
|
60
|
+
"@dxos/plugin-chess": "0.7.1-staging.599df14",
|
|
61
|
+
"@dxos/plugin-client": "0.7.1-staging.599df14",
|
|
62
|
+
"@dxos/plugin-deck": "0.7.1-staging.599df14",
|
|
63
|
+
"@dxos/plugin-graph": "0.7.1-staging.599df14",
|
|
64
|
+
"@dxos/plugin-inbox": "0.7.1-staging.599df14",
|
|
65
|
+
"@dxos/plugin-ipfs": "0.7.1-staging.599df14",
|
|
66
|
+
"@dxos/plugin-script": "0.7.1-staging.599df14",
|
|
67
|
+
"@dxos/plugin-sketch": "0.7.1-staging.599df14",
|
|
68
|
+
"@dxos/plugin-markdown": "0.7.1-staging.599df14",
|
|
69
|
+
"@dxos/plugin-space": "0.7.1-staging.599df14",
|
|
70
|
+
"@dxos/plugin-stack": "0.7.1-staging.599df14",
|
|
71
|
+
"@dxos/react-client": "0.7.1-staging.599df14",
|
|
72
|
+
"@dxos/react-ui-editor": "0.7.1-staging.599df14",
|
|
73
|
+
"@dxos/react-ui-form": "0.7.1-staging.599df14",
|
|
74
|
+
"@dxos/util": "0.7.1-staging.599df14",
|
|
75
|
+
"@dxos/schema": "0.7.1-staging.599df14"
|
|
75
76
|
},
|
|
76
77
|
"devDependencies": {
|
|
77
78
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -81,18 +82,18 @@
|
|
|
81
82
|
"react": "~18.2.0",
|
|
82
83
|
"react-dom": "~18.2.0",
|
|
83
84
|
"vite": "5.4.7",
|
|
84
|
-
"@dxos/echo-db": "0.7.
|
|
85
|
-
"@dxos/random": "0.7.
|
|
86
|
-
"@dxos/react-ui": "0.7.
|
|
87
|
-
"@dxos/react-ui
|
|
88
|
-
"@dxos/storybook-utils": "0.7.
|
|
85
|
+
"@dxos/echo-db": "0.7.1-staging.599df14",
|
|
86
|
+
"@dxos/random": "0.7.1-staging.599df14",
|
|
87
|
+
"@dxos/react-ui-theme": "0.7.1-staging.599df14",
|
|
88
|
+
"@dxos/react-ui": "0.7.1-staging.599df14",
|
|
89
|
+
"@dxos/storybook-utils": "0.7.1-staging.599df14"
|
|
89
90
|
},
|
|
90
91
|
"peerDependencies": {
|
|
91
92
|
"@phosphor-icons/react": "^2.1.5",
|
|
92
93
|
"react": "~18.2.0",
|
|
93
94
|
"react-dom": "~18.2.0",
|
|
94
|
-
"@dxos/react-ui": "0.7.
|
|
95
|
-
"@dxos/react-ui
|
|
95
|
+
"@dxos/react-ui-theme": "0.7.1-staging.599df14",
|
|
96
|
+
"@dxos/react-ui": "0.7.1-staging.599df14"
|
|
96
97
|
},
|
|
97
98
|
"publishConfig": {
|
|
98
99
|
"access": "public"
|
package/src/AutomationPlugin.tsx
CHANGED
|
@@ -16,9 +16,6 @@ import meta, { AUTOMATION_PLUGIN } from './meta';
|
|
|
16
16
|
import translations from './translations';
|
|
17
17
|
import { AutomationAction, type AutomationPluginProvides, ChainPromptType, ChainType } from './types';
|
|
18
18
|
|
|
19
|
-
// TODO(burdon): Prompt article.
|
|
20
|
-
// TODO(burdon): Trigger panel.
|
|
21
|
-
|
|
22
19
|
export const AutomationPlugin = (): PluginDefinition<AutomationPluginProvides> => {
|
|
23
20
|
return {
|
|
24
21
|
meta,
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
5
7
|
import { type Meta } from '@storybook/react';
|
|
6
8
|
import React, { useEffect, useState } from 'react';
|
|
7
9
|
|
|
@@ -64,14 +66,13 @@ const meta: Meta = {
|
|
|
64
66
|
createIdentity: true,
|
|
65
67
|
createSpace: true,
|
|
66
68
|
types: [FunctionTrigger, FunctionDef, ChainPromptType],
|
|
67
|
-
|
|
68
|
-
const space = client.spaces.default;
|
|
69
|
+
onSpaceCreated: ({ space }) => {
|
|
69
70
|
for (const fn of functions) {
|
|
70
71
|
space.db.add(create(FunctionDef, fn));
|
|
71
72
|
}
|
|
72
73
|
},
|
|
73
74
|
}),
|
|
74
|
-
withLayout({ fullscreen: true, classNames: 'flex justify-center m-2' }),
|
|
75
|
+
withLayout({ fullscreen: true, tooltips: true, classNames: 'flex justify-center m-2' }),
|
|
75
76
|
withTheme,
|
|
76
77
|
],
|
|
77
78
|
parameters: {
|
|
@@ -2,110 +2,51 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { type ChangeEventHandler, type FC, useEffect, useMemo
|
|
5
|
+
import React, { type ChangeEventHandler, type FC, useEffect, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { Mutex } from '@dxos/async';
|
|
8
|
-
import { Context } from '@dxos/context';
|
|
9
|
-
import { createSubscriptionTrigger, createWebsocketTrigger, type TriggerFactory } from '@dxos/functions';
|
|
10
7
|
import {
|
|
11
|
-
|
|
8
|
+
FunctionTriggerSchema,
|
|
12
9
|
type FunctionTriggerType,
|
|
10
|
+
type FunctionTrigger,
|
|
13
11
|
type SubscriptionTrigger,
|
|
14
12
|
type TimerTrigger,
|
|
15
|
-
type
|
|
13
|
+
type TriggerType,
|
|
14
|
+
type TriggerKind,
|
|
16
15
|
type WebhookTrigger,
|
|
17
16
|
type WebsocketTrigger,
|
|
18
17
|
} from '@dxos/functions/types';
|
|
19
|
-
import {
|
|
18
|
+
import { invariant } from '@dxos/invariant';
|
|
20
19
|
import { ScriptType } from '@dxos/plugin-script/types';
|
|
21
|
-
import { useClient } from '@dxos/react-client';
|
|
22
20
|
import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
|
|
23
21
|
import { Input, Select, useTranslation } from '@dxos/react-ui';
|
|
22
|
+
import { Form, SelectInput } from '@dxos/react-ui-form';
|
|
24
23
|
import { distinctBy } from '@dxos/util';
|
|
25
24
|
|
|
26
25
|
import { InputRow } from './Form';
|
|
27
|
-
import { invokeFunction } from './invokation-handler';
|
|
28
26
|
import { getFunctionMetaExtension, state } from './meta';
|
|
27
|
+
import { useLocalTriggerManager } from '../../hooks';
|
|
29
28
|
import { AUTOMATION_PLUGIN } from '../../meta';
|
|
30
29
|
|
|
31
|
-
const triggerTypes:
|
|
30
|
+
const triggerTypes: TriggerKind[] = ['timer', 'webhook', 'websocket', 'subscription'];
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
export type TriggerEditorProps = {
|
|
33
|
+
space: Space;
|
|
34
|
+
trigger: FunctionTrigger;
|
|
35
|
+
};
|
|
34
36
|
|
|
35
|
-
export const TriggerEditor = ({ space, trigger }:
|
|
37
|
+
export const TriggerEditor = ({ space, trigger }: TriggerEditorProps) => {
|
|
36
38
|
const { t } = useTranslation(AUTOMATION_PLUGIN);
|
|
37
|
-
const client = useClient();
|
|
38
39
|
const scripts = useQuery(space, Filter.schema(ScriptType));
|
|
39
40
|
const script = useMemo(() => scripts.find((script) => script.id === trigger.function), [trigger.function, scripts]);
|
|
41
|
+
useLocalTriggerManager(space);
|
|
40
42
|
|
|
41
|
-
const triggerLabels: Record<
|
|
43
|
+
const triggerLabels: Record<TriggerKind, string> = {
|
|
42
44
|
subscription: t('trigger type subscription'),
|
|
43
45
|
timer: t('trigger type timer'),
|
|
44
46
|
webhook: t('trigger type webhook'),
|
|
45
47
|
websocket: t('trigger type websocket'),
|
|
46
48
|
};
|
|
47
49
|
|
|
48
|
-
// TODO(burdon): Factor out, creating context for plugin (runs outside of component).
|
|
49
|
-
const [registry] = useState(new Map<string, Context>());
|
|
50
|
-
const triggers = useQuery(space, Filter.schema(FunctionTrigger));
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
setTimeout(async () => {
|
|
53
|
-
// Mark-and-sweep removing disabled triggers.
|
|
54
|
-
await registerTriggersMutex.executeSynchronized(async () => {
|
|
55
|
-
const deprecated = new Set(Array.from(registry.keys()));
|
|
56
|
-
log.info('triggers', {
|
|
57
|
-
deprecated,
|
|
58
|
-
all: triggers.map((t) => t.id),
|
|
59
|
-
enabled: triggers.filter((t) => t.enabled).map((t) => t.id),
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
for (const trigger of triggers) {
|
|
63
|
-
if (trigger.enabled) {
|
|
64
|
-
if (registry.has(trigger.id)) {
|
|
65
|
-
deprecated.delete(trigger.id);
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
log.info('activating trigger', trigger.id);
|
|
69
|
-
|
|
70
|
-
const ctx = new Context();
|
|
71
|
-
registry.set(trigger.id, ctx);
|
|
72
|
-
const triggerSpec = trigger.spec;
|
|
73
|
-
|
|
74
|
-
let triggerFactory: TriggerFactory<any>;
|
|
75
|
-
if (triggerSpec.type === 'subscription') {
|
|
76
|
-
triggerFactory = createSubscriptionTrigger;
|
|
77
|
-
} else if (triggerSpec.type === 'websocket') {
|
|
78
|
-
triggerFactory = createWebsocketTrigger;
|
|
79
|
-
} else {
|
|
80
|
-
log.info('unsupported trigger', { type: triggerSpec.type });
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
await triggerFactory(ctx, space, trigger.spec, (data: any) => {
|
|
85
|
-
return invokeFunction(client, space, trigger, data);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
for (const id of deprecated) {
|
|
91
|
-
const ctx = registry.get(id);
|
|
92
|
-
if (ctx) {
|
|
93
|
-
await ctx.dispose();
|
|
94
|
-
registry.delete(id);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
}, [JSON.stringify(triggers)]);
|
|
100
|
-
|
|
101
|
-
useEffect(() => {
|
|
102
|
-
return () => {
|
|
103
|
-
for (const ctx of registry.values()) {
|
|
104
|
-
void ctx.dispose();
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
}, []);
|
|
108
|
-
|
|
109
50
|
useEffect(() => {
|
|
110
51
|
void space.db.schemaRegistry
|
|
111
52
|
.query()
|
|
@@ -121,9 +62,10 @@ export const TriggerEditor = ({ space, trigger }: { space: Space; trigger: Funct
|
|
|
121
62
|
// Keen an enriched version of the schema in memory so we can share it with prompt editor.
|
|
122
63
|
useEffect(() => {
|
|
123
64
|
const spec = trigger.spec;
|
|
65
|
+
invariant(spec);
|
|
124
66
|
if (spec.type === 'subscription') {
|
|
125
|
-
if (spec.filter
|
|
126
|
-
const type = spec.filter
|
|
67
|
+
if (spec.filter) {
|
|
68
|
+
const type = spec.filter.type;
|
|
127
69
|
const foundSchema = state.schemas.find((schema) => schema.typename === type);
|
|
128
70
|
if (foundSchema) {
|
|
129
71
|
state.selectedSchema[trigger.id] = foundSchema;
|
|
@@ -148,9 +90,9 @@ export const TriggerEditor = ({ space, trigger }: { space: Space; trigger: Funct
|
|
|
148
90
|
};
|
|
149
91
|
|
|
150
92
|
const handleSelectTriggerType = (triggerType: string) => {
|
|
151
|
-
switch (triggerType as
|
|
93
|
+
switch (triggerType as TriggerKind) {
|
|
152
94
|
case 'subscription': {
|
|
153
|
-
trigger.spec = { type: 'subscription', filter:
|
|
95
|
+
trigger.spec = { type: 'subscription', filter: {} };
|
|
154
96
|
break;
|
|
155
97
|
}
|
|
156
98
|
case 'timer': {
|
|
@@ -171,6 +113,47 @@ export const TriggerEditor = ({ space, trigger }: { space: Space; trigger: Funct
|
|
|
171
113
|
|
|
172
114
|
const TriggerMeta = getFunctionMetaExtension(trigger, script)?.component;
|
|
173
115
|
|
|
116
|
+
const test = true;
|
|
117
|
+
if (test) {
|
|
118
|
+
const object: FunctionTriggerType = {
|
|
119
|
+
spec: {
|
|
120
|
+
// type: 'timer',
|
|
121
|
+
type: 'subscription',
|
|
122
|
+
// cron: '0 0 * * *'
|
|
123
|
+
filter: { type: 'dxos.org/type/Event' },
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<Form<FunctionTriggerType>
|
|
129
|
+
schema={FunctionTriggerSchema}
|
|
130
|
+
values={object}
|
|
131
|
+
filter={(props) => props.filter((p) => p.name !== 'meta')}
|
|
132
|
+
Custom={{
|
|
133
|
+
['function' satisfies keyof FunctionTriggerType]: (props) => (
|
|
134
|
+
<SelectInput<FunctionTriggerType>
|
|
135
|
+
{...props}
|
|
136
|
+
// TODO(burdon): Query for functions.
|
|
137
|
+
options={[].map((value) => ({
|
|
138
|
+
value,
|
|
139
|
+
label: value,
|
|
140
|
+
}))}
|
|
141
|
+
/>
|
|
142
|
+
),
|
|
143
|
+
['spec.type' as const]: (props) => (
|
|
144
|
+
<SelectInput<FunctionTriggerType>
|
|
145
|
+
{...props}
|
|
146
|
+
options={['timer', 'subscription'].map((value) => ({
|
|
147
|
+
value,
|
|
148
|
+
label: value,
|
|
149
|
+
}))}
|
|
150
|
+
/>
|
|
151
|
+
),
|
|
152
|
+
}}
|
|
153
|
+
/>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
174
157
|
return (
|
|
175
158
|
<div className='flex flex-col py-1'>
|
|
176
159
|
<table className='is-full table-fixed'>
|
|
@@ -216,7 +199,7 @@ export const TriggerEditor = ({ space, trigger }: { space: Space; trigger: Funct
|
|
|
216
199
|
</InputRow>
|
|
217
200
|
</tbody>
|
|
218
201
|
<tbody>
|
|
219
|
-
{trigger.spec && <
|
|
202
|
+
{trigger.spec && <TriggerType space={space} spec={trigger.spec} />}
|
|
220
203
|
<InputRow label={t('function enabled')}>
|
|
221
204
|
{/* TODO(burdon): Hack to make the switch the same height as other controls. */}
|
|
222
205
|
<div className='flex items-center h-8'>
|
|
@@ -224,7 +207,7 @@ export const TriggerEditor = ({ space, trigger }: { space: Space; trigger: Funct
|
|
|
224
207
|
</div>
|
|
225
208
|
</InputRow>
|
|
226
209
|
</tbody>
|
|
227
|
-
{TriggerMeta && (
|
|
210
|
+
{TriggerMeta && trigger.meta && (
|
|
228
211
|
<tbody>
|
|
229
212
|
<tr>
|
|
230
213
|
<td />
|
|
@@ -251,13 +234,13 @@ const TriggerSpecSubscription = ({ spec }: TriggerSpecProps<SubscriptionTrigger>
|
|
|
251
234
|
}
|
|
252
235
|
|
|
253
236
|
const handleValueChange = (typename: string) => {
|
|
254
|
-
spec.filter =
|
|
237
|
+
spec.filter = { type: typename };
|
|
255
238
|
};
|
|
256
239
|
|
|
257
240
|
return (
|
|
258
241
|
<>
|
|
259
242
|
<InputRow label={t('trigger filter')}>
|
|
260
|
-
<Select.Root value={spec.filter
|
|
243
|
+
<Select.Root value={spec.filter?.type} onValueChange={handleValueChange}>
|
|
261
244
|
<Select.TriggerButton classNames='w-full' placeholder={'Select type'} />
|
|
262
245
|
<Select.Portal>
|
|
263
246
|
<Select.Content>
|
|
@@ -344,10 +327,10 @@ const TriggerSpecWebsocket = ({ spec }: TriggerSpecProps<WebsocketTrigger>) => {
|
|
|
344
327
|
// Trigger spec.
|
|
345
328
|
//
|
|
346
329
|
|
|
347
|
-
type TriggerSpecProps<T =
|
|
330
|
+
type TriggerSpecProps<T = TriggerType> = { space: Space; spec: T };
|
|
348
331
|
|
|
349
332
|
const triggerRenderers: {
|
|
350
|
-
[key in
|
|
333
|
+
[key in TriggerKind]: FC<TriggerSpecProps<any>>;
|
|
351
334
|
} = {
|
|
352
335
|
subscription: TriggerSpecSubscription,
|
|
353
336
|
timer: TriggerSpecTimer,
|
|
@@ -355,7 +338,7 @@ const triggerRenderers: {
|
|
|
355
338
|
websocket: TriggerSpecWebsocket,
|
|
356
339
|
};
|
|
357
340
|
|
|
358
|
-
const
|
|
341
|
+
const TriggerType = ({ space, spec }: TriggerSpecProps) => {
|
|
359
342
|
const Component = triggerRenderers[spec.type];
|
|
360
343
|
return Component ? <Component space={space} spec={spec} /> : null;
|
|
361
344
|
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { sleep } from '@dxos/async';
|
|
6
6
|
import { getObjectCore } from '@dxos/echo-db';
|
|
7
|
-
import type
|
|
7
|
+
import { type AnyObjectData } from '@dxos/echo-schema';
|
|
8
8
|
import { type FunctionTrigger } from '@dxos/functions';
|
|
9
9
|
import { invariant } from '@dxos/invariant';
|
|
10
10
|
import { DXN, LOCAL_SPACE_TAG } from '@dxos/keys';
|
|
@@ -47,13 +47,15 @@ const callFunction = async (funcUrl: string, trigger: any, data: any) => {
|
|
|
47
47
|
|
|
48
48
|
export const invokeFunction = async (client: Client, space: Space, trigger: FunctionTrigger, data: any) => {
|
|
49
49
|
try {
|
|
50
|
+
invariant(trigger.spec);
|
|
51
|
+
invariant(trigger.function);
|
|
50
52
|
if (trigger.spec.type === 'websocket') {
|
|
51
53
|
return handleEmail(space, data.data);
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
const script = await space.crud.query({ id: trigger.function }).first();
|
|
55
57
|
const { objects: functions } = await space.crud.query({ __typename: FunctionType.typename }).run();
|
|
56
|
-
const func = functions.find((fn) => referenceEquals(fn.source, trigger.function)) as AnyObjectData | undefined;
|
|
58
|
+
const func = functions.find((fn) => referenceEquals(fn.source, trigger.function!)) as AnyObjectData | undefined;
|
|
57
59
|
const funcSlug = func?.__meta.keys.find((key) => key.source === USERFUNCTIONS_META_KEY)?.id;
|
|
58
60
|
if (!funcSlug) {
|
|
59
61
|
log.warn('function not deployed', { scriptId: script.id, name: script.name });
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useEffect, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Mutex } from '@dxos/async';
|
|
8
|
+
import { Context } from '@dxos/context';
|
|
9
|
+
import { createSubscriptionTrigger, createWebsocketTrigger, type TriggerFactory } from '@dxos/functions';
|
|
10
|
+
import { FunctionTrigger } from '@dxos/functions/types';
|
|
11
|
+
import { invariant } from '@dxos/invariant';
|
|
12
|
+
import { log } from '@dxos/log';
|
|
13
|
+
import { useClient } from '@dxos/react-client';
|
|
14
|
+
import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
|
|
15
|
+
|
|
16
|
+
import { invokeFunction } from './invocation-handler';
|
|
17
|
+
|
|
18
|
+
const registerTriggersMutex = new Mutex();
|
|
19
|
+
|
|
20
|
+
export const useLocalTriggerManager = (space: Space) => {
|
|
21
|
+
const client = useClient();
|
|
22
|
+
|
|
23
|
+
// TODO(burdon): Factor out, creating context for plugin (runs outside of component).
|
|
24
|
+
const [registry] = useState(new Map<string, Context>());
|
|
25
|
+
const triggers = useQuery(space, Filter.schema(FunctionTrigger));
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
setTimeout(async () => {
|
|
28
|
+
// Mark-and-sweep removing disabled triggers.
|
|
29
|
+
await registerTriggersMutex.executeSynchronized(async () => {
|
|
30
|
+
const deprecated = new Set(Array.from(registry.keys()));
|
|
31
|
+
log('triggers', {
|
|
32
|
+
deprecated,
|
|
33
|
+
all: triggers.map((t) => t.id),
|
|
34
|
+
enabled: triggers.filter((t) => t.enabled).map((t) => t.id),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
for (const trigger of triggers) {
|
|
38
|
+
if (trigger.enabled) {
|
|
39
|
+
if (registry.has(trigger.id)) {
|
|
40
|
+
deprecated.delete(trigger.id);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
log.info('activating trigger', trigger.id);
|
|
44
|
+
|
|
45
|
+
const ctx = new Context();
|
|
46
|
+
registry.set(trigger.id, ctx);
|
|
47
|
+
const triggerSpec = trigger.spec;
|
|
48
|
+
invariant(triggerSpec);
|
|
49
|
+
|
|
50
|
+
let triggerFactory: TriggerFactory<any>;
|
|
51
|
+
if (triggerSpec.type === 'subscription') {
|
|
52
|
+
triggerFactory = createSubscriptionTrigger;
|
|
53
|
+
} else if (triggerSpec.type === 'websocket') {
|
|
54
|
+
triggerFactory = createWebsocketTrigger;
|
|
55
|
+
} else {
|
|
56
|
+
log.info('unsupported trigger', { type: triggerSpec.type });
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
await triggerFactory(ctx, space, trigger.spec, (data: any) => {
|
|
61
|
+
return invokeFunction(client, space, trigger, data);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
for (const id of deprecated) {
|
|
67
|
+
const ctx = registry.get(id);
|
|
68
|
+
if (ctx) {
|
|
69
|
+
await ctx.dispose();
|
|
70
|
+
registry.delete(id);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}, [JSON.stringify(triggers)]);
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
return () => {
|
|
79
|
+
for (const ctx of registry.values()) {
|
|
80
|
+
void ctx.dispose();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}, []);
|
|
84
|
+
};
|
package/src/types/index.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../../../../src/components/TriggerEditor/email.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,KAAK,EAAU,MAAM,yBAAyB,CAAC;AAE7D,eAAO,MAAM,SAAS,iCAAiC,CAAC;AAExD,eAAO,MAAM,WAAW,UAAiB,KAAK,QAAQ,GAAG,oBAmCxD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invokation-handler.d.ts","sourceRoot":"","sources":["../../../../../src/components/TriggerEditor/invokation-handler.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAKvD,OAAO,EAAE,KAAK,MAAM,EAAe,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAkCrD,eAAO,MAAM,cAAc,WAAkB,MAAM,SAAS,KAAK,WAAW,eAAe,QAAQ,GAAG,oBA0BrG,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../../src/types/chain.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAE,CAAC,EAAe,MAAM,mBAAmB,CAAC;AAGxD,oBAAY,cAAc;IACxB,KAAK,IAAI;IACT,YAAY,IAAI;IAChB,SAAS,IAAI;IACb,QAAQ,IAAI;IACZ,KAAK,IAAI;IACT,QAAQ,IAAI;IACZ,OAAO,IAAI;IACX,MAAM,IAAI;CACX;AAED,eAAO,MAAM,gBAAgB;;;;GAM5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;AAEhE,qBAAa,eAAgB,SAAQ,oBAInC;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEL,qBAAa,SAAU,SAAQ,cAG7B;CAAG"}
|
/package/dist/lib/browser/{PromptContainer-3GUENQHE.mjs.map → PromptContainer-6CBNCUKQ.mjs.map}
RENAMED
|
File without changes
|