@dxos/functions 0.6.11-staging.e6894a4 → 0.6.12-main.5cc132e

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 (41) hide show
  1. package/dist/lib/browser/{chunk-XOBJR3A6.mjs → chunk-2I75VGHZ.mjs} +2 -3
  2. package/dist/lib/browser/{chunk-XOBJR3A6.mjs.map → chunk-2I75VGHZ.mjs.map} +1 -1
  3. package/dist/lib/browser/{chunk-563WM5C2.mjs → chunk-E7GXBW5N.mjs} +20 -12
  4. package/dist/lib/browser/chunk-E7GXBW5N.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +4 -2
  6. package/dist/lib/browser/index.mjs.map +1 -1
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/testing/index.mjs +2 -2
  9. package/dist/lib/browser/types.mjs +1 -1
  10. package/dist/lib/node/{chunk-GGTHSME4.cjs → chunk-JV3VNH5X.cjs} +5 -6
  11. package/dist/lib/node/{chunk-GGTHSME4.cjs.map → chunk-JV3VNH5X.cjs.map} +1 -1
  12. package/dist/lib/node/{chunk-S4S6FO6X.cjs → chunk-S5VUBTIA.cjs} +34 -35
  13. package/dist/lib/node/chunk-S5VUBTIA.cjs.map +7 -0
  14. package/dist/lib/node/index.cjs +13 -11
  15. package/dist/lib/node/index.cjs.map +1 -1
  16. package/dist/lib/node/meta.json +1 -1
  17. package/dist/lib/node/testing/index.cjs +10 -10
  18. package/dist/lib/node/types.cjs +5 -5
  19. package/dist/lib/node/types.cjs.map +1 -1
  20. package/dist/lib/node-esm/chunk-KFC4XAIY.mjs +78 -0
  21. package/dist/lib/node-esm/chunk-KFC4XAIY.mjs.map +7 -0
  22. package/dist/lib/node-esm/chunk-ZZQ234R7.mjs +597 -0
  23. package/dist/lib/node-esm/chunk-ZZQ234R7.mjs.map +7 -0
  24. package/dist/lib/node-esm/index.mjs +93 -0
  25. package/dist/lib/node-esm/index.mjs.map +7 -0
  26. package/dist/lib/node-esm/meta.json +1 -0
  27. package/dist/lib/node-esm/testing/index.mjs +665 -0
  28. package/dist/lib/node-esm/testing/index.mjs.map +7 -0
  29. package/dist/lib/node-esm/types.mjs +13 -0
  30. package/dist/lib/node-esm/types.mjs.map +7 -0
  31. package/dist/types/src/trigger/type/websocket-trigger.d.ts +1 -0
  32. package/dist/types/src/trigger/type/websocket-trigger.d.ts.map +1 -1
  33. package/package.json +20 -17
  34. package/src/function/function-registry.test.ts +3 -2
  35. package/src/runtime/dev-server.test.ts +7 -6
  36. package/src/runtime/scheduler.test.ts +9 -6
  37. package/src/testing/functions-integration.test.ts +7 -5
  38. package/src/trigger/trigger-registry.test.ts +3 -5
  39. package/src/trigger/type/websocket-trigger.ts +15 -4
  40. package/dist/lib/browser/chunk-563WM5C2.mjs.map +0 -7
  41. package/dist/lib/node/chunk-S4S6FO6X.cjs.map +0 -7
