@dxos/functions 0.6.14-main.8b352a0 → 0.6.14-staging.3e2eaca

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 (32) hide show
  1. package/dist/lib/browser/{chunk-TNNXVSUN.mjs → chunk-7QJNOQ6N.mjs} +25 -24
  2. package/dist/lib/browser/chunk-7QJNOQ6N.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-2O2MAZE4.mjs → chunk-L7H5DE53.mjs} +2 -2
  4. package/dist/lib/browser/index.mjs +2 -2
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +2 -2
  7. package/dist/lib/browser/types.mjs +1 -1
  8. package/dist/lib/node/{chunk-SCSHB4MF.cjs → chunk-3KJEM5VR.cjs} +15 -15
  9. package/dist/lib/node/{chunk-O44VB3FE.cjs → chunk-TNG3Z74V.cjs} +28 -27
  10. package/dist/lib/node/chunk-TNG3Z74V.cjs.map +7 -0
  11. package/dist/lib/node/index.cjs +12 -12
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +10 -10
  14. package/dist/lib/node/types.cjs +5 -5
  15. package/dist/lib/node/types.cjs.map +1 -1
  16. package/dist/lib/node-esm/{chunk-AM7SW4YW.mjs → chunk-DMTGUST2.mjs} +2 -2
  17. package/dist/lib/node-esm/{chunk-TJ4S5QZ3.mjs → chunk-SLC6ICH2.mjs} +25 -24
  18. package/dist/lib/node-esm/chunk-SLC6ICH2.mjs.map +7 -0
  19. package/dist/lib/node-esm/index.mjs +2 -2
  20. package/dist/lib/node-esm/meta.json +1 -1
  21. package/dist/lib/node-esm/testing/index.mjs +2 -2
  22. package/dist/lib/node-esm/types.mjs +1 -1
  23. package/dist/types/src/types.d.ts +36 -36
  24. package/dist/types/src/types.d.ts.map +1 -1
  25. package/package.json +14 -14
  26. package/src/types.ts +36 -44
  27. package/dist/lib/browser/chunk-TNNXVSUN.mjs.map +0 -7
  28. package/dist/lib/node/chunk-O44VB3FE.cjs.map +0 -7
  29. package/dist/lib/node-esm/chunk-TJ4S5QZ3.mjs.map +0 -7
  30. /package/dist/lib/browser/{chunk-2O2MAZE4.mjs.map → chunk-L7H5DE53.mjs.map} +0 -0
  31. /package/dist/lib/node/{chunk-SCSHB4MF.cjs.map → chunk-3KJEM5VR.cjs.map} +0 -0
  32. /package/dist/lib/node-esm/{chunk-AM7SW4YW.mjs.map → chunk-DMTGUST2.mjs.map} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/functions",
3
- "version": "0.6.14-main.8b352a0",
3
+ "version": "0.6.14-staging.3e2eaca",
4
4
  "description": "Functions API and runtime.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -48,23 +48,23 @@
48
48
  "express": "^4.19.2",
49
49
  "get-port-please": "^3.1.1",
50
50
  "ws": "^8.14.2",
