@dxos/functions-runtime-cloudflare 0.8.4-main.422d1c7879 → 0.8.4-main.51f1e5ca51
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 +21 -131
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +21 -131
- 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.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/wrap-handler-for-cloudflare.ts +1 -1
|
@@ -15,6 +15,7 @@ import { log } from "@dxos/log";
|
|
|
15
15
|
var copyUint8Array = (value) => new Uint8Array(value);
|
|
16
16
|
|
|
17
17
|
// src/internal/data-service-impl.ts
|
|
18
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/data-service-impl.ts";
|
|
18
19
|
function _ts_add_disposable_resource(env, value, async) {
|
|
19
20
|
if (value !== null && value !== void 0) {
|
|
20
21
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
@@ -80,7 +81,6 @@ function _ts_dispose_resources(env) {
|
|
|
80
81
|
return next();
|
|
81
82
|
})(env);
|
|
82
83
|
}
|
|
83
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/data-service-impl.ts";
|
|
84
84
|
var DataServiceImpl = class {
|
|
85
85
|
_executionContext;
|
|
86
86
|
_dataService;
|
|
@@ -91,15 +91,7 @@ var DataServiceImpl = class {
|
|
|
91
91
|
}
|
|
92
92
|
subscribe({ subscriptionId, spaceId }) {
|
|
93
93
|
return new Stream(({ next }) => {
|
|
94
|
-
invariant(SpaceId.isValid(spaceId), void 0, {
|
|
95
|
-
F: __dxlog_file,
|
|
96
|
-
L: 39,
|
|
97
|
-
S: this,
|
|
98
|
-
A: [
|
|
99
|
-
"SpaceId.isValid(spaceId)",
|
|
100
|
-
""
|
|
101
|
-
]
|
|
102
|
-
});
|
|
94
|
+
invariant(SpaceId.isValid(spaceId), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 86, S: this, A: ["SpaceId.isValid(spaceId)", ""] });
|
|
103
95
|
this.dataSubscriptions.set(subscriptionId, {
|
|
104
96
|
spaceId,
|
|
105
97
|
next
|
|
@@ -119,12 +111,7 @@ var DataServiceImpl = class {
|
|
|
119
111
|
if (addIds) {
|
|
120
112
|
log.info("request documents", {
|
|
121
113
|
count: addIds.length
|
|
122
|
-
}, {
|
|
123
|
-
F: __dxlog_file,
|
|
124
|
-
L: 59,
|
|
125
|
-
S: this,
|
|
126
|
-
C: (f, a) => f(...a)
|
|
127
|
-
});
|
|
114
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 104, S: this });
|
|
128
115
|
for (const documentId of addIds) {
|
|
129
116
|
const env = {
|
|
130
117
|
stack: [],
|
|
@@ -137,21 +124,11 @@ var DataServiceImpl = class {
|
|
|
137
124
|
documentId,
|
|
138
125
|
spaceId: sub.spaceId,
|
|
139
126
|
found: !!document
|
|
140
|
-
}, {
|
|
141
|
-
F: __dxlog_file,
|
|
142
|
-
L: 63,
|
|
143
|
-
S: this,
|
|
144
|
-
C: (f, a) => f(...a)
|
|
145
|
-
});
|
|
127
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 116, S: this });
|
|
146
128
|
if (!document) {
|
|
147
129
|
log.warn("not found", {
|
|
148
130
|
documentId
|
|
149
|
-
}, {
|
|
150
|
-
F: __dxlog_file,
|
|
151
|
-
L: 65,
|
|
152
|
-
S: this,
|
|
153
|
-
C: (f, a) => f(...a)
|
|
154
|
-
});
|
|
131
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 122, S: this });
|
|
155
132
|
continue;
|
|
156
133
|
}
|
|
157
134
|
sub.next({
|
|
@@ -180,15 +157,7 @@ var DataServiceImpl = class {
|
|
|
180
157
|
hasError: false
|
|
181
158
|
};
|
|
182
159
|
try {
|
|
183
|
-
invariant(SpaceId.isValid(spaceId), void 0, {
|
|
184
|
-
F: __dxlog_file,
|
|
185
|
-
L: 83,
|
|
186
|
-
S: this,
|
|
187
|
-
A: [
|
|
188
|
-
"SpaceId.isValid(spaceId)",
|
|
189
|
-
""
|
|
190
|
-
]
|
|
191
|
-
});
|
|
160
|
+
invariant(SpaceId.isValid(spaceId), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 153, S: this, A: ["SpaceId.isValid(spaceId)", ""] });
|
|
192
161
|
const response = _ts_add_disposable_resource(env, await this._dataService.createDocument(this._executionContext, spaceId, initialValue), false);
|
|
193
162
|
return {
|
|
194
163
|
documentId: response.documentId
|
|
@@ -239,12 +208,7 @@ var DataServiceImpl = class {
|
|
|
239
208
|
});
|
|
240
209
|
}
|
|
241
210
|
async updateIndexes() {
|
|
242
|
-
log.error("updateIndexes is not available in EDGE env.", void 0, {
|
|
243
|
-
F: __dxlog_file,
|
|
244
|
-
L: 134,
|
|
245
|
-
S: this,
|
|
246
|
-
C: (f, a) => f(...a)
|
|
247
|
-
});
|
|
211
|
+
log.error("updateIndexes is not available in EDGE env.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 206, S: this });
|
|
248
212
|
}
|
|
249
213
|
async waitUntilHeadsReplicated({ heads: _heads }) {
|
|
250
214
|
throw new NotImplementedError({
|
|
@@ -257,6 +221,7 @@ var DataServiceImpl = class {
|
|
|
257
221
|
import { Stream as Stream2 } from "@dxos/codec-protobuf/stream";
|
|
258
222
|
import { NotImplementedError as NotImplementedError2, RuntimeServiceError as RuntimeServiceError2 } from "@dxos/errors";
|
|
259
223
|
import { log as log2 } from "@dxos/log";
|
|
224
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/query-service-impl.ts";
|
|
260
225
|
function _ts_add_disposable_resource2(env, value, async) {
|
|
261
226
|
if (value !== null && value !== void 0) {
|
|
262
227
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
@@ -322,7 +287,6 @@ function _ts_dispose_resources2(env) {
|
|
|
322
287
|
return next();
|
|
323
288
|
})(env);
|
|
324
289
|
}
|
|
325
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/query-service-impl.ts";
|
|
326
290
|
var QueryServiceImpl = class {
|
|
327
291
|
_executionContext;
|
|
328
292
|
_dataService;
|
|
@@ -334,12 +298,7 @@ var QueryServiceImpl = class {
|
|
|
334
298
|
execQuery(request) {
|
|
335
299
|
log2.info("execQuery", {
|
|
336
300
|
request
|
|
337
|
-
}, {
|
|
338
|
-
F: __dxlog_file2,
|
|
339
|
-
L: 20,
|
|
340
|
-
S: this,
|
|
341
|
-
C: (f, a) => f(...a)
|
|
342
|
-
});
|
|
301
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 81, S: this });
|
|
343
302
|
return Stream2.fromPromise((async () => {
|
|
344
303
|
try {
|
|
345
304
|
const env = {
|
|
@@ -351,21 +310,11 @@ var QueryServiceImpl = class {
|
|
|
351
310
|
this._queryCount++;
|
|
352
311
|
log2.info("begin query", {
|
|
353
312
|
request
|
|
354
|
-
}, {
|
|
355
|
-
F: __dxlog_file2,
|
|
356
|
-
L: 26,
|
|
357
|
-
S: this,
|
|
358
|
-
C: (f, a) => f(...a)
|
|
359
|
-
});
|
|
313
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 93, S: this });
|
|
360
314
|
const queryResponse = _ts_add_disposable_resource2(env, await this._dataService.execQuery(this._executionContext, request), false);
|
|
361
315
|
log2.info("query response", {
|
|
362
316
|
resultCount: queryResponse.results?.length
|
|
363
|
-
}, {
|
|
364
|
-
F: __dxlog_file2,
|
|
365
|
-
L: 28,
|
|
366
|
-
S: this,
|
|
367
|
-
C: (f, a) => f(...a)
|
|
368
|
-
});
|
|
317
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 97, S: this });
|
|
369
318
|
return structuredClone(queryResponse);
|
|
370
319
|
} catch (e) {
|
|
371
320
|
env.error = e;
|
|
@@ -376,12 +325,7 @@ var QueryServiceImpl = class {
|
|
|
376
325
|
} catch (error) {
|
|
377
326
|
log2.error("query failed", {
|
|
378
327
|
err: error
|
|
379
|
-
}, {
|
|
380
|
-
F: __dxlog_file2,
|
|
381
|
-
L: 31,
|
|
382
|
-
S: this,
|
|
383
|
-
C: (f, a) => f(...a)
|
|
384
|
-
});
|
|
328
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 108, S: this });
|
|
385
329
|
throw new RuntimeServiceError2({
|
|
386
330
|
message: `Query execution failed (queryCount=${this._queryCount})`,
|
|
387
331
|
context: {
|
|
@@ -740,12 +684,7 @@ var QueuesAPIImpl = class {
|
|
|
740
684
|
log3.verbose("queue object JSON parse failed; object ignored", {
|
|
741
685
|
encoded,
|
|
742
686
|
error: err
|
|
743
|
-
}, {
|
|
744
|
-
F: __dxlog_file3,
|
|
745
|
-
L: 42,
|
|
746
|
-
S: this,
|
|
747
|
-
C: (f, a) => f(...a)
|
|
748
|
-
});
|
|
687
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 22, S: this });
|
|
749
688
|
return [];
|
|
750
689
|
}
|
|
751
690
|
});
|
|
@@ -776,30 +715,14 @@ var SpaceProxy = class extends Resource {
|
|
|
776
715
|
return this._id;
|
|
777
716
|
}
|
|
778
717
|
get db() {
|
|
779
|
-
invariant2(this._db, void 0, {
|
|
780
|
-
F: __dxlog_file4,
|
|
781
|
-
L: 35,
|
|
782
|
-
S: this,
|
|
783
|
-
A: [
|
|
784
|
-
"this._db",
|
|
785
|
-
""
|
|
786
|
-
]
|
|
787
|
-
});
|
|
718
|
+
invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 24, S: this, A: ["this._db", ""] });
|
|
788
719
|
return this._db;
|
|
789
720
|
}
|
|
790
721
|
/**
|
|
791
722
|
* @deprecated Use db API.
|
|
792
723
|
*/
|
|
793
724
|
get crud() {
|
|
794
|
-
invariant2(this._db, void 0, {
|
|
795
|
-
F: __dxlog_file4,
|
|
796
|
-
L: 43,
|
|
797
|
-
S: this,
|
|
798
|
-
A: [
|
|
799
|
-
"this._db",
|
|
800
|
-
""
|
|
801
|
-
]
|
|
802
|
-
});
|
|
725
|
+
invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 30, S: this, A: ["this._db", ""] });
|
|
803
726
|
return this._db.coreDatabase;
|
|
804
727
|
}
|
|
805
728
|
get queues() {
|
|
@@ -831,24 +754,8 @@ var FunctionsClient = class extends Resource2 {
|
|
|
831
754
|
_spaces = /* @__PURE__ */ new Map();
|
|
832
755
|
constructor(services) {
|
|
833
756
|
super();
|
|
834
|
-
invariant3(typeof services.dataService !== "undefined", "DataService is required", {
|
|
835
|
-
|
|
836
|
-
L: 33,
|
|
837
|
-
S: this,
|
|
838
|
-
A: [
|
|
839
|
-
"typeof services.dataService !== 'undefined'",
|
|
840
|
-
"'DataService is required'"
|
|
841
|
-
]
|
|
842
|
-
});
|
|
843
|
-
invariant3(typeof services.queueService !== "undefined", "QueueService is required", {
|
|
844
|
-
F: __dxlog_file5,
|
|
845
|
-
L: 34,
|
|
846
|
-
S: this,
|
|
847
|
-
A: [
|
|
848
|
-
"typeof services.queueService !== 'undefined'",
|
|
849
|
-
"'QueueService is required'"
|
|
850
|
-
]
|
|
851
|
-
});
|
|
757
|
+
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'"] });
|
|
758
|
+
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'"] });
|
|
852
759
|
this._serviceContainer = new ServiceContainer(this._executionContext, services.dataService, services.queueService, services.functionsAiService);
|
|
853
760
|
this._echoClient = new EchoClient({});
|
|
854
761
|
}
|
|
@@ -927,12 +834,7 @@ var wrapHandlerForCloudflare = (func) => {
|
|
|
927
834
|
log4.error("error invoking function", {
|
|
928
835
|
error,
|
|
929
836
|
stack: error.stack
|
|
930
|
-
}, {
|
|
931
|
-
F: __dxlog_file6,
|
|
932
|
-
L: 44,
|
|
933
|
-
S: void 0,
|
|
934
|
-
C: (f, a) => f(...a)
|
|
935
|
-
});
|
|
837
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 37, S: void 0 });
|
|
936
838
|
return EdgeResponse.failure({
|
|
937
839
|
message: error?.message ?? "Internal error",
|
|
938
840
|
error
|
|
@@ -965,12 +867,7 @@ var decodeRequest = async (request) => {
|
|
|
965
867
|
}
|
|
966
868
|
};
|
|
967
869
|
} catch (err) {
|
|
968
|
-
log4.catch(err, void 0, {
|
|
969
|
-
F: __dxlog_file6,
|
|
970
|
-
L: 79,
|
|
971
|
-
S: void 0,
|
|
972
|
-
C: (f, a) => f(...a)
|
|
973
|
-
});
|
|
870
|
+
log4.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 76, S: void 0 });
|
|
974
871
|
return {
|
|
975
872
|
data: {
|
|
976
873
|
bodyText,
|
|
@@ -1003,15 +900,7 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
|
|
|
1003
900
|
throw new Error(`Space not found: ${contextSpaceId}`);
|
|
1004
901
|
}
|
|
1005
902
|
spaceKey = meta.spaceKey;
|
|
1006
|
-
invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, {
|
|
1007
|
-
F: __dxlog_file6,
|
|
1008
|
-
L: 117,
|
|
1009
|
-
S: void 0,
|
|
1010
|
-
A: [
|
|
1011
|
-
"!meta.rootDocumentId.startsWith('automerge:')",
|
|
1012
|
-
""
|
|
1013
|
-
]
|
|
1014
|
-
});
|
|
903
|
+
invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 109, S: void 0, A: ["!meta.rootDocumentId.startsWith('automerge:')", ""] });
|
|
1015
904
|
rootUrl = `automerge:${meta.rootDocumentId}`;
|
|
1016
905
|
}
|
|
1017
906
|
return {
|
|
@@ -1071,6 +960,7 @@ export {
|
|
|
1071
960
|
FunctionsClient,
|
|
1072
961
|
ServiceContainer,
|
|
1073
962
|
createClientFromEnv,
|
|
963
|
+
createFunctionContext,
|
|
1074
964
|
setupFunctionsLogger,
|
|
1075
965
|
wrapHandlerForCloudflare
|
|
1076
966
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/functions-client.ts", "../../../src/internal/data-service-impl.ts", "../../../src/internal/utils.ts", "../../../src/internal/query-service-impl.ts", "../../../src/internal/queue-service-impl.ts", "../../../src/internal/service-container.ts", "../../../src/space-proxy.ts", "../../../src/queues-api.ts", "../../../src/types.ts", "../../../src/wrap-handler-for-cloudflare.ts", "../../../src/logger.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Resource } from '@dxos/context';\nimport { EchoClient } from '@dxos/echo-db';\nimport { invariant } from '@dxos/invariant';\nimport { type SpaceId } from '@dxos/keys';\nimport { type EdgeFunctionEnv } from '@dxos/protocols';\n\nimport { ServiceContainer } from './internal';\nimport { SpaceProxy } from './space-proxy';\n\ntype Services = {\n dataService: EdgeFunctionEnv.DataService;\n queueService: EdgeFunctionEnv.QueueService;\n functionsAiService: EdgeFunctionEnv.FunctionsAiService;\n};\n\n/**\n * API for functions to integrate with ECHO and HALO.\n * @deprecated\n */\nexport class FunctionsClient extends Resource {\n private readonly _serviceContainer;\n private readonly _echoClient;\n private readonly _executionContext: EdgeFunctionEnv.TraceContext = {};\n\n private readonly _spaces = new Map<SpaceId, SpaceProxy>();\n\n constructor(services: Services) {\n super();\n invariant(typeof services.dataService !== 'undefined', 'DataService is required');\n invariant(typeof services.queueService !== 'undefined', 'QueueService is required');\n this._serviceContainer = new ServiceContainer(\n this._executionContext,\n services.dataService,\n services.queueService,\n services.functionsAiService,\n );\n this._echoClient = new EchoClient({});\n }\n\n get echo(): EchoClient {\n return this._echoClient;\n }\n\n protected override async _open() {\n const { dataService, queryService } = await this._serviceContainer.createServices();\n this._echoClient.connectToService({ dataService, queryService });\n await this._echoClient.open();\n }\n\n protected override async _close() {\n for (const space of this._spaces.values()) {\n await space.close();\n }\n this._spaces.clear();\n\n await this._echoClient.close();\n }\n\n async getSpace(spaceId: SpaceId): Promise<SpaceProxy> {\n if (!this._spaces.has(spaceId)) {\n const space = new SpaceProxy(this._serviceContainer, this._echoClient, spaceId);\n this._spaces.set(spaceId, space);\n }\n const space = this._spaces.get(spaceId)!;\n await space.open(); // No-op if already open.\n return space;\n }\n}\n\nexport const createClientFromEnv = async (env: any): Promise<FunctionsClient> => {\n const client = new FunctionsClient({\n dataService: env.DATA_SERVICE,\n queueService: env.QUEUE_SERVICE,\n functionsAiService: env.FUNCTIONS_AI_SERVICE,\n });\n await client.open();\n return client;\n};\n\n/**\n - Provides data access capabilities for user functions.\n - No real-time replication or reactive queries -- function receives a snapshot.\n - Function event contains the metadata but doesn't need to include the data.\n */\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { RequestOptions } from '@dxos/codec-protobuf';\nimport { Stream } from '@dxos/codec-protobuf/stream';\nimport { raise } from '@dxos/debug';\nimport { NotImplementedError, RuntimeServiceError } from '@dxos/errors';\nimport { invariant } from '@dxos/invariant';\nimport { SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { type EdgeFunctionEnv } from '@dxos/protocols';\nimport type {\n BatchedDocumentUpdates,\n CreateDocumentRequest,\n CreateDocumentResponse,\n DataService as DataServiceProto,\n GetDocumentHeadsRequest,\n GetDocumentHeadsResponse,\n GetSpaceSyncStateRequest,\n ReIndexHeadsRequest,\n SpaceSyncState,\n UpdateRequest,\n UpdateSubscriptionRequest,\n} from '@dxos/protocols/proto/dxos/echo/service';\n\nimport { copyUint8Array } from './utils';\n\nexport class DataServiceImpl implements DataServiceProto {\n private dataSubscriptions = new Map<string, { spaceId: SpaceId; next: (msg: BatchedDocumentUpdates) => void }>();\n\n constructor(\n private _executionContext: EdgeFunctionEnv.TraceContext,\n private _dataService: EdgeFunctionEnv.DataService,\n ) {}\n\n subscribe({ subscriptionId, spaceId }: { subscriptionId: string; spaceId: string }): Stream<BatchedDocumentUpdates> {\n return new Stream(({ next }) => {\n invariant(SpaceId.isValid(spaceId));\n this.dataSubscriptions.set(subscriptionId, { spaceId, next });\n\n return () => {\n this.dataSubscriptions.delete(subscriptionId);\n };\n });\n }\n\n async updateSubscription({ subscriptionId, addIds }: UpdateSubscriptionRequest): Promise<void> {\n const sub =\n this.dataSubscriptions.get(subscriptionId) ??\n raise(\n new RuntimeServiceError({\n message: 'Subscription not found.',\n context: { subscriptionId },\n }),\n );\n\n if (addIds) {\n log.info('request documents', { count: addIds.length });\n // TODO(dmaretskyi): Batch.\n for (const documentId of addIds) {\n using document = await this._dataService.getDocument(this._executionContext, sub.spaceId, documentId);\n log.info('document loaded', { documentId, spaceId: sub.spaceId, found: !!document });\n if (!document) {\n log.warn('not found', { documentId });\n continue;\n }\n sub.next({\n updates: [\n {\n documentId,\n // Copy returned object to avoid hanging RPC stub\n // See https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/\n mutation: copyUint8Array(document.data),\n },\n ],\n });\n }\n }\n }\n\n async createDocument({ spaceId, initialValue }: CreateDocumentRequest): Promise<CreateDocumentResponse> {\n invariant(SpaceId.isValid(spaceId));\n using response = await this._dataService.createDocument(this._executionContext, spaceId, initialValue);\n return { documentId: response.documentId };\n }\n\n async update({ updates, subscriptionId }: UpdateRequest): Promise<void> {\n const sub =\n this.dataSubscriptions.get(subscriptionId) ??\n raise(\n new RuntimeServiceError({\n message: 'Subscription not found.',\n context: { subscriptionId },\n }),\n );\n // TODO(dmaretskyi): Batch.\n try {\n for (const update of updates ?? []) {\n await this._dataService.changeDocument(this._executionContext, sub.spaceId, update.documentId, update.mutation);\n }\n } catch (error) {\n throw RuntimeServiceError.wrap({\n message: 'Failed to apply document updates.',\n context: { subscriptionId },\n ifTypeDiffers: true,\n })(error);\n }\n }\n\n async flush(): Promise<void> {\n // No-op.\n }\n\n subscribeSpaceSyncState(_request: GetSpaceSyncStateRequest, _options?: RequestOptions): Stream<SpaceSyncState> {\n throw new NotImplementedError({\n message: 'subscribeSpaceSyncState is not implemented.',\n });\n }\n\n async getDocumentHeads({ documentIds: _documentIds }: GetDocumentHeadsRequest): Promise<GetDocumentHeadsResponse> {\n throw new NotImplementedError({\n message: 'getDocumentHeads is not implemented.',\n });\n }\n\n async reIndexHeads({ documentIds: _documentIds }: ReIndexHeadsRequest): Promise<void> {\n throw new NotImplementedError({\n message: 'reIndexHeads is not implemented.',\n });\n }\n\n async updateIndexes(): Promise<void> {\n log.error('updateIndexes is not available in EDGE env.');\n // No-op.\n }\n\n async waitUntilHeadsReplicated({ heads: _heads }: { heads: any }): Promise<void> {\n throw new NotImplementedError({\n message: 'waitUntilHeadsReplicated is not implemented.',\n });\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nexport const copyUint8Array = (value: Uint8Array): Uint8Array => new Uint8Array(value);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Stream } from '@dxos/codec-protobuf/stream';\nimport { NotImplementedError, RuntimeServiceError } from '@dxos/errors';\nimport { log } from '@dxos/log';\nimport { type EdgeFunctionEnv } from '@dxos/protocols';\nimport { type QueryRequest, type QueryResponse, type QueryService } from '@dxos/protocols/proto/dxos/echo/query';\n\nexport class QueryServiceImpl implements QueryService {\n private _queryCount = 0;\n\n constructor(\n private readonly _executionContext: EdgeFunctionEnv.TraceContext,\n private readonly _dataService: EdgeFunctionEnv.DataService,\n ) {}\n\n execQuery(request: QueryRequest): Stream<QueryResponse> {\n log.info('execQuery', { request });\n\n return Stream.fromPromise<QueryResponse>(\n (async () => {\n try {\n this._queryCount++;\n log.info('begin query', { request });\n using queryResponse = await this._dataService.execQuery(this._executionContext, request);\n log.info('query response', { resultCount: queryResponse.results?.length });\n return structuredClone(queryResponse);\n } catch (error) {\n log.error('query failed', { err: error });\n throw new RuntimeServiceError({\n message: `Query execution failed (queryCount=${this._queryCount})`,\n context: { queryCount: this._queryCount },\n cause: error,\n });\n }\n })(),\n );\n }\n\n async reindex() {\n throw new NotImplementedError({\n message: 'Reindex is not implemented.',\n });\n }\n\n async setConfig() {\n throw new NotImplementedError({\n message: 'SetConfig is not implemented.',\n });\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { RuntimeServiceError } from '@dxos/errors';\nimport { type EdgeFunctionEnv, type FeedProtocol } from '@dxos/protocols';\n\nexport class QueueServiceImpl implements FeedProtocol.QueueService {\n constructor(\n protected _ctx: EdgeFunctionEnv.TraceContext,\n private readonly _queueService: EdgeFunctionEnv.QueueService,\n ) {}\n\n async queryQueue(request: FeedProtocol.QueryQueueRequest): Promise<FeedProtocol.QueryResult> {\n try {\n using result = await this._queueService.queryQueue(this._ctx, request);\n // Copy to avoid hanging RPC stub (Workers RPC lifecycle).\n return {\n objects: structuredClone(result.objects),\n nextCursor: result.nextCursor,\n prevCursor: result.prevCursor,\n };\n } catch (error) {\n const { query } = request;\n throw RuntimeServiceError.wrap({\n message: 'Queue query failed.',\n context: {\n subspaceTag: query?.queuesNamespace,\n spaceId: query?.spaceId,\n queueId: query?.queueIds?.[0],\n },\n ifTypeDiffers: true,\n })(error);\n }\n }\n\n async insertIntoQueue(request: FeedProtocol.InsertIntoQueueRequest): Promise<void> {\n try {\n using _ = await this._queueService.insertIntoQueue(this._ctx, request);\n } catch (error) {\n const { subspaceTag, spaceId, queueId } = request;\n throw RuntimeServiceError.wrap({\n message: 'Queue append failed.',\n context: { subspaceTag, spaceId, queueId },\n ifTypeDiffers: true,\n })(error);\n }\n }\n\n async deleteFromQueue(request: FeedProtocol.DeleteFromQueueRequest): Promise<void> {\n try {\n using _ = await this._queueService.deleteFromQueue(this._ctx, request);\n } catch (error) {\n const { subspaceTag, spaceId, queueId } = request;\n throw RuntimeServiceError.wrap({\n message: 'Queue delete failed.',\n context: { subspaceTag, spaceId, queueId },\n ifTypeDiffers: true,\n })(error);\n }\n }\n\n async syncQueue(_: FeedProtocol.SyncQueueRequest): Promise<void> {\n // No-op in Cloudflare runtime.\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type AnyEntity } from '@dxos/echo/internal';\nimport { type DXN, type SpaceId } from '@dxos/keys';\nimport { type EdgeFunctionEnv, type FeedProtocol } from '@dxos/protocols';\nimport { type QueryService as QueryServiceProto } from '@dxos/protocols/proto/dxos/echo/query';\nimport type { DataService as DataServiceProto } from '@dxos/protocols/proto/dxos/echo/service';\n\nimport { DataServiceImpl } from './data-service-impl';\nimport { QueryServiceImpl } from './query-service-impl';\nimport { QueueServiceImpl } from './queue-service-impl';\n\n/**\n * TODO: make this implement DataService and QueryService to unify API over edge and web backend\n */\nexport class ServiceContainer {\n constructor(\n private readonly _executionContext: EdgeFunctionEnv.TraceContext,\n private readonly _dataService: EdgeFunctionEnv.DataService,\n private readonly _queueService: EdgeFunctionEnv.QueueService,\n private readonly _functionsService: EdgeFunctionEnv.FunctionsAiService,\n ) {}\n\n async getSpaceMeta(spaceId: SpaceId): Promise<EdgeFunctionEnv.SpaceMeta | undefined> {\n using result = await this._dataService.getSpaceMeta(this._executionContext, spaceId);\n // Copy returned object to avoid hanging RPC stub\n // See https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/\n return result\n ? {\n spaceKey: result.spaceKey,\n rootDocumentId: result.rootDocumentId,\n }\n : undefined;\n }\n\n async createServices(): Promise<{\n dataService: DataServiceProto;\n queryService: QueryServiceProto;\n queueService: FeedProtocol.QueueService;\n functionsAiService: EdgeFunctionEnv.FunctionsAiService;\n }> {\n const dataService = new DataServiceImpl(this._executionContext, this._dataService);\n const queryService = new QueryServiceImpl(this._executionContext, this._dataService);\n const queueService = new QueueServiceImpl(this._executionContext, this._queueService);\n\n return {\n dataService,\n queryService,\n queueService,\n functionsAiService: this._functionsService,\n };\n }\n\n async queryQueue(queue: DXN): Promise<FeedProtocol.QueryResult> {\n const parts = queue.asQueueDXN();\n if (!parts) {\n throw new Error('Invalid queue DXN');\n }\n const { subspaceTag, spaceId, queueId } = parts;\n const result = await this._queueService.queryQueue(this._executionContext, {\n query: {\n spaceId,\n queuesNamespace: subspaceTag,\n queueIds: [queueId],\n },\n });\n return {\n objects: structuredClone(result.objects),\n nextCursor: result.nextCursor ?? null,\n prevCursor: result.prevCursor ?? null,\n };\n }\n\n async insertIntoQueue(queue: DXN, objects: AnyEntity[]): Promise<void> {\n const parts = queue.asQueueDXN();\n if (!parts) {\n throw new Error('Invalid queue DXN');\n }\n const { subspaceTag, spaceId, queueId } = parts;\n await this._queueService.insertIntoQueue(this._executionContext, {\n subspaceTag,\n spaceId,\n queueId,\n objects: objects.map((obj) => JSON.stringify(obj)),\n });\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Resource } from '@dxos/context';\nimport { type Database } from '@dxos/echo';\nimport { type CoreDatabase, type EchoClient, type EchoDatabaseImpl } from '@dxos/echo-db';\nimport { invariant } from '@dxos/invariant';\nimport { PublicKey, type SpaceId } from '@dxos/keys';\n\nimport type { ServiceContainer } from './internal';\nimport { type QueuesAPI, QueuesAPIImpl } from './queues-api';\n\n/**\n * @deprecated\n */\nexport class SpaceProxy extends Resource {\n private _db?: EchoDatabaseImpl = undefined;\n private _queuesApi: QueuesAPIImpl;\n\n constructor(\n private readonly _serviceContainer: ServiceContainer,\n private readonly _echoClient: EchoClient,\n private readonly _id: SpaceId,\n ) {\n super();\n this._queuesApi = new QueuesAPIImpl(this._serviceContainer, this._id);\n }\n\n get id(): SpaceId {\n return this._id;\n }\n\n get db(): Database.Database {\n invariant(this._db);\n return this._db;\n }\n\n /**\n * @deprecated Use db API.\n */\n get crud(): CoreDatabase {\n invariant(this._db);\n return this._db.coreDatabase;\n }\n\n get queues(): QueuesAPI {\n return this._queuesApi;\n }\n\n protected override async _open() {\n const meta = await this._serviceContainer.getSpaceMeta(this._id);\n if (!meta) {\n throw new Error(`Space not found: ${this._id}`);\n }\n\n this._db = this._echoClient.constructDatabase({\n spaceId: this._id,\n spaceKey: PublicKey.from(meta.spaceKey),\n reactiveSchemaQuery: false,\n owningObject: this,\n });\n\n await this._db.coreDatabase.open(this._ctx, { rootUrl: meta.rootDocumentId });\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type AnyEntity } from '@dxos/echo/internal';\nimport type { DXN, SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\n\nimport type { ServiceContainer } from './internal';\n\nexport interface QueuesQueryResult {\n objects: AnyEntity[];\n nextCursor: string | null;\n prevCursor: string | null;\n}\n\n// TODO(dmaretskyi): Temporary API to get the queues working.\n// TODO(dmaretskyi): To be replaced with integrating queues into echo.\n/**\n * @deprecated\n */\nexport interface QueuesAPI {\n queryQueue(queue: DXN, options?: {}): Promise<QueuesQueryResult>;\n insertIntoQueue(queue: DXN, objects: AnyEntity[]): Promise<void>;\n}\n\n/**\n * @deprecated\n */\nexport class QueuesAPIImpl implements QueuesAPI {\n constructor(\n private readonly _serviceContainer: ServiceContainer,\n private readonly _spaceId: SpaceId,\n ) {}\n\n async queryQueue(queue: DXN, options?: {}): Promise<QueuesQueryResult> {\n const result = await this._serviceContainer.queryQueue(queue);\n const objects = (result.objects ?? []).flatMap((encoded): AnyEntity[] => {\n try {\n return [JSON.parse(encoded) as AnyEntity];\n } catch (err) {\n log.verbose('queue object JSON parse failed; object ignored', { encoded, error: err });\n return [];\n }\n });\n return {\n objects,\n nextCursor: result.nextCursor ?? null,\n prevCursor: result.prevCursor ?? null,\n };\n }\n\n insertIntoQueue(queue: DXN, objects: AnyEntity[]): Promise<void> {\n // TODO(dmaretskyi): Ugly.\n return this._serviceContainer.insertIntoQueue(queue, JSON.parse(JSON.stringify(objects)));\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { JsonSchemaType } from '@dxos/echo/internal';\n\n/**\n * Is used for to route the request to the metadata handler instead of the main handler.\n */\nexport const FUNCTION_ROUTE_HEADER = 'X-DXOS-Function-Route';\n\nexport enum FunctionRouteValue {\n Meta = 'meta',\n}\n\nexport type FunctionMetadata = {\n /**\n * FQN.\n */\n key: string;\n /**\n * Human-readable name.\n */\n name?: string;\n\n /**\n * Description.\n */\n description?: string;\n\n /**\n * Input schema.\n */\n inputSchema?: JsonSchemaType;\n\n /**\n * Output schema.\n */\n outputSchema?: JsonSchemaType;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { JsonSchemaType } from '@dxos/echo/internal';\nimport { invariant } from '@dxos/invariant';\nimport { SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { EdgeResponse } from '@dxos/protocols';\nimport type { EdgeFunctionEnv, FunctionProtocol } from '@dxos/protocols';\n\nimport { ServiceContainer } from './internal';\nimport { FUNCTION_ROUTE_HEADER, type FunctionMetadata, FunctionRouteValue } from './types';\n\n/**\n * Wraps a user function in a Cloudflare-compatible handler.\n */\nexport const wrapHandlerForCloudflare = (func: FunctionProtocol.Func): ExportedHandlerFetchHandler<any> => {\n return async (request: Request, env: EdgeFunctionEnv.Env): Promise<Response> => {\n // TODO(dmaretskyi): Should theÓ scope name reflect the function name?\n // TODO(mykola): Wrap in withCleanAutomergeWasmState;\n // TODO(mykola): Wrap in withNewExecutionContext;\n // Meta route is used to get the input schema of the function by the functions service.\n if (request.headers.get(FUNCTION_ROUTE_HEADER) === FunctionRouteValue.Meta) {\n return handleFunctionMetaCall(func, request);\n }\n\n try {\n const spaceId = new URL(request.url).searchParams.get('spaceId');\n if (spaceId) {\n if (!SpaceId.isValid(spaceId)) {\n return new Response('Invalid spaceId', { status: 400 });\n }\n }\n\n const serviceContainer = new ServiceContainer({}, env.DATA_SERVICE, env.QUEUE_SERVICE, env.FUNCTIONS_AI_SERVICE);\n const context = await createFunctionContext({\n serviceContainer,\n contextSpaceId: spaceId as SpaceId | undefined,\n });\n\n return EdgeResponse.success(await invokeFunction(func, context, request));\n } catch (error: any) {\n log.error('error invoking function', { error, stack: error.stack });\n return EdgeResponse.failure({\n message: error?.message ?? 'Internal error',\n error,\n });\n }\n };\n};\n\nconst invokeFunction = async (func: FunctionProtocol.Func, context: FunctionProtocol.Context, request: Request) => {\n // TODO(dmaretskyi): For some reason requests get wrapped like this.\n const { data } = await decodeRequest(request);\n\n return func.handler({\n context,\n data,\n });\n};\n\nconst decodeRequest = async (request: Request) => {\n const {\n data: { bodyText, ...rest },\n trigger,\n } = (await request.json()) as any;\n\n if (!bodyText) {\n return { data: rest, trigger };\n }\n\n // Webhook passed body as bodyText. Use it as function input if a well-formatted JSON\n // TODO: better trigger input mapping\n try {\n const data = JSON.parse(bodyText);\n return { data, trigger: { ...trigger, ...rest } };\n } catch (err) {\n log.catch(err);\n return { data: { bodyText, ...rest } };\n }\n};\n\nconst handleFunctionMetaCall = (functionDefinition: FunctionProtocol.Func, request: Request): Response => {\n const response: FunctionMetadata = {\n key: functionDefinition.meta.key,\n name: functionDefinition.meta.name,\n description: functionDefinition.meta.description,\n inputSchema: functionDefinition.meta.inputSchema as JsonSchemaType | undefined,\n outputSchema: functionDefinition.meta.outputSchema as JsonSchemaType | undefined,\n };\n\n return new Response(JSON.stringify(response), {\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n};\n\nconst createFunctionContext = async ({\n serviceContainer,\n contextSpaceId,\n}: {\n serviceContainer: ServiceContainer;\n contextSpaceId: SpaceId | undefined;\n}): Promise<FunctionProtocol.Context> => {\n const { dataService, queryService, queueService, functionsAiService } = await serviceContainer.createServices();\n\n let spaceKey: string | undefined;\n let rootUrl: string | undefined;\n if (contextSpaceId) {\n const meta = await serviceContainer.getSpaceMeta(contextSpaceId);\n if (!meta) {\n throw new Error(`Space not found: ${contextSpaceId}`);\n }\n spaceKey = meta.spaceKey;\n invariant(!meta.rootDocumentId.startsWith('automerge:'));\n rootUrl = `automerge:${meta.rootDocumentId}`;\n }\n\n return {\n services: {\n dataService,\n queryService,\n queueService,\n functionsAiService,\n },\n spaceId: contextSpaceId,\n spaceKey,\n spaceRootUrl: rootUrl,\n } as any; // TODO(dmaretskyi): Link and fix before merging\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\n/* eslint-disable no-console */\n\nimport { LogLevel, type LogProcessor, log, shouldLog } from '@dxos/log';\n\nexport const setupFunctionsLogger = () => {\n log.runtimeConfig.processors.length = 0;\n log.runtimeConfig.processors.push(functionLogProcessor);\n};\n\nconst functionLogProcessor: LogProcessor = (config, entry) => {\n if (!shouldLog(entry, config.filters)) {\n return;\n }\n\n const context = entry.computedContext;\n const error = entry.computedError;\n const extras = [Object.keys(context).length > 0 ? context : undefined, error].filter((value) => value !== undefined);\n\n switch (entry.level) {\n case LogLevel.DEBUG:\n case LogLevel.TRACE:\n console.debug(entry.message, ...extras);\n break;\n case LogLevel.VERBOSE:\n console.log(entry.message, ...extras);\n break;\n case LogLevel.INFO:\n console.info(entry.message, ...extras);\n break;\n case LogLevel.WARN:\n console.warn(entry.message, ...extras);\n break;\n case LogLevel.ERROR:\n console.error(entry.message, ...extras);\n break;\n default:\n console.log(entry.message, ...extras);\n break;\n }\n};\n"],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EAC5C;AAEA,SAAO;IACLE,UAAU;MACRZ;MACAC;MACAC;MACAC;IACF;IACA/C,SAASe;IACTkC;IACAQ,cAAcP;EAChB;AACF;;;AC7HA,SAASQ,UAA6BC,OAAAA,MAAKC,iBAAiB;AAErD,IAAMC,uBAAuB,MAAA;AAClCC,EAAAA,KAAIC,cAAcC,WAAWC,SAAS;AACtCH,EAAAA,KAAIC,cAAcC,WAAWE,KAAKC,oBAAAA;AACpC;AAEA,IAAMA,uBAAqC,CAACC,QAAQC,UAAAA;AAClD,MAAI,CAACC,UAAUD,OAAOD,OAAOG,OAAO,GAAG;AACrC;EACF;AAEA,QAAMC,UAAUH,MAAMI;AACtB,QAAMC,QAAQL,MAAMM;AACpB,QAAMC,SAAS;IAACC,OAAOC,KAAKN,OAAAA,EAASP,SAAS,IAAIO,UAAUO;IAAWL;IAAOM,OAAO,CAACC,UAAUA,UAAUF,MAAAA;AAE1G,UAAQV,MAAMa,OAAK;IACjB,KAAKC,SAASC;IACd,KAAKD,SAASE;AACZC,cAAQC,MAAMlB,MAAMmB,SAAO,GAAKZ,MAAAA;AAChC;IACF,KAAKO,SAASM;AACZH,cAAQxB,IAAIO,MAAMmB,SAAO,GAAKZ,MAAAA;AAC9B;IACF,KAAKO,SAASO;AACZJ,cAAQK,KAAKtB,MAAMmB,SAAO,GAAKZ,MAAAA;AAC/B;IACF,KAAKO,SAASS;AACZN,cAAQO,KAAKxB,MAAMmB,SAAO,GAAKZ,MAAAA;AAC/B;IACF,KAAKO,SAASW;AACZR,cAAQZ,MAAML,MAAMmB,SAAO,GAAKZ,MAAAA;AAChC;IACF;AACEU,cAAQxB,IAAIO,MAAMmB,SAAO,GAAKZ,MAAAA;AAC9B;EACJ;AACF;",
|
|
6
|
-
"names": ["Resource", "EchoClient", "invariant", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Resource } from '@dxos/context';\nimport { EchoClient } from '@dxos/echo-db';\nimport { invariant } from '@dxos/invariant';\nimport { type SpaceId } from '@dxos/keys';\nimport { type EdgeFunctionEnv } from '@dxos/protocols';\n\nimport { ServiceContainer } from './internal';\nimport { SpaceProxy } from './space-proxy';\n\ntype Services = {\n dataService: EdgeFunctionEnv.DataService;\n queueService: EdgeFunctionEnv.QueueService;\n functionsAiService: EdgeFunctionEnv.FunctionsAiService;\n};\n\n/**\n * API for functions to integrate with ECHO and HALO.\n * @deprecated\n */\nexport class FunctionsClient extends Resource {\n private readonly _serviceContainer;\n private readonly _echoClient;\n private readonly _executionContext: EdgeFunctionEnv.TraceContext = {};\n\n private readonly _spaces = new Map<SpaceId, SpaceProxy>();\n\n constructor(services: Services) {\n super();\n invariant(typeof services.dataService !== 'undefined', 'DataService is required');\n invariant(typeof services.queueService !== 'undefined', 'QueueService is required');\n this._serviceContainer = new ServiceContainer(\n this._executionContext,\n services.dataService,\n services.queueService,\n services.functionsAiService,\n );\n this._echoClient = new EchoClient({});\n }\n\n get echo(): EchoClient {\n return this._echoClient;\n }\n\n protected override async _open() {\n const { dataService, queryService } = await this._serviceContainer.createServices();\n this._echoClient.connectToService({ dataService, queryService });\n await this._echoClient.open();\n }\n\n protected override async _close() {\n for (const space of this._spaces.values()) {\n await space.close();\n }\n this._spaces.clear();\n\n await this._echoClient.close();\n }\n\n async getSpace(spaceId: SpaceId): Promise<SpaceProxy> {\n if (!this._spaces.has(spaceId)) {\n const space = new SpaceProxy(this._serviceContainer, this._echoClient, spaceId);\n this._spaces.set(spaceId, space);\n }\n const space = this._spaces.get(spaceId)!;\n await space.open(); // No-op if already open.\n return space;\n }\n}\n\nexport const createClientFromEnv = async (env: any): Promise<FunctionsClient> => {\n const client = new FunctionsClient({\n dataService: env.DATA_SERVICE,\n queueService: env.QUEUE_SERVICE,\n functionsAiService: env.FUNCTIONS_AI_SERVICE,\n });\n await client.open();\n return client;\n};\n\n/**\n - Provides data access capabilities for user functions.\n - No real-time replication or reactive queries -- function receives a snapshot.\n - Function event contains the metadata but doesn't need to include the data.\n */\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { RequestOptions } from '@dxos/codec-protobuf';\nimport { Stream } from '@dxos/codec-protobuf/stream';\nimport { raise } from '@dxos/debug';\nimport { NotImplementedError, RuntimeServiceError } from '@dxos/errors';\nimport { invariant } from '@dxos/invariant';\nimport { SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { type EdgeFunctionEnv } from '@dxos/protocols';\nimport type {\n BatchedDocumentUpdates,\n CreateDocumentRequest,\n CreateDocumentResponse,\n DataService as DataServiceProto,\n GetDocumentHeadsRequest,\n GetDocumentHeadsResponse,\n GetSpaceSyncStateRequest,\n ReIndexHeadsRequest,\n SpaceSyncState,\n UpdateRequest,\n UpdateSubscriptionRequest,\n} from '@dxos/protocols/proto/dxos/echo/service';\n\nimport { copyUint8Array } from './utils';\n\nexport class DataServiceImpl implements DataServiceProto {\n private dataSubscriptions = new Map<string, { spaceId: SpaceId; next: (msg: BatchedDocumentUpdates) => void }>();\n\n constructor(\n private _executionContext: EdgeFunctionEnv.TraceContext,\n private _dataService: EdgeFunctionEnv.DataService,\n ) {}\n\n subscribe({ subscriptionId, spaceId }: { subscriptionId: string; spaceId: string }): Stream<BatchedDocumentUpdates> {\n return new Stream(({ next }) => {\n invariant(SpaceId.isValid(spaceId));\n this.dataSubscriptions.set(subscriptionId, { spaceId, next });\n\n return () => {\n this.dataSubscriptions.delete(subscriptionId);\n };\n });\n }\n\n async updateSubscription({ subscriptionId, addIds }: UpdateSubscriptionRequest): Promise<void> {\n const sub =\n this.dataSubscriptions.get(subscriptionId) ??\n raise(\n new RuntimeServiceError({\n message: 'Subscription not found.',\n context: { subscriptionId },\n }),\n );\n\n if (addIds) {\n log.info('request documents', { count: addIds.length });\n // TODO(dmaretskyi): Batch.\n for (const documentId of addIds) {\n using document = await this._dataService.getDocument(this._executionContext, sub.spaceId, documentId);\n log.info('document loaded', { documentId, spaceId: sub.spaceId, found: !!document });\n if (!document) {\n log.warn('not found', { documentId });\n continue;\n }\n sub.next({\n updates: [\n {\n documentId,\n // Copy returned object to avoid hanging RPC stub\n // See https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/\n mutation: copyUint8Array(document.data),\n },\n ],\n });\n }\n }\n }\n\n async createDocument({ spaceId, initialValue }: CreateDocumentRequest): Promise<CreateDocumentResponse> {\n invariant(SpaceId.isValid(spaceId));\n using response = await this._dataService.createDocument(this._executionContext, spaceId, initialValue);\n return { documentId: response.documentId };\n }\n\n async update({ updates, subscriptionId }: UpdateRequest): Promise<void> {\n const sub =\n this.dataSubscriptions.get(subscriptionId) ??\n raise(\n new RuntimeServiceError({\n message: 'Subscription not found.',\n context: { subscriptionId },\n }),\n );\n // TODO(dmaretskyi): Batch.\n try {\n for (const update of updates ?? []) {\n await this._dataService.changeDocument(this._executionContext, sub.spaceId, update.documentId, update.mutation);\n }\n } catch (error) {\n throw RuntimeServiceError.wrap({\n message: 'Failed to apply document updates.',\n context: { subscriptionId },\n ifTypeDiffers: true,\n })(error);\n }\n }\n\n async flush(): Promise<void> {\n // No-op.\n }\n\n subscribeSpaceSyncState(_request: GetSpaceSyncStateRequest, _options?: RequestOptions): Stream<SpaceSyncState> {\n throw new NotImplementedError({\n message: 'subscribeSpaceSyncState is not implemented.',\n });\n }\n\n async getDocumentHeads({ documentIds: _documentIds }: GetDocumentHeadsRequest): Promise<GetDocumentHeadsResponse> {\n throw new NotImplementedError({\n message: 'getDocumentHeads is not implemented.',\n });\n }\n\n async reIndexHeads({ documentIds: _documentIds }: ReIndexHeadsRequest): Promise<void> {\n throw new NotImplementedError({\n message: 'reIndexHeads is not implemented.',\n });\n }\n\n async updateIndexes(): Promise<void> {\n log.error('updateIndexes is not available in EDGE env.');\n // No-op.\n }\n\n async waitUntilHeadsReplicated({ heads: _heads }: { heads: any }): Promise<void> {\n throw new NotImplementedError({\n message: 'waitUntilHeadsReplicated is not implemented.',\n });\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nexport const copyUint8Array = (value: Uint8Array): Uint8Array => new Uint8Array(value);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Stream } from '@dxos/codec-protobuf/stream';\nimport { NotImplementedError, RuntimeServiceError } from '@dxos/errors';\nimport { log } from '@dxos/log';\nimport { type EdgeFunctionEnv } from '@dxos/protocols';\nimport { type QueryRequest, type QueryResponse, type QueryService } from '@dxos/protocols/proto/dxos/echo/query';\n\nexport class QueryServiceImpl implements QueryService {\n private _queryCount = 0;\n\n constructor(\n private readonly _executionContext: EdgeFunctionEnv.TraceContext,\n private readonly _dataService: EdgeFunctionEnv.DataService,\n ) {}\n\n execQuery(request: QueryRequest): Stream<QueryResponse> {\n log.info('execQuery', { request });\n\n return Stream.fromPromise<QueryResponse>(\n (async () => {\n try {\n this._queryCount++;\n log.info('begin query', { request });\n using queryResponse = await this._dataService.execQuery(this._executionContext, request);\n log.info('query response', { resultCount: queryResponse.results?.length });\n return structuredClone(queryResponse);\n } catch (error) {\n log.error('query failed', { err: error });\n throw new RuntimeServiceError({\n message: `Query execution failed (queryCount=${this._queryCount})`,\n context: { queryCount: this._queryCount },\n cause: error,\n });\n }\n })(),\n );\n }\n\n async reindex() {\n throw new NotImplementedError({\n message: 'Reindex is not implemented.',\n });\n }\n\n async setConfig() {\n throw new NotImplementedError({\n message: 'SetConfig is not implemented.',\n });\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { RuntimeServiceError } from '@dxos/errors';\nimport { type EdgeFunctionEnv, type FeedProtocol } from '@dxos/protocols';\n\nexport class QueueServiceImpl implements FeedProtocol.QueueService {\n constructor(\n protected _ctx: EdgeFunctionEnv.TraceContext,\n private readonly _queueService: EdgeFunctionEnv.QueueService,\n ) {}\n\n async queryQueue(request: FeedProtocol.QueryQueueRequest): Promise<FeedProtocol.QueryResult> {\n try {\n using result = await this._queueService.queryQueue(this._ctx, request);\n // Copy to avoid hanging RPC stub (Workers RPC lifecycle).\n return {\n objects: structuredClone(result.objects),\n nextCursor: result.nextCursor,\n prevCursor: result.prevCursor,\n };\n } catch (error) {\n const { query } = request;\n throw RuntimeServiceError.wrap({\n message: 'Queue query failed.',\n context: {\n subspaceTag: query?.queuesNamespace,\n spaceId: query?.spaceId,\n queueId: query?.queueIds?.[0],\n },\n ifTypeDiffers: true,\n })(error);\n }\n }\n\n async insertIntoQueue(request: FeedProtocol.InsertIntoQueueRequest): Promise<void> {\n try {\n using _ = await this._queueService.insertIntoQueue(this._ctx, request);\n } catch (error) {\n const { subspaceTag, spaceId, queueId } = request;\n throw RuntimeServiceError.wrap({\n message: 'Queue append failed.',\n context: { subspaceTag, spaceId, queueId },\n ifTypeDiffers: true,\n })(error);\n }\n }\n\n async deleteFromQueue(request: FeedProtocol.DeleteFromQueueRequest): Promise<void> {\n try {\n using _ = await this._queueService.deleteFromQueue(this._ctx, request);\n } catch (error) {\n const { subspaceTag, spaceId, queueId } = request;\n throw RuntimeServiceError.wrap({\n message: 'Queue delete failed.',\n context: { subspaceTag, spaceId, queueId },\n ifTypeDiffers: true,\n })(error);\n }\n }\n\n async syncQueue(_: FeedProtocol.SyncQueueRequest): Promise<void> {\n // No-op in Cloudflare runtime.\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type AnyEntity } from '@dxos/echo/internal';\nimport { type DXN, type SpaceId } from '@dxos/keys';\nimport { type EdgeFunctionEnv, type FeedProtocol } from '@dxos/protocols';\nimport { type QueryService as QueryServiceProto } from '@dxos/protocols/proto/dxos/echo/query';\nimport type { DataService as DataServiceProto } from '@dxos/protocols/proto/dxos/echo/service';\n\nimport { DataServiceImpl } from './data-service-impl';\nimport { QueryServiceImpl } from './query-service-impl';\nimport { QueueServiceImpl } from './queue-service-impl';\n\n/**\n * TODO: make this implement DataService and QueryService to unify API over edge and web backend\n */\nexport class ServiceContainer {\n constructor(\n private readonly _executionContext: EdgeFunctionEnv.TraceContext,\n private readonly _dataService: EdgeFunctionEnv.DataService,\n private readonly _queueService: EdgeFunctionEnv.QueueService,\n private readonly _functionsService: EdgeFunctionEnv.FunctionsAiService,\n ) {}\n\n async getSpaceMeta(spaceId: SpaceId): Promise<EdgeFunctionEnv.SpaceMeta | undefined> {\n using result = await this._dataService.getSpaceMeta(this._executionContext, spaceId);\n // Copy returned object to avoid hanging RPC stub\n // See https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/\n return result\n ? {\n spaceKey: result.spaceKey,\n rootDocumentId: result.rootDocumentId,\n }\n : undefined;\n }\n\n async createServices(): Promise<{\n dataService: DataServiceProto;\n queryService: QueryServiceProto;\n queueService: FeedProtocol.QueueService;\n functionsAiService: EdgeFunctionEnv.FunctionsAiService;\n }> {\n const dataService = new DataServiceImpl(this._executionContext, this._dataService);\n const queryService = new QueryServiceImpl(this._executionContext, this._dataService);\n const queueService = new QueueServiceImpl(this._executionContext, this._queueService);\n\n return {\n dataService,\n queryService,\n queueService,\n functionsAiService: this._functionsService,\n };\n }\n\n async queryQueue(queue: DXN): Promise<FeedProtocol.QueryResult> {\n const parts = queue.asQueueDXN();\n if (!parts) {\n throw new Error('Invalid queue DXN');\n }\n const { subspaceTag, spaceId, queueId } = parts;\n const result = await this._queueService.queryQueue(this._executionContext, {\n query: {\n spaceId,\n queuesNamespace: subspaceTag,\n queueIds: [queueId],\n },\n });\n return {\n objects: structuredClone(result.objects),\n nextCursor: result.nextCursor ?? null,\n prevCursor: result.prevCursor ?? null,\n };\n }\n\n async insertIntoQueue(queue: DXN, objects: AnyEntity[]): Promise<void> {\n const parts = queue.asQueueDXN();\n if (!parts) {\n throw new Error('Invalid queue DXN');\n }\n const { subspaceTag, spaceId, queueId } = parts;\n await this._queueService.insertIntoQueue(this._executionContext, {\n subspaceTag,\n spaceId,\n queueId,\n objects: objects.map((obj) => JSON.stringify(obj)),\n });\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Resource } from '@dxos/context';\nimport { type Database } from '@dxos/echo';\nimport { type CoreDatabase, type EchoClient, type EchoDatabaseImpl } from '@dxos/echo-db';\nimport { invariant } from '@dxos/invariant';\nimport { PublicKey, type SpaceId } from '@dxos/keys';\n\nimport type { ServiceContainer } from './internal';\nimport { type QueuesAPI, QueuesAPIImpl } from './queues-api';\n\n/**\n * @deprecated\n */\nexport class SpaceProxy extends Resource {\n private _db?: EchoDatabaseImpl = undefined;\n private _queuesApi: QueuesAPIImpl;\n\n constructor(\n private readonly _serviceContainer: ServiceContainer,\n private readonly _echoClient: EchoClient,\n private readonly _id: SpaceId,\n ) {\n super();\n this._queuesApi = new QueuesAPIImpl(this._serviceContainer, this._id);\n }\n\n get id(): SpaceId {\n return this._id;\n }\n\n get db(): Database.Database {\n invariant(this._db);\n return this._db;\n }\n\n /**\n * @deprecated Use db API.\n */\n get crud(): CoreDatabase {\n invariant(this._db);\n return this._db.coreDatabase;\n }\n\n get queues(): QueuesAPI {\n return this._queuesApi;\n }\n\n protected override async _open() {\n const meta = await this._serviceContainer.getSpaceMeta(this._id);\n if (!meta) {\n throw new Error(`Space not found: ${this._id}`);\n }\n\n this._db = this._echoClient.constructDatabase({\n spaceId: this._id,\n spaceKey: PublicKey.from(meta.spaceKey),\n reactiveSchemaQuery: false,\n owningObject: this,\n });\n\n await this._db.coreDatabase.open(this._ctx, { rootUrl: meta.rootDocumentId });\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type AnyEntity } from '@dxos/echo/internal';\nimport type { DXN, SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\n\nimport type { ServiceContainer } from './internal';\n\nexport interface QueuesQueryResult {\n objects: AnyEntity[];\n nextCursor: string | null;\n prevCursor: string | null;\n}\n\n// TODO(dmaretskyi): Temporary API to get the queues working.\n// TODO(dmaretskyi): To be replaced with integrating queues into echo.\n/**\n * @deprecated\n */\nexport interface QueuesAPI {\n queryQueue(queue: DXN, options?: {}): Promise<QueuesQueryResult>;\n insertIntoQueue(queue: DXN, objects: AnyEntity[]): Promise<void>;\n}\n\n/**\n * @deprecated\n */\nexport class QueuesAPIImpl implements QueuesAPI {\n constructor(\n private readonly _serviceContainer: ServiceContainer,\n private readonly _spaceId: SpaceId,\n ) {}\n\n async queryQueue(queue: DXN, options?: {}): Promise<QueuesQueryResult> {\n const result = await this._serviceContainer.queryQueue(queue);\n const objects = (result.objects ?? []).flatMap((encoded): AnyEntity[] => {\n try {\n return [JSON.parse(encoded) as AnyEntity];\n } catch (err) {\n log.verbose('queue object JSON parse failed; object ignored', { encoded, error: err });\n return [];\n }\n });\n return {\n objects,\n nextCursor: result.nextCursor ?? null,\n prevCursor: result.prevCursor ?? null,\n };\n }\n\n insertIntoQueue(queue: DXN, objects: AnyEntity[]): Promise<void> {\n // TODO(dmaretskyi): Ugly.\n return this._serviceContainer.insertIntoQueue(queue, JSON.parse(JSON.stringify(objects)));\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { JsonSchemaType } from '@dxos/echo/internal';\n\n/**\n * Is used for to route the request to the metadata handler instead of the main handler.\n */\nexport const FUNCTION_ROUTE_HEADER = 'X-DXOS-Function-Route';\n\nexport enum FunctionRouteValue {\n Meta = 'meta',\n}\n\nexport type FunctionMetadata = {\n /**\n * FQN.\n */\n key: string;\n /**\n * Human-readable name.\n */\n name?: string;\n\n /**\n * Description.\n */\n description?: string;\n\n /**\n * Input schema.\n */\n inputSchema?: JsonSchemaType;\n\n /**\n * Output schema.\n */\n outputSchema?: JsonSchemaType;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { JsonSchemaType } from '@dxos/echo/internal';\nimport { invariant } from '@dxos/invariant';\nimport { SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { EdgeResponse } from '@dxos/protocols';\nimport type { EdgeFunctionEnv, FunctionProtocol } from '@dxos/protocols';\n\nimport { ServiceContainer } from './internal';\nimport { FUNCTION_ROUTE_HEADER, type FunctionMetadata, FunctionRouteValue } from './types';\n\n/**\n * Wraps a user function in a Cloudflare-compatible handler.\n */\nexport const wrapHandlerForCloudflare = (func: FunctionProtocol.Func): ExportedHandlerFetchHandler<any> => {\n return async (request: Request, env: EdgeFunctionEnv.Env): Promise<Response> => {\n // TODO(dmaretskyi): Should theÓ scope name reflect the function name?\n // TODO(mykola): Wrap in withCleanAutomergeWasmState;\n // TODO(mykola): Wrap in withNewExecutionContext;\n // Meta route is used to get the input schema of the function by the functions service.\n if (request.headers.get(FUNCTION_ROUTE_HEADER) === FunctionRouteValue.Meta) {\n return handleFunctionMetaCall(func, request);\n }\n\n try {\n const spaceId = new URL(request.url).searchParams.get('spaceId');\n if (spaceId) {\n if (!SpaceId.isValid(spaceId)) {\n return new Response('Invalid spaceId', { status: 400 });\n }\n }\n\n const serviceContainer = new ServiceContainer({}, env.DATA_SERVICE, env.QUEUE_SERVICE, env.FUNCTIONS_AI_SERVICE);\n const context = await createFunctionContext({\n serviceContainer,\n contextSpaceId: spaceId as SpaceId | undefined,\n });\n\n return EdgeResponse.success(await invokeFunction(func, context, request));\n } catch (error: any) {\n log.error('error invoking function', { error, stack: error.stack });\n return EdgeResponse.failure({\n message: error?.message ?? 'Internal error',\n error,\n });\n }\n };\n};\n\nconst invokeFunction = async (func: FunctionProtocol.Func, context: FunctionProtocol.Context, request: Request) => {\n // TODO(dmaretskyi): For some reason requests get wrapped like this.\n const { data } = await decodeRequest(request);\n\n return func.handler({\n context,\n data,\n });\n};\n\nconst decodeRequest = async (request: Request) => {\n const {\n data: { bodyText, ...rest },\n trigger,\n } = (await request.json()) as any;\n\n if (!bodyText) {\n return { data: rest, trigger };\n }\n\n // Webhook passed body as bodyText. Use it as function input if a well-formatted JSON\n // TODO: better trigger input mapping\n try {\n const data = JSON.parse(bodyText);\n return { data, trigger: { ...trigger, ...rest } };\n } catch (err) {\n log.catch(err);\n return { data: { bodyText, ...rest } };\n }\n};\n\nconst handleFunctionMetaCall = (functionDefinition: FunctionProtocol.Func, request: Request): Response => {\n const response: FunctionMetadata = {\n key: functionDefinition.meta.key,\n name: functionDefinition.meta.name,\n description: functionDefinition.meta.description,\n inputSchema: functionDefinition.meta.inputSchema as JsonSchemaType | undefined,\n outputSchema: functionDefinition.meta.outputSchema as JsonSchemaType | undefined,\n };\n\n return new Response(JSON.stringify(response), {\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n};\n\nexport const createFunctionContext = async ({\n serviceContainer,\n contextSpaceId,\n}: {\n serviceContainer: ServiceContainer;\n contextSpaceId: SpaceId | undefined;\n}): Promise<FunctionProtocol.Context> => {\n const { dataService, queryService, queueService, functionsAiService } = await serviceContainer.createServices();\n\n let spaceKey: string | undefined;\n let rootUrl: string | undefined;\n if (contextSpaceId) {\n const meta = await serviceContainer.getSpaceMeta(contextSpaceId);\n if (!meta) {\n throw new Error(`Space not found: ${contextSpaceId}`);\n }\n spaceKey = meta.spaceKey;\n invariant(!meta.rootDocumentId.startsWith('automerge:'));\n rootUrl = `automerge:${meta.rootDocumentId}`;\n }\n\n return {\n services: {\n dataService,\n queryService,\n queueService,\n functionsAiService,\n },\n spaceId: contextSpaceId,\n spaceKey,\n spaceRootUrl: rootUrl,\n } as any; // TODO(dmaretskyi): Link and fix before merging\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\n/* eslint-disable no-console */\n\nimport { LogLevel, type LogProcessor, log, shouldLog } from '@dxos/log';\n\nexport const setupFunctionsLogger = () => {\n log.runtimeConfig.processors.length = 0;\n log.runtimeConfig.processors.push(functionLogProcessor);\n};\n\nconst functionLogProcessor: LogProcessor = (config, entry) => {\n if (!shouldLog(entry, config.filters)) {\n return;\n }\n\n const context = entry.computedContext;\n const error = entry.computedError;\n const extras = [Object.keys(context).length > 0 ? context : undefined, error].filter((value) => value !== undefined);\n\n switch (entry.level) {\n case LogLevel.DEBUG:\n case LogLevel.TRACE:\n console.debug(entry.message, ...extras);\n break;\n case LogLevel.VERBOSE:\n console.log(entry.message, ...extras);\n break;\n case LogLevel.INFO:\n console.info(entry.message, ...extras);\n break;\n case LogLevel.WARN:\n console.warn(entry.message, ...extras);\n break;\n case LogLevel.ERROR:\n console.error(entry.message, ...ext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KC;AAClC,EAAAH,KAAA,cAAA,WAAA,SAAA;AAEF,EAAAA,KAAMG,cAAAA,WAAsCC,KAAQC,oBAAAA;;2BAEhD,CAAA,QAAA,UAAA;AACF,MAAA,CAAA,UAAA,OAAA,OAAA,OAAA,GAAA;AAEA;EACA;AACA,QAAMC,UAAS,MAAA;QAACC,QAAOC,MAAKC;QAA2CC,SAAAA;IAAOC,OAAQC,KAAAA,OAAUA,EAAAA,SAAUC,IAAAA,UAAAA;IAE1G;WACOC,CAAAA,UAASC,UAAK,MAAA;UACnB,MAAKD,OAASE;SACZC,SAAQC;SACR,SAAA;AACF,cAAKJ,MAASK,MAAO,SAAA,GAAA,MAAA;AACnBF;SACA,SAAA;AACF,cAAKH,IAASM,MAAI,SAAA,GAAA,MAAA;AAChBH;SACA,SAAA;AACF,cAAKH,KAASO,MAAI,SAAA,GAAA,MAAA;AAChBJ;SACA,SAAA;AACF,cAAKH,KAASQ,MAAK,SAAA,GAAA,MAAA;AACjBL;SACA,SAAA;AACF,cAAA,MAAA,MAAA,SAAA,GAAA,MAAA;AACEA;;AAEJ,cAAA,IAAA,MAAA,SAAA,GAAA,MAAA;AACF;;;",
|
|
6
|
+
"names": ["Resource", "EchoClient", "invariant", "raise", "NotImplementedError", "invariant", "SpaceId", "log", "copyUint8Array", "copyUint8Array", "value", "Uint8Array", "dataSubscriptions", "_executionContext", "_dataService", "subscribe", "next", "invariant", "SpaceId", "isValid", "spaceId", "subscriptionId", "message", "context", "log", "count", "info", "documentId", "found", "document", "sub", "updates", "response", "createDocument", "initialValue", "get", "changeDocument", "RuntimeServiceError", "ifTypeDiffers", "error", "subscribeSpaceSyncState", "NotImplementedError", "NotImplementedError", "log", "RuntimeServiceError", "QueryServiceImpl", "__dxlog_file", "_queryCount", "_executionContext", "_dataService", "execQuery", "info", "request", "fromPromise", "Stream", "queryResponse", "_ts_add_disposable_resource", "resultCount", "structuredClone", "error", "err", "message", "context", "queryCount", "cause", "RuntimeServiceError", "QueueServiceImpl", "_ctx", "_queueService", "queryQueue", "request", "result", "objects", "structuredClone", "nextCursor", "prevCursor", "error", "query", "wrap", "message", "context", "subspaceTag", "queuesNamespace", "spaceId", "queueId", "queueIds", "ifTypeDiffers", "insertIntoQueue", "_", "deleteFromQueue", "syncQueue", "ServiceContainer", "_executionContext", "_dataService", "_queueService", "_functionsService", "getSpaceMeta", "spaceId", "result", "spaceKey", "rootDocumentId", "undefined", "createServices", "dataService", "DataServiceImpl", "queryService", "QueryServiceImpl", "queueService", "QueueServiceImpl", "functionsAiService", "queryQueue", "queue", "parts", "asQueueDXN", "Error", "subspaceTag", "queueId", "query", "queuesNamespace", "queueIds", "objects", "structuredClone", "nextCursor", "prevCursor", "insertIntoQueue", "map", "obj", "JSON", "stringify", "Resource", "invariant", "PublicKey", "log", "__dxlog_file", "_spaceId", "queryQueue", "queue", "objects", "result", "err", "encoded", "error", "nextCursor", "prevCursor", "insertIntoQueue", "_serviceContainer", "__dxlog_file", "_db", "_queuesApi", "QueuesAPIImpl", "_serviceContainer", "id", "db", "invariant", "queues", "_open", "meta", "Error", "_echoClient", "constructDatabase", "spaceKey", "PublicKey", "reactiveSchemaQuery", "owningObject", "coreDatabase", "__dxlog_file", "_echoClient", "Resource", "_executionContext", "_spaces", "invariant", "services", "_serviceContainer", "ServiceContainer", "dataService", "queueService", "functionsAiService", "EchoClient", "echo", "_open", "queryService", "_close", "space", "clear", "getSpace", "spaceId", "set", "DATA_SERVICE", "env", "FUNCTION_ROUTE_HEADER", "FunctionRouteValue", "invariant", "SpaceId", "log", "EdgeResponse", "__dxlog_file", "SpaceId", "isValid", "spaceId", "status", "serviceContainer", "contextSpaceId", "success", "log", "error", "stack", "EdgeResponse", "message", "decodeRequest", "request", "context", "data", "rest", "trigger", "functionDefinition", "meta", "name", "description", "inputSchema", "outputSchema", "Response", "response", "spaceKey", "rootUrl", "Error", "invariant", "queryService", "queueService", "functionsAiService", "spaceRootUrl", "LogLevel", "log", "shouldLog", "log", "runtimeConfig", "push", "functionLogProcessor", "config", "entry", "extras", "Object", "keys", "context", "error", "filter", "value", "undefined", "LogLevel", "DEBUG", "TRACE", "console", "debug", "VERBOSE", "INFO", "WARN", "ERROR"]
|
|
7
7
|
}
|
|
@@ -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}}}
|