@dxos/functions-runtime-cloudflare 0.8.4-main.40e3dcdf1b → 0.8.4-main.422d1c7879

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.
@@ -180,10 +180,16 @@ var DataServiceImpl = class {
180
180
  hasError: false
181
181
  };
182
182
  try {
183
- const response = _ts_add_disposable_resource(env, await this._dataService.createDocument(this._executionContext, {
184
- spaceId,
185
- initialValue
186
- }), false);
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
+ });
192
+ const response = _ts_add_disposable_resource(env, await this._dataService.createDocument(this._executionContext, spaceId, initialValue), false);
187
193
  return {
188
194
  documentId: response.documentId
189
195
  };
@@ -235,7 +241,7 @@ var DataServiceImpl = class {
235
241
  async updateIndexes() {
236
242
  log.error("updateIndexes is not available in EDGE env.", void 0, {
237
243
  F: __dxlog_file,
238
- L: 133,
244
+ L: 134,
239
245
  S: this,
240
246
  C: (f, a) => f(...a)
241
247
  });
@@ -703,7 +709,7 @@ var ServiceContainer = class {
703
709
  subspaceTag,
704
710
  spaceId,
705
711
  queueId,
706
- objects
712
+ objects: objects.map((obj) => JSON.stringify(obj))
707
713
  });
708
714
  }
709
715
  };
@@ -714,6 +720,8 @@ import { invariant as invariant2 } from "@dxos/invariant";
714
720
  import { PublicKey } from "@dxos/keys";
715
721
 
716
722
  // src/queues-api.ts
