@dxos/functions 0.5.3-main.37bbd91 → 0.5.3-main.3b535c7
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.
- package/dist/lib/browser/index.mjs +471 -825
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +461 -805
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/handler.d.ts +12 -33
- package/dist/types/src/handler.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/runtime/dev-server.d.ts +13 -16
- package/dist/types/src/runtime/dev-server.d.ts.map +1 -1
- package/dist/types/src/runtime/scheduler.d.ts +27 -13
- package/dist/types/src/runtime/scheduler.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +101 -143
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +15 -33
- package/schema/functions.json +104 -140
- package/src/handler.ts +31 -54
- package/src/index.ts +0 -2
- package/src/runtime/dev-server.ts +53 -104
- package/src/runtime/scheduler.test.ts +73 -56
- package/src/runtime/scheduler.ts +271 -87
- package/src/types.ts +32 -59
- package/dist/lib/browser/chunk-366QG6IX.mjs +0 -81
- package/dist/lib/browser/chunk-366QG6IX.mjs.map +0 -7
- package/dist/lib/browser/types.mjs +0 -12
- package/dist/lib/browser/types.mjs.map +0 -7
- package/dist/lib/node/chunk-3VSJ57ZZ.cjs +0 -97
- package/dist/lib/node/chunk-3VSJ57ZZ.cjs.map +0 -7
- package/dist/lib/node/types.cjs +0 -33
- package/dist/lib/node/types.cjs.map +0 -7
- package/dist/types/src/function/function-registry.d.ts +0 -24
- package/dist/types/src/function/function-registry.d.ts.map +0 -1
- package/dist/types/src/function/function-registry.test.d.ts +0 -2
- package/dist/types/src/function/function-registry.test.d.ts.map +0 -1
- package/dist/types/src/function/index.d.ts +0 -2
- package/dist/types/src/function/index.d.ts.map +0 -1
- package/dist/types/src/runtime/dev-server.test.d.ts +0 -2
- package/dist/types/src/runtime/dev-server.test.d.ts.map +0 -1
- package/dist/types/src/testing/functions-integration.test.d.ts +0 -2
- package/dist/types/src/testing/functions-integration.test.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -4
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/setup.d.ts +0 -5
- package/dist/types/src/testing/setup.d.ts.map +0 -1
- package/dist/types/src/testing/test/handler.d.ts +0 -4
- package/dist/types/src/testing/test/handler.d.ts.map +0 -1
- package/dist/types/src/testing/test/index.d.ts +0 -3
- package/dist/types/src/testing/test/index.d.ts.map +0 -1
- package/dist/types/src/testing/types.d.ts +0 -9
- package/dist/types/src/testing/types.d.ts.map +0 -1
- package/dist/types/src/testing/util.d.ts +0 -3
- package/dist/types/src/testing/util.d.ts.map +0 -1
- package/dist/types/src/trigger/index.d.ts +0 -2
- package/dist/types/src/trigger/index.d.ts.map +0 -1
- package/dist/types/src/trigger/trigger-registry.d.ts +0 -40
- package/dist/types/src/trigger/trigger-registry.d.ts.map +0 -1
- package/dist/types/src/trigger/trigger-registry.test.d.ts +0 -2
- package/dist/types/src/trigger/trigger-registry.test.d.ts.map +0 -1
- package/dist/types/src/trigger/type/index.d.ts +0 -5
- package/dist/types/src/trigger/type/index.d.ts.map +0 -1
- package/dist/types/src/trigger/type/subscription-trigger.d.ts +0 -4
- package/dist/types/src/trigger/type/subscription-trigger.d.ts.map +0 -1
- package/dist/types/src/trigger/type/timer-trigger.d.ts +0 -4
- package/dist/types/src/trigger/type/timer-trigger.d.ts.map +0 -1
- package/dist/types/src/trigger/type/webhook-trigger.d.ts +0 -4
- package/dist/types/src/trigger/type/webhook-trigger.d.ts.map +0 -1
- package/dist/types/src/trigger/type/websocket-trigger.d.ts +0 -13
- package/dist/types/src/trigger/type/websocket-trigger.d.ts.map +0 -1
- package/dist/types/src/util.d.ts +0 -15
- package/dist/types/src/util.d.ts.map +0 -1
- package/dist/types/src/util.test.d.ts +0 -2
- package/dist/types/src/util.test.d.ts.map +0 -1
- package/src/function/function-registry.test.ts +0 -105
- package/src/function/function-registry.ts +0 -90
- package/src/function/index.ts +0 -5
- package/src/runtime/dev-server.test.ts +0 -60
- package/src/testing/functions-integration.test.ts +0 -99
- package/src/testing/index.ts +0 -7
- package/src/testing/setup.ts +0 -45
- package/src/testing/test/handler.ts +0 -15
- package/src/testing/test/index.ts +0 -7
- package/src/testing/types.ts +0 -9
- package/src/testing/util.ts +0 -16
- package/src/trigger/index.ts +0 -5
- package/src/trigger/trigger-registry.test.ts +0 -255
- package/src/trigger/trigger-registry.ts +0 -189
- package/src/trigger/type/index.ts +0 -8
- package/src/trigger/type/subscription-trigger.ts +0 -80
- package/src/trigger/type/timer-trigger.ts +0 -44
- package/src/trigger/type/webhook-trigger.ts +0 -47
- package/src/trigger/type/websocket-trigger.ts +0 -91
- package/src/util.test.ts +0 -43
- package/src/util.ts +0 -48
package/dist/lib/node/index.cjs
CHANGED
|
@@ -29,215 +29,87 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var node_exports = {};
|
|
30
30
|
__export(node_exports, {
|
|
31
31
|
DevServer: () => DevServer,
|
|
32
|
-
|
|
33
|
-
FunctionManifestSchema: () => import_chunk_3VSJ57ZZ.FunctionManifestSchema,
|
|
34
|
-
FunctionRegistry: () => FunctionRegistry,
|
|
35
|
-
FunctionTrigger: () => import_chunk_3VSJ57ZZ.FunctionTrigger,
|
|
32
|
+
FunctionManifestSchema: () => FunctionManifestSchema,
|
|
36
33
|
Scheduler: () => Scheduler,
|
|
37
|
-
TriggerRegistry: () => TriggerRegistry,
|
|
38
34
|
subscriptionHandler: () => subscriptionHandler
|
|
39
35
|
});
|
|
40
36
|
module.exports = __toCommonJS(node_exports);
|
|
41
|
-
var
|
|
42
|
-
var import_async = require("@dxos/async");
|
|
43
|
-
var import_echo = require("@dxos/client/echo");
|
|
44
|
-
var import_context = require("@dxos/context");
|
|
45
|
-
var import_keys = require("@dxos/keys");
|
|
37
|
+
var import_client = require("@dxos/client");
|
|
46
38
|
var import_log = require("@dxos/log");
|
|
47
39
|
var import_util = require("@dxos/util");
|
|
48
|
-
var import_client = require("@dxos/client");
|
|
49
|
-
var import_log2 = require("@dxos/log");
|
|
50
|
-
var import_util2 = require("@dxos/util");
|
|
51
40
|
var import_express = __toESM(require("express"));
|
|
52
41
|
var import_get_port_please = require("get-port-please");
|
|
53
42
|
var import_node_path = require("node:path");
|
|
54
|
-
var
|
|
55
|
-
var import_context2 = require("@dxos/context");
|
|
43
|
+
var import_async = require("@dxos/async");
|
|
56
44
|
var import_invariant = require("@dxos/invariant");
|
|
57
|
-
var
|
|
58
|
-
var import_node_path2 = __toESM(require("node:path"));
|
|
59
|
-
var import_async3 = require("@dxos/async");
|
|
60
|
-
var import_context3 = require("@dxos/context");
|
|
61
|
-
var import_log4 = require("@dxos/log");
|
|
62
|
-
var import_async4 = require("@dxos/async");
|
|
63
|
-
var import_echo2 = require("@dxos/client/echo");
|
|
64
|
-
var import_context4 = require("@dxos/context");
|
|
65
|
-
var import_echo_schema = require("@dxos/echo-schema");
|
|
66
|
-
var import_invariant2 = require("@dxos/invariant");
|
|
67
|
-
var import_keys2 = require("@dxos/keys");
|
|
68
|
-
var import_log5 = require("@dxos/log");
|
|
69
|
-
var import_util3 = require("@dxos/util");
|
|
70
|
-
var import_types = require("@braneframe/types");
|
|
71
|
-
var import_async5 = require("@dxos/async");
|
|
72
|
-
var import_echo_db = require("@dxos/echo-db");
|
|
73
|
-
var import_log6 = require("@dxos/log");
|
|
45
|
+
var import_log2 = require("@dxos/log");
|
|
74
46
|
var import_cron = require("cron");
|
|
75
|
-
var import_async6 = require("@dxos/async");
|
|
76
|
-
var import_log7 = require("@dxos/log");
|
|
77
|
-
var import_get_port_please2 = require("get-port-please");
|
|
78
47
|
var import_node_http = __toESM(require("node:http"));
|
|
79
|
-
var import_log8 = require("@dxos/log");
|
|
80
48
|
var import_ws = __toESM(require("ws"));
|
|
81
|
-
var
|
|
82
|
-
var
|
|
83
|
-
var
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
result.updated.push(remaining[index]);
|
|
98
|
-
remaining.splice(index, 1);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return result;
|
|
102
|
-
};
|
|
103
|
-
var intersection = (a, b, comparator) => a.filter((a2) => b.find((b2) => comparator(a2, b2)) !== void 0);
|
|
104
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/functions/src/function/function-registry.ts";
|
|
105
|
-
var FunctionRegistry = class extends import_context.Resource {
|
|
106
|
-
constructor(_client) {
|
|
107
|
-
super();
|
|
108
|
-
this._client = _client;
|
|
109
|
-
this._functionBySpaceKey = new import_util.ComplexMap(import_keys.PublicKey.hash);
|
|
110
|
-
this.registered = new import_async.Event();
|
|
111
|
-
}
|
|
112
|
-
getFunctions(space) {
|
|
113
|
-
return this._functionBySpaceKey.get(space.key) ?? [];
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Loads function definitions from the manifest into the space.
|
|
117
|
-
* We first load all the definitions from the space to deduplicate by functionId.
|
|
118
|
-
*/
|
|
119
|
-
async register(space, functions) {
|
|
120
|
-
(0, import_log.log)("register", {
|
|
121
|
-
space: space.key,
|
|
122
|
-
functions: functions?.length ?? 0
|
|
123
|
-
}, {
|
|
124
|
-
F: __dxlog_file,
|
|
125
|
-
L: 39,
|
|
126
|
-
S: this,
|
|
127
|
-
C: (f, a) => f(...a)
|
|
128
|
-
});
|
|
129
|
-
if (!functions?.length) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
if (!space.db.graph.runtimeSchemaRegistry.hasSchema(import_chunk_3VSJ57ZZ.FunctionDef)) {
|
|
133
|
-
space.db.graph.runtimeSchemaRegistry.registerSchema(import_chunk_3VSJ57ZZ.FunctionDef);
|
|
134
|
-
}
|
|
135
|
-
const { objects: existing } = await space.db.query(import_echo.Filter.schema(import_chunk_3VSJ57ZZ.FunctionDef)).run();
|
|
136
|
-
const { added, removed } = diff(existing, functions, (a, b) => a.uri === b.uri);
|
|
137
|
-
added.forEach((def) => space.db.add((0, import_echo.create)(import_chunk_3VSJ57ZZ.FunctionDef, def)));
|
|
138
|
-
removed.forEach((def) => space.db.remove(def));
|
|
139
|
-
}
|
|
140
|
-
async _open() {
|
|
141
|
-
const spacesSubscription = this._client.spaces.subscribe(async (spaces) => {
|
|
142
|
-
for (const space of spaces) {
|
|
143
|
-
if (this._functionBySpaceKey.has(space.key)) {
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
const registered = [];
|
|
147
|
-
this._functionBySpaceKey.set(space.key, registered);
|
|
148
|
-
await space.waitUntilReady();
|
|
149
|
-
if (this._ctx.disposed) {
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
this._ctx.onDispose(space.db.query(import_echo.Filter.schema(import_chunk_3VSJ57ZZ.FunctionDef)).subscribe(({ objects }) => {
|
|
153
|
-
const { added } = diff(registered, objects, (a, b) => a.uri === b.uri);
|
|
154
|
-
if (added.length > 0) {
|
|
155
|
-
registered.push(...added);
|
|
156
|
-
this.registered.emit({
|
|
157
|
-
space,
|
|
158
|
-
added
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}));
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
this._ctx.onDispose(() => spacesSubscription.unsubscribe());
|
|
165
|
-
}
|
|
166
|
-
async _close(_) {
|
|
167
|
-
this._functionBySpaceKey.clear();
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/functions/src/handler.ts";
|
|
49
|
+
var import_types = require("@braneframe/types");
|
|
50
|
+
var import_async2 = require("@dxos/async");
|
|
51
|
+
var import_echo = require("@dxos/client/echo");
|
|
52
|
+
var import_context = require("@dxos/context");
|
|
53
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
54
|
+
var import_log3 = require("@dxos/log");
|
|
55
|
+
var import_util2 = require("@dxos/util");
|
|
56
|
+
var S = __toESM(require("@effect/schema/Schema"));
|
|
57
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
58
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
59
|
+
}) : x)(function(x) {
|
|
60
|
+
if (typeof require !== "undefined")
|
|
61
|
+
return require.apply(this, arguments);
|
|
62
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
63
|
+
});
|
|
64
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/functions/src/handler.ts";
|
|
171
65
|
var subscriptionHandler = (handler) => {
|
|
172
|
-
return ({ event
|
|
66
|
+
return ({ event, context, ...rest }) => {
|
|
173
67
|
const { client } = context;
|
|
174
|
-
const space =
|
|
175
|
-
const objects = space
|
|
176
|
-
if (!!
|
|
177
|
-
|
|
178
|
-
|
|
68
|
+
const space = event.space ? client.spaces.get(import_client.PublicKey.from(event.space)) : void 0;
|
|
69
|
+
const objects = space && event.objects?.map((id) => space.db.getObjectById(id)).filter(import_util.nonNullable);
|
|
70
|
+
if (!!event.space && !space) {
|
|
71
|
+
import_log.log.warn("invalid space", {
|
|
72
|
+
event
|
|
179
73
|
}, {
|
|
180
|
-
F:
|
|
181
|
-
L:
|
|
74
|
+
F: __dxlog_file,
|
|
75
|
+
L: 68,
|
|
182
76
|
S: void 0,
|
|
183
77
|
C: (f, a) => f(...a)
|
|
184
78
|
});
|
|
185
79
|
} else {
|
|
186
|
-
|
|
80
|
+
import_log.log.info("handler", {
|
|
187
81
|
space: space?.key.truncate(),
|
|
188
82
|
objects: objects?.length
|
|
189
83
|
}, {
|
|
190
|
-
F:
|
|
191
|
-
L:
|
|
84
|
+
F: __dxlog_file,
|
|
85
|
+
L: 70,
|
|
192
86
|
S: void 0,
|
|
193
87
|
C: (f, a) => f(...a)
|
|
194
88
|
});
|
|
195
89
|
}
|
|
196
90
|
return handler({
|
|
197
91
|
event: {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
space,
|
|
201
|
-
objects
|
|
202
|
-
}
|
|
92
|
+
space,
|
|
93
|
+
objects
|
|
203
94
|
},
|
|
204
95
|
context,
|
|
205
96
|
...rest
|
|
206
97
|
});
|
|
207
98
|
};
|
|
208
99
|
};
|
|
209
|
-
var
|
|
100
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/functions/src/runtime/dev-server.ts";
|
|
210
101
|
var DevServer = class {
|
|
211
|
-
|
|
102
|
+
// prettier-ignore
|
|
103
|
+
constructor(_client, _options) {
|
|
212
104
|
this._client = _client;
|
|
213
|
-
this._functionsRegistry = _functionsRegistry;
|
|
214
105
|
this._options = _options;
|
|
215
|
-
this._ctx = createContext();
|
|
216
106
|
this._handlers = {};
|
|
217
107
|
this._seq = 0;
|
|
218
|
-
this.update = new import_async2.Event();
|
|
219
|
-
this._functionsRegistry.registered.on(async ({ added }) => {
|
|
220
|
-
added.forEach((def) => this._load(def));
|
|
221
|
-
await this._safeUpdateRegistration();
|
|
222
|
-
(0, import_log3.log)("new functions loaded", {
|
|
223
|
-
added
|
|
224
|
-
}, {
|
|
225
|
-
F: __dxlog_file3,
|
|
226
|
-
L: 52,
|
|
227
|
-
S: this,
|
|
228
|
-
C: (f, a) => f(...a)
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
get stats() {
|
|
233
|
-
return {
|
|
234
|
-
seq: this._seq
|
|
235
|
-
};
|
|
236
108
|
}
|
|
237
109
|
get endpoint() {
|
|
238
110
|
(0, import_invariant.invariant)(this._port, void 0, {
|
|
239
|
-
F:
|
|
240
|
-
L:
|
|
111
|
+
F: __dxlog_file2,
|
|
112
|
+
L: 46,
|
|
241
113
|
S: this,
|
|
242
114
|
A: [
|
|
243
115
|
"this._port",
|
|
@@ -252,46 +124,44 @@ var DevServer = class {
|
|
|
252
124
|
get functions() {
|
|
253
125
|
return Object.values(this._handlers);
|
|
254
126
|
}
|
|
127
|
+
async initialize() {
|
|
128
|
+
for (const def of this._options.manifest.functions) {
|
|
129
|
+
try {
|
|
130
|
+
await this._load(def);
|
|
131
|
+
} catch (err) {
|
|
132
|
+
import_log2.log.error("parsing function (check manifest)", err, {
|
|
133
|
+
F: __dxlog_file2,
|
|
134
|
+
L: 63,
|
|
135
|
+
S: this,
|
|
136
|
+
C: (f, a) => f(...a)
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
255
141
|
async start() {
|
|
256
|
-
(0, import_invariant.invariant)(!this._server, void 0, {
|
|
257
|
-
F: __dxlog_file3,
|
|
258
|
-
L: 76,
|
|
259
|
-
S: this,
|
|
260
|
-
A: [
|
|
261
|
-
"!this._server",
|
|
262
|
-
""
|
|
263
|
-
]
|
|
264
|
-
});
|
|
265
|
-
import_log3.log.info("starting...", void 0, {
|
|
266
|
-
F: __dxlog_file3,
|
|
267
|
-
L: 77,
|
|
268
|
-
S: this,
|
|
269
|
-
C: (f, a) => f(...a)
|
|
270
|
-
});
|
|
271
|
-
this._ctx = createContext();
|
|
272
142
|
const app = (0, import_express.default)();
|
|
273
143
|
app.use(import_express.default.json());
|
|
274
|
-
app.post("/:
|
|
275
|
-
const {
|
|
144
|
+
app.post("/:name", async (req, res) => {
|
|
145
|
+
const { name } = req.params;
|
|
276
146
|
try {
|
|
277
|
-
|
|
278
|
-
|
|
147
|
+
import_log2.log.info("calling", {
|
|
148
|
+
name
|
|
279
149
|
}, {
|
|
280
|
-
F:
|
|
281
|
-
L:
|
|
150
|
+
F: __dxlog_file2,
|
|
151
|
+
L: 75,
|
|
282
152
|
S: this,
|
|
283
153
|
C: (f, a) => f(...a)
|
|
284
154
|
});
|
|
285
155
|
if (this._options.reload) {
|
|
286
|
-
const { def } = this._handlers[
|
|
156
|
+
const { def } = this._handlers[name];
|
|
287
157
|
await this._load(def, true);
|
|
288
158
|
}
|
|
289
|
-
res.statusCode = await this.
|
|
159
|
+
res.statusCode = await this._invoke(name, req.body);
|
|
290
160
|
res.end();
|
|
291
161
|
} catch (err) {
|
|
292
|
-
|
|
293
|
-
F:
|
|
294
|
-
L:
|
|
162
|
+
import_log2.log.catch(err, void 0, {
|
|
163
|
+
F: __dxlog_file2,
|
|
164
|
+
L: 84,
|
|
295
165
|
S: this,
|
|
296
166
|
C: (f, a) => f(...a)
|
|
297
167
|
});
|
|
@@ -310,195 +180,93 @@ var DevServer = class {
|
|
|
310
180
|
this._server = app.listen(this._port);
|
|
311
181
|
try {
|
|
312
182
|
const { registrationId, endpoint } = await this._client.services.services.FunctionRegistryService.register({
|
|
313
|
-
endpoint: this.endpoint
|
|
183
|
+
endpoint: this.endpoint,
|
|
184
|
+
functions: this.functions.map(({ def: { name } }) => ({
|
|
185
|
+
name
|
|
186
|
+
}))
|
|
314
187
|
});
|
|
315
|
-
|
|
188
|
+
import_log2.log.info("registered", {
|
|
189
|
+
registrationId,
|
|
316
190
|
endpoint
|
|
317
191
|
}, {
|
|
318
|
-
F:
|
|
319
|
-
L:
|
|
192
|
+
F: __dxlog_file2,
|
|
193
|
+
L: 100,
|
|
320
194
|
S: this,
|
|
321
195
|
C: (f, a) => f(...a)
|
|
322
196
|
});
|
|
197
|
+
this._registrationId = registrationId;
|
|
323
198
|
this._proxy = endpoint;
|
|
324
|
-
this._functionServiceRegistration = registrationId;
|
|
325
|
-
await this._functionsRegistry.open(this._ctx);
|
|
326
199
|
} catch (err) {
|
|
327
200
|
await this.stop();
|
|
328
201
|
throw new Error("FunctionRegistryService not available (check plugin is configured).");
|
|
329
202
|
}
|
|
330
|
-
import_log3.log.info("started", {
|
|
331
|
-
port: this._port
|
|
332
|
-
}, {
|
|
333
|
-
F: __dxlog_file3,
|
|
334
|
-
L: 123,
|
|
335
|
-
S: this,
|
|
336
|
-
C: (f, a) => f(...a)
|
|
337
|
-
});
|
|
338
203
|
}
|
|
339
204
|
async stop() {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
""
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
this._server.close(async () => {
|
|
357
|
-
import_log3.log.info("server stopped", void 0, {
|
|
358
|
-
F: __dxlog_file3,
|
|
359
|
-
L: 132,
|
|
360
|
-
S: this,
|
|
361
|
-
C: (f, a) => f(...a)
|
|
362
|
-
});
|
|
363
|
-
try {
|
|
364
|
-
if (this._functionServiceRegistration) {
|
|
365
|
-
(0, import_invariant.invariant)(this._client.services.services.FunctionRegistryService, void 0, {
|
|
366
|
-
F: __dxlog_file3,
|
|
367
|
-
L: 135,
|
|
368
|
-
S: this,
|
|
369
|
-
A: [
|
|
370
|
-
"this._client.services.services.FunctionRegistryService",
|
|
371
|
-
""
|
|
372
|
-
]
|
|
373
|
-
});
|
|
374
|
-
await this._client.services.services.FunctionRegistryService.unregister({
|
|
375
|
-
registrationId: this._functionServiceRegistration
|
|
376
|
-
});
|
|
377
|
-
import_log3.log.info("unregistered", {
|
|
378
|
-
registrationId: this._functionServiceRegistration
|
|
379
|
-
}, {
|
|
380
|
-
F: __dxlog_file3,
|
|
381
|
-
L: 140,
|
|
382
|
-
S: this,
|
|
383
|
-
C: (f, a) => f(...a)
|
|
384
|
-
});
|
|
385
|
-
this._functionServiceRegistration = void 0;
|
|
386
|
-
this._proxy = void 0;
|
|
387
|
-
}
|
|
388
|
-
trigger.wake();
|
|
389
|
-
} catch (err) {
|
|
390
|
-
trigger.throw(err);
|
|
205
|
+
const trigger = new import_async.Trigger();
|
|
206
|
+
this._server?.close(async () => {
|
|
207
|
+
if (this._registrationId) {
|
|
208
|
+
await this._client.services.services.FunctionRegistryService.unregister({
|
|
209
|
+
registrationId: this._registrationId
|
|
210
|
+
});
|
|
211
|
+
import_log2.log.info("unregistered", {
|
|
212
|
+
registrationId: this._registrationId
|
|
213
|
+
}, {
|
|
214
|
+
F: __dxlog_file2,
|
|
215
|
+
L: 117,
|
|
216
|
+
S: this,
|
|
217
|
+
C: (f, a) => f(...a)
|
|
218
|
+
});
|
|
219
|
+
this._registrationId = void 0;
|
|
220
|
+
this._proxy = void 0;
|
|
391
221
|
}
|
|
222
|
+
trigger.wake();
|
|
392
223
|
});
|
|
393
224
|
await trigger.wait();
|
|
394
225
|
this._port = void 0;
|
|
395
226
|
this._server = void 0;
|
|
396
|
-
import_log3.log.info("stopped", void 0, {
|
|
397
|
-
F: __dxlog_file3,
|
|
398
|
-
L: 154,
|
|
399
|
-
S: this,
|
|
400
|
-
C: (f, a) => f(...a)
|
|
401
|
-
});
|
|
402
227
|
}
|
|
403
228
|
/**
|
|
404
229
|
* Load function.
|
|
405
230
|
*/
|
|
406
|
-
async _load(def,
|
|
407
|
-
const {
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
force
|
|
231
|
+
async _load(def, flush = false) {
|
|
232
|
+
const { id, name, handler } = def;
|
|
233
|
+
const path = (0, import_node_path.join)(this._options.directory, handler);
|
|
234
|
+
import_log2.log.info("loading", {
|
|
235
|
+
id
|
|
412
236
|
}, {
|
|
413
|
-
F:
|
|
414
|
-
L:
|
|
237
|
+
F: __dxlog_file2,
|
|
238
|
+
L: 136,
|
|
415
239
|
S: this,
|
|
416
240
|
C: (f, a) => f(...a)
|
|
417
241
|
});
|
|
418
|
-
if (
|
|
419
|
-
Object.keys(
|
|
420
|
-
delete import_chunk_3VSJ57ZZ.__require.cache[key];
|
|
421
|
-
});
|
|
242
|
+
if (flush) {
|
|
243
|
+
Object.keys(__require.cache).filter((key) => key.startsWith(path)).forEach((key) => delete __require.cache[key]);
|
|
422
244
|
}
|
|
423
|
-
const module2 =
|
|
245
|
+
const module2 = __require(path);
|
|
424
246
|
if (typeof module2.default !== "function") {
|
|
425
|
-
throw new Error(`Handler must export default function: ${
|
|
247
|
+
throw new Error(`Handler must export default function: ${id}`);
|
|
426
248
|
}
|
|
427
|
-
this._handlers[
|
|
249
|
+
this._handlers[name] = {
|
|
428
250
|
def,
|
|
429
251
|
handler: module2.default
|
|
430
252
|
};
|
|
431
253
|
}
|
|
432
|
-
async _safeUpdateRegistration() {
|
|
433
|
-
(0, import_invariant.invariant)(this._functionServiceRegistration, void 0, {
|
|
434
|
-
F: __dxlog_file3,
|
|
435
|
-
L: 185,
|
|
436
|
-
S: this,
|
|
437
|
-
A: [
|
|
438
|
-
"this._functionServiceRegistration",
|
|
439
|
-
""
|
|
440
|
-
]
|
|
441
|
-
});
|
|
442
|
-
try {
|
|
443
|
-
await this._client.services.services.FunctionRegistryService.updateRegistration({
|
|
444
|
-
registrationId: this._functionServiceRegistration,
|
|
445
|
-
functions: this.functions.map(({ def: { id, route } }) => ({
|
|
446
|
-
id,
|
|
447
|
-
route
|
|
448
|
-
}))
|
|
449
|
-
});
|
|
450
|
-
} catch (e) {
|
|
451
|
-
import_log3.log.catch(e, void 0, {
|
|
452
|
-
F: __dxlog_file3,
|
|
453
|
-
L: 192,
|
|
454
|
-
S: this,
|
|
455
|
-
C: (f, a) => f(...a)
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
254
|
/**
|
|
460
|
-
* Invoke function.
|
|
255
|
+
* Invoke function handler.
|
|
461
256
|
*/
|
|
462
|
-
async
|
|
257
|
+
async _invoke(name, event) {
|
|
463
258
|
const seq = ++this._seq;
|
|
464
259
|
const now = Date.now();
|
|
465
|
-
|
|
466
|
-
seq,
|
|
467
|
-
path: path2
|
|
468
|
-
}, {
|
|
469
|
-
F: __dxlog_file3,
|
|
470
|
-
L: 203,
|
|
471
|
-
S: this,
|
|
472
|
-
C: (f, a) => f(...a)
|
|
473
|
-
});
|
|
474
|
-
const statusCode = await this._invoke(path2, {
|
|
475
|
-
data
|
|
476
|
-
});
|
|
477
|
-
import_log3.log.info("res", {
|
|
260
|
+
import_log2.log.info("req", {
|
|
478
261
|
seq,
|
|
479
|
-
|
|
480
|
-
statusCode,
|
|
481
|
-
duration: Date.now() - now
|
|
262
|
+
name
|
|
482
263
|
}, {
|
|
483
|
-
F:
|
|
484
|
-
L:
|
|
264
|
+
F: __dxlog_file2,
|
|
265
|
+
L: 161,
|
|
485
266
|
S: this,
|
|
486
267
|
C: (f, a) => f(...a)
|
|
487
268
|
});
|
|
488
|
-
this.
|
|
489
|
-
return statusCode;
|
|
490
|
-
}
|
|
491
|
-
async _invoke(path2, event) {
|
|
492
|
-
const { handler } = this._handlers[path2] ?? {};
|
|
493
|
-
(0, import_invariant.invariant)(handler, `invalid path: ${path2}`, {
|
|
494
|
-
F: __dxlog_file3,
|
|
495
|
-
L: 213,
|
|
496
|
-
S: this,
|
|
497
|
-
A: [
|
|
498
|
-
"handler",
|
|
499
|
-
"`invalid path: ${path}`"
|
|
500
|
-
]
|
|
501
|
-
});
|
|
269
|
+
const { handler } = this._handlers[name];
|
|
502
270
|
const context = {
|
|
503
271
|
client: this._client,
|
|
504
272
|
dataDir: this._options.dataDir
|
|
@@ -515,551 +283,439 @@ var DevServer = class {
|
|
|
515
283
|
event,
|
|
516
284
|
response
|
|
517
285
|
});
|
|
286
|
+
import_log2.log.info("res", {
|
|
287
|
+
seq,
|
|
288
|
+
name,
|
|
289
|
+
statusCode,
|
|
290
|
+
duration: Date.now() - now
|
|
291
|
+
}, {
|
|
292
|
+
F: __dxlog_file2,
|
|
293
|
+
L: 178,
|
|
294
|
+
S: this,
|
|
295
|
+
C: (f, a) => f(...a)
|
|
296
|
+
});
|
|
518
297
|
return statusCode;
|
|
519
298
|
}
|
|
520
299
|
};
|
|
521
|
-
var
|
|
522
|
-
name: "DevServer"
|
|
523
|
-
});
|
|
524
|
-
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/functions/src/runtime/scheduler.ts";
|
|
300
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/functions/src/runtime/scheduler.ts";
|
|
525
301
|
var Scheduler = class {
|
|
526
|
-
constructor(
|
|
527
|
-
this.
|
|
528
|
-
this.
|
|
302
|
+
constructor(_client, _manifest, _options = {}) {
|
|
303
|
+
this._client = _client;
|
|
304
|
+
this._manifest = _manifest;
|
|
529
305
|
this._options = _options;
|
|
530
|
-
this.
|
|
531
|
-
this._callMutex = new import_async3.Mutex();
|
|
532
|
-
this.functions.registered.on(async ({ space, added }) => {
|
|
533
|
-
await this._safeActivateTriggers(space, this.triggers.getInactiveTriggers(space), added);
|
|
534
|
-
});
|
|
535
|
-
this.triggers.registered.on(async ({ space, triggers: triggers2 }) => {
|
|
536
|
-
await this._safeActivateTriggers(space, triggers2, this.functions.getFunctions(space));
|
|
537
|
-
});
|
|
306
|
+
this._mounts = new import_util2.ComplexMap(({ id, spaceKey }) => `${spaceKey.toHex()}:${id}`);
|
|
538
307
|
}
|
|
539
308
|
async start() {
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
309
|
+
this._client.spaces.subscribe(async (spaces) => {
|
|
310
|
+
for (const space of spaces) {
|
|
311
|
+
await space.waitUntilReady();
|
|
312
|
+
for (const trigger of this._manifest.triggers ?? []) {
|
|
313
|
+
await this.mount(new import_context.Context(), space, trigger);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
});
|
|
544
317
|
}
|
|
545
318
|
async stop() {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
}
|
|
550
|
-
// TODO(burdon): Remove and update registries directly.
|
|
551
|
-
async register(space, manifest) {
|
|
552
|
-
await this.functions.register(space, manifest.functions);
|
|
553
|
-
await this.triggers.register(space, manifest);
|
|
319
|
+
for (const { id, spaceKey } of this._mounts.keys()) {
|
|
320
|
+
await this.unmount(id, spaceKey);
|
|
321
|
+
}
|
|
554
322
|
}
|
|
555
|
-
async
|
|
556
|
-
const
|
|
557
|
-
|
|
323
|
+
async mount(ctx, space, trigger) {
|
|
324
|
+
const key = {
|
|
325
|
+
id: trigger.function,
|
|
326
|
+
spaceKey: space.key
|
|
327
|
+
};
|
|
328
|
+
const def = this._manifest.functions.find((config) => config.id === trigger.function);
|
|
329
|
+
(0, import_invariant2.invariant)(def, `Function not found: ${trigger.function}`, {
|
|
330
|
+
F: __dxlog_file3,
|
|
331
|
+
L: 72,
|
|
332
|
+
S: this,
|
|
333
|
+
A: [
|
|
334
|
+
"def",
|
|
335
|
+
"`Function not found: ${trigger.function}`"
|
|
336
|
+
]
|
|
558
337
|
});
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
338
|
+
const exists = this._mounts.get(key);
|
|
339
|
+
if (!exists) {
|
|
340
|
+
this._mounts.set(key, {
|
|
341
|
+
ctx,
|
|
342
|
+
trigger
|
|
343
|
+
});
|
|
344
|
+
(0, import_log3.log)("mount", {
|
|
345
|
+
space: space.key,
|
|
346
|
+
trigger
|
|
566
347
|
}, {
|
|
567
|
-
F:
|
|
348
|
+
F: __dxlog_file3,
|
|
568
349
|
L: 78,
|
|
569
350
|
S: this,
|
|
570
351
|
C: (f, a) => f(...a)
|
|
571
352
|
});
|
|
572
|
-
|
|
353
|
+
if (ctx.disposed) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
if (trigger.timer) {
|
|
357
|
+
await this._createTimer(ctx, space, def, trigger.timer);
|
|
358
|
+
}
|
|
359
|
+
if (trigger.webhook) {
|
|
360
|
+
await this._createWebhook(ctx, space, def, trigger.webhook);
|
|
361
|
+
}
|
|
362
|
+
if (trigger.websocket) {
|
|
363
|
+
await this._createWebsocket(ctx, space, def, trigger.websocket);
|
|
364
|
+
}
|
|
365
|
+
if (trigger.subscription) {
|
|
366
|
+
await this._createSubscription(ctx, space, def, trigger.subscription);
|
|
367
|
+
}
|
|
573
368
|
}
|
|
574
|
-
await this.triggers.activate({
|
|
575
|
-
space
|
|
576
|
-
}, fnTrigger, async (args) => {
|
|
577
|
-
return this._callMutex.executeSynchronized(() => {
|
|
578
|
-
return this._execFunction(definition, fnTrigger, {
|
|
579
|
-
meta: fnTrigger.meta,
|
|
580
|
-
data: {
|
|
581
|
-
...args,
|
|
582
|
-
spaceKey: space.key
|
|
583
|
-
}
|
|
584
|
-
});
|
|
585
|
-
});
|
|
586
|
-
});
|
|
587
|
-
(0, import_log4.log)("activated trigger", {
|
|
588
|
-
space: space.key,
|
|
589
|
-
trigger: fnTrigger
|
|
590
|
-
}, {
|
|
591
|
-
F: __dxlog_file4,
|
|
592
|
-
L: 91,
|
|
593
|
-
S: this,
|
|
594
|
-
C: (f, a) => f(...a)
|
|
595
|
-
});
|
|
596
369
|
}
|
|
597
|
-
async
|
|
598
|
-
|
|
370
|
+
async unmount(id, spaceKey) {
|
|
371
|
+
const key = {
|
|
372
|
+
id,
|
|
373
|
+
spaceKey
|
|
374
|
+
};
|
|
375
|
+
const { ctx } = this._mounts.get(key) ?? {};
|
|
376
|
+
if (ctx) {
|
|
377
|
+
this._mounts.delete(key);
|
|
378
|
+
await ctx.dispose();
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
// TODO(burdon): Pass in Space key (common context).
|
|
382
|
+
async _execFunction(def, data) {
|
|
599
383
|
try {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
},
|
|
384
|
+
import_log3.log.info("exec", {
|
|
385
|
+
function: def.id
|
|
386
|
+
}, {
|
|
387
|
+
F: __dxlog_file3,
|
|
388
|
+
L: 117,
|
|
389
|
+
S: this,
|
|
390
|
+
C: (f, a) => f(...a)
|
|
391
|
+
});
|
|
603
392
|
const { endpoint, callback } = this._options;
|
|
604
393
|
if (endpoint) {
|
|
605
|
-
|
|
606
|
-
import_log4.log.info("exec", {
|
|
607
|
-
function: def.uri,
|
|
608
|
-
url,
|
|
609
|
-
triggerType: trigger.spec.type
|
|
610
|
-
}, {
|
|
611
|
-
F: __dxlog_file4,
|
|
612
|
-
L: 108,
|
|
613
|
-
S: this,
|
|
614
|
-
C: (f, a) => f(...a)
|
|
615
|
-
});
|
|
616
|
-
const response = await fetch(url, {
|
|
394
|
+
await fetch(`${this._options.endpoint}/${def.name}`, {
|
|
617
395
|
method: "POST",
|
|
618
396
|
headers: {
|
|
619
397
|
"Content-Type": "application/json"
|
|
620
398
|
},
|
|
621
|
-
body: JSON.stringify(
|
|
399
|
+
body: JSON.stringify(data)
|
|
622
400
|
});
|
|
623
|
-
status = response.status;
|
|
624
401
|
} else if (callback) {
|
|
625
|
-
|
|
626
|
-
function: def.uri
|
|
627
|
-
}, {
|
|
628
|
-
F: __dxlog_file4,
|
|
629
|
-
L: 119,
|
|
630
|
-
S: this,
|
|
631
|
-
C: (f, a) => f(...a)
|
|
632
|
-
});
|
|
633
|
-
status = await callback(payload) ?? 200;
|
|
634
|
-
}
|
|
635
|
-
if (status && status >= 400) {
|
|
636
|
-
throw new Error(`Response: ${status}`);
|
|
402
|
+
await callback(data);
|
|
637
403
|
}
|
|
638
|
-
|
|
639
|
-
function: def.
|
|
640
|
-
status
|
|
404
|
+
import_log3.log.info("done", {
|
|
405
|
+
function: def.id
|
|
641
406
|
}, {
|
|
642
|
-
F:
|
|
643
|
-
L:
|
|
407
|
+
F: __dxlog_file3,
|
|
408
|
+
L: 133,
|
|
644
409
|
S: this,
|
|
645
410
|
C: (f, a) => f(...a)
|
|
646
411
|
});
|
|
647
412
|
} catch (err) {
|
|
648
|
-
|
|
649
|
-
function: def.
|
|
413
|
+
import_log3.log.error("error", {
|
|
414
|
+
function: def.id,
|
|
650
415
|
error: err.message
|
|
651
416
|
}, {
|
|
652
|
-
F:
|
|
653
|
-
L:
|
|
417
|
+
F: __dxlog_file3,
|
|
418
|
+
L: 135,
|
|
654
419
|
S: this,
|
|
655
420
|
C: (f, a) => f(...a)
|
|
656
421
|
});
|
|
657
|
-
status = 500;
|
|
658
422
|
}
|
|
659
|
-
return status;
|
|
660
423
|
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
objectIds.clear();
|
|
672
|
-
await callback({
|
|
673
|
-
objects
|
|
674
|
-
});
|
|
675
|
-
}
|
|
676
|
-
}, {
|
|
677
|
-
maxFrequency: 4
|
|
678
|
-
});
|
|
679
|
-
const subscriptions = [];
|
|
680
|
-
const subscription = (0, import_echo_db.createSubscription)(({ added, updated }) => {
|
|
681
|
-
const sizeBefore = objectIds.size;
|
|
682
|
-
for (const object of added) {
|
|
683
|
-
objectIds.add(object.id);
|
|
684
|
-
}
|
|
685
|
-
for (const object of updated) {
|
|
686
|
-
objectIds.add(object.id);
|
|
687
|
-
}
|
|
688
|
-
if (objectIds.size > sizeBefore) {
|
|
689
|
-
import_log6.log.info("updated", {
|
|
690
|
-
added: added.length,
|
|
691
|
-
updated: updated.length
|
|
692
|
-
}, {
|
|
693
|
-
F: __dxlog_file5,
|
|
694
|
-
L: 45,
|
|
695
|
-
S: void 0,
|
|
696
|
-
C: (f, a) => f(...a)
|
|
697
|
-
});
|
|
698
|
-
task.trigger();
|
|
699
|
-
}
|
|
700
|
-
});
|
|
701
|
-
subscriptions.push(() => subscription.unsubscribe());
|
|
702
|
-
const { filter, options: { deep, delay } = {} } = spec;
|
|
703
|
-
const update = ({ objects }) => {
|
|
704
|
-
subscription.update(objects);
|
|
705
|
-
if (deep) {
|
|
706
|
-
import_log6.log.info("update", {
|
|
707
|
-
objects: objects.length
|
|
708
|
-
}, {
|
|
709
|
-
F: __dxlog_file5,
|
|
710
|
-
L: 59,
|
|
711
|
-
S: void 0,
|
|
712
|
-
C: (f, a) => f(...a)
|
|
713
|
-
});
|
|
714
|
-
for (const object of objects) {
|
|
715
|
-
const content = object.content;
|
|
716
|
-
if (content instanceof import_types.TextV0Type) {
|
|
717
|
-
subscriptions.push((0, import_echo_db.getAutomergeObjectCore)(content).updates.on((0, import_async5.debounce)(() => subscription.update([
|
|
718
|
-
object
|
|
719
|
-
]), 1e3)));
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
};
|
|
724
|
-
const query = triggerCtx.space.db.query(import_echo_db.Filter.or(filter.map(({ type, props }) => import_echo_db.Filter.typename(type, props))));
|
|
725
|
-
subscriptions.push(query.subscribe(delay ? (0, import_async5.debounce)(update, delay) : update));
|
|
726
|
-
ctx.onDispose(() => {
|
|
727
|
-
subscriptions.forEach((unsubscribe) => unsubscribe());
|
|
728
|
-
});
|
|
729
|
-
};
|
|
730
|
-
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/functions/src/trigger/type/timer-trigger.ts";
|
|
731
|
-
var createTimerTrigger = async (ctx, triggerContext, spec, callback) => {
|
|
732
|
-
const task = new import_async6.DeferredTask(ctx, async () => {
|
|
733
|
-
await callback({});
|
|
734
|
-
});
|
|
735
|
-
let last = 0;
|
|
736
|
-
let run = 0;
|
|
737
|
-
const job = import_cron.CronJob.from({
|
|
738
|
-
cronTime: spec.cron,
|
|
739
|
-
runOnInit: false,
|
|
740
|
-
onTick: () => {
|
|
741
|
-
const now = Date.now();
|
|
742
|
-
const delta = last ? now - last : 0;
|
|
743
|
-
last = now;
|
|
744
|
-
run++;
|
|
745
|
-
import_log7.log.info("tick", {
|
|
746
|
-
space: triggerContext.space.key.truncate(),
|
|
747
|
-
count: run,
|
|
748
|
-
delta
|
|
749
|
-
}, {
|
|
750
|
-
F: __dxlog_file6,
|
|
751
|
-
L: 37,
|
|
752
|
-
S: void 0,
|
|
753
|
-
C: (f, a) => f(...a)
|
|
754
|
-
});
|
|
755
|
-
task.schedule();
|
|
756
|
-
}
|
|
757
|
-
});
|
|
758
|
-
job.start();
|
|
759
|
-
ctx.onDispose(() => job.stop());
|
|
760
|
-
};
|
|
761
|
-
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/functions/src/trigger/type/webhook-trigger.ts";
|
|
762
|
-
var createWebhookTrigger = async (ctx, _, spec, callback) => {
|
|
763
|
-
const server = import_node_http.default.createServer(async (req, res) => {
|
|
764
|
-
if (req.method !== spec.method) {
|
|
765
|
-
res.statusCode = 405;
|
|
766
|
-
return res.end();
|
|
767
|
-
}
|
|
768
|
-
res.statusCode = await callback({});
|
|
769
|
-
res.end();
|
|
770
|
-
});
|
|
771
|
-
const port = await (0, import_get_port_please2.getPort)({
|
|
772
|
-
random: true
|
|
773
|
-
});
|
|
774
|
-
server.listen(port, () => {
|
|
775
|
-
import_log8.log.info("started webhook", {
|
|
776
|
-
port
|
|
424
|
+
//
|
|
425
|
+
// Triggers
|
|
426
|
+
//
|
|
427
|
+
/**
|
|
428
|
+
* Cron timer.
|
|
429
|
+
*/
|
|
430
|
+
async _createTimer(ctx, space, def, trigger) {
|
|
431
|
+
import_log3.log.info("timer", {
|
|
432
|
+
space: space.key,
|
|
433
|
+
trigger
|
|
777
434
|
}, {
|
|
778
|
-
F:
|
|
779
|
-
L:
|
|
780
|
-
S:
|
|
435
|
+
F: __dxlog_file3,
|
|
436
|
+
L: 147,
|
|
437
|
+
S: this,
|
|
781
438
|
C: (f, a) => f(...a)
|
|
782
439
|
});
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
};
|
|
789
|
-
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/functions/src/trigger/type/websocket-trigger.ts";
|
|
790
|
-
var createWebsocketTrigger = async (ctx, triggerCtx, spec, callback, options = {
|
|
791
|
-
retryDelay: 2,
|
|
792
|
-
maxAttempts: 5
|
|
793
|
-
}) => {
|
|
794
|
-
const { url, init } = spec;
|
|
795
|
-
let ws;
|
|
796
|
-
for (let attempt = 1; attempt <= options.maxAttempts; attempt++) {
|
|
797
|
-
const open = new import_async7.Trigger();
|
|
798
|
-
ws = new import_ws.default(url);
|
|
799
|
-
Object.assign(ws, {
|
|
800
|
-
onopen: () => {
|
|
801
|
-
import_log9.log.info("opened", {
|
|
802
|
-
url
|
|
803
|
-
}, {
|
|
804
|
-
F: __dxlog_file8,
|
|
805
|
-
L: 39,
|
|
806
|
-
S: void 0,
|
|
807
|
-
C: (f, a) => f(...a)
|
|
808
|
-
});
|
|
809
|
-
if (spec.init) {
|
|
810
|
-
ws.send(new TextEncoder().encode(JSON.stringify(init)));
|
|
811
|
-
}
|
|
812
|
-
open.wake(true);
|
|
813
|
-
},
|
|
814
|
-
onclose: (event) => {
|
|
815
|
-
import_log9.log.info("closed", {
|
|
816
|
-
url,
|
|
817
|
-
code: event.code
|
|
818
|
-
}, {
|
|
819
|
-
F: __dxlog_file8,
|
|
820
|
-
L: 48,
|
|
821
|
-
S: void 0,
|
|
822
|
-
C: (f, a) => f(...a)
|
|
823
|
-
});
|
|
824
|
-
if (event.code === 1006) {
|
|
825
|
-
setTimeout(async () => {
|
|
826
|
-
import_log9.log.info(`reconnecting in ${options.retryDelay}s...`, {
|
|
827
|
-
url
|
|
828
|
-
}, {
|
|
829
|
-
F: __dxlog_file8,
|
|
830
|
-
L: 53,
|
|
831
|
-
S: void 0,
|
|
832
|
-
C: (f, a) => f(...a)
|
|
833
|
-
});
|
|
834
|
-
await createWebsocketTrigger(ctx, triggerCtx, spec, callback, options);
|
|
835
|
-
}, options.retryDelay * 1e3);
|
|
836
|
-
}
|
|
837
|
-
open.wake(false);
|
|
838
|
-
},
|
|
839
|
-
onerror: (event) => {
|
|
840
|
-
import_log9.log.catch(event.error, {
|
|
841
|
-
url
|
|
842
|
-
}, {
|
|
843
|
-
F: __dxlog_file8,
|
|
844
|
-
L: 62,
|
|
845
|
-
S: void 0,
|
|
846
|
-
C: (f, a) => f(...a)
|
|
847
|
-
});
|
|
848
|
-
},
|
|
849
|
-
onmessage: async (event) => {
|
|
850
|
-
try {
|
|
851
|
-
import_log9.log.info("message", void 0, {
|
|
852
|
-
F: __dxlog_file8,
|
|
853
|
-
L: 67,
|
|
854
|
-
S: void 0,
|
|
855
|
-
C: (f, a) => f(...a)
|
|
856
|
-
});
|
|
857
|
-
const data = JSON.parse(new TextDecoder().decode(event.data));
|
|
858
|
-
await callback({
|
|
859
|
-
data
|
|
860
|
-
});
|
|
861
|
-
} catch (err) {
|
|
862
|
-
import_log9.log.catch(err, {
|
|
863
|
-
url
|
|
864
|
-
}, {
|
|
865
|
-
F: __dxlog_file8,
|
|
866
|
-
L: 71,
|
|
867
|
-
S: void 0,
|
|
868
|
-
C: (f, a) => f(...a)
|
|
869
|
-
});
|
|
870
|
-
}
|
|
871
|
-
}
|
|
440
|
+
const { cron } = trigger;
|
|
441
|
+
const task = new import_async2.DeferredTask(ctx, async () => {
|
|
442
|
+
await this._execFunction(def, {
|
|
443
|
+
space: space.key
|
|
444
|
+
});
|
|
872
445
|
});
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
446
|
+
let last = 0;
|
|
447
|
+
let run = 0;
|
|
448
|
+
const job = import_cron.CronJob.from({
|
|
449
|
+
cronTime: cron,
|
|
450
|
+
runOnInit: false,
|
|
451
|
+
onTick: () => {
|
|
452
|
+
const now = Date.now();
|
|
453
|
+
const delta = last ? now - last : 0;
|
|
454
|
+
last = now;
|
|
455
|
+
run++;
|
|
456
|
+
import_log3.log.info("tick", {
|
|
457
|
+
space: space.key.truncate(),
|
|
458
|
+
count: run,
|
|
459
|
+
delta
|
|
881
460
|
}, {
|
|
882
|
-
F:
|
|
883
|
-
L:
|
|
884
|
-
S:
|
|
461
|
+
F: __dxlog_file3,
|
|
462
|
+
L: 167,
|
|
463
|
+
S: this,
|
|
885
464
|
C: (f, a) => f(...a)
|
|
886
465
|
});
|
|
887
|
-
|
|
466
|
+
task.schedule();
|
|
888
467
|
}
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
ws?.close();
|
|
893
|
-
});
|
|
894
|
-
};
|
|
895
|
-
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/functions/src/trigger/trigger-registry.ts";
|
|
896
|
-
var triggerHandlers = {
|
|
897
|
-
subscription: createSubscriptionTrigger,
|
|
898
|
-
timer: createTimerTrigger,
|
|
899
|
-
webhook: createWebhookTrigger,
|
|
900
|
-
websocket: createWebsocketTrigger
|
|
901
|
-
};
|
|
902
|
-
var TriggerRegistry = class extends import_context4.Resource {
|
|
903
|
-
constructor(_client, _options) {
|
|
904
|
-
super();
|
|
905
|
-
this._client = _client;
|
|
906
|
-
this._options = _options;
|
|
907
|
-
this._triggersBySpaceKey = new import_util3.ComplexMap(import_keys2.PublicKey.hash);
|
|
908
|
-
this.registered = new import_async4.Event();
|
|
909
|
-
this.removed = new import_async4.Event();
|
|
910
|
-
}
|
|
911
|
-
getActiveTriggers(space) {
|
|
912
|
-
return this._getTriggers(space, (t) => t.activationCtx != null);
|
|
913
|
-
}
|
|
914
|
-
getInactiveTriggers(space) {
|
|
915
|
-
return this._getTriggers(space, (t) => t.activationCtx == null);
|
|
468
|
+
});
|
|
469
|
+
job.start();
|
|
470
|
+
ctx.onDispose(() => job.stop());
|
|
916
471
|
}
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
472
|
+
/**
|
|
473
|
+
* Webhook.
|
|
474
|
+
*/
|
|
475
|
+
async _createWebhook(ctx, space, def, trigger) {
|
|
476
|
+
import_log3.log.info("webhook", {
|
|
477
|
+
space: space.key,
|
|
920
478
|
trigger
|
|
921
479
|
}, {
|
|
922
|
-
F:
|
|
923
|
-
L:
|
|
480
|
+
F: __dxlog_file3,
|
|
481
|
+
L: 180,
|
|
924
482
|
S: this,
|
|
925
483
|
C: (f, a) => f(...a)
|
|
926
484
|
});
|
|
927
|
-
const
|
|
928
|
-
|
|
485
|
+
const { port } = trigger;
|
|
486
|
+
const server = import_node_http.default.createServer(async (req, res) => {
|
|
487
|
+
await this._execFunction(def, {
|
|
488
|
+
space: space.key
|
|
489
|
+
});
|
|
929
490
|
});
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
491
|
+
server.listen(port, () => {
|
|
492
|
+
import_log3.log.info("started webhook", {
|
|
493
|
+
port
|
|
494
|
+
}, {
|
|
495
|
+
F: __dxlog_file3,
|
|
496
|
+
L: 189,
|
|
497
|
+
S: this,
|
|
498
|
+
C: (f, a) => f(...a)
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
ctx.onDispose(() => {
|
|
502
|
+
server.close();
|
|
940
503
|
});
|
|
941
|
-
registeredTrigger.activationCtx = activationCtx;
|
|
942
|
-
try {
|
|
943
|
-
const options = this._options?.[trigger.spec.type];
|
|
944
|
-
await triggerHandlers[trigger.spec.type](activationCtx, triggerCtx, trigger.spec, callback, options);
|
|
945
|
-
} catch (err) {
|
|
946
|
-
delete registeredTrigger.activationCtx;
|
|
947
|
-
throw err;
|
|
948
|
-
}
|
|
949
504
|
}
|
|
950
505
|
/**
|
|
951
|
-
*
|
|
506
|
+
* Websocket.
|
|
952
507
|
*/
|
|
953
|
-
async
|
|
954
|
-
|
|
955
|
-
|
|
508
|
+
async _createWebsocket(ctx, space, def, trigger, options = {
|
|
509
|
+
retryDelay: 2,
|
|
510
|
+
maxAttempts: 5
|
|
511
|
+
}) {
|
|
512
|
+
import_log3.log.info("websocket", {
|
|
513
|
+
space: space.key,
|
|
514
|
+
trigger
|
|
956
515
|
}, {
|
|
957
|
-
F:
|
|
958
|
-
L:
|
|
516
|
+
F: __dxlog_file3,
|
|
517
|
+
L: 213,
|
|
959
518
|
S: this,
|
|
960
519
|
C: (f, a) => f(...a)
|
|
961
520
|
});
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
521
|
+
const { url } = trigger;
|
|
522
|
+
let ws;
|
|
523
|
+
for (let attempt = 1; attempt <= options.maxAttempts; attempt++) {
|
|
524
|
+
const open = new import_async2.Trigger();
|
|
525
|
+
ws = new import_ws.default(url);
|
|
526
|
+
Object.assign(ws, {
|
|
527
|
+
onopen: () => {
|
|
528
|
+
import_log3.log.info("opened", {
|
|
529
|
+
url
|
|
530
|
+
}, {
|
|
531
|
+
F: __dxlog_file3,
|
|
532
|
+
L: 223,
|
|
533
|
+
S: this,
|
|
534
|
+
C: (f, a) => f(...a)
|
|
535
|
+
});
|
|
536
|
+
if (trigger.init) {
|
|
537
|
+
ws.send(new TextEncoder().encode(JSON.stringify(trigger.init)));
|
|
538
|
+
}
|
|
539
|
+
open.wake(true);
|
|
540
|
+
},
|
|
541
|
+
onclose: () => {
|
|
542
|
+
import_log3.log.info("closed", {
|
|
543
|
+
url
|
|
544
|
+
}, {
|
|
545
|
+
F: __dxlog_file3,
|
|
546
|
+
L: 232,
|
|
547
|
+
S: this,
|
|
548
|
+
C: (f, a) => f(...a)
|
|
549
|
+
});
|
|
550
|
+
open.wake(false);
|
|
551
|
+
},
|
|
552
|
+
onerror: (event) => {
|
|
553
|
+
import_log3.log.catch(event.error, {
|
|
554
|
+
url
|
|
555
|
+
}, {
|
|
556
|
+
F: __dxlog_file3,
|
|
557
|
+
L: 237,
|
|
558
|
+
S: this,
|
|
559
|
+
C: (f, a) => f(...a)
|
|
560
|
+
});
|
|
561
|
+
},
|
|
562
|
+
onmessage: async (event) => {
|
|
563
|
+
try {
|
|
564
|
+
const data = JSON.parse(new TextDecoder().decode(event.data));
|
|
565
|
+
await this._execFunction(def, {
|
|
566
|
+
space: space.key,
|
|
567
|
+
data
|
|
568
|
+
});
|
|
569
|
+
} catch (err) {
|
|
570
|
+
import_log3.log.catch(err, {
|
|
571
|
+
url
|
|
572
|
+
}, {
|
|
573
|
+
F: __dxlog_file3,
|
|
574
|
+
L: 245,
|
|
575
|
+
S: this,
|
|
576
|
+
C: (f, a) => f(...a)
|
|
577
|
+
});
|
|
578
|
+
}
|
|
989
579
|
}
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
580
|
+
});
|
|
581
|
+
const isOpen = await open.wait();
|
|
582
|
+
if (isOpen) {
|
|
583
|
+
break;
|
|
584
|
+
} else {
|
|
585
|
+
const wait = Math.pow(attempt, 2) * options.retryDelay;
|
|
586
|
+
if (attempt < options.maxAttempts) {
|
|
587
|
+
import_log3.log.warn(`failed to connect; trying again in ${wait}s`, {
|
|
588
|
+
attempt
|
|
589
|
+
}, {
|
|
590
|
+
F: __dxlog_file3,
|
|
591
|
+
L: 256,
|
|
592
|
+
S: this,
|
|
593
|
+
C: (f, a) => f(...a)
|
|
594
|
+
});
|
|
595
|
+
await (0, import_async2.sleep)(wait * 1e3);
|
|
995
596
|
}
|
|
996
|
-
const functionsSubscription = space.db.query(import_echo2.Filter.schema(import_chunk_3VSJ57ZZ.FunctionTrigger)).subscribe(async (triggers) => {
|
|
997
|
-
await this._handleRemovedTriggers(space, triggers.objects, registered);
|
|
998
|
-
this._handleNewTriggers(space, triggers.objects, registered);
|
|
999
|
-
});
|
|
1000
|
-
this._ctx.onDispose(functionsSubscription);
|
|
1001
597
|
}
|
|
598
|
+
}
|
|
599
|
+
ctx.onDispose(() => {
|
|
600
|
+
ws?.close();
|
|
1002
601
|
});
|
|
1003
|
-
this._ctx.onDispose(() => spaceListSubscription.unsubscribe());
|
|
1004
|
-
}
|
|
1005
|
-
async _close(_) {
|
|
1006
|
-
this._triggersBySpaceKey.clear();
|
|
1007
602
|
}
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
603
|
+
/**
|
|
604
|
+
* ECHO subscription.
|
|
605
|
+
*/
|
|
606
|
+
async _createSubscription(ctx, space, def, trigger) {
|
|
607
|
+
import_log3.log.info("subscription", {
|
|
608
|
+
space: space.key,
|
|
609
|
+
trigger
|
|
610
|
+
}, {
|
|
611
|
+
F: __dxlog_file3,
|
|
612
|
+
L: 271,
|
|
613
|
+
S: this,
|
|
614
|
+
C: (f, a) => f(...a)
|
|
1011
615
|
});
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
616
|
+
const objectIds = /* @__PURE__ */ new Set();
|
|
617
|
+
const task = new import_async2.DeferredTask(ctx, async () => {
|
|
618
|
+
await this._execFunction(def, {
|
|
619
|
+
space: space.key,
|
|
620
|
+
objects: Array.from(objectIds)
|
|
621
|
+
});
|
|
622
|
+
});
|
|
623
|
+
const subscriptions = [];
|
|
624
|
+
const subscription = (0, import_echo.createSubscription)(({ added, updated }) => {
|
|
625
|
+
import_log3.log.info("updated", {
|
|
626
|
+
added: added.length,
|
|
627
|
+
updated: updated.length
|
|
628
|
+
}, {
|
|
629
|
+
F: __dxlog_file3,
|
|
630
|
+
L: 281,
|
|
1023
631
|
S: this,
|
|
1024
632
|
C: (f, a) => f(...a)
|
|
1025
633
|
});
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
triggers: newTriggers
|
|
1029
|
-
});
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
async _handleRemovedTriggers(space, allTriggers, registered) {
|
|
1033
|
-
const removed = [];
|
|
1034
|
-
for (let i = registered.length - 1; i >= 0; i--) {
|
|
1035
|
-
const wasRemoved = allTriggers.find((trigger) => trigger.id === registered[i].trigger.id) == null;
|
|
1036
|
-
if (wasRemoved) {
|
|
1037
|
-
const unregistered = registered.splice(i, 1)[0];
|
|
1038
|
-
await unregistered.activationCtx?.dispose();
|
|
1039
|
-
removed.push(unregistered.trigger);
|
|
634
|
+
for (const object of added) {
|
|
635
|
+
objectIds.add(object.id);
|
|
1040
636
|
}
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
637
|
+
for (const object of updated) {
|
|
638
|
+
objectIds.add(object.id);
|
|
639
|
+
}
|
|
640
|
+
task.schedule();
|
|
641
|
+
});
|
|
642
|
+
subscriptions.push(() => subscription.unsubscribe());
|
|
643
|
+
const { filter, options: { deep, delay } = {} } = trigger;
|
|
644
|
+
const update = ({ objects }) => {
|
|
645
|
+
subscription.update(objects);
|
|
646
|
+
if (deep) {
|
|
647
|
+
import_log3.log.info("update", {
|
|
648
|
+
objects: objects.length
|
|
649
|
+
}, {
|
|
650
|
+
F: __dxlog_file3,
|
|
651
|
+
L: 301,
|
|
652
|
+
S: this,
|
|
653
|
+
C: (f, a) => f(...a)
|
|
654
|
+
});
|
|
655
|
+
for (const object of objects) {
|
|
656
|
+
const content = object.content;
|
|
657
|
+
if (content instanceof import_types.TextV0Type) {
|
|
658
|
+
subscriptions.push((0, import_echo.getAutomergeObjectCore)(content).updates.on((0, import_async2.debounce)(() => subscription.update([
|
|
659
|
+
object
|
|
660
|
+
]), 1e3)));
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
const query = space.db.query(import_echo.Filter.or(filter.map(({ type, props }) => import_echo.Filter.typename(type, props))));
|
|
666
|
+
subscriptions.push(query.subscribe(delay ? (0, import_async2.debounce)(update, delay) : update));
|
|
667
|
+
ctx.onDispose(() => {
|
|
668
|
+
subscriptions.forEach((unsubscribe) => unsubscribe());
|
|
669
|
+
});
|
|
1052
670
|
}
|
|
1053
671
|
};
|
|
672
|
+
var TimerTriggerSchema = S.struct({
|
|
673
|
+
cron: S.string
|
|
674
|
+
});
|
|
675
|
+
var WebhookTriggerSchema = S.struct({
|
|
676
|
+
port: S.number
|
|
677
|
+
});
|
|
678
|
+
var WebsocketTriggerSchema = S.struct({
|
|
679
|
+
url: S.string,
|
|
680
|
+
init: S.optional(S.record(S.string, S.any))
|
|
681
|
+
});
|
|
682
|
+
var SubscriptionTriggerSchema = S.struct({
|
|
683
|
+
spaceKey: S.optional(S.string),
|
|
684
|
+
// TODO(burdon): Define query DSL.
|
|
685
|
+
filter: S.array(S.struct({
|
|
686
|
+
type: S.string,
|
|
687
|
+
props: S.optional(S.record(S.string, S.any))
|
|
688
|
+
})),
|
|
689
|
+
options: S.optional(S.struct({
|
|
690
|
+
// Watch changes to object (not just creation).
|
|
691
|
+
deep: S.optional(S.boolean),
|
|
692
|
+
// Debounce changes (delay in ms).
|
|
693
|
+
delay: S.optional(S.number)
|
|
694
|
+
}))
|
|
695
|
+
});
|
|
696
|
+
var FunctionTriggerSchema = S.struct({
|
|
697
|
+
function: S.string.pipe(S.description("Function ID/URI.")),
|
|
698
|
+
timer: S.optional(TimerTriggerSchema),
|
|
699
|
+
webhook: S.optional(WebhookTriggerSchema),
|
|
700
|
+
websocket: S.optional(WebsocketTriggerSchema),
|
|
701
|
+
subscription: S.optional(SubscriptionTriggerSchema)
|
|
702
|
+
});
|
|
703
|
+
var FunctionDefSchema = S.struct({
|
|
704
|
+
id: S.string,
|
|
705
|
+
description: S.optional(S.string),
|
|
706
|
+
name: S.string,
|
|
707
|
+
// TODO(burdon): NPM/GitHub URL?
|
|
708
|
+
handler: S.string
|
|
709
|
+
});
|
|
710
|
+
var FunctionManifestSchema = S.struct({
|
|
711
|
+
functions: S.mutable(S.array(FunctionDefSchema)),
|
|
712
|
+
triggers: S.mutable(S.array(FunctionTriggerSchema))
|
|
713
|
+
});
|
|
1054
714
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1055
715
|
0 && (module.exports = {
|
|
1056
716
|
DevServer,
|
|
1057
|
-
FunctionDef,
|
|
1058
717
|
FunctionManifestSchema,
|
|
1059
|
-
FunctionRegistry,
|
|
1060
|
-
FunctionTrigger,
|
|
1061
718
|
Scheduler,
|
|
1062
|
-
TriggerRegistry,
|
|
1063
719
|
subscriptionHandler
|
|
1064
720
|
});
|
|
1065
721
|
//# sourceMappingURL=index.cjs.map
|