@dxos/functions 0.3.8-next.f4e0086 → 0.3.9-main.03b62b6

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":1341,"imports":[],"format":"esm"},"packages/core/functions/src/manifest.ts":{"bytes":1795,"imports":[],"format":"esm"},"packages/core/functions/src/runtime/dev-server.ts":{"bytes":18840,"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":20292,"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":18300},"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":4802},"packages/core/functions/src/runtime/index.ts":{"bytesInOutput":0},"packages/core/functions/src/runtime/scheduler.ts":{"bytesInOutput":5040}},"bytes":10423}}}
@@ -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: 46,
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: 63,
87
91
  S: this,
88
92
  C: (f, a) => f(...a)
89
93
  });
@@ -93,66 +97,56 @@ 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: 83,
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
+ host: "localhost",
122
+ port: 7200,
123
+ portRange: [
124
+ 7200,
125
+ 7299
126
+ ]
143
127
  });
144
128
  this._server = app.listen(this._port);
145
129
  try {
146
- const { registrationId } = await this._client.services.services.FunctionRegistryService.register({
130
+ const { registrationId, endpoint } = await this._client.services.services.FunctionRegistryService.register({
147
131
  endpoint: this.endpoint,
148
- functions: this.functions.map(({ def: { endpoint } }) => ({
149
- name: endpoint
132
+ functions: this.functions.map(({ def: { name } }) => ({
133
+ name
150
134
  }))
151
135
  });
136
+ import_log.log.info("registered", {
137
+ registrationId,
138
+ endpoint
139
+ }, {
140
+ F: __dxlog_file,
141
+ L: 99,
142
+ S: this,
143
+ C: (f, a) => f(...a)
144
+ });
152
145
  this._registrationId = registrationId;
146
+ this._proxy = endpoint;
153
147
  } catch (err) {
154
148
  await this.stop();
155
- throw new Error("FunctionRegistryService not available; check config (agent.plugins.functions).");
149
+ throw new Error("FunctionRegistryService not available (check plugin is configured).");
156
150
  }
157
151
  }
158
152
  async stop() {
@@ -162,31 +156,102 @@ var DevServer = class {
162
156
  await this._client.services.services.FunctionRegistryService.unregister({
163
157
  registrationId: this._registrationId
164
158
  });
159
+ import_log.log.info("unregistered", {
160
+ registrationId: this._registrationId
161
+ }, {
162
+ F: __dxlog_file,
163
+ L: 116,
164
+ S: this,
165
+ C: (f, a) => f(...a)
166
+ });
165
167
  this._registrationId = void 0;
168
+ this._proxy = void 0;
166
169
  }
167
170
  trigger.wake();
168
171
  });
169
172
  await trigger.wait();
170
- this._server = void 0;
171
173
  this._port = void 0;
174
+ this._server = void 0;
175
+ }
176
+ /**
177
+ * Load function.
178
+ */
179
+ async _load(def, flush = false) {
180
+ const { id, name, handler } = def;
181
+ const path = (0, import_node_path.join)(this._options.directory, handler);
182
+ import_log.log.info("loading", {
183
+ id
184
+ }, {
185
+ F: __dxlog_file,
186
+ L: 135,
187
+ S: this,
188
+ C: (f, a) => f(...a)
189
+ });
190
+ if (flush) {
191
+ Object.keys(__require.cache).filter((key) => key.startsWith(path)).forEach((key) => delete __require.cache[key]);
192
+ }
193
+ const module2 = __require(path);
194
+ if (typeof module2.default !== "function") {
195
+ throw new Error(`Handler must export default function: ${id}`);
196
+ }
197
+ this._handlers[name] = {
198
+ def,
199
+ handler: module2.default
200
+ };
201
+ }
202
+ /**
203
+ * Invoke function handler.
204
+ */
205
+ async _invoke(name, event) {
206
+ const seq = ++this._seq;
207
+ const now = Date.now();
208
+ import_log.log.info("req", {
209
+ seq,
210
+ name
211
+ }, {
212
+ F: __dxlog_file,
213
+ L: 160,
214
+ S: this,
215
+ C: (f, a) => f(...a)
216
+ });
217
+ const { handler } = this._handlers[name];
218
+ const context = {
219
+ client: this._client,
220
+ dataDir: this._options.dataDir
221
+ };
222
+ let statusCode = 200;
223
+ const response = {
224
+ status: (code) => {
225
+ statusCode = code;
226
+ return response;
227
+ }
228
+ };
229
+ await handler({
230
+ context,
231
+ event,
232
+ response
233
+ });
234
+ import_log.log.info("res", {
235
+ seq,
236
+ name,
237
+ statusCode,
238
+ duration: Date.now() - now
239
+ }, {
240
+ F: __dxlog_file,
241
+ L: 177,
242
+ S: this,
243
+ C: (f, a) => f(...a)
244
+ });
245
+ return statusCode;
172
246
  }
173
247
  };
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) {
248
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/functions/src/runtime/scheduler.ts";
249
+ var Scheduler = class {
250
+ constructor(_client, _manifest, _options) {
185
251
  this._client = _client;
186
252
  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();
253
+ this._options = _options;
254
+ this._mounts = new import_util.ComplexMap(({ id, spaceKey }) => `${spaceKey.toHex()}:${id}`);
190
255
  }
191
256
  async start() {
192
257
  this._client.spaces.subscribe(async (spaces) => {
@@ -199,22 +264,22 @@ var TriggerManager = class {
199
264
  });
200
265
  }
201
266
  async stop() {
202
- for (const { name, spaceKey } of this._mounts.keys()) {
203
- await this.unmount(name, spaceKey);
267
+ for (const { id, spaceKey } of this._mounts.keys()) {
268
+ await this.unmount(id, spaceKey);
204
269
  }
205
270
  }
206
271
  async mount(ctx, space, trigger) {
207
272
  const key = {
208
- name: trigger.function,
273
+ id: trigger.function,
209
274
  spaceKey: space.key
210
275
  };
211
- const config = this._manifest.functions.find((config2) => config2.id === trigger.function);
212
- (0, import_invariant.invariant)(config, `Function not found: ${trigger.function}`, {
276
+ const def = this._manifest.functions.find((config) => config.id === trigger.function);
277
+ (0, import_invariant2.invariant)(def, `Function not found: ${trigger.function}`, {
213
278
  F: __dxlog_file2,
214
- L: 58,
279
+ L: 59,
215
280
  S: this,
216
281
  A: [
217
- "config",
282
+ "def",
218
283
  "`Function not found: ${trigger.function}`"
219
284
  ]
220
285
  });
@@ -229,57 +294,77 @@ var TriggerManager = class {
229
294
  trigger
230
295
  }, {
231
296
  F: __dxlog_file2,
232
- L: 62,
297
+ L: 64,
233
298
  S: this,
234
299
  C: (f, a) => f(...a)
235
300
  });
236
301
  if (ctx.disposed) {
237
302
  return;
238
303
  }
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)
304
+ if (trigger.schedule) {
305
+ const task = new import_async2.DeferredTask(ctx, async () => {
306
+ await this.execFunction(def, {
307
+ space: space.key
308
+ });
244
309
  });
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)
310
+ const job = new import_cron.CronJob(trigger.schedule, () => task.schedule());
311
+ job.start();
312
+ ctx.onDispose(() => job.stop());
313
+ }
314
+ if (trigger.subscription) {
315
+ const objectIds = /* @__PURE__ */ new Set();
316
+ const task = new import_async2.DeferredTask(ctx, async () => {
317
+ await this.execFunction(def, {
318
+ space: space.key,
319
+ objects: Array.from(objectIds)
320
+ });
264
321
  });
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
- });
322
+ const subscriptions = [];
323
+ const subscription = (0, import_echo_schema.createSubscription)(({ added, updated }) => {
324
+ for (const object of added) {
325
+ objectIds.add(object.id);
326
+ }
327
+ for (const object of updated) {
328
+ objectIds.add(object.id);
329
+ }
330
+ task.schedule();
331
+ });
332
+ subscriptions.push(() => subscription.unsubscribe());
333
+ const { type, props, deep, delay } = trigger.subscription;
334
+ const update = ({ objects }) => {
335
+ subscription.update(objects);
336
+ if (deep) {
337
+ import_log2.log.info("update", {
338
+ type,
339
+ deep,
340
+ objects: objects.length
341
+ }, {
342
+ F: __dxlog_file2,
343
+ L: 114,
344
+ S: this,
345
+ C: (f, a) => f(...a)
346
+ });
347
+ for (const object of objects) {
348
+ const content = object.content;
349
+ if (content instanceof import_echo.TextObject) {
350
+ subscriptions.push(content[import_echo_schema.subscribe]((0, import_async2.debounce)(() => subscription.update([
351
+ object
352
+ ]), 1e3)));
353
+ }
354
+ }
355
+ }
356
+ };
357
+ const query = space.db.query(import_echo_schema.Filter.typename(type, props));
358
+ subscriptions.push(query.subscribe(delay ? (0, import_async2.debounce)(update, delay * 1e3) : update));
359
+ ctx.onDispose(() => {
360
+ subscriptions.forEach((unsubscribe) => unsubscribe());
361
+ });
362
+ }
278
363
  }
279
364
  }
