@dxos/functions 0.8.4-main.ead640a → 0.8.4-main.ef1bc66f44

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 (204) hide show
  1. package/dist/lib/neutral/index.mjs +1229 -0
  2. package/dist/lib/neutral/index.mjs.map +7 -0
  3. package/dist/lib/neutral/meta.json +1 -0
  4. package/dist/types/src/errors.d.ts +44 -60
  5. package/dist/types/src/errors.d.ts.map +1 -1
  6. package/dist/types/src/{examples → example}/fib.d.ts +1 -1
  7. package/dist/types/src/example/fib.d.ts.map +1 -0
  8. package/dist/types/src/example/forex-effect.d.ts +3 -0
  9. package/dist/types/src/example/forex-effect.d.ts.map +1 -0
  10. package/dist/types/src/example/index.d.ts +12 -0
  11. package/dist/types/src/example/index.d.ts.map +1 -0
  12. package/dist/types/src/{examples → example}/reply.d.ts +1 -1
  13. package/dist/types/src/example/reply.d.ts.map +1 -0
  14. package/dist/types/src/{examples → example}/sleep.d.ts +1 -1
  15. package/dist/types/src/example/sleep.d.ts.map +1 -0
  16. package/dist/types/src/index.d.ts +4 -8
  17. package/dist/types/src/index.d.ts.map +1 -1
  18. package/dist/types/src/operation-compatibility.test.d.ts +2 -0
  19. package/dist/types/src/operation-compatibility.test.d.ts.map +1 -0
  20. package/dist/types/src/protocol/functions-ai-http-client.d.ts +12 -0
  21. package/dist/types/src/protocol/functions-ai-http-client.d.ts.map +1 -0
  22. package/dist/types/src/protocol/index.d.ts +2 -0
  23. package/dist/types/src/protocol/index.d.ts.map +1 -0
  24. package/dist/types/src/protocol/protocol.d.ts +7 -0
  25. package/dist/types/src/protocol/protocol.d.ts.map +1 -0
  26. package/dist/types/src/protocol/protocol.test.d.ts +2 -0
  27. package/dist/types/src/protocol/protocol.test.d.ts.map +1 -0
  28. package/dist/types/src/sdk.d.ts +114 -0
  29. package/dist/types/src/sdk.d.ts.map +1 -0
  30. package/dist/types/src/services/credentials.d.ts +6 -4
  31. package/dist/types/src/services/credentials.d.ts.map +1 -1
  32. package/dist/types/src/services/event-logger.d.ts +33 -27
  33. package/dist/types/src/services/event-logger.d.ts.map +1 -1
  34. package/dist/types/src/services/function-invocation-service.d.ts +7 -19
  35. package/dist/types/src/services/function-invocation-service.d.ts.map +1 -1
  36. package/dist/types/src/services/index.d.ts +2 -4
  37. package/dist/types/src/services/index.d.ts.map +1 -1
  38. package/dist/types/src/services/queues.d.ts +4 -4
  39. package/dist/types/src/services/queues.d.ts.map +1 -1
  40. package/dist/types/src/services/tracing.d.ts +41 -12
  41. package/dist/types/src/services/tracing.d.ts.map +1 -1
  42. package/dist/types/src/types/Function.d.ts +52 -0
  43. package/dist/types/src/types/Function.d.ts.map +1 -0
  44. package/dist/types/src/types/Script.d.ts +21 -0
  45. package/dist/types/src/types/Script.d.ts.map +1 -0
  46. package/dist/types/src/types/Trigger.d.ts +121 -0
  47. package/dist/types/src/types/Trigger.d.ts.map +1 -0
  48. package/dist/types/src/types/TriggerEvent.d.ts +74 -0
  49. package/dist/types/src/types/TriggerEvent.d.ts.map +1 -0
  50. package/dist/types/src/types/index.d.ts +6 -0
  51. package/dist/types/src/types/index.d.ts.map +1 -0
  52. package/dist/types/src/types/url.d.ts +13 -0
  53. package/dist/types/src/types/url.d.ts.map +1 -0
  54. package/dist/types/tsconfig.tsbuildinfo +1 -1
  55. package/package.json +24 -63
  56. package/src/errors.ts +4 -4
  57. package/src/{examples → example}/fib.ts +1 -1
  58. package/src/example/forex-effect.ts +40 -0
  59. package/src/example/index.ts +13 -0
  60. package/src/{examples → example}/reply.ts +1 -1
  61. package/src/{examples → example}/sleep.ts +1 -1
  62. package/src/index.ts +4 -8
  63. package/src/operation-compatibility.test.ts +185 -0
  64. package/src/protocol/functions-ai-http-client.ts +67 -0
  65. package/src/{executor → protocol}/index.ts +1 -1
  66. package/src/protocol/protocol.test.ts +59 -0
  67. package/src/protocol/protocol.ts +262 -0
  68. package/src/sdk.ts +289 -0
  69. package/src/services/credentials.ts +32 -17
  70. package/src/services/event-logger.ts +10 -4
  71. package/src/services/function-invocation-service.ts +23 -70
  72. package/src/services/index.ts +2 -4
  73. package/src/services/queues.ts +5 -7
  74. package/src/services/tracing.ts +68 -44
  75. package/src/types/Function.ts +82 -0
  76. package/src/types/Script.ts +34 -0
  77. package/src/types/Trigger.ts +143 -0
  78. package/src/types/TriggerEvent.ts +62 -0
  79. package/src/types/index.ts +9 -0
  80. package/src/types/url.ts +32 -0
  81. package/dist/lib/browser/bundler/index.mjs +0 -269
  82. package/dist/lib/browser/bundler/index.mjs.map +0 -7
  83. package/dist/lib/browser/chunk-J5LGTIGS.mjs +0 -10
  84. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +0 -7
  85. package/dist/lib/browser/chunk-LKYT2SAL.mjs +0 -665
  86. package/dist/lib/browser/chunk-LKYT2SAL.mjs.map +0 -7
  87. package/dist/lib/browser/edge/index.mjs +0 -83
  88. package/dist/lib/browser/edge/index.mjs.map +0 -7
  89. package/dist/lib/browser/index.mjs +0 -1395
  90. package/dist/lib/browser/index.mjs.map +0 -7
  91. package/dist/lib/browser/meta.json +0 -1
  92. package/dist/lib/browser/testing/index.mjs +0 -131
  93. package/dist/lib/browser/testing/index.mjs.map +0 -7
  94. package/dist/lib/node-esm/bundler/index.mjs +0 -270
  95. package/dist/lib/node-esm/bundler/index.mjs.map +0 -7
  96. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
  97. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +0 -7
  98. package/dist/lib/node-esm/chunk-NAQIKLZB.mjs +0 -667
  99. package/dist/lib/node-esm/chunk-NAQIKLZB.mjs.map +0 -7
  100. package/dist/lib/node-esm/edge/index.mjs +0 -84
  101. package/dist/lib/node-esm/edge/index.mjs.map +0 -7
  102. package/dist/lib/node-esm/index.mjs +0 -1396
  103. package/dist/lib/node-esm/index.mjs.map +0 -7
  104. package/dist/lib/node-esm/meta.json +0 -1
  105. package/dist/lib/node-esm/testing/index.mjs +0 -132
  106. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  107. package/dist/types/src/bundler/bundler.d.ts +0 -49
  108. package/dist/types/src/bundler/bundler.d.ts.map +0 -1
  109. package/dist/types/src/bundler/bundler.test.d.ts +0 -2
  110. package/dist/types/src/bundler/bundler.test.d.ts.map +0 -1
  111. package/dist/types/src/bundler/index.d.ts +0 -2
  112. package/dist/types/src/bundler/index.d.ts.map +0 -1
  113. package/dist/types/src/edge/functions.d.ts +0 -17
  114. package/dist/types/src/edge/functions.d.ts.map +0 -1
  115. package/dist/types/src/edge/index.d.ts +0 -2
  116. package/dist/types/src/edge/index.d.ts.map +0 -1
  117. package/dist/types/src/examples/fib.d.ts.map +0 -1
  118. package/dist/types/src/examples/index.d.ts +0 -4
  119. package/dist/types/src/examples/index.d.ts.map +0 -1
  120. package/dist/types/src/examples/reply.d.ts.map +0 -1
  121. package/dist/types/src/examples/sleep.d.ts.map +0 -1
  122. package/dist/types/src/executor/executor.d.ts +0 -14
  123. package/dist/types/src/executor/executor.d.ts.map +0 -1
  124. package/dist/types/src/executor/index.d.ts +0 -2
  125. package/dist/types/src/executor/index.d.ts.map +0 -1
  126. package/dist/types/src/handler.d.ts +0 -109
  127. package/dist/types/src/handler.d.ts.map +0 -1
  128. package/dist/types/src/schema.d.ts +0 -43
  129. package/dist/types/src/schema.d.ts.map +0 -1
  130. package/dist/types/src/services/database.d.ts +0 -67
  131. package/dist/types/src/services/database.d.ts.map +0 -1
  132. package/dist/types/src/services/function-invocation-service.test.d.ts +0 -2
  133. package/dist/types/src/services/function-invocation-service.test.d.ts.map +0 -1
  134. package/dist/types/src/services/local-function-execution.d.ts +0 -34
  135. package/dist/types/src/services/local-function-execution.d.ts.map +0 -1
  136. package/dist/types/src/services/remote-function-execution-service.d.ts +0 -22
  137. package/dist/types/src/services/remote-function-execution-service.d.ts.map +0 -1
  138. package/dist/types/src/services/service-container.d.ts +0 -57
  139. package/dist/types/src/services/service-container.d.ts.map +0 -1
  140. package/dist/types/src/services/service-registry.d.ts +0 -31
  141. package/dist/types/src/services/service-registry.d.ts.map +0 -1
  142. package/dist/types/src/services/service-registry.test.d.ts +0 -2
  143. package/dist/types/src/services/service-registry.test.d.ts.map +0 -1
  144. package/dist/types/src/testing/index.d.ts +0 -3
  145. package/dist/types/src/testing/index.d.ts.map +0 -1
  146. package/dist/types/src/testing/layer.d.ts +0 -18
  147. package/dist/types/src/testing/layer.d.ts.map +0 -1
  148. package/dist/types/src/testing/logger.d.ts +0 -5
  149. package/dist/types/src/testing/logger.d.ts.map +0 -1
  150. package/dist/types/src/testing/persist-database.test.d.ts +0 -2
  151. package/dist/types/src/testing/persist-database.test.d.ts.map +0 -1
  152. package/dist/types/src/testing/services.d.ts +0 -59
  153. package/dist/types/src/testing/services.d.ts.map +0 -1
  154. package/dist/types/src/trace.d.ts +0 -122
  155. package/dist/types/src/trace.d.ts.map +0 -1
  156. package/dist/types/src/translations.d.ts +0 -12
  157. package/dist/types/src/translations.d.ts.map +0 -1
  158. package/dist/types/src/triggers/index.d.ts +0 -4
  159. package/dist/types/src/triggers/index.d.ts.map +0 -1
  160. package/dist/types/src/triggers/input-builder.d.ts +0 -3
  161. package/dist/types/src/triggers/input-builder.d.ts.map +0 -1
  162. package/dist/types/src/triggers/invocation-tracer.d.ts +0 -37
  163. package/dist/types/src/triggers/invocation-tracer.d.ts.map +0 -1
  164. package/dist/types/src/triggers/trigger-dispatcher.d.ts +0 -78
  165. package/dist/types/src/triggers/trigger-dispatcher.d.ts.map +0 -1
  166. package/dist/types/src/triggers/trigger-dispatcher.test.d.ts +0 -2
  167. package/dist/types/src/triggers/trigger-dispatcher.test.d.ts.map +0 -1
  168. package/dist/types/src/triggers/trigger-state-store.d.ts +0 -28
  169. package/dist/types/src/triggers/trigger-state-store.d.ts.map +0 -1
  170. package/dist/types/src/types.d.ts +0 -230
  171. package/dist/types/src/types.d.ts.map +0 -1
  172. package/dist/types/src/url.d.ts +0 -21
  173. package/dist/types/src/url.d.ts.map +0 -1
  174. package/src/bundler/bundler.test.ts +0 -58
  175. package/src/bundler/bundler.ts +0 -295
  176. package/src/bundler/index.ts +0 -5
  177. package/src/edge/functions.ts +0 -67
  178. package/src/edge/index.ts +0 -9
  179. package/src/examples/index.ts +0 -7
  180. package/src/executor/executor.ts +0 -58
  181. package/src/handler.ts +0 -225
  182. package/src/schema.ts +0 -71
  183. package/src/services/database.ts +0 -175
  184. package/src/services/function-invocation-service.test.ts +0 -81
  185. package/src/services/local-function-execution.ts +0 -153
  186. package/src/services/remote-function-execution-service.ts +0 -63
  187. package/src/services/service-container.ts +0 -115
  188. package/src/services/service-registry.test.ts +0 -45
  189. package/src/services/service-registry.ts +0 -63
  190. package/src/testing/index.ts +0 -6
  191. package/src/testing/layer.ts +0 -114
  192. package/src/testing/logger.ts +0 -17
  193. package/src/testing/persist-database.test.ts +0 -87
  194. package/src/testing/services.ts +0 -115
  195. package/src/trace.ts +0 -178
  196. package/src/translations.ts +0 -20
  197. package/src/triggers/index.ts +0 -7
  198. package/src/triggers/input-builder.ts +0 -35
  199. package/src/triggers/invocation-tracer.ts +0 -101
  200. package/src/triggers/trigger-dispatcher.test.ts +0 -665
  201. package/src/triggers/trigger-dispatcher.ts +0 -533
  202. package/src/triggers/trigger-state-store.ts +0 -61
  203. package/src/types.ts +0 -218
  204. package/src/url.ts +0 -55
