@dxos/functions-runtime-cloudflare 0.8.4-main.3eb6e50203 → 0.8.4-main.3fbcb4aa9b

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.
Files changed (35) hide show
  1. package/dist/lib/browser/index.mjs +78 -269
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +78 -269
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/functions-client.d.ts.map +1 -1
  8. package/dist/types/src/internal/data-service-impl.d.ts +1 -1
  9. package/dist/types/src/internal/data-service-impl.d.ts.map +1 -1
  10. package/dist/types/src/internal/query-service-impl.d.ts +3 -9
  11. package/dist/types/src/internal/query-service-impl.d.ts.map +1 -1
  12. package/dist/types/src/internal/queue-service-impl.d.ts +3 -2
  13. package/dist/types/src/internal/queue-service-impl.d.ts.map +1 -1
  14. package/dist/types/src/internal/service-container.d.ts +1 -1
  15. package/dist/types/src/internal/service-container.d.ts.map +1 -1
  16. package/dist/types/src/internal/utils.d.ts.map +1 -1
  17. package/dist/types/src/queues-api.d.ts +7 -3
  18. package/dist/types/src/queues-api.d.ts.map +1 -1
  19. package/dist/types/src/space-proxy.d.ts.map +1 -1
  20. package/dist/types/src/wrap-handler-for-cloudflare.d.ts +6 -0
  21. package/dist/types/src/wrap-handler-for-cloudflare.d.ts.map +1 -1
  22. package/dist/types/tsconfig.tsbuildinfo +1 -1
  23. package/package.json +16 -16
  24. package/src/functions-client.ts +1 -1
  25. package/src/internal/data-service-impl.ts +3 -2
  26. package/src/internal/query-service-impl.ts +8 -62
  27. package/src/internal/queue-service-impl.ts +5 -1
  28. package/src/internal/service-container.ts +2 -2
  29. package/src/logger.ts +10 -8
  30. package/src/queues-api.ts +23 -4
  31. package/src/space-proxy.ts +1 -1
  32. package/src/wrap-handler-for-cloudflare.ts +1 -1
  33. package/dist/types/src/internal/adapter.d.ts +0 -12
  34. package/dist/types/src/internal/adapter.d.ts.map +0 -1
  35. package/src/internal/adapter.ts +0 -48
@@ -3,7 +3,7 @@ import { createRequire } from 'node:module';const require = createRequire(import
3
3
  // src/functions-client.ts
4
4
  import { Resource as Resource2 } from "@dxos/context";
5
5
  import { EchoClient } from "@dxos/echo-db";
6
- import { invariant as invariant5 } from "@dxos/invariant";
6
+ import { invariant as invariant3 } from "@dxos/invariant";
7
7
 
8
8
  // src/internal/data-service-impl.ts
9
9
  import { Stream } from "@dxos/codec-protobuf/stream";
@@ -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,10 +159,8 @@ var DataServiceImpl = class {
182
159
  hasError: false
183
160
  };
184
161
  try {
185
- const response = _ts_add_disposable_resource(env, await this._dataService.createDocument(this._executionContext, {
186
- spaceId,
187
- initialValue
188
- }), false);
162
+ invariant(SpaceId.isValid(spaceId), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 153, S: this, A: ["SpaceId.isValid(spaceId)", ""] });
163
+ const response = _ts_add_disposable_resource(env, await this._dataService.createDocument(this._executionContext, spaceId, initialValue), false);
189
164
  return {
190
165
  documentId: response.documentId
191
166
  };
@@ -235,12 +210,7 @@ var DataServiceImpl = class {
235
210
  });
236
211
  }
