@dxos/plugin-automation 0.8.2-main.fbd8ed0 → 0.8.2-staging.7ac8446

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.
Files changed (168) hide show
  1. package/dist/lib/browser/{chunk-2QF27UJ2.mjs → AutomationPanel-YAHFXQX6.mjs} +23 -24
  2. package/dist/lib/browser/AutomationPanel-YAHFXQX6.mjs.map +7 -0
  3. package/dist/lib/browser/app-graph-builder-K3BIQFWW.mjs +40 -0
  4. package/dist/lib/browser/app-graph-builder-K3BIQFWW.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-FALBBJNO.mjs +138 -0
  6. package/dist/lib/browser/chunk-FALBBJNO.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-MT3FZH4V.mjs +8 -0
  8. package/dist/lib/browser/chunk-MT3FZH4V.mjs.map +7 -0
  9. package/dist/lib/browser/index.mjs +19 -25
  10. package/dist/lib/browser/index.mjs.map +3 -3
  11. package/dist/lib/browser/meta.json +1 -1
  12. package/dist/lib/browser/react-surface-4QQSJR4A.mjs +42 -0
  13. package/dist/lib/browser/react-surface-4QQSJR4A.mjs.map +7 -0
  14. package/dist/lib/node/{chunk-TI3WBQIB.cjs → AutomationPanel-ZKAMIU6O.cjs} +26 -31
  15. package/dist/lib/node/AutomationPanel-ZKAMIU6O.cjs.map +7 -0
  16. package/dist/lib/node/app-graph-builder-HO4FPGZ5.cjs +56 -0
  17. package/dist/lib/node/app-graph-builder-HO4FPGZ5.cjs.map +7 -0
  18. package/dist/lib/node/{chunk-SV2CB3FT.cjs → chunk-AGJ6XTDN.cjs} +7 -16
  19. package/dist/lib/node/chunk-AGJ6XTDN.cjs.map +7 -0
  20. package/dist/lib/node/chunk-FTEDH5Q6.cjs +167 -0
  21. package/dist/lib/node/chunk-FTEDH5Q6.cjs.map +7 -0
  22. package/dist/lib/node/index.cjs +22 -28
  23. package/dist/lib/node/index.cjs.map +3 -3
  24. package/dist/lib/node/meta.json +1 -1
  25. package/dist/lib/node/{react-surface-43VHU36V.cjs → react-surface-52M54VWV.cjs} +15 -39
  26. package/dist/lib/node/react-surface-52M54VWV.cjs.map +7 -0
  27. package/dist/lib/node-esm/{chunk-DIUPZXCQ.mjs → AutomationPanel-XF7YPSKM.mjs} +23 -24
  28. package/dist/lib/node-esm/AutomationPanel-XF7YPSKM.mjs.map +7 -0
  29. package/dist/lib/node-esm/app-graph-builder-XCJR33VS.mjs +41 -0
  30. package/dist/lib/node-esm/app-graph-builder-XCJR33VS.mjs.map +7 -0
  31. package/dist/lib/node-esm/chunk-M4QXMIIB.mjs +139 -0
  32. package/dist/lib/node-esm/chunk-M4QXMIIB.mjs.map +7 -0
  33. package/dist/lib/node-esm/chunk-OA75PSGH.mjs +10 -0
  34. package/dist/lib/node-esm/chunk-OA75PSGH.mjs.map +7 -0
  35. package/dist/lib/node-esm/index.mjs +19 -25
  36. package/dist/lib/node-esm/index.mjs.map +3 -3
  37. package/dist/lib/node-esm/meta.json +1 -1
  38. package/dist/lib/node-esm/react-surface-MGKM3OO3.mjs +43 -0
  39. package/dist/lib/node-esm/react-surface-MGKM3OO3.mjs.map +7 -0
  40. package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
  41. package/dist/types/src/capabilities/app-graph-builder.d.ts +179 -2
  42. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  43. package/dist/types/src/capabilities/index.d.ts +177 -2
  44. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  45. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  46. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +3 -6
  47. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
  48. package/dist/types/src/components/AutomationPanel/index.d.ts +0 -1
  49. package/dist/types/src/components/AutomationPanel/index.d.ts.map +1 -1
  50. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +1 -1
  51. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
  52. package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
  53. package/dist/types/src/components/index.d.ts +1 -8
  54. package/dist/types/src/components/index.d.ts.map +1 -1
  55. package/dist/types/src/testing/test-functions.d.ts.map +1 -1
  56. package/dist/types/src/translations.d.ts +0 -8
  57. package/dist/types/src/translations.d.ts.map +1 -1
  58. package/dist/types/tsconfig.tsbuildinfo +1 -1
  59. package/package.json +24 -36
  60. package/src/AutomationPlugin.tsx +10 -5
  61. package/src/capabilities/app-graph-builder.ts +17 -71
  62. package/src/capabilities/index.ts +0 -1
  63. package/src/capabilities/react-surface.tsx +8 -32
  64. package/src/components/AutomationPanel/AutomationPanel.stories.tsx +5 -5
  65. package/src/components/AutomationPanel/AutomationPanel.tsx +72 -72
  66. package/src/components/AutomationPanel/index.ts +0 -2
  67. package/src/components/TriggerEditor/TriggerEditor.stories.tsx +10 -19
  68. package/src/components/TriggerEditor/TriggerEditor.tsx +93 -53
  69. package/src/components/index.ts +0 -3
  70. package/src/testing/test-functions.ts +9 -23
  71. package/src/translations.ts +1 -10
  72. package/dist/lib/browser/AutomationContainer-DA6IW7O2.mjs +0 -34
  73. package/dist/lib/browser/AutomationContainer-DA6IW7O2.mjs.map +0 -7
  74. package/dist/lib/browser/AutomationPanel-R42D3LDD.mjs +0 -11
  75. package/dist/lib/browser/AutomationPanel-R42D3LDD.mjs.map +0 -7
  76. package/dist/lib/browser/FunctionsContainer-MPBMMOMS.mjs +0 -33
  77. package/dist/lib/browser/FunctionsContainer-MPBMMOMS.mjs.map +0 -7
  78. package/dist/lib/browser/FunctionsPanel-NSI3P53X.mjs +0 -10
  79. package/dist/lib/browser/FunctionsPanel-NSI3P53X.mjs.map +0 -7
  80. package/dist/lib/browser/app-graph-builder-2OGPEVBA.mjs +0 -79
  81. package/dist/lib/browser/app-graph-builder-2OGPEVBA.mjs.map +0 -7
  82. package/dist/lib/browser/chunk-2QF27UJ2.mjs.map +0 -7
  83. package/dist/lib/browser/chunk-ADYCSC6Y.mjs +0 -39
  84. package/dist/lib/browser/chunk-ADYCSC6Y.mjs.map +0 -7
  85. package/dist/lib/browser/chunk-BNQNURZN.mjs +0 -211
  86. package/dist/lib/browser/chunk-BNQNURZN.mjs.map +0 -7
  87. package/dist/lib/browser/chunk-SGT76SL2.mjs +0 -14
  88. package/dist/lib/browser/chunk-SGT76SL2.mjs.map +0 -7
  89. package/dist/lib/browser/chunk-TRC3J2I6.mjs +0 -88
  90. package/dist/lib/browser/chunk-TRC3J2I6.mjs.map +0 -7
  91. package/dist/lib/browser/intent-resolver-X3H6ZSP4.mjs +0 -77
  92. package/dist/lib/browser/intent-resolver-X3H6ZSP4.mjs.map +0 -7
  93. package/dist/lib/browser/react-surface-MOXIHBMS.mjs +0 -68
  94. package/dist/lib/browser/react-surface-MOXIHBMS.mjs.map +0 -7
  95. package/dist/lib/browser/types.mjs +0 -8
  96. package/dist/lib/browser/types.mjs.map +0 -7
  97. package/dist/lib/node/AutomationContainer-FIFH4P5T.cjs +0 -62
  98. package/dist/lib/node/AutomationContainer-FIFH4P5T.cjs.map +0 -7
  99. package/dist/lib/node/AutomationPanel-HTNEWBGB.cjs +0 -32
  100. package/dist/lib/node/AutomationPanel-HTNEWBGB.cjs.map +0 -7
  101. package/dist/lib/node/FunctionsContainer-LF2F6CPE.cjs +0 -61
  102. package/dist/lib/node/FunctionsContainer-LF2F6CPE.cjs.map +0 -7
  103. package/dist/lib/node/FunctionsPanel-6HOAIMQ3.cjs +0 -31
  104. package/dist/lib/node/FunctionsPanel-6HOAIMQ3.cjs.map +0 -7
  105. package/dist/lib/node/app-graph-builder-3XGDVWHR.cjs +0 -95
  106. package/dist/lib/node/app-graph-builder-3XGDVWHR.cjs.map +0 -7
  107. package/dist/lib/node/chunk-CBHWMYKF.cjs +0 -116
  108. package/dist/lib/node/chunk-CBHWMYKF.cjs.map +0 -7
  109. package/dist/lib/node/chunk-GDCG2BML.cjs +0 -58
  110. package/dist/lib/node/chunk-GDCG2BML.cjs.map +0 -7
  111. package/dist/lib/node/chunk-S3Z4AP77.cjs +0 -234
  112. package/dist/lib/node/chunk-S3Z4AP77.cjs.map +0 -7
  113. package/dist/lib/node/chunk-SV2CB3FT.cjs.map +0 -7
  114. package/dist/lib/node/chunk-TI3WBQIB.cjs.map +0 -7
  115. package/dist/lib/node/intent-resolver-Q7WJ4PZZ.cjs +0 -93
  116. package/dist/lib/node/intent-resolver-Q7WJ4PZZ.cjs.map +0 -7
  117. package/dist/lib/node/react-surface-43VHU36V.cjs.map +0 -7
  118. package/dist/lib/node/types.cjs +0 -30
  119. package/dist/lib/node/types.cjs.map +0 -7
  120. package/dist/lib/node-esm/AutomationContainer-OP43F4PD.mjs +0 -35
  121. package/dist/lib/node-esm/AutomationContainer-OP43F4PD.mjs.map +0 -7
  122. package/dist/lib/node-esm/AutomationPanel-ZQKRBWP2.mjs +0 -12
  123. package/dist/lib/node-esm/AutomationPanel-ZQKRBWP2.mjs.map +0 -7
  124. package/dist/lib/node-esm/FunctionsContainer-5TVRDIX5.mjs +0 -34
  125. package/dist/lib/node-esm/FunctionsContainer-5TVRDIX5.mjs.map +0 -7
  126. package/dist/lib/node-esm/FunctionsPanel-NMEW26KL.mjs +0 -11
  127. package/dist/lib/node-esm/FunctionsPanel-NMEW26KL.mjs.map +0 -7
  128. package/dist/lib/node-esm/app-graph-builder-UR2E5CQY.mjs +0 -80
  129. package/dist/lib/node-esm/app-graph-builder-UR2E5CQY.mjs.map +0 -7
  130. package/dist/lib/node-esm/chunk-AD4C4IK2.mjs +0 -89
  131. package/dist/lib/node-esm/chunk-AD4C4IK2.mjs.map +0 -7
  132. package/dist/lib/node-esm/chunk-CUPEMOYK.mjs +0 -16
  133. package/dist/lib/node-esm/chunk-CUPEMOYK.mjs.map +0 -7
  134. package/dist/lib/node-esm/chunk-DIUPZXCQ.mjs.map +0 -7
  135. package/dist/lib/node-esm/chunk-DZ7RKC52.mjs +0 -212
  136. package/dist/lib/node-esm/chunk-DZ7RKC52.mjs.map +0 -7
  137. package/dist/lib/node-esm/chunk-EEA6CZ6B.mjs +0 -40
  138. package/dist/lib/node-esm/chunk-EEA6CZ6B.mjs.map +0 -7
  139. package/dist/lib/node-esm/intent-resolver-HEUGQ6SL.mjs +0 -78
  140. package/dist/lib/node-esm/intent-resolver-HEUGQ6SL.mjs.map +0 -7
  141. package/dist/lib/node-esm/react-surface-TER7JEF6.mjs +0 -69
  142. package/dist/lib/node-esm/react-surface-TER7JEF6.mjs.map +0 -7
  143. package/dist/lib/node-esm/types.mjs +0 -9
  144. package/dist/lib/node-esm/types.mjs.map +0 -7
  145. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  146. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  147. package/dist/types/src/components/AutomationContainer.d.ts +0 -7
  148. package/dist/types/src/components/AutomationContainer.d.ts.map +0 -1
  149. package/dist/types/src/components/FunctionsContainer.d.ts +0 -7
  150. package/dist/types/src/components/FunctionsContainer.d.ts.map +0 -1
  151. package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts +0 -7
  152. package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +0 -1
  153. package/dist/types/src/components/FunctionsPanel/index.d.ts +0 -4
  154. package/dist/types/src/components/FunctionsPanel/index.d.ts.map +0 -1
  155. package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +0 -12
  156. package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +0 -1
  157. package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts +0 -5
  158. package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +0 -1
  159. package/dist/types/src/types.d.ts +0 -25
  160. package/dist/types/src/types.d.ts.map +0 -1
  161. package/src/capabilities/intent-resolver.ts +0 -73
  162. package/src/components/AutomationContainer.tsx +0 -31
  163. package/src/components/FunctionsContainer.tsx +0 -31
  164. package/src/components/FunctionsPanel/FunctionsPanel.tsx +0 -95
  165. package/src/components/FunctionsPanel/index.ts +0 -8
  166. package/src/components/TriggerEditor/FunctionInputEditor.tsx +0 -77
  167. package/src/components/TriggerEditor/SpecSelector.tsx +0 -59
  168. package/src/types.ts +0 -33
