@dxos/functions 0.3.8-next.f4e0086 → 0.3.9-main.14901ff

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.
@@ -1 +1 @@
1
- {"inputs":{"packages/core/functions/src/handler.ts":{"bytes":1109,"imports":[],"format":"esm"},"packages/core/functions/src/manifest.ts":{"bytes":1358,"imports":[],"format":"esm"},"packages/core/functions/src/runtime/dev-server.ts":{"bytes":15536,"imports":[{"path":"express","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"portfinder","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/runtime/trigger-manager.ts":{"bytes":17315,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/runtime/index.ts":{"bytes":584,"imports":[{"path":"packages/core/functions/src/runtime/dev-server.ts","kind":"import-statement","original":"./dev-server"},{"path":"packages/core/functions/src/runtime/trigger-manager.ts","kind":"import-statement","original":"./trigger-manager"}],"format":"esm"},"packages/core/functions/src/index.ts":{"bytes":637,"imports":[{"path":"packages/core/functions/src/handler.ts","kind":"import-statement","original":"./handler"},{"path":"packages/core/functions/src/manifest.ts","kind":"import-statement","original":"./manifest"},{"path":"packages/core/functions/src/runtime/index.ts","kind":"import-statement","original":"./runtime"}],"format":"esm"}},"outputs":{"packages/core/functions/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":15421},"packages/core/functions/dist/lib/browser/index.mjs":{"imports":[{"path":"express","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"portfinder","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["DevServer","TriggerManager"],"entryPoint":"packages/core/functions/src/index.ts","inputs":{"packages/core/functions/src/index.ts":{"bytesInOutput":0},"packages/core/functions/src/runtime/dev-server.ts":{"bytesInOutput":3815},"packages/core/functions/src/runtime/index.ts":{"bytesInOutput":0},"packages/core/functions/src/runtime/trigger-manager.ts":{"bytesInOutput":4642}},"bytes":9049}}}
1
+ {"inputs":{"packages/core/functions/src/handler.ts":{"bytes":1313,"imports":[],"format":"esm"},"packages/core/functions/src/manifest.ts":{"bytes":1795,"imports":[],"format":"esm"},"packages/core/functions/src/runtime/dev-server.ts":{"bytes":18569,"imports":[{"path":"express","kind":"import-statement","external":true},{"path":"get-port-please","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/runtime/scheduler.ts":{"bytes":20325,"imports":[{"path":"cron","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/runtime/index.ts":{"bytes":566,"imports":[{"path":"packages/core/functions/src/runtime/dev-server.ts","kind":"import-statement","original":"./dev-server"},{"path":"packages/core/functions/src/runtime/scheduler.ts","kind":"import-statement","original":"./scheduler"}],"format":"esm"},"packages/core/functions/src/index.ts":{"bytes":637,"imports":[{"path":"packages/core/functions/src/handler.ts","kind":"import-statement","original":"./handler"},{"path":"packages/core/functions/src/manifest.ts","kind":"import-statement","original":"./manifest"},{"path":"packages/core/functions/src/runtime/index.ts","kind":"import-statement","original":"./runtime"}],"format":"esm"}},"outputs":{"packages/core/functions/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18178},"packages/core/functions/dist/lib/browser/index.mjs":{"imports":[{"path":"express","kind":"import-statement","external":true},{"path":"get-port-please","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"cron","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["DevServer","Scheduler"],"entryPoint":"packages/core/functions/src/index.ts","inputs":{"packages/core/functions/src/index.ts":{"bytesInOutput":0},"packages/core/functions/src/runtime/dev-server.ts":{"bytesInOutput":4739},"packages/core/functions/src/runtime/index.ts":{"bytesInOutput":0},"packages/core/functions/src/runtime/scheduler.ts":{"bytesInOutput":5045}},"bytes":10365}}}
@@ -26,64 +26,68 @@ 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
-
30
- // packages/core/functions/src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
29
+ var node_exports = {};
30
+ __export(node_exports, {
33
31
  DevServer: () => DevServer,
34
- TriggerManager: () => TriggerManager
32
+ Scheduler: () => Scheduler
35
33
  });
36
- module.exports = __toCommonJS(src_exports);
37
-
38
- // packages/core/functions/src/runtime/dev-server.ts
34
+ module.exports = __toCommonJS(node_exports);
39
35
  var import_express = __toESM(require("express"));
36
+ var import_get_port_please = require("get-port-please");
40
37
  var import_node_path = require("node:path");
41
- var import_portfinder = require("portfinder");
42
38
  var import_async = require("@dxos/async");
39
+ var import_invariant = require("@dxos/invariant");
43
40
  var import_log = require("@dxos/log");
41
+ var import_cron = require("cron");
42
+ var import_async2 = require("@dxos/async");
43
+ var import_echo = require("@dxos/client/echo");
44
+ var import_context = require("@dxos/context");
45
+ var import_echo_schema = require("@dxos/echo-schema");
46
+ var import_invariant2 = require("@dxos/invariant");
47
+ var import_log2 = require("@dxos/log");
48
+ var import_util = require("@dxos/util");
49
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
50
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
51
+ }) : x)(function(x) {
52
+ if (typeof require !== "undefined")
53
+ return require.apply(this, arguments);
54
+ throw Error('Dynamic require of "' + x + '" is not supported');
55
+ });
44
56
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/functions/src/runtime/dev-server.ts";
45
- var DEFAULT_PORT = 7001;
46
57
  var DevServer = class {
47
58
  // prettier-ignore
48
59
  constructor(_client, _options) {
49
60
  this._client = _client;
50
61
  this._options = _options;
51
62
  this._handlers = {};
52
- }
53
- get port() {
54
- return this._port;
63
+ this._seq = 0;
55
64
  }
56
65
  get endpoint() {
57
- return this._port ? `http://localhost:${this._port}` : void 0;
66
+ (0, import_invariant.invariant)(this._port, void 0, {
67
+ F: __dxlog_file,
68
+ L: 45,
69
+ S: this,
70
+ A: [
71
+ "this._port",
72
+ ""
73
+ ]
74
+ });
75
+ return `http://localhost:${this._port}`;
76
+ }
77
+ get proxy() {
78
+ return this._proxy;
58
79
  }
59
80
  get functions() {
60
81
  return Object.values(this._handlers);
61
82
  }
62
83
  async initialize() {
63
84
  for (const def of this._options.manifest.functions) {
64
- const { id, endpoint, handler: path } = def;
65
85
  try {
66
- const module2 = require((0, import_node_path.join)(this._options.directory, path));
67
- const handler = module2.default;
68
- if (typeof handler !== "function") {
69
- throw new Error(`Handler must export default function: ${id}`);
70
- }
71
- if (this._handlers[endpoint]) {
72
- import_log.log.warn(`Function already registered: ${id}`, void 0, {
73
- F: __dxlog_file,
74
- L: 64,
75
- S: this,
76
- C: (f, a) => f(...a)
77
- });
78
- }
79
- this._handlers[endpoint] = {
80
- def,
81
- handler
82
- };
86
+ await this._load(def);
83
87
  } catch (err) {
84
88
  import_log.log.error("parsing function (check manifest)", err, {
85
89
  F: __dxlog_file,
86
- L: 69,
90
+ L: 62,
87
91
  S: this,
88
92
  C: (f, a) => f(...a)
89
93
  });
@@ -93,66 +97,55 @@ var DevServer = class {
93
97
  async start() {
94
98
  const app = (0, import_express.default)();
95
99
  app.use(import_express.default.json());
96
- app.post("/:endpoint", async (req, res) => {
97
- const { endpoint } = req.params;
98
- const response = {
99
- status: (code) => {
100
- res.statusCode = code;
101
- return response;
102
- },
103
- succeed: (result = {}) => {
104
- res.end(JSON.stringify(result));
105
- return response;
106
- }
107
- };
108
- const context = {
109
- client: this._client,
110
- status: response.status.bind(response)
111
- };
112
- void (async () => {
113
- try {
114
- (0, import_log.log)("invoking", {
115
- endpoint
116
- }, {
117
- F: __dxlog_file,
118
- L: 100,
119
- S: this,
120
- C: (f, a) => f(...a)
121
- });
122
- const { handler } = this._handlers[endpoint];
123
- const response2 = await handler({
124
- context,
125
- event: req.body
126
- });
127
- (0, import_log.log)("done", {
128
- response: response2
129
- }, {
130
- F: __dxlog_file,
131
- L: 103,
132
- S: this,
133
- C: (f, a) => f(...a)
134
- });
135
- } catch (err) {
136
- res.statusCode = 500;
137
- res.end(err.message);
100
+ app.post("/:name", async (req, res) => {
101
+ const { name } = req.params;
102
+ try {
103
+ if (this._options.reload) {
104
+ const { def } = this._handlers[name];
105
+ await this._load(def, true);
138
106
  }
139
- })();
107
+ res.statusCode = await this._invoke(name, req.body);
108
+ res.end();
109
+ } catch (err) {
110
+ import_log.log.catch(err, void 0, {
111
+ F: __dxlog_file,
112
+ L: 82,
113
+ S: this,
114
+ C: (f, a) => f(...a)
115
+ });
116
+ res.statusCode = 500;
117
+ res.end();
118
+ }
140
119
  });
141
- this._port = await (0, import_portfinder.getPortPromise)({
142
- startPort: DEFAULT_PORT
120
+ this._port = await (0, import_get_port_please.getPort)({
121
+ port: 7200,
122
+ portRange: [
123
+ 7200,
124
+ 7299
125
+ ]
143
126
  });
144
127
  this._server = app.listen(this._port);
145
128
  try {
146
- const { registrationId } = await this._client.services.services.FunctionRegistryService.register({
129
+ const { registrationId, endpoint } = await this._client.services.services.FunctionRegistryService.register({
147
130
  endpoint: this.endpoint,
148
- functions: this.functions.map(({ def: { endpoint } }) => ({
149
- name: endpoint
131
+ functions: this.functions.map(({ def: { name } }) => ({
132
+ name
150
133
  }))
151
134
  });
135
+ import_log.log.info("registered", {
136
+ registrationId,
137
+ endpoint
138
+ }, {
139
+ F: __dxlog_file,
140
+ L: 98,
141
+ S: this,
142
+ C: (f, a) => f(...a)
143
+ });
152
144
  this._registrationId = registrationId;
145
+ this._proxy = endpoint;
153
146
  } catch (err) {
154
147
  await this.stop();
155
- throw new Error("FunctionRegistryService not available; check config (agent.plugins.functions).");
148
+ throw new Error("FunctionRegistryService not available (check plugin is configured).");
156
149
  }
157
150
  }
158
151
  async stop() {
@@ -162,31 +155,101 @@ var DevServer = class {
162
155
  await this._client.services.services.FunctionRegistryService.unregister({
163
156
  registrationId: this._registrationId
164
157
  });
158
+ import_log.log.info("unregistered", {
159
+ registrationId: this._registrationId
160
+ }, {
161
+ F: __dxlog_file,
162
+ L: 115,
163
+ S: this,
164
+ C: (f, a) => f(...a)
165
+ });
165
166
  this._registrationId = void 0;
167
+ this._proxy = void 0;
166
168
  }
167
169
  trigger.wake();
168
170
  });
169
171
  await trigger.wait();
170
- this._server = void 0;
171
172
  this._port = void 0;
173
+ this._server = void 0;
174
+ }
175
+ /**
176
+ * Load function.
177
+ */
178
+ async _load(def, flush = false) {
179
+ const { id, name, handler } = def;
180
+ const path = (0, import_node_path.join)(this._options.directory, handler);
181
+ import_log.log.info("loading", {
182
+ id
183
+ }, {
184
+ F: __dxlog_file,
185
+ L: 134,
186
+ S: this,
187
+ C: (f, a) => f(...a)
188
+ });
189
+ if (flush) {
190
+ Object.keys(__require.cache).filter((key) => key.startsWith(path)).forEach((key) => delete __require.cache[key]);
191
+ }
192
+ const module2 = __require(path);
193
+ if (typeof module2.default !== "function") {
194
+ throw new Error(`Handler must export default function: ${id}`);
195
+ }
196
+ this._handlers[name] = {
197
+ def,
198
+ handler: module2.default
199
+ };
200
+ }
201
+ /**
202
+ * Invoke function handler.
203
+ */
204
+ async _invoke(name, event) {
205
+ const seq = ++this._seq;
206
+ const now = Date.now();
207
+ import_log.log.info("req", {
208
+ seq,
209
+ name
210
+ }, {
211
+ F: __dxlog_file,
212
+ L: 159,
213
+ S: this,
214
+ C: (f, a) => f(...a)
215
+ });
216
+ const { handler } = this._handlers[name];
217
+ const context = {
218
+ client: this._client
219
+ };
220
+ let statusCode = 200;
221
+ const response = {
222
+ status: (code) => {
223
+ statusCode = code;
224
+ return response;
225
+ }
226
+ };
227
+ await handler({
228
+ context,
229
+ event,
230
+ response
231
+ });
232
+ import_log.log.info("res", {
233
+ seq,
234
+ name,
235
+ statusCode,
236
+ duration: Date.now() - now
237
+ }, {
238
+ F: __dxlog_file,
239
+ L: 175,
240
+ S: this,
241
+ C: (f, a) => f(...a)
242
+ });
243
+ return statusCode;
172
244
  }
173
245
  };
174
-
175
- // packages/core/functions/src/runtime/trigger-manager.ts
176
- var import_async2 = require("@dxos/async");
177
- var import_context = require("@dxos/context");
178
- var import_echo_schema = require("@dxos/echo-schema");
179
- var import_invariant = require("@dxos/invariant");
180
- var import_log2 = require("@dxos/log");
181
- var import_util = require("@dxos/util");
182
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/functions/src/runtime/trigger-manager.ts";
183
- var TriggerManager = class {
184
- constructor(_client, _manifest, _invokeOptions) {
246
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/functions/src/runtime/scheduler.ts";
247
+ var Scheduler = class {
248
+ constructor(_client, _manifest, _options) {
185
249
  this._client = _client;
186
250
  this._manifest = _manifest;
187
- this._invokeOptions = _invokeOptions;
188
- this._mounts = new import_util.ComplexMap(({ name, spaceKey }) => `${spaceKey.toHex()}:${name}`);
189
- this._queries = /* @__PURE__ */ new Set();
251
+ this._options = _options;
252
+ this._mounts = new import_util.ComplexMap(({ id, spaceKey }) => `${spaceKey.toHex()}:${id}`);
190
253
  }
191
254
  async start() {
192
255
  this._client.spaces.subscribe(async (spaces) => {
@@ -199,22 +262,22 @@ var TriggerManager = class {
199
262
  });
200
263
  }
201
264
  async stop() {
202
- for (const { name, spaceKey } of this._mounts.keys()) {
203
- await this.unmount(name, spaceKey);
265
+ for (const { id, spaceKey } of this._mounts.keys()) {
266
+ await this.unmount(id, spaceKey);
204
267
  }
205
268
  }
206
269
  async mount(ctx, space, trigger) {
207
270
  const key = {
208
- name: trigger.function,
271
+ id: trigger.function,
209
272
  spaceKey: space.key
210
273
  };
211
- const config = this._manifest.functions.find((config2) => config2.id === trigger.function);
212
- (0, import_invariant.invariant)(config, `Function not found: ${trigger.function}`, {
274
+ const def = this._manifest.functions.find((config) => config.id === trigger.function);
275
+ (0, import_invariant2.invariant)(def, `Function not found: ${trigger.function}`, {
213
276
  F: __dxlog_file2,
214
- L: 58,
277
+ L: 59,
215
278
  S: this,
216
279
  A: [
217
- "config",
280
+ "def",
218
281
  "`Function not found: ${trigger.function}`"
219
282
  ]
220
283
  });
@@ -224,62 +287,82 @@ var TriggerManager = class {
224
287
  ctx,
225
288
  trigger
226
289
  });
227
- (0, import_log2.log)("mount", {
290
+ import_log2.log.info("mount", {
228
291
  space: space.key,
229
292
  trigger
230
293
  }, {
231
294
  F: __dxlog_file2,
232
- L: 62,
295
+ L: 64,
233
296
  S: this,
234
297
  C: (f, a) => f(...a)
235
298
  });
236
299
  if (ctx.disposed) {
237
300
  return;
238
301
  }
239
- const objectIds = /* @__PURE__ */ new Set();
240
- const task = new import_async2.DeferredTask(ctx, async () => {
241
- await this.execFunction(this._invokeOptions, config.endpoint, {
242
- space: space.key,
243
- objects: Array.from(objectIds)
302
+ if (trigger.schedule) {
303
+ const task = new import_async2.DeferredTask(ctx, async () => {
304
+ await this.execFunction(def, {
305
+ space: space.key
306
+ });
244
307
  });
245
- });
246
- let count = 0;
247
- const subscription = (0, import_echo_schema.createSubscription)(({ added, updated }) => {
248
- for (const object of added) {
249
- objectIds.add(object.id);
250
- }
251
- for (const object of updated) {
252
- objectIds.add(object.id);
253
- }
254
- (0, import_log2.log)("updated", {
255
- trigger,
256
- space: space.key,
257
- objects: objectIds.size,
258
- count
259
- }, {
260
- F: __dxlog_file2,
261
- L: 85,
262
- S: this,
263
- C: (f, a) => f(...a)
308
+ const job = new import_cron.CronJob(trigger.schedule, () => task.schedule());
309
+ job.start();
310
+ ctx.onDispose(() => job.stop());
311
+ }
312
+ if (trigger.subscription) {
313
+ const objectIds = /* @__PURE__ */ new Set();
314
+ const task = new import_async2.DeferredTask(ctx, async () => {
315
+ await this.execFunction(def, {
316
+ space: space.key,
317
+ objects: Array.from(objectIds)
318
+ });
264
319
  });
265
- task.schedule();
266
- count++;
267
- });
268
- const query = space.db.query(import_echo_schema.Filter.typename(trigger.subscription.type, trigger.subscription.props));
269
- this._queries.add(query);
270
- const unsubscribe = query.subscribe(({ objects }) => {
271
- subscription.update(objects);
272
- }, true);
273
- ctx.onDispose(() => {
274
- subscription.unsubscribe();
275
- unsubscribe();
276
- this._queries.delete(query);
277
- });
320
+ const subscriptions = [];
321
+ const subscription = (0, import_echo_schema.createSubscription)(({ added, updated }) => {
322
+ for (const object of added) {
323
+ objectIds.add(object.id);
324
+ }
325
+ for (const object of updated) {
326
+ objectIds.add(object.id);
327
+ }
328
+ task.schedule();
329
+ });
330
+ subscriptions.push(() => subscription.unsubscribe());
331
+ const { type, props, deep, delay } = trigger.subscription;
332
+ const update = ({ objects }) => {
333
+ subscription.update(objects);
334
+ if (deep) {
335
+ import_log2.log.info("update", {
336
+ type,
337
+ deep,
338
+ objects: objects.length
339
+ }, {
340
+ F: __dxlog_file2,
341
+ L: 114,
342
+ S: this,
343
+ C: (f, a) => f(...a)
344
+ });
345
+ for (const object of objects) {
346
+ const content = object.content;
347
+ if (content instanceof import_echo.TextObject) {
348
+ subscriptions.push(content[import_echo_schema.subscribe]((0, import_async2.debounce)(() => subscription.update([
349
+ object
350
+ ]), 1e3)));
351
+ }
352
+ }
353
+ }
354
+ };
355
+ const query = space.db.query(import_echo_schema.Filter.typename(type, props));
356
+ subscriptions.push(query.subscribe(delay ? (0, import_async2.debounce)(update, delay * 1e3) : update));
357
+ ctx.onDispose(() => {
358
+ subscriptions.forEach((unsubscribe) => unsubscribe());
359
+ });
360
+ }
278
361
  }
279
362
  }
280
- async unmount(name, spaceKey) {
363
+ async unmount(id, spaceKey) {
281
364
  const key = {
282
- name,
365
+ id,
283
366
  spaceKey
284
367
  };
285
368
  const { ctx } = this._mounts.get(key) ?? {};
@@ -288,59 +371,39 @@ var TriggerManager = class {
288
371
  await ctx.dispose();
289
372
  }
290
373
  }
291
- async execFunction(options, functionName, data) {
292
- const { endpoint, runtime } = options;
293
- (0, import_invariant.invariant)(endpoint, "Missing endpoint", {
294
- F: __dxlog_file2,
295
- L: 121,
296
- S: this,
297
- A: [
298
- "endpoint",
299
- "'Missing endpoint'"
300
- ]
301
- });
302
- (0, import_invariant.invariant)(runtime, "Missing runtime", {
303
- F: __dxlog_file2,
304
- L: 122,
305
- S: this,
306
- A: [
307
- "runtime",
308
- "'Missing runtime'"
309
- ]
310
- });
374
+ async execFunction(def, data) {
311
375
  try {
312
- (0, import_log2.log)("invoke", {
313
- function: functionName
376
+ (0, import_log2.log)("request", {
377
+ function: def.id
314
378
  }, {
315
379
  F: __dxlog_file2,
316
- L: 125,
380
+ L: 147,
317
381
  S: this,
318
382
  C: (f, a) => f(...a)
319
383
  });
320
- const url = `${endpoint}/${runtime}/${functionName}`;
321
- const res = await fetch(url, {
384
+ const response = await fetch(`${this._options.endpoint}/${def.name}`, {
322
385
  method: "POST",
323
- body: JSON.stringify(data),
324
386
  headers: {
325
387
  "Content-Type": "application/json"
326
- }
388
+ },
389
+ body: JSON.stringify(data)
327
390
  });
328
391
  (0, import_log2.log)("result", {
329
- function: functionName,
330
- result: await res.json()
392
+ function: def.id,
393
+ result: response.status
331
394
  }, {
332
395
  F: __dxlog_file2,
333
- L: 135,
396
+ L: 157,
334
397
  S: this,
335
398
  C: (f, a) => f(...a)
336
399
  });
337
400
  } catch (err) {
338
401
  import_log2.log.error("error", {
339
- function: functionName,
402
+ function: def.id,
340
403
  error: err.message
341
404
  }, {
342
405
  F: __dxlog_file2,
343
- L: 137,
406
+ L: 159,
344
407
  S: this,
345
408
  C: (f, a) => f(...a)
346
409
  });
@@ -350,6 +413,6 @@ var TriggerManager = class {
350
413
  // Annotate the CommonJS export names for ESM import in node:
351
414
  0 && (module.exports = {
352
415
  DevServer,
353
- TriggerManager
416
+ Scheduler
354
417
  });
355
418
  //# sourceMappingURL=index.cjs.map