@dxos/functions-runtime-cloudflare 0.8.4-main.70d3990 → 0.8.4-main.765dc60934

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +1 -1
  3. package/dist/lib/browser/index.mjs +741 -251
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/node-esm/index.mjs +741 -251
  7. package/dist/lib/node-esm/index.mjs.map +4 -4
  8. package/dist/lib/node-esm/meta.json +1 -1
  9. package/dist/types/src/functions-client.d.ts +1 -5
  10. package/dist/types/src/functions-client.d.ts.map +1 -1
  11. package/dist/types/src/index.d.ts +2 -0
  12. package/dist/types/src/index.d.ts.map +1 -1
  13. package/dist/types/src/internal/data-service-impl.d.ts +8 -7
  14. package/dist/types/src/internal/data-service-impl.d.ts.map +1 -1
  15. package/dist/types/src/internal/query-service-impl.d.ts +4 -9
  16. package/dist/types/src/internal/query-service-impl.d.ts.map +1 -1
  17. package/dist/types/src/internal/queue-service-impl.d.ts +8 -9
  18. package/dist/types/src/internal/queue-service-impl.d.ts.map +1 -1
  19. package/dist/types/src/internal/service-container.d.ts +9 -9
  20. package/dist/types/src/internal/service-container.d.ts.map +1 -1
  21. package/dist/types/src/internal/utils.d.ts +2 -0
  22. package/dist/types/src/internal/utils.d.ts.map +1 -0
  23. package/dist/types/src/logger.d.ts +2 -0
  24. package/dist/types/src/logger.d.ts.map +1 -0
  25. package/dist/types/src/queues-api.d.ts +10 -6
  26. package/dist/types/src/queues-api.d.ts.map +1 -1
  27. package/dist/types/src/space-proxy.d.ts +3 -2
  28. package/dist/types/src/space-proxy.d.ts.map +1 -1
  29. package/dist/types/src/wrap-handler-for-cloudflare.d.ts +6 -0
  30. package/dist/types/src/wrap-handler-for-cloudflare.d.ts.map +1 -1
  31. package/dist/types/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +21 -16
  33. package/src/functions-client.ts +9 -8
  34. package/src/index.ts +2 -0
  35. package/src/internal/data-service-impl.ts +73 -18
  36. package/src/internal/query-service-impl.ts +23 -61
  37. package/src/internal/queue-service-impl.ts +54 -11
  38. package/src/internal/service-container.ts +50 -12
  39. package/src/internal/utils.ts +5 -0
  40. package/src/logger.ts +44 -0
  41. package/src/queues-api.ts +26 -7
  42. package/src/space-proxy.ts +5 -4
  43. package/src/wrap-handler-for-cloudflare.ts +4 -4
  44. package/dist/types/src/internal/adapter.d.ts +0 -12
  45. package/dist/types/src/internal/adapter.d.ts.map +0 -1
  46. package/src/internal/adapter.ts +0 -48
@@ -1,12 +1,88 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
+ // src/functions-client.ts
4
+ import { Resource as Resource2 } from "@dxos/context";
5
+ import { EchoClient } from "@dxos/echo-db";
6
+ import { invariant as invariant3 } from "@dxos/invariant";
7
+
3
8
  // src/internal/data-service-impl.ts
4
9
  import { Stream } from "@dxos/codec-protobuf/stream";
5
10
  import { raise } from "@dxos/debug";
11
+ import { NotImplementedError, RuntimeServiceError } from "@dxos/errors";
6
12
  import { invariant } from "@dxos/invariant";
7
13
  import { SpaceId } from "@dxos/keys";
8
14
  import { log } from "@dxos/log";
