@dxos/functions 0.8.2-main.36232bc → 0.8.2-main.5ca3450

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 (174) hide show
  1. package/dist/lib/browser/bundler/index.mjs +0 -3
  2. package/dist/lib/browser/bundler/index.mjs.map +1 -1
  3. package/dist/lib/browser/edge/index.mjs +63 -7
  4. package/dist/lib/browser/edge/index.mjs.map +4 -4
  5. package/dist/lib/browser/index.mjs +370 -102
  6. package/dist/lib/browser/index.mjs.map +4 -4
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/node/bundler/index.cjs +0 -1
  9. package/dist/lib/node/bundler/index.cjs.map +1 -1
  10. package/dist/lib/node/edge/index.cjs +65 -5
  11. package/dist/lib/node/edge/index.cjs.map +4 -4
  12. package/dist/lib/node/index.cjs +382 -94
  13. package/dist/lib/node/index.cjs.map +4 -4
  14. package/dist/lib/node/meta.json +1 -1
  15. package/dist/lib/node-esm/bundler/index.mjs +0 -1
  16. package/dist/lib/node-esm/bundler/index.mjs.map +1 -1
  17. package/dist/lib/node-esm/edge/index.mjs +64 -6
  18. package/dist/lib/node-esm/edge/index.mjs.map +4 -4
  19. package/dist/lib/node-esm/index.mjs +370 -100
  20. package/dist/lib/node-esm/index.mjs.map +4 -4
  21. package/dist/lib/node-esm/meta.json +1 -1
  22. package/dist/types/src/bundler/bundler.d.ts.map +1 -1
  23. package/dist/types/src/edge/functions.d.ts.map +1 -1
  24. package/dist/types/src/edge/index.d.ts.map +1 -1
  25. package/dist/types/src/handler.d.ts +15 -64
  26. package/dist/types/src/handler.d.ts.map +1 -1
  27. package/dist/types/src/index.d.ts +3 -3
  28. package/dist/types/src/index.d.ts.map +1 -1
  29. package/dist/types/src/schema.d.ts +57 -0
  30. package/dist/types/src/schema.d.ts.map +1 -0
  31. package/dist/types/src/trace.d.ts +148 -0
  32. package/dist/types/src/trace.d.ts.map +1 -0
  33. package/dist/types/src/translations.d.ts +2 -1
  34. package/dist/types/src/translations.d.ts.map +1 -1
  35. package/dist/types/src/types.d.ts +407 -0
  36. package/dist/types/src/types.d.ts.map +1 -0
  37. package/dist/types/src/url.d.ts.map +1 -0
  38. package/dist/types/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +20 -36
  40. package/src/edge/index.ts +4 -0
  41. package/src/handler.ts +20 -122
  42. package/src/index.ts +4 -5
  43. package/src/schema.ts +53 -0
  44. package/src/{types/trace.ts → trace.ts} +33 -31
  45. package/src/translations.ts +1 -1
  46. package/src/types.ts +210 -0
  47. package/dist/lib/browser/chunk-2YE6S7XY.mjs +0 -360
  48. package/dist/lib/browser/chunk-2YE6S7XY.mjs.map +0 -7
  49. package/dist/lib/browser/chunk-7CHDHCV3.mjs +0 -482
  50. package/dist/lib/browser/chunk-7CHDHCV3.mjs.map +0 -7
  51. package/dist/lib/browser/chunk-LT4LR4VU.mjs +0 -72
  52. package/dist/lib/browser/chunk-LT4LR4VU.mjs.map +0 -7
  53. package/dist/lib/browser/chunk-XRCXIG74.mjs +0 -12
  54. package/dist/lib/browser/chunk-XRCXIG74.mjs.map +0 -7
  55. package/dist/lib/browser/testing/index.mjs +0 -670
  56. package/dist/lib/browser/testing/index.mjs.map +0 -7
  57. package/dist/lib/browser/types/index.mjs +0 -51
  58. package/dist/lib/browser/types/index.mjs.map +0 -7
  59. package/dist/lib/node/chunk-FBIUZ7SD.cjs +0 -496
  60. package/dist/lib/node/chunk-FBIUZ7SD.cjs.map +0 -7
  61. package/dist/lib/node/chunk-JEQ2X3Z6.cjs +0 -34
  62. package/dist/lib/node/chunk-JEQ2X3Z6.cjs.map +0 -7
  63. package/dist/lib/node/chunk-NXZNXVT3.cjs +0 -94
  64. package/dist/lib/node/chunk-NXZNXVT3.cjs.map +0 -7
  65. package/dist/lib/node/chunk-SV5NRE5L.cjs +0 -395
  66. package/dist/lib/node/chunk-SV5NRE5L.cjs.map +0 -7
  67. package/dist/lib/node/testing/index.cjs +0 -687
  68. package/dist/lib/node/testing/index.cjs.map +0 -7
  69. package/dist/lib/node/types/index.cjs +0 -72
  70. package/dist/lib/node/types/index.cjs.map +0 -7
  71. package/dist/lib/node-esm/chunk-3XMJFSID.mjs +0 -360
  72. package/dist/lib/node-esm/chunk-3XMJFSID.mjs.map +0 -7
  73. package/dist/lib/node-esm/chunk-C6YINTWG.mjs +0 -482
  74. package/dist/lib/node-esm/chunk-C6YINTWG.mjs.map +0 -7
  75. package/dist/lib/node-esm/chunk-DHGBFXSZ.mjs +0 -12
  76. package/dist/lib/node-esm/chunk-DHGBFXSZ.mjs.map +0 -7
  77. package/dist/lib/node-esm/chunk-O2SXVYU5.mjs +0 -72
  78. package/dist/lib/node-esm/chunk-O2SXVYU5.mjs.map +0 -7
  79. package/dist/lib/node-esm/testing/index.mjs +0 -670
  80. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  81. package/dist/lib/node-esm/types/index.mjs +0 -51
  82. package/dist/lib/node-esm/types/index.mjs.map +0 -7
  83. package/dist/types/src/browser/index.d.ts +0 -2
  84. package/dist/types/src/browser/index.d.ts.map +0 -1
  85. package/dist/types/src/function/function-registry.d.ts +0 -25
  86. package/dist/types/src/function/function-registry.d.ts.map +0 -1
  87. package/dist/types/src/function/function-registry.test.d.ts +0 -2
  88. package/dist/types/src/function/function-registry.test.d.ts.map +0 -1
  89. package/dist/types/src/function/index.d.ts +0 -2
  90. package/dist/types/src/function/index.d.ts.map +0 -1
  91. package/dist/types/src/runtime/dev-server.d.ts +0 -52
  92. package/dist/types/src/runtime/dev-server.d.ts.map +0 -1
  93. package/dist/types/src/runtime/dev-server.test.d.ts +0 -2
  94. package/dist/types/src/runtime/dev-server.test.d.ts.map +0 -1
  95. package/dist/types/src/runtime/index.d.ts +0 -3
  96. package/dist/types/src/runtime/index.d.ts.map +0 -1
  97. package/dist/types/src/runtime/scheduler.d.ts +0 -34
  98. package/dist/types/src/runtime/scheduler.d.ts.map +0 -1
  99. package/dist/types/src/runtime/scheduler.test.d.ts +0 -2
  100. package/dist/types/src/runtime/scheduler.test.d.ts.map +0 -1
  101. package/dist/types/src/testing/functions-integration.test.d.ts +0 -2
  102. package/dist/types/src/testing/functions-integration.test.d.ts.map +0 -1
  103. package/dist/types/src/testing/index.d.ts +0 -5
  104. package/dist/types/src/testing/index.d.ts.map +0 -1
  105. package/dist/types/src/testing/manifest.d.ts +0 -3
  106. package/dist/types/src/testing/manifest.d.ts.map +0 -1
  107. package/dist/types/src/testing/plugin-init.d.ts +0 -6
  108. package/dist/types/src/testing/plugin-init.d.ts.map +0 -1
  109. package/dist/types/src/testing/setup.d.ts +0 -15
  110. package/dist/types/src/testing/setup.d.ts.map +0 -1
  111. package/dist/types/src/testing/test/handler.d.ts +0 -4
  112. package/dist/types/src/testing/test/handler.d.ts.map +0 -1
  113. package/dist/types/src/testing/test/index.d.ts +0 -3
  114. package/dist/types/src/testing/test/index.d.ts.map +0 -1
  115. package/dist/types/src/testing/types.d.ts +0 -10
  116. package/dist/types/src/testing/types.d.ts.map +0 -1
  117. package/dist/types/src/testing/util.d.ts +0 -5
  118. package/dist/types/src/testing/util.d.ts.map +0 -1
  119. package/dist/types/src/trigger/index.d.ts +0 -3
  120. package/dist/types/src/trigger/index.d.ts.map +0 -1
  121. package/dist/types/src/trigger/trigger-registry.d.ts +0 -38
  122. package/dist/types/src/trigger/trigger-registry.d.ts.map +0 -1
  123. package/dist/types/src/trigger/trigger-registry.test.d.ts +0 -2
  124. package/dist/types/src/trigger/trigger-registry.test.d.ts.map +0 -1
  125. package/dist/types/src/trigger/type/index.d.ts +0 -3
  126. package/dist/types/src/trigger/type/index.d.ts.map +0 -1
  127. package/dist/types/src/trigger/type/subscription-trigger.d.ts +0 -4
  128. package/dist/types/src/trigger/type/subscription-trigger.d.ts.map +0 -1
  129. package/dist/types/src/trigger/type/timer-trigger.d.ts +0 -4
  130. package/dist/types/src/trigger/type/timer-trigger.d.ts.map +0 -1
  131. package/dist/types/src/trigger/type/webhook-trigger.d.ts +0 -4
  132. package/dist/types/src/trigger/type/webhook-trigger.d.ts.map +0 -1
  133. package/dist/types/src/types/index.d.ts +0 -5
  134. package/dist/types/src/types/index.d.ts.map +0 -1
  135. package/dist/types/src/types/schema.d.ts +0 -53
  136. package/dist/types/src/types/schema.d.ts.map +0 -1
  137. package/dist/types/src/types/trace.d.ts +0 -146
  138. package/dist/types/src/types/trace.d.ts.map +0 -1
  139. package/dist/types/src/types/types.d.ts +0 -265
  140. package/dist/types/src/types/types.d.ts.map +0 -1
  141. package/dist/types/src/types/url.d.ts.map +0 -1
  142. package/dist/types/tools/schema.d.ts +0 -2
  143. package/dist/types/tools/schema.d.ts.map +0 -1
  144. package/schema/functions.json +0 -211
  145. package/src/browser/index.ts +0 -5
  146. package/src/function/function-registry.test.ts +0 -118
  147. package/src/function/function-registry.ts +0 -104
  148. package/src/function/index.ts +0 -5
  149. package/src/runtime/dev-server.test.ts +0 -79
  150. package/src/runtime/dev-server.ts +0 -240
  151. package/src/runtime/index.ts +0 -6
  152. package/src/runtime/scheduler.test.ts +0 -152
  153. package/src/runtime/scheduler.ts +0 -170
  154. package/src/testing/functions-integration.test.ts +0 -65
  155. package/src/testing/index.ts +0 -8
  156. package/src/testing/manifest.ts +0 -15
  157. package/src/testing/plugin-init.ts +0 -20
  158. package/src/testing/setup.ts +0 -109
  159. package/src/testing/test/handler.ts +0 -15
  160. package/src/testing/test/index.ts +0 -7
  161. package/src/testing/types.ts +0 -9
  162. package/src/testing/util.ts +0 -26
  163. package/src/trigger/index.ts +0 -6
  164. package/src/trigger/trigger-registry.test.ts +0 -278
  165. package/src/trigger/trigger-registry.ts +0 -218
  166. package/src/trigger/type/index.ts +0 -7
  167. package/src/trigger/type/subscription-trigger.ts +0 -84
  168. package/src/trigger/type/timer-trigger.ts +0 -48
  169. package/src/trigger/type/webhook-trigger.ts +0 -48
  170. package/src/types/index.ts +0 -8
  171. package/src/types/schema.ts +0 -46
  172. package/src/types/types.ts +0 -163
  173. /package/dist/types/src/{types/url.d.ts → url.d.ts} +0 -0
  174. /package/src/{types/url.ts → url.ts} +0 -0
