@dxos/functions 0.5.9-main.a2de4fa → 0.5.9-main.af4882d

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 (33) hide show
  1. package/dist/lib/browser/{chunk-YSDC6YCF.mjs → chunk-ERWZ4JUZ.mjs} +2 -2
  2. package/dist/lib/browser/{chunk-YSDC6YCF.mjs.map → chunk-ERWZ4JUZ.mjs.map} +2 -2
  3. package/dist/lib/browser/{chunk-ROZT7SSI.mjs → chunk-YKYOGE5O.mjs} +34 -55
  4. package/dist/lib/browser/chunk-YKYOGE5O.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +2 -2
  6. package/dist/lib/browser/meta.json +1 -1
  7. package/dist/lib/browser/testing/index.mjs +3 -3
  8. package/dist/lib/browser/testing/index.mjs.map +2 -2
  9. package/dist/lib/browser/types.mjs +1 -1
  10. package/dist/lib/node/{chunk-3E6PY6JH.cjs → chunk-BLLSDTKZ.cjs} +5 -5
  11. package/dist/lib/node/{chunk-3E6PY6JH.cjs.map → chunk-BLLSDTKZ.cjs.map} +2 -2
  12. package/dist/lib/node/{chunk-H5Q2TXOA.cjs → chunk-CIFOOX2V.cjs} +54 -75
  13. package/dist/lib/node/chunk-CIFOOX2V.cjs.map +7 -0
  14. package/dist/lib/node/index.cjs +10 -10
  15. package/dist/lib/node/meta.json +1 -1
  16. package/dist/lib/node/testing/index.cjs +10 -10
  17. package/dist/lib/node/testing/index.cjs.map +2 -2
  18. package/dist/lib/node/types.cjs +5 -5
  19. package/dist/lib/node/types.cjs.map +1 -1
  20. package/dist/types/src/runtime/dev-server.d.ts +1 -2
  21. package/dist/types/src/runtime/dev-server.d.ts.map +1 -1
  22. package/dist/types/src/runtime/scheduler.d.ts +1 -8
  23. package/dist/types/src/runtime/scheduler.d.ts.map +1 -1
  24. package/dist/types/src/testing/setup.d.ts +1 -1
  25. package/package.json +14 -15
  26. package/src/runtime/dev-server.test.ts +3 -3
  27. package/src/runtime/dev-server.ts +3 -6
  28. package/src/runtime/scheduler.ts +6 -29
  29. package/src/testing/functions-integration.test.ts +1 -1
  30. package/src/testing/setup.ts +1 -1
  31. package/src/types.ts +1 -1
  32. package/dist/lib/browser/chunk-ROZT7SSI.mjs.map +0 -7
  33. package/dist/lib/node/chunk-H5Q2TXOA.cjs.map +0 -7
