@dxos/functions 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 (176) hide show
  1. package/dist/lib/browser/bundler/index.mjs +3 -0
  2. package/dist/lib/browser/bundler/index.mjs.map +1 -1
  3. package/dist/lib/browser/chunk-HI7YZO2K.mjs +482 -0
  4. package/dist/lib/browser/chunk-HI7YZO2K.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-LT4LR4VU.mjs +72 -0
  6. package/dist/lib/browser/chunk-LT4LR4VU.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-RVSG6WTL.mjs +358 -0
  8. package/dist/lib/browser/chunk-RVSG6WTL.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-XRCXIG74.mjs +12 -0
  10. package/dist/lib/browser/chunk-XRCXIG74.mjs.map +7 -0
  11. package/dist/lib/browser/edge/index.mjs +7 -63
  12. package/dist/lib/browser/edge/index.mjs.map +4 -4
  13. package/dist/lib/browser/index.mjs +101 -371
  14. package/dist/lib/browser/index.mjs.map +4 -4
  15. package/dist/lib/browser/meta.json +1 -1
  16. package/dist/lib/browser/testing/index.mjs +670 -0
  17. package/dist/lib/browser/testing/index.mjs.map +7 -0
  18. package/dist/lib/browser/types/index.mjs +49 -0
  19. package/dist/lib/browser/types/index.mjs.map +7 -0
  20. package/dist/lib/node/bundler/index.cjs +1 -0
  21. package/dist/lib/node/bundler/index.cjs.map +1 -1
  22. package/dist/lib/node/chunk-DSUGRAAL.cjs +392 -0
  23. package/dist/lib/node/chunk-DSUGRAAL.cjs.map +7 -0
  24. package/dist/lib/node/chunk-JEQ2X3Z6.cjs +34 -0
  25. package/dist/lib/node/chunk-JEQ2X3Z6.cjs.map +7 -0
  26. package/dist/lib/node/chunk-NXZNXVT3.cjs +94 -0
  27. package/dist/lib/node/chunk-NXZNXVT3.cjs.map +7 -0
  28. package/dist/lib/node/chunk-RXMCVAMJ.cjs +496 -0
  29. package/dist/lib/node/chunk-RXMCVAMJ.cjs.map +7 -0
  30. package/dist/lib/node/edge/index.cjs +5 -65
  31. package/dist/lib/node/edge/index.cjs.map +4 -4
  32. package/dist/lib/node/index.cjs +93 -383
  33. package/dist/lib/node/index.cjs.map +4 -4
  34. package/dist/lib/node/meta.json +1 -1
  35. package/dist/lib/node/testing/index.cjs +687 -0
  36. package/dist/lib/node/testing/index.cjs.map +7 -0
  37. package/dist/lib/node/types/index.cjs +70 -0
  38. package/dist/lib/node/types/index.cjs.map +7 -0
  39. package/dist/lib/node-esm/bundler/index.mjs +1 -0
  40. package/dist/lib/node-esm/bundler/index.mjs.map +1 -1
  41. package/dist/lib/node-esm/chunk-DHGBFXSZ.mjs +12 -0
  42. package/dist/lib/node-esm/chunk-DHGBFXSZ.mjs.map +7 -0
  43. package/dist/lib/node-esm/chunk-HBD2FZXO.mjs +358 -0
  44. package/dist/lib/node-esm/chunk-HBD2FZXO.mjs.map +7 -0
  45. package/dist/lib/node-esm/chunk-O2SXVYU5.mjs +72 -0
  46. package/dist/lib/node-esm/chunk-O2SXVYU5.mjs.map +7 -0
  47. package/dist/lib/node-esm/chunk-SQSJO5HI.mjs +482 -0
  48. package/dist/lib/node-esm/chunk-SQSJO5HI.mjs.map +7 -0
  49. package/dist/lib/node-esm/edge/index.mjs +6 -64
  50. package/dist/lib/node-esm/edge/index.mjs.map +4 -4
  51. package/dist/lib/node-esm/index.mjs +99 -371
  52. package/dist/lib/node-esm/index.mjs.map +4 -4
  53. package/dist/lib/node-esm/meta.json +1 -1
  54. package/dist/lib/node-esm/testing/index.mjs +670 -0
  55. package/dist/lib/node-esm/testing/index.mjs.map +7 -0
  56. package/dist/lib/node-esm/types/index.mjs +49 -0
  57. package/dist/lib/node-esm/types/index.mjs.map +7 -0
  58. package/dist/types/src/browser/index.d.ts +2 -0
  59. package/dist/types/src/browser/index.d.ts.map +1 -0
  60. package/dist/types/src/bundler/bundler.d.ts.map +1 -1
  61. package/dist/types/src/edge/functions.d.ts +3 -3
  62. package/dist/types/src/edge/functions.d.ts.map +1 -1
  63. package/dist/types/src/edge/index.d.ts.map +1 -1
  64. package/dist/types/src/function/function-registry.d.ts +25 -0
  65. package/dist/types/src/function/function-registry.d.ts.map +1 -0
  66. package/dist/types/src/function/function-registry.test.d.ts +2 -0
  67. package/dist/types/src/function/function-registry.test.d.ts.map +1 -0
  68. package/dist/types/src/function/index.d.ts +2 -0
  69. package/dist/types/src/function/index.d.ts.map +1 -0
  70. package/dist/types/src/handler.d.ts +66 -18
  71. package/dist/types/src/handler.d.ts.map +1 -1
  72. package/dist/types/src/index.d.ts +3 -3
  73. package/dist/types/src/index.d.ts.map +1 -1
  74. package/dist/types/src/runtime/dev-server.d.ts +52 -0
  75. package/dist/types/src/runtime/dev-server.d.ts.map +1 -0
  76. package/dist/types/src/runtime/dev-server.test.d.ts +2 -0
  77. package/dist/types/src/runtime/dev-server.test.d.ts.map +1 -0
  78. package/dist/types/src/runtime/index.d.ts +3 -0
  79. package/dist/types/src/runtime/index.d.ts.map +1 -0
  80. package/dist/types/src/runtime/scheduler.d.ts +34 -0
  81. package/dist/types/src/runtime/scheduler.d.ts.map +1 -0
  82. package/dist/types/src/runtime/scheduler.test.d.ts +2 -0
  83. package/dist/types/src/runtime/scheduler.test.d.ts.map +1 -0
  84. package/dist/types/src/testing/functions-integration.test.d.ts +2 -0
  85. package/dist/types/src/testing/functions-integration.test.d.ts.map +1 -0
  86. package/dist/types/src/testing/index.d.ts +5 -0
  87. package/dist/types/src/testing/index.d.ts.map +1 -0
  88. package/dist/types/src/testing/manifest.d.ts +3 -0
  89. package/dist/types/src/testing/manifest.d.ts.map +1 -0
  90. package/dist/types/src/testing/plugin-init.d.ts +6 -0
  91. package/dist/types/src/testing/plugin-init.d.ts.map +1 -0
  92. package/dist/types/src/testing/setup.d.ts +15 -0
  93. package/dist/types/src/testing/setup.d.ts.map +1 -0
  94. package/dist/types/src/testing/test/handler.d.ts +4 -0
  95. package/dist/types/src/testing/test/handler.d.ts.map +1 -0
  96. package/dist/types/src/testing/test/index.d.ts +3 -0
  97. package/dist/types/src/testing/test/index.d.ts.map +1 -0
  98. package/dist/types/src/testing/types.d.ts +10 -0
  99. package/dist/types/src/testing/types.d.ts.map +1 -0
  100. package/dist/types/src/testing/util.d.ts +5 -0
  101. package/dist/types/src/testing/util.d.ts.map +1 -0
  102. package/dist/types/src/translations.d.ts +1 -2
  103. package/dist/types/src/translations.d.ts.map +1 -1
  104. package/dist/types/src/trigger/index.d.ts +3 -0
  105. package/dist/types/src/trigger/index.d.ts.map +1 -0
  106. package/dist/types/src/trigger/trigger-registry.d.ts +38 -0
  107. package/dist/types/src/trigger/trigger-registry.d.ts.map +1 -0
  108. package/dist/types/src/trigger/trigger-registry.test.d.ts +2 -0
  109. package/dist/types/src/trigger/trigger-registry.test.d.ts.map +1 -0
  110. package/dist/types/src/trigger/type/index.d.ts +3 -0
  111. package/dist/types/src/trigger/type/index.d.ts.map +1 -0
  112. package/dist/types/src/trigger/type/subscription-trigger.d.ts +4 -0
  113. package/dist/types/src/trigger/type/subscription-trigger.d.ts.map +1 -0
  114. package/dist/types/src/trigger/type/timer-trigger.d.ts +4 -0
  115. package/dist/types/src/trigger/type/timer-trigger.d.ts.map +1 -0
  116. package/dist/types/src/trigger/type/webhook-trigger.d.ts +4 -0
  117. package/dist/types/src/trigger/type/webhook-trigger.d.ts.map +1 -0
  118. package/dist/types/src/types/index.d.ts +5 -0
  119. package/dist/types/src/types/index.d.ts.map +1 -0
  120. package/dist/types/src/types/schema.d.ts +53 -0
  121. package/dist/types/src/types/schema.d.ts.map +1 -0
  122. package/dist/types/src/types/trace.d.ts +146 -0
  123. package/dist/types/src/types/trace.d.ts.map +1 -0
  124. package/dist/types/src/types/types.d.ts +265 -0
  125. package/dist/types/src/types/types.d.ts.map +1 -0
  126. package/dist/types/src/{url.d.ts → types/url.d.ts} +0 -6
  127. package/dist/types/src/types/url.d.ts.map +1 -0
  128. package/dist/types/tools/schema.d.ts +2 -0
  129. package/dist/types/tools/schema.d.ts.map +1 -0
  130. package/dist/types/tsconfig.tsbuildinfo +1 -1
  131. package/package.json +35 -20
  132. package/schema/functions.json +211 -0
  133. package/src/browser/index.ts +5 -0
  134. package/src/edge/functions.ts +4 -7
  135. package/src/edge/index.ts +0 -4
  136. package/src/function/function-registry.test.ts +118 -0
  137. package/src/function/function-registry.ts +104 -0
  138. package/src/function/index.ts +5 -0
  139. package/src/handler.ts +124 -23
  140. package/src/index.ts +5 -4
  141. package/src/runtime/dev-server.test.ts +79 -0
  142. package/src/runtime/dev-server.ts +240 -0
  143. package/src/runtime/index.ts +6 -0
  144. package/src/runtime/scheduler.test.ts +152 -0
  145. package/src/runtime/scheduler.ts +170 -0
  146. package/src/testing/functions-integration.test.ts +65 -0
  147. package/src/testing/index.ts +8 -0
  148. package/src/testing/manifest.ts +15 -0
  149. package/src/testing/plugin-init.ts +20 -0
  150. package/src/testing/setup.ts +109 -0
  151. package/src/testing/test/handler.ts +15 -0
  152. package/src/testing/test/index.ts +7 -0
  153. package/src/testing/types.ts +9 -0
  154. package/src/testing/util.ts +26 -0
  155. package/src/translations.ts +1 -1
  156. package/src/trigger/index.ts +6 -0
  157. package/src/trigger/trigger-registry.test.ts +278 -0
  158. package/src/trigger/trigger-registry.ts +218 -0
  159. package/src/trigger/type/index.ts +7 -0
  160. package/src/trigger/type/subscription-trigger.ts +84 -0
  161. package/src/trigger/type/timer-trigger.ts +48 -0
  162. package/src/trigger/type/webhook-trigger.ts +48 -0
  163. package/src/types/index.ts +8 -0
  164. package/src/types/schema.ts +46 -0
  165. package/src/{trace.ts → types/trace.ts} +31 -33
  166. package/src/types/types.ts +163 -0
  167. package/src/{url.ts → types/url.ts} +0 -5
  168. package/dist/types/src/schema.d.ts +0 -57
  169. package/dist/types/src/schema.d.ts.map +0 -1
  170. package/dist/types/src/trace.d.ts +0 -148
  171. package/dist/types/src/trace.d.ts.map +0 -1
  172. package/dist/types/src/types.d.ts +0 -407
  173. package/dist/types/src/types.d.ts.map +0 -1
  174. package/dist/types/src/url.d.ts.map +0 -1
  175. package/src/schema.ts +0 -53
  176. package/src/types.ts +0 -210