51
- "@dxos/client": "0.6.14-main.8b352a0",
52
- "@dxos/async": "0.6.14-main.8b352a0",
53
- "@dxos/echo-db": "0.6.14-main.8b352a0",
54
- "@dxos/echo-protocol": "0.6.14-main.8b352a0",
55
- "@dxos/context": "0.6.14-main.8b352a0",
56
- "@dxos/echo-schema": "0.6.14-main.8b352a0",
57
- "@dxos/keys": "0.6.14-main.8b352a0",
58
- "@dxos/invariant": "0.6.14-main.8b352a0",
59
- "@dxos/log": "0.6.14-main.8b352a0",
60
- "@dxos/node-std": "0.6.14-main.8b352a0",
61
- "@dxos/protocols": "0.6.14-main.8b352a0",
62
- "@dxos/util": "0.6.14-main.8b352a0"
51
+ "@dxos/async": "0.6.14-staging.3e2eaca",
52
+ "@dxos/client": "0.6.14-staging.3e2eaca",
53
+ "@dxos/context": "0.6.14-staging.3e2eaca",
54
+ "@dxos/echo-protocol": "0.6.14-staging.3e2eaca",
55
+ "@dxos/echo-schema": "0.6.14-staging.3e2eaca",
56
+ "@dxos/echo-db": "0.6.14-staging.3e2eaca",
57
+ "@dxos/invariant": "0.6.14-staging.3e2eaca",
58
+ "@dxos/keys": "0.6.14-staging.3e2eaca",
59
+ "@dxos/node-std": "0.6.14-staging.3e2eaca",
60
+ "@dxos/protocols": "0.6.14-staging.3e2eaca",
61
+ "@dxos/log": "0.6.14-staging.3e2eaca",
62
+ "@dxos/util": "0.6.14-staging.3e2eaca"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@types/express": "^4.17.17",
66
66
  "@types/ws": "^7.4.0",
67
- "@dxos/agent": "0.6.14-main.8b352a0"
67
+ "@dxos/agent": "0.6.14-staging.3e2eaca"
68
68
  },
