@dxos/functions-runtime-cloudflare 0.8.4-main.9be5663bfe → 0.8.4-main.abd8ff62ef
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 +63 -144
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +63 -144
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/functions-client.d.ts.map +1 -1
- package/dist/types/src/internal/data-service-impl.d.ts.map +1 -1
- package/dist/types/src/internal/query-service-impl.d.ts.map +1 -1
- package/dist/types/src/internal/queue-service-impl.d.ts.map +1 -1
- package/dist/types/src/internal/service-container.d.ts.map +1 -1
- package/dist/types/src/internal/utils.d.ts.map +1 -1
- package/dist/types/src/queues-api.d.ts +7 -3
- package/dist/types/src/queues-api.d.ts.map +1 -1
- package/dist/types/src/space-proxy.d.ts.map +1 -1
- package/dist/types/src/wrap-handler-for-cloudflare.d.ts +6 -0
- package/dist/types/src/wrap-handler-for-cloudflare.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -14
- package/src/internal/service-container.ts +1 -1
- package/src/logger.ts +10 -8
- package/src/queues-api.ts +23 -4
- package/src/wrap-handler-for-cloudflare.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/internal/utils.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/internal/utils.ts":{"bytes":590,"imports":[],"format":"esm"},"src/internal/data-service-impl.ts":{"bytes":19256,"imports":[{"path":"@dxos/codec-protobuf/stream","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"src/internal/utils.ts","kind":"import-statement","original":"./utils"}],"format":"esm"},"src/internal/query-service-impl.ts":{"bytes":9324,"imports":[{"path":"@dxos/codec-protobuf/stream","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/internal/queue-service-impl.ts":{"bytes":11248,"imports":[{"path":"@dxos/errors","kind":"import-statement","external":true}],"format":"esm"},"src/internal/service-container.ts":{"bytes":12950,"imports":[{"path":"src/internal/data-service-impl.ts","kind":"import-statement","original":"./data-service-impl"},{"path":"src/internal/query-service-impl.ts","kind":"import-statement","original":"./query-service-impl"},{"path":"src/internal/queue-service-impl.ts","kind":"import-statement","original":"./queue-service-impl"}],"format":"esm"},"src/internal/index.ts":{"bytes":401,"imports":[{"path":"src/internal/service-container.ts","kind":"import-statement","original":"./service-container"}],"format":"esm"},"src/queues-api.ts":{"bytes":4985,"imports":[{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/space-proxy.ts":{"bytes":6098,"imports":[{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"src/queues-api.ts","kind":"import-statement","original":"./queues-api"}],"format":"esm"},"src/functions-client.ts":{"bytes":9115,"imports":[{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/internal/index.ts","kind":"import-statement","original":"./internal"},{"path":"src/space-proxy.ts","kind":"import-statement","original":"./space-proxy"}],"format":"esm"},"src/types.ts":{"bytes":1603,"imports":[],"format":"esm"},"src/wrap-handler-for-cloudflare.ts":{"bytes":15140,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"src/internal/index.ts","kind":"import-statement","original":"./internal"},{"path":"src/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"src/logger.ts":{"bytes":4864,"imports":[{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":786,"imports":[{"path":"src/functions-client.ts","kind":"import-statement","original":"./functions-client"},{"path":"src/internal/index.ts","kind":"import-statement","original":"./internal"},{"path":"src/types.ts","kind":"import-statement","original":"./types"},{"path":"src/wrap-handler-for-cloudflare.ts","kind":"import-statement","original":"./wrap-handler-for-cloudflare"},{"path":"src/logger.ts","kind":"import-statement","original":"./logger"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":39599},"dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/codec-protobuf/stream","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/codec-protobuf/stream","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["FUNCTION_ROUTE_HEADER","FunctionRouteValue","FunctionsClient","ServiceContainer","createClientFromEnv","createFunctionContext","setupFunctionsLogger","wrapHandlerForCloudflare"],"entryPoint":"src/index.ts","inputs":{"src/functions-client.ts":{"bytesInOutput":2107},"src/internal/data-service-impl.ts":{"bytesInOutput":6995},"src/internal/utils.ts":{"bytesInOutput":55},"src/internal/query-service-impl.ts":{"bytesInOutput":4388},"src/internal/queue-service-impl.ts":{"bytesInOutput":4790},"src/internal/service-container.ts":{"bytesInOutput":4452},"src/space-proxy.ts":{"bytesInOutput":1501},"src/queues-api.ts":{"bytesInOutput":1078},"src/index.ts":{"bytesInOutput":0},"src/types.ts":{"bytesInOutput":205},"src/wrap-handler-for-cloudflare.ts":{"bytesInOutput":3427},"src/logger.ts":{"bytesInOutput":1064}},"bytes":30709}}}
|
|
@@ -17,6 +17,7 @@ import { log } from "@dxos/log";
|
|
|
17
17
|
var copyUint8Array = (value) => new Uint8Array(value);
|
|
18
18
|
|
|
19
19
|
// src/internal/data-service-impl.ts
|
|
20
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/data-service-impl.ts";
|
|
20
21
|
function _ts_add_disposable_resource(env, value, async) {
|
|
21
22
|
if (value !== null && value !== void 0) {
|
|
22
23
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
@@ -82,7 +83,6 @@ function _ts_dispose_resources(env) {
|
|
|
82
83
|
return next();
|
|
83
84
|
})(env);
|
|
84
85
|
}
|
|
85
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/data-service-impl.ts";
|
|
86
86
|
var DataServiceImpl = class {
|
|
87
87
|
_executionContext;
|
|
88
88
|
_dataService;
|
|
@@ -93,15 +93,7 @@ var DataServiceImpl = class {
|
|
|
93
93
|
}
|
|
94
94
|
subscribe({ subscriptionId, spaceId }) {
|
|
95
95
|
return new Stream(({ next }) => {
|
|
96
|
-
invariant(SpaceId.isValid(spaceId), void 0, {
|
|
97
|
-
F: __dxlog_file,
|
|
98
|
-
L: 39,
|
|
99
|
-
S: this,
|
|
100
|
-
A: [
|
|
101
|
-
"SpaceId.isValid(spaceId)",
|
|
102
|
-
""
|
|
103
|
-
]
|
|
104
|
-
});
|
|
96
|
+
invariant(SpaceId.isValid(spaceId), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 86, S: this, A: ["SpaceId.isValid(spaceId)", ""] });
|
|
105
97
|
this.dataSubscriptions.set(subscriptionId, {
|
|
106
98
|
spaceId,
|
|
107
99
|
next
|
|
@@ -121,12 +113,7 @@ var DataServiceImpl = class {
|
|
|
121
113
|
if (addIds) {
|
|
122
114
|
log.info("request documents", {
|
|
123
115
|
count: addIds.length
|
|
124
|
-
}, {
|
|
125
|
-
F: __dxlog_file,
|
|
126
|
-
L: 59,
|
|
127
|
-
S: this,
|
|
128
|
-
C: (f, a) => f(...a)
|
|
129
|
-
});
|
|
116
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 104, S: this });
|
|
130
117
|
for (const documentId of addIds) {
|
|
131
118
|
const env = {
|
|
132
119
|
stack: [],
|
|
@@ -139,21 +126,11 @@ var DataServiceImpl = class {
|
|
|
139
126
|
documentId,
|
|
140
127
|
spaceId: sub.spaceId,
|
|
141
128
|
found: !!document
|
|
142
|
-
}, {
|
|
143
|
-
F: __dxlog_file,
|
|
144
|
-
L: 63,
|
|
145
|
-
S: this,
|
|
146
|
-
C: (f, a) => f(...a)
|
|
147
|
-
});
|
|
129
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 116, S: this });
|
|
148
130
|
if (!document) {
|
|
149
131
|
log.warn("not found", {
|
|
150
132
|
documentId
|
|
151
|
-
}, {
|
|
152
|
-
F: __dxlog_file,
|
|
153
|
-
L: 65,
|
|
154
|
-
S: this,
|
|
155
|
-
C: (f, a) => f(...a)
|
|
156
|
-
});
|
|
133
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 122, S: this });
|
|
157
134
|
continue;
|
|
158
135
|
}
|
|
159
136
|
sub.next({
|
|
@@ -182,15 +159,7 @@ var DataServiceImpl = class {
|
|
|
182
159
|
hasError: false
|
|
183
160
|
};
|
|
184
161
|
try {
|
|
185
|
-
invariant(SpaceId.isValid(spaceId), void 0, {
|
|
186
|
-
F: __dxlog_file,
|
|
187
|
-
L: 83,
|
|
188
|
-
S: this,
|
|
189
|
-
A: [
|
|
190
|
-
"SpaceId.isValid(spaceId)",
|
|
191
|
-
""
|
|
192
|
-
]
|
|
193
|
-
});
|
|
162
|
+
invariant(SpaceId.isValid(spaceId), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 153, S: this, A: ["SpaceId.isValid(spaceId)", ""] });
|
|
194
163
|
const response = _ts_add_disposable_resource(env, await this._dataService.createDocument(this._executionContext, spaceId, initialValue), false);
|
|
195
164
|
return {
|
|
196
165
|
documentId: response.documentId
|
|
@@ -241,12 +210,7 @@ var DataServiceImpl = class {
|
|
|
241
210
|
});
|
|
242
211
|
}
|
|
243
212
|
async updateIndexes() {
|
|
244
|
-
log.error("updateIndexes is not available in EDGE env.", void 0, {
|
|
245
|
-
F: __dxlog_file,
|
|
246
|
-
L: 134,
|
|
247
|
-
S: this,
|
|
248
|
-
C: (f, a) => f(...a)
|
|
249
|
-
});
|
|
213
|
+
log.error("updateIndexes is not available in EDGE env.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 206, S: this });
|
|
250
214
|
}
|
|
251
215
|
async waitUntilHeadsReplicated({ heads: _heads }) {
|
|
252
216
|
throw new NotImplementedError({
|
|
@@ -259,6 +223,7 @@ var DataServiceImpl = class {
|
|
|
259
223
|
import { Stream as Stream2 } from "@dxos/codec-protobuf/stream";
|
|
260
224
|
import { NotImplementedError as NotImplementedError2, RuntimeServiceError as RuntimeServiceError2 } from "@dxos/errors";
|
|
261
225
|
import { log as log2 } from "@dxos/log";
|
|
226
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/query-service-impl.ts";
|
|
262
227
|
function _ts_add_disposable_resource2(env, value, async) {
|
|
263
228
|
if (value !== null && value !== void 0) {
|
|
264
229
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
@@ -324,7 +289,6 @@ function _ts_dispose_resources2(env) {
|
|
|
324
289
|
return next();
|
|
325
290
|
})(env);
|
|
326
291
|
}
|
|
327
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/query-service-impl.ts";
|
|
328
292
|
var QueryServiceImpl = class {
|
|
329
293
|
_executionContext;
|
|
330
294
|
_dataService;
|
|
@@ -336,12 +300,7 @@ var QueryServiceImpl = class {
|
|
|
336
300
|
execQuery(request) {
|
|
337
301
|
log2.info("execQuery", {
|
|
338
302
|
request
|
|
339
|
-
}, {
|
|
340
|
-
F: __dxlog_file2,
|
|
341
|
-
L: 20,
|
|
342
|
-
S: this,
|
|
343
|
-
C: (f, a) => f(...a)
|
|
344
|
-
});
|
|
303
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 81, S: this });
|
|
345
304
|
return Stream2.fromPromise((async () => {
|
|
346
305
|
try {
|
|
347
306
|
const env = {
|
|
@@ -353,21 +312,11 @@ var QueryServiceImpl = class {
|
|
|
353
312
|
this._queryCount++;
|
|
354
313
|
log2.info("begin query", {
|
|
355
314
|
request
|
|
356
|
-
}, {
|
|
357
|
-
F: __dxlog_file2,
|
|
358
|
-
L: 26,
|
|
359
|
-
S: this,
|
|
360
|
-
C: (f, a) => f(...a)
|
|
361
|
-
});
|
|
315
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 93, S: this });
|
|
362
316
|
const queryResponse = _ts_add_disposable_resource2(env, await this._dataService.execQuery(this._executionContext, request), false);
|
|
363
317
|
log2.info("query response", {
|
|
364
318
|
resultCount: queryResponse.results?.length
|
|
365
|
-
}, {
|
|
366
|
-
F: __dxlog_file2,
|
|
367
|
-
L: 28,
|
|
368
|
-
S: this,
|
|
369
|
-
C: (f, a) => f(...a)
|
|
370
|
-
});
|
|
319
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 97, S: this });
|
|
371
320
|
return structuredClone(queryResponse);
|
|
372
321
|
} catch (e) {
|
|
373
322
|
env.error = e;
|
|
@@ -378,12 +327,7 @@ var QueryServiceImpl = class {
|
|
|
378
327
|
} catch (error) {
|
|
379
328
|
log2.error("query failed", {
|
|
380
329
|
err: error
|
|
381
|
-
}, {
|
|
382
|
-
F: __dxlog_file2,
|
|
383
|
-
L: 31,
|
|
384
|
-
S: this,
|
|
385
|
-
C: (f, a) => f(...a)
|
|
386
|
-
});
|
|
330
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 108, S: this });
|
|
387
331
|
throw new RuntimeServiceError2({
|
|
388
332
|
message: `Query execution failed (queryCount=${this._queryCount})`,
|
|
389
333
|
context: {
|
|
@@ -711,7 +655,7 @@ var ServiceContainer = class {
|
|
|
711
655
|
subspaceTag,
|
|
712
656
|
spaceId,
|
|
713
657
|
queueId,
|
|
714
|
-
objects
|
|
658
|
+
objects: objects.map((obj) => JSON.stringify(obj))
|
|
715
659
|
});
|
|
716
660
|
}
|
|
717
661
|
};
|
|
@@ -722,6 +666,8 @@ import { invariant as invariant2 } from "@dxos/invariant";
|
|
|
722
666
|
import { PublicKey } from "@dxos/keys";
|
|
723
667
|
|
|
724
668
|
// src/queues-api.ts
|
|
669
|
+
import { log as log3 } from "@dxos/log";
|
|
670
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/queues-api.ts";
|
|
725
671
|
var QueuesAPIImpl = class {
|
|
726
672
|
_serviceContainer;
|
|
727
673
|
_spaceId;
|
|
@@ -729,8 +675,26 @@ var QueuesAPIImpl = class {
|
|
|
729
675
|
this._serviceContainer = _serviceContainer;
|
|
730
676
|
this._spaceId = _spaceId;
|
|
731
677
|
}
|
|
732
|
-
queryQueue(queue, options) {
|
|
733
|
-
|
|
678
|
+
async queryQueue(queue, options) {
|
|
679
|
+
const result = await this._serviceContainer.queryQueue(queue);
|
|
680
|
+
const objects = (result.objects ?? []).flatMap((encoded) => {
|
|
681
|
+
try {
|
|
682
|
+
return [
|
|
683
|
+
JSON.parse(encoded)
|
|
684
|
+
];
|
|
685
|
+
} catch (err) {
|
|
686
|
+
log3.verbose("queue object JSON parse failed; object ignored", {
|
|
687
|
+
encoded,
|
|
688
|
+
error: err
|
|
689
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 22, S: this });
|
|
690
|
+
return [];
|
|
691
|
+
}
|
|
692
|
+
});
|
|
693
|
+
return {
|
|
694
|
+
objects,
|
|
695
|
+
nextCursor: result.nextCursor ?? null,
|
|
696
|
+
prevCursor: result.prevCursor ?? null
|
|
697
|
+
};
|
|
734
698
|
}
|
|
735
699
|
insertIntoQueue(queue, objects) {
|
|
736
700
|
return this._serviceContainer.insertIntoQueue(queue, JSON.parse(JSON.stringify(objects)));
|
|
@@ -738,7 +702,7 @@ var QueuesAPIImpl = class {
|
|
|
738
702
|
};
|
|
739
703
|
|
|
740
704
|
// src/space-proxy.ts
|
|
741
|
-
var
|
|
705
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/space-proxy.ts";
|
|
742
706
|
var SpaceProxy = class extends Resource {
|
|
743
707
|
_serviceContainer;
|
|
744
708
|
_echoClient;
|
|
@@ -753,30 +717,14 @@ var SpaceProxy = class extends Resource {
|
|
|
753
717
|
return this._id;
|
|
754
718
|
}
|
|
755
719
|
get db() {
|
|
756
|
-
invariant2(this._db, void 0, {
|
|
757
|
-
F: __dxlog_file3,
|
|
758
|
-
L: 35,
|
|
759
|
-
S: this,
|
|
760
|
-
A: [
|
|
761
|
-
"this._db",
|
|
762
|
-
""
|
|
763
|
-
]
|
|
764
|
-
});
|
|
720
|
+
invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 24, S: this, A: ["this._db", ""] });
|
|
765
721
|
return this._db;
|
|
766
722
|
}
|
|
767
723
|
/**
|
|
768
724
|
* @deprecated Use db API.
|
|
769
725
|
*/
|
|
770
726
|
get crud() {
|
|
771
|
-
invariant2(this._db, void 0, {
|
|
772
|
-
F: __dxlog_file3,
|
|
773
|
-
L: 43,
|
|
774
|
-
S: this,
|
|
775
|
-
A: [
|
|
776
|
-
"this._db",
|
|
777
|
-
""
|
|
778
|
-
]
|
|
779
|
-
});
|
|
727
|
+
invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 30, S: this, A: ["this._db", ""] });
|
|
780
728
|
return this._db.coreDatabase;
|
|
781
729
|
}
|
|
782
730
|
get queues() {
|
|
@@ -800,7 +748,7 @@ var SpaceProxy = class extends Resource {
|
|
|
800
748
|
};
|
|
801
749
|
|
|
802
750
|
// src/functions-client.ts
|
|
803
|
-
var
|
|
751
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/functions-client.ts";
|
|
804
752
|
var FunctionsClient = class extends Resource2 {
|
|
805
753
|
_serviceContainer;
|
|
806
754
|
_echoClient;
|
|
@@ -808,24 +756,8 @@ var FunctionsClient = class extends Resource2 {
|
|
|
808
756
|
_spaces = /* @__PURE__ */ new Map();
|
|
809
757
|
constructor(services) {
|
|
810
758
|
super();
|
|
811
|
-
invariant3(typeof services.dataService !== "undefined", "DataService is required", {
|
|
812
|
-
|
|
813
|
-
L: 33,
|
|
814
|
-
S: this,
|
|
815
|
-
A: [
|
|
816
|
-
"typeof services.dataService !== 'undefined'",
|
|
817
|
-
"'DataService is required'"
|
|
818
|
-
]
|
|
819
|
-
});
|
|
820
|
-
invariant3(typeof services.queueService !== "undefined", "QueueService is required", {
|
|
821
|
-
F: __dxlog_file4,
|
|
822
|
-
L: 34,
|
|
823
|
-
S: this,
|
|
824
|
-
A: [
|
|
825
|
-
"typeof services.queueService !== 'undefined'",
|
|
826
|
-
"'QueueService is required'"
|
|
827
|
-
]
|
|
828
|
-
});
|
|
759
|
+
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'"] });
|
|
760
|
+
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'"] });
|
|
829
761
|
this._serviceContainer = new ServiceContainer(this._executionContext, services.dataService, services.queueService, services.functionsAiService);
|
|
830
762
|
this._echoClient = new EchoClient({});
|
|
831
763
|
}
|
|
@@ -877,9 +809,9 @@ var FunctionRouteValue = /* @__PURE__ */ (function(FunctionRouteValue2) {
|
|
|
877
809
|
// src/wrap-handler-for-cloudflare.ts
|
|
878
810
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
879
811
|
import { SpaceId as SpaceId2 } from "@dxos/keys";
|
|
880
|
-
import { log as
|
|
812
|
+
import { log as log4 } from "@dxos/log";
|
|
881
813
|
import { EdgeResponse } from "@dxos/protocols";
|
|
882
|
-
var
|
|
814
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/wrap-handler-for-cloudflare.ts";
|
|
883
815
|
var wrapHandlerForCloudflare = (func) => {
|
|
884
816
|
return async (request, env) => {
|
|
885
817
|
if (request.headers.get(FUNCTION_ROUTE_HEADER) === FunctionRouteValue.Meta) {
|
|
@@ -901,15 +833,10 @@ var wrapHandlerForCloudflare = (func) => {
|
|
|
901
833
|
});
|
|
902
834
|
return EdgeResponse.success(await invokeFunction(func, context, request));
|
|
903
835
|
} catch (error) {
|
|
904
|
-
|
|
836
|
+
log4.error("error invoking function", {
|
|
905
837
|
error,
|
|
906
838
|
stack: error.stack
|
|
907
|
-
}, {
|
|
908
|
-
F: __dxlog_file5,
|
|
909
|
-
L: 44,
|
|
910
|
-
S: void 0,
|
|
911
|
-
C: (f, a) => f(...a)
|
|
912
|
-
});
|
|
839
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 37, S: void 0 });
|
|
913
840
|
return EdgeResponse.failure({
|
|
914
841
|
message: error?.message ?? "Internal error",
|
|
915
842
|
error
|
|
@@ -942,12 +869,7 @@ var decodeRequest = async (request) => {
|
|
|
942
869
|
}
|
|
943
870
|
};
|
|
944
871
|
} catch (err) {
|
|
945
|
-
|
|
946
|
-
F: __dxlog_file5,
|
|
947
|
-
L: 79,
|
|
948
|
-
S: void 0,
|
|
949
|
-
C: (f, a) => f(...a)
|
|
950
|
-
});
|
|
872
|
+
log4.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 76, S: void 0 });
|
|
951
873
|
return {
|
|
952
874
|
data: {
|
|
953
875
|
bodyText,
|
|
@@ -980,15 +902,7 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
|
|
|
980
902
|
throw new Error(`Space not found: ${contextSpaceId}`);
|
|
981
903
|
}
|
|
982
904
|
spaceKey = meta.spaceKey;
|
|
983
|
-
invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, {
|
|
984
|
-
F: __dxlog_file5,
|
|
985
|
-
L: 117,
|
|
986
|
-
S: void 0,
|
|
987
|
-
A: [
|
|
988
|
-
"!meta.rootDocumentId.startsWith('automerge:')",
|
|
989
|
-
""
|
|
990
|
-
]
|
|
991
|
-
});
|
|
905
|
+
invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 109, S: void 0, A: ["!meta.rootDocumentId.startsWith('automerge:')", ""] });
|
|
992
906
|
rootUrl = `automerge:${meta.rootDocumentId}`;
|
|
993
907
|
}
|
|
994
908
|
return {
|
|
@@ -1005,36 +919,40 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
|
|
|
1005
919
|
};
|
|
1006
920
|
|
|
1007
921
|
// src/logger.ts
|
|
1008
|
-
import { LogLevel, log as
|
|
922
|
+
import { LogLevel, log as log5, shouldLog } from "@dxos/log";
|
|
1009
923
|
var setupFunctionsLogger = () => {
|
|
1010
|
-
|
|
1011
|
-
|
|
924
|
+
log5.runtimeConfig.processors.length = 0;
|
|
925
|
+
log5.runtimeConfig.processors.push(functionLogProcessor);
|
|
1012
926
|
};
|
|
1013
927
|
var functionLogProcessor = (config, entry) => {
|
|
1014
928
|
if (!shouldLog(entry, config.filters)) {
|
|
1015
929
|
return;
|
|
1016
930
|
}
|
|
931
|
+
const context = entry.computedContext;
|
|
932
|
+
const error = entry.computedError;
|
|
933
|
+
const extras = [
|
|
934
|
+
Object.keys(context).length > 0 ? context : void 0,
|
|
935
|
+
error
|
|
936
|
+
].filter((value) => value !== void 0);
|
|
1017
937
|
switch (entry.level) {
|
|
1018
938
|
case LogLevel.DEBUG:
|
|
1019
|
-
console.debug(entry.message, entry.context);
|
|
1020
|
-
break;
|
|
1021
939
|
case LogLevel.TRACE:
|
|
1022
|
-
console.debug(entry.message,
|
|
940
|
+
console.debug(entry.message, ...extras);
|
|
1023
941
|
break;
|
|
1024
942
|
case LogLevel.VERBOSE:
|
|
1025
|
-
console.log(entry.message,
|
|
943
|
+
console.log(entry.message, ...extras);
|
|
1026
944
|
break;
|
|
1027
945
|
case LogLevel.INFO:
|
|
1028
|
-
console.info(entry.message,
|
|
946
|
+
console.info(entry.message, ...extras);
|
|
1029
947
|
break;
|
|
1030
948
|
case LogLevel.WARN:
|
|
1031
|
-
console.warn(entry.message,
|
|
949
|
+
console.warn(entry.message, ...extras);
|
|
1032
950
|
break;
|
|
1033
951
|
case LogLevel.ERROR:
|
|
1034
|
-
console.error(entry.message,
|
|
952
|
+
console.error(entry.message, ...extras);
|
|
1035
953
|
break;
|
|
1036
954
|
default:
|
|
1037
|
-
console.log(entry.message,
|
|
955
|
+
console.log(entry.message, ...extras);
|
|
1038
956
|
break;
|
|
1039
957
|
}
|
|
1040
958
|
};
|
|
@@ -1044,6 +962,7 @@ export {
|
|
|
1044
962
|
FunctionsClient,
|
|
1045
963
|
ServiceContainer,
|
|
1046
964
|
createClientFromEnv,
|
|
965
|
+
createFunctionContext,
|
|
1047
966
|
setupFunctionsLogger,
|
|
1048
967
|
wrapHandlerForCloudflare
|
|
1049
968
|
};
|