@dxos/functions 0.7.1 → 0.7.2-staging.6d26b2a

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 (53) hide show
  1. package/dist/lib/browser/{chunk-QX2SGAWR.mjs → chunk-2WV7BKNM.mjs} +28 -159
  2. package/dist/lib/browser/chunk-2WV7BKNM.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-FWIFI2MH.mjs → chunk-MKVZCFKN.mjs} +28 -15
  4. package/dist/lib/browser/chunk-MKVZCFKN.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +5 -7
  6. package/dist/lib/browser/index.mjs.map +2 -2
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/testing/index.mjs +5 -3
  9. package/dist/lib/browser/testing/index.mjs.map +3 -3
  10. package/dist/lib/browser/types.mjs +3 -1
  11. package/dist/lib/node/{chunk-OKV7IWWB.cjs → chunk-G2EVL5ME.cjs} +45 -176
  12. package/dist/lib/node/chunk-G2EVL5ME.cjs.map +7 -0
  13. package/dist/lib/node/{chunk-GKDHAWCP.cjs → chunk-XRSOYOZ5.cjs} +31 -17
  14. package/dist/lib/node/chunk-XRSOYOZ5.cjs.map +7 -0
  15. package/dist/lib/node/index.cjs +14 -16
  16. package/dist/lib/node/index.cjs.map +2 -2
  17. package/dist/lib/node/meta.json +1 -1
  18. package/dist/lib/node/testing/index.cjs +13 -11
  19. package/dist/lib/node/testing/index.cjs.map +3 -3
  20. package/dist/lib/node/types.cjs +9 -7
  21. package/dist/lib/node/types.cjs.map +2 -2
  22. package/dist/lib/node-esm/{chunk-SPHZ5SOR.mjs → chunk-PCEHXPSI.mjs} +28 -159
  23. package/dist/lib/node-esm/chunk-PCEHXPSI.mjs.map +7 -0
  24. package/dist/lib/node-esm/{chunk-YSKH6PBN.mjs → chunk-UZVXZLDV.mjs} +28 -15
  25. package/dist/lib/node-esm/chunk-UZVXZLDV.mjs.map +7 -0
  26. package/dist/lib/node-esm/index.mjs +5 -7
  27. package/dist/lib/node-esm/index.mjs.map +2 -2
  28. package/dist/lib/node-esm/meta.json +1 -1
  29. package/dist/lib/node-esm/testing/index.mjs +5 -3
  30. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  31. package/dist/lib/node-esm/types.mjs +3 -1
  32. package/dist/types/src/handler.d.ts +2 -2
  33. package/dist/types/src/trigger/type/index.d.ts +0 -1
  34. package/dist/types/src/trigger/type/index.d.ts.map +1 -1
  35. package/dist/types/src/types.d.ts +43 -77
  36. package/dist/types/src/types.d.ts.map +1 -1
  37. package/package.json +15 -15
  38. package/src/handler.ts +3 -3
  39. package/src/runtime/scheduler.test.ts +4 -55
  40. package/src/runtime/scheduler.ts +1 -1
  41. package/src/testing/functions-integration.test.ts +2 -2
  42. package/src/trigger/trigger-registry.test.ts +4 -4
  43. package/src/trigger/type/index.ts +0 -1
  44. package/src/types.ts +26 -24
  45. package/dist/lib/browser/chunk-FWIFI2MH.mjs.map +0 -7
  46. package/dist/lib/browser/chunk-QX2SGAWR.mjs.map +0 -7
  47. package/dist/lib/node/chunk-GKDHAWCP.cjs.map +0 -7
  48. package/dist/lib/node/chunk-OKV7IWWB.cjs.map +0 -7
  49. package/dist/lib/node-esm/chunk-SPHZ5SOR.mjs.map +0 -7
  50. package/dist/lib/node-esm/chunk-YSKH6PBN.mjs.map +0 -7
  51. package/dist/types/src/trigger/type/websocket-trigger.d.ts +0 -14
  52. package/dist/types/src/trigger/type/websocket-trigger.d.ts.map +0 -1
  53. package/src/trigger/type/websocket-trigger.ts +0 -112