package/src/types.ts DELETED
@@ -1,218 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import * as Schema from 'effect/Schema';
6
- import * as SchemaAST from 'effect/SchemaAST';
7
-
8
- import { Obj, QueryAST, Type } from '@dxos/echo';
9
- import { Expando, OptionsAnnotationId, RawObject, Ref } from '@dxos/echo/internal';
10
- import { DXN } from '@dxos/keys';
11
-
12
- import { FunctionType } from './schema';
13
-
14
- /**
15
- * Type discriminator for TriggerType.
16
- * Every spec has a type field of type TriggerKind that we can use to understand which type we're working with.
17
- * https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions
18
- */
19
- export const TriggerKinds = ['timer', 'webhook', 'subscription', 'email', 'queue'] as const;
20
- export type TriggerKind = (typeof TriggerKinds)[number];
21
-
22
- const kindLiteralAnnotations = { title: 'Kind' };
23
-
24
- /**
25
- * Cron timer.
26
- */
27
- const TimerTriggerSchema = Schema.Struct({
28
- kind: Schema.Literal('timer').annotations(kindLiteralAnnotations),
29
- cron: Schema.String.annotations({
30
- title: 'Cron',
31
- [SchemaAST.ExamplesAnnotationId]: ['0 0 * * *'],
32
- }),
33
- }).pipe(Schema.mutable);
34
- export type TimerTrigger = Schema.Schema.Type<typeof TimerTriggerSchema>;
35
-
36
- const EmailTriggerSchema = Schema.Struct({
37
- kind: Schema.Literal('email').annotations(kindLiteralAnnotations),
38
- }).pipe(Schema.mutable);
39
- export type EmailTrigger = Schema.Schema.Type<typeof EmailTriggerSchema>;
40
-
41
- const QueueTriggerSchema = Schema.Struct({
42
- kind: Schema.Literal('queue').annotations(kindLiteralAnnotations),
43
-
44
- // TODO(dmaretskyi): Change to a reference.
45
- queue: DXN.Schema,
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('webhook').annotations(kindLiteralAnnotations),
54
- method: Schema.optional(
55
- Schema.String.annotations({
56
- title: 'Method',
57
- [OptionsAnnotationId]: ['GET', 'POST'],
58
- }),
59
- ),
60
- port: Schema.optional(
61
- Schema.Number.annotations({
62
- title: 'Port',
63
- }),
64
- ),
65
- }).pipe(Schema.mutable);
66
- export type WebhookTrigger = Schema.Schema.Type<typeof WebhookTriggerSchema>;
67
-
68
- /**
69
- * Subscription.
70
- */
71
- const SubscriptionTriggerSchema = Schema.Struct({
72
- kind: Schema.Literal('subscription').annotations(kindLiteralAnnotations),
73
- query: Schema.Struct({
74
- raw: Schema.optional(Schema.String.annotations({ title: 'Query' })),
75
- ast: QueryAST.Query,
76
- }).pipe(Schema.mutable),
77
- options: Schema.optional(
78
- Schema.Struct({
79
- // Watch changes to object (not just creation).
80
- deep: Schema.optional(Schema.Boolean.annotations({ title: 'Nested' })),
81
- // Debounce changes (delay in ms).
82
- delay: Schema.optional(Schema.Number.annotations({ title: 'Delay' })),
83
- }).annotations({ title: 'Options' }),
84
- ),
85
- }).pipe(Schema.mutable);
86
- export type SubscriptionTrigger = Schema.Schema.Type<typeof SubscriptionTriggerSchema>;
87
-
88
- /**
89
- * Trigger schema (discriminated union).
90
- */
91
- export const TriggerSchema = Schema.Union(
92
- EmailTriggerSchema,
93
- QueueTriggerSchema,
94
- SubscriptionTriggerSchema,
95
- TimerTriggerSchema,
96
- WebhookTriggerSchema,
97
- ).annotations({
98
- title: 'Trigger',
99
- });
100
- export type TriggerType = Schema.Schema.Type<typeof TriggerSchema>;
101
-
102
- export type EventType =
103
- | EmailTriggerOutput
104
- | QueueTriggerOutput
105
- | SubscriptionTriggerOutput
106
- | TimerTriggerOutput
107
- | WebhookTriggerOutput;
108
-
109
- // TODO(burdon): Reuse trigger schema from @dxos/functions (TriggerType).
110
- export const EmailTriggerOutput = Schema.mutable(
111
- Schema.Struct({
112
- from: Schema.String,
113
- to: Schema.String,
114
- subject: Schema.String,
115
- created: Schema.String,
116
- body: Schema.String,
117
- }),
118
- );
119
- export type EmailTriggerOutput = Schema.Schema.Type<typeof EmailTriggerOutput>;
120
-
121
- export const WebhookTriggerOutput = Schema.mutable(
122
- Schema.Struct({
123
- url: Schema.String,
124
- method: Schema.Literal('GET', 'POST'),
125
- headers: Schema.Record({ key: Schema.String, value: Schema.String }),
126
- bodyText: Schema.String,
127
- }),
128
- );
129
- export type WebhookTriggerOutput = Schema.Schema.Type<typeof WebhookTriggerOutput>;
130
-
131
- export const QueueTriggerOutput = Schema.mutable(
132
- Schema.Struct({
133
- queue: DXN.Schema,
134
- item: Schema.Any,
135
- cursor: Schema.String,
136
- }),
137
- );
138
- export type QueueTriggerOutput = Schema.Schema.Type<typeof QueueTriggerOutput>;
139
-
140
- export const SubscriptionTriggerOutput = Schema.Struct({
141
- /**
142
- * Type of the mutation.
143
- */
144
- // TODO(dmaretskyi): Specify enum.
145
- type: Schema.String,
146
-
147
- /**
148
- * Reference to the object that was changed or created.
149
- */
150
- subject: Type.Ref(Obj.Any),
151
-
152
- /**
153
- * @deprecated
154
- */
155
- changedObjectId: Schema.optional(Schema.String),
156
- }).pipe(Schema.mutable);
157
- export type SubscriptionTriggerOutput = Schema.Schema.Type<typeof SubscriptionTriggerOutput>;
158
-
159
- export const TimerTriggerOutput = Schema.mutable(Schema.Struct({ tick: Schema.Number }));
160
- export type TimerTriggerOutput = Schema.Schema.Type<typeof TimerTriggerOutput>;
161
-
162
- /**
163
- * Function trigger.
164
- * Function is invoked with the `payload` passed as input data.
165
- * The event that triggers the function is available in the function context.
166
- */
167
- const FunctionTrigger_ = Schema.Struct({
168
- /**
169
- * Function or workflow to invoke.
170
- */
171
- // TODO(dmaretskyi): Can be a Ref(FunctionType) or Ref(ComputeGraphType).
172
- function: Schema.optional(Ref(Expando).annotations({ title: 'Function' })),
173
-
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.String.annotations({ title: 'Input Node ID' })),
180
-
181
- enabled: Schema.optional(Schema.Boolean.annotations({ title: 'Enabled' })),
182
-
183
- spec: Schema.optional(TriggerSchema),
184
-
185
- /**
186
- * Passed as the input data to the function.
187
- * Must match the function's input schema.
188
- *
189
- * @example
190
- * {
191
- * item: '{{$.trigger.event}}',
192
- * instructions: 'Summarize and perform entity-extraction'
193
- * mailbox: { '/': 'dxn:echo:AAA:ZZZ' }
194
- * }
195
- */
196
- input: Schema.optional(Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.Any }))),
197
- }).pipe(
198
- Type.Obj({
199
- typename: 'dxos.org/type/FunctionTrigger',
200
- version: '0.2.0',
201
- }),
202
- );
203
- export interface FunctionTrigger extends Schema.Schema.Type<typeof FunctionTrigger_> {}
204
- export interface FunctionTriggerEncoded extends Schema.Schema.Encoded<typeof FunctionTrigger_> {}
205
- export const FunctionTrigger: Schema.Schema<FunctionTrigger, FunctionTriggerEncoded> = FunctionTrigger_;
206
-
207
- // TODO(wittjosiah): Remove?
208
-
209
- /**
210
- * Function manifest file.
211
- */
212
- export const FunctionManifestSchema = Schema.Struct({
213
- functions: Schema.optional(Schema.mutable(Schema.Array(RawObject(FunctionType)))),
214
- triggers: Schema.optional(Schema.mutable(Schema.Array(RawObject(FunctionTrigger)))),
215
- });
216
- export type FunctionManifest = Schema.Schema.Type<typeof FunctionManifestSchema>;
217
-
218
- export const FUNCTION_TYPES = [FunctionType, FunctionTrigger];
package/src/url.ts DELETED
@@ -1,55 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { type ObjectMeta } from '@dxos/echo/internal';
6
- import { type SpaceId } from '@dxos/keys';
7
-
8
- // TODO: use URL scheme for source?
9
- export const FUNCTIONS_META_KEY = 'dxos.org/service/function';
10
-
11
- export const FUNCTIONS_PRESET_META_KEY = 'dxos.org/service/function-preset';
12
-
13
- const isSecure = (protocol: string) => {
14
- return protocol === 'https:' || protocol === 'wss:';
15
- };
16
-
17
- /**
18
- * NOTE: functionId is backend ID, not ECHO object id.
19
- */
20
- export const getUserFunctionIdInMetadata = (meta: ObjectMeta) => {
21
- return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;
22
- };
23
-
24
- /**
25
- * NOTE: functionId is backend ID, not ECHO object id.
26
- */
27
- export const setUserFunctionIdInMetadata = (meta: ObjectMeta, functionId: string) => {
28
- const key = meta.keys.find((key) => key.source === FUNCTIONS_META_KEY);
29
- if (key) {
30
- if (key.id !== functionId) {
31
- throw new Error('Metadata mismatch');
32
- }
33
- } else {
34
- meta.keys.push({ source: FUNCTIONS_META_KEY, id: functionId });
35
- }
36
- };
37
-
38
- /**
39
- * NOTE: functionId is backend ID, not ECHO object id.
40
- */
41
- export const getInvocationUrl = (functionId: string, edgeUrl: string, options: InvocationOptions = {}) => {
42
- const baseUrl = new URL('functions/', edgeUrl);
43
-
44
- // Leading slashes cause the URL to be treated as an absolute path.
45
- const url = new URL(`./${functionId}`, baseUrl.toString());
46
- options.spaceId && url.searchParams.set('spaceId', options.spaceId);
47
- options.subjectId && url.searchParams.set('subjectId', options.subjectId);
48
- url.protocol = isSecure(url.protocol) ? 'https' : 'http';
49
- return url.toString();
50
- };
51
-
52
- export type InvocationOptions = {
53
- spaceId?: SpaceId;
54
- subjectId?: string;
55
- };