@dxos/functions-runtime-cloudflare 0.8.4-main.937b3ca → 0.8.4-main.9be5663bfe
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 +8 -8
- package/dist/types/src/internal/queue-service-impl.d.ts.map +1 -1
- package/dist/types/src/internal/service-container.d.ts +4 -6
- package/dist/types/src/internal/service-container.d.ts.map +1 -1
- package/dist/types/src/queues-api.d.ts +3 -3
- package/dist/types/src/queues-api.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 +32 -35
- package/src/internal/service-container.ts +27 -11
- package/src/queues-api.ts +3 -3
- 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/functions-client.ts
|
|
2
2
|
import { Resource as Resource2 } from "@dxos/context";
|
|
3
3
|
import { EchoClient } from "@dxos/echo-db";
|
|
4
|
-
import { invariant as
|
|
4
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
5
5
|
|
|
6
6
|
// src/internal/data-service-impl.ts
|
|
7
7
|
import { Stream } from "@dxos/codec-protobuf/stream";
|
|
@@ -180,10 +180,16 @@ var DataServiceImpl = class {
|
|
|
180
180
|
hasError: false
|
|
181
181
|
};
|
|
182
182
|
try {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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:
|
|
244
|
+
L: 134,
|
|
239
245
|
S: this,
|
|
240
246
|
C: (f, a) => f(...a)
|
|
241
247
|
});
|
|
@@ -248,83 +254,9 @@ var DataServiceImpl = class {
|
|
|
248
254
|
};
|
|
249
255
|
|
|
250
256
|
// src/internal/query-service-impl.ts
|
|
251
|
-
import * as Schema from "effect/Schema";
|
|
252
257
|
import { Stream as Stream2 } from "@dxos/codec-protobuf/stream";
|
|
253
|
-
import { QueryAST } from "@dxos/echo-protocol";
|
|
254
258
|
import { NotImplementedError as NotImplementedError2, RuntimeServiceError as RuntimeServiceError2 } from "@dxos/errors";
|
|
255
|
-
import { invariant as invariant3 } from "@dxos/invariant";
|
|
256
|
-
import { PublicKey } from "@dxos/keys";
|
|
257
|
-
import { SpaceId as SpaceId3 } from "@dxos/keys";
|
|
258
259
|
import { log as log2 } from "@dxos/log";
|
|
259
|
-
|
|
260
|
-
// src/internal/adapter.ts
|
|
261
|
-
import { failUndefined } from "@dxos/debug";
|
|
262
|
-
import { invariant as invariant2 } from "@dxos/invariant";
|
|
263
|
-
import { SpaceId as SpaceId2 } from "@dxos/keys";
|
|
264
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/adapter.ts";
|
|
265
|
-
var queryToDataServiceRequest = (query) => {
|
|
266
|
-
const { filter, options } = isSimpleSelectionQuery(query) ?? failUndefined();
|
|
267
|
-
invariant2(options?.spaceIds?.length === 1, "Only one space is supported", {
|
|
268
|
-
F: __dxlog_file2,
|
|
269
|
-
L: 13,
|
|
270
|
-
S: void 0,
|
|
271
|
-
A: [
|
|
272
|
-
"options?.spaceIds?.length === 1",
|
|
273
|
-
"'Only one space is supported'"
|
|
274
|
-
]
|
|
275
|
-
});
|
|
276
|
-
invariant2(filter.type === "object", "Only object filters are supported", {
|
|
277
|
-
F: __dxlog_file2,
|
|
278
|
-
L: 14,
|
|
279
|
-
S: void 0,
|
|
280
|
-
A: [
|
|
281
|
-
"filter.type === 'object'",
|
|
282
|
-
"'Only object filters are supported'"
|
|
283
|
-
]
|
|
284
|
-
});
|
|
285
|
-
const spaceId = options.spaceIds[0];
|
|
286
|
-
invariant2(SpaceId2.isValid(spaceId), void 0, {
|
|
287
|
-
F: __dxlog_file2,
|
|
288
|
-
L: 17,
|
|
289
|
-
S: void 0,
|
|
290
|
-
A: [
|
|
291
|
-
"SpaceId.isValid(spaceId)",
|
|
292
|
-
""
|
|
293
|
-
]
|
|
294
|
-
});
|
|
295
|
-
return {
|
|
296
|
-
spaceId,
|
|
297
|
-
type: filter.typename ?? void 0,
|
|
298
|
-
objectIds: [
|
|
299
|
-
...filter.id ?? []
|
|
300
|
-
]
|
|
301
|
-
};
|
|
302
|
-
};
|
|
303
|
-
var isSimpleSelectionQuery = (query) => {
|
|
304
|
-
switch (query.type) {
|
|
305
|
-
case "options": {
|
|
306
|
-
const maybeFilter = isSimpleSelectionQuery(query.query);
|
|
307
|
-
if (!maybeFilter) {
|
|
308
|
-
return null;
|
|
309
|
-
}
|
|
310
|
-
return {
|
|
311
|
-
filter: maybeFilter.filter,
|
|
312
|
-
options: query.options
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
case "select": {
|
|
316
|
-
return {
|
|
317
|
-
filter: query.filter,
|
|
318
|
-
options: void 0
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
default: {
|
|
322
|
-
return null;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
// src/internal/query-service-impl.ts
|
|
328
260
|
function _ts_add_disposable_resource2(env, value, async) {
|
|
329
261
|
if (value !== null && value !== void 0) {
|
|
330
262
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
@@ -390,7 +322,7 @@ function _ts_dispose_resources2(env) {
|
|
|
390
322
|
return next();
|
|
391
323
|
})(env);
|
|
392
324
|
}
|
|
393
|
-
var
|
|
325
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/query-service-impl.ts";
|
|
394
326
|
var QueryServiceImpl = class {
|
|
395
327
|
_executionContext;
|
|
396
328
|
_dataService;
|
|
@@ -403,23 +335,11 @@ var QueryServiceImpl = class {
|
|
|
403
335
|
log2.info("execQuery", {
|
|
404
336
|
request
|
|
405
337
|
}, {
|
|
406
|
-
F:
|
|
407
|
-
L:
|
|
338
|
+
F: __dxlog_file2,
|
|
339
|
+
L: 20,
|
|
408
340
|
S: this,
|
|
409
341
|
C: (f, a) => f(...a)
|
|
410
342
|
});
|
|
411
|
-
const query = QueryAST.Query.pipe(Schema.decodeUnknownSync)(JSON.parse(request.query));
|
|
412
|
-
const requestedSpaceIds = getTargetSpacesForQuery(query);
|
|
413
|
-
invariant3(requestedSpaceIds.length === 1, "Only one space is supported", {
|
|
414
|
-
F: __dxlog_file3,
|
|
415
|
-
L: 37,
|
|
416
|
-
S: this,
|
|
417
|
-
A: [
|
|
418
|
-
"requestedSpaceIds.length === 1",
|
|
419
|
-
"'Only one space is supported'"
|
|
420
|
-
]
|
|
421
|
-
});
|
|
422
|
-
const spaceId = requestedSpaceIds[0];
|
|
423
343
|
return Stream2.fromPromise((async () => {
|
|
424
344
|
try {
|
|
425
345
|
const env = {
|
|
@@ -430,37 +350,23 @@ var QueryServiceImpl = class {
|
|
|
430
350
|
try {
|
|
431
351
|
this._queryCount++;
|
|
432
352
|
log2.info("begin query", {
|
|
433
|
-
|
|
353
|
+
request
|
|
434
354
|
}, {
|
|
435
|
-
F:
|
|
436
|
-
L:
|
|
355
|
+
F: __dxlog_file2,
|
|
356
|
+
L: 26,
|
|
437
357
|
S: this,
|
|
438
358
|
C: (f, a) => f(...a)
|
|
439
359
|
});
|
|
440
|
-
const queryResponse = _ts_add_disposable_resource2(env, await this._dataService.
|
|
360
|
+
const queryResponse = _ts_add_disposable_resource2(env, await this._dataService.execQuery(this._executionContext, request), false);
|
|
441
361
|
log2.info("query response", {
|
|
442
|
-
|
|
443
|
-
filter: request.filter,
|
|
444
|
-
resultCount: queryResponse.results.length
|
|
362
|
+
resultCount: queryResponse.results?.length
|
|
445
363
|
}, {
|
|
446
|
-
F:
|
|
447
|
-
L:
|
|
364
|
+
F: __dxlog_file2,
|
|
365
|
+
L: 28,
|
|
448
366
|
S: this,
|
|
449
367
|
C: (f, a) => f(...a)
|
|
450
368
|
});
|
|
451
|
-
return
|
|
452
|
-
results: queryResponse.results.map((object) => ({
|
|
453
|
-
id: object.objectId,
|
|
454
|
-
spaceId,
|
|
455
|
-
spaceKey: PublicKey.ZERO,
|
|
456
|
-
documentId: object.document.documentId,
|
|
457
|
-
// Rank 1 for predicate matches where ranking is not determined.
|
|
458
|
-
rank: 1,
|
|
459
|
-
// Copy returned object to avoid hanging RPC stub.
|
|
460
|
-
// See https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/
|
|
461
|
-
documentAutomerge: copyUint8Array(object.document.data)
|
|
462
|
-
}))
|
|
463
|
-
};
|
|
369
|
+
return structuredClone(queryResponse);
|
|
464
370
|
} catch (e) {
|
|
465
371
|
env.error = e;
|
|
466
372
|
env.hasError = true;
|
|
@@ -471,16 +377,14 @@ var QueryServiceImpl = class {
|
|
|
471
377
|
log2.error("query failed", {
|
|
472
378
|
err: error
|
|
473
379
|
}, {
|
|
474
|
-
F:
|
|
475
|
-
L:
|
|
380
|
+
F: __dxlog_file2,
|
|
381
|
+
L: 31,
|
|
476
382
|
S: this,
|
|
477
383
|
C: (f, a) => f(...a)
|
|
478
384
|
});
|
|
479
385
|
throw new RuntimeServiceError2({
|
|
480
386
|
message: `Query execution failed (queryCount=${this._queryCount})`,
|
|
481
387
|
context: {
|
|
482
|
-
spaceId,
|
|
483
|
-
filter: request.filter,
|
|
484
388
|
queryCount: this._queryCount
|
|
485
389
|
},
|
|
486
390
|
cause: error
|
|
@@ -499,26 +403,9 @@ var QueryServiceImpl = class {
|
|
|
499
403
|
});
|
|
500
404
|
}
|
|
501
405
|
};
|
|
502
|
-
var getTargetSpacesForQuery = (query) => {
|
|
503
|
-
const spaces = /* @__PURE__ */ new Set();
|
|
504
|
-
const visitor = (node) => {
|
|
505
|
-
if (node.type === "options") {
|
|
506
|
-
if (node.options.spaceIds) {
|
|
507
|
-
for (const spaceId of node.options.spaceIds) {
|
|
508
|
-
spaces.add(SpaceId3.make(spaceId));
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
};
|
|
513
|
-
QueryAST.visit(query, visitor);
|
|
514
|
-
return [
|
|
515
|
-
...spaces
|
|
516
|
-
];
|
|
517
|
-
};
|
|
518
406
|
|
|
519
407
|
// src/internal/queue-service-impl.ts
|
|
520
|
-
import {
|
|
521
|
-
import { invariant as invariant4 } from "@dxos/invariant";
|
|
408
|
+
import { RuntimeServiceError as RuntimeServiceError3 } from "@dxos/errors";
|
|
522
409
|
function _ts_add_disposable_resource3(env, value, async) {
|
|
523
410
|
if (value !== null && value !== void 0) {
|
|
524
411
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
@@ -584,7 +471,6 @@ function _ts_dispose_resources3(env) {
|
|
|
584
471
|
return next();
|
|
585
472
|
})(env);
|
|
586
473
|
}
|
|
587
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/queue-service-impl.ts";
|
|
588
474
|
var QueueServiceImpl = class {
|
|
589
475
|
_ctx;
|
|
590
476
|
_queueService;
|
|
@@ -593,19 +479,6 @@ var QueueServiceImpl = class {
|
|
|
593
479
|
this._queueService = _queueService;
|
|
594
480
|
}
|
|
595
481
|
async queryQueue(request) {
|
|
596
|
-
const { query } = request;
|
|
597
|
-
const { queueIds, ...filter } = query;
|
|
598
|
-
const spaceId = query.spaceId;
|
|
599
|
-
const queueId = queueIds?.[0];
|
|
600
|
-
invariant4(request.query.queuesNamespace, void 0, {
|
|
601
|
-
F: __dxlog_file4,
|
|
602
|
-
L: 26,
|
|
603
|
-
S: this,
|
|
604
|
-
A: [
|
|
605
|
-
"request.query.queuesNamespace",
|
|
606
|
-
""
|
|
607
|
-
]
|
|
608
|
-
});
|
|
609
482
|
try {
|
|
610
483
|
const env = {
|
|
611
484
|
stack: [],
|
|
@@ -613,10 +486,8 @@ var QueueServiceImpl = class {
|
|
|
613
486
|
hasError: false
|
|
614
487
|
};
|
|
615
488
|
try {
|
|
616
|
-
const result = _ts_add_disposable_resource3(env, await this._queueService.
|
|
489
|
+
const result = _ts_add_disposable_resource3(env, await this._queueService.queryQueue(this._ctx, request), false);
|
|
617
490
|
return {
|
|
618
|
-
// Copy returned object to avoid hanging RPC stub
|
|
619
|
-
// See https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/
|
|
620
491
|
objects: structuredClone(result.objects),
|
|
621
492
|
nextCursor: result.nextCursor,
|
|
622
493
|
prevCursor: result.prevCursor
|
|
@@ -628,22 +499,35 @@ var QueueServiceImpl = class {
|
|
|
628
499
|
_ts_dispose_resources3(env);
|
|
629
500
|
}
|
|
630
501
|
} catch (error) {
|
|
502
|
+
const { query } = request;
|
|
631
503
|
throw RuntimeServiceError3.wrap({
|
|
632
504
|
message: "Queue query failed.",
|
|
633
505
|
context: {
|
|
634
|
-
subspaceTag:
|
|
635
|
-
spaceId,
|
|
636
|
-
queueId
|
|
506
|
+
subspaceTag: query?.queuesNamespace,
|
|
507
|
+
spaceId: query?.spaceId,
|
|
508
|
+
queueId: query?.queueIds?.[0]
|
|
637
509
|
},
|
|
638
510
|
ifTypeDiffers: true
|
|
639
511
|
})(error);
|
|
640
512
|
}
|
|
641
513
|
}
|
|
642
514
|
async insertIntoQueue(request) {
|
|
643
|
-
const { subspaceTag, spaceId, queueId, objects } = request;
|
|
644
515
|
try {
|
|
645
|
-
|
|
516
|
+
const env = {
|
|
517
|
+
stack: [],
|
|
518
|
+
error: void 0,
|
|
519
|
+
hasError: false
|
|
520
|
+
};
|
|
521
|
+
try {
|
|
522
|
+
const _ = _ts_add_disposable_resource3(env, await this._queueService.insertIntoQueue(this._ctx, request), false);
|
|
523
|
+
} catch (e) {
|
|
524
|
+
env.error = e;
|
|
525
|
+
env.hasError = true;
|
|
526
|
+
} finally {
|
|
527
|
+
_ts_dispose_resources3(env);
|
|
528
|
+
}
|
|
646
529
|
} catch (error) {
|
|
530
|
+
const { subspaceTag, spaceId, queueId } = request;
|
|
647
531
|
throw RuntimeServiceError3.wrap({
|
|
648
532
|
message: "Queue append failed.",
|
|
649
533
|
context: {
|
|
@@ -655,16 +539,35 @@ var QueueServiceImpl = class {
|
|
|
655
539
|
})(error);
|
|
656
540
|
}
|
|
657
541
|
}
|
|
658
|
-
deleteFromQueue(request) {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
542
|
+
async deleteFromQueue(request) {
|
|
543
|
+
try {
|
|
544
|
+
const env = {
|
|
545
|
+
stack: [],
|
|
546
|
+
error: void 0,
|
|
547
|
+
hasError: false
|
|
548
|
+
};
|
|
549
|
+
try {
|
|
550
|
+
const _ = _ts_add_disposable_resource3(env, await this._queueService.deleteFromQueue(this._ctx, request), false);
|
|
551
|
+
} catch (e) {
|
|
552
|
+
env.error = e;
|
|
553
|
+
env.hasError = true;
|
|
554
|
+
} finally {
|
|
555
|
+
_ts_dispose_resources3(env);
|
|
666
556
|
}
|
|
667
|
-
})
|
|
557
|
+
} catch (error) {
|
|
558
|
+
const { subspaceTag, spaceId, queueId } = request;
|
|
559
|
+
throw RuntimeServiceError3.wrap({
|
|
560
|
+
message: "Queue delete failed.",
|
|
561
|
+
context: {
|
|
562
|
+
subspaceTag,
|
|
563
|
+
spaceId,
|
|
564
|
+
queueId
|
|
565
|
+
},
|
|
566
|
+
ifTypeDiffers: true
|
|
567
|
+
})(error);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
async syncQueue(_) {
|
|
668
571
|
}
|
|
669
572
|
};
|
|
670
573
|
|
|
@@ -776,37 +679,45 @@ var ServiceContainer = class {
|
|
|
776
679
|
};
|
|
777
680
|
}
|
|
778
681
|
async queryQueue(queue) {
|
|
779
|
-
const
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
hasError: false
|
|
783
|
-
};
|
|
784
|
-
try {
|
|
785
|
-
const { spaceId } = queue.asQueueDXN() ?? {};
|
|
786
|
-
const result = _ts_add_disposable_resource4(env, await this._queueService.query({}, queue.toString(), {
|
|
787
|
-
spaceId
|
|
788
|
-
}), false);
|
|
789
|
-
return {
|
|
790
|
-
objects: structuredClone(result.objects),
|
|
791
|
-
nextCursor: result.nextCursor ?? null,
|
|
792
|
-
prevCursor: result.prevCursor ?? null
|
|
793
|
-
};
|
|
794
|
-
} catch (e) {
|
|
795
|
-
env.error = e;
|
|
796
|
-
env.hasError = true;
|
|
797
|
-
} finally {
|
|
798
|
-
_ts_dispose_resources4(env);
|
|
682
|
+
const parts = queue.asQueueDXN();
|
|
683
|
+
if (!parts) {
|
|
684
|
+
throw new Error("Invalid queue DXN");
|
|
799
685
|
}
|
|
686
|
+
const { subspaceTag, spaceId, queueId } = parts;
|
|
687
|
+
const result = await this._queueService.queryQueue(this._executionContext, {
|
|
688
|
+
query: {
|
|
689
|
+
spaceId,
|
|
690
|
+
queuesNamespace: subspaceTag,
|
|
691
|
+
queueIds: [
|
|
692
|
+
queueId
|
|
693
|
+
]
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
return {
|
|
697
|
+
objects: structuredClone(result.objects),
|
|
698
|
+
nextCursor: result.nextCursor ?? null,
|
|
699
|
+
prevCursor: result.prevCursor ?? null
|
|
700
|
+
};
|
|
800
701
|
}
|
|
801
702
|
async insertIntoQueue(queue, objects) {
|
|
802
|
-
|
|
703
|
+
const parts = queue.asQueueDXN();
|
|
704
|
+
if (!parts) {
|
|
705
|
+
throw new Error("Invalid queue DXN");
|
|
706
|
+
}
|
|
707
|
+
const { subspaceTag, spaceId, queueId } = parts;
|
|
708
|
+
await this._queueService.insertIntoQueue(this._executionContext, {
|
|
709
|
+
subspaceTag,
|
|
710
|
+
spaceId,
|
|
711
|
+
queueId,
|
|
712
|
+
objects
|
|
713
|
+
});
|
|
803
714
|
}
|
|
804
715
|
};
|
|
805
716
|
|
|
806
717
|
// src/space-proxy.ts
|
|
807
718
|
import { Resource } from "@dxos/context";
|
|
808
|
-
import { invariant as
|
|
809
|
-
import { PublicKey
|
|
719
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
720
|
+
import { PublicKey } from "@dxos/keys";
|
|
810
721
|
|
|
811
722
|
// src/queues-api.ts
|
|
812
723
|
var QueuesAPIImpl = class {
|
|
@@ -825,7 +736,7 @@ var QueuesAPIImpl = class {
|
|
|
825
736
|
};
|
|
826
737
|
|
|
827
738
|
// src/space-proxy.ts
|
|
828
|
-
var
|
|
739
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/space-proxy.ts";
|
|
829
740
|
var SpaceProxy = class extends Resource {
|
|
830
741
|
_serviceContainer;
|
|
831
742
|
_echoClient;
|
|
@@ -840,8 +751,8 @@ var SpaceProxy = class extends Resource {
|
|
|
840
751
|
return this._id;
|
|
841
752
|
}
|
|
842
753
|
get db() {
|
|
843
|
-
|
|
844
|
-
F:
|
|
754
|
+
invariant2(this._db, void 0, {
|
|
755
|
+
F: __dxlog_file3,
|
|
845
756
|
L: 35,
|
|
846
757
|
S: this,
|
|
847
758
|
A: [
|
|
@@ -855,8 +766,8 @@ var SpaceProxy = class extends Resource {
|
|
|
855
766
|
* @deprecated Use db API.
|
|
856
767
|
*/
|
|
857
768
|
get crud() {
|
|
858
|
-
|
|
859
|
-
F:
|
|
769
|
+
invariant2(this._db, void 0, {
|
|
770
|
+
F: __dxlog_file3,
|
|
860
771
|
L: 43,
|
|
861
772
|
S: this,
|
|
862
773
|
A: [
|
|
@@ -876,18 +787,18 @@ var SpaceProxy = class extends Resource {
|
|
|
876
787
|
}
|
|
877
788
|
this._db = this._echoClient.constructDatabase({
|
|
878
789
|
spaceId: this._id,
|
|
879
|
-
spaceKey:
|
|
790
|
+
spaceKey: PublicKey.from(meta.spaceKey),
|
|
880
791
|
reactiveSchemaQuery: false,
|
|
881
792
|
owningObject: this
|
|
882
793
|
});
|
|
883
|
-
await this._db.coreDatabase.open({
|
|
794
|
+
await this._db.coreDatabase.open(this._ctx, {
|
|
884
795
|
rootUrl: meta.rootDocumentId
|
|
885
796
|
});
|
|
886
797
|
}
|
|
887
798
|
};
|
|
888
799
|
|
|
889
800
|
// src/functions-client.ts
|
|
890
|
-
var
|
|
801
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/functions-client.ts";
|
|
891
802
|
var FunctionsClient = class extends Resource2 {
|
|
892
803
|
_serviceContainer;
|
|
893
804
|
_echoClient;
|
|
@@ -895,8 +806,8 @@ var FunctionsClient = class extends Resource2 {
|
|
|
895
806
|
_spaces = /* @__PURE__ */ new Map();
|
|
896
807
|
constructor(services) {
|
|
897
808
|
super();
|
|
898
|
-
|
|
899
|
-
F:
|
|
809
|
+
invariant3(typeof services.dataService !== "undefined", "DataService is required", {
|
|
810
|
+
F: __dxlog_file4,
|
|
900
811
|
L: 33,
|
|
901
812
|
S: this,
|
|
902
813
|
A: [
|
|
@@ -904,8 +815,8 @@ var FunctionsClient = class extends Resource2 {
|
|
|
904
815
|
"'DataService is required'"
|
|
905
816
|
]
|
|
906
817
|
});
|
|
907
|
-
|
|
908
|
-
F:
|
|
818
|
+
invariant3(typeof services.queueService !== "undefined", "QueueService is required", {
|
|
819
|
+
F: __dxlog_file4,
|
|
909
820
|
L: 34,
|
|
910
821
|
S: this,
|
|
911
822
|
A: [
|
|
@@ -962,11 +873,11 @@ var FunctionRouteValue = /* @__PURE__ */ (function(FunctionRouteValue2) {
|
|
|
962
873
|
})({});
|
|
963
874
|
|
|
964
875
|
// src/wrap-handler-for-cloudflare.ts
|
|
965
|
-
import { invariant as
|
|
966
|
-
import { SpaceId as
|
|
876
|
+
import { invariant as invariant4 } from "@dxos/invariant";
|
|
877
|
+
import { SpaceId as SpaceId2 } from "@dxos/keys";
|
|
967
878
|
import { log as log3 } from "@dxos/log";
|
|
968
879
|
import { EdgeResponse } from "@dxos/protocols";
|
|
969
|
-
var
|
|
880
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/wrap-handler-for-cloudflare.ts";
|
|
970
881
|
var wrapHandlerForCloudflare = (func) => {
|
|
971
882
|
return async (request, env) => {
|
|
972
883
|
if (request.headers.get(FUNCTION_ROUTE_HEADER) === FunctionRouteValue.Meta) {
|
|
@@ -975,7 +886,7 @@ var wrapHandlerForCloudflare = (func) => {
|
|
|
975
886
|
try {
|
|
976
887
|
const spaceId = new URL(request.url).searchParams.get("spaceId");
|
|
977
888
|
if (spaceId) {
|
|
978
|
-
if (!
|
|
889
|
+
if (!SpaceId2.isValid(spaceId)) {
|
|
979
890
|
return new Response("Invalid spaceId", {
|
|
980
891
|
status: 400
|
|
981
892
|
});
|
|
@@ -992,7 +903,7 @@ var wrapHandlerForCloudflare = (func) => {
|
|
|
992
903
|
error,
|
|
993
904
|
stack: error.stack
|
|
994
905
|
}, {
|
|
995
|
-
F:
|
|
906
|
+
F: __dxlog_file5,
|
|
996
907
|
L: 44,
|
|
997
908
|
S: void 0,
|
|
998
909
|
C: (f, a) => f(...a)
|
|
@@ -1030,7 +941,7 @@ var decodeRequest = async (request) => {
|
|
|
1030
941
|
};
|
|
1031
942
|
} catch (err) {
|
|
1032
943
|
log3.catch(err, void 0, {
|
|
1033
|
-
F:
|
|
944
|
+
F: __dxlog_file5,
|
|
1034
945
|
L: 79,
|
|
1035
946
|
S: void 0,
|
|
1036
947
|
C: (f, a) => f(...a)
|
|
@@ -1067,8 +978,8 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
|
|
|
1067
978
|
throw new Error(`Space not found: ${contextSpaceId}`);
|
|
1068
979
|
}
|
|
1069
980
|
spaceKey = meta.spaceKey;
|
|
1070
|
-
|
|
1071
|
-
F:
|
|
981
|
+
invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, {
|
|
982
|
+
F: __dxlog_file5,
|
|
1072
983
|
L: 117,
|
|
1073
984
|
S: void 0,
|
|
1074
985
|
A: [
|