@@ -16,17 +16,15 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_OKV7IWWB_exports = {};
20
- __export(chunk_OKV7IWWB_exports, {
19
+ var chunk_G2EVL5ME_exports = {};
20
+ __export(chunk_G2EVL5ME_exports, {
21
21
  FunctionRegistry: () => FunctionRegistry,
22
22
  TriggerRegistry: () => TriggerRegistry,
23
23
  createSubscriptionTrigger: () => createSubscriptionTrigger,
24
- createTimerTrigger: () => createTimerTrigger,
25
- createWebSocket: () => createWebSocket,
26
- createWebsocketTrigger: () => createWebsocketTrigger
24
+ createTimerTrigger: () => createTimerTrigger
27
25
  });
28
- module.exports = __toCommonJS(chunk_OKV7IWWB_exports);
29
- var import_chunk_GKDHAWCP = require("./chunk-GKDHAWCP.cjs");
26
+ module.exports = __toCommonJS(chunk_G2EVL5ME_exports);
27
+ var import_chunk_XRSOYOZ5 = require("./chunk-XRSOYOZ5.cjs");
30
28
  var import_async = require("@dxos/async");
31
29
  var import_echo = require("@dxos/client/echo");
32
30
  var import_context = require("@dxos/context");
@@ -41,14 +39,12 @@ var import_cron = require("cron");
41
39
  var import_async3 = require("@dxos/async");
42
40
  var import_log3 = require("@dxos/log");
43
41
  var import_async4 = require("@dxos/async");
44
- var import_log4 = require("@dxos/log");
45
- var import_async5 = require("@dxos/async");
46
42
  var import_echo3 = require("@dxos/client/echo");
47
43
  var import_context2 = require("@dxos/context");
48
44
  var import_echo_schema = require("@dxos/echo-schema");
49
45
  var import_invariant = require("@dxos/invariant");
50
46
  var import_keys2 = require("@dxos/keys");
51
- var import_log5 = require("@dxos/log");
47
+ var import_log4 = require("@dxos/log");
52
48
  var import_util2 = require("@dxos/util");
53
49
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/functions/src/function/function-registry.ts";
54
50
  var FunctionRegistry = class extends import_context.Resource {
@@ -89,14 +85,14 @@ var FunctionRegistry = class extends import_context.Resource {
89
85
  if (!functions?.length) {
90
86
  return;
91
87
  }
92
- if (!space.db.graph.schemaRegistry.hasSchema(import_chunk_GKDHAWCP.FunctionDef)) {
88
+ if (!space.db.graph.schemaRegistry.hasSchema(import_chunk_XRSOYOZ5.FunctionDef)) {
93
89
  space.db.graph.schemaRegistry.addSchema([
94
- import_chunk_GKDHAWCP.FunctionDef
90
+ import_chunk_XRSOYOZ5.FunctionDef
95
91
  ]);
96
92
  }
97
- const { objects: existing } = await space.db.query(import_echo.Filter.schema(import_chunk_GKDHAWCP.FunctionDef)).run();
93
+ const { objects: existing } = await space.db.query(import_echo.Filter.schema(import_chunk_XRSOYOZ5.FunctionDef)).run();
98
94
  const { added } = (0, import_util.diff)(existing, functions, (a, b) => a.uri === b.uri);
99
- added.forEach((def) => space.db.add((0, import_echo.create)(import_chunk_GKDHAWCP.FunctionDef, def)));
95
+ added.forEach((def) => space.db.add((0, import_echo.create)(import_chunk_XRSOYOZ5.FunctionDef, def)));
100
96
  if (added.length > 0) {
101
97
  await space.db.flush({
102
98
  indexes: true,
@@ -122,7 +118,7 @@ var FunctionRegistry = class extends import_context.Resource {
122
118
  if (this._ctx.disposed) {
123
119
  break;
124
120
  }
125
- this._ctx.onDispose(space.db.query(import_echo.Filter.schema(import_chunk_GKDHAWCP.FunctionDef)).subscribe(({ objects }) => {
121
+ this._ctx.onDispose(space.db.query(import_echo.Filter.schema(import_chunk_XRSOYOZ5.FunctionDef)).subscribe(({ objects }) => {
126
122
  const { added } = (0, import_util.diff)(registered, objects, (a, b) => a.uri === b.uri);
127
123
  if (added.length > 0) {
128
124
  registered.push(...added);
@@ -244,132 +240,7 @@ var createTimerTrigger = async (ctx, space, spec, callback) => {
244
240
  job.start();
245
241
  ctx.onDispose(() => job.stop());
246
242
  };
247
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/functions/src/trigger/type/websocket-trigger.ts";
248
- var createWebsocketTrigger = async (ctx, space, spec, callback, options = {
249
- retryDelay: 2,
250
- maxAttempts: 5
251
- }) => {
252
- const { url, init } = spec;
253
- let wasOpen = false;
254
- let ws;
255
- for (let attempt = 1; attempt <= options.maxAttempts; attempt++) {
256
- const open = new import_async4.Trigger();
257
- ws = await createWebSocket(url);
258
- Object.assign(ws, {
259
- onopen: () => {
260
- import_log4.log.info("opened", {
261
- url
262
- }, {
263
- F: __dxlog_file4,
264
- L: 39,
265
- S: void 0,
266
- C: (f, a) => f(...a)
267
- });
268
- if (spec.init) {
269
- ws.send(new TextEncoder().encode(JSON.stringify(init)));
270
- }
271
- open.wake(true);
272
- },
273
- onclose: (event) => {
274
- import_log4.log.info("closed", {
275
- url,
276
- code: event.code
277
- }, {
278
- F: __dxlog_file4,
279
- L: 48,
280
- S: void 0,
281
- C: (f, a) => f(...a)
282
- });
283
- if (event.code === 1006 && wasOpen && !ctx.disposed) {
284
- setTimeout(async () => {
285
- import_log4.log.info(`reconnecting in ${options.retryDelay}s...`, {
286
- url
287
- }, {
288
- F: __dxlog_file4,
289
- L: 53,
290
- S: void 0,
291
- C: (f, a) => f(...a)
292
- });
293
- await createWebsocketTrigger(ctx, space, spec, callback, options);
294
- }, options.retryDelay * 1e3);
295
- }
296
- open.wake(false);
297
- },
298
- onerror: (event) => {
299
- import_log4.log.catch(event.error ?? new Error("Unspecified ws error."), {
300
- url
301
- }, {
302
- F: __dxlog_file4,
303
- L: 61,
304
- S: void 0,
305
- C: (f, a) => f(...a)
306
- });
307
- open.wake(false);
308
- },
309
- onmessage: async (event) => {
310
- try {
311
- import_log4.log.info("message", void 0, {
312
- F: __dxlog_file4,
313
- L: 67,
314
- S: void 0,
315
- C: (f, a) => f(...a)
316
- });
317
- let data;
318
- if (event.data && "text" in event.data) {
319
- data = JSON.parse(await event.data.text());
320
- } else {
321
- data = JSON.parse(new TextDecoder().decode(event.data));
322
- }
323
- await callback({
324
- data
325
- });
326
- } catch (err) {
327
- import_log4.log.catch(err, {
328
- url,
329
- data: event.data
330
- }, {
331
- F: __dxlog_file4,
332
- L: 76,
333
- S: void 0,
334
- C: (f, a) => f(...a)
335
- });
336
- }
337
- }
338
- });
339
- const isOpen = await open.wait();
340
- if (ctx.disposed) {
341
- break;
342
- }
343
- if (isOpen) {
344
- wasOpen = true;
345
- break;
346
- }
347
- const wait = Math.pow(attempt, 2) * options.retryDelay;
348
- if (attempt < options.maxAttempts) {
349
- import_log4.log.warn(`failed to connect; trying again in ${wait}s`, {
350
- attempt
351
- }, {
352
- F: __dxlog_file4,
353
- L: 91,
354
- S: void 0,
355
- C: (f, a) => f(...a)
356
- });
357
- await (0, import_async4.sleep)(wait * 1e3);
358
- }
359
- }
360
- ctx.onDispose(() => {
361
- ws?.close();
362
- });
363
- };
364
- var createNodeWebSocket = async (url) => {
365
- const importESM = Function("path", "return import(path)");
366
- const { default: { WebSocket: WebSocket1 } } = await importESM("ws");
367
- return new WebSocket1(url);
368
- };
369
- var createWebSocket = async (url) => {
370
- return typeof globalThis.WebSocket === "undefined" ? await createNodeWebSocket(url) : new WebSocket(url);
371
- };
372
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/functions/src/trigger/trigger-registry.ts";
243
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/functions/src/trigger/trigger-registry.ts";
373
244
  var triggerFactory = {
374
245
  timer: createTimerTrigger,
375
246
  // TODO(burdon): Cannot use in browser.
@@ -382,8 +253,8 @@ var TriggerRegistry = class extends import_context2.Resource {
382
253
  this._client = _client;
383
254
  this._options = _options;
384
255
  this._triggersBySpaceKey = new import_util2.ComplexMap(import_keys2.PublicKey.hash);
385
- this.registered = new import_async5.Event();
386
- this.removed = new import_async5.Event();
256
+ this.registered = new import_async4.Event();
257
+ this.removed = new import_async4.Event();
387
258
  }
388
259
  getActiveTriggers(space) {
389
260
  return this._getTriggers(space, (t) => t.activationCtx != null);
@@ -395,11 +266,11 @@ var TriggerRegistry = class extends import_context2.Resource {
395
266
  * Set callback for trigger.
396
267
  */
397
268
  async activate(space, trigger, callback) {
398
- (0, import_log5.log)("activate", {
269
+ (0, import_log4.log)("activate", {
399
270
  space: space.key,
400
271
  trigger
401
272
  }, {
402
- F: __dxlog_file5,
273
+ F: __dxlog_file4,
403
274
  L: 75,
404
275
  S: this,
405
276
  C: (f, a) => f(...a)
@@ -407,13 +278,13 @@ var TriggerRegistry = class extends import_context2.Resource {
407
278
  const activationCtx = new import_context2.Context({
408
279
  name: `FunctionTrigger-${trigger.function}`
409
280
  }, {
410
- F: __dxlog_file5,
281
+ F: __dxlog_file4,
411
282
  L: 77
412
283
  });
413
284
  this._ctx.onDispose(() => activationCtx.dispose());
414
285
  const registeredTrigger = this._triggersBySpaceKey.get(space.key)?.find((reg) => reg.trigger.id === trigger.id);
415
286
  (0, import_invariant.invariant)(registeredTrigger, `Trigger is not registered: ${trigger.function}`, {
416
- F: __dxlog_file5,
287
+ F: __dxlog_file4,
417
288
  L: 80,
418
289
  S: this,
419
290
  A: [
@@ -424,7 +295,7 @@ var TriggerRegistry = class extends import_context2.Resource {
424
295
  registeredTrigger.activationCtx = activationCtx;
425
296
  try {
426
297
  (0, import_invariant.invariant)(trigger.spec, void 0, {
427
- F: __dxlog_file5,
298
+ F: __dxlog_file4,
428
299
  L: 85,
429
300
  S: this,
430
301
  A: [
@@ -435,7 +306,7 @@ var TriggerRegistry = class extends import_context2.Resource {
435
306
  const options = this._options?.[trigger.spec.type];
436
307
  const createTrigger = triggerFactory[trigger.spec.type];
437
308
  (0, import_invariant.invariant)(createTrigger, `Trigger factory not found: ${trigger.spec.type}`, {
438
- F: __dxlog_file5,
309
+ F: __dxlog_file4,
439
310
  L: 88,
440
311
  S: this,
441
312
  A: [
@@ -453,10 +324,10 @@ var TriggerRegistry = class extends import_context2.Resource {
453
324
  * Loads triggers from the manifest into the space.
454
325
  */
455
326
  async register(space, manifest) {
456
- (0, import_log5.log)("register", {
327
+ (0, import_log4.log)("register", {
457
328
  space: space.key
458
329
  }, {
459
- F: __dxlog_file5,
330
+ F: __dxlog_file4,
460
331
  L: 100,
461
332
  S: this,
462
333
  C: (f, a) => f(...a)
@@ -464,9 +335,9 @@ var TriggerRegistry = class extends import_context2.Resource {
464
335
  if (!manifest.triggers?.length) {
465
336
  return;
466
337
  }
467
- if (!space.db.graph.schemaRegistry.hasSchema(import_chunk_GKDHAWCP.FunctionTrigger)) {
338
+ if (!space.db.graph.schemaRegistry.hasSchema(import_chunk_XRSOYOZ5.FunctionTrigger)) {
468
339
  space.db.graph.schemaRegistry.addSchema([
469
- import_chunk_GKDHAWCP.FunctionTrigger
340
+ import_chunk_XRSOYOZ5.FunctionTrigger
470
341
  ]);
471
342
  }
472
343
  const manifestTriggers = manifest.triggers.map((trigger) => {
@@ -480,18 +351,18 @@ var TriggerRegistry = class extends import_context2.Resource {
480
351
  ].join(":"))
481
352
  ];
482
353
  }
483
- return (0, import_echo3.create)(import_chunk_GKDHAWCP.FunctionTrigger, trigger, {
354
+ return (0, import_echo3.create)(import_chunk_XRSOYOZ5.FunctionTrigger, trigger, {
484
355
  keys
485
356
  });
486
357
  });
487
- const { objects: existing } = await space.db.query(import_echo3.Filter.schema(import_chunk_GKDHAWCP.FunctionTrigger)).run();
358
+ const { objects: existing } = await space.db.query(import_echo3.Filter.schema(import_chunk_XRSOYOZ5.FunctionTrigger)).run();
488
359
  const { added } = (0, import_util2.diff)(existing, manifestTriggers, import_echo_schema.compareForeignKeys);
489
360
  added.forEach((trigger) => {
490
361
  space.db.add(trigger);
491
- import_log5.log.info("added", {
362
+ import_log4.log.info("added", {
492
363
  meta: (0, import_echo3.getMeta)(trigger)
493
364
  }, {
494
- F: __dxlog_file5,
365
+ F: __dxlog_file4,
495
366
  L: 127,
496
367
  S: this,
497
368
  C: (f, a) => f(...a)
@@ -502,8 +373,8 @@ var TriggerRegistry = class extends import_context2.Resource {
502
373
  }
503
374
  }
504
375
  async _open() {
505
- import_log5.log.info("open...", void 0, {
506
- F: __dxlog_file5,
376
+ import_log4.log.info("open...", void 0, {
377
+ F: __dxlog_file4,
507
378
  L: 136,
508
379
  S: this,
509
380
  C: (f, a) => f(...a)
@@ -519,13 +390,13 @@ var TriggerRegistry = class extends import_context2.Resource {
519
390
  if (this._ctx.disposed) {
520
391
  break;
521
392
  }
522
- this._ctx.onDispose(space.db.query(import_echo3.Filter.schema(import_chunk_GKDHAWCP.FunctionTrigger)).subscribe(async ({ objects: current }) => {
523
- import_log5.log.info("update", {
393
+ this._ctx.onDispose(space.db.query(import_echo3.Filter.schema(import_chunk_XRSOYOZ5.FunctionTrigger)).subscribe(async ({ objects: current }) => {
394
+ import_log4.log.info("update", {
524
395
  space: space.key,
525
396
  registered: registered.length,
526
397
  current: current.length
527
398
  }, {
528
- F: __dxlog_file5,
399
+ F: __dxlog_file4,
529
400
  L: 153,
530
401
  S: this,
531
402
  C: (f, a) => f(...a)
@@ -536,23 +407,23 @@ var TriggerRegistry = class extends import_context2.Resource {
536
407
  }
537
408
  });
538
409
  this._ctx.onDispose(() => spaceListSubscription.unsubscribe());
539
- import_log5.log.info("opened", void 0, {
540
- F: __dxlog_file5,
410
+ import_log4.log.info("opened", void 0, {
411
+ F: __dxlog_file4,
541
412
  L: 162,
542
413
  S: this,
543
414
  C: (f, a) => f(...a)
544
415
  });
545
416
  }
546
417
  async _close(_) {
547
- import_log5.log.info("close...", void 0, {
548
- F: __dxlog_file5,
418
+ import_log4.log.info("close...", void 0, {
419
+ F: __dxlog_file4,
549
420
  L: 166,
550
421
  S: this,
551
422
  C: (f, a) => f(...a)
552
423
  });
553
424
  this._triggersBySpaceKey.clear();
554
- import_log5.log.info("closed", void 0, {
555
- F: __dxlog_file5,
425
+ import_log4.log.info("closed", void 0, {
426
+ F: __dxlog_file4,
556
427
  L: 168,
557
428
  S: this,
558
429
  C: (f, a) => f(...a)
@@ -567,11 +438,11 @@ var TriggerRegistry = class extends import_context2.Resource {
567
438
  trigger
568
439
  }));
569
440
  registered.push(...newRegisteredTriggers);
570
- import_log5.log.info("added", () => ({
441
+ import_log4.log.info("added", () => ({
571
442
  spaceKey: space.key,
572
443
  triggers: added.map((trigger) => trigger.function)
573
444
  }), {
574
- F: __dxlog_file5,
445
+ F: __dxlog_file4,
575
446
  L: 179,
576
447
  S: this,
577
448
  C: (f, a) => f(...a)
@@ -593,11 +464,11 @@ var TriggerRegistry = class extends import_context2.Resource {
593
464
  }
594
465
  }
595
466
  if (removed.length > 0) {
596
- import_log5.log.info("removed", () => ({
467
+ import_log4.log.info("removed", () => ({
597
468
  spaceKey: space.key,
598
469
  triggers: removed.map((trigger) => trigger.function)
599
470
  }), {
600
- F: __dxlog_file5,
471
+ F: __dxlog_file4,
601
472
  L: 205,
602
473
  S: this,
603
474
  C: (f, a) => f(...a)
@@ -618,8 +489,6 @@ var TriggerRegistry = class extends import_context2.Resource {
618
489
  FunctionRegistry,
619
490
  TriggerRegistry,
620
491
  createSubscriptionTrigger,
621
- createTimerTrigger,
622
- createWebSocket,
623
- createWebsocketTrigger
492
+ createTimerTrigger
624
493
  });
625
- //# sourceMappingURL=chunk-OKV7IWWB.cjs.map
494
+ //# sourceMappingURL=chunk-G2EVL5ME.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/function/function-registry.ts", "../../../src/trigger/type/subscription-trigger.ts", "../../../src/trigger/type/timer-trigger.ts", "../../../src/trigger/trigger-registry.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Event } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { create, Filter, type Space } from '@dxos/client/echo';\nimport { type Context, Resource } from '@dxos/context';\nimport { PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { ComplexMap, diff } from '@dxos/util';\n\nimport { FunctionDef, type FunctionManifest } from '../types';\n\nexport type FunctionsRegisteredEvent = {\n space: Space;\n added: FunctionDef[];\n};\n\nexport class FunctionRegistry extends Resource {\n private readonly _functionBySpaceKey = new ComplexMap<PublicKey, FunctionDef[]>(PublicKey.hash);\n\n public readonly registered = new Event<FunctionsRegisteredEvent>();\n\n constructor(private readonly _client: Client) {\n super();\n }\n\n public getFunctions(space: Space): FunctionDef[] {\n return this._functionBySpaceKey.get(space.key) ?? [];\n }\n\n public getUniqueByUri(): FunctionDef[] {\n const uniqueByUri = [...this._functionBySpaceKey.values()]\n .flatMap((defs) => defs)\n .reduce((acc, v) => {\n acc.set(v.uri, v);\n return acc;\n }, new Map<string, FunctionDef>());\n return [...uniqueByUri.values()];\n }\n\n /**\n * Loads function definitions from the manifest into the space.\n * We first load all the definitions from the space to deduplicate by functionId.\n */\n public async register(space: Space, functions: FunctionManifest['functions']): Promise<void> {\n log('register', { space: space.key, functions: functions?.length ?? 0 });\n if (!functions?.length) {\n return;\n }\n if (!space.db.graph.schemaRegistry.hasSchema(FunctionDef)) {\n space.db.graph.schemaRegistry.addSchema([FunctionDef]);\n }\n\n // Sync definitions.\n const { objects: existing } = await space.db.query(Filter.schema(FunctionDef)).run();\n const { added } = diff(existing, functions, (a, b) => a.uri === b.uri);\n // TODO(burdon): Update existing templates.\n added.forEach((def) => space.db.add(create(FunctionDef, def)));\n\n if (added.length > 0) {\n await space.db.flush({ indexes: true, updates: true });\n }\n }\n\n protected override async _open(): Promise<void> {\n log.info('opening...');\n const spacesSubscription = this._client.spaces.subscribe(async (spaces) => {\n for (const space of spaces) {\n if (this._functionBySpaceKey.has(space.key)) {\n continue;\n }\n\n const registered: FunctionDef[] = [];\n this._functionBySpaceKey.set(space.key, registered);\n await space.waitUntilReady();\n if (this._ctx.disposed) {\n break;\n }\n\n // Subscribe to updates.\n this._ctx.onDispose(\n space.db.query(Filter.schema(FunctionDef)).subscribe(({ objects }) => {\n const { added } = diff(registered, objects, (a, b) => a.uri === b.uri);\n // TODO(burdon): Update and remove.\n if (added.length > 0) {\n registered.push(...added);\n this.registered.emit({ space, added });\n }\n }),\n );\n }\n });\n\n // TODO(burdon): API: Normalize unsubscribe methods.\n this._ctx.onDispose(() => spacesSubscription.unsubscribe());\n }\n\n protected override async _close(_: Context): Promise<void> {\n log.info('closing...');\n this._functionBySpaceKey.clear();\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { debounce, UpdateScheduler } from '@dxos/async';\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { type Context } from '@dxos/context';\nimport { createSubscription, type Query } from '@dxos/echo-db';\nimport { log } from '@dxos/log';\n\nimport type { SubscriptionTrigger } from '../../types';\nimport { type TriggerCallback, type TriggerFactory } from '../trigger-registry';\n\nexport const createSubscriptionTrigger: TriggerFactory<SubscriptionTrigger> = async (\n ctx: Context,\n space: Space,\n spec: SubscriptionTrigger,\n callback: TriggerCallback,\n) => {\n const objectIds = new Set<string>();\n const task = new UpdateScheduler(\n ctx,\n async () => {\n if (objectIds.size > 0) {\n const objects = Array.from(objectIds);\n objectIds.clear();\n await callback({ objects });\n }\n },\n { maxFrequency: 4 },\n );\n\n // TODO(burdon): Factor out diff.\n // TODO(burdon): Don't fire initially?\n // TODO(burdon): Create queue. Only allow one invocation per trigger at a time?\n const subscriptions: (() => void)[] = [];\n const subscription = createSubscription(({ added, updated }) => {\n const sizeBefore = objectIds.size;\n for (const object of added) {\n objectIds.add(object.id);\n }\n for (const object of updated) {\n objectIds.add(object.id);\n }\n if (objectIds.size > sizeBefore) {\n log.info('updated', { added: added.length, updated: updated.length });\n task.trigger();\n }\n });\n\n subscriptions.push(() => subscription.unsubscribe());\n\n // TODO(burdon): Disable trigger if keeps failing.\n const { filter, options: { deep, delay } = {} } = spec;\n const update = ({ objects }: Query) => {\n log.info('update', { objects: objects.length });\n subscription.update(objects);\n\n // TODO(burdon): Hack to monitor changes to Document's text object.\n if (deep) {\n // TODO(dmaretskyi): Removed to not have dependency on markdown-plugin.\n // for (const object of objects) {\n // const content = object.content;\n // if (content instanceof TextType) {\n // subscriptions.push(getObjectCore(content).updates.on(debounce(() => subscription.update([object]), 1_000)));\n // }\n // }\n }\n };\n\n // TODO(burdon): OR not working.\n // TODO(burdon): [Bug]: all callbacks are fired on the first mutation.\n // TODO(burdon): [Bug]: not updated when document is deleted (either top or hierarchically).\n log.info('subscription', { filter });\n // const query = triggerCtx.space.db.query(Filter.or(filter.map(({ type, props }) => Filter.typename(type, props))));\n if (filter.type) {\n const query = space.db.query(Filter.typename(filter.type, filter.props));\n subscriptions.push(query.subscribe(delay ? debounce(update, delay) : update));\n }\n\n ctx.onDispose(() => {\n subscriptions.forEach((unsubscribe) => unsubscribe());\n });\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { CronJob } from 'cron';\n\nimport { DeferredTask } from '@dxos/async';\nimport { type Space } from '@dxos/client/echo';\nimport { type Context } from '@dxos/context';\nimport { log } from '@dxos/log';\n\nimport type { TimerTrigger } from '../../types';\nimport { type TriggerCallback, type TriggerFactory } from '../trigger-registry';\n\nexport const createTimerTrigger: TriggerFactory<TimerTrigger> = async (\n ctx: Context,\n space: Space,\n spec: TimerTrigger,\n callback: TriggerCallback,\n) => {\n const task = new DeferredTask(ctx, async () => {\n await callback({});\n });\n\n let last = 0;\n let run = 0;\n // https://www.npmjs.com/package/cron#constructor\n const job = CronJob.from({\n cronTime: spec.cron,\n runOnInit: false,\n onTick: () => {\n // TODO(burdon): Check greater than 30s (use cron-parser).\n const now = Date.now();\n const delta = last ? now - last : 0;\n last = now;\n\n run++;\n log.info('tick', { space: space.key.truncate(), count: run, delta });\n task.schedule();\n },\n });\n\n job.start();\n ctx.onDispose(() => job.stop());\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Event } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { create, Filter, getMeta, type Space } from '@dxos/client/echo';\nimport { Context, Resource } from '@dxos/context';\nimport { compareForeignKeys, ECHO_ATTR_META, foreignKey } from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { ComplexMap, diff } from '@dxos/util';\n\nimport { createSubscriptionTrigger, createTimerTrigger } from './type';\nimport { type FunctionManifest, FunctionTrigger, type TriggerKind, type TriggerType } from '../types';\n\ntype ResponseCode = number;\n\nexport type TriggerCallback = (args: object) => Promise<ResponseCode>;\n\n// TODO(burdon): Make object?\nexport type TriggerFactory<Spec extends TriggerType, Options = any> = (\n ctx: Context,\n space: Space,\n spec: Spec,\n callback: TriggerCallback,\n options?: Options,\n) => Promise<void>;\n\nexport type TriggerFactoryMap = Partial<Record<TriggerKind, TriggerFactory<any>>>;\n\nconst triggerFactory: TriggerFactoryMap = {\n timer: createTimerTrigger,\n // TODO(burdon): Cannot use in browser.\n // webhook: createWebhookTrigger,\n subscription: createSubscriptionTrigger,\n};\n\nexport type TriggerEvent = {\n space: Space;\n triggers: FunctionTrigger[];\n};\n\ntype RegisteredTrigger = {\n activationCtx?: Context;\n trigger: FunctionTrigger;\n};\n\nexport class TriggerRegistry extends Resource {\n private readonly _triggersBySpaceKey = new ComplexMap<PublicKey, RegisteredTrigger[]>(PublicKey.hash);\n\n public readonly registered = new Event<TriggerEvent>();\n public readonly removed = new Event<TriggerEvent>();\n\n constructor(\n private readonly _client: Client,\n private readonly _options?: TriggerFactoryMap,\n ) {\n super();\n }\n\n public getActiveTriggers(space: Space): FunctionTrigger[] {\n return this._getTriggers(space, (t) => t.activationCtx != null);\n }\n\n public getInactiveTriggers(space: Space): FunctionTrigger[] {\n return this._getTriggers(space, (t) => t.activationCtx == null);\n }\n\n /**\n * Set callback for trigger.\n */\n public async activate(space: Space, trigger: FunctionTrigger, callback: TriggerCallback): Promise<void> {\n log('activate', { space: space.key, trigger });\n\n const activationCtx = new Context({ name: `FunctionTrigger-${trigger.function}` });\n this._ctx.onDispose(() => activationCtx.dispose());\n const registeredTrigger = this._triggersBySpaceKey.get(space.key)?.find((reg) => reg.trigger.id === trigger.id);\n invariant(registeredTrigger, `Trigger is not registered: ${trigger.function}`);\n registeredTrigger.activationCtx = activationCtx;\n\n try {\n // Create trigger.\n invariant(trigger.spec);\n const options = this._options?.[trigger.spec.type];\n const createTrigger = triggerFactory[trigger.spec.type];\n invariant(createTrigger, `Trigger factory not found: ${trigger.spec.type}`);\n await createTrigger(activationCtx, space, trigger.spec, callback, options);\n } catch (err) {\n delete registeredTrigger.activationCtx;\n throw err;\n }\n }\n\n /**\n * Loads triggers from the manifest into the space.\n */\n public async register(space: Space, manifest: FunctionManifest): Promise<void> {\n log('register', { space: space.key });\n if (!manifest.triggers?.length) {\n return;\n }\n\n if (!space.db.graph.schemaRegistry.hasSchema(FunctionTrigger)) {\n space.db.graph.schemaRegistry.addSchema([FunctionTrigger]);\n }\n\n // Create FK to enable syncing if none are set (NOTE: Possible collision).\n const manifestTriggers = manifest.triggers.map((trigger) => {\n let keys = trigger[ECHO_ATTR_META]?.keys;\n delete trigger[ECHO_ATTR_META];\n if (!keys?.length) {\n keys = [foreignKey('manifest', [trigger.function, trigger.spec?.type].join(':'))];\n }\n\n return create(FunctionTrigger, trigger, { keys });\n });\n\n // Sync triggers.\n const { objects: existing } = await space.db.query(Filter.schema(FunctionTrigger)).run();\n const { added } = diff(existing, manifestTriggers, compareForeignKeys);\n\n // TODO(burdon): Update existing.\n added.forEach((trigger) => {\n space.db.add(trigger);\n log.info('added', { meta: getMeta(trigger) });\n });\n\n if (added.length > 0) {\n await space.db.flush();\n }\n }\n\n protected override async _open(): Promise<void> {\n log.info('open...');\n const spaceListSubscription = this._client.spaces.subscribe(async (spaces) => {\n for (const space of spaces) {\n if (this._triggersBySpaceKey.has(space.key)) {\n continue;\n }\n\n const registered: RegisteredTrigger[] = [];\n this._triggersBySpaceKey.set(space.key, registered);\n await space.waitUntilReady();\n if (this._ctx.disposed) {\n break;\n }\n\n // Subscribe to updates.\n this._ctx.onDispose(\n space.db.query(Filter.schema(FunctionTrigger)).subscribe(async ({ objects: current }) => {\n log.info('update', { space: space.key, registered: registered.length, current: current.length });\n await this._handleRemovedTriggers(space, current, registered);\n this._handleNewTriggers(space, current, registered);\n }),\n );\n }\n });\n\n this._ctx.onDispose(() => spaceListSubscription.unsubscribe());\n log.info('opened');\n }\n\n protected override async _close(_: Context): Promise<void> {\n log.info('close...');\n this._triggersBySpaceKey.clear();\n log.info('closed');\n }\n\n private _handleNewTriggers(space: Space, current: FunctionTrigger[], registered: RegisteredTrigger[]) {\n const added = current.filter((candidate) => {\n return candidate.enabled && registered.find((reg) => reg.trigger.id === candidate.id) == null;\n });\n\n if (added.length > 0) {\n const newRegisteredTriggers: RegisteredTrigger[] = added.map((trigger) => ({ trigger }));\n registered.push(...newRegisteredTriggers);\n log.info('added', () => ({\n spaceKey: space.key,\n triggers: added.map((trigger) => trigger.function),\n }));\n\n this.registered.emit({ space, triggers: added });\n }\n }\n\n private async _handleRemovedTriggers(\n space: Space,\n current: FunctionTrigger[],\n registered: RegisteredTrigger[],\n ): Promise<void> {\n const removed: FunctionTrigger[] = [];\n for (let i = registered.length - 1; i >= 0; i--) {\n const wasRemoved =\n current.filter((trigger) => trigger.enabled).find((trigger) => trigger.id === registered[i].trigger.id) == null;\n if (wasRemoved) {\n const unregistered = registered.splice(i, 1)[0];\n await unregistered.activationCtx?.dispose();\n removed.push(unregistered.trigger);\n }\n }\n\n if (removed.length > 0) {\n log.info('removed', () => ({\n spaceKey: space.key,\n triggers: removed.map((trigger) => trigger.function),\n }));\n\n this.removed.emit({ space, triggers: removed });\n }\n }\n\n private _getTriggers(space: Space, predicate: (trigger: RegisteredTrigger) => boolean): FunctionTrigger[] {\n const allSpaceTriggers = this._triggersBySpaceKey.get(space.key) ?? [];\n return allSpaceTriggers.filter(predicate).map((trigger) => trigger.trigger);\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAsB;AAEtB,kBAA2C;AAC3C,qBAAuC;AACvC,kBAA0B;AAC1B,iBAAoB;AACpB,kBAAiC;ACNjC,IAAAA,gBAA0C;AAC1C,IAAAC,eAAmC;AAEnC,qBAA+C;AAC/C,IAAAC,cAAoB;ACJpB,kBAAwB;AAExB,IAAAF,gBAA6B;AAG7B,IAAAE,cAAoB;ACLpB,IAAAF,gBAAsB;AAEtB,IAAAC,eAAoD;AACpD,IAAAE,kBAAkC;AAClC,yBAA+D;AAC/D,uBAA0B;AAC1B,IAAAC,eAA0B;AAC1B,IAAAF,cAAoB;AACpB,IAAAG,eAAiC;;AHO1B,IAAMC,mBAAN,cAA+BC,wBAAAA;EAKpCC,YAA6BC,SAAiB;AAC5C,UAAK;SADsBA,UAAAA;SAJZC,sBAA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AAC5C,YAAYA,QAAQD,OAAO9E,WAAWoJ,CAAAA,EAAGrE,QAAQD,EAAE,KAAK;AAC7G,UAAIuE,YAAY;AACd,cAAMC,eAAetJ,WAAWuJ,OAAOH,GAAG,CAAA,EAAG,CAAA;AAC7C,cAAME,aAAanC,eAAeM,QAAAA;AAClCV,gBAAQzD,KAAKgG,aAAavE,OAAO;MACnC;IACF;AAEA,QAAIgC,QAAQ3F,SAAS,GAAG;AACtBD,kBAAAA,IAAI0B,KAAK,WAAW,OAAO;QACzBsG,UAAUhJ,MAAME;QAChB4H,UAAUlB,QAAQqB,IAAI,CAACrD,YAAYA,QAAQyC,QAAQ;MACrD,IAAA;;;;;;AAEA,WAAKT,QAAQxD,KAAK;QAAEpD;QAAO8H,UAAUlB;MAAQ,CAAA;IAC/C;EACF;EAEQE,aAAa9G,OAAcqJ,WAAuE;AACxG,UAAMC,mBAAmB,KAAK3C,oBAAoB1G,IAAID,MAAME,GAAG,KAAK,CAAA;AACpE,WAAOoJ,iBAAiBzE,OAAOwE,SAAAA,EAAWpB,IAAI,CAACrD,YAAYA,QAAQA,OAAO;EAC5E;AACF;",
6
+ "names": ["import_async", "import_echo", "import_log", "import_context", "import_keys", "import_util", "FunctionRegistry", "Resource", "constructor", "_client", "_functionBySpaceKey", "ComplexMap", "PublicKey", "hash", "registered", "Event", "getFunctions", "space", "get", "key", "getUniqueByUri", "uniqueByUri", "values", "flatMap", "defs", "reduce", "acc", "v", "set", "uri", "Map", "register", "functions", "log", "length", "db", "graph", "schemaRegistry", "hasSchema", "FunctionDef", "addSchema", "objects", "existing", "query", "Filter", "schema", "run", "added", "diff", "a", "b", "forEach", "def", "add", "create", "flush", "indexes", "updates", "_open", "info", "spacesSubscription", "spaces", "subscribe", "has", "waitUntilReady", "_ctx", "disposed", "onDispose", "push", "emit", "unsubscribe", "_close", "_", "clear", "createSubscriptionTrigger", "ctx", "spec", "callback", "objectIds", "Set", "task", "UpdateScheduler", "size", "Array", "from", "maxFrequency", "subscriptions", "subscription", "createSubscription", "updated", "sizeBefore", "object", "id", "trigger", "filter", "options", "deep", "delay", "update", "type", "typename", "props", "debounce", "createTimerTrigger", "DeferredTask", "last", "job", "CronJob", "cronTime", "cron", "runOnInit", "onTick", "now", "Date", "delta", "truncate", "count", "schedule", "start", "stop", "triggerFactory", "timer", "TriggerRegistry", "_options", "_triggersBySpaceKey", "removed", "getActiveTriggers", "_getTriggers", "t", "activationCtx", "getInactiveTriggers", "activate", "Context", "name", "function", "dispose", "registeredTrigger", "find", "reg", "invariant", "createTrigger", "err", "manifest", "triggers", "FunctionTrigger", "manifestTriggers", "map", "keys", "ECHO_ATTR_META", "foreignKey", "join", "compareForeignKeys", "meta", "getMeta", "spaceListSubscription", "current", "_handleRemovedTriggers", "_handleNewTriggers", "candidate", "enabled", "newRegisteredTriggers", "spaceKey", "i", "wasRemoved", "unregistered", "splice", "predicate", "allSpaceTriggers"]
7
+ }
@@ -16,17 +16,18 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_GKDHAWCP_exports = {};
20
- __export(chunk_GKDHAWCP_exports, {
19
+ var chunk_XRSOYOZ5_exports = {};
20
+ __export(chunk_XRSOYOZ5_exports, {
21
21
  FUNCTION_TYPES: () => FUNCTION_TYPES,
22
22
  FunctionDef: () => FunctionDef,
23
23
  FunctionManifestSchema: () => FunctionManifestSchema,
24
24
  FunctionTrigger: () => FunctionTrigger,
25
25
  FunctionTriggerSchema: () => FunctionTriggerSchema,
26
+ TriggerKind: () => TriggerKind,
26
27
  TriggerSchema: () => TriggerSchema,
27
28
  __require: () => __require
28
29
  });
29
- module.exports = __toCommonJS(chunk_GKDHAWCP_exports);
30
+ module.exports = __toCommonJS(chunk_XRSOYOZ5_exports);
30
31
  var import_echo_schema = require("@dxos/echo-schema");
31
32
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
32
33
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -34,28 +35,35 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
34
35
  if (typeof require !== "undefined") return require.apply(this, arguments);
35
36
  throw Error('Dynamic require of "' + x + '" is not supported');
36
37
  });
38
+ var TriggerKind;
39
+ (function(TriggerKind2) {
40
+ TriggerKind2["Timer"] = "timer";
41
+ TriggerKind2["Webhook"] = "webhook";
42
+ TriggerKind2["Subscription"] = "subscription";
43
+ })(TriggerKind || (TriggerKind = {}));
37
44
  var typeLiteralAnnotations = {
38
45
  [import_echo_schema.AST.TitleAnnotationId]: "Type"
39
46
  };
40
47
  var TimerTriggerSchema = import_echo_schema.S.Struct({
41
48
  type: import_echo_schema.S.Literal("timer").annotations(typeLiteralAnnotations),
42
- cron: import_echo_schema.S.NonEmptyString.annotations({
49
+ cron: import_echo_schema.S.String.annotations({
43
50
  [import_echo_schema.AST.TitleAnnotationId]: "Cron",
44
- [import_echo_schema.AST.ExamplesAnnotationId]: "0 0 * * *"
51
+ [import_echo_schema.AST.ExamplesAnnotationId]: [
52
+ "0 0 * * *"
53
+ ]
45
54
  })
46
55
  }).pipe(import_echo_schema.S.mutable);
47
56
  var WebhookTriggerSchema = import_echo_schema.S.Struct({
48
57
  type: import_echo_schema.S.Literal("webhook").annotations(typeLiteralAnnotations),
49
- method: import_echo_schema.S.String,
50
- // Assigned port.
51
- port: import_echo_schema.S.optional(import_echo_schema.S.Number)
52
- }).pipe(import_echo_schema.S.mutable);
53
- var WebsocketTriggerSchema = import_echo_schema.S.Struct({
54
- type: import_echo_schema.S.Literal("websocket").annotations(typeLiteralAnnotations),
55
- url: import_echo_schema.S.String,
56
- init: import_echo_schema.S.optional(import_echo_schema.S.Record({
57
- key: import_echo_schema.S.String,
58
- value: import_echo_schema.S.Any
58
+ method: import_echo_schema.S.optional(import_echo_schema.S.String.annotations({
59
+ [import_echo_schema.AST.TitleAnnotationId]: "Method",
60
+ [import_echo_schema.OptionsAnnotationId]: [
61
+ "GET",
62
+ "POST"
63
+ ]
64
+ })),
65
+ port: import_echo_schema.S.optional(import_echo_schema.S.Number.annotations({
66
+ [import_echo_schema.AST.TitleAnnotationId]: "Port"
59
67
  }))
60
68
  }).pipe(import_echo_schema.S.mutable);
61
69
  var QuerySchema = import_echo_schema.S.Struct({
@@ -86,7 +94,12 @@ var SubscriptionTriggerSchema = import_echo_schema.S.Struct({
86
94
  [import_echo_schema.AST.TitleAnnotationId]: "Options"
87
95
  }))
88
96
  }).pipe(import_echo_schema.S.mutable);
89
- var TriggerSchema = import_echo_schema.S.Union(TimerTriggerSchema, WebhookTriggerSchema, WebsocketTriggerSchema, SubscriptionTriggerSchema).annotations({
97
+ var TriggerSchema = import_echo_schema.S.Union(
98
+ //
99
+ TimerTriggerSchema,
100
+ WebhookTriggerSchema,
101
+ SubscriptionTriggerSchema
102
+ ).annotations({
90
103
  [import_echo_schema.AST.TitleAnnotationId]: "Trigger"
91
104
  });
92
105
  var FunctionTriggerSchema = import_echo_schema.S.Struct({
@@ -136,7 +149,8 @@ var FUNCTION_TYPES = [
136
149
  FunctionManifestSchema,
137
150
  FunctionTrigger,
138
151
  FunctionTriggerSchema,
152
+ TriggerKind,
139
153
  TriggerSchema,
140
154
  __require
141
155
  });
142
- //# sourceMappingURL=chunk-GKDHAWCP.cjs.map
156
+ //# sourceMappingURL=chunk-XRSOYOZ5.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/types.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { AST, OptionsAnnotationId, RawObject, S, TypedObject } from '@dxos/echo-schema';\n\n/**\n * Type discriminator for TriggerType.\n * Every spec has a type field of type TriggerKind that we can use to understand which type we're working with.\n * https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions\n */\nexport enum TriggerKind {\n Timer = 'timer',\n Webhook = 'webhook',\n Subscription = 'subscription',\n}\n\n// TODO(burdon): Rename prop kind.\nconst typeLiteralAnnotations = { [AST.TitleAnnotationId]: 'Type' };\n\n/**\n * Cron timer.\n */\nconst TimerTriggerSchema = S.Struct({\n type: S.Literal(TriggerKind.Timer).annotations(typeLiteralAnnotations),\n cron: S.String.annotations({\n [AST.TitleAnnotationId]: 'Cron',\n [AST.ExamplesAnnotationId]: ['0 0 * * *'],\n }),\n}).pipe(S.mutable);\n\nexport type TimerTrigger = S.Schema.Type<typeof TimerTriggerSchema>;\n\n/**\n * Webhook.\n */\nconst WebhookTriggerSchema = S.Struct({\n type: S.Literal(TriggerKind.Webhook).annotations(typeLiteralAnnotations),\n method: S.optional(\n S.String.annotations({\n [AST.TitleAnnotationId]: 'Method',\n [OptionsAnnotationId]: ['GET', 'POST'],\n }),\n ),\n port: S.optional(\n S.Number.annotations({\n [AST.TitleAnnotationId]: 'Port',\n }),\n ),\n}).pipe(S.mutable);\n\nexport type WebhookTrigger = S.Schema.Type<typeof WebhookTriggerSchema>;\n\n// TODO(burdon): Use ECHO definition (from https://github.com/dxos/dxos/pull/8233).\nconst QuerySchema = S.Struct({\n type: S.optional(S.String.annotations({ [AST.TitleAnnotationId]: 'Type' })),\n props: S.optional(S.Record({ key: S.String, value: S.Any })),\n}).annotations({ [AST.TitleAnnotationId]: 'Query' });\n\n/**\n * Subscription.\n */\nconst SubscriptionTriggerSchema = S.Struct({\n type: S.Literal(TriggerKind.Subscription).annotations(typeLiteralAnnotations),\n // TODO(burdon): Define query DSL (from ECHO). Reconcile with Table.Query.\n filter: QuerySchema,\n options: S.optional(\n S.Struct({\n // Watch changes to object (not just creation).\n deep: S.optional(S.Boolean.annotations({ [AST.TitleAnnotationId]: 'Nested' })),\n // Debounce changes (delay in ms).\n delay: S.optional(S.Number.annotations({ [AST.TitleAnnotationId]: 'Delay' })),\n }).annotations({ [AST.TitleAnnotationId]: 'Options' }),\n ),\n}).pipe(S.mutable);\n\nexport type SubscriptionTrigger = S.Schema.Type<typeof SubscriptionTriggerSchema>;\n\n/**\n * Trigger schema (discriminated union).\n */\nexport const TriggerSchema = S.Union(\n //\n TimerTriggerSchema,\n WebhookTriggerSchema,\n SubscriptionTriggerSchema,\n).annotations({\n [AST.TitleAnnotationId]: 'Trigger',\n});\n\nexport type TriggerType = S.Schema.Type<typeof TriggerSchema>;\n\n/**\n * Function trigger.\n */\nexport const FunctionTriggerSchema = S.Struct({\n // TODO(burdon): What type does this reference.\n function: S.optional(S.String.annotations({ [AST.TitleAnnotationId]: 'Function' })),\n enabled: S.optional(S.Boolean.annotations({ [AST.TitleAnnotationId]: 'Enabled' })),\n\n // TODO(burdon): Flatten?\n spec: S.optional(TriggerSchema),\n\n // TODO(burdon): Get meta from function.\n // The `meta` property is merged into the event data passed to the function.\n meta: S.optional(S.mutable(S.Record({ key: S.String, value: S.Any }))),\n});\n\nexport type FunctionTriggerType = S.Schema.Type<typeof FunctionTriggerSchema>;\n\n/**\n * Function trigger.\n */\nexport class FunctionTrigger extends TypedObject({\n typename: 'dxos.org/type/FunctionTrigger',\n version: '0.1.0',\n})(FunctionTriggerSchema.fields) {}\n\n/**\n * Function definition.\n * @deprecated (Use dxos.org/type/Function)\n */\n// TODO(burdon): Reconcile with FunctionType.\nexport class FunctionDef extends TypedObject({\n typename: 'dxos.org/type/FunctionDef',\n version: '0.1.0',\n})({\n uri: S.String,\n description: S.optional(S.String),\n route: S.String,\n handler: S.String,\n}) {}\n\n/**\n * Function manifest file.\n */\nexport const FunctionManifestSchema = S.Struct({\n functions: S.optional(S.mutable(S.Array(RawObject(FunctionDef)))),\n triggers: S.optional(S.mutable(S.Array(RawObject(FunctionTrigger)))),\n});\n\nexport type FunctionManifest = S.Schema.Type<typeof FunctionManifestSchema>;\n\nexport const FUNCTION_TYPES = [FunctionDef, FunctionTrigger];\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAAoE;;;;;;;;UAOxDA,cAAAA;;;;GAAAA,gBAA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ACb,CAAA,EAAA;AAAI;AAKG,IAAMuC,yBAAyB7C,qBAAEC,OAAO;EAC7C6C,WAAW9C,qBAAEY,SAASZ,qBAAES,QAAQT,qBAAE+C,UAAMC,8BAAUR,WAAAA,CAAAA,CAAAA,CAAAA;EAClDS,UAAUjD,qBAAEY,SAASZ,qBAAES,QAAQT,qBAAE+C,UAAMC,8BAAUb,eAAAA,CAAAA,CAAAA,CAAAA;AACnD,CAAA;AAIO,IAAMe,iBAAiB;EAACV;EAAaL;;",
6
+ "names": ["TriggerKind", "typeLiteralAnnotations", "AST", "TitleAnnotationId", "TimerTriggerSchema", "S", "Struct", "type", "Literal", "annotations", "cron", "String", "ExamplesAnnotationId", "pipe", "mutable", "WebhookTriggerSchema", "method", "optional", "OptionsAnnotationId", "port", "Number", "QuerySchema", "props", "Record", "key", "value", "Any", "SubscriptionTriggerSchema", "filter", "options", "deep", "Boolean", "delay", "TriggerSchema", "Union", "FunctionTriggerSchema", "function", "enabled", "spec", "meta", "FunctionTrigger", "TypedObject", "typename", "version", "fields", "FunctionDef", "uri", "description", "route", "handler", "FunctionManifestSchema", "functions", "Array", "RawObject", "triggers", "FUNCTION_TYPES"]
7
+ }
@@ -18,23 +18,22 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var node_exports = {};
20
20
  __export(node_exports, {
21
- FUNCTION_TYPES: () => import_chunk_GKDHAWCP.FUNCTION_TYPES,
22
- FunctionDef: () => import_chunk_GKDHAWCP.FunctionDef,
23
- FunctionManifestSchema: () => import_chunk_GKDHAWCP.FunctionManifestSchema,
24
- FunctionRegistry: () => import_chunk_OKV7IWWB.FunctionRegistry,
25
- FunctionTrigger: () => import_chunk_GKDHAWCP.FunctionTrigger,
26
- FunctionTriggerSchema: () => import_chunk_GKDHAWCP.FunctionTriggerSchema,
27
- TriggerRegistry: () => import_chunk_OKV7IWWB.TriggerRegistry,
28
- TriggerSchema: () => import_chunk_GKDHAWCP.TriggerSchema,
29
- createSubscriptionTrigger: () => import_chunk_OKV7IWWB.createSubscriptionTrigger,
30
- createTimerTrigger: () => import_chunk_OKV7IWWB.createTimerTrigger,
31
- createWebSocket: () => import_chunk_OKV7IWWB.createWebSocket,
32
- createWebsocketTrigger: () => import_chunk_OKV7IWWB.createWebsocketTrigger,
21
+ FUNCTION_TYPES: () => import_chunk_XRSOYOZ5.FUNCTION_TYPES,
22
+ FunctionDef: () => import_chunk_XRSOYOZ5.FunctionDef,
23
+ FunctionManifestSchema: () => import_chunk_XRSOYOZ5.FunctionManifestSchema,
24
+ FunctionRegistry: () => import_chunk_G2EVL5ME.FunctionRegistry,
25
+ FunctionTrigger: () => import_chunk_XRSOYOZ5.FunctionTrigger,
26
+ FunctionTriggerSchema: () => import_chunk_XRSOYOZ5.FunctionTriggerSchema,
27
+ TriggerKind: () => import_chunk_XRSOYOZ5.TriggerKind,
28
+ TriggerRegistry: () => import_chunk_G2EVL5ME.TriggerRegistry,
29
+ TriggerSchema: () => import_chunk_XRSOYOZ5.TriggerSchema,
30
+ createSubscriptionTrigger: () => import_chunk_G2EVL5ME.createSubscriptionTrigger,
31
+ createTimerTrigger: () => import_chunk_G2EVL5ME.createTimerTrigger,
33
32
  subscriptionHandler: () => subscriptionHandler
34
33
  });
35
34
  module.exports = __toCommonJS(node_exports);
36
- var import_chunk_OKV7IWWB = require("./chunk-OKV7IWWB.cjs");
37
- var import_chunk_GKDHAWCP = require("./chunk-GKDHAWCP.cjs");
35
+ var import_chunk_G2EVL5ME = require("./chunk-G2EVL5ME.cjs");
36
+ var import_chunk_XRSOYOZ5 = require("./chunk-XRSOYOZ5.cjs");
38
37
  var import_client = require("@dxos/client");
39
38
  var import_log = require("@dxos/log");
40
39
  var import_util = require("@dxos/util");
@@ -106,12 +105,11 @@ var registerTypes = (space, types = []) => {
106
105
  FunctionRegistry,
107
106
  FunctionTrigger,
108
107
  FunctionTriggerSchema,
108
+ TriggerKind,
109
109
  TriggerRegistry,
110
110
  TriggerSchema,
111
111
  createSubscriptionTrigger,
112
112
  createTimerTrigger,
113
- createWebSocket,
114
- createWebsocketTrigger,
115
113
  subscriptionHandler
116
114
  });
117
115
  //# sourceMappingURL=index.cjs.map