237
212
  async updateIndexes() {
238
- log.error("updateIndexes is not available in EDGE env.", void 0, {
239
- F: __dxlog_file,
240
- L: 133,
241
- S: this,
242
- C: (f, a) => f(...a)
243
- });
213
+ log.error("updateIndexes is not available in EDGE env.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 206, S: this });
244
214
  }
245
215
  async waitUntilHeadsReplicated({ heads: _heads }) {
246
216
  throw new NotImplementedError({
@@ -250,83 +220,10 @@ var DataServiceImpl = class {
250
220
  };
251
221
 
252
222
  // src/internal/query-service-impl.ts
253
- import * as Schema from "effect/Schema";
254
223
  import { Stream as Stream2 } from "@dxos/codec-protobuf/stream";
255
- import { QueryAST } from "@dxos/echo-protocol";
256
224
  import { NotImplementedError as NotImplementedError2, RuntimeServiceError as RuntimeServiceError2 } from "@dxos/errors";
257
- import { invariant as invariant3 } from "@dxos/invariant";
258
- import { PublicKey } from "@dxos/keys";
259
- import { SpaceId as SpaceId3 } from "@dxos/keys";
260
225
  import { log as log2 } from "@dxos/log";
261
-
262
- // src/internal/adapter.ts
263
- import { failUndefined } from "@dxos/debug";
264
- import { invariant as invariant2 } from "@dxos/invariant";
265
- import { SpaceId as SpaceId2 } from "@dxos/keys";
266
- var __dxlog_file2 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/adapter.ts";
267
- var queryToDataServiceRequest = (query) => {
268
- const { filter, options } = isSimpleSelectionQuery(query) ?? failUndefined();
269
- invariant2(options?.spaceIds?.length === 1, "Only one space is supported", {
270
- F: __dxlog_file2,
271
- L: 13,
272
- S: void 0,
273
- A: [
274
- "options?.spaceIds?.length === 1",
275
- "'Only one space is supported'"
276
- ]
277
- });
278
- invariant2(filter.type === "object", "Only object filters are supported", {
279
- F: __dxlog_file2,
280
- L: 14,
281
- S: void 0,
282
- A: [
283
- "filter.type === 'object'",
284
- "'Only object filters are supported'"
285
- ]
286
- });
287
- const spaceId = options.spaceIds[0];
288
- invariant2(SpaceId2.isValid(spaceId), void 0, {
289
- F: __dxlog_file2,
290
- L: 17,
291
- S: void 0,
292
- A: [
293
- "SpaceId.isValid(spaceId)",
294
- ""
295
- ]
296
- });
297
- return {
298
- spaceId,
299
- type: filter.typename ?? void 0,
300
- objectIds: [
301
- ...filter.id ?? []
302
- ]
303
- };
304
- };
305
- var isSimpleSelectionQuery = (query) => {
306
- switch (query.type) {
307
- case "options": {
308
- const maybeFilter = isSimpleSelectionQuery(query.query);
309
- if (!maybeFilter) {
310
- return null;
311
- }
312
- return {
313
- filter: maybeFilter.filter,
314
- options: query.options
315
- };
316
- }
317
- case "select": {
318
- return {
319
- filter: query.filter,
320
- options: void 0
321
- };
322
- }
323
- default: {
324
- return null;
325
- }
326
- }
327
- };
328
-
329
- // src/internal/query-service-impl.ts
226
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/internal/query-service-impl.ts";
330
227
  function _ts_add_disposable_resource2(env, value, async) {
331
228
  if (value !== null && value !== void 0) {
332
229
  if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
@@ -392,7 +289,6 @@ function _ts_dispose_resources2(env) {
392
289
  return next();
393
290
  })(env);
394
291
  }
395
- var __dxlog_file3 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/query-service-impl.ts";
396
292
  var QueryServiceImpl = class {
397
293
  _executionContext;
398
294
  _dataService;
@@ -404,24 +300,7 @@ var QueryServiceImpl = class {
404
300
  execQuery(request) {
405
301
  log2.info("execQuery", {
406
302
  request
407
- }, {
408
- F: __dxlog_file3,
409
- L: 34,
410
- S: this,
411
- C: (f, a) => f(...a)
412
- });
413
- const query = QueryAST.Query.pipe(Schema.decodeUnknownSync)(JSON.parse(request.query));
414
- const requestedSpaceIds = getTargetSpacesForQuery(query);
415
- invariant3(requestedSpaceIds.length === 1, "Only one space is supported", {
416
- F: __dxlog_file3,
417
- L: 37,
418
- S: this,
419
- A: [
420
- "requestedSpaceIds.length === 1",
421
- "'Only one space is supported'"
422
- ]
423
- });
424
- const spaceId = requestedSpaceIds[0];
303
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 81, S: this });
425
304
  return Stream2.fromPromise((async () => {
426
305
  try {
427
306
  const env = {
@@ -432,37 +311,13 @@ var QueryServiceImpl = class {
432
311
  try {
433
312
  this._queryCount++;
434
313
  log2.info("begin query", {
435
- spaceId
436
- }, {
437
- F: __dxlog_file3,
438
- L: 44,
439
- S: this,
440
- C: (f, a) => f(...a)
441
- });
442
- const queryResponse = _ts_add_disposable_resource2(env, await this._dataService.queryDocuments(this._executionContext, queryToDataServiceRequest(query)), false);
314
+ request
315
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 93, S: this });
316
+ const queryResponse = _ts_add_disposable_resource2(env, await this._dataService.execQuery(this._executionContext, request), false);
443
317
  log2.info("query response", {
444
- spaceId,
445
- filter: request.filter,
446
- resultCount: queryResponse.results.length
447
- }, {
448
- F: __dxlog_file3,
449
- L: 49,
450
- S: this,
451
- C: (f, a) => f(...a)
452
- });
453
- return {
454
- results: queryResponse.results.map((object) => ({
455
- id: object.objectId,
456
- spaceId,
457
- spaceKey: PublicKey.ZERO,
458
- documentId: object.document.documentId,
459
- // Rank 1 for predicate matches where ranking is not determined.
460
- rank: 1,
461
- // Copy returned object to avoid hanging RPC stub.
462
- // See https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/
463
- documentAutomerge: copyUint8Array(object.document.data)
464
- }))
465
- };
318
+ resultCount: queryResponse.results?.length
319
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 97, S: this });
320
+ return structuredClone(queryResponse);
466
321
  } catch (e) {
467
322
  env.error = e;
468
323
  env.hasError = true;
@@ -472,17 +327,10 @@ var QueryServiceImpl = class {
472
327
  } catch (error) {
473
328
  log2.error("query failed", {
474
329
  err: error
475
- }, {
476
- F: __dxlog_file3,
477
- L: 66,
478
- S: this,
479
- C: (f, a) => f(...a)
480
- });
330
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 108, S: this });
481
331
  throw new RuntimeServiceError2({
482
332
  message: `Query execution failed (queryCount=${this._queryCount})`,
483
333
  context: {
484
- spaceId,
485
- filter: request.filter,
486
334
  queryCount: this._queryCount
487
335
  },
488
336
  cause: error
@@ -501,22 +349,6 @@ var QueryServiceImpl = class {
501
349
  });
502
350
  }
503
351
  };
504
- var getTargetSpacesForQuery = (query) => {
505
- const spaces = /* @__PURE__ */ new Set();
506
- const visitor = (node) => {
507
- if (node.type === "options") {
508
- if (node.options.spaceIds) {
509
- for (const spaceId of node.options.spaceIds) {
510
- spaces.add(SpaceId3.make(spaceId));
511
- }
512
- }
513
- }
514
- };
515
- QueryAST.visit(query, visitor);
516
- return [
517
- ...spaces
518
- ];
519
- };
520
352
 
521
353
  // src/internal/queue-service-impl.ts
522
354
  import { RuntimeServiceError as RuntimeServiceError3 } from "@dxos/errors";
@@ -681,6 +513,8 @@ var QueueServiceImpl = class {
681
513
  })(error);
682
514
  }
683
515
  }
516
+ async syncQueue(_) {
517
+ }
684
518
  };
685
519
 
686
520
  // src/internal/service-container.ts
@@ -821,17 +655,19 @@ var ServiceContainer = class {
821
655
  subspaceTag,
822
656
  spaceId,
823
657
  queueId,
824
- objects
658
+ objects: objects.map((obj) => JSON.stringify(obj))
825
659
  });
826
660
  }