9
- var __dxlog_file = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/data-service-impl.ts";
15
+
16
+ // src/internal/utils.ts
17
+ var copyUint8Array = (value) => new Uint8Array(value);
18
+
19
+ // src/internal/data-service-impl.ts
20
+ var __dxlog_file = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/internal/data-service-impl.ts";
21
+ function _ts_add_disposable_resource(env, value, async) {
22
+ if (value !== null && value !== void 0) {
23
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
24
+ var dispose, inner;
25
+ if (async) {
26
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
27
+ dispose = value[Symbol.asyncDispose];
28
+ }
29
+ if (dispose === void 0) {
30
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
31
+ dispose = value[Symbol.dispose];
32
+ if (async) inner = dispose;
33
+ }
34
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
35
+ if (inner) dispose = function() {
36
+ try {
37
+ inner.call(this);
38
+ } catch (e) {
39
+ return Promise.reject(e);
40
+ }
41
+ };
42
+ env.stack.push({
43
+ value,
44
+ dispose,
45
+ async
46
+ });
47
+ } else if (async) {
48
+ env.stack.push({
49
+ async: true
50
+ });
51
+ }
52
+ return value;
53
+ }
54
+ function _ts_dispose_resources(env) {
55
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
56
+ var e = new Error(message);
57
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
58
+ };
59
+ return (_ts_dispose_resources = function _ts_dispose_resources5(env2) {
60
+ function fail(e) {
61
+ env2.error = env2.hasError ? new _SuppressedError(e, env2.error, "An error was suppressed during disposal.") : e;
62
+ env2.hasError = true;
63
+ }
64
+ var r, s = 0;
65
+ function next() {
66
+ while (r = env2.stack.pop()) {
67
+ try {
68
+ if (!r.async && s === 1) return s = 0, env2.stack.push(r), Promise.resolve().then(next);
69
+ if (r.dispose) {
70
+ var result = r.dispose.call(r.value);
71
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
72
+ fail(e);
73
+ return next();
74
+ });
75
+ } else s |= 1;
76
+ } catch (e) {
77
+ fail(e);
78
+ }
79
+ }
80
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
81
+ if (env2.hasError) throw env2.error;
82
+ }
83
+ return next();
84
+ })(env);
85
+ }
10
86
  var DataServiceImpl = class {
11
87
  _executionContext;
12
88
  _dataService;
@@ -17,15 +93,7 @@ var DataServiceImpl = class {
17
93
  }
18
94
  subscribe({ subscriptionId, spaceId }) {
19
95
  return new Stream(({ next }) => {
20
- invariant(SpaceId.isValid(spaceId), void 0, {
21
- F: __dxlog_file,
22
- L: 34,
23
- S: this,
24
- A: [
25
- "SpaceId.isValid(spaceId)",
26
- ""
27
- ]
28
- });
96
+ invariant(SpaceId.isValid(spaceId), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 86, S: this, A: ["SpaceId.isValid(spaceId)", ""] });
29
97
  this.dataSubscriptions.set(subscriptionId, {
30
98
  spaceId,
31
99
  next
@@ -35,158 +103,199 @@ var DataServiceImpl = class {
35
103
  };
36
104
  });
37
105
  }
38
- async updateSubscription({ subscriptionId, addIds, removeIds }) {
39
- const sub = this.dataSubscriptions.get(subscriptionId) ?? raise(new Error("Subscription not found"));
106
+ async updateSubscription({ subscriptionId, addIds }) {
107
+ const sub = this.dataSubscriptions.get(subscriptionId) ?? raise(new RuntimeServiceError({
108
+ message: "Subscription not found.",
109
+ context: {
110
+ subscriptionId
111
+ }
112
+ }));
40
113
  if (addIds) {
41
114
  log.info("request documents", {
42
115
  count: addIds.length
43
- }, {
44
- F: __dxlog_file,
45
- L: 47,
46
- S: this,
47
- C: (f, a) => f(...a)
48
- });
116
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 104, S: this });
49
117
  for (const documentId of addIds) {
50
- const document = await this._dataService.getDocument(this._executionContext, sub.spaceId, documentId);
51
- log.info("document loaded", {
52
- documentId,
53
- spaceId: sub.spaceId,
54
- found: !!document
55
- }, {
56
- F: __dxlog_file,
57
- L: 51,
58
- S: this,
59
- C: (f, a) => f(...a)
60
- });
61
- if (!document) {
62
- log.warn("not found", {
63
- documentId
64
- }, {
65
- F: __dxlog_file,
66
- L: 53,
67
- S: this,
68
- C: (f, a) => f(...a)
118
+ const env = {
119
+ stack: [],
120
+ error: void 0,
121
+ hasError: false
122
+ };
123
+ try {
124
+ const document = _ts_add_disposable_resource(env, await this._dataService.getDocument(this._executionContext, sub.spaceId, documentId), false);
125
+ log.info("document loaded", {
126
+ documentId,
127
+ spaceId: sub.spaceId,
128
+ found: !!document
129
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 116, S: this });
130
+ if (!document) {
131
+ log.warn("not found", {
132
+ documentId
133
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 122, S: this });
134
+ continue;
135
+ }
136
+ sub.next({
137
+ updates: [
138
+ {
139
+ documentId,
140
+ // Copy returned object to avoid hanging RPC stub
141
+ // See https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/
142
+ mutation: copyUint8Array(document.data)
143
+ }
144
+ ]
69
145
  });
70
- continue;
146
+ } catch (e) {
147
+ env.error = e;
148
+ env.hasError = true;
149
+ } finally {
150
+ _ts_dispose_resources(env);
71
151
  }
72
- sub.next({
73
- updates: [
74
- {
75
- documentId,
76
- mutation: document.data
77
- }
78
- ]
79
- });
80
152
  }
81
153
  }
82
154
  }
155
+ async createDocument({ spaceId, initialValue }) {
156
+ const env = {
157
+ stack: [],
158
+ error: void 0,
159
+ hasError: false
160
+ };
161
+ try {
162
+ invariant(SpaceId.isValid(spaceId), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 153, S: this, A: ["SpaceId.isValid(spaceId)", ""] });
163
+ const response = _ts_add_disposable_resource(env, await this._dataService.createDocument(this._executionContext, spaceId, initialValue), false);
164
+ return {
165
+ documentId: response.documentId
166
+ };
167
+ } catch (e) {
168
+ env.error = e;
169
+ env.hasError = true;
170
+ } finally {
171
+ _ts_dispose_resources(env);
172
+ }
173
+ }
83
174
  async update({ updates, subscriptionId }) {
84
- const sub = this.dataSubscriptions.get(subscriptionId) ?? raise(new Error("Subscription not found"));
85
- for (const update of updates ?? []) {
86
- await this._dataService.changeDocument(this._executionContext, sub.spaceId, update.documentId, update.mutation);
175
+ const sub = this.dataSubscriptions.get(subscriptionId) ?? raise(new RuntimeServiceError({
176
+ message: "Subscription not found.",
177
+ context: {
178
+ subscriptionId
179
+ }
180
+ }));
181
+ try {
182
+ for (const update of updates ?? []) {
183
+ if (!update.mutation) {
184
+ continue;
185
+ }
186
+ await this._dataService.changeDocument(this._executionContext, sub.spaceId, update.documentId, update.mutation);
187
+ }
188
+ } catch (error) {
189
+ throw RuntimeServiceError.wrap({
190
+ message: "Failed to apply document updates.",
191
+ context: {
192
+ subscriptionId
193
+ },
194
+ ifTypeDiffers: true
195
+ })(error);
87
196
  }
88
- throw new Error("Method not implemented.");
89
197
  }
90
198
  async flush() {
91
199
  }
92
- subscribeSpaceSyncState(request, options) {
93
- throw new Error("Method not implemented.");
200
+ subscribeSpaceSyncState(_request, _options) {
201
+ throw new NotImplementedError({
202
+ message: "subscribeSpaceSyncState is not implemented."
203
+ });
94
204
  }
95
- async getDocumentHeads({ documentIds }) {
96
- throw new Error("Method not implemented.");
205
+ async getDocumentHeads({ documentIds: _documentIds }) {
206
+ throw new NotImplementedError({
207
+ message: "getDocumentHeads is not implemented."
208
+ });
97
209
  }
98
- async reIndexHeads({ documentIds }) {
99
- throw new Error("Method not implemented.");
210
+ async reIndexHeads({ documentIds: _documentIds }) {
211
+ throw new NotImplementedError({
212
+ message: "reIndexHeads is not implemented."
213
+ });
100
214
  }
101
215
  async updateIndexes() {
102
- throw new Error("Method not implemented.");
216
+ log.verbose("updateIndexes called, but it is a no-op in EDGE env.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 211, S: this });
103
217
  }
104
- async waitUntilHeadsReplicated({ heads }) {
105
- throw new Error("Method not implemented.");
218
+ async waitUntilHeadsReplicated({ heads: _heads }) {
219
+ throw new NotImplementedError({
220
+ message: "waitUntilHeadsReplicated is not implemented."
221
+ });
106
222
  }
107
223
  };
108
224
 
109
225
  // src/internal/query-service-impl.ts
110
- import * as Schema from "effect/Schema";
111
226
  import { Stream as Stream2 } from "@dxos/codec-protobuf/stream";
112
- import { QueryAST } from "@dxos/echo-protocol";
113
- import { invariant as invariant3 } from "@dxos/invariant";
114
- import { PublicKey } from "@dxos/keys";
115
- import { SpaceId as SpaceId3 } from "@dxos/keys";
227
+ import { NotImplementedError as NotImplementedError2, RuntimeServiceError as RuntimeServiceError2 } from "@dxos/errors";
116
228
  import { log as log2 } from "@dxos/log";
117
-
118
- // src/internal/adapter.ts
119
- import { failUndefined } from "@dxos/debug";
120
- import { invariant as invariant2 } from "@dxos/invariant";
121
- import { SpaceId as SpaceId2 } from "@dxos/keys";
122
- var __dxlog_file2 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/adapter.ts";
123
- var queryToDataServiceRequest = (query) => {
124
- const { filter, options } = isSimpleSelectionQuery(query) ?? failUndefined();
125
- invariant2(options?.spaceIds?.length === 1, "Only one space is supported", {
126
- F: __dxlog_file2,
127
- L: 13,
128
- S: void 0,
129
- A: [
130
- "options?.spaceIds?.length === 1",
131
- "'Only one space is supported'"
132
- ]
133
- });
134
- invariant2(filter.type === "object", "Only object filters are supported", {
135
- F: __dxlog_file2,
136
- L: 14,
137
- S: void 0,
138
- A: [
139
- "filter.type === 'object'",
140
- "'Only object filters are supported'"
141
- ]
142
- });
143
- const spaceId = options.spaceIds[0];
144
- invariant2(SpaceId2.isValid(spaceId), void 0, {
145
- F: __dxlog_file2,
146
- L: 17,
147
- S: void 0,
148
- A: [
149
- "SpaceId.isValid(spaceId)",
150
- ""
151
- ]
152
- });
153
- return {
154
- spaceId,
155
- type: filter.typename ?? void 0,
156
- objectIds: [
157
- ...filter.id ?? []
158
- ]
159
- };
160
- };
161
- var isSimpleSelectionQuery = (query) => {
162
- switch (query.type) {
163
- case "options": {
164
- const maybeFilter = isSimpleSelectionQuery(query.query);
165
- if (!maybeFilter) {
166
- return null;
167
- }
168
- return {
169
- filter: maybeFilter.filter,
170
- options: query.options
171
- };
229
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/internal/query-service-impl.ts";
230
+ function _ts_add_disposable_resource2(env, value, async) {
231
+ if (value !== null && value !== void 0) {
232
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
233
+ var dispose, inner;
234
+ if (async) {
235
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
236
+ dispose = value[Symbol.asyncDispose];
172
237
  }
173
- case "select": {
174
- return {
175
- filter: query.filter,
176
- options: void 0
177
- };
178
- }
179
- default: {
180
- return null;
238
+ if (dispose === void 0) {
239
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
240
+ dispose = value[Symbol.dispose];
241
+ if (async) inner = dispose;
181
242
  }
243
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
244
+ if (inner) dispose = function() {
245
+ try {
246
+ inner.call(this);
247
+ } catch (e) {
248
+ return Promise.reject(e);
249
+ }
250
+ };
251
+ env.stack.push({
252
+ value,
253
+ dispose,
254
+ async
255
+ });
256
+ } else if (async) {
257
+ env.stack.push({
258
+ async: true
259
+ });
182
260
  }
183
- };
184
-
185
- // src/internal/query-service-impl.ts
186
- var __dxlog_file3 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/query-service-impl.ts";
261
+ return value;
262
+ }
263
+ function _ts_dispose_resources2(env) {
264
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
265
+ var e = new Error(message);
266
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
267
+ };
268
+ return (_ts_dispose_resources2 = function _ts_dispose_resources5(env2) {
269
+ function fail(e) {
270
+ env2.error = env2.hasError ? new _SuppressedError(e, env2.error, "An error was suppressed during disposal.") : e;
271
+ env2.hasError = true;
272
+ }
273
+ var r, s = 0;
274
+ function next() {
275
+ while (r = env2.stack.pop()) {
276
+ try {
277
+ if (!r.async && s === 1) return s = 0, env2.stack.push(r), Promise.resolve().then(next);
278
+ if (r.dispose) {
279
+ var result = r.dispose.call(r.value);
280
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
281
+ fail(e);
282
+ return next();
283
+ });
284
+ } else s |= 1;
285
+ } catch (e) {
286
+ fail(e);
287
+ }
288
+ }
289
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
290
+ if (env2.hasError) throw env2.error;
291
+ }
292
+ return next();
293
+ })(env);
294
+ }
187
295
  var QueryServiceImpl = class {
188
296
  _executionContext;
189
297
  _dataService;
298
+ _queryCount = 0;
190
299
  constructor(_executionContext, _dataService) {
191
300
  this._executionContext = _executionContext;
192
301
  this._dataService = _dataService;
@@ -194,93 +303,123 @@ var QueryServiceImpl = class {
194
303
  execQuery(request) {
195
304
  log2.info("execQuery", {
196
305
  request
197
- }, {
198
- F: __dxlog_file3,
199
- L: 30,
200
- S: this,
201
- C: (f, a) => f(...a)
202
- });
203
- const query = QueryAST.Query.pipe(Schema.decodeUnknownSync)(JSON.parse(request.query));
204
- const requestedSpaceIds = getTargetSpacesForQuery(query);
205
- invariant3(requestedSpaceIds.length === 1, "Only one space is supported", {
206
- F: __dxlog_file3,
207
- L: 33,
208
- S: this,
209
- A: [
210
- "requestedSpaceIds.length === 1",
211
- "'Only one space is supported'"
212
- ]
213
- });
214
- const spaceId = requestedSpaceIds[0];
306
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 81, S: this });
215
307
  return Stream2.fromPromise((async () => {
216
308
  try {
217
- log2.info("begin query", {
218
- spaceId
219
- }, {
220
- F: __dxlog_file3,
221
- L: 39,
222
- S: this,
223
- C: (f, a) => f(...a)
224
- });
225
- const queryResponse = await this._dataService.queryDocuments(this._executionContext, queryToDataServiceRequest(query));
226
- log2.info("query response", {
227
- spaceId,
228
- filter: request.filter,
229
- resultCount: queryResponse.results.length
230
- }, {
231
- F: __dxlog_file3,
232
- L: 44,
233
- S: this,
234
- C: (f, a) => f(...a)
235
- });
236
- return {
237
- results: queryResponse.results.map((object) => ({
238
- id: object.objectId,
239
- spaceId,
240
- spaceKey: PublicKey.ZERO,
241
- documentId: object.document.documentId,
242
- rank: 0,
243
- documentAutomerge: object.document.data
244
- }))
309
+ const env = {
310
+ stack: [],
311
+ error: void 0,
312
+ hasError: false
245
313
  };
246
- } catch (err) {
314
+ try {
315
+ this._queryCount++;
316
+ log2.info("begin query", {
317
+ request
318
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 93, S: this });
319
+ const queryResponse = _ts_add_disposable_resource2(env, await this._dataService.execQuery(this._executionContext, request), false);
320
+ log2.info("query response", {
321
+ resultCount: queryResponse.results?.length
322
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 97, S: this });
323
+ return structuredClone(queryResponse);
324
+ } catch (e) {
325
+ env.error = e;
326
+ env.hasError = true;
327
+ } finally {
328
+ _ts_dispose_resources2(env);
329
+ }
330
+ } catch (error) {
247
331
  log2.error("query failed", {
248
- err
249
- }, {
250
- F: __dxlog_file3,
251
- L: 58,
252
- S: this,
253
- C: (f, a) => f(...a)
332
+ err: error
333
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 108, S: this });
334
+ throw new RuntimeServiceError2({
335
+ message: `Query execution failed (queryCount=${this._queryCount})`,
336
+ context: {
337
+ queryCount: this._queryCount
338
+ },
339
+ cause: error
254
340
  });
255
- throw err;
256
341
  }
257
342
  })());
258
343
  }
259
344
  async reindex() {
260
- throw new Error("Method not implemented.");
345
+ throw new NotImplementedError2({
346
+ message: "Reindex is not implemented."
347
+ });
261
348
  }
262
349
  async setConfig() {
263
- throw new Error("Method not implemented.");
350
+ throw new NotImplementedError2({
351
+ message: "SetConfig is not implemented."
352
+ });
264
353
  }
265
354
  };
266
- var getTargetSpacesForQuery = (query) => {
267
- const spaces = /* @__PURE__ */ new Set();
268
- const visitor = (node) => {
269
- if (node.type === "options") {
270
- if (node.options.spaceIds) {
271
- for (const spaceId of node.options.spaceIds) {
272
- spaces.add(SpaceId3.make(spaceId));
355
+
356
+ // src/internal/queue-service-impl.ts
357
+ import { RuntimeServiceError as RuntimeServiceError3 } from "@dxos/errors";
358
+ function _ts_add_disposable_resource3(env, value, async) {
359
+ if (value !== null && value !== void 0) {
360
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
361
+ var dispose, inner;
362
+ if (async) {
363
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
364
+ dispose = value[Symbol.asyncDispose];
365
+ }
366
+ if (dispose === void 0) {
367
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
368
+ dispose = value[Symbol.dispose];
369
+ if (async) inner = dispose;
370
+ }
371
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
372
+ if (inner) dispose = function() {
373
+ try {
374
+ inner.call(this);
375
+ } catch (e) {
376
+ return Promise.reject(e);
377
+ }
378
+ };
379
+ env.stack.push({
380
+ value,
381
+ dispose,
382
+ async
383
+ });
384
+ } else if (async) {
385
+ env.stack.push({
386
+ async: true
387
+ });
388
+ }
389
+ return value;
390
+ }
391
+ function _ts_dispose_resources3(env) {
392
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
393
+ var e = new Error(message);
394
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
395
+ };
396
+ return (_ts_dispose_resources3 = function _ts_dispose_resources5(env2) {
397
+ function fail(e) {
398
+ env2.error = env2.hasError ? new _SuppressedError(e, env2.error, "An error was suppressed during disposal.") : e;
399
+ env2.hasError = true;
400
+ }
401
+ var r, s = 0;
402
+ function next() {
403
+ while (r = env2.stack.pop()) {
404
+ try {
405
+ if (!r.async && s === 1) return s = 0, env2.stack.push(r), Promise.resolve().then(next);
406
+ if (r.dispose) {
407
+ var result = r.dispose.call(r.value);
408
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
409
+ fail(e);
410
+ return next();
411
+ });
412
+ } else s |= 1;
413
+ } catch (e) {
414
+ fail(e);
273
415
  }
274
416
  }
417
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
418
+ if (env2.hasError) throw env2.error;
275
419
  }
276
- };
277
- QueryAST.visit(query, visitor);
278
- return [
279
- ...spaces
280
- ];
281
- };
282
-
283
- // src/internal/queue-service-impl.ts
420
+ return next();
421
+ })(env);
422
+ }
284
423
  var QueueServiceImpl = class {
285
424
  _ctx;
286
425
  _queueService;
@@ -288,29 +427,194 @@ var QueueServiceImpl = class {
288
427
  this._ctx = _ctx;
289
428
  this._queueService = _queueService;
290
429
  }
291
- queryQueue(subspaceTag, spaceId, { queueId, ...query }) {
292
- return this._queueService.query(this._ctx, `dxn:queue:${subspaceTag}:${spaceId}:${queueId}`, query);
430
+ async queryQueue(request) {
431
+ try {
432
+ const env = {
433
+ stack: [],
434
+ error: void 0,
435
+ hasError: false
436
+ };
437
+ try {
438
+ const result = _ts_add_disposable_resource3(env, await this._queueService.queryQueue(this._ctx, request), false);
439
+ return {
440
+ objects: structuredClone(result.objects),
441
+ nextCursor: result.nextCursor,
442
+ prevCursor: result.prevCursor
443
+ };
444
+ } catch (e) {
445
+ env.error = e;
446
+ env.hasError = true;
447
+ } finally {
448
+ _ts_dispose_resources3(env);
449
+ }
450
+ } catch (error) {
451
+ const { query } = request;
452
+ throw RuntimeServiceError3.wrap({
453
+ message: "Queue query failed.",
454
+ context: {
455
+ subspaceTag: query?.queuesNamespace,
456
+ spaceId: query?.spaceId,
457
+ queueId: query?.queueIds?.[0]
458
+ },
459
+ ifTypeDiffers: true
460
+ })(error);
461
+ }
293
462
  }
294
- insertIntoQueue(subspaceTag, spaceId, queueId, objects) {
295
- return this._queueService.append(this._ctx, `dxn:queue:${subspaceTag}:${spaceId}:${queueId}`, objects);
463
+ async insertIntoQueue(request) {
464
+ try {
465
+ const env = {
466
+ stack: [],
467
+ error: void 0,
468
+ hasError: false
469
+ };
470
+ try {
471
+ const _ = _ts_add_disposable_resource3(env, await this._queueService.insertIntoQueue(this._ctx, request), false);
472
+ } catch (e) {
473
+ env.error = e;
474
+ env.hasError = true;
475
+ } finally {
476
+ _ts_dispose_resources3(env);
477
+ }
478
+ } catch (error) {
479
+ const { subspaceTag, spaceId, queueId } = request;
480
+ throw RuntimeServiceError3.wrap({
481
+ message: "Queue append failed.",
482
+ context: {
483
+ subspaceTag,
484
+ spaceId,
485
+ queueId
486
+ },
487
+ ifTypeDiffers: true
488
+ })(error);
489
+ }
490
+ }
491
+ async deleteFromQueue(request) {
492
+ try {
493
+ const env = {
494
+ stack: [],
495
+ error: void 0,
496
+ hasError: false
497
+ };
498
+ try {
499
+ const _ = _ts_add_disposable_resource3(env, await this._queueService.deleteFromQueue(this._ctx, request), false);
500
+ } catch (e) {
501
+ env.error = e;
502
+ env.hasError = true;
503
+ } finally {
504
+ _ts_dispose_resources3(env);
505
+ }
506
+ } catch (error) {
507
+ const { subspaceTag, spaceId, queueId } = request;
508
+ throw RuntimeServiceError3.wrap({
509
+ message: "Queue delete failed.",
510
+ context: {
511
+ subspaceTag,
512
+ spaceId,
513
+ queueId
514
+ },
515
+ ifTypeDiffers: true
516
+ })(error);
517
+ }
296
518
  }
297
- deleteFromQueue(subspaceTag, spaceId, queueId, objectIds) {
298
- throw new Error("Deleting from queue is not supported.");
519
+ async syncQueue(_) {
299
520
  }
300
521
  };
301
522
 
302
523
  // src/internal/service-container.ts
524
+ function _ts_add_disposable_resource4(env, value, async) {
525
+ if (value !== null && value !== void 0) {
526
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
527
+ var dispose, inner;
528
+ if (async) {
529
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
530
+ dispose = value[Symbol.asyncDispose];
531
+ }
532
+ if (dispose === void 0) {
533
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
534
+ dispose = value[Symbol.dispose];
535
+ if (async) inner = dispose;
536
+ }
537
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
538
+ if (inner) dispose = function() {
539
+ try {
540
+ inner.call(this);
541
+ } catch (e) {
542
+ return Promise.reject(e);
543
+ }
544
+ };
545
+ env.stack.push({
546
+ value,
547
+ dispose,
548
+ async
549
+ });
550
+ } else if (async) {
551
+ env.stack.push({
552
+ async: true
553
+ });
554
+ }
555
+ return value;
556
+ }
557
+ function _ts_dispose_resources4(env) {
558
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
559
+ var e = new Error(message);
560
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
561
+ };
562
+ return (_ts_dispose_resources4 = function _ts_dispose_resources5(env2) {
563
+ function fail(e) {
564
+ env2.error = env2.hasError ? new _SuppressedError(e, env2.error, "An error was suppressed during disposal.") : e;
565
+ env2.hasError = true;
566
+ }
567
+ var r, s = 0;
568
+ function next() {
569
+ while (r = env2.stack.pop()) {
570
+ try {
571
+ if (!r.async && s === 1) return s = 0, env2.stack.push(r), Promise.resolve().then(next);
572
+ if (r.dispose) {
573
+ var result = r.dispose.call(r.value);
574
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
575
+ fail(e);
576
+ return next();
577
+ });
578
+ } else s |= 1;
579
+ } catch (e) {
580
+ fail(e);
581
+ }
582
+ }
583
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
584
+ if (env2.hasError) throw env2.error;
585
+ }
586
+ return next();
587
+ })(env);
588
+ }
303
589
  var ServiceContainer = class {
304
590
  _executionContext;
305
591
  _dataService;
306
592
  _queueService;
307
- constructor(_executionContext, _dataService, _queueService) {
593
+ _functionsService;
594
+ constructor(_executionContext, _dataService, _queueService, _functionsService) {
308
595
  this._executionContext = _executionContext;
309
596
  this._dataService = _dataService;
310
597
  this._queueService = _queueService;
598
+ this._functionsService = _functionsService;
311
599
  }
312
600
  async getSpaceMeta(spaceId) {
313
- return this._dataService.getSpaceMeta(this._executionContext, spaceId);
601
+ const env = {
602
+ stack: [],
603
+ error: void 0,
604
+ hasError: false
605
+ };
606
+ try {
607
+ const result = _ts_add_disposable_resource4(env, await this._dataService.getSpaceMeta(this._executionContext, spaceId), false);
608
+ return result ? {
609
+ spaceKey: result.spaceKey,
610
+ rootDocumentId: result.rootDocumentId
611
+ } : void 0;
612
+ } catch (e) {
613
+ env.error = e;
614
+ env.hasError = true;
615
+ } finally {
616
+ _ts_dispose_resources4(env);
617
+ }
314
618
  }
315
619
  async createServices() {
316
620
  const dataService = new DataServiceImpl(this._executionContext, this._dataService);
@@ -319,17 +623,185 @@ var ServiceContainer = class {
319
623
  return {
320
624
  dataService,
321
625
  queryService,
322
- queueService
626
+ queueService,
627
+ functionsAiService: this._functionsService
628
+ };
629
+ }
630
+ async queryQueue(queue) {
631
+ const parts = queue.asQueueDXN();
632
+ if (!parts) {
633
+ throw new Error("Invalid queue DXN");
634
+ }
635
+ const { subspaceTag, spaceId, queueId } = parts;
636
+ const result = await this._queueService.queryQueue(this._executionContext, {
637
+ query: {
638
+ spaceId,
639
+ queuesNamespace: subspaceTag,
640
+ queueIds: [
641
+ queueId
642
+ ]
643
+ }
644
+ });
645
+ return {
646
+ objects: structuredClone(result.objects),
647
+ nextCursor: result.nextCursor ?? null,
648
+ prevCursor: result.prevCursor ?? null
323
649
  };
324
650
  }
325
- queryQueue(queue) {
326
- return this._queueService.query({}, queue.toString(), {});
651
+ async insertIntoQueue(queue, objects) {
652
+ const parts = queue.asQueueDXN();
653
+ if (!parts) {
654
+ throw new Error("Invalid queue DXN");
655
+ }
656
+ const { subspaceTag, spaceId, queueId } = parts;
657
+ await this._queueService.insertIntoQueue(this._executionContext, {
658
+ subspaceTag,
659
+ spaceId,
660
+ queueId,
661
+ objects: objects.map((obj) => JSON.stringify(obj))
662
+ });
663
+ }
664
+ };
665
+
666
+ // src/space-proxy.ts
667
+ import { Resource } from "@dxos/context";
668
+ import { invariant as invariant2 } from "@dxos/invariant";
669
+ import { PublicKey } from "@dxos/keys";
670
+
671
+ // src/queues-api.ts
672
+ import { log as log3 } from "@dxos/log";
673
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/queues-api.ts";
674
+ var QueuesAPIImpl = class {
675
+ _serviceContainer;
676
+ _spaceId;
677
+ constructor(_serviceContainer, _spaceId) {
678
+ this._serviceContainer = _serviceContainer;
679
+ this._spaceId = _spaceId;
680
+ }
681
+ async queryQueue(queue, options) {
682
+ const result = await this._serviceContainer.queryQueue(queue);
683
+ const objects = (result.objects ?? []).flatMap((encoded) => {
684
+ try {
685
+ return [
686
+ JSON.parse(encoded)
687
+ ];
688
+ } catch (err) {
689
+ log3.verbose("queue object JSON parse failed; object ignored", {
690
+ encoded,
691
+ error: err
692
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 22, S: this });
693
+ return [];
694
+ }
695
+ });
696
+ return {
697
+ objects,
698
+ nextCursor: result.nextCursor ?? null,
699
+ prevCursor: result.prevCursor ?? null
700
+ };
327
701
  }
328
702
  insertIntoQueue(queue, objects) {
329
- return this._queueService.append({}, queue.toString(), objects);
703
+ return this._serviceContainer.insertIntoQueue(queue, JSON.parse(JSON.stringify(objects)));
704
+ }
705
+ };
706
+
707
+ // src/space-proxy.ts
708
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/space-proxy.ts";
709
+ var SpaceProxy = class extends Resource {
710
+ _serviceContainer;
711
+ _echoClient;
712
+ _id;
713
+ _db = void 0;
714
+ _queuesApi;
715
+ constructor(_serviceContainer, _echoClient, _id) {
716
+ super(), this._serviceContainer = _serviceContainer, this._echoClient = _echoClient, this._id = _id;
717
+ this._queuesApi = new QueuesAPIImpl(this._serviceContainer, this._id);
718
+ }
719
+ get id() {
720
+ return this._id;
721
+ }
722
+ get db() {
723
+ invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 24, S: this, A: ["this._db", ""] });
724
+ return this._db;
725
+ }
726
+ /**
727
+ * @deprecated Use db API.
728
+ */
729
+ get crud() {
730
+ invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 30, S: this, A: ["this._db", ""] });
731
+ return this._db.coreDatabase;
732
+ }
733
+ get queues() {
734
+ return this._queuesApi;
735
+ }
736
+ async _open() {
737
+ const meta = await this._serviceContainer.getSpaceMeta(this._id);
738
+ if (!meta) {
739
+ throw new Error(`Space not found: ${this._id}`);
740
+ }
741
+ this._db = this._echoClient.constructDatabase({
742
+ spaceId: this._id,
743
+ spaceKey: PublicKey.from(meta.spaceKey),
744
+ reactiveSchemaQuery: false,
745
+ owningObject: this
746
+ });
747
+ await this._db.coreDatabase.open(this._ctx, {
748
+ rootUrl: meta.rootDocumentId
749
+ });
330
750
  }
331
751
  };
332
752
 
753
+ // src/functions-client.ts
754
+ var __dxlog_file5 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/functions-client.ts";
755
+ var FunctionsClient = class extends Resource2 {
756
+ _serviceContainer;
757
+ _echoClient;
758
+ _executionContext = {};
759
+ _spaces = /* @__PURE__ */ new Map();
760
+ constructor(services) {
761
+ super();
762
+ invariant3(typeof services.dataService !== "undefined", "DataService is required", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 19, S: this, A: ["typeof services.dataService !== 'undefined'", "'DataService is required'"] });
763
+ invariant3(typeof services.queueService !== "undefined", "QueueService is required", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 20, S: this, A: ["typeof services.queueService !== 'undefined'", "'QueueService is required'"] });
764
+ this._serviceContainer = new ServiceContainer(this._executionContext, services.dataService, services.queueService, services.functionsAiService);
765
+ this._echoClient = new EchoClient({});
766
+ }
767
+ get echo() {
768
+ return this._echoClient;
769
+ }
770
+ async _open() {
771
+ const { dataService, queryService } = await this._serviceContainer.createServices();
772
+ this._echoClient.connectToService({
773
+ dataService,
774
+ queryService
775
+ });
776
+ await this._echoClient.open();
777
+ }
778
+ async _close() {
779
+ for (const space of this._spaces.values()) {
780
+ await space.close();
781
+ }
782
+ this._spaces.clear();
783
+ await this._echoClient.close();
784
+ }
785
+ async getSpace(spaceId) {
786
+ if (!this._spaces.has(spaceId)) {
787
+ const space2 = new SpaceProxy(this._serviceContainer, this._echoClient, spaceId);
788
+ this._spaces.set(spaceId, space2);
789
+ }
790
+ const space = this._spaces.get(spaceId);
791
+ await space.open();
792
+ return space;
793
+ }
794
+ };
795
+ var createClientFromEnv = async (env) => {
796
+ const client = new FunctionsClient({
797
+ dataService: env.DATA_SERVICE,
798
+ queueService: env.QUEUE_SERVICE,
799
+ functionsAiService: env.FUNCTIONS_AI_SERVICE
800
+ });
801
+ await client.open();
802
+ return client;
803
+ };
804
+
333
805
  // src/types.ts
334
806
  var FUNCTION_ROUTE_HEADER = "X-DXOS-Function-Route";
335
807
  var FunctionRouteValue = /* @__PURE__ */ (function(FunctionRouteValue2) {
@@ -339,48 +811,35 @@ var FunctionRouteValue = /* @__PURE__ */ (function(FunctionRouteValue2) {
339
811
 
340
812
  // src/wrap-handler-for-cloudflare.ts
341
813
  import { invariant as invariant4 } from "@dxos/invariant";
342
- import { SpaceId as SpaceId4 } from "@dxos/keys";
343
- import { log as log3 } from "@dxos/log";
814
+ import { SpaceId as SpaceId2 } from "@dxos/keys";
815
+ import { log as log4 } from "@dxos/log";
344
816
  import { EdgeResponse } from "@dxos/protocols";
345
- var __dxlog_file4 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/wrap-handler-for-cloudflare.ts";
817
+ var __dxlog_file6 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/wrap-handler-for-cloudflare.ts";
346
818
  var wrapHandlerForCloudflare = (func) => {
347
819
  return async (request, env) => {
348
820
  if (request.headers.get(FUNCTION_ROUTE_HEADER) === FunctionRouteValue.Meta) {
349
- log3.info(">>> meta", {
350
- func
351
- }, {
352
- F: __dxlog_file4,
353
- L: 25,
354
- S: void 0,
355
- C: (f, a) => f(...a)
356
- });
357
821
  return handleFunctionMetaCall(func, request);
358
822
  }
359
823
  try {
360
824
  const spaceId = new URL(request.url).searchParams.get("spaceId");
361
825
  if (spaceId) {
362
- if (!SpaceId4.isValid(spaceId)) {
826
+ if (!SpaceId2.isValid(spaceId)) {
363
827
  return new Response("Invalid spaceId", {
364
828
  status: 400
365
829
  });
366
830
  }
367
831
  }
368
- const serviceContainer = new ServiceContainer({}, env.DATA_SERVICE, env.QUEUE_SERVICE);
832
+ const serviceContainer = new ServiceContainer({}, env.DATA_SERVICE, env.QUEUE_SERVICE, env.FUNCTIONS_AI_SERVICE);
369
833
  const context = await createFunctionContext({
370
834
  serviceContainer,
371
835
  contextSpaceId: spaceId
372
836
  });
373
837
  return EdgeResponse.success(await invokeFunction(func, context, request));
374
838
  } catch (error) {
375
- log3.error("error invoking function", {
839
+ log4.error("error invoking function", {
376
840
  error,
377
841
  stack: error.stack
378
- }, {
379
- F: __dxlog_file4,
380
- L: 45,
381
- S: void 0,
382
- C: (f, a) => f(...a)
383
- });
842
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 37, S: void 0 });
384
843
  return EdgeResponse.failure({
385
844
  message: error?.message ?? "Internal error",
386
845
  error
@@ -413,12 +872,7 @@ var decodeRequest = async (request) => {
413
872
  }
414
873
  };
415
874
  } catch (err) {
416
- log3.catch(err, void 0, {
417
- F: __dxlog_file4,
418
- L: 80,
419
- S: void 0,
420
- C: (f, a) => f(...a)
421
- });
875
+ log4.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 76, S: void 0 });
422
876
  return {
423
877
  data: {
424
878
  bodyText,
@@ -442,7 +896,7 @@ var handleFunctionMetaCall = (functionDefinition, request) => {
442
896
  });
443
897
  };
444
898
  var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
445
- const { dataService, queryService, queueService } = await serviceContainer.createServices();
899
+ const { dataService, queryService, queueService, functionsAiService } = await serviceContainer.createServices();
446
900
  let spaceKey;
447
901
  let rootUrl;
448
902
  if (contextSpaceId) {
@@ -451,32 +905,68 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
451
905
  throw new Error(`Space not found: ${contextSpaceId}`);
452
906
  }
453
907
  spaceKey = meta.spaceKey;
454
- invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, {
455
- F: __dxlog_file4,
456
- L: 118,
457
- S: void 0,
458
- A: [
459
- "!meta.rootDocumentId.startsWith('automerge:')",
460
- ""
461
- ]
462
- });
908
+ invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 109, S: void 0, A: ["!meta.rootDocumentId.startsWith('automerge:')", ""] });
463
909
  rootUrl = `automerge:${meta.rootDocumentId}`;
464
910
  }
465
911
  return {
466
912
  services: {
467
913
  dataService,
468
914
  queryService,
469
- queueService
915
+ queueService,
916
+ functionsAiService
470
917
  },
471
918
  spaceId: contextSpaceId,
472
919
  spaceKey,
473
920
  spaceRootUrl: rootUrl
474
921
  };
475
922
  };
923
+
924
+ // src/logger.ts
925
+ import { LogLevel, log as log5, shouldLog } from "@dxos/log";
926
+ var setupFunctionsLogger = () => {
927
+ log5.runtimeConfig.processors.length = 0;
928
+ log5.runtimeConfig.processors.push(functionLogProcessor);
929
+ };
930
+ var functionLogProcessor = (config, entry) => {
931
+ if (!shouldLog(entry, config.filters)) {
932
+ return;
933
+ }
934
+ const context = entry.computedContext;
935
+ const error = entry.computedError;
936
+ const extras = [
937
+ Object.keys(context).length > 0 ? context : void 0,
938
+ error
939
+ ].filter((value) => value !== void 0);
940
+ switch (entry.level) {
941
+ case LogLevel.DEBUG:
942
+ case LogLevel.TRACE:
943
+ console.debug(entry.message, ...extras);
944
+ break;
945
+ case LogLevel.VERBOSE:
946
+ console.log(entry.message, ...extras);
947
+ break;
948
+ case LogLevel.INFO:
949
+ console.info(entry.message, ...extras);
950
+ break;
951
+ case LogLevel.WARN:
952
+ console.warn(entry.message, ...extras);
953
+ break;
954
+ case LogLevel.ERROR:
955
+ console.error(entry.message, ...extras);
956
+ break;
957
+ default:
958
+ console.log(entry.message, ...extras);
959
+ break;
960
+ }
961
+ };
476
962
  export {
477
963
  FUNCTION_ROUTE_HEADER,
478
964
  FunctionRouteValue,
965
+ FunctionsClient,
479
966
  ServiceContainer,
967
+ createClientFromEnv,
968
+ createFunctionContext,
969
+ setupFunctionsLogger,
480
970
  wrapHandlerForCloudflare
481
971
  };
482
972
  //# sourceMappingURL=index.mjs.map