69
69
  "publishConfig": {
70
70
  "access": "public"
package/src/types.ts CHANGED
@@ -12,59 +12,51 @@ import { RawObject, S, TypedObject } from '@dxos/echo-schema';
12
12
  */
13
13
  export type FunctionTriggerType = 'subscription' | 'timer' | 'webhook' | 'websocket';
14
14
 
15
- const SubscriptionTriggerSchema = S.mutable(
16
- S.Struct({
17
- type: S.Literal('subscription'),
18
- // TODO(burdon): Define query DSL (from ECHO).
19
- filter: S.Array(
20
- S.Struct({
21
- type: S.String,
22
- props: S.optional(S.Record({ key: S.String, value: S.Any })),
23
- }),
24
- ),
25
- options: S.optional(
26
- S.Struct({
27
- // Watch changes to object (not just creation).
28
- deep: S.optional(S.Boolean),
29
- // Debounce changes (delay in ms).
30
- delay: S.optional(S.Number),
31
- }),
32
- ),
33
- }),
34
- );
35
-
36
- export type SubscriptionTrigger = S.Schema.Type<typeof SubscriptionTriggerSchema>;
37
-
38
- const TimerTriggerSchema = S.mutable(
39
- S.Struct({
40
- type: S.Literal('timer'),
41
- cron: S.String,
42
- }),
43
- );
15
+ const TimerTriggerSchema = S.Struct({
16
+ type: S.Literal('timer'),
17
+ cron: S.String,
18
+ }).pipe(S.mutable);
44
19
 
45
20
  export type TimerTrigger = S.Schema.Type<typeof TimerTriggerSchema>;
46
21
 
47
- const WebhookTriggerSchema = S.mutable(
48
- S.Struct({
49
- type: S.Literal('webhook'),
50
- method: S.String,
51
- // Assigned port.
52
- port: S.optional(S.Number),
53
- }),
54
- );
22
+ const WebhookTriggerSchema = S.Struct({
23
+ type: S.Literal('webhook'),
24
+ method: S.String,
25
+ // Assigned port.
26
+ port: S.optional(S.Number),
27
+ }).pipe(S.mutable);
55
28
 
56
29
  export type WebhookTrigger = S.Schema.Type<typeof WebhookTriggerSchema>;
57
30
 
58
- const WebsocketTriggerSchema = S.mutable(
59
- S.Struct({
60
- type: S.Literal('websocket'),
61
- url: S.String,
62
- init: S.optional(S.Record({ key: S.String, value: S.Any })),
63
- }),
64
- );
31
+ const WebsocketTriggerSchema = S.Struct({
32
+ type: S.Literal('websocket'),
33
+ url: S.String,
34
+ init: S.optional(S.Record({ key: S.String, value: S.Any })),
35
+ }).pipe(S.mutable);
65
36
 
66
37
  export type WebsocketTrigger = S.Schema.Type<typeof WebsocketTriggerSchema>;
67
38
 
39
+ const QuerySchema = S.Struct({
40
+ type: S.String,
41
+ props: S.optional(S.Record({ key: S.String, value: S.Any })),
42
+ });
43
+
44
+ const SubscriptionTriggerSchema = S.Struct({
45
+ type: S.Literal('subscription'),
46
+ // TODO(burdon): Define query DSL (from ECHO). Reconcile with Table.Query.
47
+ filter: S.Array(QuerySchema),
48
+ options: S.optional(
49
+ S.Struct({
50
+ // Watch changes to object (not just creation).
51
+ deep: S.optional(S.Boolean),
52
+ // Debounce changes (delay in ms).
53
+ delay: S.optional(S.Number),
54
+ }),
55
+ ),
56
+ }).pipe(S.mutable);
57
+
58
+ export type SubscriptionTrigger = S.Schema.Type<typeof SubscriptionTriggerSchema>;
59
+
68
60
  const TriggerSpecSchema = S.Union(
69
61
  TimerTriggerSchema,
70
62
  WebhookTriggerSchema,
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/types.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { RawObject, S, TypedObject } from '@dxos/echo-schema';\n\n/**\n * Type discriminator for TriggerSpec.\n * Every spec has a type field of type FunctionTriggerType that we can use to understand which\n * type we're working with.\n * https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions\n */\nexport type FunctionTriggerType = 'subscription' | 'timer' | 'webhook' | 'websocket';\n\nconst SubscriptionTriggerSchema = S.mutable(\n S.Struct({\n type: S.Literal('subscription'),\n // TODO(burdon): Define query DSL (from ECHO).\n filter: S.Array(\n S.Struct({\n type: S.String,\n props: S.optional(S.Record({ key: S.String, value: S.Any })),\n }),\n ),\n options: S.optional(\n S.Struct({\n // Watch changes to object (not just creation).\n deep: S.optional(S.Boolean),\n // Debounce changes (delay in ms).\n delay: S.optional(S.Number),\n }),\n ),\n }),\n);\n\nexport type SubscriptionTrigger = S.Schema.Type<typeof SubscriptionTriggerSchema>;\n\nconst TimerTriggerSchema = S.mutable(\n S.Struct({\n type: S.Literal('timer'),\n cron: S.String,\n }),\n);\n\nexport type TimerTrigger = S.Schema.Type<typeof TimerTriggerSchema>;\n\nconst WebhookTriggerSchema = S.mutable(\n S.Struct({\n type: S.Literal('webhook'),\n method: S.String,\n // Assigned port.\n port: S.optional(S.Number),\n }),\n);\n\nexport type WebhookTrigger = S.Schema.Type<typeof WebhookTriggerSchema>;\n\nconst WebsocketTriggerSchema = S.mutable(\n S.Struct({\n type: S.Literal('websocket'),\n url: S.String,\n init: S.optional(S.Record({ key: S.String, value: S.Any })),\n }),\n);\n\nexport type WebsocketTrigger = S.Schema.Type<typeof WebsocketTriggerSchema>;\n\nconst TriggerSpecSchema = S.Union(\n TimerTriggerSchema,\n WebhookTriggerSchema,\n WebsocketTriggerSchema,\n SubscriptionTriggerSchema,\n);\n\nexport type TriggerSpec = TimerTrigger | WebhookTrigger | WebsocketTrigger | SubscriptionTrigger;\n\n/**\n * Function definition.\n */\nexport class FunctionDef extends TypedObject({\n typename: 'dxos.org/type/FunctionDef',\n version: '0.1.0',\n})({\n uri: S.String,\n description: S.optional(S.String),\n route: S.String,\n handler: S.String,\n}) {}\n\n/**\n * Function trigger.\n */\nexport class FunctionTrigger extends TypedObject({\n typename: 'dxos.org/type/FunctionTrigger',\n version: '0.1.0',\n})({\n name: S.optional(S.String),\n enabled: S.optional(S.Boolean),\n function: S.String.pipe(S.annotations({ description: 'Function URI.' })),\n // The `meta` property is merged into the event data passed to the function.\n meta: S.optional(S.mutable(S.Record({ key: S.String, value: S.Any }))),\n spec: TriggerSpecSchema,\n}) {}\n\n/**\n * Function manifest file.\n */\nexport const FunctionManifestSchema = S.Struct({\n functions: S.optional(S.mutable(S.Array(RawObject(FunctionDef)))),\n triggers: S.optional(S.mutable(S.Array(RawObject(FunctionTrigger)))),\n});\n\nexport type FunctionManifest = S.Schema.Type<typeof FunctionManifestSchema>;\n\n// TODO(burdon): Standards?\nexport const FUNCTION_SCHEMA = [FunctionDef, FunctionTrigger];\n"],
5
- "mappings": ";;;;;;;;;AAIA,SAASA,WAAWC,GAAGC,mBAAmB;AAU1C,IAAMC,4BAA4BC,EAAEC,QAClCD,EAAEE,OAAO;EACPC,MAAMH,EAAEI,QAAQ,cAAA;;EAEhBC,QAAQL,EAAEM,MACRN,EAAEE,OAAO;IACPC,MAAMH,EAAEO;IACRC,OAAOR,EAAES,SAAST,EAAEU,OAAO;MAAEC,KAAKX,EAAEO;MAAQK,OAAOZ,EAAEa;IAAI,CAAA,CAAA;EAC3D,CAAA,CAAA;EAEFC,SAASd,EAAES,SACTT,EAAEE,OAAO;;IAEPa,MAAMf,EAAES,SAAST,EAAEgB,OAAO;;IAE1BC,OAAOjB,EAAES,SAAST,EAAEkB,MAAM;EAC5B,CAAA,CAAA;AAEJ,CAAA,CAAA;AAKF,IAAMC,qBAAqBnB,EAAEC,QAC3BD,EAAEE,OAAO;EACPC,MAAMH,EAAEI,QAAQ,OAAA;EAChBgB,MAAMpB,EAAEO;AACV,CAAA,CAAA;AAKF,IAAMc,uBAAuBrB,EAAEC,QAC7BD,EAAEE,OAAO;EACPC,MAAMH,EAAEI,QAAQ,SAAA;EAChBkB,QAAQtB,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D,CAAA;AAKO,IAAMY,kBAAkB;EAACpB;EAAaQ;;",
6
- "names": ["RawObject", "S", "TypedObject", "SubscriptionTriggerSchema", "S", "mutable", "Struct", "type", "Literal", "filter", "Array", "String", "props", "optional", "Record", "key", "value", "Any", "options", "deep", "Boolean", "delay", "Number", "TimerTriggerSchema", "cron", "WebhookTriggerSchema", "method", "port", "WebsocketTriggerSchema", "url", "init", "TriggerSpecSchema", "Union", "FunctionDef", "TypedObject", "typename", "version", "uri", "description", "route", "handler", "FunctionTrigger", "name", "enabled", "function", "pipe", "annotations", "meta", "spec", "FunctionManifestSchema", "functions", "RawObject", "triggers", "FUNCTION_SCHEMA"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/types.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { RawObject, S, TypedObject } from '@dxos/echo-schema';\n\n/**\n * Type discriminator for TriggerSpec.\n * Every spec has a type field of type FunctionTriggerType that we can use to understand which\n * type we're working with.\n * https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions\n */\nexport type FunctionTriggerType = 'subscription' | 'timer' | 'webhook' | 'websocket';\n\nconst SubscriptionTriggerSchema = S.mutable(\n S.Struct({\n type: S.Literal('subscription'),\n // TODO(burdon): Define query DSL (from ECHO).\n filter: S.Array(\n S.Struct({\n type: S.String,\n props: S.optional(S.Record({ key: S.String, value: S.Any })),\n }),\n ),\n options: S.optional(\n S.Struct({\n // Watch changes to object (not just creation).\n deep: S.optional(S.Boolean),\n // Debounce changes (delay in ms).\n delay: S.optional(S.Number),\n }),\n ),\n }),\n);\n\nexport type SubscriptionTrigger = S.Schema.Type<typeof SubscriptionTriggerSchema>;\n\nconst TimerTriggerSchema = S.mutable(\n S.Struct({\n type: S.Literal('timer'),\n cron: S.String,\n }),\n);\n\nexport type TimerTrigger = S.Schema.Type<typeof TimerTriggerSchema>;\n\nconst WebhookTriggerSchema = S.mutable(\n S.Struct({\n type: S.Literal('webhook'),\n method: S.String,\n // Assigned port.\n port: S.optional(S.Number),\n }),\n);\n\nexport type WebhookTrigger = S.Schema.Type<typeof WebhookTriggerSchema>;\n\nconst WebsocketTriggerSchema = S.mutable(\n S.Struct({\n type: S.Literal('websocket'),\n url: S.String,\n init: S.optional(S.Record({ key: S.String, value: S.Any })),\n }),\n);\n\nexport type WebsocketTrigger = S.Schema.Type<typeof WebsocketTriggerSchema>;\n\nconst TriggerSpecSchema = S.Union(\n TimerTriggerSchema,\n WebhookTriggerSchema,\n WebsocketTriggerSchema,\n SubscriptionTriggerSchema,\n);\n\nexport type TriggerSpec = TimerTrigger | WebhookTrigger | WebsocketTrigger | SubscriptionTrigger;\n\n/**\n * Function definition.\n */\nexport class FunctionDef extends TypedObject({\n typename: 'dxos.org/type/FunctionDef',\n version: '0.1.0',\n})({\n uri: S.String,\n description: S.optional(S.String),\n route: S.String,\n handler: S.String,\n}) {}\n\n/**\n * Function trigger.\n */\nexport class FunctionTrigger extends TypedObject({\n typename: 'dxos.org/type/FunctionTrigger',\n version: '0.1.0',\n})({\n name: S.optional(S.String),\n enabled: S.optional(S.Boolean),\n function: S.String.pipe(S.annotations({ description: 'Function URI.' })),\n // The `meta` property is merged into the event data passed to the function.\n meta: S.optional(S.mutable(S.Record({ key: S.String, value: S.Any }))),\n spec: TriggerSpecSchema,\n}) {}\n\n/**\n * Function manifest file.\n */\nexport const FunctionManifestSchema = S.Struct({\n functions: S.optional(S.mutable(S.Array(RawObject(FunctionDef)))),\n triggers: S.optional(S.mutable(S.Array(RawObject(FunctionTrigger)))),\n});\n\nexport type FunctionManifest = S.Schema.Type<typeof FunctionManifestSchema>;\n\n// TODO(burdon): Standards?\nexport const FUNCTION_SCHEMA = [FunctionDef, FunctionTrigger];\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAA0C;;;;;;;AAU1C,IAAMA,4BAA4BC,qBAAEC,QAClCD,qBAAEE,OAAO;EACPC,MAAM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I;AAKG,IAAM8B,kBAAN,kBAA8BP,gCAAY;EAC/CC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;EACDM,MAAMtC,qBAAES,SAAST,qBAAEO,MAAM;EACzBgC,SAASvC,qBAAES,SAAST,qBAAEgB,OAAO;EAC7BwB,UAAUxC,qBAAEO,OAAOkC,KAAKzC,qBAAE0C,YAAY;IAAER,aAAa;EAAgB,CAAA,CAAA;;EAErES,MAAM3C,qBAAES,SAAST,qBAAEC,QAAQD,qBAAEU,OAAO;IAAEC,KAAKX,qBAAEO;IAAQK,OAAOZ,qBAAEa;EAAI,CAAA,CAAA,CAAA;EAClE+B,MAAMjB;AACR,CAAA,EAAA;AAAI;AAKG,IAAMkB,yBAAyB7C,qBAAEE,OAAO;EAC7C4C,WAAW9C,qBAAES,SAAST,qBAAEC,QAAQD,qBAAEM,UAAMyC,8BAAUlB,WAAAA,CAAAA,CAAAA,CAAAA;EAClDmB,UAAUhD,qBAAES,SAAST,qBAAEC,QAAQD,qBAAEM,UAAMyC,8BAAUV,eAAAA,CAAAA,CAAAA,CAAAA;AACnD,CAAA;AAKO,IAAMY,kBAAkB;EAACpB;EAAaQ;;",
6
- "names": ["SubscriptionTriggerSchema", "S", "mutable", "Struct", "type", "Literal", "filter", "Array", "String", "props", "optional", "Record", "key", "value", "Any", "options", "deep", "Boolean", "delay", "Number", "TimerTriggerSchema", "cron", "WebhookTriggerSchema", "method", "port", "WebsocketTriggerSchema", "url", "init", "TriggerSpecSchema", "Union", "FunctionDef", "TypedObject", "typename", "version", "uri", "description", "route", "handler", "FunctionTrigger", "name", "enabled", "function", "pipe", "annotations", "meta", "spec", "FunctionManifestSchema", "functions", "RawObject", "triggers", "FUNCTION_SCHEMA"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/types.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { RawObject, S, TypedObject } from '@dxos/echo-schema';\n\n/**\n * Type discriminator for TriggerSpec.\n * Every spec has a type field of type FunctionTriggerType that we can use to understand which\n * type we're working with.\n * https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions\n */\nexport type FunctionTriggerType = 'subscription' | 'timer' | 'webhook' | 'websocket';\n\nconst SubscriptionTriggerSchema = S.mutable(\n S.Struct({\n type: S.Literal('subscription'),\n // TODO(burdon): Define query DSL (from ECHO).\n filter: S.Array(\n S.Struct({\n type: S.String,\n props: S.optional(S.Record({ key: S.String, value: S.Any })),\n }),\n ),\n options: S.optional(\n S.Struct({\n // Watch changes to object (not just creation).\n deep: S.optional(S.Boolean),\n // Debounce changes (delay in ms).\n delay: S.optional(S.Number),\n }),\n ),\n }),\n);\n\nexport type SubscriptionTrigger = S.Schema.Type<typeof SubscriptionTriggerSchema>;\n\nconst TimerTriggerSchema = S.mutable(\n S.Struct({\n type: S.Literal('timer'),\n cron: S.String,\n }),\n);\n\nexport type TimerTrigger = S.Schema.Type<typeof TimerTriggerSchema>;\n\nconst WebhookTriggerSchema = S.mutable(\n S.Struct({\n type: S.Literal('webhook'),\n method: S.String,\n // Assigned port.\n port: S.optional(S.Number),\n }),\n);\n\nexport type WebhookTrigger = S.Schema.Type<typeof WebhookTriggerSchema>;\n\nconst WebsocketTriggerSchema = S.mutable(\n S.Struct({\n type: S.Literal('websocket'),\n url: S.String,\n init: S.optional(S.Record({ key: S.String, value: S.Any })),\n }),\n);\n\nexport type WebsocketTrigger = S.Schema.Type<typeof WebsocketTriggerSchema>;\n\nconst TriggerSpecSchema = S.Union(\n TimerTriggerSchema,\n WebhookTriggerSchema,\n WebsocketTriggerSchema,\n SubscriptionTriggerSchema,\n);\n\nexport type TriggerSpec = TimerTrigger | WebhookTrigger | WebsocketTrigger | SubscriptionTrigger;\n\n/**\n * Function definition.\n */\nexport class FunctionDef extends TypedObject({\n typename: 'dxos.org/type/FunctionDef',\n version: '0.1.0',\n})({\n uri: S.String,\n description: S.optional(S.String),\n route: S.String,\n handler: S.String,\n}) {}\n\n/**\n * Function trigger.\n */\nexport class FunctionTrigger extends TypedObject({\n typename: 'dxos.org/type/FunctionTrigger',\n version: '0.1.0',\n})({\n name: S.optional(S.String),\n enabled: S.optional(S.Boolean),\n function: S.String.pipe(S.annotations({ description: 'Function URI.' })),\n // The `meta` property is merged into the event data passed to the function.\n meta: S.optional(S.mutable(S.Record({ key: S.String, value: S.Any }))),\n spec: TriggerSpecSchema,\n}) {}\n\n/**\n * Function manifest file.\n */\nexport const FunctionManifestSchema = S.Struct({\n functions: S.optional(S.mutable(S.Array(RawObject(FunctionDef)))),\n triggers: S.optional(S.mutable(S.Array(RawObject(FunctionTrigger)))),\n});\n\nexport type FunctionManifest = S.Schema.Type<typeof FunctionManifestSchema>;\n\n// TODO(burdon): Standards?\nexport const FUNCTION_SCHEMA = [FunctionDef, FunctionTrigger];\n"],
5
- "mappings": ";;;;;;;;;AAIA,SAASA,WAAWC,GAAGC,mBAAmB;AAU1C,IAAMC,4BAA4BC,EAAEC,QAClCD,EAAEE,OAAO;EACPC,MAAMH,EAAEI,QAAQ,cAAA;;EAEhBC,QAAQL,EAAEM,MACRN,EAAEE,OAAO;IACPC,MAAMH,EAAEO;IACRC,OAAOR,EAAES,SAAST,EAAEU,OAAO;MAAEC,KAAKX,EAAEO;MAAQK,OAAOZ,EAAEa;IAAI,CAAA,CAAA;EAC3D,CAAA,CAAA;EAEFC,SAASd,EAAES,SACTT,EAAEE,OAAO;;IAEPa,MAAMf,EAAES,SAAST,EAAEgB,OAAO;;IAE1BC,OAAOjB,EAAES,SAAST,EAAEkB,MAAM;EAC5B,CAAA,CAAA;AAEJ,CAAA,CAAA;AAKF,IAAMC,qBAAqBnB,EAAEC,QAC3BD,EAAEE,OAAO;EACPC,MAAMH,EAAEI,QAAQ,OAAA;EAChBgB,MAAMpB,EAAEO;AACV,CAAA,CAAA;AAKF,IAAMc,uBAAuBrB,EAAEC,QAC7BD,EAAEE,OAAO;EACPC,MAAMH,EAAEI,QAAQ,SAAA;E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AAA,CAAAA;AACnD,CAAA;AAKO,IAAMY,kBAAkB;EAACpB;EAAaQ;;",
6
- "names": ["RawObject", "S", "TypedObject", "SubscriptionTriggerSchema", "S", "mutable", "Struct", "type", "Literal", "filter", "Array", "String", "props", "optional", "Record", "key", "value", "Any", "options", "deep", "Boolean", "delay", "Number", "TimerTriggerSchema", "cron", "WebhookTriggerSchema", "method", "port", "WebsocketTriggerSchema", "url", "init", "TriggerSpecSchema", "Union", "FunctionDef", "TypedObject", "typename", "version", "uri", "description", "route", "handler", "FunctionTrigger", "name", "enabled", "function", "pipe", "annotations", "meta", "spec", "FunctionManifestSchema", "functions", "RawObject", "triggers", "FUNCTION_SCHEMA"]
7
- }