723
+ import { log as log3 } from "@dxos/log";
724
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/queues-api.ts";
717
725
  var QueuesAPIImpl = class {
718
726
  _serviceContainer;
719
727
  _spaceId;
@@ -721,8 +729,31 @@ var QueuesAPIImpl = class {
721
729
  this._serviceContainer = _serviceContainer;
722
730
  this._spaceId = _spaceId;
723
731
  }
724
- queryQueue(queue, options) {
725
- return this._serviceContainer.queryQueue(queue);
732
+ async queryQueue(queue, options) {
733
+ const result = await this._serviceContainer.queryQueue(queue);
734
+ const objects = (result.objects ?? []).flatMap((encoded) => {
735
+ try {
736
+ return [
737
+ JSON.parse(encoded)
738
+ ];
739
+ } catch (err) {
740
+ log3.verbose("queue object JSON parse failed; object ignored", {
741
+ encoded,
742
+ error: err
743
+ }, {
744
+ F: __dxlog_file3,
745
+ L: 42,
746
+ S: this,
747
+ C: (f, a) => f(...a)
748
+ });
749
+ return [];
750
+ }
751
+ });
752
+ return {
753
+ objects,
754
+ nextCursor: result.nextCursor ?? null,
755
+ prevCursor: result.prevCursor ?? null
756
+ };
726
757
  }
727
758
  insertIntoQueue(queue, objects) {
728
759
  return this._serviceContainer.insertIntoQueue(queue, JSON.parse(JSON.stringify(objects)));
@@ -730,7 +761,7 @@ var QueuesAPIImpl = class {
730
761
  };
731
762
 
732
763
  // src/space-proxy.ts
733
- var __dxlog_file3 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/space-proxy.ts";
764
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/space-proxy.ts";
734
765
  var SpaceProxy = class extends Resource {
735
766
  _serviceContainer;
736
767
  _echoClient;
@@ -746,7 +777,7 @@ var SpaceProxy = class extends Resource {
746
777
  }
747
778
  get db() {
748
779
  invariant2(this._db, void 0, {
749
- F: __dxlog_file3,
780
+ F: __dxlog_file4,
750
781
  L: 35,
751
782
  S: this,
752
783
  A: [
@@ -761,7 +792,7 @@ var SpaceProxy = class extends Resource {
761
792
  */
762
793
  get crud() {
763
794
  invariant2(this._db, void 0, {
764
- F: __dxlog_file3,
795
+ F: __dxlog_file4,
765
796
  L: 43,
766
797
  S: this,
767
798
  A: [
@@ -785,14 +816,14 @@ var SpaceProxy = class extends Resource {
785
816
  reactiveSchemaQuery: false,
786
817
  owningObject: this
787
818
  });
788
- await this._db.coreDatabase.open({
819
+ await this._db.coreDatabase.open(this._ctx, {
789
820
  rootUrl: meta.rootDocumentId
790
821
  });
791
822
  }
792
823
  };
793
824
 
794
825
  // src/functions-client.ts
795
- var __dxlog_file4 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/functions-client.ts";
826
+ var __dxlog_file5 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/functions-client.ts";
796
827
  var FunctionsClient = class extends Resource2 {
797
828
  _serviceContainer;
798
829
  _echoClient;
@@ -801,7 +832,7 @@ var FunctionsClient = class extends Resource2 {
801
832
  constructor(services) {
802
833
  super();
803
834
  invariant3(typeof services.dataService !== "undefined", "DataService is required", {
804
- F: __dxlog_file4,
835
+ F: __dxlog_file5,
805
836
  L: 33,
806
837
  S: this,
807
838
  A: [
@@ -810,7 +841,7 @@ var FunctionsClient = class extends Resource2 {
810
841
  ]
811
842
  });
812
843
  invariant3(typeof services.queueService !== "undefined", "QueueService is required", {
813
- F: __dxlog_file4,
844
+ F: __dxlog_file5,
814
845
  L: 34,
815
846
  S: this,
816
847
  A: [
@@ -869,9 +900,9 @@ var FunctionRouteValue = /* @__PURE__ */ (function(FunctionRouteValue2) {
869
900
  // src/wrap-handler-for-cloudflare.ts
870
901
  import { invariant as invariant4 } from "@dxos/invariant";
871
902
  import { SpaceId as SpaceId2 } from "@dxos/keys";
872
- import { log as log3 } from "@dxos/log";
903
+ import { log as log4 } from "@dxos/log";
873
904
  import { EdgeResponse } from "@dxos/protocols";
874
- var __dxlog_file5 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/wrap-handler-for-cloudflare.ts";
905
+ var __dxlog_file6 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/wrap-handler-for-cloudflare.ts";
875
906
  var wrapHandlerForCloudflare = (func) => {
876
907
  return async (request, env) => {
877
908
  if (request.headers.get(FUNCTION_ROUTE_HEADER) === FunctionRouteValue.Meta) {
@@ -893,11 +924,11 @@ var wrapHandlerForCloudflare = (func) => {
893
924
  });
894
925
  return EdgeResponse.success(await invokeFunction(func, context, request));
895
926
  } catch (error) {
896
- log3.error("error invoking function", {
927
+ log4.error("error invoking function", {
897
928
  error,
898
929
  stack: error.stack
899
930
  }, {
900
- F: __dxlog_file5,
931
+ F: __dxlog_file6,
901
932
  L: 44,
902
933
  S: void 0,
903
934
  C: (f, a) => f(...a)
@@ -934,8 +965,8 @@ var decodeRequest = async (request) => {
934
965
  }
935
966
  };
936
967
  } catch (err) {
937
- log3.catch(err, void 0, {
938
- F: __dxlog_file5,
968
+ log4.catch(err, void 0, {
969
+ F: __dxlog_file6,
939
970
  L: 79,
940
971
  S: void 0,
941
972
  C: (f, a) => f(...a)
@@ -973,7 +1004,7 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
973
1004
  }
974
1005
  spaceKey = meta.spaceKey;
975
1006
  invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, {
976
- F: __dxlog_file5,
1007
+ F: __dxlog_file6,
977
1008
  L: 117,
978
1009
  S: void 0,
979
1010
  A: [
@@ -997,36 +1028,40 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
997
1028
  };
998
1029
 
999
1030
  // src/logger.ts
1000
- import { LogLevel, log as log4, shouldLog } from "@dxos/log";
1031
+ import { LogLevel, log as log5, shouldLog } from "@dxos/log";
1001
1032
  var setupFunctionsLogger = () => {
1002
- log4.runtimeConfig.processors.length = 0;
1003
- log4.runtimeConfig.processors.push(functionLogProcessor);
1033
+ log5.runtimeConfig.processors.length = 0;
1034
+ log5.runtimeConfig.processors.push(functionLogProcessor);
1004
1035
  };
1005
1036
  var functionLogProcessor = (config, entry) => {
1006
1037
  if (!shouldLog(entry, config.filters)) {
1007
1038
  return;
1008
1039
  }
1040
+ const context = entry.computedContext;
1041
+ const error = entry.computedError;
1042
+ const extras = [
1043
+ Object.keys(context).length > 0 ? context : void 0,
1044
+ error
1045
+ ].filter((value) => value !== void 0);
1009
1046
  switch (entry.level) {
1010
1047
  case LogLevel.DEBUG:
1011
- console.debug(entry.message, entry.context);
1012
- break;
1013
1048
  case LogLevel.TRACE:
1014
- console.debug(entry.message, entry.context);
1049
+ console.debug(entry.message, ...extras);
1015
1050
  break;
1016
1051
  case LogLevel.VERBOSE:
1017
- console.log(entry.message, entry.context);
1052
+ console.log(entry.message, ...extras);
1018
1053
  break;
1019
1054
  case LogLevel.INFO:
1020
- console.info(entry.message, entry.context);
1055
+ console.info(entry.message, ...extras);
1021
1056
  break;
1022
1057
  case LogLevel.WARN:
1023
- console.warn(entry.message, entry.context);
1058
+ console.warn(entry.message, ...extras);
1024
1059
  break;
1025
1060
  case LogLevel.ERROR:
1026
- console.error(entry.message, entry.context);
1061
+ console.error(entry.message, ...extras);
1027
1062
  break;
1028
1063
  default:
1029
- console.log(entry.message, entry.context);
1064
+ console.log(entry.message, ...extras);
1030
1065
  break;
1031
1066
  }
1032
1067
  };
@@ -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 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({ 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;;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ACf,KAAKgB,eAAeC,WAAW,YAAA,GAAA,QAAA;;;;;;;;;AAC1CL,cAAU,aAAaZ,KAAKgB,cAAc;EAC5C;AAEA,SAAO;IACLE,UAAU;MACRZ;MACAC;MACAC;MACAC;IACF;IACA/C,SAASe;IACTkC;IACAQ,cAAcP;EAChB;AACF;;;AC7HA,SAASQ,UAA6BC,OAAAA,MAAKC,iBAAiB;AAErD,IAAMC,uBAAuB,MAAA;AAClCC,EAAAA,KAAIC,cAAcC,WAAWC,SAAS;AACtCH,EAAAA,KAAIC,cAAcC,WAAWE,KAAKC,oBAAAA;AACpC;AAEA,IAAMA,uBAAqC,CAACC,QAAQC,UAAAA;AAClD,MAAI,CAACC,UAAUD,OAAOD,OAAOG,OAAO,GAAG;AACrC;EACF;AAEA,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", "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/**\n - Provides data access capabilities for user functions.\n - No real-time replication or reactive queries -- function receives a snapshot.\n - Function event contains the metadata but doesn't need to include the data.\n */\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { RequestOptions } from '@dxos/codec-protobuf';\nimport { Stream } from '@dxos/codec-protobuf/stream';\nimport { raise } from '@dxos/debug';\nimport { NotImplementedError, RuntimeServiceError } from '@dxos/errors';\nimport { invariant } from '@dxos/invariant';\nimport { SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { type EdgeFunctionEnv } from '@dxos/protocols';\nimport type {\n BatchedDocumentUpdates,\n CreateDocumentRequest,\n CreateDocumentResponse,\n DataService as DataServiceProto,\n GetDocumentHeadsRequest,\n GetDocumentHeadsResponse,\n GetSpaceSyncStateRequest,\n ReIndexHeadsRequest,\n SpaceSyncState,\n UpdateRequest,\n UpdateSubscriptionRequest,\n} from '@dxos/protocols/proto/dxos/echo/service';\n\nimport { copyUint8Array } from './utils';\n\nexport class DataServiceImpl implements DataServiceProto {\n private dataSubscriptions = new Map<string, { spaceId: SpaceId; next: (msg: BatchedDocumentUpdates) => void }>();\n\n constructor(\n private _executionContext: EdgeFunctionEnv.TraceContext,\n private _dataService: EdgeFunctionEnv.DataService,\n ) {}\n\n subscribe({ subscriptionId, spaceId }: { subscriptionId: string; spaceId: string }): Stream<BatchedDocumentUpdates> {\n return new Stream(({ next }) => {\n invariant(SpaceId.isValid(spaceId));\n this.dataSubscriptions.set(subscriptionId, { spaceId, next });\n\n return () => {\n this.dataSubscriptions.delete(subscriptionId);\n };\n });\n }\n\n async updateSubscription({ subscriptionId, addIds }: UpdateSubscriptionRequest): Promise<void> {\n const sub =\n this.dataSubscriptions.get(subscriptionId) ??\n raise(\n new RuntimeServiceError({\n message: 'Subscription not found.',\n context: { subscriptionId },\n }),\n );\n\n if (addIds) {\n log.info('request documents', { count: addIds.length });\n // TODO(dmaretskyi): Batch.\n for (const documentId of addIds) {\n using document = await this._dataService.getDocument(this._executionContext, sub.spaceId, documentId);\n log.info('document loaded', { documentId, spaceId: sub.spaceId, found: !!document });\n if (!document) {\n log.warn('not found', { documentId });\n continue;\n }\n sub.next({\n updates: [\n {\n documentId,\n // Copy returned object to avoid hanging RPC stub\n // See https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/\n mutation: copyUint8Array(document.data),\n },\n ],\n });\n }\n }\n }\n\n async createDocument({ spaceId, initialValue }: CreateDocumentRequest): Promise<CreateDocumentResponse> {\n invariant(SpaceId.isValid(spaceId));\n using response = await this._dataService.createDocument(this._executionContext, spaceId, initialValue);\n return { documentId: response.documentId };\n }\n\n async update({ updates, subscriptionId }: UpdateRequest): Promise<void> {\n const sub =\n this.dataSubscriptions.get(subscriptionId) ??\n raise(\n new RuntimeServiceError({\n message: 'Subscription not found.',\n context: { subscriptionId },\n }),\n );\n // TODO(dmaretskyi): Batch.\n try {\n for (const update of updates ?? []) {\n await this._dataService.changeDocument(this._executionContext, sub.spaceId, update.documentId, update.mutation);\n }\n } catch (error) {\n throw RuntimeServiceError.wrap({\n message: 'Failed to apply document updates.',\n context: { subscriptionId },\n ifTypeDiffers: true,\n })(error);\n }\n }\n\n async flush(): Promise<void> {\n // No-op.\n }\n\n subscribeSpaceSyncState(_request: GetSpaceSyncStateRequest, _options?: RequestOptions): Stream<SpaceSyncState> {\n throw new NotImplementedError({\n message: 'subscribeSpaceSyncState is not implemented.',\n });\n }\n\n async getDocumentHeads({ documentIds: _documentIds }: GetDocumentHeadsRequest): Promise<GetDocumentHeadsResponse> {\n throw new NotImplementedError({\n message: 'getDocumentHeads is not implemented.',\n });\n }\n\n async reIndexHeads({ documentIds: _documentIds }: ReIndexHeadsRequest): Promise<void> {\n throw new NotImplementedError({\n message: 'reIndexHeads is not implemented.',\n });\n }\n\n async updateIndexes(): Promise<void> {\n log.error('updateIndexes is not available in EDGE env.');\n // No-op.\n }\n\n async waitUntilHeadsReplicated({ heads: _heads }: { heads: any }): Promise<void> {\n throw new NotImplementedError({\n message: 'waitUntilHeadsReplicated is not implemented.',\n });\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nexport const copyUint8Array = (value: Uint8Array): Uint8Array => new Uint8Array(value);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Stream } from '@dxos/codec-protobuf/stream';\nimport { NotImplementedError, RuntimeServiceError } from '@dxos/errors';\nimport { log } from '@dxos/log';\nimport { type EdgeFunctionEnv } from '@dxos/protocols';\nimport { type QueryRequest, type QueryResponse, type QueryService } from '@dxos/protocols/proto/dxos/echo/query';\n\nexport class QueryServiceImpl implements QueryService {\n private _queryCount = 0;\n\n constructor(\n private readonly _executionContext: EdgeFunctionEnv.TraceContext,\n private readonly _dataService: EdgeFunctionEnv.DataService,\n ) {}\n\n execQuery(request: QueryRequest): Stream<QueryResponse> {\n log.info('execQuery', { request });\n\n return Stream.fromPromise<QueryResponse>(\n (async () => {\n try {\n this._queryCount++;\n log.info('begin query', { request });\n using queryResponse = await this._dataService.execQuery(this._executionContext, request);\n log.info('query response', { resultCount: queryResponse.results?.length });\n return structuredClone(queryResponse);\n } catch (error) {\n log.error('query failed', { err: error });\n throw new RuntimeServiceError({\n message: `Query execution failed (queryCount=${this._queryCount})`,\n context: { queryCount: this._queryCount },\n cause: error,\n });\n }\n })(),\n );\n }\n\n async reindex() {\n throw new NotImplementedError({\n message: 'Reindex is not implemented.',\n });\n }\n\n async setConfig() {\n throw new NotImplementedError({\n message: 'SetConfig is not implemented.',\n });\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { RuntimeServiceError } from '@dxos/errors';\nimport { type EdgeFunctionEnv, type FeedProtocol } from '@dxos/protocols';\n\nexport class QueueServiceImpl implements FeedProtocol.QueueService {\n constructor(\n protected _ctx: EdgeFunctionEnv.TraceContext,\n private readonly _queueService: EdgeFunctionEnv.QueueService,\n ) {}\n\n async queryQueue(request: FeedProtocol.QueryQueueRequest): Promise<FeedProtocol.QueryResult> {\n try {\n using result = await this._queueService.queryQueue(this._ctx, request);\n // Copy to avoid hanging RPC stub (Workers RPC lifecycle).\n return {\n objects: structuredClone(result.objects),\n nextCursor: result.nextCursor,\n prevCursor: result.prevCursor,\n };\n } catch (error) {\n const { query } = request;\n throw RuntimeServiceError.wrap({\n message: 'Queue query failed.',\n context: {\n subspaceTag: query?.queuesNamespace,\n spaceId: query?.spaceId,\n queueId: query?.queueIds?.[0],\n },\n ifTypeDiffers: true,\n })(error);\n }\n }\n\n async insertIntoQueue(request: FeedProtocol.InsertIntoQueueRequest): Promise<void> {\n try {\n using _ = await this._queueService.insertIntoQueue(this._ctx, request);\n } catch (error) {\n const { subspaceTag, spaceId, queueId } = request;\n throw RuntimeServiceError.wrap({\n message: 'Queue append failed.',\n context: { subspaceTag, spaceId, queueId },\n ifTypeDiffers: true,\n })(error);\n }\n }\n\n async deleteFromQueue(request: FeedProtocol.DeleteFromQueueRequest): Promise<void> {\n try {\n using _ = await this._queueService.deleteFromQueue(this._ctx, request);\n } catch (error) {\n const { subspaceTag, spaceId, queueId } = request;\n throw RuntimeServiceError.wrap({\n message: 'Queue delete failed.',\n context: { subspaceTag, spaceId, queueId },\n ifTypeDiffers: true,\n })(error);\n }\n }\n\n async syncQueue(_: FeedProtocol.SyncQueueRequest): Promise<void> {\n // No-op in Cloudflare runtime.\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type AnyEntity } from '@dxos/echo/internal';\nimport { type DXN, type SpaceId } from '@dxos/keys';\nimport { type EdgeFunctionEnv, type FeedProtocol } from '@dxos/protocols';\nimport { type QueryService as QueryServiceProto } from '@dxos/protocols/proto/dxos/echo/query';\nimport type { DataService as DataServiceProto } from '@dxos/protocols/proto/dxos/echo/service';\n\nimport { DataServiceImpl } from './data-service-impl';\nimport { QueryServiceImpl } from './query-service-impl';\nimport { QueueServiceImpl } from './queue-service-impl';\n\n/**\n * TODO: make this implement DataService and QueryService to unify API over edge and web backend\n */\nexport class ServiceContainer {\n constructor(\n private readonly _executionContext: EdgeFunctionEnv.TraceContext,\n private readonly _dataService: EdgeFunctionEnv.DataService,\n private readonly _queueService: EdgeFunctionEnv.QueueService,\n private readonly _functionsService: EdgeFunctionEnv.FunctionsAiService,\n ) {}\n\n async getSpaceMeta(spaceId: SpaceId): Promise<EdgeFunctionEnv.SpaceMeta | undefined> {\n using result = await this._dataService.getSpaceMeta(this._executionContext, spaceId);\n // Copy returned object to avoid hanging RPC stub\n // See https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/\n return result\n ? {\n spaceKey: result.spaceKey,\n rootDocumentId: result.rootDocumentId,\n }\n : undefined;\n }\n\n async createServices(): Promise<{\n dataService: DataServiceProto;\n queryService: QueryServiceProto;\n queueService: FeedProtocol.QueueService;\n functionsAiService: EdgeFunctionEnv.FunctionsAiService;\n }> {\n const dataService = new DataServiceImpl(this._executionContext, this._dataService);\n const queryService = new QueryServiceImpl(this._executionContext, this._dataService);\n const queueService = new QueueServiceImpl(this._executionContext, this._queueService);\n\n return {\n dataService,\n queryService,\n queueService,\n functionsAiService: this._functionsService,\n };\n }\n\n async queryQueue(queue: DXN): Promise<FeedProtocol.QueryResult> {\n const parts = queue.asQueueDXN();\n if (!parts) {\n throw new Error('Invalid queue DXN');\n }\n const { subspaceTag, spaceId, queueId } = parts;\n const result = await this._queueService.queryQueue(this._executionContext, {\n query: {\n spaceId,\n queuesNamespace: subspaceTag,\n queueIds: [queueId],\n },\n });\n return {\n objects: structuredClone(result.objects),\n nextCursor: result.nextCursor ?? null,\n prevCursor: result.prevCursor ?? null,\n };\n }\n\n async insertIntoQueue(queue: DXN, objects: AnyEntity[]): Promise<void> {\n const parts = queue.asQueueDXN();\n if (!parts) {\n throw new Error('Invalid queue DXN');\n }\n const { subspaceTag, spaceId, queueId } = parts;\n await this._queueService.insertIntoQueue(this._executionContext, {\n subspaceTag,\n spaceId,\n queueId,\n objects: objects.map((obj) => JSON.stringify(obj)),\n });\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Resource } from '@dxos/context';\nimport { type Database } from '@dxos/echo';\nimport { type CoreDatabase, type EchoClient, type EchoDatabaseImpl } from '@dxos/echo-db';\nimport { invariant } from '@dxos/invariant';\nimport { PublicKey, type SpaceId } from '@dxos/keys';\n\nimport type { ServiceContainer } from './internal';\nimport { type QueuesAPI, QueuesAPIImpl } from './queues-api';\n\n/**\n * @deprecated\n */\nexport class SpaceProxy extends Resource {\n private _db?: EchoDatabaseImpl = undefined;\n private _queuesApi: QueuesAPIImpl;\n\n constructor(\n private readonly _serviceContainer: ServiceContainer,\n private readonly _echoClient: EchoClient,\n private readonly _id: SpaceId,\n ) {\n super();\n this._queuesApi = new QueuesAPIImpl(this._serviceContainer, this._id);\n }\n\n get id(): SpaceId {\n return this._id;\n }\n\n get db(): Database.Database {\n invariant(this._db);\n return this._db;\n }\n\n /**\n * @deprecated Use db API.\n */\n get crud(): CoreDatabase {\n invariant(this._db);\n return this._db.coreDatabase;\n }\n\n get queues(): QueuesAPI {\n return this._queuesApi;\n }\n\n protected override async _open() {\n const meta = await this._serviceContainer.getSpaceMeta(this._id);\n if (!meta) {\n throw new Error(`Space not found: ${this._id}`);\n }\n\n this._db = this._echoClient.constructDatabase({\n spaceId: this._id,\n spaceKey: PublicKey.from(meta.spaceKey),\n reactiveSchemaQuery: false,\n owningObject: this,\n });\n\n await this._db.coreDatabase.open(this._ctx, { rootUrl: meta.rootDocumentId });\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type AnyEntity } from '@dxos/echo/internal';\nimport type { DXN, SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\n\nimport type { ServiceContainer } from './internal';\n\nexport interface QueuesQueryResult {\n objects: AnyEntity[];\n nextCursor: string | null;\n prevCursor: string | null;\n}\n\n// TODO(dmaretskyi): Temporary API to get the queues working.\n// TODO(dmaretskyi): To be replaced with integrating queues into echo.\n/**\n * @deprecated\n */\nexport interface QueuesAPI {\n queryQueue(queue: DXN, options?: {}): Promise<QueuesQueryResult>;\n insertIntoQueue(queue: DXN, objects: AnyEntity[]): Promise<void>;\n}\n\n/**\n * @deprecated\n */\nexport class QueuesAPIImpl implements QueuesAPI {\n constructor(\n private readonly _serviceContainer: ServiceContainer,\n private readonly _spaceId: SpaceId,\n ) {}\n\n async queryQueue(queue: DXN, options?: {}): Promise<QueuesQueryResult> {\n const result = await this._serviceContainer.queryQueue(queue);\n const objects = (result.objects ?? []).flatMap((encoded): AnyEntity[] => {\n try {\n return [JSON.parse(encoded) as AnyEntity];\n } catch (err) {\n log.verbose('queue object JSON parse failed; object ignored', { encoded, error: err });\n return [];\n }\n });\n return {\n objects,\n nextCursor: result.nextCursor ?? null,\n prevCursor: result.prevCursor ?? null,\n };\n }\n\n insertIntoQueue(queue: DXN, objects: AnyEntity[]): Promise<void> {\n // TODO(dmaretskyi): Ugly.\n return this._serviceContainer.insertIntoQueue(queue, JSON.parse(JSON.stringify(objects)));\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { JsonSchemaType } from '@dxos/echo/internal';\n\n/**\n * Is used for to route the request to the metadata handler instead of the main handler.\n */\nexport const FUNCTION_ROUTE_HEADER = 'X-DXOS-Function-Route';\n\nexport enum FunctionRouteValue {\n Meta = 'meta',\n}\n\nexport type FunctionMetadata = {\n /**\n * FQN.\n */\n key: string;\n /**\n * Human-readable name.\n */\n name?: string;\n\n /**\n * Description.\n */\n description?: string;\n\n /**\n * Input schema.\n */\n inputSchema?: JsonSchemaType;\n\n /**\n * Output schema.\n */\n outputSchema?: JsonSchemaType;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { JsonSchemaType } from '@dxos/echo/internal';\nimport { invariant } from '@dxos/invariant';\nimport { SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { EdgeResponse } from '@dxos/protocols';\nimport type { EdgeFunctionEnv, FunctionProtocol } from '@dxos/protocols';\n\nimport { ServiceContainer } from './internal';\nimport { FUNCTION_ROUTE_HEADER, type FunctionMetadata, FunctionRouteValue } from './types';\n\n/**\n * Wraps a user function in a Cloudflare-compatible handler.\n */\nexport const wrapHandlerForCloudflare = (func: FunctionProtocol.Func): ExportedHandlerFetchHandler<any> => {\n return async (request: Request, env: EdgeFunctionEnv.Env): Promise<Response> => {\n // TODO(dmaretskyi): Should theÓ scope name reflect the function name?\n // TODO(mykola): Wrap in withCleanAutomergeWasmState;\n // TODO(mykola): Wrap in withNewExecutionContext;\n // Meta route is used to get the input schema of the function by the functions service.\n if (request.headers.get(FUNCTION_ROUTE_HEADER) === FunctionRouteValue.Meta) {\n return handleFunctionMetaCall(func, request);\n }\n\n try {\n const spaceId = new URL(request.url).searchParams.get('spaceId');\n if (spaceId) {\n if (!SpaceId.isValid(spaceId)) {\n return new Response('Invalid spaceId', { status: 400 });\n }\n }\n\n const serviceContainer = new ServiceContainer({}, env.DATA_SERVICE, env.QUEUE_SERVICE, env.FUNCTIONS_AI_SERVICE);\n const context = await createFunctionContext({\n serviceContainer,\n contextSpaceId: spaceId as SpaceId | undefined,\n });\n\n return EdgeResponse.success(await invokeFunction(func, context, request));\n } catch (error: any) {\n log.error('error invoking function', { error, stack: error.stack });\n return EdgeResponse.failure({\n message: error?.message ?? 'Internal error',\n error,\n });\n }\n };\n};\n\nconst invokeFunction = async (func: FunctionProtocol.Func, context: FunctionProtocol.Context, request: Request) => {\n // TODO(dmaretskyi): For some reason requests get wrapped like this.\n const { data } = await decodeRequest(request);\n\n return func.handler({\n context,\n data,\n });\n};\n\nconst decodeRequest = async (request: Request) => {\n const {\n data: { bodyText, ...rest },\n trigger,\n } = (await request.json()) as any;\n\n if (!bodyText) {\n return { data: rest, trigger };\n }\n\n // Webhook passed body as bodyText. Use it as function input if a well-formatted JSON\n // TODO: better trigger input mapping\n try {\n const data = JSON.parse(bodyText);\n return { data, trigger: { ...trigger, ...rest } };\n } catch (err) {\n log.catch(err);\n return { data: { bodyText, ...rest } };\n }\n};\n\nconst handleFunctionMetaCall = (functionDefinition: FunctionProtocol.Func, request: Request): Response => {\n const response: FunctionMetadata = {\n key: functionDefinition.meta.key,\n name: functionDefinition.meta.name,\n description: functionDefinition.meta.description,\n inputSchema: functionDefinition.meta.inputSchema as JsonSchemaType | undefined,\n outputSchema: functionDefinition.meta.outputSchema as JsonSchemaType | undefined,\n };\n\n return new Response(JSON.stringify(response), {\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n};\n\nconst createFunctionContext = async ({\n serviceContainer,\n contextSpaceId,\n}: {\n serviceContainer: ServiceContainer;\n contextSpaceId: SpaceId | undefined;\n}): Promise<FunctionProtocol.Context> => {\n const { dataService, queryService, queueService, functionsAiService } = await serviceContainer.createServices();\n\n let spaceKey: string | undefined;\n let rootUrl: string | undefined;\n if (contextSpaceId) {\n const meta = await serviceContainer.getSpaceMeta(contextSpaceId);\n if (!meta) {\n throw new Error(`Space not found: ${contextSpaceId}`);\n }\n spaceKey = meta.spaceKey;\n invariant(!meta.rootDocumentId.startsWith('automerge:'));\n rootUrl = `automerge:${meta.rootDocumentId}`;\n }\n\n return {\n services: {\n dataService,\n queryService,\n queueService,\n functionsAiService,\n },\n spaceId: contextSpaceId,\n spaceKey,\n spaceRootUrl: rootUrl,\n } as any; // TODO(dmaretskyi): Link and fix before merging\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\n/* eslint-disable no-console */\n\nimport { LogLevel, type LogProcessor, log, shouldLog } from '@dxos/log';\n\nexport const setupFunctionsLogger = () => {\n log.runtimeConfig.processors.length = 0;\n log.runtimeConfig.processors.push(functionLogProcessor);\n};\n\nconst functionLogProcessor: LogProcessor = (config, entry) => {\n if (!shouldLog(entry, config.filters)) {\n return;\n }\n\n const context = entry.computedContext;\n const error = entry.computedError;\n const extras = [Object.keys(context).length > 0 ? context : undefined, error].filter((value) => value !== undefined);\n\n switch (entry.level) {\n case LogLevel.DEBUG:\n case LogLevel.TRACE:\n console.debug(entry.message, ...extras);\n break;\n case LogLevel.VERBOSE:\n console.log(entry.message, ...extras);\n break;\n case LogLevel.INFO:\n console.info(entry.message, ...extras);\n break;\n case LogLevel.WARN:\n console.warn(entry.message, ...extras);\n break;\n case LogLevel.ERROR:\n console.error(entry.message, ...extras);\n break;\n default:\n console.log(entry.message, ...extras);\n break;\n }\n};\n"],
5
+ "mappings": ";AAIA,SAASA,YAA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;MACAC;MACAC;MACAC;IACF;IACA/C,SAASe;IACTkC;IACAQ,cAAcP;EAChB;AACF;;;AC7HA,SAASQ,UAA6BC,OAAAA,MAAKC,iBAAiB;AAErD,IAAMC,uBAAuB,MAAA;AAClCC,EAAAA,KAAIC,cAAcC,WAAWC,SAAS;AACtCH,EAAAA,KAAIC,cAAcC,WAAWE,KAAKC,oBAAAA;AACpC;AAEA,IAAMA,uBAAqC,CAACC,QAAQC,UAAAA;AAClD,MAAI,CAACC,UAAUD,OAAOD,OAAOG,OAAO,GAAG;AACrC;EACF;AAEA,QAAMC,UAAUH,MAAMI;AACtB,QAAMC,QAAQL,MAAMM;AACpB,QAAMC,SAAS;IAACC,OAAOC,KAAKN,OAAAA,EAASP,SAAS,IAAIO,UAAUO;IAAWL;IAAOM,OAAO,CAACC,UAAUA,UAAUF,MAAAA;AAE1G,UAAQV,MAAMa,OAAK;IACjB,KAAKC,SAASC;IACd,KAAKD,SAASE;AACZC,cAAQC,MAAMlB,MAAMmB,SAAO,GAAKZ,MAAAA;AAChC;IACF,KAAKO,SAASM;AACZH,cAAQxB,IAAIO,MAAMmB,SAAO,GAAKZ,MAAAA;AAC9B;IACF,KAAKO,SAASO;AACZJ,cAAQK,KAAKtB,MAAMmB,SAAO,GAAKZ,MAAAA;AAC/B;IACF,KAAKO,SAASS;AACZN,cAAQO,KAAKxB,MAAMmB,SAAO,GAAKZ,MAAAA;AAC/B;IACF,KAAKO,SAASW;AACZR,cAAQZ,MAAML,MAAMmB,SAAO,GAAKZ,MAAAA;AAChC;IACF;AACEU,cAAQxB,IAAIO,MAAMmB,SAAO,GAAKZ,MAAAA;AAC9B;EACJ;AACF;",
6
+ "names": ["Resource", "EchoClient", "invariant", "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", "map", "obj", "JSON", "stringify", "Resource", "invariant", "PublicKey", "log", "QueuesAPIImpl", "_serviceContainer", "_spaceId", "queryQueue", "queue", "options", "result", "objects", "flatMap", "encoded", "JSON", "parse", "err", "verbose", "error", "nextCursor", "prevCursor", "insertIntoQueue", "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", "context", "computedContext", "error", "computedError", "extras", "Object", "keys", "undefined", "filter", "value", "level", "LogLevel", "DEBUG", "TRACE", "console", "debug", "message", "VERBOSE", "INFO", "info", "WARN", "warn", "ERROR"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/internal/utils.ts":{"bytes":692,"imports":[],"format":"esm"},"src/internal/data-service-impl.ts":{"bytes":19654,"imports":[{"path":"@dxos/codec-protobuf/stream","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"src/internal/utils.ts","kind":"import-statement","original":"./utils"}],"format":"esm"},"src/internal/query-service-impl.ts":{"bytes":9761,"imports":[{"path":"@dxos/codec-protobuf/stream","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/internal/queue-service-impl.ts":{"bytes":11363,"imports":[{"path":"@dxos/errors","kind":"import-statement","external":true}],"format":"esm"},"src/internal/service-container.ts":{"bytes":12952,"imports":[{"path":"src/internal/data-service-impl.ts","kind":"import-statement","original":"./data-service-impl"},{"path":"src/internal/query-service-impl.ts","kind":"import-statement","original":"./query-service-impl"},{"path":"src/internal/queue-service-impl.ts","kind":"import-statement","original":"./queue-service-impl"}],"format":"esm"},"src/internal/index.ts":{"bytes":503,"imports":[{"path":"src/internal/service-container.ts","kind":"import-statement","original":"./service-container"}],"format":"esm"},"src/queues-api.ts":{"bytes":3005,"imports":[],"format":"esm"},"src/space-proxy.ts":{"bytes":6240,"imports":[{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"src/queues-api.ts","kind":"import-statement","original":"./queues-api"}],"format":"esm"},"src/functions-client.ts":{"bytes":9322,"imports":[{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/internal/index.ts","kind":"import-statement","original":"./internal"},{"path":"src/space-proxy.ts","kind":"import-statement","original":"./space-proxy"}],"format":"esm"},"src/types.ts":{"bytes":1696,"imports":[],"format":"esm"},"src/wrap-handler-for-cloudflare.ts":{"bytes":15375,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"src/internal/index.ts","kind":"import-statement","original":"./internal"},{"path":"src/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"src/logger.ts":{"bytes":4389,"imports":[{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":879,"imports":[{"path":"src/functions-client.ts","kind":"import-statement","original":"./functions-client"},{"path":"src/internal/index.ts","kind":"import-statement","original":"./internal"},{"path":"src/types.ts","kind":"import-statement","original":"./types"},{"path":"src/wrap-handler-for-cloudflare.ts","kind":"import-statement","original":"./wrap-handler-for-cloudflare"},{"path":"src/logger.ts","kind":"import-statement","original":"./logger"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":39868},"dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/codec-protobuf/stream","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/codec-protobuf/stream","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["FUNCTION_ROUTE_HEADER","FunctionRouteValue","FunctionsClient","ServiceContainer","createClientFromEnv","setupFunctionsLogger","wrapHandlerForCloudflare"],"entryPoint":"src/index.ts","inputs":{"src/functions-client.ts":{"bytesInOutput":2163},"src/internal/data-service-impl.ts":{"bytesInOutput":7096},"src/internal/utils.ts":{"bytesInOutput":55},"src/internal/query-service-impl.ts":{"bytesInOutput":4571},"src/internal/queue-service-impl.ts":{"bytesInOutput":4790},"src/internal/service-container.ts":{"bytesInOutput":4409},"src/space-proxy.ts":{"bytesInOutput":1546},"src/queues-api.ts":{"bytesInOutput":414},"src/index.ts":{"bytesInOutput":0},"src/types.ts":{"bytesInOutput":205},"src/wrap-handler-for-cloudflare.ts":{"bytesInOutput":3517},"src/logger.ts":{"bytesInOutput":948}},"bytes":30336}}}
1
+ {"inputs":{"src/internal/utils.ts":{"bytes":692,"imports":[],"format":"esm"},"src/internal/data-service-impl.ts":{"bytes":19959,"imports":[{"path":"@dxos/codec-protobuf/stream","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"src/internal/utils.ts","kind":"import-statement","original":"./utils"}],"format":"esm"},"src/internal/query-service-impl.ts":{"bytes":9761,"imports":[{"path":"@dxos/codec-protobuf/stream","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/internal/queue-service-impl.ts":{"bytes":11363,"imports":[{"path":"@dxos/errors","kind":"import-statement","external":true}],"format":"esm"},"src/internal/service-container.ts":{"bytes":13064,"imports":[{"path":"src/internal/data-service-impl.ts","kind":"import-statement","original":"./data-service-impl"},{"path":"src/internal/query-service-impl.ts","kind":"import-statement","original":"./query-service-impl"},{"path":"src/internal/queue-service-impl.ts","kind":"import-statement","original":"./queue-service-impl"}],"format":"esm"},"src/internal/index.ts":{"bytes":503,"imports":[{"path":"src/internal/service-container.ts","kind":"import-statement","original":"./service-container"}],"format":"esm"},"src/queues-api.ts":{"bytes":5096,"imports":[{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/space-proxy.ts":{"bytes":6303,"imports":[{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"src/queues-api.ts","kind":"import-statement","original":"./queues-api"}],"format":"esm"},"src/functions-client.ts":{"bytes":9322,"imports":[{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/internal/index.ts","kind":"import-statement","original":"./internal"},{"path":"src/space-proxy.ts","kind":"import-statement","original":"./space-proxy"}],"format":"esm"},"src/types.ts":{"bytes":1696,"imports":[],"format":"esm"},"src/wrap-handler-for-cloudflare.ts":{"bytes":15375,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"src/internal/index.ts","kind":"import-statement","original":"./internal"},{"path":"src/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"src/logger.ts":{"bytes":4865,"imports":[{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":879,"imports":[{"path":"src/functions-client.ts","kind":"import-statement","original":"./functions-client"},{"path":"src/internal/index.ts","kind":"import-statement","original":"./internal"},{"path":"src/types.ts","kind":"import-statement","original":"./types"},{"path":"src/wrap-handler-for-cloudflare.ts","kind":"import-statement","original":"./wrap-handler-for-cloudflare"},{"path":"src/logger.ts","kind":"import-statement","original":"./logger"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":41345},"dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/codec-protobuf/stream","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/codec-protobuf/stream","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["FUNCTION_ROUTE_HEADER","FunctionRouteValue","FunctionsClient","ServiceContainer","createClientFromEnv","setupFunctionsLogger","wrapHandlerForCloudflare"],"entryPoint":"src/index.ts","inputs":{"src/functions-client.ts":{"bytesInOutput":2163},"src/internal/data-service-impl.ts":{"bytesInOutput":7263},"src/internal/utils.ts":{"bytesInOutput":55},"src/internal/query-service-impl.ts":{"bytesInOutput":4571},"src/internal/queue-service-impl.ts":{"bytesInOutput":4790},"src/internal/service-container.ts":{"bytesInOutput":4452},"src/space-proxy.ts":{"bytesInOutput":1557},"src/queues-api.ts":{"bytesInOutput":1124},"src/index.ts":{"bytesInOutput":0},"src/types.ts":{"bytesInOutput":205},"src/wrap-handler-for-cloudflare.ts":{"bytesInOutput":3517},"src/logger.ts":{"bytesInOutput":1064}},"bytes":31383}}}