@dxos/functions-runtime-cloudflare 0.8.4-main.9be5663bfe → 0.8.4-main.abd8ff62ef
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +63 -144
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +63 -144
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/functions-client.d.ts.map +1 -1
- package/dist/types/src/internal/data-service-impl.d.ts.map +1 -1
- package/dist/types/src/internal/query-service-impl.d.ts.map +1 -1
- package/dist/types/src/internal/queue-service-impl.d.ts.map +1 -1
- package/dist/types/src/internal/service-container.d.ts.map +1 -1
- package/dist/types/src/internal/utils.d.ts.map +1 -1
- package/dist/types/src/queues-api.d.ts +7 -3
- package/dist/types/src/queues-api.d.ts.map +1 -1
- package/dist/types/src/space-proxy.d.ts.map +1 -1
- package/dist/types/src/wrap-handler-for-cloudflare.d.ts +6 -0
- package/dist/types/src/wrap-handler-for-cloudflare.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -14
- package/src/internal/service-container.ts +1 -1
- package/src/logger.ts +10 -8
- package/src/queues-api.ts +23 -4
- package/src/wrap-handler-for-cloudflare.ts +1 -1
|
@@ -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: {
|
|
@@ -709,7 +653,7 @@ var ServiceContainer = class {
|
|
|
709
653
|
subspaceTag,
|
|
710
654
|
spaceId,
|
|
711
655
|
queueId,
|
|
712
|
-
objects
|
|
656
|
+
objects: objects.map((obj) => JSON.stringify(obj))
|
|
713
657
|
});
|
|
714
658
|
}
|
|
715
659
|
};
|
|
@@ -720,6 +664,8 @@ import { invariant as invariant2 } from "@dxos/invariant";
|
|
|
720
664
|
import { PublicKey } from "@dxos/keys";
|
|
721
665
|
|
|
722
666
|
// src/queues-api.ts
|
|
667
|
+
import { log as log3 } from "@dxos/log";
|
|
668
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/queues-api.ts";
|
|
723
669
|
var QueuesAPIImpl = class {
|
|
724
670
|
_serviceContainer;
|
|
725
671
|
_spaceId;
|
|
@@ -727,8 +673,26 @@ var QueuesAPIImpl = class {
|
|
|
727
673
|
this._serviceContainer = _serviceContainer;
|
|
728
674
|
this._spaceId = _spaceId;
|
|
729
675
|
}
|
|
730
|
-
queryQueue(queue, options) {
|
|
731
|
-
|
|
676
|
+
async queryQueue(queue, options) {
|
|
677
|
+
const result = await this._serviceContainer.queryQueue(queue);
|
|
678
|
+
const objects = (result.objects ?? []).flatMap((encoded) => {
|
|
679
|
+
try {
|
|
680
|
+
return [
|
|
681
|
+
JSON.parse(encoded)
|
|
682
|
+
];
|
|
683
|
+
} catch (err) {
|
|
684
|
+
log3.verbose("queue object JSON parse failed; object ignored", {
|
|
685
|
+
encoded,
|
|
686
|
+
error: err
|
|
687
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 22, S: this });
|
|
688
|
+
return [];
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
return {
|
|
692
|
+
objects,
|
|
693
|
+
nextCursor: result.nextCursor ?? null,
|
|
694
|
+
prevCursor: result.prevCursor ?? null
|
|
695
|
+
};
|
|
732
696
|
}
|
|
733
697
|
insertIntoQueue(queue, objects) {
|
|
734
698
|
return this._serviceContainer.insertIntoQueue(queue, JSON.parse(JSON.stringify(objects)));
|
|
@@ -736,7 +700,7 @@ var QueuesAPIImpl = class {
|
|
|
736
700
|
};
|
|
737
701
|
|
|
738
702
|
// src/space-proxy.ts
|
|
739
|
-
var
|
|
703
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/space-proxy.ts";
|
|
740
704
|
var SpaceProxy = class extends Resource {
|
|
741
705
|
_serviceContainer;
|
|
742
706
|
_echoClient;
|
|
@@ -751,30 +715,14 @@ var SpaceProxy = class extends Resource {
|
|
|
751
715
|
return this._id;
|
|
752
716
|
}
|
|
753
717
|
get db() {
|
|
754
|
-
invariant2(this._db, void 0, {
|
|
755
|
-
F: __dxlog_file3,
|
|
756
|
-
L: 35,
|
|
757
|
-
S: this,
|
|
758
|
-
A: [
|
|
759
|
-
"this._db",
|
|
760
|
-
""
|
|
761
|
-
]
|
|
762
|
-
});
|
|
718
|
+
invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 24, S: this, A: ["this._db", ""] });
|
|
763
719
|
return this._db;
|
|
764
720
|
}
|
|
765
721
|
/**
|
|
766
722
|
* @deprecated Use db API.
|
|
767
723
|
*/
|
|
768
724
|
get crud() {
|
|
769
|
-
invariant2(this._db, void 0, {
|
|
770
|
-
F: __dxlog_file3,
|
|
771
|
-
L: 43,
|
|
772
|
-
S: this,
|
|
773
|
-
A: [
|
|
774
|
-
"this._db",
|
|
775
|
-
""
|
|
776
|
-
]
|
|
777
|
-
});
|
|
725
|
+
invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 30, S: this, A: ["this._db", ""] });
|
|
778
726
|
return this._db.coreDatabase;
|
|
779
727
|
}
|
|
780
728
|
get queues() {
|
|
@@ -798,7 +746,7 @@ var SpaceProxy = class extends Resource {
|
|
|
798
746
|
};
|
|
799
747
|
|
|
800
748
|
// src/functions-client.ts
|
|
801
|
-
var
|
|
749
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/functions-client.ts";
|
|
802
750
|
var FunctionsClient = class extends Resource2 {
|
|
803
751
|
_serviceContainer;
|
|
804
752
|
_echoClient;
|
|
@@ -806,24 +754,8 @@ var FunctionsClient = class extends Resource2 {
|
|
|
806
754
|
_spaces = /* @__PURE__ */ new Map();
|
|
807
755
|
constructor(services) {
|
|
808
756
|
super();
|
|
809
|
-
invariant3(typeof services.dataService !== "undefined", "DataService is required", {
|
|
810
|
-
|
|
811
|
-
L: 33,
|
|
812
|
-
S: this,
|
|
813
|
-
A: [
|
|
814
|
-
"typeof services.dataService !== 'undefined'",
|
|
815
|
-
"'DataService is required'"
|
|
816
|
-
]
|
|
817
|
-
});
|
|
818
|
-
invariant3(typeof services.queueService !== "undefined", "QueueService is required", {
|
|
819
|
-
F: __dxlog_file4,
|
|
820
|
-
L: 34,
|
|
821
|
-
S: this,
|
|
822
|
-
A: [
|
|
823
|
-
"typeof services.queueService !== 'undefined'",
|
|
824
|
-
"'QueueService is required'"
|
|
825
|
-
]
|
|
826
|
-
});
|
|
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'"] });
|
|
827
759
|
this._serviceContainer = new ServiceContainer(this._executionContext, services.dataService, services.queueService, services.functionsAiService);
|
|
828
760
|
this._echoClient = new EchoClient({});
|
|
829
761
|
}
|
|
@@ -875,9 +807,9 @@ var FunctionRouteValue = /* @__PURE__ */ (function(FunctionRouteValue2) {
|
|
|
875
807
|
// src/wrap-handler-for-cloudflare.ts
|
|
876
808
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
877
809
|
import { SpaceId as SpaceId2 } from "@dxos/keys";
|
|
878
|
-
import { log as
|
|
810
|
+
import { log as log4 } from "@dxos/log";
|
|
879
811
|
import { EdgeResponse } from "@dxos/protocols";
|
|
880
|
-
var
|
|
812
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/wrap-handler-for-cloudflare.ts";
|
|
881
813
|
var wrapHandlerForCloudflare = (func) => {
|
|
882
814
|
return async (request, env) => {
|
|
883
815
|
if (request.headers.get(FUNCTION_ROUTE_HEADER) === FunctionRouteValue.Meta) {
|
|
@@ -899,15 +831,10 @@ var wrapHandlerForCloudflare = (func) => {
|
|
|
899
831
|
});
|
|
900
832
|
return EdgeResponse.success(await invokeFunction(func, context, request));
|
|
901
833
|
} catch (error) {
|
|
902
|
-
|
|
834
|
+
log4.error("error invoking function", {
|
|
903
835
|
error,
|
|
904
836
|
stack: error.stack
|
|
905
|
-
}, {
|
|
906
|
-
F: __dxlog_file5,
|
|
907
|
-
L: 44,
|
|
908
|
-
S: void 0,
|
|
909
|
-
C: (f, a) => f(...a)
|
|
910
|
-
});
|
|
837
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 37, S: void 0 });
|
|
911
838
|
return EdgeResponse.failure({
|
|
912
839
|
message: error?.message ?? "Internal error",
|
|
913
840
|
error
|
|
@@ -940,12 +867,7 @@ var decodeRequest = async (request) => {
|
|
|
940
867
|
}
|
|
941
868
|
};
|
|
942
869
|
} catch (err) {
|
|
943
|
-
|
|
944
|
-
F: __dxlog_file5,
|
|
945
|
-
L: 79,
|
|
946
|
-
S: void 0,
|
|
947
|
-
C: (f, a) => f(...a)
|
|
948
|
-
});
|
|
870
|
+
log4.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 76, S: void 0 });
|
|
949
871
|
return {
|
|
950
872
|
data: {
|
|
951
873
|
bodyText,
|
|
@@ -978,15 +900,7 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
|
|
|
978
900
|
throw new Error(`Space not found: ${contextSpaceId}`);
|
|
979
901
|
}
|
|
980
902
|
spaceKey = meta.spaceKey;
|
|
981
|
-
invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, {
|
|
982
|
-
F: __dxlog_file5,
|
|
983
|
-
L: 117,
|
|
984
|
-
S: void 0,
|
|
985
|
-
A: [
|
|
986
|
-
"!meta.rootDocumentId.startsWith('automerge:')",
|
|
987
|
-
""
|
|
988
|
-
]
|
|
989
|
-
});
|
|
903
|
+
invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 109, S: void 0, A: ["!meta.rootDocumentId.startsWith('automerge:')", ""] });
|
|
990
904
|
rootUrl = `automerge:${meta.rootDocumentId}`;
|
|
991
905
|
}
|
|
992
906
|
return {
|
|
@@ -1003,36 +917,40 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
|
|
|
1003
917
|
};
|
|
1004
918
|
|
|
1005
919
|
// src/logger.ts
|
|
1006
|
-
import { LogLevel, log as
|
|
920
|
+
import { LogLevel, log as log5, shouldLog } from "@dxos/log";
|
|
1007
921
|
var setupFunctionsLogger = () => {
|
|
1008
|
-
|
|
1009
|
-
|
|
922
|
+
log5.runtimeConfig.processors.length = 0;
|
|
923
|
+
log5.runtimeConfig.processors.push(functionLogProcessor);
|
|
1010
924
|
};
|
|
1011
925
|
var functionLogProcessor = (config, entry) => {
|
|
1012
926
|
if (!shouldLog(entry, config.filters)) {
|
|
1013
927
|
return;
|
|
1014
928
|
}
|
|
929
|
+
const context = entry.computedContext;
|
|
930
|
+
const error = entry.computedError;
|
|
931
|
+
const extras = [
|
|
932
|
+
Object.keys(context).length > 0 ? context : void 0,
|
|
933
|
+
error
|
|
934
|
+
].filter((value) => value !== void 0);
|
|
1015
935
|
switch (entry.level) {
|
|
1016
936
|
case LogLevel.DEBUG:
|
|
1017
|
-
console.debug(entry.message, entry.context);
|
|
1018
|
-
break;
|
|
1019
937
|
case LogLevel.TRACE:
|
|
1020
|
-
console.debug(entry.message,
|
|
938
|
+
console.debug(entry.message, ...extras);
|
|
1021
939
|
break;
|
|
1022
940
|
case LogLevel.VERBOSE:
|
|
1023
|
-
console.log(entry.message,
|
|
941
|
+
console.log(entry.message, ...extras);
|
|
1024
942
|
break;
|
|
1025
943
|
case LogLevel.INFO:
|
|
1026
|
-
console.info(entry.message,
|
|
944
|
+
console.info(entry.message, ...extras);
|
|
1027
945
|
break;
|
|
1028
946
|
case LogLevel.WARN:
|
|
1029
|
-
console.warn(entry.message,
|
|
947
|
+
console.warn(entry.message, ...extras);
|
|
1030
948
|
break;
|
|
1031
949
|
case LogLevel.ERROR:
|
|
1032
|
-
console.error(entry.message,
|
|
950
|
+
console.error(entry.message, ...extras);
|
|
1033
951
|
break;
|
|
1034
952
|
default:
|
|
1035
|
-
console.log(entry.message,
|
|
953
|
+
console.log(entry.message, ...extras);
|
|
1036
954
|
break;
|
|
1037
955
|
}
|
|
1038
956
|
};
|
|
@@ -1042,6 +960,7 @@ export {
|
|
|
1042
960
|
FunctionsClient,
|
|
1043
961
|
ServiceContainer,
|
|
1044
962
|
createClientFromEnv,
|
|
963
|
+
createFunctionContext,
|
|
1045
964
|
setupFunctionsLogger,
|
|
1046
965
|
wrapHandlerForCloudflare
|
|
1047
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 as FeedProtocol.InsertIntoQueueRequest['objects'],\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 { type FeedProtocol } from '@dxos/protocols';\n\nimport type { ServiceContainer } from './internal';\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<FeedProtocol.QueryResult>;\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 queryQueue(queue: DXN, options?: {}): Promise<FeedProtocol.QueryResult> {\n return this._serviceContainer.queryQueue(queue);\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 switch (entry.level) {\n case LogLevel.DEBUG:\n console.debug(entry.message, entry.context);\n break;\n case LogLevel.TRACE:\n console.debug(entry.message, entry.context);\n break;\n case LogLevel.VERBOSE:\n console.log(entry.message, entry.context);\n break;\n case LogLevel.INFO:\n console.info(entry.message, entry.context);\n break;\n case LogLevel.WARN:\n console.warn(entry.message, entry.context);\n break;\n case LogLevel.ERROR:\n console.error(entry.message, entry.context);\n break;\n default:\n console.log(entry.message, entry.context);\n break;\n }\n};\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,YAAAA,iBAAgB;AACzB,SAASC,kBAAkB;AAC3B,SAASC,aAAAA,kBAAiB;;;ACD1B,SAASC,cAAc;AACvB,SAASC,aAAa;AACtB,SAASC,qBAAqBC,2BAA2B;AACzD,SAASC,iBAAiB;AAC1B,SAASC,eAAe;AACxB,SAASC,WAAW;;;ACNb,IAAMC,iBAAiB,CAACC,UAAkC,IAAIC,WAAWD,KAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ADwBzE,IAAME,kBAAN,MAAMA;;;EACHC,oBAAoB,oBAAIC,IAAAA;EAEhC,YACUC,mBACAC,cACR;SAFQD,oBAAAA;SACAC,eAAAA;EACP;EAEHC,UAAU,EAAEC,gBAAgBC,QAAO,GAAiF;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|
|
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, ...extras);\n break;\n default:\n console.log(entry.message, ...extras);\n break;\n }\n};\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,YAAAA,iBAAgB;AACzB,SAASC,kBAAkB;AAC3B,SAASC,aAAAA,kBAAiB;;;ACA1B,SAASC,cAAa;AACtB,SAASC,aAAAA;AACT,SAASC,qBAAiB,2BAAkB;AAC5C,SAASC,iBAAe;AACxB,SAASC,eAAW;AAgBpB,SAASC,WAAAA;;;ACtBF,IAAMC,iBAAiB,CAACC,UAAkC,IAAIC,WAAWD,KAAAA;;;ADJhF,IAAE,eAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKF;;;EAwBUE;EAER,oBACUC,oBAAAA,IAAAA;cAAAA,mBAAAA,cAAAA;SACAC,oBAAAA;AACP,SAAA,eAAA;EAEHC;YACE,EAAO,gBAAcC,QAAM,GAAA;WACzBC,IAAAA,OAAUC,CAAAA,EAAAA,KAAQC,MAAQC;AAC1B,gBAAKR,QAAAA,QAAqB,OAACS,GAAAA,QAAAA,EAAgB,YAAA,YAAA,GAAA,cAAA,GAAA,IAAA,GAAA,MAAA,GAAA,CAAA,4BAAA,EAAA,EAAA,CAAA;WAAED,kBAAAA,IAAAA,gBAAAA;QAASJ;QAAK;MAE3D,CAAA;aACE,MAAKJ;AACP,aAAA,kBAAA,OAAA,cAAA;MACF;IACF,CAAA;EAEA;QACE,mBACOA,EAAAA,gBAAsBS,OAAAA,GAAAA;UAGvBC,MAAAA,KAAS,kBAAA,IAAA,cAAA,KAAA,MAAA,IAAA,oBAAA;MACTC,SAAS;eAAEF;QAAe;MAC5B;IAGJ,CAAA,CAAA;QACEG,QAAQ;UAAwBC,KAAAA,qBAAoB;QAAC,OAAA,OAAA;MACrD,G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ACA9B;IACAwB;IACAO,SAAAA;IACQ;IACV,cAAA;;;;;AC7HF,SAASC,UAA6BC,OAAAA,MAAKC,iBAAiB;AAI1DC,IAAIC,uBAAyBC,MAAKC;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
|
}
|