@@ -0,0 +1,665 @@
1
+ import {
2
+ FunctionRegistry,
3
+ TriggerRegistry
4
+ } from "../chunk-ZZQ234R7.mjs";
5
+ import {
6
+ FunctionDef,
7
+ FunctionTrigger,
8
+ __require
9
+ } from "../chunk-KFC4XAIY.mjs";
10
+
11
+ // packages/core/functions/src/testing/setup.ts
12
+ import { getRandomPort } from "get-port-please";
13
+ import path2 from "node:path";
14
+ import { waitForCondition } from "@dxos/async";
15
+ import { Client, Config } from "@dxos/client";
16
+ import { range } from "@dxos/util";
17
+
18
+ // packages/core/functions/src/testing/types.ts
19
+ import { S, TypedObject } from "@dxos/echo-schema";
20
+ var TestType = class extends TypedObject({
21
+ typename: "example.com/type/Test",
22
+ version: "0.1.0"
23
+ })({
24
+ title: S.String
25
+ }) {
26
+ };
27
+
28
+ // packages/core/functions/src/runtime/dev-server.ts
29
+ import express from "express";
30
+ import { getPort } from "get-port-please";
31
+ import { join } from "node:path";
32
+ import { asyncTimeout, Event, Trigger } from "@dxos/async";
33
+ import { Context } from "@dxos/context";
34
+ import { invariant } from "@dxos/invariant";
35
+ import { log } from "@dxos/log";
36
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/functions/src/runtime/dev-server.ts";
37
+ var FN_TIMEOUT = 2e4;
38
+ var DevServer = class {
39
+ constructor(_client, _functionsRegistry, _options) {
40
+ this._client = _client;
41
+ this._functionsRegistry = _functionsRegistry;
42
+ this._options = _options;
43
+ this._ctx = createContext();
44
+ this._handlers = {};
45
+ this._seq = 0;
46
+ this.update = new Event();
47
+ }
48
+ get stats() {
49
+ return {
50
+ seq: this._seq
51
+ };
52
+ }
53
+ get endpoint() {
54
+ invariant(this._port, void 0, {
55
+ F: __dxlog_file,
56
+ L: 60,
57
+ S: this,
58
+ A: [
59
+ "this._port",
60
+ ""
61
+ ]
62
+ });
63
+ return `http://localhost:${this._port}`;
64
+ }
65
+ get proxy() {
66
+ return this._proxy;
67
+ }
68
+ get functions() {
69
+ return Object.values(this._handlers);
70
+ }
71
+ async start() {
72
+ invariant(!this._server, void 0, {
73
+ F: __dxlog_file,
74
+ L: 73,
75
+ S: this,
76
+ A: [
77
+ "!this._server",
78
+ ""
79
+ ]
80
+ });
81
+ log.info("starting...", void 0, {
82
+ F: __dxlog_file,
83
+ L: 74,
84
+ S: this,
85
+ C: (f, a) => f(...a)
86
+ });
87
+ this._ctx = createContext();
88
+ const app = express();
89
+ app.use(express.json());
90
+ app.post("/:path", async (req, res) => {
91
+ const { path: path3 } = req.params;
92
+ try {
93
+ log.info("calling", {
94
+ path: path3
95
+ }, {
96
+ F: __dxlog_file,
97
+ L: 84,
98
+ S: this,
99
+ C: (f, a) => f(...a)
100
+ });
101
+ if (this._options.reload) {
102
+ const { def } = this._handlers["/" + path3];
103
+ await this._load(def, true);
104
+ }
105
+ res.statusCode = await asyncTimeout(this.invoke("/" + path3, req.body), FN_TIMEOUT);
106
+ res.end();
107
+ } catch (err) {
108
+ log.catch(err, void 0, {
109
+ F: __dxlog_file,
110
+ L: 94,
111
+ S: this,
112
+ C: (f, a) => f(...a)
113
+ });
114
+ res.statusCode = 500;
115
+ res.end();
116
+ }
117
+ });
118
+ this._port = this._options.port ?? await getPort({
119
+ host: "localhost",
120
+ port: 7200,
121
+ portRange: [
122
+ 7200,
123
+ 7299
124
+ ]
125
+ });
126
+ this._server = app.listen(this._port);
127
+ try {
128
+ const { registrationId, endpoint } = await this._client.services.services.FunctionRegistryService.register({
129
+ endpoint: this.endpoint
130
+ });
131
+ log.info("registered", {
132
+ endpoint
133
+ }, {
134
+ F: __dxlog_file,
135
+ L: 109,
136
+ S: this,
137
+ C: (f, a) => f(...a)
138
+ });
139
+ this._proxy = endpoint;
140
+ this._functionServiceRegistration = registrationId;
141
+ await this._handleNewFunctions(this._functionsRegistry.getUniqueByUri());
142
+ this._ctx.onDispose(this._functionsRegistry.registered.on(({ added }) => this._handleNewFunctions(added)));
143
+ } catch (err) {
144
+ await this.stop();
145
+ throw new Error("FunctionRegistryService not available (check plugin is configured).");
146
+ }
147
+ log.info("started", {
148
+ port: this._port
149
+ }, {
150
+ F: __dxlog_file,
151
+ L: 121,
152
+ S: this,
153
+ C: (f, a) => f(...a)
154
+ });
155
+ }
156
+ async stop() {
157
+ if (!this._server) {
158
+ return;
159
+ }
160
+ log.info("stopping...", void 0, {
161
+ F: __dxlog_file,
162
+ L: 129,
163
+ S: this,
164
+ C: (f, a) => f(...a)
165
+ });
166
+ await this._ctx.dispose();
167
+ const trigger = new Trigger();
168
+ this._server.close(async () => {
169
+ log.info("server stopped", void 0, {
170
+ F: __dxlog_file,
171
+ L: 134,
172
+ S: this,
173
+ C: (f, a) => f(...a)
174
+ });
175
+ try {
176
+ if (this._functionServiceRegistration) {
177
+ invariant(this._client.services.services.FunctionRegistryService, void 0, {
178
+ F: __dxlog_file,
179
+ L: 137,
180
+ S: this,
181
+ A: [
182
+ "this._client.services.services.FunctionRegistryService",
183
+ ""
184
+ ]
185
+ });
186
+ await this._client.services.services.FunctionRegistryService.unregister({
187
+ registrationId: this._functionServiceRegistration
188
+ });
189
+ log.info("unregistered", {
190
+ registrationId: this._functionServiceRegistration
191
+ }, {
192
+ F: __dxlog_file,
193
+ L: 142,
194
+ S: this,
195
+ C: (f, a) => f(...a)
196
+ });
197
+ this._functionServiceRegistration = void 0;
198
+ this._proxy = void 0;
199
+ }
200
+ trigger.wake();
201
+ } catch (err) {
202
+ trigger.throw(err);
203
+ }
204
+ });
205
+ await trigger.wait();
206
+ this._port = void 0;
207
+ this._server = void 0;
208
+ log.info("stopped", void 0, {
209
+ F: __dxlog_file,
210
+ L: 156,
211
+ S: this,
212
+ C: (f, a) => f(...a)
213
+ });
214
+ }
215
+ async _handleNewFunctions(newFunctions) {
216
+ newFunctions.forEach((def) => this._load(def));
217
+ await this._safeUpdateRegistration();
218
+ log("new functions loaded", {
219
+ newFunctions
220
+ }, {
221
+ F: __dxlog_file,
222
+ L: 162,
223
+ S: this,
224
+ C: (f, a) => f(...a)
225
+ });
226
+ }
227
+ /**
228
+ * Load function.
229
+ */
230
+ async _load(def, force) {
231
+ const { uri, route, handler } = def;
232
+ const filePath = join(this._options.baseDir, handler);
233
+ log.info("loading", {
234
+ uri,
235
+ force
236
+ }, {
237
+ F: __dxlog_file,
238
+ L: 171,
239
+ S: this,
240
+ C: (f, a) => f(...a)
241
+ });
242
+ if (force) {
243
+ Object.keys(__require.cache).filter((key) => key.startsWith(filePath)).forEach((key) => {
244
+ delete __require.cache[key];
245
+ });
246
+ }
247
+ const module = __require(filePath);
248
+ if (typeof module.default !== "function") {
249
+ throw new Error(`Handler must export default function: ${uri}`);
250
+ }
251
+ this._handlers[route] = {
252
+ def,
253
+ handler: module.default
254
+ };
255
+ }
256
+ async _safeUpdateRegistration() {
257
+ invariant(this._functionServiceRegistration, void 0, {
258
+ F: __dxlog_file,
259
+ L: 193,
260
+ S: this,
261
+ A: [
262
+ "this._functionServiceRegistration",
263
+ ""
264
+ ]
265
+ });
266
+ try {
267
+ await this._client.services.services.FunctionRegistryService.updateRegistration({
268
+ registrationId: this._functionServiceRegistration,
269
+ functions: this.functions.map(({ def: { id, route } }) => ({
270
+ id,
271
+ route
272
+ }))
273
+ });
274
+ } catch (err) {
275
+ log.catch(err, void 0, {
276
+ F: __dxlog_file,
277
+ L: 200,
278
+ S: this,
279
+ C: (f, a) => f(...a)
280
+ });
281
+ }
282
+ }
283
+ /**
284
+ * Invoke function.
285
+ */
286
+ async invoke(path3, data) {
287
+ const seq = ++this._seq;
288
+ const now = Date.now();
289
+ log.info("req", {
290
+ seq,
291
+ path: path3
292
+ }, {
293
+ F: __dxlog_file,
294
+ L: 211,
295
+ S: this,
296
+ C: (f, a) => f(...a)
297
+ });
298
+ const statusCode = await this._invoke(path3, {
299
+ data
300
+ });
301
+ log.info("res", {
302
+ seq,
303
+ path: path3,
304
+ statusCode,
305
+ duration: Date.now() - now
306
+ }, {
307
+ F: __dxlog_file,
308
+ L: 214,
309
+ S: this,
310
+ C: (f, a) => f(...a)
311
+ });
312
+ this.update.emit(statusCode);
313
+ return statusCode;
314
+ }
315
+ async _invoke(path3, event) {
316
+ const { handler } = this._handlers[path3] ?? {};
317
+ invariant(handler, `invalid path: ${path3}`, {
318
+ F: __dxlog_file,
319
+ L: 221,
320
+ S: this,
321
+ A: [
322
+ "handler",
323
+ "`invalid path: ${path}`"
324
+ ]
325
+ });
326
+ const context = {
327
+ client: this._client,
328
+ dataDir: this._options.dataDir
329
+ };
330
+ let statusCode = 200;
331
+ const response = {
332
+ status: (code) => {
333
+ statusCode = code;
334
+ return response;
335
+ }
336
+ };
337
+ await handler({
338
+ context,
339
+ event,
340
+ response
341
+ });
342
+ return statusCode;
343
+ }
344
+ };
345
+ var createContext = () => new Context({
346
+ name: "DevServer"
347
+ }, {
348
+ F: __dxlog_file,
349
+ L: 240
350
+ });
351
+
352
+ // packages/core/functions/src/runtime/scheduler.ts
353
+ import path from "node:path";
354
+ import { Mutex } from "@dxos/async";
355
+ import { loadObjectReferences } from "@dxos/client/echo";
356
+ import { Context as Context2 } from "@dxos/context";
357
+ import { Reference } from "@dxos/echo-protocol";
358
+ import { log as log2 } from "@dxos/log";
359
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/functions/src/runtime/scheduler.ts";
360
+ var Scheduler = class {
361
+ constructor(functions, triggers, _options = {}) {
362
+ this.functions = functions;
363
+ this.triggers = triggers;
364
+ this._options = _options;
365
+ this._ctx = createContext2();
366
+ this._functionUriToCallMutex = /* @__PURE__ */ new Map();
367
+ this.functions.registered.on(async ({ space, added }) => {
368
+ await this._safeActivateTriggers(space, this.triggers.getInactiveTriggers(space), added);
369
+ });
370
+ this.triggers.registered.on(async ({ space, triggers: triggers2 }) => {
371
+ await this._safeActivateTriggers(space, triggers2, this.functions.getFunctions(space));
372
+ });
373
+ }
374
+ async start() {
375
+ await this._ctx.dispose();
376
+ this._ctx = createContext2();
377
+ await this.functions.open(this._ctx);
378
+ await this.triggers.open(this._ctx);
379
+ }
380
+ async stop() {
381
+ await this._ctx.dispose();
382
+ await this.functions.close();
383
+ await this.triggers.close();
384
+ }
385
+ // TODO(burdon): Remove and update registries directly?
386
+ async register(space, manifest) {
387
+ await this.functions.register(space, manifest.functions);
388
+ await this.triggers.register(space, manifest);
389
+ }
390
+ async _safeActivateTriggers(space, triggers, functions) {
391
+ const mountTasks = triggers.map((trigger) => {
392
+ return this.activate(space, functions, trigger);
393
+ });
394
+ await Promise.all(mountTasks).catch(log2.catch);
395
+ }
396
+ /**
397
+ * Activate trigger.
398
+ */
399
+ // TODO(burdon): How are triggers deactivated?
400
+ async activate(space, functions, trigger) {
401
+ const definition = functions.find((def) => def.uri === trigger.function);
402
+ if (!definition) {
403
+ log2.info("function is not found for trigger", {
404
+ trigger
405
+ }, {
406
+ F: __dxlog_file2,
407
+ L: 85,
408
+ S: this,
409
+ C: (f, a) => f(...a)
410
+ });
411
+ return;
412
+ }
413
+ const execFunction = async (args) => {
414
+ const mutex = this._functionUriToCallMutex.get(definition.uri) ?? new Mutex();
415
+ this._functionUriToCallMutex.set(definition.uri, mutex);
416
+ log2.info("function triggered, waiting for mutex", {
417
+ uri: definition.uri
418
+ }, {
419
+ F: __dxlog_file2,
420
+ L: 93,
421
+ S: this,
422
+ C: (f, a) => f(...a)
423
+ });
424
+ return mutex.executeSynchronized(async () => {
425
+ log2.info("mutex acquired", {
426
+ uri: definition.uri
427
+ }, {
428
+ F: __dxlog_file2,
429
+ L: 95,
430
+ S: this,
431
+ C: (f, a) => f(...a)
432
+ });
433
+ await loadObjectReferences(trigger, (t) => Object.values(t.meta ?? {}));
434
+ const meta = {};
435
+ for (const [key, value] of Object.entries(trigger.meta ?? {})) {
436
+ if (value instanceof Reference) {
437
+ const object = await space.db.loadObjectById(value.objectId);
438
+ if (object) {
439
+ meta[key] = object;
440
+ }
441
+ } else {
442
+ meta[key] = value;
443
+ }
444
+ }
445
+ return this._execFunction(definition, trigger, {
446
+ meta,
447
+ data: {
448
+ ...args,
449
+ spaceKey: space.key
450
+ }
451
+ });
452
+ });
453
+ };
454
+ await this.triggers.activate(space, trigger, execFunction);
455
+ log2("activated trigger", {
456
+ space: space.key,
457
+ trigger
458
+ }, {
459
+ F: __dxlog_file2,
460
+ L: 119,
461
+ S: this,
462
+ C: (f, a) => f(...a)
463
+ });
464
+ }
465
+ /**
466
+ * Invoke function RPC.
467
+ */
468
+ async _execFunction(def, trigger, { meta, data }) {
469
+ let status = 0;
470
+ try {
471
+ const payload = Object.assign({}, meta && {
472
+ meta
473
+ }, data);
474
+ const { endpoint, callback } = this._options;
475
+ if (endpoint) {
476
+ const url = path.join(endpoint, def.route);
477
+ log2.info("exec", {
478
+ function: def.uri,
479
+ url,
480
+ triggerType: trigger.spec.type
481
+ }, {
482
+ F: __dxlog_file2,
483
+ L: 139,
484
+ S: this,
485
+ C: (f, a) => f(...a)
486
+ });
487
+ const response = await fetch(url, {
488
+ method: "POST",
489
+ headers: {
490
+ "Content-Type": "application/json"
491
+ },
492
+ body: JSON.stringify(payload)
493
+ });
494
+ status = response.status;
495
+ } else if (callback) {
496
+ log2.info("exec", {
497
+ function: def.uri
498
+ }, {
499
+ F: __dxlog_file2,
500
+ L: 150,
501
+ S: this,
502
+ C: (f, a) => f(...a)
503
+ });
504
+ status = await callback(payload) ?? 200;
505
+ }
506
+ if (status && status >= 400) {
507
+ throw new Error(`Response: ${status}`);
508
+ }
509
+ log2.info("done", {
510
+ function: def.uri,
511
+ status
512
+ }, {
513
+ F: __dxlog_file2,
514
+ L: 160,
515
+ S: this,
516
+ C: (f, a) => f(...a)
517
+ });
518
+ } catch (err) {
519
+ log2.error("error", {
520
+ function: def.uri,
521
+ error: err.message
522
+ }, {
523
+ F: __dxlog_file2,
524
+ L: 162,
525
+ S: this,
526
+ C: (f, a) => f(...a)
527
+ });
528
+ status = 500;
529
+ }
530
+ return status;
531
+ }
532
+ };
533
+ var createContext2 = () => new Context2({
534
+ name: "FunctionScheduler"
535
+ }, {
536
+ F: __dxlog_file2,
537
+ L: 170
538
+ });
539
+
540
+ // packages/core/functions/src/testing/setup.ts
541
+ var createInitializedClients = async (testBuilder, count = 1, config) => {
542
+ const clients = range(count).map(() => new Client({
543
+ config,
544
+ services: testBuilder.createLocalClientServices()
545
+ }));
546
+ testBuilder.ctx.onDispose(() => Promise.all(clients.map((client) => client.destroy())));
547
+ return Promise.all(clients.map(async (client, index) => {
548
+ await client.initialize();
549
+ await client.halo.createIdentity({
550
+ displayName: `Peer ${index}`
551
+ });
552
+ await client.spaces.isReady.wait();
553
+ client.addTypes([
554
+ FunctionDef,
555
+ FunctionTrigger,
556
+ TestType
557
+ ]);
558
+ return client;
559
+ }));
560
+ };
561
+ var createFunctionRuntime = async (testBuilder, pluginInitializer) => {
562
+ const functionsPort = await getRandomPort("127.0.0.1");
563
+ const config = new Config({
564
+ runtime: {
565
+ agent: {
566
+ plugins: [
567
+ {
568
+ id: "dxos.org/agent/plugin/functions",
569
+ config: {
570
+ port: functionsPort
571
+ }
572
+ }
573
+ ]
574
+ }
575
+ }
576
+ });
577
+ const [client] = await createInitializedClients(testBuilder, 1, config);
578
+ const plugin = await pluginInitializer(client);
579
+ testBuilder.ctx.onDispose(() => plugin.close());
580
+ return client;
581
+ };
582
+ var startFunctionsHost = async (testBuilder, pluginInitializer, options) => {
583
+ const functionRuntime = await createFunctionRuntime(testBuilder, pluginInitializer);
584
+ const functionsRegistry = new FunctionRegistry(functionRuntime);
585
+ const devServer = await startDevServer(testBuilder, functionRuntime, functionsRegistry, options);
586
+ const scheduler = await startScheduler(testBuilder, functionRuntime, devServer, functionsRegistry);
587
+ return {
588
+ scheduler,
589
+ client: functionRuntime,
590
+ waitForActiveTriggers: async (space) => {
591
+ await waitForCondition({
592
+ condition: () => scheduler.triggers.getActiveTriggers(space).length > 0
593
+ });
594
+ }
595
+ };
596
+ };
597
+ var startScheduler = async (testBuilder, client, devServer, functionRegistry) => {
598
+ const triggerRegistry = new TriggerRegistry(client);
599
+ const scheduler = new Scheduler(functionRegistry, triggerRegistry, {
600
+ endpoint: devServer.endpoint
601
+ });
602
+ await scheduler.start();
603
+ testBuilder.ctx.onDispose(() => scheduler.stop());
604
+ return scheduler;
605
+ };
606
+ var startDevServer = async (testBuilder, client, functionRegistry, options) => {
607
+ const server = new DevServer(client, functionRegistry, {
608
+ baseDir: path2.join(__dirname, "../testing"),
609
+ port: await getRandomPort("127.0.0.1"),
610
+ ...options
611
+ });
612
+ await server.start();
613
+ testBuilder.ctx.onDispose(() => server.stop());
614
+ return server;
615
+ };
616
+
617
+ // packages/core/functions/src/testing/util.ts
618
+ import { Filter } from "@dxos/client/echo";
619
+ import { performInvitation } from "@dxos/client/testing";
620
+ import { invariant as invariant2 } from "@dxos/invariant";
621
+ import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
622
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/functions/src/testing/util.ts";
623
+ var triggerWebhook = async (space, uri) => {
624
+ const trigger = (await space.db.query(Filter.schema(FunctionTrigger, (t) => t.function === uri)).run()).objects[0];
625
+ invariant2(trigger.spec.type === "webhook", void 0, {
626
+ F: __dxlog_file3,
627
+ L: 17,
628
+ S: void 0,
629
+ A: [
630
+ "trigger.spec.type === 'webhook'",
631
+ ""
632
+ ]
633
+ });
634
+ void fetch(`http://localhost:${trigger.spec.port}`);
635
+ };
636
+ var inviteMember = async (host, guest) => {
637
+ const [{ invitation: hostInvitation }] = await Promise.all(performInvitation({
638
+ host,
639
+ guest: guest.spaces
640
+ }));
641
+ if (hostInvitation?.state !== Invitation.State.SUCCESS) {
642
+ throw new Error(`Expected ${hostInvitation?.state} to be ${Invitation.State.SUCCESS}.`);
643
+ }
644
+ };
645
+
646
+ // packages/core/functions/src/testing/manifest.ts
647
+ var testFunctionManifest = {
648
+ functions: [
649
+ {
650
+ uri: "example.com/function/test",
651
+ route: "test",
652
+ handler: "test"
653
+ }
654
+ ]
655
+ };
656
+ export {
657
+ TestType,
658
+ createFunctionRuntime,
659
+ createInitializedClients,
660
+ inviteMember,
661
+ startFunctionsHost,
662
+ testFunctionManifest,
663
+ triggerWebhook
664
+ };
665
+ //# sourceMappingURL=index.mjs.map