@dxos/functions-runtime-cloudflare 0.8.4-main.9be5663bfe → 0.8.4-main.bc2380dfbc

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.
@@ -17,6 +17,7 @@ import { log } from "@dxos/log";
17
17
  var copyUint8Array = (value) => new Uint8Array(value);
18
18
 
19
19
  // src/internal/data-service-impl.ts
20
+ var __dxlog_file = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/internal/data-service-impl.ts";
20
21
  function _ts_add_disposable_resource(env, value, async) {
21
22
  if (value !== null && value !== void 0) {
22
23
  if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
@@ -82,7 +83,6 @@ function _ts_dispose_resources(env) {
82
83
  return next();
83
84
  })(env);
84
85
  }
85
- var __dxlog_file = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/data-service-impl.ts";
86
86
  var DataServiceImpl = class {
87
87
  _executionContext;
88
88
  _dataService;
@@ -93,15 +93,7 @@ var DataServiceImpl = class {
93
93
  }
94
94
  subscribe({ subscriptionId, spaceId }) {
95
95
  return new Stream(({ next }) => {
96
- invariant(SpaceId.isValid(spaceId), void 0, {
97
- F: __dxlog_file,
98
- L: 39,
99
- S: this,
100
- A: [
101
- "SpaceId.isValid(spaceId)",
102
- ""
103
- ]
104
- });
96
+ invariant(SpaceId.isValid(spaceId), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 86, S: this, A: ["SpaceId.isValid(spaceId)", ""] });
105
97
  this.dataSubscriptions.set(subscriptionId, {
106
98
  spaceId,
107
99
  next
@@ -121,12 +113,7 @@ var DataServiceImpl = class {
121
113
  if (addIds) {
122
114
  log.info("request documents", {
123
115
  count: addIds.length
124
- }, {
125
- F: __dxlog_file,
126
- L: 59,
127
- S: this,
128
- C: (f, a) => f(...a)
129
- });
116
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 104, S: this });
130
117
  for (const documentId of addIds) {
131
118
  const env = {
132
119
  stack: [],
@@ -139,21 +126,11 @@ var DataServiceImpl = class {
139
126
  documentId,
140
127
  spaceId: sub.spaceId,
141
128
  found: !!document
142
- }, {
143
- F: __dxlog_file,
144
- L: 63,
145
- S: this,
146
- C: (f, a) => f(...a)
147
- });
129
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 116, S: this });
148
130
  if (!document) {
149
131
  log.warn("not found", {
150
132
  documentId
151
- }, {
152
- F: __dxlog_file,
153
- L: 65,
154
- S: this,
155
- C: (f, a) => f(...a)
156
- });
133
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 122, S: this });
157
134
  continue;
158
135
  }
159
136
  sub.next({
@@ -182,15 +159,7 @@ var DataServiceImpl = class {
182
159
  hasError: false
183
160
  };
184
161
  try {
185
- invariant(SpaceId.isValid(spaceId), void 0, {
186
- F: __dxlog_file,
187
- L: 83,
188
- S: this,
189
- A: [
190
- "SpaceId.isValid(spaceId)",
191
- ""
192
- ]
193
- });
162
+ invariant(SpaceId.isValid(spaceId), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 153, S: this, A: ["SpaceId.isValid(spaceId)", ""] });
194
163
  const response = _ts_add_disposable_resource(env, await this._dataService.createDocument(this._executionContext, spaceId, initialValue), false);
195
164
  return {
196
165
  documentId: response.documentId
@@ -211,6 +180,9 @@ var DataServiceImpl = class {
211
180
  }));
212
181
  try {
213
182
  for (const update of updates ?? []) {
183
+ if (!update.mutation) {
184
+ continue;
185
+ }
214
186
  await this._dataService.changeDocument(this._executionContext, sub.spaceId, update.documentId, update.mutation);
215
187
  }
216
188
  } catch (error) {
@@ -241,12 +213,7 @@ var DataServiceImpl = class {
241
213
  });
242
214
  }
243
215
  async updateIndexes() {
244
- log.error("updateIndexes is not available in EDGE env.", void 0, {
245
- F: __dxlog_file,
246
- L: 134,
247
- S: this,
248
- C: (f, a) => f(...a)
249
- });
216
+ log.verbose("updateIndexes called, but it is a no-op in EDGE env.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 211, S: this });
250
217
  }
251
218
  async waitUntilHeadsReplicated({ heads: _heads }) {
252
219
  throw new NotImplementedError({
@@ -259,6 +226,7 @@ var DataServiceImpl = class {
259
226
  import { Stream as Stream2 } from "@dxos/codec-protobuf/stream";
260
227
  import { NotImplementedError as NotImplementedError2, RuntimeServiceError as RuntimeServiceError2 } from "@dxos/errors";
261
228
  import { log as log2 } from "@dxos/log";
229
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/internal/query-service-impl.ts";
262
230
  function _ts_add_disposable_resource2(env, value, async) {
263
231
  if (value !== null && value !== void 0) {
264
232
  if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
@@ -324,7 +292,6 @@ function _ts_dispose_resources2(env) {
324
292
  return next();
325
293
  })(env);
326
294
  }
327
- var __dxlog_file2 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/query-service-impl.ts";
328
295
  var QueryServiceImpl = class {
329
296
  _executionContext;
330
297
  _dataService;
@@ -336,12 +303,7 @@ var QueryServiceImpl = class {
336
303
  execQuery(request) {
337
304
  log2.info("execQuery", {
338
305
  request
339
- }, {
340
- F: __dxlog_file2,
341
- L: 20,
342
- S: this,
343
- C: (f, a) => f(...a)
344
- });
306
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 81, S: this });
345
307
  return Stream2.fromPromise((async () => {
346
308
  try {
347
309
  const env = {
@@ -353,21 +315,11 @@ var QueryServiceImpl = class {
353
315
  this._queryCount++;
354
316
  log2.info("begin query", {
355
317
  request
356
- }, {
357
- F: __dxlog_file2,
358
- L: 26,
359
- S: this,
360
- C: (f, a) => f(...a)
361
- });
318
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 93, S: this });
362
319
  const queryResponse = _ts_add_disposable_resource2(env, await this._dataService.execQuery(this._executionContext, request), false);
363
320
  log2.info("query response", {
364
321
  resultCount: queryResponse.results?.length
365
- }, {
366
- F: __dxlog_file2,
367
- L: 28,
368
- S: this,
369
- C: (f, a) => f(...a)
370
- });
322
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 97, S: this });
371
323
  return structuredClone(queryResponse);
372
324
  } catch (e) {
373
325
  env.error = e;
@@ -378,12 +330,7 @@ var QueryServiceImpl = class {
378
330
  } catch (error) {
379
331
  log2.error("query failed", {
380
332
  err: error
381
- }, {
382
- F: __dxlog_file2,
383
- L: 31,
384
- S: this,
385
- C: (f, a) => f(...a)
386
- });
333
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 108, S: this });
387
334
  throw new RuntimeServiceError2({
388
335
  message: `Query execution failed (queryCount=${this._queryCount})`,
389
336
  context: {
@@ -711,7 +658,7 @@ var ServiceContainer = class {
711
658
  subspaceTag,
712
659
  spaceId,
713
660
  queueId,
714
- objects
661
+ objects: objects.map((obj) => JSON.stringify(obj))
715
662
  });
716
663
  }
717
664
  };
@@ -722,6 +669,8 @@ import { invariant as invariant2 } from "@dxos/invariant";
722
669
  import { PublicKey } from "@dxos/keys";
723
670
 
724
671
  // src/queues-api.ts
672
+ import { log as log3 } from "@dxos/log";
673
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/queues-api.ts";
725
674
  var QueuesAPIImpl = class {
726
675
  _serviceContainer;
727
676
  _spaceId;
@@ -729,8 +678,26 @@ var QueuesAPIImpl = class {
729
678
  this._serviceContainer = _serviceContainer;
730
679
  this._spaceId = _spaceId;
731
680
  }
732
- queryQueue(queue, options) {
733
- return this._serviceContainer.queryQueue(queue);
681
+ async queryQueue(queue, options) {
682
+ const result = await this._serviceContainer.queryQueue(queue);
683
+ const objects = (result.objects ?? []).flatMap((encoded) => {
684
+ try {
685
+ return [
686
+ JSON.parse(encoded)
687
+ ];
688
+ } catch (err) {
689
+ log3.verbose("queue object JSON parse failed; object ignored", {
690
+ encoded,
691
+ error: err
692
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 22, S: this });
693
+ return [];
694
+ }
695
+ });
696
+ return {
697
+ objects,
698
+ nextCursor: result.nextCursor ?? null,
699
+ prevCursor: result.prevCursor ?? null
700
+ };
734
701
  }
735
702
  insertIntoQueue(queue, objects) {
736
703
  return this._serviceContainer.insertIntoQueue(queue, JSON.parse(JSON.stringify(objects)));
@@ -738,7 +705,7 @@ var QueuesAPIImpl = class {
738
705
  };
739
706
 
740
707
  // src/space-proxy.ts
741
- var __dxlog_file3 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/space-proxy.ts";
708
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/space-proxy.ts";
742
709
  var SpaceProxy = class extends Resource {
743
710
  _serviceContainer;
744
711
  _echoClient;
@@ -753,30 +720,14 @@ var SpaceProxy = class extends Resource {
753
720
  return this._id;
754
721
  }
755
722
  get db() {
756
- invariant2(this._db, void 0, {
757
- F: __dxlog_file3,
758
- L: 35,
759
- S: this,
760
- A: [
761
- "this._db",
762
- ""
763
- ]
764
- });
723
+ invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 24, S: this, A: ["this._db", ""] });
765
724
  return this._db;
766
725
  }
767
726
  /**
768
727
  * @deprecated Use db API.
769
728
  */
770
729
  get crud() {
771
- invariant2(this._db, void 0, {
772
- F: __dxlog_file3,
773
- L: 43,
774
- S: this,
775
- A: [
776
- "this._db",
777
- ""
778
- ]
779
- });
730
+ invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 30, S: this, A: ["this._db", ""] });
780
731
  return this._db.coreDatabase;
781
732
  }
782
733
  get queues() {
@@ -800,7 +751,7 @@ var SpaceProxy = class extends Resource {
800
751
  };
801
752
 
802
753
  // src/functions-client.ts
803
- var __dxlog_file4 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/functions-client.ts";
754
+ var __dxlog_file5 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/functions-client.ts";
804
755
  var FunctionsClient = class extends Resource2 {
805
756
  _serviceContainer;
806
757
  _echoClient;
@@ -808,24 +759,8 @@ var FunctionsClient = class extends Resource2 {
808
759
  _spaces = /* @__PURE__ */ new Map();
809
760
  constructor(services) {
810
761
  super();
811
- invariant3(typeof services.dataService !== "undefined", "DataService is required", {
812
- F: __dxlog_file4,
813
- L: 33,
814
- S: this,
815
- A: [
816
- "typeof services.dataService !== 'undefined'",
817
- "'DataService is required'"
818
- ]
819
- });
820
- invariant3(typeof services.queueService !== "undefined", "QueueService is required", {
821
- F: __dxlog_file4,
822
- L: 34,
823
- S: this,
824
- A: [
825
- "typeof services.queueService !== 'undefined'",
826
- "'QueueService is required'"
827
- ]
828
- });
762
+ invariant3(typeof services.dataService !== "undefined", "DataService is required", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 19, S: this, A: ["typeof services.dataService !== 'undefined'", "'DataService is required'"] });
763
+ invariant3(typeof services.queueService !== "undefined", "QueueService is required", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 20, S: this, A: ["typeof services.queueService !== 'undefined'", "'QueueService is required'"] });
829
764
  this._serviceContainer = new ServiceContainer(this._executionContext, services.dataService, services.queueService, services.functionsAiService);
830
765
  this._echoClient = new EchoClient({});
831
766
  }
@@ -877,9 +812,9 @@ var FunctionRouteValue = /* @__PURE__ */ (function(FunctionRouteValue2) {
877
812
  // src/wrap-handler-for-cloudflare.ts
878
813
  import { invariant as invariant4 } from "@dxos/invariant";
879
814
  import { SpaceId as SpaceId2 } from "@dxos/keys";
880
- import { log as log3 } from "@dxos/log";
815
+ import { log as log4 } from "@dxos/log";
881
816
  import { EdgeResponse } from "@dxos/protocols";
882
- var __dxlog_file5 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/wrap-handler-for-cloudflare.ts";
817
+ var __dxlog_file6 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/wrap-handler-for-cloudflare.ts";
883
818
  var wrapHandlerForCloudflare = (func) => {
884
819
  return async (request, env) => {
885
820
  if (request.headers.get(FUNCTION_ROUTE_HEADER) === FunctionRouteValue.Meta) {
@@ -901,15 +836,10 @@ var wrapHandlerForCloudflare = (func) => {
901
836
  });
902
837
  return EdgeResponse.success(await invokeFunction(func, context, request));
903
838
  } catch (error) {
904
- log3.error("error invoking function", {
839
+ log4.error("error invoking function", {
905
840
  error,
906
841
  stack: error.stack
907
- }, {
908
- F: __dxlog_file5,
909
- L: 44,
910
- S: void 0,
911
- C: (f, a) => f(...a)
912
- });
842
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 37, S: void 0 });
913
843
  return EdgeResponse.failure({
914
844
  message: error?.message ?? "Internal error",
915
845
  error
@@ -942,12 +872,7 @@ var decodeRequest = async (request) => {
942
872
  }
943
873
  };
944
874
  } catch (err) {
945
- log3.catch(err, void 0, {
946
- F: __dxlog_file5,
947
- L: 79,
948
- S: void 0,
949
- C: (f, a) => f(...a)
950
- });
875
+ log4.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 76, S: void 0 });
951
876
  return {
952
877
  data: {
953
878
  bodyText,
@@ -980,15 +905,7 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
980
905
  throw new Error(`Space not found: ${contextSpaceId}`);
981
906
  }
982
907
  spaceKey = meta.spaceKey;
983
- invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, {
984
- F: __dxlog_file5,
985
- L: 117,
986
- S: void 0,
987
- A: [
988
- "!meta.rootDocumentId.startsWith('automerge:')",
989
- ""
990
- ]
991
- });
908
+ invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 109, S: void 0, A: ["!meta.rootDocumentId.startsWith('automerge:')", ""] });
992
909
  rootUrl = `automerge:${meta.rootDocumentId}`;
993
910
  }
994
911
  return {
@@ -1005,36 +922,40 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
1005
922
  };
1006
923
 
1007
924
  // src/logger.ts
1008
- import { LogLevel, log as log4, shouldLog } from "@dxos/log";
925
+ import { LogLevel, log as log5, shouldLog } from "@dxos/log";
1009
926
  var setupFunctionsLogger = () => {
1010
- log4.runtimeConfig.processors.length = 0;
1011
- log4.runtimeConfig.processors.push(functionLogProcessor);
927
+ log5.runtimeConfig.processors.length = 0;
928
+ log5.runtimeConfig.processors.push(functionLogProcessor);
1012
929
  };
1013
930
  var functionLogProcessor = (config, entry) => {
1014
931
  if (!shouldLog(entry, config.filters)) {
1015
932
  return;
1016
933
  }
934
+ const context = entry.computedContext;
935
+ const error = entry.computedError;
936
+ const extras = [
937
+ Object.keys(context).length > 0 ? context : void 0,
938
+ error
939
+ ].filter((value) => value !== void 0);
1017
940
  switch (entry.level) {
1018
941
  case LogLevel.DEBUG:
1019
- console.debug(entry.message, entry.context);
1020
- break;
1021
942
  case LogLevel.TRACE:
1022
- console.debug(entry.message, entry.context);
943
+ console.debug(entry.message, ...extras);
1023
944
  break;
1024
945
  case LogLevel.VERBOSE:
1025
- console.log(entry.message, entry.context);
946
+ console.log(entry.message, ...extras);
1026
947
  break;
1027
948
  case LogLevel.INFO:
1028
- console.info(entry.message, entry.context);
949
+ console.info(entry.message, ...extras);
1029
950
  break;
1030
951
  case LogLevel.WARN:
1031
- console.warn(entry.message, entry.context);
952
+ console.warn(entry.message, ...extras);
1032
953
  break;
1033
954
  case LogLevel.ERROR:
1034
- console.error(entry.message, entry.context);
955
+ console.error(entry.message, ...extras);
1035
956
  break;
1036
957
  default:
1037
- console.log(entry.message, entry.context);
958
+ console.log(entry.message, ...extras);
1038
959
  break;
1039
960
  }
1040
961
  };
@@ -1044,6 +965,7 @@ export {
1044
965
  FunctionsClient,
1045
966
  ServiceContainer,
1046
967
  createClientFromEnv,
968
+ createFunctionContext,
1047
969
  setupFunctionsLogger,
1048
970
  wrapHandlerForCloudflare
1049
971
  };
@@ -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;AAClH,WAAO,IAAIC,OAAO,CAAC,EAAEC,KAAI,MAAE;AACzBC,gBAAUC,QAAQC,QAAQL,OAAAA,GAAAA,QAAAA;;;;;;;;;AAC1B,WAAKN,kBAAkBY,IAAIP,gBAAgB;QAAEC;QAASE;MAAK,CAAA;AAE3D,aAAO,MAAA;AACL,aAAKR,kBAAkBa,OAAOR,cAAAA;MAChC;IACF,CAAA;EACF;EAEA,MAAMS,mBAAmB,EAAET,gBAAgBU,OAAM,GAA8C;AAC7F,UAAMC,MACJ,KAAKhB,kBAAkBiB,IAAIZ,cAAAA,KAC3Ba,MACE,IAAIC,oBAAoB;MACtBC,SAAS;MACTC,SAAS;QAAEhB;MAAe;IAC5B,CAAA,CAAA;AAGJ,QAAIU,QAAQ;AACVO,UAAIC,KAAK,qBAAqB;QAAEC,OAAOT,OAAOU;MAAO,GAAA;;;;;;AAErD,iBAAWC,cAAcX,QAAQ;;;;;;;gBACzBY,WAAAA,4BAAAA,KAAW,MAAM,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AUD,OAAOD,OAAOG,OAAO,GAAG;AACrC;EACF;AAEA,UAAQF,MAAMG,OAAK;IACjB,KAAKC,SAASC;AACZC,cAAQC,MAAMP,MAAMQ,SAASR,MAAMS,OAAO;AAC1C;IACF,KAAKL,SAASM;AACZJ,cAAQC,MAAMP,MAAMQ,SAASR,MAAMS,OAAO;AAC1C;IACF,KAAKL,SAASO;AACZL,cAAQb,IAAIO,MAAMQ,SAASR,MAAMS,OAAO;AACxC;IACF,KAAKL,SAASQ;AACZN,cAAQO,KAAKb,MAAMQ,SAASR,MAAMS,OAAO;AACzC;IACF,KAAKL,SAASU;AACZR,cAAQS,KAAKf,MAAMQ,SAASR,MAAMS,OAAO;AACzC;IACF,KAAKL,SAASY;AACZV,cAAQW,MAAMjB,MAAMQ,SAASR,MAAMS,OAAO;AAC1C;IACF;AACEH,cAAQb,IAAIO,MAAMQ,SAASR,MAAMS,OAAO;AACxC;EACJ;AACF;",
6
- "names": ["Resource", "EchoClient", "invariant", "Stream", "raise", "NotImplementedError", "RuntimeServiceError", "invariant", "SpaceId", "log", "copyUint8Array", "value", "Uint8Array", "DataServiceImpl", "dataSubscriptions", "Map", "_executionContext", "_dataService", "subscribe", "subscriptionId", "spaceId", "Stream", "next", "invariant", "SpaceId", "isValid", "set", "delete", "updateSubscription", "addIds", "sub", "get", "raise", "RuntimeServiceError", "message", "context", "log", "info", "count", "length", "documentId", "document", "getDocument", "found", "warn", "updates", "mutation", "copyUint8Array", "data", "createDocument", "initialValue", "response", "update", "changeDocument", "error", "wrap", "ifTypeDiffers", "flush", "subscribeSpaceSyncState", "_request", "_options", "NotImplementedError", "getDocumentHeads", "documentIds", "_documentIds", "reIndexHeads", "updateIndexes", "waitUntilHeadsReplicated", "heads", "_heads", "Stream", "NotImplementedError", "RuntimeServiceError", "log", "QueryServiceImpl", "_queryCount", "_executionContext", "_dataService", "execQuery", "request", "info", "fromPromise", "queryResponse", "resultCount", "results", "length", "structuredClone", "error", "err", "message", "context", "queryCount", "cause", "reindex", "setConfig", "RuntimeServiceError", "QueueServiceImpl", "_ctx", "_queueService", "queryQueue", "request", "result", "objects", "structuredClone", "nextCursor", "prevCursor", "error", "query", "RuntimeServiceError", "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", "Resource", "invariant", "PublicKey", "QueuesAPIImpl", "_serviceContainer", "_spaceId", "queryQueue", "queue", "options", "insertIntoQueue", "objects", "JSON", "parse", "stringify", "SpaceProxy", "Resource", "_db", "undefined", "_queuesApi", "_serviceContainer", "_echoClient", "_id", "QueuesAPIImpl", "id", "db", "invariant", "crud", "coreDatabase", "queues", "_open", "meta", "getSpaceMeta", "Error", "constructDatabase", "spaceId", "spaceKey", "PublicKey", "from", "reactiveSchemaQuery", "owningObject", "open", "_ctx", "rootUrl", "rootDocumentId", "FunctionsClient", "Resource", "_serviceContainer", "_echoClient", "_executionContext", "_spaces", "Map", "services", "invariant", "dataService", "queueService", "ServiceContainer", "functionsAiService", "EchoClient", "echo", "_open", "queryService", "createServices", "connectToService", "open", "_close", "space", "values", "close", "clear", "getSpace", "spaceId", "has", "SpaceProxy", "set", "get", "createClientFromEnv", "env", "client", "DATA_SERVICE", "QUEUE_SERVICE", "FUNCTIONS_AI_SERVICE", "FUNCTION_ROUTE_HEADER", "FunctionRouteValue", "invariant", "SpaceId", "log", "EdgeResponse", "wrapHandlerForCloudflare", "func", "request", "env", "headers", "get", "FUNCTION_ROUTE_HEADER", "FunctionRouteValue", "Meta", "handleFunctionMetaCall", "spaceId", "URL", "url", "searchParams", "SpaceId", "isValid", "Response", "status", "serviceContainer", "ServiceContainer", "DATA_SERVICE", "QUEUE_SERVICE", "FUNCTIONS_AI_SERVICE", "context", "createFunctionContext", "contextSpaceId", "EdgeResponse", "success", "invokeFunction", "error", "log", "stack", "failure", "message", "data", "decodeRequest", "handler", "bodyText", "rest", "trigger", "json", "JSON", "parse", "err", "catch", "functionDefinition", "response", "key", "meta", "name", "description", "inputSchema", "outputSchema", "stringify", "dataService", "queryService", "queueService", "functionsAiService", "createServices", "spaceKey", "rootUrl", "getSpaceMeta", "Error", "invariant", "rootDocumentId", "startsWith", "services", "spaceRootUrl", "LogLevel", "log", "shouldLog", "setupFunctionsLogger", "log", "runtimeConfig", "processors", "length", "push", "functionLogProcessor", "config", "entry", "shouldLog", "filters", "level", "LogLevel", "DEBUG", "console", "debug", "message", "context", "TRACE", "VERBOSE", "INFO", "info", "WARN", "warn", "ERROR", "error"]
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// 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 // Mutation-less updates (e.g. `requesting: true` transition signals from the worker) carry no\n // bytes to apply; this runtime only forwards real document writes.\n if (!update.mutation) {\n continue;\n }\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.verbose('updateIndexes called, but it is a no-op 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\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\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\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,mBA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BH;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", "RuntimeServiceError", "ifTypeDiffers", "error", "subscribeSpaceSyncState", "NotImplementedError", "NotImplementedError", "log", "RuntimeServiceError", "QueryServiceImpl", "_queryCount", "_executionContext", "_dataService", "execQuery", "info", "request", "fromPromise", "__dxlog_file", "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
  }