@@ -1,407 +0,0 @@
1
- import { Schema } from 'effect';
2
- import { Expando, Ref } from '@dxos/echo-schema';
3
- import { FunctionType } from './schema';
4
- /**
5
- * Type discriminator for TriggerType.
6
- * Every spec has a type field of type TriggerKind that we can use to understand which type we're working with.
7
- * https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions
8
- */
9
- export declare enum TriggerKind {
10
- Timer = "timer",
11
- Webhook = "webhook",
12
- Subscription = "subscription",
13
- Email = "email",
14
- Queue = "queue"
15
- }
16
- /**
17
- * Cron timer.
18
- */
19
- declare const TimerTriggerSchema: Schema.mutable<Schema.Struct<{
20
- kind: Schema.Literal<[TriggerKind.Timer]>;
21
- cron: Schema.SchemaClass<string, string, never>;
22
- }>>;
23
- export type TimerTrigger = Schema.Schema.Type<typeof TimerTriggerSchema>;
24
- declare const EmailTriggerSchema: Schema.mutable<Schema.Struct<{
25
- kind: Schema.Literal<[TriggerKind.Email]>;
26
- }>>;
27
- export type EmailTrigger = Schema.Schema.Type<typeof EmailTriggerSchema>;
28
- declare const QueueTriggerSchema: Schema.mutable<Schema.Struct<{
29
- kind: Schema.Literal<[TriggerKind.Queue]>;
30
- queue: Schema.refine<string, typeof Schema.NonEmptyString>;
31
- }>>;
32
- export type QueueTrigger = Schema.Schema.Type<typeof QueueTriggerSchema>;
33
- /**
34
- * Webhook.
35
- */
36
- declare const WebhookTriggerSchema: Schema.mutable<Schema.Struct<{
37
- kind: Schema.Literal<[TriggerKind.Webhook]>;
38
- method: Schema.optional<Schema.SchemaClass<string, string, never>>;
39
- port: Schema.optional<Schema.SchemaClass<number, number, never>>;
40
- }>>;
41
- export type WebhookTrigger = Schema.Schema.Type<typeof WebhookTriggerSchema>;
42
- /**
43
- * Subscription.
44
- */
45
- declare const SubscriptionTriggerSchema: Schema.mutable<Schema.Struct<{
46
- kind: Schema.Literal<[TriggerKind.Subscription]>;
47
- filter: Schema.Struct<{
48
- type: Schema.optional<Schema.SchemaClass<string, string, never>>;
49
- props: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Any>>;
50
- }>;
51
- options: Schema.optional<Schema.Struct<{
52
- deep: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
53
- delay: Schema.optional<Schema.SchemaClass<number, number, never>>;
54
- }>>;
55
- }>>;
56
- export type SubscriptionTrigger = Schema.Schema.Type<typeof SubscriptionTriggerSchema>;
57
- /**
58
- * Trigger schema (discriminated union).
59
- */
60
- export declare const TriggerSchema: Schema.Union<[Schema.mutable<Schema.Struct<{
61
- kind: Schema.Literal<[TriggerKind.Timer]>;
62
- cron: Schema.SchemaClass<string, string, never>;
63
- }>>, Schema.mutable<Schema.Struct<{
64
- kind: Schema.Literal<[TriggerKind.Webhook]>;
65
- method: Schema.optional<Schema.SchemaClass<string, string, never>>;
66
- port: Schema.optional<Schema.SchemaClass<number, number, never>>;
67
- }>>, Schema.mutable<Schema.Struct<{
68
- kind: Schema.Literal<[TriggerKind.Subscription]>;
69
- filter: Schema.Struct<{
70
- type: Schema.optional<Schema.SchemaClass<string, string, never>>;
71
- props: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Any>>;
72
- }>;
73
- options: Schema.optional<Schema.Struct<{
74
- deep: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
75
- delay: Schema.optional<Schema.SchemaClass<number, number, never>>;
76
- }>>;
77
- }>>, Schema.mutable<Schema.Struct<{
78
- kind: Schema.Literal<[TriggerKind.Email]>;
79
- }>>, Schema.mutable<Schema.Struct<{
80
- kind: Schema.Literal<[TriggerKind.Queue]>;
81
- queue: Schema.refine<string, typeof Schema.NonEmptyString>;
82
- }>>]>;
83
- export type TriggerType = Schema.Schema.Type<typeof TriggerSchema>;
84
- export type EventType = EmailTriggerOutput | WebhookTriggerOutput | QueueTriggerOutput | SubscriptionTriggerOutput | TimerTriggerOutput;
85
- export declare const EmailTriggerOutput: Schema.mutable<Schema.Struct<{
86
- from: typeof Schema.String;
87
- to: typeof Schema.String;
88
- subject: typeof Schema.String;
89
- created: typeof Schema.String;
90
- body: typeof Schema.String;
91
- }>>;
92
- export type EmailTriggerOutput = Schema.Schema.Type<typeof EmailTriggerOutput>;
93
- export declare const WebhookTriggerOutput: Schema.mutable<Schema.Struct<{
94
- url: typeof Schema.String;
95
- method: Schema.Literal<["GET", "POST"]>;
96
- headers: Schema.Record$<typeof Schema.String, typeof Schema.String>;
97
- bodyText: typeof Schema.String;
98
- }>>;
99
- export type WebhookTriggerOutput = Schema.Schema.Type<typeof WebhookTriggerOutput>;
100
- export declare const QueueTriggerOutput: Schema.mutable<Schema.Struct<{
101
- queue: Schema.refine<string, typeof Schema.NonEmptyString>;
102
- item: typeof Schema.Any;
103
- cursor: typeof Schema.String;
104
- }>>;
105
- export type QueueTriggerOutput = Schema.Schema.Type<typeof QueueTriggerOutput>;
106
- export declare const SubscriptionTriggerOutput: Schema.mutable<Schema.Struct<{
107
- type: typeof Schema.String;
108
- changedObjectId: typeof Schema.String;
109
- }>>;
110
- export type SubscriptionTriggerOutput = Schema.Schema.Type<typeof SubscriptionTriggerOutput>;
111
- export declare const TimerTriggerOutput: Schema.mutable<Schema.Struct<{
112
- tick: typeof Schema.Number;
113
- }>>;
114
- export type TimerTriggerOutput = Schema.Schema.Type<typeof TimerTriggerOutput>;
115
- /**
116
- * Function trigger.
117
- * Function is invoked with the `payload` passed as input data.
118
- * The event that triggers the function is available in the function context.
119
- */
120
- export declare const FunctionTriggerSchema: Schema.Struct<{
121
- /**
122
- * Function or workflow to invoke.
123
- */
124
- function: Schema.optional<Schema.SchemaClass<Ref<Expando>, import("@dxos/echo-protocol").EncodedReference, never>>;
125
- /**
126
- * Only used for workflowSchema.
127
- * Specifies the input node in the circuit.
128
- * @deprecated Remove and enforce a single input node in all compute graphSchema.
129
- */
130
- inputNodeId: Schema.optional<Schema.SchemaClass<string, string, never>>;
131
- enabled: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
132
- spec: Schema.optional<Schema.Union<[Schema.mutable<Schema.Struct<{
133
- kind: Schema.Literal<[TriggerKind.Timer]>;
134
- cron: Schema.SchemaClass<string, string, never>;
135
- }>>, Schema.mutable<Schema.Struct<{
136
- kind: Schema.Literal<[TriggerKind.Webhook]>;
137
- method: Schema.optional<Schema.SchemaClass<string, string, never>>;
138
- port: Schema.optional<Schema.SchemaClass<number, number, never>>;
139
- }>>, Schema.mutable<Schema.Struct<{
140
- kind: Schema.Literal<[TriggerKind.Subscription]>;
141
- filter: Schema.Struct<{
142
- type: Schema.optional<Schema.SchemaClass<string, string, never>>;
143
- props: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Any>>;
144
- }>;
145
- options: Schema.optional<Schema.Struct<{
146
- deep: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
147
- delay: Schema.optional<Schema.SchemaClass<number, number, never>>;
148
- }>>;
149
- }>>, Schema.mutable<Schema.Struct<{
150
- kind: Schema.Literal<[TriggerKind.Email]>;
151
- }>>, Schema.mutable<Schema.Struct<{
152
- kind: Schema.Literal<[TriggerKind.Queue]>;
153
- queue: Schema.refine<string, typeof Schema.NonEmptyString>;
154
- }>>]>>;
155
- /**
156
- * Passed as the input data to the function.
157
- * Must match the function's input schema.
158
- *
159
- * @example
160
- * {
161
- * item: '{{$.trigger.event}}',
162
- * instructions: 'Summarize and perform entity-extraction'
163
- * mailbox: { '/': 'dxn:echo:AAA:ZZZ' }
164
- * }
165
- */
166
- input: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, typeof Schema.Any>>>;
167
- }>;
168
- export type FunctionTriggerType = Schema.Schema.Type<typeof FunctionTriggerSchema>;
169
- declare const FunctionTrigger_base: import("@dxos/echo-schema").TypedObjectPrototype<import("@dxos/echo-schema").TypedObjectFields<Readonly<{
170
- /**
171
- * Function or workflow to invoke.
172
- */
173
- function: Schema.optional<Schema.SchemaClass<Ref<Expando>, import("@dxos/echo-protocol").EncodedReference, never>>;
174
- /**
175
- * Only used for workflowSchema.
176
- * Specifies the input node in the circuit.
177
- * @deprecated Remove and enforce a single input node in all compute graphSchema.
178
- */
179
- inputNodeId: Schema.optional<Schema.SchemaClass<string, string, never>>;
180
- enabled: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
181
- spec: Schema.optional<Schema.Union<[Schema.mutable<Schema.Struct<{
182
- kind: Schema.Literal<[TriggerKind.Timer]>;
183
- cron: Schema.SchemaClass<string, string, never>;
184
- }>>, Schema.mutable<Schema.Struct<{
185
- kind: Schema.Literal<[TriggerKind.Webhook]>;
186
- method: Schema.optional<Schema.SchemaClass<string, string, never>>;
187
- port: Schema.optional<Schema.SchemaClass<number, number, never>>;
188
- }>>, Schema.mutable<Schema.Struct<{
189
- kind: Schema.Literal<[TriggerKind.Subscription]>;
190
- filter: Schema.Struct<{
191
- type: Schema.optional<Schema.SchemaClass<string, string, never>>;
192
- props: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Any>>;
193
- }>;
194
- options: Schema.optional<Schema.Struct<{
195
- deep: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
196
- delay: Schema.optional<Schema.SchemaClass<number, number, never>>;
197
- }>>;
198
- }>>, Schema.mutable<Schema.Struct<{
199
- kind: Schema.Literal<[TriggerKind.Email]>;
200
- }>>, Schema.mutable<Schema.Struct<{
201
- kind: Schema.Literal<[TriggerKind.Queue]>;
202
- queue: Schema.refine<string, typeof Schema.NonEmptyString>;
203
- }>>]>>;
204
- /**
205
- * Passed as the input data to the function.
206
- * Must match the function's input schema.
207
- *
208
- * @example
209
- * {
210
- * item: '{{$.trigger.event}}',
211
- * instructions: 'Summarize and perform entity-extraction'
212
- * mailbox: { '/': 'dxn:echo:AAA:ZZZ' }
213
- * }
214
- */
215
- input: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, typeof Schema.Any>>>;
216
- }>, import("@dxos/echo-schema").TypedObjectOptions>, Schema.Struct.Encoded<Readonly<{
217
- /**
218
- * Function or workflow to invoke.
219
- */
220
- function: Schema.optional<Schema.SchemaClass<Ref<Expando>, import("@dxos/echo-protocol").EncodedReference, never>>;
221
- /**
222
- * Only used for workflowSchema.
223
- * Specifies the input node in the circuit.
224
- * @deprecated Remove and enforce a single input node in all compute graphSchema.
225
- */
226
- inputNodeId: Schema.optional<Schema.SchemaClass<string, string, never>>;
227
- enabled: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
228
- spec: Schema.optional<Schema.Union<[Schema.mutable<Schema.Struct<{
229
- kind: Schema.Literal<[TriggerKind.Timer]>;
230
- cron: Schema.SchemaClass<string, string, never>;
231
- }>>, Schema.mutable<Schema.Struct<{
232
- kind: Schema.Literal<[TriggerKind.Webhook]>;
233
- method: Schema.optional<Schema.SchemaClass<string, string, never>>;
234
- port: Schema.optional<Schema.SchemaClass<number, number, never>>;
235
- }>>, Schema.mutable<Schema.Struct<{
236
- kind: Schema.Literal<[TriggerKind.Subscription]>;
237
- filter: Schema.Struct<{
238
- type: Schema.optional<Schema.SchemaClass<string, string, never>>;
239
- props: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Any>>;
240
- }>;
241
- options: Schema.optional<Schema.Struct<{
242
- deep: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
243
- delay: Schema.optional<Schema.SchemaClass<number, number, never>>;
244
- }>>;
245
- }>>, Schema.mutable<Schema.Struct<{
246
- kind: Schema.Literal<[TriggerKind.Email]>;
247
- }>>, Schema.mutable<Schema.Struct<{
248
- kind: Schema.Literal<[TriggerKind.Queue]>;
249
- queue: Schema.refine<string, typeof Schema.NonEmptyString>;
250
- }>>]>>;
251
- /**
252
- * Passed as the input data to the function.
253
- * Must match the function's input schema.
254
- *
255
- * @example
256
- * {
257
- * item: '{{$.trigger.event}}',
258
- * instructions: 'Summarize and perform entity-extraction'
259
- * mailbox: { '/': 'dxn:echo:AAA:ZZZ' }
260
- * }
261
- */
262
- input: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, typeof Schema.Any>>>;
263
- }>>>;
264
- /**
265
- * Function trigger.
266
- */
267
- export declare class FunctionTrigger extends FunctionTrigger_base {
268
- }
269
- /**
270
- * Function manifest file.
271
- */
272
- export declare const FunctionManifestSchema: Schema.Struct<{
273
- functions: Schema.optional<Schema.mutable<Schema.Array$<Schema.Schema<import("@dxos/echo-schema").ExcludeId<import("@dxos/echo-schema").TypedObjectFields<{
274
- name: typeof Schema.NonEmptyString;
275
- version: typeof Schema.String;
276
- description: Schema.optional<typeof Schema.String>;
277
- source: Schema.optional<import("@dxos/echo-schema").Ref$<{
278
- readonly id: string;
279
- name?: string | undefined;
280
- description?: string | undefined;
281
- changed?: boolean | undefined;
282
- source: Ref<{
283
- readonly id: string;
284
- content: string;
285
- }>;
286
- }>>;
287
- inputSchema: Schema.optional<Schema.Schema<import("@dxos/echo-schema").JsonSchemaType, import("@dxos/echo-schema").JsonSchemaType, never>>;
288
- outputSchema: Schema.optional<Schema.Schema<import("@dxos/echo-schema").JsonSchemaType, import("@dxos/echo-schema").JsonSchemaType, never>>;
289
- binding: Schema.optional<typeof Schema.String>;
290
- }, import("@dxos/echo-schema").TypedObjectOptions>> & import("@dxos/echo-schema").WithMeta, Schema.Struct.Encoded<{
291
- name: typeof Schema.NonEmptyString;
292
- version: typeof Schema.String;
293
- description: Schema.optional<typeof Schema.String>;
294
- source: Schema.optional<import("@dxos/echo-schema").Ref$<{
295
- readonly id: string;
296
- name?: string | undefined;
297
- description?: string | undefined;
298
- changed?: boolean | undefined;
299
- source: Ref<{
300
- readonly id: string;
301
- content: string;
302
- }>;
303
- }>>;
304
- inputSchema: Schema.optional<Schema.Schema<import("@dxos/echo-schema").JsonSchemaType, import("@dxos/echo-schema").JsonSchemaType, never>>;
305
- outputSchema: Schema.optional<Schema.Schema<import("@dxos/echo-schema").JsonSchemaType, import("@dxos/echo-schema").JsonSchemaType, never>>;
306
- binding: Schema.optional<typeof Schema.String>;
307
- }>, never>>>>;
308
- triggers: Schema.optional<Schema.mutable<Schema.Array$<Schema.Schema<import("@dxos/echo-schema").ExcludeId<import("@dxos/echo-schema").TypedObjectFields<Readonly<{
309
- /**
310
- * Function or workflow to invoke.
311
- */
312
- function: Schema.optional<Schema.SchemaClass<Ref<Expando>, import("@dxos/echo-protocol").EncodedReference, never>>;
313
- /**
314
- * Only used for workflowSchema.
315
- * Specifies the input node in the circuit.
316
- * @deprecated Remove and enforce a single input node in all compute graphSchema.
317
- */
318
- inputNodeId: Schema.optional<Schema.SchemaClass<string, string, never>>;
319
- enabled: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
320
- spec: Schema.optional<Schema.Union<[Schema.mutable<Schema.Struct<{
321
- kind: Schema.Literal<[TriggerKind.Timer]>;
322
- cron: Schema.SchemaClass<string, string, never>;
323
- }>>, Schema.mutable<Schema.Struct<{
324
- kind: Schema.Literal<[TriggerKind.Webhook]>;
325
- method: Schema.optional<Schema.SchemaClass<string, string, never>>;
326
- port: Schema.optional<Schema.SchemaClass<number, number, never>>;
327
- }>>, Schema.mutable<Schema.Struct<{
328
- kind: Schema.Literal<[TriggerKind.Subscription]>;
329
- filter: Schema.Struct<{
330
- type: Schema.optional<Schema.SchemaClass<string, string, never>>;
331
- props: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Any>>;
332
- }>;
333
- options: Schema.optional<Schema.Struct<{
334
- deep: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
335
- delay: Schema.optional<Schema.SchemaClass<number, number, never>>;
336
- }>>;
337
- }>>, Schema.mutable<Schema.Struct<{
338
- kind: Schema.Literal<[TriggerKind.Email]>;
339
- }>>, Schema.mutable<Schema.Struct<{
340
- kind: Schema.Literal<[TriggerKind.Queue]>;
341
- queue: Schema.refine<string, typeof Schema.NonEmptyString>;
342
- }>>]>>;
343
- /**
344
- * Passed as the input data to the function.
345
- * Must match the function's input schema.
346
- *
347
- * @example
348
- * {
349
- * item: '{{$.trigger.event}}',
350
- * instructions: 'Summarize and perform entity-extraction'
351
- * mailbox: { '/': 'dxn:echo:AAA:ZZZ' }
352
- * }
353
- */
354
- input: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, typeof Schema.Any>>>;
355
- }>, import("@dxos/echo-schema").TypedObjectOptions>> & import("@dxos/echo-schema").WithMeta, Schema.Struct.Encoded<Readonly<{
356
- /**
357
- * Function or workflow to invoke.
358
- */
359
- function: Schema.optional<Schema.SchemaClass<Ref<Expando>, import("@dxos/echo-protocol").EncodedReference, never>>;
360
- /**
361
- * Only used for workflowSchema.
362
- * Specifies the input node in the circuit.
363
- * @deprecated Remove and enforce a single input node in all compute graphSchema.
364
- */
365
- inputNodeId: Schema.optional<Schema.SchemaClass<string, string, never>>;
366
- enabled: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
367
- spec: Schema.optional<Schema.Union<[Schema.mutable<Schema.Struct<{
368
- kind: Schema.Literal<[TriggerKind.Timer]>;
369
- cron: Schema.SchemaClass<string, string, never>;
370
- }>>, Schema.mutable<Schema.Struct<{
371
- kind: Schema.Literal<[TriggerKind.Webhook]>;
372
- method: Schema.optional<Schema.SchemaClass<string, string, never>>;
373
- port: Schema.optional<Schema.SchemaClass<number, number, never>>;
374
- }>>, Schema.mutable<Schema.Struct<{
375
- kind: Schema.Literal<[TriggerKind.Subscription]>;
376
- filter: Schema.Struct<{
377
- type: Schema.optional<Schema.SchemaClass<string, string, never>>;
378
- props: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Any>>;
379
- }>;
380
- options: Schema.optional<Schema.Struct<{
381
- deep: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
382
- delay: Schema.optional<Schema.SchemaClass<number, number, never>>;
383
- }>>;
384
- }>>, Schema.mutable<Schema.Struct<{
385
- kind: Schema.Literal<[TriggerKind.Email]>;
386
- }>>, Schema.mutable<Schema.Struct<{
387
- kind: Schema.Literal<[TriggerKind.Queue]>;
388
- queue: Schema.refine<string, typeof Schema.NonEmptyString>;
389
- }>>]>>;
390
- /**
391
- * Passed as the input data to the function.
392
- * Must match the function's input schema.
393
- *
394
- * @example
395
- * {
396
- * item: '{{$.trigger.event}}',
397
- * instructions: 'Summarize and perform entity-extraction'
398
- * mailbox: { '/': 'dxn:echo:AAA:ZZZ' }
399
- * }
400
- */
401
- input: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, typeof Schema.Any>>>;
402
- }>>, never>>>>;
403
- }>;
404
- export type FunctionManifest = Schema.Schema.Type<typeof FunctionManifestSchema>;
405
- export declare const FUNCTION_TYPES: (typeof FunctionType | typeof FunctionTrigger)[];
406
- export {};
407
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/url.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAK1C,eAAO,MAAM,yBAAyB,qCAAqC,CAAC;AAM5E,eAAO,MAAM,4BAA4B,GAAI,MAAM,UAAU,uBAE5D,CAAC;AAEF,eAAO,MAAM,4BAA4B,GAAI,MAAM,UAAU,EAAE,aAAa,MAAM,SASjF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,IAAI;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,WAAwB,CAAC;AAEnF,eAAO,MAAM,gBAAgB,GAAI,aAAa,MAAM,EAAE,SAAS,MAAM,EAAE,UAAS,iBAAsB,WAUrG,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
package/src/schema.ts DELETED
@@ -1,53 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { Schema } from 'effect';
6
-
7
- import { EchoObject, JsonSchemaType, LabelAnnotationId, Ref, TypedObject } from '@dxos/echo-schema';
8
- import { DataType } from '@dxos/schema';
9
-
10
- /**
11
- * Source script.
12
- */
13
- export const ScriptType = Schema.Struct({
14
- name: Schema.optional(Schema.String),
15
- description: Schema.optional(Schema.String),
16
- // TODO(burdon): Change to hash of deployed content.
17
- // Whether source has changed since last deploy.
18
- changed: Schema.optional(Schema.Boolean),
19
- source: Ref(DataType.Text),
20
- })
21
- .annotations({ [LabelAnnotationId]: 'name' })
22
- .pipe(
23
- EchoObject({
24
- typename: 'dxos.org/type/Script',
25
- version: '0.1.0',
26
- }),
27
- );
28
-
29
- export type ScriptType = Schema.Schema.Type<typeof ScriptType>;
30
-
31
- /**
32
- * Function deployment.
33
- */
34
- export class FunctionType extends TypedObject({
35
- typename: 'dxos.org/type/Function',
36
- version: '0.1.0',
37
- })({
38
- // TODO(burdon): Rename to id/uri?
39
- name: Schema.NonEmptyString,
40
- version: Schema.String,
41
-
42
- description: Schema.optional(Schema.String),
43
-
44
- // Reference to a source script if it exists within ECHO.
45
- // TODO(burdon): Don't ref ScriptType directly (core).
46
- source: Schema.optional(Ref(ScriptType)),
47
-
48
- inputSchema: Schema.optional(JsonSchemaType),
49
- outputSchema: Schema.optional(JsonSchemaType),
50
-
51
- // Local binding to a function name.
52
- binding: Schema.optional(Schema.String),
53
- }) {}
package/src/types.ts DELETED
@@ -1,210 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { Schema, SchemaAST } from 'effect';
6
-
7
- import { Expando, OptionsAnnotationId, TypedObject, DXN, Ref, RawObject } from '@dxos/echo-schema';
8
-
9
- import { FunctionType } from './schema';
10
-
11
- /**
12
- * Type discriminator for TriggerType.
13
- * Every spec has a type field of type TriggerKind that we can use to understand which type we're working with.
14
- * https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions
15
- */
16
- export enum TriggerKind {
17
- Timer = 'timer',
18
- Webhook = 'webhook',
19
- Subscription = 'subscription',
20
- Email = 'email',
21
- Queue = 'queue',
22
- }
23
-
24
- const kindLiteralAnnotations = { [SchemaAST.TitleAnnotationId]: 'Kind' };
25
-
26
- /**
27
- * Cron timer.
28
- */
29
- const TimerTriggerSchema = Schema.Struct({
30
- kind: Schema.Literal(TriggerKind.Timer).annotations(kindLiteralAnnotations),
31
- cron: Schema.String.annotations({
32
- [SchemaAST.TitleAnnotationId]: 'Cron',
33
- [SchemaAST.ExamplesAnnotationId]: ['0 0 * * *'],
34
- }),
35
- }).pipe(Schema.mutable);
36
- export type TimerTrigger = Schema.Schema.Type<typeof TimerTriggerSchema>;
37
-
38
- const EmailTriggerSchema = Schema.Struct({
39
- kind: Schema.Literal(TriggerKind.Email).annotations(kindLiteralAnnotations),
40
- }).pipe(Schema.mutable);
41
- export type EmailTrigger = Schema.Schema.Type<typeof EmailTriggerSchema>;
42
-
43
- const QueueTriggerSchema = Schema.Struct({
44
- kind: Schema.Literal(TriggerKind.Queue).annotations(kindLiteralAnnotations),
45
- queue: DXN,
46
- }).pipe(Schema.mutable);
47
- export type QueueTrigger = Schema.Schema.Type<typeof QueueTriggerSchema>;
48
-
49
- /**
50
- * Webhook.
51
- */
52
- const WebhookTriggerSchema = Schema.Struct({
53
- kind: Schema.Literal(TriggerKind.Webhook).annotations(kindLiteralAnnotations),
54
- method: Schema.optional(
55
- Schema.String.annotations({
56
- [SchemaAST.TitleAnnotationId]: 'Method',
57
- [OptionsAnnotationId]: ['GET', 'POST'],
58
- }),
59
- ),
60
- port: Schema.optional(
61
- Schema.Number.annotations({
62
- [SchemaAST.TitleAnnotationId]: 'Port',
63
- }),
64
- ),
65
- }).pipe(Schema.mutable);
66
- export type WebhookTrigger = Schema.Schema.Type<typeof WebhookTriggerSchema>;
67
-
68
- // TODO(burdon): Use ECHO definition (from https://github.com/dxos/dxos/pull/8233).
69
- const QuerySchema = Schema.Struct({
70
- type: Schema.optional(Schema.String.annotations({ [SchemaAST.TitleAnnotationId]: 'Type' })),
71
- props: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),
72
- }).annotations({ [SchemaAST.TitleAnnotationId]: 'Query' });
73
-
74
- /**
75
- * Subscription.
76
- */
77
- const SubscriptionTriggerSchema = Schema.Struct({
78
- kind: Schema.Literal(TriggerKind.Subscription).annotations(kindLiteralAnnotations),
79
- // TODO(burdon): Define query DSL (from ECHO). Reconcile with Table.Query.
80
- filter: QuerySchema,
81
- options: Schema.optional(
82
- Schema.Struct({
83
- // Watch changes to object (not just creation).
84
- deep: Schema.optional(Schema.Boolean.annotations({ [SchemaAST.TitleAnnotationId]: 'Nested' })),
85
- // Debounce changes (delay in ms).
86
- delay: Schema.optional(Schema.Number.annotations({ [SchemaAST.TitleAnnotationId]: 'Delay' })),
87
- }).annotations({ [SchemaAST.TitleAnnotationId]: 'Options' }),
88
- ),
89
- }).pipe(Schema.mutable);
90
- export type SubscriptionTrigger = Schema.Schema.Type<typeof SubscriptionTriggerSchema>;
91
-
92
- /**
93
- * Trigger schema (discriminated union).
94
- */
95
- export const TriggerSchema = Schema.Union(
96
- TimerTriggerSchema,
97
- WebhookTriggerSchema,
98
- SubscriptionTriggerSchema,
99
- EmailTriggerSchema,
100
- QueueTriggerSchema,
101
- ).annotations({
102
- [SchemaAST.TitleAnnotationId]: 'Trigger',
103
- });
104
- export type TriggerType = Schema.Schema.Type<typeof TriggerSchema>;
105
-
106
- export type EventType =
107
- | EmailTriggerOutput
108
- | WebhookTriggerOutput
109
- | QueueTriggerOutput
110
- | SubscriptionTriggerOutput
111
- | TimerTriggerOutput;
112
-
113
- // TODO(burdon): Reuse trigger schema from @dxos/functions (TriggerType).
114
- export const EmailTriggerOutput = Schema.mutable(
115
- Schema.Struct({
116
- from: Schema.String,
117
- to: Schema.String,
118
- subject: Schema.String,
119
- created: Schema.String,
120
- body: Schema.String,
121
- }),
122
- );
123
- export type EmailTriggerOutput = Schema.Schema.Type<typeof EmailTriggerOutput>;
124
-
125
- export const WebhookTriggerOutput = Schema.mutable(
126
- Schema.Struct({
127
- url: Schema.String,
128
- method: Schema.Literal('GET', 'POST'),
129
- headers: Schema.Record({ key: Schema.String, value: Schema.String }),
130
- bodyText: Schema.String,
131
- }),
132
- );
133
- export type WebhookTriggerOutput = Schema.Schema.Type<typeof WebhookTriggerOutput>;
134
-
135
- export const QueueTriggerOutput = Schema.mutable(
136
- Schema.Struct({
137
- queue: DXN,
138
- item: Schema.Any,
139
- cursor: Schema.String,
140
- }),
141
- );
142
- export type QueueTriggerOutput = Schema.Schema.Type<typeof QueueTriggerOutput>;
143
-
144
- export const SubscriptionTriggerOutput = Schema.mutable(
145
- Schema.Struct({ type: Schema.String, changedObjectId: Schema.String }),
146
- );
147
- export type SubscriptionTriggerOutput = Schema.Schema.Type<typeof SubscriptionTriggerOutput>;
148
-
149
- export const TimerTriggerOutput = Schema.mutable(Schema.Struct({ tick: Schema.Number }));
150
- export type TimerTriggerOutput = Schema.Schema.Type<typeof TimerTriggerOutput>;
151
-
152
- /**
153
- * Function trigger.
154
- * Function is invoked with the `payload` passed as input data.
155
- * The event that triggers the function is available in the function context.
156
- */
157
- export const FunctionTriggerSchema = Schema.Struct({
158
- /**
159
- * Function or workflow to invoke.
160
- */
161
- // TODO(dmaretskyi): Can be a Ref(FunctionType) or Ref(ComputeGraphType).
162
- function: Schema.optional(Ref(Expando).annotations({ [SchemaAST.TitleAnnotationId]: 'Function' })),
163
-
164
- /**
165
- * Only used for workflowSchema.
166
- * Specifies the input node in the circuit.
167
- * @deprecated Remove and enforce a single input node in all compute graphSchema.
168
- */
169
- inputNodeId: Schema.optional(Schema.String.annotations({ [SchemaAST.TitleAnnotationId]: 'Input Node ID' })),
170
-
171
- enabled: Schema.optional(Schema.Boolean.annotations({ [SchemaAST.TitleAnnotationId]: 'Enabled' })),
172
-
173
- spec: Schema.optional(TriggerSchema),
174
-
175
- /**
176
- * Passed as the input data to the function.
177
- * Must match the function's input schema.
178
- *
179
- * @example
180
- * {
181
- * item: '{{$.trigger.event}}',
182
- * instructions: 'Summarize and perform entity-extraction'
183
- * mailbox: { '/': 'dxn:echo:AAA:ZZZ' }
184
- * }
185
- */
186
- input: Schema.optional(Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.Any }))),
187
- });
188
-
189
- export type FunctionTriggerType = Schema.Schema.Type<typeof FunctionTriggerSchema>;
190
-
191
- /**
192
- * Function trigger.
193
- */
194
- export class FunctionTrigger extends TypedObject({
195
- typename: 'dxos.org/type/FunctionTrigger',
196
- version: '0.2.0',
197
- })(FunctionTriggerSchema.fields) {}
198
-
199
- // TODO(wittjosiah): Remove?
200
-
201
- /**
202
- * Function manifest file.
203
- */
204
- export const FunctionManifestSchema = Schema.Struct({
205
- functions: Schema.optional(Schema.mutable(Schema.Array(RawObject(FunctionType)))),
206
- triggers: Schema.optional(Schema.mutable(Schema.Array(RawObject(FunctionTrigger)))),
207
- });
208
- export type FunctionManifest = Schema.Schema.Type<typeof FunctionManifestSchema>;
209
-
210
- export const FUNCTION_TYPES = [FunctionType, FunctionTrigger];