280
- async unmount(name, spaceKey) {
365
+ async unmount(id, spaceKey) {
281
366
  const key = {
282
- name,
367
+ id,
283
368
  spaceKey
284
369
  };
285
370
  const { ctx } = this._mounts.get(key) ?? {};
@@ -288,59 +373,39 @@ var TriggerManager = class {
288
373
  await ctx.dispose();
289
374
  }
290
375
  }
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
- });
376
+ async execFunction(def, data) {
311
377
  try {
312
- (0, import_log2.log)("invoke", {
313
- function: functionName
378
+ (0, import_log2.log)("request", {
379
+ function: def.id
314
380
  }, {
315
381
  F: __dxlog_file2,
316
- L: 125,
382
+ L: 147,
317
383
  S: this,
318
384
  C: (f, a) => f(...a)
319
385
  });
320
- const url = `${endpoint}/${runtime}/${functionName}`;
321
- const res = await fetch(url, {
386
+ const response = await fetch(`${this._options.endpoint}/${def.name}`, {
322
387
  method: "POST",
323
- body: JSON.stringify(data),
324
388
  headers: {
325
389
  "Content-Type": "application/json"
326
- }
390
+ },
391
+ body: JSON.stringify(data)
327
392
  });
328
393
  (0, import_log2.log)("result", {
329
- function: functionName,
330
- result: await res.json()
394
+ function: def.id,
395
+ result: response.status
331
396
  }, {
332
397
  F: __dxlog_file2,
333
- L: 135,
398
+ L: 157,
334
399
  S: this,
335
400
  C: (f, a) => f(...a)
336
401
  });
337
402
  } catch (err) {
338
403
  import_log2.log.error("error", {
339
- function: functionName,
404
+ function: def.id,
340
405
  error: err.message
341
406
  }, {
342
407
  F: __dxlog_file2,
343
- L: 137,
408
+ L: 159,
344
409
  S: this,
345
410
  C: (f, a) => f(...a)
346
411
  });
@@ -350,6 +415,6 @@ var TriggerManager = class {
350
415
  // Annotate the CommonJS export names for ESM import in node:
351
416
  0 && (module.exports = {
352
417
  DevServer,
353
- TriggerManager
418
+ Scheduler
354
419
  });
355
420
  //# sourceMappingURL=index.cjs.map