@dxos/functions-runtime-cloudflare 0.8.4-main.ef1bc66f44 → 0.8.4-main.fcfe5033a5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +124 -213
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +124 -213
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/functions-client.d.ts.map +1 -1
- package/dist/types/src/internal/data-service-impl.d.ts +1 -1
- package/dist/types/src/internal/data-service-impl.d.ts.map +1 -1
- package/dist/types/src/internal/query-service-impl.d.ts +3 -9
- package/dist/types/src/internal/query-service-impl.d.ts.map +1 -1
- package/dist/types/src/internal/queue-service-impl.d.ts +3 -2
- package/dist/types/src/internal/queue-service-impl.d.ts.map +1 -1
- package/dist/types/src/internal/service-container.d.ts +1 -1
- package/dist/types/src/internal/service-container.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -16
- package/src/functions-client.ts +1 -1
- package/src/internal/data-service-impl.ts +3 -2
- package/src/internal/query-service-impl.ts +8 -62
- package/src/internal/queue-service-impl.ts +28 -24
- package/src/internal/service-container.ts +24 -6
- package/src/space-proxy.ts +1 -1
- package/dist/types/src/internal/adapter.d.ts +0 -12
- package/dist/types/src/internal/adapter.d.ts.map +0 -1
- 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
|
|
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";
|
|
@@ -182,10 +182,16 @@ var DataServiceImpl = class {
|
|
|
182
182
|
hasError: false
|
|
183
183
|
};
|
|
184
184
|
try {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
invariant(SpaceId.isValid(spaceId), void 0, {
|
|
186
|
+
F: __dxlog_file,
|
|
187
|
+
L: 83,
|
|
188
|
+
S: this,
|
|
189
|
+
A: [
|
|
190
|
+
"SpaceId.isValid(spaceId)",
|
|
191
|
+
""
|
|
192
|
+
]
|
|
193
|
+
});
|
|
194
|
+
const response = _ts_add_disposable_resource(env, await this._dataService.createDocument(this._executionContext, spaceId, initialValue), false);
|
|
189
195
|
return {
|
|
190
196
|
documentId: response.documentId
|
|
191
197
|
};
|
|
@@ -237,7 +243,7 @@ var DataServiceImpl = class {
|
|
|
237
243
|
async updateIndexes() {
|
|
238
244
|
log.error("updateIndexes is not available in EDGE env.", void 0, {
|
|
239
245
|
F: __dxlog_file,
|
|
240
|
-
L:
|
|
246
|
+
L: 134,
|
|
241
247
|
S: this,
|
|
242
248
|
C: (f, a) => f(...a)
|
|
243
249
|
});
|
|
@@ -250,83 +256,9 @@ var DataServiceImpl = class {
|
|
|
250
256
|
};
|
|
251
257
|
|
|
252
258
|
// src/internal/query-service-impl.ts
|
|
253
|
-
import * as Schema from "effect/Schema";
|
|
254
259
|
import { Stream as Stream2 } from "@dxos/codec-protobuf/stream";
|
|
255
|
-
import { QueryAST } from "@dxos/echo-protocol";
|
|
256
260
|
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
261
|
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
|
|
330
262
|
function _ts_add_disposable_resource2(env, value, async) {
|
|
331
263
|
if (value !== null && value !== void 0) {
|
|
332
264
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
@@ -392,7 +324,7 @@ function _ts_dispose_resources2(env) {
|
|
|
392
324
|
return next();
|
|
393
325
|
})(env);
|
|
394
326
|
}
|
|
395
|
-
var
|
|
327
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/query-service-impl.ts";
|
|
396
328
|
var QueryServiceImpl = class {
|
|
397
329
|
_executionContext;
|
|
398
330
|
_dataService;
|
|
@@ -405,23 +337,11 @@ var QueryServiceImpl = class {
|
|
|
405
337
|
log2.info("execQuery", {
|
|
406
338
|
request
|
|
407
339
|
}, {
|
|
408
|
-
F:
|
|
409
|
-
L:
|
|
340
|
+
F: __dxlog_file2,
|
|
341
|
+
L: 20,
|
|
410
342
|
S: this,
|
|
411
343
|
C: (f, a) => f(...a)
|
|
412
344
|
});
|
|
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];
|
|
425
345
|
return Stream2.fromPromise((async () => {
|
|
426
346
|
try {
|
|
427
347
|
const env = {
|
|
@@ -432,37 +352,23 @@ var QueryServiceImpl = class {
|
|
|
432
352
|
try {
|
|
433
353
|
this._queryCount++;
|
|
434
354
|
log2.info("begin query", {
|
|
435
|
-
|
|
355
|
+
request
|
|
436
356
|
}, {
|
|
437
|
-
F:
|
|
438
|
-
L:
|
|
357
|
+
F: __dxlog_file2,
|
|
358
|
+
L: 26,
|
|
439
359
|
S: this,
|
|
440
360
|
C: (f, a) => f(...a)
|
|
441
361
|
});
|
|
442
|
-
const queryResponse = _ts_add_disposable_resource2(env, await this._dataService.
|
|
362
|
+
const queryResponse = _ts_add_disposable_resource2(env, await this._dataService.execQuery(this._executionContext, request), false);
|
|
443
363
|
log2.info("query response", {
|
|
444
|
-
|
|
445
|
-
filter: request.filter,
|
|
446
|
-
resultCount: queryResponse.results.length
|
|
364
|
+
resultCount: queryResponse.results?.length
|
|
447
365
|
}, {
|
|
448
|
-
F:
|
|
449
|
-
L:
|
|
366
|
+
F: __dxlog_file2,
|
|
367
|
+
L: 28,
|
|
450
368
|
S: this,
|
|
451
369
|
C: (f, a) => f(...a)
|
|
452
370
|
});
|
|
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
|
-
};
|
|
371
|
+
return structuredClone(queryResponse);
|
|
466
372
|
} catch (e) {
|
|
467
373
|
env.error = e;
|
|
468
374
|
env.hasError = true;
|
|
@@ -473,16 +379,14 @@ var QueryServiceImpl = class {
|
|
|
473
379
|
log2.error("query failed", {
|
|
474
380
|
err: error
|
|
475
381
|
}, {
|
|
476
|
-
F:
|
|
477
|
-
L:
|
|
382
|
+
F: __dxlog_file2,
|
|
383
|
+
L: 31,
|
|
478
384
|
S: this,
|
|
479
385
|
C: (f, a) => f(...a)
|
|
480
386
|
});
|
|
481
387
|
throw new RuntimeServiceError2({
|
|
482
388
|
message: `Query execution failed (queryCount=${this._queryCount})`,
|
|
483
389
|
context: {
|
|
484
|
-
spaceId,
|
|
485
|
-
filter: request.filter,
|
|
486
390
|
queryCount: this._queryCount
|
|
487
391
|
},
|
|
488
392
|
cause: error
|
|
@@ -501,26 +405,9 @@ var QueryServiceImpl = class {
|
|
|
501
405
|
});
|
|
502
406
|
}
|
|
503
407
|
};
|
|
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
408
|
|
|
521
409
|
// src/internal/queue-service-impl.ts
|
|
522
|
-
import {
|
|
523
|
-
import { invariant as invariant4 } from "@dxos/invariant";
|
|
410
|
+
import { RuntimeServiceError as RuntimeServiceError3 } from "@dxos/errors";
|
|
524
411
|
function _ts_add_disposable_resource3(env, value, async) {
|
|
525
412
|
if (value !== null && value !== void 0) {
|
|
526
413
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
@@ -586,7 +473,6 @@ function _ts_dispose_resources3(env) {
|
|
|
586
473
|
return next();
|
|
587
474
|
})(env);
|
|
588
475
|
}
|
|
589
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/queue-service-impl.ts";
|
|
590
476
|
var QueueServiceImpl = class {
|
|
591
477
|
_ctx;
|
|
592
478
|
_queueService;
|
|
@@ -595,19 +481,6 @@ var QueueServiceImpl = class {
|
|
|
595
481
|
this._queueService = _queueService;
|
|
596
482
|
}
|
|
597
483
|
async queryQueue(request) {
|
|
598
|
-
const { query } = request;
|
|
599
|
-
const { queueIds, ...filter } = query;
|
|
600
|
-
const spaceId = query.spaceId;
|
|
601
|
-
const queueId = queueIds?.[0];
|
|
602
|
-
invariant4(request.query.queuesNamespace, void 0, {
|
|
603
|
-
F: __dxlog_file4,
|
|
604
|
-
L: 19,
|
|
605
|
-
S: this,
|
|
606
|
-
A: [
|
|
607
|
-
"request.query.queuesNamespace",
|
|
608
|
-
""
|
|
609
|
-
]
|
|
610
|
-
});
|
|
611
484
|
try {
|
|
612
485
|
const env = {
|
|
613
486
|
stack: [],
|
|
@@ -615,10 +488,8 @@ var QueueServiceImpl = class {
|
|
|
615
488
|
hasError: false
|
|
616
489
|
};
|
|
617
490
|
try {
|
|
618
|
-
const result = _ts_add_disposable_resource3(env, await this._queueService.
|
|
491
|
+
const result = _ts_add_disposable_resource3(env, await this._queueService.queryQueue(this._ctx, request), false);
|
|
619
492
|
return {
|
|
620
|
-
// Copy returned object to avoid hanging RPC stub
|
|
621
|
-
// See https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/
|
|
622
493
|
objects: structuredClone(result.objects),
|
|
623
494
|
nextCursor: result.nextCursor,
|
|
624
495
|
prevCursor: result.prevCursor
|
|
@@ -630,22 +501,35 @@ var QueueServiceImpl = class {
|
|
|
630
501
|
_ts_dispose_resources3(env);
|
|
631
502
|
}
|
|
632
503
|
} catch (error) {
|
|
504
|
+
const { query } = request;
|
|
633
505
|
throw RuntimeServiceError3.wrap({
|
|
634
506
|
message: "Queue query failed.",
|
|
635
507
|
context: {
|
|
636
|
-
subspaceTag:
|
|
637
|
-
spaceId,
|
|
638
|
-
queueId
|
|
508
|
+
subspaceTag: query?.queuesNamespace,
|
|
509
|
+
spaceId: query?.spaceId,
|
|
510
|
+
queueId: query?.queueIds?.[0]
|
|
639
511
|
},
|
|
640
512
|
ifTypeDiffers: true
|
|
641
513
|
})(error);
|
|
642
514
|
}
|
|
643
515
|
}
|
|
644
516
|
async insertIntoQueue(request) {
|
|
645
|
-
const { subspaceTag, spaceId, queueId, objects } = request;
|
|
646
517
|
try {
|
|
647
|
-
|
|
518
|
+
const env = {
|
|
519
|
+
stack: [],
|
|
520
|
+
error: void 0,
|
|
521
|
+
hasError: false
|
|
522
|
+
};
|
|
523
|
+
try {
|
|
524
|
+
const _ = _ts_add_disposable_resource3(env, await this._queueService.insertIntoQueue(this._ctx, request), false);
|
|
525
|
+
} catch (e) {
|
|
526
|
+
env.error = e;
|
|
527
|
+
env.hasError = true;
|
|
528
|
+
} finally {
|
|
529
|
+
_ts_dispose_resources3(env);
|
|
530
|
+
}
|
|
648
531
|
} catch (error) {
|
|
532
|
+
const { subspaceTag, spaceId, queueId } = request;
|
|
649
533
|
throw RuntimeServiceError3.wrap({
|
|
650
534
|
message: "Queue append failed.",
|
|
651
535
|
context: {
|
|
@@ -657,16 +541,35 @@ var QueueServiceImpl = class {
|
|
|
657
541
|
})(error);
|
|
658
542
|
}
|
|
659
543
|
}
|
|
660
|
-
deleteFromQueue(request) {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
544
|
+
async deleteFromQueue(request) {
|
|
545
|
+
try {
|
|
546
|
+
const env = {
|
|
547
|
+
stack: [],
|
|
548
|
+
error: void 0,
|
|
549
|
+
hasError: false
|
|
550
|
+
};
|
|
551
|
+
try {
|
|
552
|
+
const _ = _ts_add_disposable_resource3(env, await this._queueService.deleteFromQueue(this._ctx, request), false);
|
|
553
|
+
} catch (e) {
|
|
554
|
+
env.error = e;
|
|
555
|
+
env.hasError = true;
|
|
556
|
+
} finally {
|
|
557
|
+
_ts_dispose_resources3(env);
|
|
668
558
|
}
|
|
669
|
-
})
|
|
559
|
+
} catch (error) {
|
|
560
|
+
const { subspaceTag, spaceId, queueId } = request;
|
|
561
|
+
throw RuntimeServiceError3.wrap({
|
|
562
|
+
message: "Queue delete failed.",
|
|
563
|
+
context: {
|
|
564
|
+
subspaceTag,
|
|
565
|
+
spaceId,
|
|
566
|
+
queueId
|
|
567
|
+
},
|
|
568
|
+
ifTypeDiffers: true
|
|
569
|
+
})(error);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
async syncQueue(_) {
|
|
670
573
|
}
|
|
671
574
|
};
|
|
672
575
|
|
|
@@ -778,37 +681,45 @@ var ServiceContainer = class {
|
|
|
778
681
|
};
|
|
779
682
|
}
|
|
780
683
|
async queryQueue(queue) {
|
|
781
|
-
const
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
hasError: false
|
|
785
|
-
};
|
|
786
|
-
try {
|
|
787
|
-
const { spaceId } = queue.asQueueDXN() ?? {};
|
|
788
|
-
const result = _ts_add_disposable_resource4(env, await this._queueService.query({}, queue.toString(), {
|
|
789
|
-
spaceId
|
|
790
|
-
}), false);
|
|
791
|
-
return {
|
|
792
|
-
objects: structuredClone(result.objects),
|
|
793
|
-
nextCursor: result.nextCursor ?? null,
|
|
794
|
-
prevCursor: result.prevCursor ?? null
|
|
795
|
-
};
|
|
796
|
-
} catch (e) {
|
|
797
|
-
env.error = e;
|
|
798
|
-
env.hasError = true;
|
|
799
|
-
} finally {
|
|
800
|
-
_ts_dispose_resources4(env);
|
|
684
|
+
const parts = queue.asQueueDXN();
|
|
685
|
+
if (!parts) {
|
|
686
|
+
throw new Error("Invalid queue DXN");
|
|
801
687
|
}
|
|
688
|
+
const { subspaceTag, spaceId, queueId } = parts;
|
|
689
|
+
const result = await this._queueService.queryQueue(this._executionContext, {
|
|
690
|
+
query: {
|
|
691
|
+
spaceId,
|
|
692
|
+
queuesNamespace: subspaceTag,
|
|
693
|
+
queueIds: [
|
|
694
|
+
queueId
|
|
695
|
+
]
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
return {
|
|
699
|
+
objects: structuredClone(result.objects),
|
|
700
|
+
nextCursor: result.nextCursor ?? null,
|
|
701
|
+
prevCursor: result.prevCursor ?? null
|
|
702
|
+
};
|
|
802
703
|
}
|
|
803
704
|
async insertIntoQueue(queue, objects) {
|
|
804
|
-
|
|
705
|
+
const parts = queue.asQueueDXN();
|
|
706
|
+
if (!parts) {
|
|
707
|
+
throw new Error("Invalid queue DXN");
|
|
708
|
+
}
|
|
709
|
+
const { subspaceTag, spaceId, queueId } = parts;
|
|
710
|
+
await this._queueService.insertIntoQueue(this._executionContext, {
|
|
711
|
+
subspaceTag,
|
|
712
|
+
spaceId,
|
|
713
|
+
queueId,
|
|
714
|
+
objects
|
|
715
|
+
});
|
|
805
716
|
}
|
|
806
717
|
};
|
|
807
718
|
|
|
808
719
|
// src/space-proxy.ts
|
|
809
720
|
import { Resource } from "@dxos/context";
|
|
810
|
-
import { invariant as
|
|
811
|
-
import { PublicKey
|
|
721
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
722
|
+
import { PublicKey } from "@dxos/keys";
|
|
812
723
|
|
|
813
724
|
// src/queues-api.ts
|
|
814
725
|
var QueuesAPIImpl = class {
|
|
@@ -827,7 +738,7 @@ var QueuesAPIImpl = class {
|
|
|
827
738
|
};
|
|
828
739
|
|
|
829
740
|
// src/space-proxy.ts
|
|
830
|
-
var
|
|
741
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/space-proxy.ts";
|
|
831
742
|
var SpaceProxy = class extends Resource {
|
|
832
743
|
_serviceContainer;
|
|
833
744
|
_echoClient;
|
|
@@ -842,8 +753,8 @@ var SpaceProxy = class extends Resource {
|
|
|
842
753
|
return this._id;
|
|
843
754
|
}
|
|
844
755
|
get db() {
|
|
845
|
-
|
|
846
|
-
F:
|
|
756
|
+
invariant2(this._db, void 0, {
|
|
757
|
+
F: __dxlog_file3,
|
|
847
758
|
L: 35,
|
|
848
759
|
S: this,
|
|
849
760
|
A: [
|
|
@@ -857,8 +768,8 @@ var SpaceProxy = class extends Resource {
|
|
|
857
768
|
* @deprecated Use db API.
|
|
858
769
|
*/
|
|
859
770
|
get crud() {
|
|
860
|
-
|
|
861
|
-
F:
|
|
771
|
+
invariant2(this._db, void 0, {
|
|
772
|
+
F: __dxlog_file3,
|
|
862
773
|
L: 43,
|
|
863
774
|
S: this,
|
|
864
775
|
A: [
|
|
@@ -878,18 +789,18 @@ var SpaceProxy = class extends Resource {
|
|
|
878
789
|
}
|
|
879
790
|
this._db = this._echoClient.constructDatabase({
|
|
880
791
|
spaceId: this._id,
|
|
881
|
-
spaceKey:
|
|
792
|
+
spaceKey: PublicKey.from(meta.spaceKey),
|
|
882
793
|
reactiveSchemaQuery: false,
|
|
883
794
|
owningObject: this
|
|
884
795
|
});
|
|
885
|
-
await this._db.coreDatabase.open({
|
|
796
|
+
await this._db.coreDatabase.open(this._ctx, {
|
|
886
797
|
rootUrl: meta.rootDocumentId
|
|
887
798
|
});
|
|
888
799
|
}
|
|
889
800
|
};
|
|
890
801
|
|
|
891
802
|
// src/functions-client.ts
|
|
892
|
-
var
|
|
803
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/functions-client.ts";
|
|
893
804
|
var FunctionsClient = class extends Resource2 {
|
|
894
805
|
_serviceContainer;
|
|
895
806
|
_echoClient;
|
|
@@ -897,8 +808,8 @@ var FunctionsClient = class extends Resource2 {
|
|
|
897
808
|
_spaces = /* @__PURE__ */ new Map();
|
|
898
809
|
constructor(services) {
|
|
899
810
|
super();
|
|
900
|
-
|
|
901
|
-
F:
|
|
811
|
+
invariant3(typeof services.dataService !== "undefined", "DataService is required", {
|
|
812
|
+
F: __dxlog_file4,
|
|
902
813
|
L: 33,
|
|
903
814
|
S: this,
|
|
904
815
|
A: [
|
|
@@ -906,8 +817,8 @@ var FunctionsClient = class extends Resource2 {
|
|
|
906
817
|
"'DataService is required'"
|
|
907
818
|
]
|
|
908
819
|
});
|
|
909
|
-
|
|
910
|
-
F:
|
|
820
|
+
invariant3(typeof services.queueService !== "undefined", "QueueService is required", {
|
|
821
|
+
F: __dxlog_file4,
|
|
911
822
|
L: 34,
|
|
912
823
|
S: this,
|
|
913
824
|
A: [
|
|
@@ -964,11 +875,11 @@ var FunctionRouteValue = /* @__PURE__ */ (function(FunctionRouteValue2) {
|
|
|
964
875
|
})({});
|
|
965
876
|
|
|
966
877
|
// src/wrap-handler-for-cloudflare.ts
|
|
967
|
-
import { invariant as
|
|
968
|
-
import { SpaceId as
|
|
878
|
+
import { invariant as invariant4 } from "@dxos/invariant";
|
|
879
|
+
import { SpaceId as SpaceId2 } from "@dxos/keys";
|
|
969
880
|
import { log as log3 } from "@dxos/log";
|
|
970
881
|
import { EdgeResponse } from "@dxos/protocols";
|
|
971
|
-
var
|
|
882
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/wrap-handler-for-cloudflare.ts";
|
|
972
883
|
var wrapHandlerForCloudflare = (func) => {
|
|
973
884
|
return async (request, env) => {
|
|
974
885
|
if (request.headers.get(FUNCTION_ROUTE_HEADER) === FunctionRouteValue.Meta) {
|
|
@@ -977,7 +888,7 @@ var wrapHandlerForCloudflare = (func) => {
|
|
|
977
888
|
try {
|
|
978
889
|
const spaceId = new URL(request.url).searchParams.get("spaceId");
|
|
979
890
|
if (spaceId) {
|
|
980
|
-
if (!
|
|
891
|
+
if (!SpaceId2.isValid(spaceId)) {
|
|
981
892
|
return new Response("Invalid spaceId", {
|
|
982
893
|
status: 400
|
|
983
894
|
});
|
|
@@ -994,7 +905,7 @@ var wrapHandlerForCloudflare = (func) => {
|
|
|
994
905
|
error,
|
|
995
906
|
stack: error.stack
|
|
996
907
|
}, {
|
|
997
|
-
F:
|
|
908
|
+
F: __dxlog_file5,
|
|
998
909
|
L: 44,
|
|
999
910
|
S: void 0,
|
|
1000
911
|
C: (f, a) => f(...a)
|
|
@@ -1032,7 +943,7 @@ var decodeRequest = async (request) => {
|
|
|
1032
943
|
};
|
|
1033
944
|
} catch (err) {
|
|
1034
945
|
log3.catch(err, void 0, {
|
|
1035
|
-
F:
|
|
946
|
+
F: __dxlog_file5,
|
|
1036
947
|
L: 79,
|
|
1037
948
|
S: void 0,
|
|
1038
949
|
C: (f, a) => f(...a)
|
|
@@ -1069,8 +980,8 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
|
|
|
1069
980
|
throw new Error(`Space not found: ${contextSpaceId}`);
|
|
1070
981
|
}
|
|
1071
982
|
spaceKey = meta.spaceKey;
|
|
1072
|
-
|
|
1073
|
-
F:
|
|
983
|
+
invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, {
|
|
984
|
+
F: __dxlog_file5,
|
|
1074
985
|
L: 117,
|
|
1075
986
|
S: void 0,
|
|
1076
987
|
A: [
|