@@ -1,46 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { EchoObject, JsonSchemaType, LabelAnnotationId, Ref, S, TypedObject } from '@dxos/echo-schema';
6
- import { TextType } from '@dxos/schema';
7
-
8
- /**
9
- * Source script.
10
- */
11
- export const ScriptType = S.Struct({
12
- name: S.optional(S.String),
13
- description: S.optional(S.String),
14
- // TODO(burdon): Change to hash of deployed content.
15
- // Whether source has changed since last deploy.
16
- changed: S.optional(S.Boolean),
17
- source: Ref(TextType),
18
- })
19
- .annotations({ [LabelAnnotationId]: 'name' })
20
- .pipe(EchoObject({ typename: 'dxos.org/type/Script', version: '0.1.0' }));
21
-
22
- export type ScriptType = S.Schema.Type<typeof ScriptType>;
23
-
24
- /**
25
- * Function deployment.
26
- */
27
- export class FunctionType extends TypedObject({
28
- typename: 'dxos.org/type/Function',
29
- version: '0.1.0',
30
- })({
31
- // TODO(burdon): Rename to id/uri?
32
- name: S.NonEmptyString,
33
- version: S.String,
34
-
35
- description: S.optional(S.String),
36
-
37
- // Reference to a source script if it exists within ECHO.
38
- // TODO(burdon): Don't ref ScriptType directly (core).
39
- source: S.optional(Ref(ScriptType)),
40
-
41
- inputSchema: S.optional(JsonSchemaType),
42
- outputSchema: S.optional(JsonSchemaType),
43
-
44
- // Local binding to a function name.
45
- binding: S.optional(S.String),
46
- }) {}
@@ -1,163 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { AST, OptionsAnnotationId, RawObject, S, TypedObject, DXN } from '@dxos/echo-schema';
6
-
7
- /**
8
- * Type discriminator for TriggerType.
9
- * Every spec has a type field of type TriggerKind that we can use to understand which type we're working with.
10
- * https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions
11
- */
12
- export enum TriggerKind {
13
- Timer = 'timer',
14
- Webhook = 'webhook',
15
- Subscription = 'subscription',
16
- Email = 'email',
17
- Queue = 'queue',
18
- }
19
-
20
- // TODO(burdon): Rename prop kind.
21
- const typeLiteralAnnotations = { [AST.TitleAnnotationId]: 'Type' };
22
-
23
- /**
24
- * Cron timer.
25
- */
26
- const TimerTriggerSchema = S.Struct({
27
- type: S.Literal(TriggerKind.Timer).annotations(typeLiteralAnnotations),
28
- cron: S.String.annotations({
29
- [AST.TitleAnnotationId]: 'Cron',
30
- [AST.ExamplesAnnotationId]: ['0 0 * * *'],
31
- }),
32
- }).pipe(S.mutable);
33
-
34
- export type TimerTrigger = S.Schema.Type<typeof TimerTriggerSchema>;
35
-
36
- const EmailTriggerSchema = S.Struct({
37
- type: S.Literal(TriggerKind.Email).annotations(typeLiteralAnnotations),
38
- }).pipe(S.mutable);
39
-
40
- export type EmailTrigger = S.Schema.Type<typeof EmailTriggerSchema>;
41
-
42
- const QueueTriggerSchema = S.Struct({
43
- type: S.Literal(TriggerKind.Queue).annotations(typeLiteralAnnotations),
44
- queue: DXN,
45
- }).pipe(S.mutable);
46
-
47
- export type QueueTrigger = S.Schema.Type<typeof QueueTriggerSchema>;
48
-
49
- /**
50
- * Webhook.
51
- */
52
- const WebhookTriggerSchema = S.Struct({
53
- type: S.Literal(TriggerKind.Webhook).annotations(typeLiteralAnnotations),
54
- method: S.optional(
55
- S.String.annotations({
56
- [AST.TitleAnnotationId]: 'Method',
57
- [OptionsAnnotationId]: ['GET', 'POST'],
58
- }),
59
- ),
60
- port: S.optional(
61
- S.Number.annotations({
62
- [AST.TitleAnnotationId]: 'Port',
63
- }),
64
- ),
65
- }).pipe(S.mutable);
66
-
67
- export type WebhookTrigger = S.Schema.Type<typeof WebhookTriggerSchema>;
68
-
69
- // TODO(burdon): Use ECHO definition (from https://github.com/dxos/dxos/pull/8233).
70
- const QuerySchema = S.Struct({
71
- type: S.optional(S.String.annotations({ [AST.TitleAnnotationId]: 'Type' })),
72
- props: S.optional(S.Record({ key: S.String, value: S.Any })),
73
- }).annotations({ [AST.TitleAnnotationId]: 'Query' });
74
-
75
- /**
76
- * Subscription.
77
- */
78
- const SubscriptionTriggerSchema = S.Struct({
79
- type: S.Literal(TriggerKind.Subscription).annotations(typeLiteralAnnotations),
80
- // TODO(burdon): Define query DSL (from ECHO). Reconcile with Table.Query.
81
- filter: QuerySchema,
82
- options: S.optional(
83
- S.Struct({
84
- // Watch changes to object (not just creation).
85
- deep: S.optional(S.Boolean.annotations({ [AST.TitleAnnotationId]: 'Nested' })),
86
- // Debounce changes (delay in ms).
87
- delay: S.optional(S.Number.annotations({ [AST.TitleAnnotationId]: 'Delay' })),
88
- }).annotations({ [AST.TitleAnnotationId]: 'Options' }),
89
- ),
90
- }).pipe(S.mutable);
91
-
92
- export type SubscriptionTrigger = S.Schema.Type<typeof SubscriptionTriggerSchema>;
93
-
94
- /**
95
- * Trigger schema (discriminated union).
96
- */
97
- export const TriggerSchema = S.Union(
98
- TimerTriggerSchema,
99
- WebhookTriggerSchema,
100
- SubscriptionTriggerSchema,
101
- EmailTriggerSchema,
102
- QueueTriggerSchema,
103
- ).annotations({
104
- [AST.TitleAnnotationId]: 'Trigger',
105
- });
106
-
107
- export type TriggerType = S.Schema.Type<typeof TriggerSchema>;
108
-
109
- /**
110
- * Function trigger.
111
- */
112
- export const FunctionTriggerSchema = S.Struct({
113
- // TODO(burdon): What type does this reference.
114
- // TODO(wittjosiah): This should probably be a Ref?
115
- function: S.optional(S.String.annotations({ [AST.TitleAnnotationId]: 'Function' })),
116
-
117
- enabled: S.optional(S.Boolean.annotations({ [AST.TitleAnnotationId]: 'Enabled' })),
118
-
119
- // TODO(burdon): Flatten entire schema.
120
- spec: S.optional(TriggerSchema),
121
-
122
- // TODO(burdon): Get schema as partial from function.
123
- // TODO(wittjosiah): Rename to payload.
124
- // The `meta` property is merged into the event data passed to the function.
125
- meta: S.optional(S.mutable(S.Record({ key: S.String, value: S.Any }))),
126
- });
127
-
128
- export type FunctionTriggerType = S.Schema.Type<typeof FunctionTriggerSchema>;
129
-
130
- /**
131
- * Function trigger.
132
- */
133
- export class FunctionTrigger extends TypedObject({
134
- typename: 'dxos.org/type/FunctionTrigger',
135
- version: '0.1.0',
136
- })(FunctionTriggerSchema.fields) {}
137
-
138
- /**
139
- * Function definition.
140
- * @deprecated (Use dxos.org/type/Function)
141
- */
142
- // TODO(burdon): Reconcile with FunctionType.
143
- export class FunctionDef extends TypedObject({
144
- typename: 'dxos.org/type/FunctionDef',
145
- version: '0.1.0',
146
- })({
147
- uri: S.String,
148
- description: S.optional(S.String),
149
- route: S.String,
150
- handler: S.String,
151
- }) {}
152
-
153
- /**
154
- * Function manifest file.
155
- */
156
- export const FunctionManifestSchema = S.Struct({
157
- functions: S.optional(S.mutable(S.Array(RawObject(FunctionDef)))),
158
- triggers: S.optional(S.mutable(S.Array(RawObject(FunctionTrigger)))),
159
- });
160
-
161
- export type FunctionManifest = S.Schema.Type<typeof FunctionManifestSchema>;
162
-
163
- export const FUNCTION_TYPES = [FunctionDef, FunctionTrigger];
File without changes
File without changes