827
661
  };
828
662
 
829
663
  // src/space-proxy.ts
830
664
  import { Resource } from "@dxos/context";
831
- import { invariant as invariant4 } from "@dxos/invariant";
832
- import { PublicKey as PublicKey2 } from "@dxos/keys";
665
+ import { invariant as invariant2 } from "@dxos/invariant";
666
+ import { PublicKey } from "@dxos/keys";
833
667
 
834
668
  // src/queues-api.ts
669
+ import { log as log3 } from "@dxos/log";
670
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/queues-api.ts";
835
671
  var QueuesAPIImpl = class {
836
672
  _serviceContainer;
837
673
  _spaceId;
@@ -839,8 +675,26 @@ var QueuesAPIImpl = class {
839
675
  this._serviceContainer = _serviceContainer;
840
676
  this._spaceId = _spaceId;
841
677
  }
842
- queryQueue(queue, options) {
843
- return this._serviceContainer.queryQueue(queue);
678
+ async queryQueue(queue, options) {
679
+ const result = await this._serviceContainer.queryQueue(queue);
680
+ const objects = (result.objects ?? []).flatMap((encoded) => {
681
+ try {
682
+ return [
683
+ JSON.parse(encoded)
684
+ ];
685
+ } catch (err) {
686
+ log3.verbose("queue object JSON parse failed; object ignored", {
687
+ encoded,
688
+ error: err
689
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 22, S: this });
690
+ return [];
691
+ }
692
+ });
693
+ return {
694
+ objects,
695
+ nextCursor: result.nextCursor ?? null,
696
+ prevCursor: result.prevCursor ?? null
697
+ };
844
698
  }
845
699
  insertIntoQueue(queue, objects) {
846
700
  return this._serviceContainer.insertIntoQueue(queue, JSON.parse(JSON.stringify(objects)));
@@ -848,7 +702,7 @@ var QueuesAPIImpl = class {
848
702
  };
849
703
 
850
704
  // src/space-proxy.ts
851
- var __dxlog_file4 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/space-proxy.ts";
705
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/space-proxy.ts";
852
706
  var SpaceProxy = class extends Resource {
853
707
  _serviceContainer;
854
708
  _echoClient;
@@ -863,30 +717,14 @@ var SpaceProxy = class extends Resource {
863
717
  return this._id;
864
718
  }
865
719
  get db() {
866
- invariant4(this._db, void 0, {
867
- F: __dxlog_file4,
868
- L: 35,
869
- S: this,
870
- A: [
871
- "this._db",
872
- ""
873
- ]
874
- });
720
+ invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 24, S: this, A: ["this._db", ""] });
875
721
  return this._db;
876
722
  }
877
723
  /**
878
724
  * @deprecated Use db API.
879
725
  */
880
726
  get crud() {
881
- invariant4(this._db, void 0, {
882
- F: __dxlog_file4,
883
- L: 43,
884
- S: this,
885
- A: [
886
- "this._db",
887
- ""
888
- ]
889
- });
727
+ invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 30, S: this, A: ["this._db", ""] });
890
728
  return this._db.coreDatabase;
891
729
  }