@@ -1,78 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- AutomationAction
4
- } from "./chunk-EEA6CZ6B.mjs";
5
- import "./chunk-DZ44LGYT.mjs";
6
-
7
- // packages/plugins/plugin-automation/src/capabilities/intent-resolver.ts
8
- import { contributes, Capabilities, createResolver, createIntent, LayoutAction } from "@dxos/app-framework";
9
- import { Ref } from "@dxos/echo";
10
- import { FunctionTrigger, FunctionType, ScriptType, TriggerKind } from "@dxos/functions";
11
- import { live } from "@dxos/live-object";
12
- import { ATTENDABLE_PATH_SEPARATOR } from "@dxos/plugin-deck/types";
13
- import { SpaceAction } from "@dxos/plugin-space/types";
14
- import { Filter } from "@dxos/react-client/echo";
15
- var intent_resolver_default = (context) => contributes(Capabilities.IntentResolver, [
16
- createResolver({
17
- intent: AutomationAction.CreateTriggerFromTemplate,
18
- resolve: async ({ space, template, enabled = false, scriptName, input }) => {
19
- const trigger = live(FunctionTrigger, {
20
- enabled,
21
- input
22
- });
23
- if (scriptName) {
24
- const { objects: [script] } = await space.db.query(Filter.type(ScriptType, {
25
- name: scriptName
26
- })).run();
27
- if (script) {
28
- const { objects: [fn] } = await space.db.query(Filter.type(FunctionType, {
29
- source: Ref.make(script)
30
- })).run();
31
- if (fn) {
32
- trigger.function = Ref.make(fn);
33
- }
34
- }
35
- }
36
- switch (template.type) {
37
- case "timer": {
38
- trigger.spec = {
39
- kind: TriggerKind.Timer,
40
- cron: template.cron
41
- };
42
- break;
43
- }
44
- case "queue": {
45
- trigger.spec = {
46
- kind: TriggerKind.Queue,
47
- queue: template.queueDXN.toString()
48
- };
49
- break;
50
- }
51
- default: {
52
- break;
53
- }
54
- }
55
- return {
56
- intents: [
57
- createIntent(SpaceAction.AddObject, {
58
- object: trigger,
59
- target: space
60
- }),
61
- createIntent(LayoutAction.Open, {
62
- part: "main",
63
- subject: [
64
- `automation-settings${ATTENDABLE_PATH_SEPARATOR}${space.id}`
65
- ],
66
- options: {
67
- workspace: space.id
68
- }
69
- })
70
- ]
71
- };
72
- }
73
- })
74
- ]);
75
- export {
76
- intent_resolver_default as default
77
- };
78
- //# sourceMappingURL=intent-resolver-HEUGQ6SL.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/intent-resolver.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport {\n contributes,\n Capabilities,\n createResolver,\n type PluginContext,\n createIntent,\n LayoutAction,\n} from '@dxos/app-framework';\nimport { Ref } from '@dxos/echo';\nimport { FunctionTrigger, FunctionType, ScriptType, TriggerKind } from '@dxos/functions';\nimport { type DXN } from '@dxos/keys';\nimport { live } from '@dxos/live-object';\nimport { ATTENDABLE_PATH_SEPARATOR } from '@dxos/plugin-deck/types';\nimport { SpaceAction } from '@dxos/plugin-space/types';\nimport { Filter } from '@dxos/react-client/echo';\n\nimport { AutomationAction } from '../types';\n\nexport default (context: PluginContext) =>\n contributes(Capabilities.IntentResolver, [\n createResolver({\n intent: AutomationAction.CreateTriggerFromTemplate,\n resolve: async ({ space, template, enabled = false, scriptName, input }) => {\n const trigger = live(FunctionTrigger, { enabled, input });\n\n // TODO(wittjosiah): Factor out function lookup by script name?\n if (scriptName) {\n const {\n objects: [script],\n } = await space.db.query(Filter.type(ScriptType, { name: scriptName })).run();\n if (script) {\n const {\n objects: [fn],\n } = await space.db.query(Filter.type(FunctionType, { source: Ref.make(script) })).run();\n if (fn) {\n trigger.function = Ref.make(fn);\n }\n }\n }\n\n switch (template.type) {\n case 'timer': {\n trigger.spec = { kind: TriggerKind.Timer, cron: template.cron };\n break;\n }\n case 'queue': {\n trigger.spec = { kind: TriggerKind.Queue, queue: (template.queueDXN as DXN).toString() };\n break;\n }\n default: {\n break;\n }\n }\n\n return {\n intents: [\n createIntent(SpaceAction.AddObject, { object: trigger, target: space }),\n createIntent(LayoutAction.Open, {\n part: 'main',\n subject: [`automation-settings${ATTENDABLE_PATH_SEPARATOR}${space.id}`],\n options: {\n workspace: space.id,\n },\n }),\n ],\n };\n },\n }),\n ]);\n"],
5
- "mappings": ";;;;;;;AAIA,SACEA,aACAC,cACAC,gBAEAC,cACAC,oBACK;AACP,SAASC,WAAW;AACpB,SAASC,iBAAiBC,cAAcC,YAAYC,mBAAmB;AAEvE,SAASC,YAAY;AACrB,SAASC,iCAAiC;AAC1C,SAASC,mBAAmB;AAC5B,SAASC,cAAc;AAIvB,IAAA,0BAAe,CAACC,YACdC,YAAYC,aAAaC,gBAAgB;EACvCC,eAAe;IACbC,QAAQC,iBAAiBC;IACzBC,SAAS,OAAO,EAAEC,OAAOC,UAAUC,UAAU,OAAOC,YAAYC,MAAK,MAAE;AACrE,YAAMC,UAAUC,KAAKC,iBAAiB;QAAEL;QAASE;MAAM,CAAA;AAGvD,UAAID,YAAY;AACd,cAAM,EACJK,SAAS,CAACC,MAAAA,EAAO,IACf,MAAMT,MAAMU,GAAGC,MAAMC,OAAOC,KAAKC,YAAY;UAAEC,MAAMZ;QAAW,CAAA,CAAA,EAAIa,IAAG;AAC3E,YAAIP,QAAQ;AACV,gBAAM,EACJD,SAAS,CAACS,EAAAA,EAAG,IACX,MAAMjB,MAAMU,GAAGC,MAAMC,OAAOC,KAAKK,cAAc;YAAEC,QAAQC,IAAIC,KAAKZ,MAAAA;UAAQ,CAAA,CAAA,EAAIO,IAAG;AACrF,cAAIC,IAAI;AACNZ,oBAAQiB,WAAWF,IAAIC,KAAKJ,EAAAA;UAC9B;QACF;MACF;AAEA,cAAQhB,SAASY,MAAI;QACnB,KAAK,SAAS;AACZR,kBAAQkB,OAAO;YAAEC,MAAMC,YAAYC;YAAOC,MAAM1B,SAAS0B;UAAK;AAC9D;QACF;QACA,KAAK,SAAS;AACZtB,kBAAQkB,OAAO;YAAEC,MAAMC,YAAYG;YAAOC,OAAQ5B,SAAS6B,SAAiBC,SAAQ;UAAG;AACvF;QACF;QACA,SAAS;AACP;QACF;MACF;AAEA,aAAO;QACLC,SAAS;UACPC,aAAaC,YAAYC,WAAW;YAAEC,QAAQ/B;YAASgC,QAAQrC;UAAM,CAAA;UACrEiC,aAAaK,aAAaC,MAAM;YAC9BC,MAAM;YACNC,SAAS;cAAC,sBAAsBC,yBAAAA,GAA4B1C,MAAM2C,EAAE;;YACpEC,SAAS;cACPC,WAAW7C,MAAM2C;YACnB;UACF,CAAA;;MAEJ;IACF;EACF,CAAA;CACD;",
6
- "names": ["contributes", "Capabilities", "createResolver", "createIntent", "LayoutAction", "Ref", "FunctionTrigger", "FunctionType", "ScriptType", "TriggerKind", "live", "ATTENDABLE_PATH_SEPARATOR", "SpaceAction", "Filter", "context", "contributes", "Capabilities", "IntentResolver", "createResolver", "intent", "AutomationAction", "CreateTriggerFromTemplate", "resolve", "space", "template", "enabled", "scriptName", "input", "trigger", "live", "FunctionTrigger", "objects", "script", "db", "query", "Filter", "type", "ScriptType", "name", "run", "fn", "FunctionType", "source", "Ref", "make", "function", "spec", "kind", "TriggerKind", "Timer", "cron", "Queue", "queue", "queueDXN", "toString", "intents", "createIntent", "SpaceAction", "AddObject", "object", "target", "LayoutAction", "Open", "part", "subject", "ATTENDABLE_PATH_SEPARATOR", "id", "options", "workspace"]
7
- }
@@ -1,69 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- AutomationContainer,
4
- AutomationPanel,
5
- FunctionsContainer
6
- } from "./chunk-CUPEMOYK.mjs";
7
- import "./chunk-DZ7RKC52.mjs";
8
- import {
9
- meta
10
- } from "./chunk-DZ44LGYT.mjs";
11
-
12
- // packages/plugins/plugin-automation/src/capabilities/react-surface.tsx
13
- import React from "react";
14
- import { Capabilities, contributes, createSurface, useLayout } from "@dxos/app-framework";
15
- import { isInstanceOf } from "@dxos/echo-schema";
16
- import { ScriptType } from "@dxos/functions";
17
- import { getSpace, parseId, useSpace } from "@dxos/react-client/echo";
18
- import { StackItem } from "@dxos/react-ui-stack";
19
- var react_surface_default = () => contributes(Capabilities.ReactSurface, [
20
- createSurface({
21
- id: `${meta.id}/space-settings-automation`,
22
- role: "article",
23
- filter: (data) => data.subject === `${meta.id}/space-settings-automation`,
24
- component: () => {
25
- const layout = useLayout();
26
- const { spaceId } = parseId(layout.workspace);
27
- const space = useSpace(spaceId);
28
- if (!space || !spaceId) {
29
- return null;
30
- }
31
- return /* @__PURE__ */ React.createElement(AutomationContainer, {
32
- space
33
- });
34
- }
35
- }),
36
- createSurface({
37
- id: `${meta.id}/space-settings-functions`,
38
- role: "article",
39
- filter: (data) => data.subject === `${meta.id}/space-settings-functions`,
40
- component: () => {
41
- const layout = useLayout();
42
- const { spaceId } = parseId(layout.workspace);
43
- const space = useSpace(spaceId);
44
- if (!space || !spaceId) {
45
- return null;
46
- }
47
- return /* @__PURE__ */ React.createElement(FunctionsContainer, {
48
- space
49
- });
50
- }
51
- }),
52
- createSurface({
53
- id: `${meta.id}/companion/automation`,
54
- role: "article",
55
- filter: (data) => isInstanceOf(ScriptType, data.companionTo) && data.subject === "automation",
56
- component: ({ data, role }) => {
57
- return /* @__PURE__ */ React.createElement(StackItem.Content, {
58
- role
59
- }, /* @__PURE__ */ React.createElement(AutomationPanel, {
60
- space: getSpace(data.companionTo),
61
- object: data.companionTo
62
- }));
63
- }
64
- })
65
- ]);
66
- export {
67
- react_surface_default as default
68
- };
69
- //# sourceMappingURL=react-surface-TER7JEF6.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/react-surface.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Capabilities, contributes, createSurface, useLayout } from '@dxos/app-framework';\nimport { isInstanceOf } from '@dxos/echo-schema';\nimport { ScriptType } from '@dxos/functions';\nimport { getSpace, parseId, useSpace } from '@dxos/react-client/echo';\nimport { StackItem } from '@dxos/react-ui-stack';\n\nimport { AutomationContainer, AutomationPanel, FunctionsContainer } from '../components';\nimport { meta } from '../meta';\n\nexport default () =>\n contributes(Capabilities.ReactSurface, [\n createSurface({\n id: `${meta.id}/space-settings-automation`,\n role: 'article',\n filter: (data): data is { subject: string } => data.subject === `${meta.id}/space-settings-automation`,\n component: () => {\n const layout = useLayout();\n const { spaceId } = parseId(layout.workspace);\n const space = useSpace(spaceId);\n if (!space || !spaceId) {\n return null;\n }\n\n return <AutomationContainer space={space} />;\n },\n }),\n createSurface({\n id: `${meta.id}/space-settings-functions`,\n role: 'article',\n filter: (data): data is { subject: string } => data.subject === `${meta.id}/space-settings-functions`,\n component: () => {\n const layout = useLayout();\n const { spaceId } = parseId(layout.workspace);\n const space = useSpace(spaceId);\n if (!space || !spaceId) {\n return null;\n }\n\n return <FunctionsContainer space={space} />;\n },\n }),\n createSurface({\n id: `${meta.id}/companion/automation`,\n role: 'article',\n filter: (data): data is { companionTo: ScriptType; subject: 'automation' } =>\n isInstanceOf(ScriptType, data.companionTo) && data.subject === 'automation',\n component: ({ data, role }) => {\n return (\n <StackItem.Content role={role}>\n <AutomationPanel space={getSpace(data.companionTo)!} object={data.companionTo} />\n </StackItem.Content>\n );\n },\n }),\n ]);\n"],
5
- "mappings": ";;;;;;;;;;;;AAIA,OAAOA,WAAW;AAElB,SAASC,cAAcC,aAAaC,eAAeC,iBAAiB;AACpE,SAASC,oBAAoB;AAC7B,SAASC,kBAAkB;AAC3B,SAASC,UAAUC,SAASC,gBAAgB;AAC5C,SAASC,iBAAiB;AAK1B,IAAA,wBAAe,MACbC,YAAYC,aAAaC,cAAc;EACrCC,cAAc;IACZC,IAAI,GAAGC,KAAKD,EAAE;IACdE,MAAM;IACNC,QAAQ,CAACC,SAAsCA,KAAKC,YAAY,GAAGJ,KAAKD,EAAE;IAC1EM,WAAW,MAAA;AACT,YAAMC,SAASC,UAAAA;AACf,YAAM,EAAEC,QAAO,IAAKC,QAAQH,OAAOI,SAAS;AAC5C,YAAMC,QAAQC,SAASJ,OAAAA;AACvB,UAAI,CAACG,SAAS,CAACH,SAAS;AACtB,eAAO;MACT;AAEA,aAAO,sBAAA,cAACK,qBAAAA;QAAoBF;;IAC9B;EACF,CAAA;EACAb,cAAc;IACZC,IAAI,GAAGC,KAAKD,EAAE;IACdE,MAAM;IACNC,QAAQ,CAACC,SAAsCA,KAAKC,YAAY,GAAGJ,KAAKD,EAAE;IAC1EM,WAAW,MAAA;AACT,YAAMC,SAASC,UAAAA;AACf,YAAM,EAAEC,QAAO,IAAKC,QAAQH,OAAOI,SAAS;AAC5C,YAAMC,QAAQC,SAASJ,OAAAA;AACvB,UAAI,CAACG,SAAS,CAACH,SAAS;AACtB,eAAO;MACT;AAEA,aAAO,sBAAA,cAACM,oBAAAA;QAAmBH;;IAC7B;EACF,CAAA;EACAb,cAAc;IACZC,IAAI,GAAGC,KAAKD,EAAE;IACdE,MAAM;IACNC,QAAQ,CAACC,SACPY,aAAaC,YAAYb,KAAKc,WAAW,KAAKd,KAAKC,YAAY;IACjEC,WAAW,CAAC,EAAEF,MAAMF,KAAI,MAAE;AACxB,aACE,sBAAA,cAACiB,UAAUC,SAAO;QAAClB;SACjB,sBAAA,cAACmB,iBAAAA;QAAgBT,OAAOU,SAASlB,KAAKc,WAAW;QAAIK,QAAQnB,KAAKc;;IAGxE;EACF,CAAA;CACD;",
6
- "names": ["React", "Capabilities", "contributes", "createSurface", "useLayout", "isInstanceOf", "ScriptType", "getSpace", "parseId", "useSpace", "StackItem", "contributes", "Capabilities", "ReactSurface", "createSurface", "id", "meta", "role", "filter", "data", "subject", "component", "layout", "useLayout", "spaceId", "parseId", "workspace", "space", "useSpace", "AutomationContainer", "FunctionsContainer", "isInstanceOf", "ScriptType", "companionTo", "StackItem", "Content", "AutomationPanel", "getSpace", "object"]
7
- }
@@ -1,9 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- AutomationAction
4
- } from "./chunk-EEA6CZ6B.mjs";
5
- import "./chunk-DZ44LGYT.mjs";
6
- export {
7
- AutomationAction
8
- };
9
- //# sourceMappingURL=types.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }
@@ -1,4 +0,0 @@
1
- import { Capabilities, type PluginContext } from '@dxos/app-framework';
2
- declare const _default: (context: PluginContext) => import("@dxos/app-framework").Capability<Capabilities.IntentResolver>;
3
- export default _default;
4
- //# sourceMappingURL=intent-resolver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"intent-resolver.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/intent-resolver.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,YAAY,EAEZ,KAAK,aAAa,EAGnB,MAAM,qBAAqB,CAAC;yBAWb,SAAS,aAAa;AAAtC,wBAkDK"}
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import { type Space } from '@dxos/react-client/echo';
3
- export declare const AutomationContainer: ({ space }: {
4
- space: Space;
5
- }) => React.JSX.Element;
6
- export default AutomationContainer;
7
- //# sourceMappingURL=AutomationContainer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AutomationContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/AutomationContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAQrD,eAAO,MAAM,mBAAmB,GAAI,WAAW;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,sBAc9D,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import { type Space } from '@dxos/react-client/echo';
3
- export declare const FunctionsContainer: ({ space }: {
4
- space: Space;
5
- }) => React.JSX.Element;
6
- export default FunctionsContainer;
7
- //# sourceMappingURL=FunctionsContainer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FunctionsContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/FunctionsContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAQrD,eAAO,MAAM,kBAAkB,GAAI,WAAW;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,sBAc7D,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import { type Space } from '@dxos/react-client/echo';
3
- export type FunctionsPanelProps = {
4
- space: Space;
5
- };
6
- export declare const FunctionsPanel: ({ space }: FunctionsPanelProps) => React.JSX.Element;
7
- //# sourceMappingURL=FunctionsPanel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FunctionsPanel.d.ts","sourceRoot":"","sources":["../../../../../src/components/FunctionsPanel/FunctionsPanel.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA+B,MAAM,OAAO,CAAC;AAIpD,OAAO,EAAsC,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAUzF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,WAAW,mBAAmB,sBAuE5D,CAAC"}
@@ -1,4 +0,0 @@
1
- import { FunctionsPanel } from './FunctionsPanel';
2
- export * from './FunctionsPanel';
3
- export default FunctionsPanel;
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/FunctionsPanel/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,cAAc,kBAAkB,CAAC;AACjC,eAAe,cAAc,CAAC"}
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import { type FunctionType } from '@dxos/functions';
3
- import { type FormInputStateProps, type QueryRefOptions } from '@dxos/react-ui-form';
4
- export type FunctionInputEditorProps = {
5
- functions: FunctionType[];
6
- onQueryRefOptions: QueryRefOptions;
7
- } & FormInputStateProps;
8
- /**
9
- * Editor component for function input parameters.
10
- */
11
- export declare const FunctionInputEditor: ({ functions, getValue, onValueChange, onQueryRefOptions, }: FunctionInputEditorProps) => React.JSX.Element | null;
12
- //# sourceMappingURL=FunctionInputEditor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FunctionInputEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/TriggerEditor/FunctionInputEditor.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA+B,MAAM,OAAO,CAAC;AAGpD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAQ,KAAK,mBAAmB,EAAE,KAAK,eAAe,EAAiB,MAAM,qBAAqB,CAAC;AAE1G,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,iBAAiB,EAAE,eAAe,CAAC;CACpC,GAAG,mBAAmB,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,4DAKjC,wBAAwB,6BAoD1B,CAAC"}
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import { type InputProps } from '@dxos/react-ui-form';
3
- export type SpecSelectorProps = InputProps;
4
- export declare const SpecSelector: (props: SpecSelectorProps) => React.JSX.Element;
5
- //# sourceMappingURL=SpecSelector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SpecSelector.d.ts","sourceRoot":"","sources":["../../../../../src/components/TriggerEditor/SpecSelector.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA+B,MAAM,OAAO,CAAC;AAIpD,OAAO,EAAe,KAAK,UAAU,EAAiB,MAAM,qBAAqB,CAAC;AAIlF,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAE3C,eAAO,MAAM,YAAY,GAAI,OAAO,iBAAiB,sBA4CpD,CAAC"}
@@ -1,25 +0,0 @@
1
- import { Schema } from 'effect';
2
- export declare namespace AutomationAction {
3
- const CreateTriggerFromTemplate_base: Schema.TaggedClass<CreateTriggerFromTemplate, "dxos.org/plugin/automation/action/create-trigger-from-template", {
4
- readonly _tag: Schema.tag<"dxos.org/plugin/automation/action/create-trigger-from-template">;
5
- } & {
6
- input: Schema.Struct<{
7
- space: Schema.Schema<import("@dxos/client-protocol").Space, import("@dxos/client-protocol").Space, never>;
8
- template: Schema.Union<[Schema.Struct<{
9
- type: Schema.Literal<["timer"]>;
10
- cron: typeof Schema.String;
11
- }>, Schema.Struct<{
12
- type: Schema.Literal<["queue"]>;
13
- queueDXN: typeof Schema.Any;
14
- }>]>;
15
- enabled: Schema.optional<typeof Schema.Boolean>;
16
- scriptName: Schema.optional<typeof Schema.String>;
17
- input: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Any>>;
18
- }>;
19
- output: typeof Schema.Void;
20
- }>;
21
- export class CreateTriggerFromTemplate extends CreateTriggerFromTemplate_base {
22
- }
23
- export {};
24
- }
25
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAWhC,yBAAiB,gBAAgB,CAAC;;;;;;;;;;;;;;;;;;;IAGhC,MAAM,OAAO,yBAA0B,SAAQ,8BAa9C;KAAG;;CACL"}
@@ -1,73 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import {
6
- contributes,
7
- Capabilities,
8
- createResolver,
9
- type PluginContext,
10
- createIntent,
11
- LayoutAction,
12
- } from '@dxos/app-framework';
13
- import { Ref } from '@dxos/echo';
14
- import { FunctionTrigger, FunctionType, ScriptType, TriggerKind } from '@dxos/functions';
15
- import { type DXN } from '@dxos/keys';
16
- import { live } from '@dxos/live-object';
17
- import { ATTENDABLE_PATH_SEPARATOR } from '@dxos/plugin-deck/types';
18
- import { SpaceAction } from '@dxos/plugin-space/types';
19
- import { Filter } from '@dxos/react-client/echo';
20
-
21
- import { AutomationAction } from '../types';
22
-
23
- export default (context: PluginContext) =>
24
- contributes(Capabilities.IntentResolver, [
25
- createResolver({
26
- intent: AutomationAction.CreateTriggerFromTemplate,
27
- resolve: async ({ space, template, enabled = false, scriptName, input }) => {
28
- const trigger = live(FunctionTrigger, { enabled, input });
29
-
30
- // TODO(wittjosiah): Factor out function lookup by script name?
31
- if (scriptName) {
32
- const {
33
- objects: [script],
34
- } = await space.db.query(Filter.type(ScriptType, { name: scriptName })).run();
35
- if (script) {
36
- const {
37
- objects: [fn],
38
- } = await space.db.query(Filter.type(FunctionType, { source: Ref.make(script) })).run();
39
- if (fn) {
40
- trigger.function = Ref.make(fn);
41
- }
42
- }
43
- }
44
-
45
- switch (template.type) {
46
- case 'timer': {
47
- trigger.spec = { kind: TriggerKind.Timer, cron: template.cron };
48
- break;
49
- }
50
- case 'queue': {
51
- trigger.spec = { kind: TriggerKind.Queue, queue: (template.queueDXN as DXN).toString() };
52
- break;
53
- }
54
- default: {
55
- break;
56
- }
57
- }
58
-
59
- return {
60
- intents: [
61
- createIntent(SpaceAction.AddObject, { object: trigger, target: space }),
62
- createIntent(LayoutAction.Open, {
63
- part: 'main',
64
- subject: [`automation-settings${ATTENDABLE_PATH_SEPARATOR}${space.id}`],
65
- options: {
66
- workspace: space.id,
67
- },
68
- }),
69
- ],
70
- };
71
- },
72
- }),
73
- ]);
@@ -1,31 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { type Space } from '@dxos/react-client/echo';
8
- import { useTranslation } from '@dxos/react-ui';
9
- import { ControlSection, ControlPage } from '@dxos/react-ui-form';
10
- import { StackItem } from '@dxos/react-ui-stack';
11
-
12
- import { AutomationPanel } from './AutomationPanel';
13
- import { AUTOMATION_PLUGIN } from '../meta';
14
-
15
- export const AutomationContainer = ({ space }: { space: Space }) => {
16
- const { t } = useTranslation(AUTOMATION_PLUGIN);
17
- return (
18
- <StackItem.Content classNames='block overflow-y-auto'>
19
- <ControlPage>
20
- <ControlSection
21
- title={t('automation verbose label', { ns: AUTOMATION_PLUGIN })}
22
- description={t('automation description', { ns: AUTOMATION_PLUGIN })}
23
- >
24
- <AutomationPanel space={space} />
25
- </ControlSection>
26
- </ControlPage>
27
- </StackItem.Content>
28
- );
29
- };
30
-
31
- export default AutomationContainer;
@@ -1,31 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { type Space } from '@dxos/react-client/echo';
8
- import { useTranslation } from '@dxos/react-ui';
9
- import { ControlPage, ControlSection } from '@dxos/react-ui-form';
10
- import { StackItem } from '@dxos/react-ui-stack';
11
-
12
- import { FunctionsPanel } from './FunctionsPanel';
13
- import { AUTOMATION_PLUGIN } from '../meta';
14
-
15
- export const FunctionsContainer = ({ space }: { space: Space }) => {
16
- const { t } = useTranslation(AUTOMATION_PLUGIN);
17
- return (
18
- <StackItem.Content classNames='block overflow-y-auto'>
19
- <ControlPage>
20
- <ControlSection
21
- title={t('functions verbose label', { ns: AUTOMATION_PLUGIN })}
22
- description={t('functions description', { ns: AUTOMATION_PLUGIN })}
23
- >
24
- <FunctionsPanel space={space} />
25
- </ControlSection>
26
- </ControlPage>
27
- </StackItem.Content>
28
- );
29
- };
30
-
31
- export default FunctionsContainer;
@@ -1,95 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Schema } from 'effect';
6
- import React, { useCallback, useMemo } from 'react';
7
-
8
- import { createIntent, LayoutAction, useIntentDispatcher } from '@dxos/app-framework';
9
- import { FunctionType, ScriptType } from '@dxos/functions';
10
- import { Filter, fullyQualifiedId, useQuery, type Space } from '@dxos/react-client/echo';
11
- import { Button, useTranslation } from '@dxos/react-ui';
12
- import { controlItemClasses } from '@dxos/react-ui-form';
13
- import { List } from '@dxos/react-ui-list';
14
- import { ghostHover, mx } from '@dxos/react-ui-theme';
15
-
16
- import { AUTOMATION_PLUGIN } from '../../meta';
17
-
18
- const grid = 'grid grid-cols-[1fr_auto] min-bs-[2.5rem]';
19
-
20
- export type FunctionsPanelProps = {
21
- space: Space;
22
- };
23
-
24
- export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
25
- const { t } = useTranslation(AUTOMATION_PLUGIN);
26
- const functions = useQuery(space, Filter.type(FunctionType));
27
- const scripts = useQuery(space, Filter.type(ScriptType));
28
- const { dispatchPromise: dispatch } = useIntentDispatcher();
29
-
30
- const functionToScriptMap = useMemo(
31
- () =>
32
- functions.reduce(
33
- (map, func) => {
34
- const scriptId = func.source?.target?.id;
35
- if (scriptId) {
36
- const script = scripts.find((s) => s.id === scriptId);
37
- if (script) {
38
- map[func.id] = script;
39
- }
40
- }
41
- return map;
42
- },
43
- {} as Record<string, ScriptType>,
44
- ),
45
- [functions, scripts],
46
- );
47
-
48
- const getScriptName = useCallback(
49
- (func: FunctionType) => {
50
- const script = functionToScriptMap[func.id];
51
- return script?.name;
52
- },
53
- [functionToScriptMap],
54
- );
55
-
56
- const handleGoToScript = useCallback(
57
- (func: FunctionType) => {
58
- const script = functionToScriptMap[func.id];
59
- if (script) {
60
- void dispatch(createIntent(LayoutAction.Open, { part: 'main', subject: [fullyQualifiedId(script)] }));
61
- }
62
- },
63
- [functionToScriptMap, dispatch],
64
- );
65
-
66
- return (
67
- <div role='none' className={mx(controlItemClasses)}>
68
- <List.Root<FunctionType> items={functions} isItem={Schema.is(FunctionType)} getId={(func) => func.id}>
69
- {({ items }) => (
70
- <div role='list' className='flex flex-col w-full'>
71
- {items?.map((func) => (
72
- <List.Item<FunctionType>
73
- key={func.id}
74
- item={func}
75
- classNames={mx(grid, ghostHover, 'items-center', 'pli-2', 'min-bs-[3rem]')}
76
- >
77
- <div className='flex flex-col truncate'>
78
- <List.ItemTitle classNames='truncate'>{func.name}</List.ItemTitle>
79
- {getScriptName(func) && (
80
- <div className='text-xs text-description truncate'>{getScriptName(func)}</div>
81
- )}
82
- </div>
83
- {functionToScriptMap[func.id] && (
84
- <Button onClick={() => handleGoToScript(func)}>{t('go to function source button label')}</Button>
85
- )}
86
- </List.Item>
87
- ))}
88
- </div>
89
- )}
90
- </List.Root>
91
-
92
- {functions.length === 0 && <div className='text-center plb-4 text-gray-500'>{t('no functions found')}</div>}
93
- </div>
94
- );
95
- };
@@ -1,8 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { FunctionsPanel } from './FunctionsPanel';
6
-
7
- export * from './FunctionsPanel';
8
- export default FunctionsPanel;
@@ -1,77 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React, { useCallback, useMemo } from 'react';
6
-
7
- import { type JsonPath, RefImpl, toEffectSchema } from '@dxos/echo-schema';
8
- import { type FunctionType } from '@dxos/functions';
9
- import { useOnTransition } from '@dxos/react-ui';
10
- import { Form, type FormInputStateProps, type QueryRefOptions, useFormValues } from '@dxos/react-ui-form';
11
-
12
- export type FunctionInputEditorProps = {
13
- functions: FunctionType[];
14
- onQueryRefOptions: QueryRefOptions;
15
- } & FormInputStateProps;
16
-
17
- /**
18
- * Editor component for function input parameters.
19
- */
20
- export const FunctionInputEditor = ({
21
- functions,
22
- getValue,
23
- onValueChange,
24
- onQueryRefOptions,
25
- }: FunctionInputEditorProps) => {
26
- const selectedFunctionValue = useFormValues(['function' as JsonPath]);
27
- const selectedFunctionId = useMemo(() => {
28
- if (selectedFunctionValue instanceof RefImpl) {
29
- return selectedFunctionValue.dxn.toString().split('dxn:echo:@:').at(1);
30
- }
31
- }, [selectedFunctionValue]);
32
-
33
- const selectedFunction = useMemo(
34
- () => functions.find((f) => f.id === selectedFunctionId),
35
- [functions, selectedFunctionId],
36
- );
37
-
38
- useOnTransition(
39
- // Clear function parameter input when the function changes.
40
- selectedFunctionValue,
41
- (prevValue) => prevValue !== undefined && prevValue !== selectedFunctionValue,
42
- (currValue) => currValue !== undefined,
43
- () => onValueChange('object', {}),
44
- );
45
-
46
- const inputSchema = useMemo(() => selectedFunction?.inputSchema, [selectedFunction]);
47
- const effectSchema = useMemo(() => (inputSchema ? toEffectSchema(inputSchema) : undefined), [inputSchema]);
48
- const propertyCount = inputSchema?.properties ? Object.keys(inputSchema.properties).length : 0;
49
-
50
- const values = useMemo(() => getValue() ?? {}, [getValue]);
51
-
52
- const handleValuesChanged = useCallback(
53
- (values: any) => {
54
- onValueChange('object', values);
55
- },
56
- [onValueChange],
57
- );
58
-
59
- if (selectedFunction === undefined || effectSchema === undefined || propertyCount === 0) {
60
- return null;
61
- }
62
-
63
- return (
64
- <>
65
- <h3 className='text-md'>Function parameters</h3>
66
- {/* TODO(ZaymonFC): Try using <FormFields /> internal component for this nesting.
67
- This would allow errors to flow up to the root context. */}
68
- <Form
69
- schema={effectSchema}
70
- values={values}
71
- classNames='p-0'
72
- onValuesChanged={handleValuesChanged}
73
- onQueryRefOptions={onQueryRefOptions}
74
- />
75
- </>
76
- );
77
- };