@@ -26,15 +26,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_H5Q2TXOA_exports = {};
30
- __export(chunk_H5Q2TXOA_exports, {
29
+ var chunk_CIFOOX2V_exports = {};
30
+ __export(chunk_CIFOOX2V_exports, {
31
31
  DevServer: () => DevServer,
32
32
  FunctionRegistry: () => FunctionRegistry,
33
33
  Scheduler: () => Scheduler,
34
34
  TriggerRegistry: () => TriggerRegistry
35
35
  });
36
- module.exports = __toCommonJS(chunk_H5Q2TXOA_exports);
37
- var import_chunk_3E6PY6JH = require("./chunk-3E6PY6JH.cjs");
36
+ module.exports = __toCommonJS(chunk_CIFOOX2V_exports);
37
+ var import_chunk_BLLSDTKZ = require("./chunk-BLLSDTKZ.cjs");
38
38
  var import_async = require("@dxos/async");
39
39
  var import_echo = require("@dxos/client/echo");
40
40
  var import_context = require("@dxos/context");
@@ -50,12 +50,10 @@ var import_invariant = require("@dxos/invariant");
50
50
  var import_log2 = require("@dxos/log");
51
51
  var import_node_path2 = __toESM(require("node:path"));
52
52
  var import_async3 = require("@dxos/async");
53
- var import_echo2 = require("@dxos/client/echo");
54
53
  var import_context3 = require("@dxos/context");
55
- var import_echo_protocol = require("@dxos/echo-protocol");
56
54
  var import_log3 = require("@dxos/log");
57
55
  var import_async4 = require("@dxos/async");
58
- var import_echo3 = require("@dxos/client/echo");
56
+ var import_echo2 = require("@dxos/client/echo");
59
57
  var import_context4 = require("@dxos/context");
60
58
  var import_echo_schema = require("@dxos/echo-schema");
61
59
  var import_invariant2 = require("@dxos/invariant");
@@ -64,7 +62,7 @@ var import_log4 = require("@dxos/log");
64
62
  var import_util2 = require("@dxos/util");
65
63
  var import_types = require("@braneframe/types");
66
64
  var import_async5 = require("@dxos/async");
67
- var import_echo4 = require("@dxos/client/echo");
65
+ var import_echo3 = require("@dxos/client/echo");
68
66
  var import_echo_db = require("@dxos/echo-db");
69
67
  var import_log5 = require("@dxos/log");
70
68
  var import_cron = require("cron");
@@ -115,14 +113,14 @@ var FunctionRegistry = class extends import_context.Resource {
115
113
  if (!functions?.length) {
116
114
  return;
117
115
  }
118
- if (!space.db.graph.schemaRegistry.hasSchema(import_chunk_3E6PY6JH.FunctionDef)) {
116
+ if (!space.db.graph.schemaRegistry.hasSchema(import_chunk_BLLSDTKZ.FunctionDef)) {
119
117
  space.db.graph.schemaRegistry.addSchema([
120
- import_chunk_3E6PY6JH.FunctionDef
118
+ import_chunk_BLLSDTKZ.FunctionDef
121
119
  ]);
122
120
  }
123
- const { objects: existing } = await space.db.query(import_echo.Filter.schema(import_chunk_3E6PY6JH.FunctionDef)).run();
121
+ const { objects: existing } = await space.db.query(import_echo.Filter.schema(import_chunk_BLLSDTKZ.FunctionDef)).run();
124
122
  const { added } = (0, import_util.diff)(existing, functions, (a, b) => a.uri === b.uri);
125
- added.forEach((def) => space.db.add((0, import_echo.create)(import_chunk_3E6PY6JH.FunctionDef, def)));
123
+ added.forEach((def) => space.db.add((0, import_echo.create)(import_chunk_BLLSDTKZ.FunctionDef, def)));
126
124
  }
127
125
  async _open() {
128
126
  import_log.log.info("opening...", void 0, {
@@ -142,7 +140,7 @@ var FunctionRegistry = class extends import_context.Resource {
142
140
  if (this._ctx.disposed) {
143
141
  break;
144
142
  }
145
- this._ctx.onDispose(space.db.query(import_echo.Filter.schema(import_chunk_3E6PY6JH.FunctionDef)).subscribe(({ objects }) => {
143
+ this._ctx.onDispose(space.db.query(import_echo.Filter.schema(import_chunk_BLLSDTKZ.FunctionDef)).subscribe(({ objects }) => {
146
144
  const { added } = (0, import_util.diff)(registered, objects, (a, b) => a.uri === b.uri);
147
145
  if (added.length > 0) {
148
146
  registered.push(...added);
@@ -167,7 +165,6 @@ var FunctionRegistry = class extends import_context.Resource {
167
165
  }
168
166
  };
169
167
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/functions/src/runtime/dev-server.ts";
170
- var FN_TIMEOUT = 2e4;
171
168
  var DevServer = class {
172
169
  constructor(_client, _functionsRegistry, _options) {
173
170
  this._client = _client;
@@ -186,7 +183,7 @@ var DevServer = class {
186
183
  get endpoint() {
187
184
  (0, import_invariant.invariant)(this._port, void 0, {
188
185
  F: __dxlog_file2,
189
- L: 60,
186
+ L: 57,
190
187
  S: this,
191
188
  A: [
192
189
  "this._port",
@@ -204,7 +201,7 @@ var DevServer = class {
204
201
  async start() {
205
202
  (0, import_invariant.invariant)(!this._server, void 0, {
206
203
  F: __dxlog_file2,
207
- L: 73,
204
+ L: 70,
208
205
  S: this,
209
206
  A: [
210
207
  "!this._server",
@@ -213,7 +210,7 @@ var DevServer = class {
213
210
  });
214
211
  import_log2.log.info("starting...", void 0, {
215
212
  F: __dxlog_file2,
216
- L: 74,
213
+ L: 71,
217
214
  S: this,
218
215
  C: (f, a) => f(...a)
219
216
  });
@@ -227,7 +224,7 @@ var DevServer = class {
227
224
  path: path2
228
225
  }, {
229
226
  F: __dxlog_file2,
230
- L: 84,
227
+ L: 81,
231
228
  S: this,
232
229
  C: (f, a) => f(...a)
233
230
  });
@@ -235,12 +232,12 @@ var DevServer = class {
235
232
  const { def } = this._handlers["/" + path2];
236
233
  await this._load(def, true);
237
234
  }
238
- res.statusCode = await (0, import_async2.asyncTimeout)(this.invoke("/" + path2, req.body), FN_TIMEOUT);
235
+ res.statusCode = await (0, import_async2.asyncTimeout)(this.invoke("/" + path2, req.body), 2e4);
239
236
  res.end();
240
237
  } catch (err) {
241
238
  import_log2.log.catch(err, void 0, {
242
239
  F: __dxlog_file2,
243
- L: 94,
240
+ L: 91,
244
241
  S: this,
245
242
  C: (f, a) => f(...a)
246
243
  });
@@ -265,7 +262,7 @@ var DevServer = class {
265
262
  endpoint
266
263
  }, {
267
264
  F: __dxlog_file2,
268
- L: 109,
265
+ L: 106,
269
266
  S: this,
270
267
  C: (f, a) => f(...a)
271
268
  });
@@ -281,7 +278,7 @@ var DevServer = class {
281
278
  port: this._port
282
279
  }, {
283
280
  F: __dxlog_file2,
284
- L: 121,
281
+ L: 118,
285
282
  S: this,
286
283
  C: (f, a) => f(...a)
287
284
  });
@@ -292,7 +289,7 @@ var DevServer = class {
292
289
  }
293
290
  import_log2.log.info("stopping...", void 0, {
294
291
  F: __dxlog_file2,
295
- L: 129,
292
+ L: 126,
296
293
  S: this,
297
294
  C: (f, a) => f(...a)
298
295
  });
@@ -301,7 +298,7 @@ var DevServer = class {
301
298
  this._server.close(async () => {
302
299
  import_log2.log.info("server stopped", void 0, {
303
300
  F: __dxlog_file2,
304
- L: 134,
301
+ L: 131,
305
302
  S: this,
306
303
  C: (f, a) => f(...a)
307
304
  });
@@ -309,7 +306,7 @@ var DevServer = class {
309
306
  if (this._functionServiceRegistration) {
310
307
  (0, import_invariant.invariant)(this._client.services.services.FunctionRegistryService, void 0, {
311
308
  F: __dxlog_file2,
312
- L: 137,
309
+ L: 134,
313
310
  S: this,
314
311
  A: [
315
312
  "this._client.services.services.FunctionRegistryService",
@@ -323,7 +320,7 @@ var DevServer = class {
323
320
  registrationId: this._functionServiceRegistration
324
321
  }, {
325
322
  F: __dxlog_file2,
326
- L: 142,
323
+ L: 139,
327
324
  S: this,
328
325
  C: (f, a) => f(...a)
329
326
  });
@@ -340,7 +337,7 @@ var DevServer = class {
340
337
  this._server = void 0;
341
338
  import_log2.log.info("stopped", void 0, {
342
339
  F: __dxlog_file2,
343
- L: 156,
340
+ L: 153,
344
341
  S: this,
345
342
  C: (f, a) => f(...a)
346
343
  });
@@ -352,7 +349,7 @@ var DevServer = class {
352
349
  newFunctions
353
350
  }, {
354
351
  F: __dxlog_file2,
355
- L: 162,
352
+ L: 159,
356
353
  S: this,
357
354
  C: (f, a) => f(...a)
358
355
  });
@@ -368,16 +365,16 @@ var DevServer = class {
368
365
  force
369
366
  }, {
370
367
  F: __dxlog_file2,
371
- L: 171,
368
+ L: 168,
372
369
  S: this,
373
370
  C: (f, a) => f(...a)
374
371
  });
375
372
  if (force) {
376
- Object.keys(import_chunk_3E6PY6JH.__require.cache).filter((key) => key.startsWith(filePath)).forEach((key) => {
377
- delete import_chunk_3E6PY6JH.__require.cache[key];
373
+ Object.keys(import_chunk_BLLSDTKZ.__require.cache).filter((key) => key.startsWith(filePath)).forEach((key) => {
374
+ delete import_chunk_BLLSDTKZ.__require.cache[key];
378
375
  });
379
376
  }
380
- const module2 = (0, import_chunk_3E6PY6JH.__require)(filePath);
377
+ const module2 = (0, import_chunk_BLLSDTKZ.__require)(filePath);
381
378
  if (typeof module2.default !== "function") {
382
379
  throw new Error(`Handler must export default function: ${uri}`);
383
380
  }
@@ -389,7 +386,7 @@ var DevServer = class {
389
386
  async _safeUpdateRegistration() {
390
387
  (0, import_invariant.invariant)(this._functionServiceRegistration, void 0, {
391
388
  F: __dxlog_file2,
392
- L: 193,
389
+ L: 190,
393
390
  S: this,
394
391
  A: [
395
392
  "this._functionServiceRegistration",
@@ -407,7 +404,7 @@ var DevServer = class {
407
404
  } catch (err) {
408
405
  import_log2.log.catch(err, void 0, {
409
406
  F: __dxlog_file2,
410
- L: 200,
407
+ L: 197,
411
408
  S: this,
412
409
  C: (f, a) => f(...a)
413
410
  });
@@ -424,7 +421,7 @@ var DevServer = class {
424
421
  path: path2
425
422
  }, {
426
423
  F: __dxlog_file2,
427
- L: 211,
424
+ L: 208,
428
425
  S: this,
429
426
  C: (f, a) => f(...a)
430
427
  });
@@ -438,7 +435,7 @@ var DevServer = class {
438
435
  duration: Date.now() - now
439
436
  }, {
440
437
  F: __dxlog_file2,
441
- L: 214,
438
+ L: 211,
442
439
  S: this,
443
440
  C: (f, a) => f(...a)
444
441
  });
@@ -449,7 +446,7 @@ var DevServer = class {
449
446
  const { handler } = this._handlers[path2] ?? {};
450
447
  (0, import_invariant.invariant)(handler, `invalid path: ${path2}`, {
451
448
  F: __dxlog_file2,
452
- L: 221,
449
+ L: 218,
453
450
  S: this,
454
451
  A: [
455
452
  "handler",
@@ -504,7 +501,7 @@ var Scheduler = class {
504
501
  await this.functions.close();
505
502
  await this.triggers.close();
506
503
  }
507
- // TODO(burdon): Remove and update registries directly?
504
+ // TODO(burdon): Remove and update registries directly.
508
505
  async register(space, manifest) {
509
506
  await this.functions.register(space, manifest.functions);
510
507
  await this.triggers.register(space, manifest);
@@ -515,9 +512,6 @@ var Scheduler = class {
515
512
  });
516
513
  await Promise.all(mountTasks).catch(import_log3.log.catch);
517
514
  }
518
- /**
519
- * Activate trigger.
520
- */
521
515
  async activate(space, functions, trigger) {
522
516
  const definition = functions.find((def) => def.uri === trigger.function);
523
517
  if (!definition) {
@@ -525,7 +519,7 @@ var Scheduler = class {
525
519
  trigger
526
520
  }, {
527
521
  F: __dxlog_file3,
528
- L: 83,
522
+ L: 78,
529
523
  S: this,
530
524
  C: (f, a) => f(...a)
531
525
  });
@@ -538,33 +532,21 @@ var Scheduler = class {
538
532
  uri: definition.uri
539
533
  }, {
540
534
  F: __dxlog_file3,
541
- L: 91,
535
+ L: 86,
542
536
  S: this,
543
537
  C: (f, a) => f(...a)
544
538
  });
545
- return mutex.executeSynchronized(async () => {
539
+ return mutex.executeSynchronized(() => {
546
540
  import_log3.log.info("mutex acquired", {
547
541
  uri: definition.uri
548
542
  }, {
549
543
  F: __dxlog_file3,
550
- L: 93,
544
+ L: 88,
551
545
  S: this,
552
546
  C: (f, a) => f(...a)
553
547
  });
554
- await (0, import_echo2.loadObjectReferences)(trigger, (t) => Object.values(t.meta ?? {}));
555
- const meta = {};
556
- for (const [key, value] of Object.entries(trigger.meta ?? {})) {
557
- if (value instanceof import_echo_protocol.Reference) {
558
- const object = await space.db.loadObjectById(value.objectId);
559
- if (object) {
560
- meta[key] = object;
561
- }
562
- } else {
563
- meta[key] = value;
564
- }
565
- }
566
548
  return this._execFunction(definition, trigger, {
567
- meta,
549
+ meta: trigger.meta ?? {},
568
550
  data: {
569
551
  ...args,
570
552
  spaceKey: space.key
@@ -577,15 +559,12 @@ var Scheduler = class {
577
559
  trigger
578
560
  }, {
579
561
  F: __dxlog_file3,
580
- L: 116,
562
+ L: 96,
581
563
  S: this,
582
564
  C: (f, a) => f(...a)
583
565
  });
584
566
  }
585
- /**
586
- * Invoke function RPC.
587
- */
588
- async _execFunction(def, trigger, { meta, data }) {
567
+ async _execFunction(def, trigger, { data, meta }) {
589
568
  let status = 0;
590
569
  try {
591
570
  const payload = Object.assign({}, meta && {
@@ -600,7 +579,7 @@ var Scheduler = class {
600
579
  triggerType: trigger.spec.type
601
580
  }, {
602
581
  F: __dxlog_file3,
603
- L: 136,
582
+ L: 113,
604
583
  S: this,
605
584
  C: (f, a) => f(...a)
606
585
  });
@@ -617,7 +596,7 @@ var Scheduler = class {
617
596
  function: def.uri
618
597
  }, {
619
598
  F: __dxlog_file3,
620
- L: 147,
599
+ L: 124,
621
600
  S: this,
622
601
  C: (f, a) => f(...a)
623
602
  });
@@ -631,7 +610,7 @@ var Scheduler = class {
631
610
  status
632
611
  }, {
633
612
  F: __dxlog_file3,
634
- L: 157,
613
+ L: 134,
635
614
  S: this,
636
615
  C: (f, a) => f(...a)
637
616
  });
@@ -641,7 +620,7 @@ var Scheduler = class {
641
620
  error: err.message
642
621
  }, {
643
622
  F: __dxlog_file3,
644
- L: 159,
623
+ L: 136,
645
624
  S: this,
646
625
  C: (f, a) => f(...a)
647
626
  });
@@ -721,7 +700,7 @@ var createSubscriptionTrigger = async (ctx, space, spec, callback) => {
721
700
  C: (f, a) => f(...a)
722
701
  });
723
702
  if (filter) {
724
- const query = space.db.query(import_echo4.Filter.typename(filter[0].type, filter[0].props));
703
+ const query = space.db.query(import_echo3.Filter.typename(filter[0].type, filter[0].props));
725
704
  subscriptions.push(query.subscribe(delay ? (0, import_async5.debounce)(update, delay) : update));
726
705
  }
727
706
  ctx.onDispose(() => {
@@ -968,9 +947,9 @@ var TriggerRegistry = class extends import_context4.Resource {
968
947
  if (!manifest.triggers?.length) {
969
948
  return;
970
949
  }
971
- if (!space.db.graph.schemaRegistry.hasSchema(import_chunk_3E6PY6JH.FunctionTrigger)) {
950
+ if (!space.db.graph.schemaRegistry.hasSchema(import_chunk_BLLSDTKZ.FunctionTrigger)) {
972
951
  space.db.graph.schemaRegistry.addSchema([
973
- import_chunk_3E6PY6JH.FunctionTrigger
952
+ import_chunk_BLLSDTKZ.FunctionTrigger
974
953
  ]);
975
954
  }
976
955
  const manifestTriggers = manifest.triggers.map((trigger) => {
@@ -984,16 +963,16 @@ var TriggerRegistry = class extends import_context4.Resource {
984
963
  ].join(":"))
985
964
  ];
986
965
  }
987
- return (0, import_echo3.create)(import_chunk_3E6PY6JH.FunctionTrigger, trigger, {
966
+ return (0, import_echo2.create)(import_chunk_BLLSDTKZ.FunctionTrigger, trigger, {
988
967
  keys
989
968
  });
990
969
  });
991
- const { objects: existing } = await space.db.query(import_echo3.Filter.schema(import_chunk_3E6PY6JH.FunctionTrigger)).run();
970
+ const { objects: existing } = await space.db.query(import_echo2.Filter.schema(import_chunk_BLLSDTKZ.FunctionTrigger)).run();
992
971
  const { added } = (0, import_util2.diff)(existing, manifestTriggers, import_echo_schema.compareForeignKeys);
993
972
  added.forEach((trigger) => {
994
973
  space.db.add(trigger);
995
974
  import_log4.log.info("added", {
996
- meta: (0, import_echo3.getMeta)(trigger)
975
+ meta: (0, import_echo2.getMeta)(trigger)
997
976
  }, {
998
977
  F: __dxlog_file8,
999
978
  L: 120,
@@ -1023,7 +1002,7 @@ var TriggerRegistry = class extends import_context4.Resource {
1023
1002
  if (this._ctx.disposed) {
1024
1003
  break;
1025
1004
  }
1026
- this._ctx.onDispose(space.db.query(import_echo3.Filter.schema(import_chunk_3E6PY6JH.FunctionTrigger)).subscribe(async ({ objects: current }) => {
1005
+ this._ctx.onDispose(space.db.query(import_echo2.Filter.schema(import_chunk_BLLSDTKZ.FunctionTrigger)).subscribe(async ({ objects: current }) => {
1027
1006
  import_log4.log.info("update", {
1028
1007
  space: space.key,
1029
1008
  registered: registered.length,
@@ -1124,4 +1103,4 @@ var TriggerRegistry = class extends import_context4.Resource {
1124
1103
  Scheduler,
1125
1104
  TriggerRegistry
1126
1105
  });
1127
- //# sourceMappingURL=chunk-H5Q2TXOA.cjs.map
1106
+ //# sourceMappingURL=chunk-CIFOOX2V.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/function/function-registry.ts", "../../../src/runtime/dev-server.ts", "../../../src/runtime/scheduler.ts", "../../../src/trigger/trigger-registry.ts", "../../../src/trigger/type/subscription-trigger.ts", "../../../src/trigger/type/timer-trigger.ts", "../../../src/trigger/type/webhook-trigger.ts", "../../../src/trigger/type/websocket-trigger.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\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 2023 DXOS.org\n//\n\nimport express from 'express';\nimport { getPort } from 'get-port-please';\nimport type http from 'http';\nimport { join } from 'node:path';\n\nimport { asyncTimeout, Event, Trigger } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { Context } from '@dxos/context';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nimport { type FunctionRegistry } from '../function';\nimport { type FunctionContext, type FunctionEvent, type FunctionHandler, type FunctionResponse } from '../handler';\nimport { type FunctionDef } from '../types';\n\nexport type DevServerOptions = {\n baseDir: string;\n port?: number;\n reload?: boolean;\n dataDir?: string;\n};\n\n/**\n * Functions dev server provides a local HTTP server for testing functions.\n */\nexport class DevServer {\n private _ctx = createContext();\n\n // Function handlers indexed by name (URL path).\n private readonly _handlers: Record<string, { def: FunctionDef; handler: FunctionHandler<any> }> = {};\n\n private _server?: http.Server;\n private _port?: number;\n private _functionServiceRegistration?: string;\n private _proxy?: string;\n private _seq = 0;\n\n public readonly update = new Event<number>();\n\n constructor(\n private readonly _client: Client,\n private readonly _functionsRegistry: FunctionRegistry,\n private readonly _options: DevServerOptions,\n ) {}\n\n get stats() {\n return {\n seq: this._seq,\n };\n }\n\n get endpoint() {\n invariant(this._port);\n return `http://localhost:${this._port}`;\n }\n\n get proxy() {\n return this._proxy;\n }\n\n get functions() {\n return Object.values(this._handlers);\n }\n\n async start() {\n invariant(!this._server);\n log.info('starting...');\n this._ctx = createContext();\n\n // TODO(burdon): Move to hono.\n const app = express();\n app.use(express.json());\n\n app.post('/:path', async (req, res) => {\n const { path } = req.params;\n try {\n log.info('calling', { path });\n if (this._options.reload) {\n const { def } = this._handlers['/' + path];\n await this._load(def, true);\n }\n\n // TODO(burdon): Get function context.\n res.statusCode = await asyncTimeout(this.invoke('/' + path, req.body), 20_000);\n res.end();\n } catch (err: any) {\n log.catch(err);\n res.statusCode = 500;\n res.end();\n }\n });\n\n this._port = this._options.port ?? (await getPort({ host: 'localhost', port: 7200, portRange: [7200, 7299] }));\n this._server = app.listen(this._port);\n\n try {\n // Register functions.\n const { registrationId, endpoint } = await this._client.services.services.FunctionRegistryService!.register({\n endpoint: this.endpoint,\n });\n\n log.info('registered', { endpoint });\n this._proxy = endpoint;\n this._functionServiceRegistration = registrationId;\n\n // Open after registration, so that it can be updated with the list of function definitions.\n await this._handleNewFunctions(this._functionsRegistry.getUniqueByUri());\n this._ctx.onDispose(this._functionsRegistry.registered.on(({ added }) => this._handleNewFunctions(added)));\n } catch (err: any) {\n await this.stop();\n throw new Error('FunctionRegistryService not available (check plugin is configured).');\n }\n\n log.info('started', { port: this._port });\n }\n\n async stop() {\n if (!this._server) {\n return;\n }\n\n log.info('stopping...');\n await this._ctx.dispose();\n\n const trigger = new Trigger();\n this._server.close(async () => {\n log.info('server stopped');\n try {\n if (this._functionServiceRegistration) {\n invariant(this._client.services.services.FunctionRegistryService);\n await this._client.services.services.FunctionRegistryService.unregister({\n registrationId: this._functionServiceRegistration,\n });\n\n log.info('unregistered', { registrationId: this._functionServiceRegistration });\n this._functionServiceRegistration = undefined;\n this._proxy = undefined;\n }\n\n trigger.wake();\n } catch (err) {\n trigger.throw(err as Error);\n }\n });\n\n await trigger.wait();\n this._port = undefined;\n this._server = undefined;\n log.info('stopped');\n }\n\n private async _handleNewFunctions(newFunctions: FunctionDef[]) {\n newFunctions.forEach((def) => this._load(def));\n await this._safeUpdateRegistration();\n log('new functions loaded', { newFunctions });\n }\n\n /**\n * Load function.\n */\n private async _load(def: FunctionDef, force?: boolean | undefined) {\n const { uri, route, handler } = def;\n const filePath = join(this._options.baseDir, handler);\n log.info('loading', { uri, force });\n\n // Remove from cache.\n if (force) {\n Object.keys(require.cache)\n .filter((key) => key.startsWith(filePath))\n .forEach((key) => {\n delete require.cache[key];\n });\n }\n\n // TODO(burdon): Import types.\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const module = require(filePath);\n if (typeof module.default !== 'function') {\n throw new Error(`Handler must export default function: ${uri}`);\n }\n\n this._handlers[route] = { def, handler: module.default };\n }\n\n private async _safeUpdateRegistration(): Promise<void> {\n invariant(this._functionServiceRegistration);\n try {\n await this._client.services.services.FunctionRegistryService!.updateRegistration({\n registrationId: this._functionServiceRegistration,\n functions: this.functions.map(({ def: { id, route } }) => ({ id, route })),\n });\n } catch (err) {\n log.catch(err);\n }\n }\n\n /**\n * Invoke function.\n */\n public async invoke(path: string, data: any): Promise<number> {\n const seq = ++this._seq;\n const now = Date.now();\n\n log.info('req', { seq, path });\n const statusCode = await this._invoke(path, { data });\n\n log.info('res', { seq, path, statusCode, duration: Date.now() - now });\n this.update.emit(statusCode);\n return statusCode;\n }\n\n private async _invoke(path: string, event: FunctionEvent) {\n const { handler } = this._handlers[path] ?? {};\n invariant(handler, `invalid path: ${path}`);\n const context: FunctionContext = {\n client: this._client,\n dataDir: this._options.dataDir,\n };\n\n let statusCode = 200;\n const response: FunctionResponse = {\n status: (code: number) => {\n statusCode = code;\n return response;\n },\n };\n\n await handler({ context, event, response });\n return statusCode;\n }\n}\n\nconst createContext = () => new Context({ name: 'DevServer' });\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport path from 'node:path';\n\nimport { Mutex } from '@dxos/async';\nimport { type Space } from '@dxos/client/echo';\nimport { Context } from '@dxos/context';\nimport { log } from '@dxos/log';\n\nimport { type FunctionRegistry } from '../function';\nimport { type FunctionEventMeta } from '../handler';\nimport { type TriggerRegistry } from '../trigger';\nimport { type FunctionDef, type FunctionManifest, type FunctionTrigger } from '../types';\n\nexport type Callback = (data: any) => Promise<void | number>;\n\nexport type SchedulerOptions = {\n endpoint?: string;\n callback?: Callback;\n};\n\n/**\n * The scheduler triggers function execution based on various triggers.\n */\nexport class Scheduler {\n private _ctx = createContext();\n\n private readonly _functionUriToCallMutex = new Map<string, Mutex>();\n\n constructor(\n public readonly functions: FunctionRegistry,\n public readonly triggers: TriggerRegistry,\n private readonly _options: SchedulerOptions = {},\n ) {\n this.functions.registered.on(async ({ space, added }) => {\n await this._safeActivateTriggers(space, this.triggers.getInactiveTriggers(space), added);\n });\n this.triggers.registered.on(async ({ space, triggers }) => {\n await this._safeActivateTriggers(space, triggers, this.functions.getFunctions(space));\n });\n }\n\n async start() {\n await this._ctx.dispose();\n this._ctx = createContext();\n await this.functions.open(this._ctx);\n await this.triggers.open(this._ctx);\n }\n\n async stop() {\n await this._ctx.dispose();\n await this.functions.close();\n await this.triggers.close();\n }\n\n // TODO(burdon): Remove and update registries directly.\n public async register(space: Space, manifest: FunctionManifest) {\n await this.functions.register(space, manifest.functions);\n await this.triggers.register(space, manifest);\n }\n\n private async _safeActivateTriggers(\n space: Space,\n triggers: FunctionTrigger[],\n functions: FunctionDef[],\n ): Promise<void> {\n const mountTasks = triggers.map((trigger) => {\n return this.activate(space, functions, trigger);\n });\n await Promise.all(mountTasks).catch(log.catch);\n }\n\n private async activate(space: Space, functions: FunctionDef[], trigger: FunctionTrigger) {\n const definition = functions.find((def) => def.uri === trigger.function);\n if (!definition) {\n log.info('function is not found for trigger', { trigger });\n return;\n }\n\n await this.triggers.activate(space, trigger, async (args) => {\n const mutex = this._functionUriToCallMutex.get(definition.uri) ?? new Mutex();\n this._functionUriToCallMutex.set(definition.uri, mutex);\n\n log.info('function triggered, waiting for mutex', { uri: definition.uri });\n return mutex.executeSynchronized(() => {\n log.info('mutex acquired', { uri: definition.uri });\n return this._execFunction(definition, trigger, {\n meta: trigger.meta ?? {},\n data: { ...args, spaceKey: space.key },\n });\n });\n });\n\n log('activated trigger', { space: space.key, trigger });\n }\n\n private async _execFunction<TData, TMeta>(\n def: FunctionDef,\n trigger: FunctionTrigger,\n { data, meta }: { data: TData; meta?: TMeta },\n ): Promise<number> {\n let status = 0;\n try {\n // TODO(burdon): Pass in Space key (common context)?\n const payload = Object.assign({}, meta && ({ meta } satisfies FunctionEventMeta<TMeta>), data);\n\n const { endpoint, callback } = this._options;\n if (endpoint) {\n // TODO(burdon): Move out of scheduler (generalize as callback).\n const url = path.join(endpoint, def.route);\n log.info('exec', { function: def.uri, url, triggerType: trigger.spec.type });\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(payload),\n });\n\n status = response.status;\n } else if (callback) {\n log.info('exec', { function: def.uri });\n status = (await callback(payload)) ?? 200;\n }\n\n // Check errors.\n if (status && status >= 400) {\n throw new Error(`Response: ${status}`);\n }\n\n // const result = await response.json();\n log.info('done', { function: def.uri, status });\n } catch (err: any) {\n log.error('error', { function: def.uri, error: err.message });\n status = 500;\n }\n\n return status;\n }\n}\n\nconst createContext = () => new Context({ name: 'FunctionScheduler' });\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, createWebhookTrigger, createWebsocketTrigger } from './type';\nimport { type FunctionManifest, FunctionTrigger, type FunctionTriggerType, type TriggerSpec } 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 TriggerSpec, Options = any> = (\n ctx: Context,\n space: Space,\n spec: Spec,\n callback: TriggerCallback,\n options?: Options,\n) => Promise<void>;\n\nexport type TriggerHandlerMap = { [type in FunctionTriggerType]: TriggerFactory<any> };\n\nconst triggerHandlers: TriggerHandlerMap = {\n subscription: createSubscriptionTrigger,\n timer: createTimerTrigger,\n webhook: createWebhookTrigger,\n websocket: createWebsocketTrigger,\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?: TriggerHandlerMap,\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 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 const options = this._options?.[trigger.spec.type];\n await triggerHandlers[trigger.spec.type](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", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { TextType } from '@braneframe/types';\nimport { debounce, UpdateScheduler } from '@dxos/async';\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { type Context } from '@dxos/context';\nimport { createSubscription, getObjectCore, 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 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) {\n const query = space.db.query(Filter.typename(filter[0].type, filter[0].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 { getPort } from 'get-port-please';\nimport http from 'node:http';\n\nimport { type Space } from '@dxos/client/echo';\nimport { type Context } from '@dxos/context';\nimport { log } from '@dxos/log';\n\nimport type { WebhookTrigger } from '../../types';\nimport { type TriggerCallback, type TriggerFactory } from '../trigger-registry';\n\nexport const createWebhookTrigger: TriggerFactory<WebhookTrigger> = async (\n ctx: Context,\n space: Space,\n spec: WebhookTrigger,\n callback: TriggerCallback,\n) => {\n // TODO(burdon): Enable POST hook with payload.\n const server = http.createServer(async (req, res) => {\n if (req.method !== spec.method) {\n res.statusCode = 405;\n return res.end();\n }\n res.statusCode = await callback({});\n res.end();\n });\n\n // TODO(burdon): Not used.\n // const DEF_PORT_RANGE = { min: 7500, max: 7599 };\n // const portRange = Object.assign({}, trigger.port, DEF_PORT_RANGE) as WebhookTrigger['port'];\n const port = await getPort({\n random: true,\n // portRange: [portRange!.min, portRange!.max],\n });\n\n // TODO(burdon): Update trigger object with actual port.\n server.listen(port, () => {\n log.info('started webhook', { port });\n spec.port = port;\n });\n\n ctx.onDispose(() => {\n server.close();\n });\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport WebSocket from 'ws';\n\nimport { sleep, Trigger } from '@dxos/async';\nimport { type Space } from '@dxos/client/echo';\nimport { type Context } from '@dxos/context';\nimport { log } from '@dxos/log';\n\nimport { type WebsocketTrigger } from '../../types';\nimport { type TriggerCallback, type TriggerFactory } from '../trigger-registry';\n\ninterface WebsocketTriggerOptions {\n retryDelay: number;\n maxAttempts: number;\n}\n\n/**\n * Websocket.\n * NOTE: The port must be unique, so the same hook cannot be used for multiple spaces.\n */\nexport const createWebsocketTrigger: TriggerFactory<WebsocketTrigger, WebsocketTriggerOptions> = async (\n ctx: Context,\n space: Space,\n spec: WebsocketTrigger,\n callback: TriggerCallback,\n options: WebsocketTriggerOptions = { retryDelay: 2, maxAttempts: 5 },\n) => {\n const { url, init } = spec;\n\n let wasOpen = false;\n let ws: WebSocket;\n for (let attempt = 1; attempt <= options.maxAttempts; attempt++) {\n const open = new Trigger<boolean>();\n\n ws = new WebSocket(url);\n Object.assign(ws, {\n onopen: () => {\n log.info('opened', { url });\n if (spec.init) {\n ws.send(new TextEncoder().encode(JSON.stringify(init)));\n }\n\n open.wake(true);\n },\n\n onclose: (event) => {\n log.info('closed', { url, code: event.code });\n // Reconnect if server closes (e.g., CF restart).\n // https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code\n if (event.code === 1006 && wasOpen && !ctx.disposed) {\n setTimeout(async () => {\n log.info(`reconnecting in ${options.retryDelay}s...`, { url });\n await createWebsocketTrigger(ctx, space, spec, callback, options);\n }, options.retryDelay * 1_000);\n }\n open.wake(false);\n },\n\n onerror: (event) => {\n log.catch(event.error, { url });\n open.wake(false);\n },\n\n onmessage: async (event) => {\n try {\n log.info('message');\n const data = JSON.parse(new TextDecoder().decode(event.data as Uint8Array));\n await callback({ data });\n } catch (err) {\n log.catch(err, { url });\n }\n },\n } satisfies Partial<WebSocket>);\n\n const isOpen = await open.wait();\n if (ctx.disposed) {\n break;\n }\n if (isOpen) {\n wasOpen = true;\n break;\n }\n const wait = Math.pow(attempt, 2) * options.retryDelay;\n if (attempt < options.maxAttempts) {\n log.warn(`failed to connect; trying again in ${wait}s`, { attempt });\n await sleep(wait * 1_000);\n }\n }\n\n ctx.onDispose(() => {\n ws?.close();\n });\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAsB;AAEtB,kBAA2C;AAC3C,qBAAuC;AACvC,kBAA0B;AAC1B,iBAAoB;AACpB,kBAAiC;ACNjC,qBAAoB;AACpB,6BAAwB;AAExB,uBAAqB;AAErB,IAAAA,gBAA6C;AAE7C,IAAAC,kBAAwB;AACxB,uBAA0B;AAC1B,IAAAC,cAAoB;ACTpB,IAAAC,oBAAiB;AAEjB,IAAAH,gBAAsB;AAEtB,IAAAC,kBAAwB;AACxB,IAAAC,cAAoB;ACLpB,IAAAF,gBAAsB;AAEtB,IAAAI,eAAoD;AACpD,IAAAH,kBAAkC;AAClC,yBAA+D;AAC/D,IAAAI,oBAA0B;AAC1B,IAAAC,eAA0B;AAC1B,IAAAJ,cAAoB;AACpB,IAAAK,eAAiC;ACRjC,mBAAyB;AACzB,IAAAP,gBAA0C;AAC1C,IAAAI,eAAmC;AAEnC,qBAA8D;AAC9D,IAAAF,cAAoB;ACL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2Q,SACA9Q,YACe;AACf,UAAM+P,UAA6B,CAAA;AACnC,aAASqB,IAAIpR,WAAWoB,SAAS,GAAGgQ,KAAK,GAAGA,KAAK;AAC/C,YAAMC,aACJP,QAAQjJ,OAAO,CAACnB,YAAYA,QAAQwK,OAAO,EAAEpH,KAAK,CAACpD,YAAYA,QAAQyB,OAAOnI,WAAWoR,CAAAA,EAAG1K,QAAQyB,EAAE,KAAK;AAC7G,UAAIkJ,YAAY;AACd,cAAMC,eAAetR,WAAWuR,OAAOH,GAAG,CAAA,EAAG,CAAA;AAC7C,cAAME,aAAanB,eAAe1J,QAAAA;AAClCsJ,gBAAQ5M,KAAKmO,aAAa5K,OAAO;MACnC;IACF;AAEA,QAAIqJ,QAAQ3O,SAAS,GAAG;AACtBD,kBAAAA,IAAIuB,KAAK,WAAW,OAAO;QACzB4H,UAAUnK,MAAME;QAChB8I,UAAU4G,QAAQ7H,IAAI,CAACxB,YAAYA,QAAQqD,QAAQ;MACrD,IAAA;;;;;;AAEA,WAAKgG,QAAQ3M,KAAK;QAAEjD;QAAOgJ,UAAU4G;MAAQ,CAAA;IAC/C;EACF;EAEQE,aAAa9P,OAAcqR,WAAuE;AACxG,UAAMC,mBAAmB,KAAK3B,oBAAoB1P,IAAID,MAAME,GAAG,KAAK,CAAA;AACpE,WAAOoR,iBAAiB5J,OAAO2J,SAAAA,EAAWtJ,IAAI,CAACxB,YAAYA,QAAQA,OAAO;EAC5E;AACF;",
6
+ "names": ["import_async", "import_context", "import_log", "import_node_path", "import_echo", "import_invariant", "import_keys", "import_util", "import_get_port_please", "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", "_open", "info", "spacesSubscription", "spaces", "subscribe", "has", "waitUntilReady", "_ctx", "disposed", "onDispose", "push", "emit", "unsubscribe", "_close", "_", "clear", "DevServer", "_functionsRegistry", "_options", "createContext", "_handlers", "_seq", "update", "stats", "seq", "endpoint", "invariant", "_port", "proxy", "_proxy", "Object", "start", "_server", "app", "express", "use", "json", "post", "req", "res", "path", "params", "reload", "_load", "statusCode", "asyncTimeout", "invoke", "body", "end", "err", "catch", "port", "getPort", "host", "portRange", "listen", "registrationId", "services", "FunctionRegistryService", "_functionServiceRegistration", "_handleNewFunctions", "on", "stop", "Error", "dispose", "trigger", "Trigger", "close", "unregister", "undefined", "wake", "throw", "wait", "newFunctions", "_safeUpdateRegistration", "force", "route", "handler", "filePath", "join", "baseDir", "keys", "require", "cache", "filter", "startsWith", "module", "default", "updateRegistration", "map", "id", "data", "now", "Date", "_invoke", "duration", "event", "context", "client", "dataDir", "response", "status", "code", "Context", "name", "Scheduler", "triggers", "_functionUriToCallMutex", "_safeActivateTriggers", "getInactiveTriggers", "open", "manifest", "mountTasks", "activate", "Promise", "all", "definition", "find", "function", "args", "mutex", "Mutex", "executeSynchronized", "_execFunction", "meta", "spaceKey", "payload", "assign", "callback", "url", "triggerType", "spec", "type", "fetch", "method", "headers", "JSON", "stringify", "error", "message", "createSubscriptionTrigger", "ctx", "objectIds", "Set", "task", "UpdateScheduler", "size", "Array", "from", "maxFrequency", "subscriptions", "subscription", "createSubscription", "updated", "sizeBefore", "object", "options", "deep", "delay", "content", "TextType", "getObjectCore", "updates", "debounce", "typename", "props", "createTimerTrigger", "DeferredTask", "last", "job", "CronJob", "cronTime", "cron", "runOnInit", "onTick", "delta", "truncate", "count", "schedule", "createWebhookTrigger", "server", "http", "createServer", "random", "createWebsocketTrigger", "retryDelay", "maxAttempts", "init", "wasOpen", "ws", "attempt", "WebSocket", "onopen", "send", "TextEncoder", "encode", "onclose", "setTimeout", "onerror", "onmessage", "parse", "TextDecoder", "decode", "isOpen", "Math", "pow", "warn", "sleep", "triggerHandlers", "timer", "webhook", "websocket", "TriggerRegistry", "_triggersBySpaceKey", "removed", "getActiveTriggers", "_getTriggers", "t", "activationCtx", "registeredTrigger", "reg", "FunctionTrigger", "manifestTriggers", "ECHO_ATTR_META", "foreignKey", "compareForeignKeys", "getMeta", "flush", "spaceListSubscription", "current", "_handleRemovedTriggers", "_handleNewTriggers", "candidate", "enabled", "newRegisteredTriggers", "i", "wasRemoved", "unregistered", "splice", "predicate", "allSpaceTriggers"]
7
+ }
@@ -18,19 +18,19 @@ 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
- DevServer: () => import_chunk_H5Q2TXOA.DevServer,
22
- FUNCTION_SCHEMA: () => import_chunk_3E6PY6JH.FUNCTION_SCHEMA,
23
- FunctionDef: () => import_chunk_3E6PY6JH.FunctionDef,
24
- FunctionManifestSchema: () => import_chunk_3E6PY6JH.FunctionManifestSchema,
25
- FunctionRegistry: () => import_chunk_H5Q2TXOA.FunctionRegistry,
26
- FunctionTrigger: () => import_chunk_3E6PY6JH.FunctionTrigger,
27
- Scheduler: () => import_chunk_H5Q2TXOA.Scheduler,
28
- TriggerRegistry: () => import_chunk_H5Q2TXOA.TriggerRegistry,
21
+ DevServer: () => import_chunk_CIFOOX2V.DevServer,
22
+ FUNCTION_SCHEMA: () => import_chunk_BLLSDTKZ.FUNCTION_SCHEMA,
23
+ FunctionDef: () => import_chunk_BLLSDTKZ.FunctionDef,
24
+ FunctionManifestSchema: () => import_chunk_BLLSDTKZ.FunctionManifestSchema,
25
+ FunctionRegistry: () => import_chunk_CIFOOX2V.FunctionRegistry,
26
+ FunctionTrigger: () => import_chunk_BLLSDTKZ.FunctionTrigger,
27
+ Scheduler: () => import_chunk_CIFOOX2V.Scheduler,
28
+ TriggerRegistry: () => import_chunk_CIFOOX2V.TriggerRegistry,
29
29
  subscriptionHandler: () => subscriptionHandler
30
30
  });
31
31
  module.exports = __toCommonJS(node_exports);
32
- var import_chunk_H5Q2TXOA = require("./chunk-H5Q2TXOA.cjs");
33
- var import_chunk_3E6PY6JH = require("./chunk-3E6PY6JH.cjs");
32
+ var import_chunk_CIFOOX2V = require("./chunk-CIFOOX2V.cjs");
33
+ var import_chunk_BLLSDTKZ = require("./chunk-BLLSDTKZ.cjs");
34
34
  var import_client = require("@dxos/client");
35
35
  var import_log = require("@dxos/log");
36
36
  var import_util = require("@dxos/util");