892
730
  get queues() {
@@ -899,18 +737,18 @@ var SpaceProxy = class extends Resource {
899
737
  }
900
738
  this._db = this._echoClient.constructDatabase({
901
739
  spaceId: this._id,
902
- spaceKey: PublicKey2.from(meta.spaceKey),
740
+ spaceKey: PublicKey.from(meta.spaceKey),
903
741
  reactiveSchemaQuery: false,
904
742
  owningObject: this
905
743
  });
906
- await this._db.coreDatabase.open({
744
+ await this._db.coreDatabase.open(this._ctx, {
907
745
  rootUrl: meta.rootDocumentId
908
746
  });
909
747
  }
910
748
  };
911
749
 
912
750
  // src/functions-client.ts
913
- var __dxlog_file5 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/functions-client.ts";
751
+ var __dxlog_file5 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/functions-client.ts";
914
752
  var FunctionsClient = class extends Resource2 {
915
753
  _serviceContainer;
916
754
  _echoClient;
@@ -918,24 +756,8 @@ var FunctionsClient = class extends Resource2 {
918
756
  _spaces = /* @__PURE__ */ new Map();
919
757
  constructor(services) {
920
758
  super();
921
- invariant5(typeof services.dataService !== "undefined", "DataService is required", {
922
- F: __dxlog_file5,
923
- L: 33,
924
- S: this,
925
- A: [
926
- "typeof services.dataService !== 'undefined'",
927
- "'DataService is required'"
928
- ]
929
- });
930
- invariant5(typeof services.queueService !== "undefined", "QueueService is required", {
931
- F: __dxlog_file5,
932
- L: 34,
933
- S: this,
934
- A: [
935
- "typeof services.queueService !== 'undefined'",
936
- "'QueueService is required'"
937
- ]
938
- });
759
+ invariant3(typeof services.dataService !== "undefined", "DataService is required", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 19, S: this, A: ["typeof services.dataService !== 'undefined'", "'DataService is required'"] });
760
+ invariant3(typeof services.queueService !== "undefined", "QueueService is required", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 20, S: this, A: ["typeof services.queueService !== 'undefined'", "'QueueService is required'"] });
939
761
  this._serviceContainer = new ServiceContainer(this._executionContext, services.dataService, services.queueService, services.functionsAiService);
940
762
  this._echoClient = new EchoClient({});
941
763
  }
@@ -985,11 +807,11 @@ var FunctionRouteValue = /* @__PURE__ */ (function(FunctionRouteValue2) {
985
807
  })({});
986
808
 
987
809
  // src/wrap-handler-for-cloudflare.ts
988
- import { invariant as invariant6 } from "@dxos/invariant";
989
- import { SpaceId as SpaceId4 } from "@dxos/keys";
990
- import { log as log3 } from "@dxos/log";
810
+ import { invariant as invariant4 } from "@dxos/invariant";
811
+ import { SpaceId as SpaceId2 } from "@dxos/keys";
812
+ import { log as log4 } from "@dxos/log";
991
813
  import { EdgeResponse } from "@dxos/protocols";
992
- var __dxlog_file6 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/wrap-handler-for-cloudflare.ts";
814
+ var __dxlog_file6 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/wrap-handler-for-cloudflare.ts";
993
815
  var wrapHandlerForCloudflare = (func) => {
994
816
  return async (request, env) => {
995
817
  if (request.headers.get(FUNCTION_ROUTE_HEADER) === FunctionRouteValue.Meta) {
@@ -998,7 +820,7 @@ var wrapHandlerForCloudflare = (func) => {
998
820
  try {
999
821
  const spaceId = new URL(request.url).searchParams.get("spaceId");
1000
822
  if (spaceId) {
1001
- if (!SpaceId4.isValid(spaceId)) {
823
+ if (!SpaceId2.isValid(spaceId)) {
1002
824
  return new Response("Invalid spaceId", {
1003
825
  status: 400
1004
826
  });
@@ -1011,15 +833,10 @@ var wrapHandlerForCloudflare = (func) => {
1011
833
  });
1012
834
  return EdgeResponse.success(await invokeFunction(func, context, request));
1013
835
  } catch (error) {
1014
- log3.error("error invoking function", {
836
+ log4.error("error invoking function", {
1015
837
  error,
1016
838
  stack: error.stack
1017
- }, {
1018
- F: __dxlog_file6,
1019
- L: 44,
1020
- S: void 0,
1021
- C: (f, a) => f(...a)
1022
- });
839
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 37, S: void 0 });
1023
840
  return EdgeResponse.failure({
1024
841
  message: error?.message ?? "Internal error",
1025
842
  error
@@ -1052,12 +869,7 @@ var decodeRequest = async (request) => {
1052
869
  }
1053
870
  };
1054
871
  } catch (err) {
1055
- log3.catch(err, void 0, {
1056
- F: __dxlog_file6,
1057
- L: 79,
1058
- S: void 0,
1059
- C: (f, a) => f(...a)
1060
- });
872
+ log4.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 76, S: void 0 });
1061
873
  return {
1062
874
  data: {
1063
875
  bodyText,
@@ -1090,15 +902,7 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
1090
902
  throw new Error(`Space not found: ${contextSpaceId}`);
1091
903
  }
1092
904
  spaceKey = meta.spaceKey;
1093
- invariant6(!meta.rootDocumentId.startsWith("automerge:"), void 0, {
1094
- F: __dxlog_file6,
1095
- L: 117,
1096
- S: void 0,
1097
- A: [
1098
- "!meta.rootDocumentId.startsWith('automerge:')",
1099
- ""
1100
- ]
1101
- });
905
+ invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 109, S: void 0, A: ["!meta.rootDocumentId.startsWith('automerge:')", ""] });
1102
906
  rootUrl = `automerge:${meta.rootDocumentId}`;
1103
907
  }
1104
908
  return {
@@ -1115,36 +919,40 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
1115
919
  };
1116
920
 
1117
921
  // src/logger.ts
1118
- import { LogLevel, log as log4, shouldLog } from "@dxos/log";
922
+ import { LogLevel, log as log5, shouldLog } from "@dxos/log";
1119
923
  var setupFunctionsLogger = () => {
1120
- log4.runtimeConfig.processors.length = 0;
1121
- log4.runtimeConfig.processors.push(functionLogProcessor);
924
+ log5.runtimeConfig.processors.length = 0;
925
+ log5.runtimeConfig.processors.push(functionLogProcessor);
1122
926
  };
1123
927
  var functionLogProcessor = (config, entry) => {
1124
928
  if (!shouldLog(entry, config.filters)) {
1125
929
  return;
1126
930
  }
931
+ const context = entry.computedContext;
932
+ const error = entry.computedError;
933
+ const extras = [
934
+ Object.keys(context).length > 0 ? context : void 0,
935
+ error
936
+ ].filter((value) => value !== void 0);
1127
937
  switch (entry.level) {
1128
938
  case LogLevel.DEBUG:
1129
- console.debug(entry.message, entry.context);
1130
- break;
1131
939
  case LogLevel.TRACE:
1132
- console.debug(entry.message, entry.context);
940
+ console.debug(entry.message, ...extras);
1133
941
  break;
1134
942
  case LogLevel.VERBOSE:
1135
- console.log(entry.message, entry.context);
943
+ console.log(entry.message, ...extras);
1136
944
  break;
1137
945
  case LogLevel.INFO:
1138
- console.info(entry.message, entry.context);
946
+ console.info(entry.message, ...extras);
1139
947
  break;
1140
948
  case LogLevel.WARN:
1141
- console.warn(entry.message, entry.context);
949
+ console.warn(entry.message, ...extras);
1142
950
  break;
1143
951
  case LogLevel.ERROR:
1144
- console.error(entry.message, entry.context);
952
+ console.error(entry.message, ...extras);
1145
953
  break;
1146
954
  default:
1147
- console.log(entry.message, entry.context);
955
+ console.log(entry.message, ...extras);
1148
956
  break;
1149
957
  }
1150
958
  };
@@ -1154,6 +962,7 @@ export {
1154
962
  FunctionsClient,
1155
963
  ServiceContainer,
1156
964
  createClientFromEnv,
965
+ createFunctionContext,
1157
966
  setupFunctionsLogger,
1158
967
  wrapHandlerForCloudflare
1159
968
  };