@dxos/functions-runtime-cloudflare 0.8.4-main.d05673bc65 → 0.8.4-main.e00bdcdb52
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 +65 -140
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +65 -140
- 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 +15 -15
- package/src/internal/data-service-impl.ts +2 -1
- package/src/internal/service-container.ts +1 -1
- package/src/logger.ts +10 -8
- package/src/queues-api.ts +23 -4
- package/src/space-proxy.ts +1 -1
- 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,10 +159,8 @@ var DataServiceImpl = class {
|
|
|
182
159
|
hasError: false
|
|
183
160
|
};
|
|
184
161
|
try {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
initialValue
|
|
188
|
-
}), false);
|
|
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);
|
|
189
164
|
return {
|
|
190
165
|
documentId: response.documentId
|
|
191
166
|
};
|
|
@@ -235,12 +210,7 @@ var DataServiceImpl = class {
|
|
|
235
210
|
});
|
|
236
211
|
}
|
|
237
212
|
async updateIndexes() {
|
|
238
|
-
log.error("updateIndexes is not available in EDGE env.", void 0, {
|
|
239
|
-
F: __dxlog_file,
|
|
240
|
-
L: 133,
|
|
241
|
-
S: this,
|
|
242
|
-
C: (f, a) => f(...a)
|
|
243
|
-
});
|
|
213
|
+
log.error("updateIndexes is not available in EDGE env.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 206, S: this });
|
|
244
214
|
}
|
|
245
215
|
async waitUntilHeadsReplicated({ heads: _heads }) {
|
|
246
216
|
throw new NotImplementedError({
|
|
@@ -253,6 +223,7 @@ var DataServiceImpl = class {
|
|
|
253
223
|
import { Stream as Stream2 } from "@dxos/codec-protobuf/stream";
|
|
254
224
|
import { NotImplementedError as NotImplementedError2, RuntimeServiceError as RuntimeServiceError2 } from "@dxos/errors";
|
|
255
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";
|
|
256
227
|
function _ts_add_disposable_resource2(env, value, async) {
|
|
257
228
|
if (value !== null && value !== void 0) {
|
|
258
229
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
@@ -318,7 +289,6 @@ function _ts_dispose_resources2(env) {
|
|
|
318
289
|
return next();
|
|
319
290
|
})(env);
|
|
320
291
|
}
|
|
321
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/query-service-impl.ts";
|
|
322
292
|
var QueryServiceImpl = class {
|
|
323
293
|
_executionContext;
|
|
324
294
|
_dataService;
|
|
@@ -330,12 +300,7 @@ var QueryServiceImpl = class {
|
|
|
330
300
|
execQuery(request) {
|
|
331
301
|
log2.info("execQuery", {
|
|
332
302
|
request
|
|
333
|
-
}, {
|
|
334
|
-
F: __dxlog_file2,
|
|
335
|
-
L: 20,
|
|
336
|
-
S: this,
|
|
337
|
-
C: (f, a) => f(...a)
|
|
338
|
-
});
|
|
303
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 81, S: this });
|
|
339
304
|
return Stream2.fromPromise((async () => {
|
|
340
305
|
try {
|
|
341
306
|
const env = {
|
|
@@ -347,21 +312,11 @@ var QueryServiceImpl = class {
|
|
|
347
312
|
this._queryCount++;
|
|
348
313
|
log2.info("begin query", {
|
|
349
314
|
request
|
|
350
|
-
}, {
|
|
351
|
-
F: __dxlog_file2,
|
|
352
|
-
L: 26,
|
|
353
|
-
S: this,
|
|
354
|
-
C: (f, a) => f(...a)
|
|
355
|
-
});
|
|
315
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 93, S: this });
|
|
356
316
|
const queryResponse = _ts_add_disposable_resource2(env, await this._dataService.execQuery(this._executionContext, request), false);
|
|
357
317
|
log2.info("query response", {
|
|
358
318
|
resultCount: queryResponse.results?.length
|
|
359
|
-
}, {
|
|
360
|
-
F: __dxlog_file2,
|
|
361
|
-
L: 28,
|
|
362
|
-
S: this,
|
|
363
|
-
C: (f, a) => f(...a)
|
|
364
|
-
});
|
|
319
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 97, S: this });
|
|
365
320
|
return structuredClone(queryResponse);
|
|
366
321
|
} catch (e) {
|
|
367
322
|
env.error = e;
|
|
@@ -372,12 +327,7 @@ var QueryServiceImpl = class {
|
|
|
372
327
|
} catch (error) {
|
|
373
328
|
log2.error("query failed", {
|
|
374
329
|
err: error
|
|
375
|
-
}, {
|
|
376
|
-
F: __dxlog_file2,
|
|
377
|
-
L: 31,
|
|
378
|
-
S: this,
|
|
379
|
-
C: (f, a) => f(...a)
|
|
380
|
-
});
|
|
330
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 108, S: this });
|
|
381
331
|
throw new RuntimeServiceError2({
|
|
382
332
|
message: `Query execution failed (queryCount=${this._queryCount})`,
|
|
383
333
|
context: {
|
|
@@ -705,7 +655,7 @@ var ServiceContainer = class {
|
|
|
705
655
|
subspaceTag,
|
|
706
656
|
spaceId,
|
|
707
657
|
queueId,
|
|
708
|
-
objects
|
|
658
|
+
objects: objects.map((obj) => JSON.stringify(obj))
|
|
709
659
|
});
|
|
710
660
|
}
|
|
711
661
|
};
|
|
@@ -716,6 +666,8 @@ import { invariant as invariant2 } from "@dxos/invariant";
|
|
|
716
666
|
import { PublicKey } from "@dxos/keys";
|
|
717
667
|
|
|
718
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";
|
|
719
671
|
var QueuesAPIImpl = class {
|
|
720
672
|
_serviceContainer;
|
|
721
673
|
_spaceId;
|
|
@@ -723,8 +675,26 @@ var QueuesAPIImpl = class {
|
|
|
723
675
|
this._serviceContainer = _serviceContainer;
|
|
724
676
|
this._spaceId = _spaceId;
|
|
725
677
|
}
|
|
726
|
-
queryQueue(queue, options) {
|
|
727
|
-
|
|
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
|
+
};
|
|
728
698
|
}
|
|
729
699
|
insertIntoQueue(queue, objects) {
|
|
730
700
|
return this._serviceContainer.insertIntoQueue(queue, JSON.parse(JSON.stringify(objects)));
|
|
@@ -732,7 +702,7 @@ var QueuesAPIImpl = class {
|
|
|
732
702
|
};
|
|
733
703
|
|
|
734
704
|
// src/space-proxy.ts
|
|
735
|
-
var
|
|
705
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/space-proxy.ts";
|
|
736
706
|
var SpaceProxy = class extends Resource {
|
|
737
707
|
_serviceContainer;
|
|
738
708
|
_echoClient;
|
|
@@ -747,30 +717,14 @@ var SpaceProxy = class extends Resource {
|
|
|
747
717
|
return this._id;
|
|
748
718
|
}
|
|
749
719
|
get db() {
|
|
750
|
-
invariant2(this._db, void 0, {
|
|
751
|
-
F: __dxlog_file3,
|
|
752
|
-
L: 35,
|
|
753
|
-
S: this,
|
|
754
|
-
A: [
|
|
755
|
-
"this._db",
|
|
756
|
-
""
|
|
757
|
-
]
|
|
758
|
-
});
|
|
720
|
+
invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 24, S: this, A: ["this._db", ""] });
|
|
759
721
|
return this._db;
|
|
760
722
|
}
|
|
761
723
|
/**
|
|
762
724
|
* @deprecated Use db API.
|
|
763
725
|
*/
|
|
764
726
|
get crud() {
|
|
765
|
-
invariant2(this._db, void 0, {
|
|
766
|
-
F: __dxlog_file3,
|
|
767
|
-
L: 43,
|
|
768
|
-
S: this,
|
|
769
|
-
A: [
|
|
770
|
-
"this._db",
|
|
771
|
-
""
|
|
772
|
-
]
|
|
773
|
-
});
|
|
727
|
+
invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 30, S: this, A: ["this._db", ""] });
|
|
774
728
|
return this._db.coreDatabase;
|
|
775
729
|
}
|
|
776
730
|
get queues() {
|
|
@@ -787,14 +741,14 @@ var SpaceProxy = class extends Resource {
|
|
|
787
741
|
reactiveSchemaQuery: false,
|
|
788
742
|
owningObject: this
|
|
789
743
|
});
|
|
790
|
-
await this._db.coreDatabase.open({
|
|
744
|
+
await this._db.coreDatabase.open(this._ctx, {
|
|
791
745
|
rootUrl: meta.rootDocumentId
|
|
792
746
|
});
|
|
793
747
|
}
|
|
794
748
|
};
|
|
795
749
|
|
|
796
750
|
// src/functions-client.ts
|
|
797
|
-
var
|
|
751
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/functions-client.ts";
|
|
798
752
|
var FunctionsClient = class extends Resource2 {
|
|
799
753
|
_serviceContainer;
|
|
800
754
|
_echoClient;
|
|
@@ -802,24 +756,8 @@ var FunctionsClient = class extends Resource2 {
|
|
|
802
756
|
_spaces = /* @__PURE__ */ new Map();
|
|
803
757
|
constructor(services) {
|
|
804
758
|
super();
|
|
805
|
-
invariant3(typeof services.dataService !== "undefined", "DataService is required", {
|
|
806
|
-
|
|
807
|
-
L: 33,
|
|
808
|
-
S: this,
|
|
809
|
-
A: [
|
|
810
|
-
"typeof services.dataService !== 'undefined'",
|
|
811
|
-
"'DataService is required'"
|
|
812
|
-
]
|
|
813
|
-
});
|
|
814
|
-
invariant3(typeof services.queueService !== "undefined", "QueueService is required", {
|
|
815
|
-
F: __dxlog_file4,
|
|
816
|
-
L: 34,
|
|
817
|
-
S: this,
|
|
818
|
-
A: [
|
|
819
|
-
"typeof services.queueService !== 'undefined'",
|
|
820
|
-
"'QueueService is required'"
|
|
821
|
-
]
|
|
822
|
-
});
|
|
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'"] });
|
|
823
761
|
this._serviceContainer = new ServiceContainer(this._executionContext, services.dataService, services.queueService, services.functionsAiService);
|
|
824
762
|
this._echoClient = new EchoClient({});
|
|
825
763
|
}
|
|
@@ -871,9 +809,9 @@ var FunctionRouteValue = /* @__PURE__ */ (function(FunctionRouteValue2) {
|
|
|
871
809
|
// src/wrap-handler-for-cloudflare.ts
|
|
872
810
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
873
811
|
import { SpaceId as SpaceId2 } from "@dxos/keys";
|
|
874
|
-
import { log as
|
|
812
|
+
import { log as log4 } from "@dxos/log";
|
|
875
813
|
import { EdgeResponse } from "@dxos/protocols";
|
|
876
|
-
var
|
|
814
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/wrap-handler-for-cloudflare.ts";
|
|
877
815
|
var wrapHandlerForCloudflare = (func) => {
|
|
878
816
|
return async (request, env) => {
|
|
879
817
|
if (request.headers.get(FUNCTION_ROUTE_HEADER) === FunctionRouteValue.Meta) {
|
|
@@ -895,15 +833,10 @@ var wrapHandlerForCloudflare = (func) => {
|
|
|
895
833
|
});
|
|
896
834
|
return EdgeResponse.success(await invokeFunction(func, context, request));
|
|
897
835
|
} catch (error) {
|
|
898
|
-
|
|
836
|
+
log4.error("error invoking function", {
|
|
899
837
|
error,
|
|
900
838
|
stack: error.stack
|
|
901
|
-
}, {
|
|
902
|
-
F: __dxlog_file5,
|
|
903
|
-
L: 44,
|
|
904
|
-
S: void 0,
|
|
905
|
-
C: (f, a) => f(...a)
|
|
906
|
-
});
|
|
839
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 37, S: void 0 });
|
|
907
840
|
return EdgeResponse.failure({
|
|
908
841
|
message: error?.message ?? "Internal error",
|
|
909
842
|
error
|
|
@@ -936,12 +869,7 @@ var decodeRequest = async (request) => {
|
|
|
936
869
|
}
|
|
937
870
|
};
|
|
938
871
|
} catch (err) {
|
|
939
|
-
|
|
940
|
-
F: __dxlog_file5,
|
|
941
|
-
L: 79,
|
|
942
|
-
S: void 0,
|
|
943
|
-
C: (f, a) => f(...a)
|
|
944
|
-
});
|
|
872
|
+
log4.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 76, S: void 0 });
|
|
945
873
|
return {
|
|
946
874
|
data: {
|
|
947
875
|
bodyText,
|
|
@@ -974,15 +902,7 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
|
|
|
974
902
|
throw new Error(`Space not found: ${contextSpaceId}`);
|
|
975
903
|
}
|
|
976
904
|
spaceKey = meta.spaceKey;
|
|
977
|
-
invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, {
|
|
978
|
-
F: __dxlog_file5,
|
|
979
|
-
L: 117,
|
|
980
|
-
S: void 0,
|
|
981
|
-
A: [
|
|
982
|
-
"!meta.rootDocumentId.startsWith('automerge:')",
|
|
983
|
-
""
|
|
984
|
-
]
|
|
985
|
-
});
|
|
905
|
+
invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 109, S: void 0, A: ["!meta.rootDocumentId.startsWith('automerge:')", ""] });
|
|
986
906
|
rootUrl = `automerge:${meta.rootDocumentId}`;
|
|
987
907
|
}
|
|
988
908
|
return {
|
|
@@ -999,36 +919,40 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
|
|
|
999
919
|
};
|
|
1000
920
|
|
|
1001
921
|
// src/logger.ts
|
|
1002
|
-
import { LogLevel, log as
|
|
922
|
+
import { LogLevel, log as log5, shouldLog } from "@dxos/log";
|
|
1003
923
|
var setupFunctionsLogger = () => {
|
|
1004
|
-
|
|
1005
|
-
|
|
924
|
+
log5.runtimeConfig.processors.length = 0;
|
|
925
|
+
log5.runtimeConfig.processors.push(functionLogProcessor);
|
|
1006
926
|
};
|
|
1007
927
|
var functionLogProcessor = (config, entry) => {
|
|
1008
928
|
if (!shouldLog(entry, config.filters)) {
|
|
1009
929
|
return;
|
|
1010
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);
|
|
1011
937
|
switch (entry.level) {
|
|
1012
938
|
case LogLevel.DEBUG:
|
|
1013
|
-
console.debug(entry.message, entry.context);
|
|
1014
|
-
break;
|
|
1015
939
|
case LogLevel.TRACE:
|
|
1016
|
-
console.debug(entry.message,
|
|
940
|
+
console.debug(entry.message, ...extras);
|
|
1017
941
|
break;
|
|
1018
942
|
case LogLevel.VERBOSE:
|
|
1019
|
-
console.log(entry.message,
|
|
943
|
+
console.log(entry.message, ...extras);
|
|
1020
944
|
break;
|
|
1021
945
|
case LogLevel.INFO:
|
|
1022
|
-
console.info(entry.message,
|
|
946
|
+
console.info(entry.message, ...extras);
|
|
1023
947
|
break;
|
|
1024
948
|
case LogLevel.WARN:
|
|
1025
|
-
console.warn(entry.message,
|
|
949
|
+
console.warn(entry.message, ...extras);
|
|
1026
950
|
break;
|
|
1027
951
|
case LogLevel.ERROR:
|
|
1028
|
-
console.error(entry.message,
|
|
952
|
+
console.error(entry.message, ...extras);
|
|
1029
953
|
break;
|
|
1030
954
|
default:
|
|
1031
|
-
console.log(entry.message,
|
|
955
|
+
console.log(entry.message, ...extras);
|
|
1032
956
|
break;
|
|
1033
957
|
}
|
|
1034
958
|
};
|
|
@@ -1038,6 +962,7 @@ export {
|
|
|
1038
962
|
FunctionsClient,
|
|
1039
963
|
ServiceContainer,
|
|
1040
964
|
createClientFromEnv,
|
|
965
|
+
createFunctionContext,
|
|
1041
966
|
setupFunctionsLogger,
|
|
1042
967
|
wrapHandlerForCloudflare
|
|
1043
968
|
};
|