@query-farm/vgi 0.43.0 → 0.44.0
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/README.md +5 -2
- package/dist/attach-ticket.d.ts +18 -7
- package/dist/client-entry.js +215 -91
- package/dist/client-entry.js.map +10 -9
- package/dist/codec/asd.d.ts +3 -1
- package/dist/codec/conform.d.ts +51 -0
- package/dist/errors.d.ts +5 -1
- package/dist/index.core.d.ts +1 -1
- package/dist/index.js +218 -39
- package/dist/index.js.map +17 -16
- package/dist/protocol/handlers/shared.d.ts +2 -1
- package/dist/protocol/serializers/shared.d.ts +2 -1
- package/dist/rpc-server.d.ts +2 -2
- package/dist/serve-entry.js +259 -89
- package/dist/serve-entry.js.map +13 -12
- package/dist/worker-cf-entry.js +201 -30
- package/dist/worker-cf-entry.js.map +17 -16
- package/package.json +3 -3
- package/src/attach-ticket.ts +41 -13
- package/src/catalog/composite.ts +2 -1
- package/src/catalog/interface.ts +5 -4
- package/src/catalog/read-only.ts +8 -6
- package/src/client/client.ts +13 -5
- package/src/codec/asd.ts +5 -2
- package/src/codec/conform.ts +193 -0
- package/src/errors.ts +27 -7
- package/src/functions/registry.ts +3 -2
- package/src/http/fetch.ts +1 -1
- package/src/index.core.ts +3 -1
- package/src/protocol/handlers/shared.ts +8 -2
- package/src/protocol/serializers/bind.ts +3 -1
- package/src/protocol/serializers/shared.ts +5 -2
- package/src/rpc-server.ts +7 -7
|
@@ -11,7 +11,8 @@ export declare function unwrapRequest(requestBytes: any): Record<string, any>;
|
|
|
11
11
|
export declare function normalizeRequestSchemaPaths(params: Record<string, any>): void;
|
|
12
12
|
/**
|
|
13
13
|
* Wrap a dict of values into a single "result" Binary column.
|
|
14
|
-
* Builds a 1-row batch from the values using the given schema
|
|
14
|
+
* Builds a 1-row batch from the values using the given schema (conformed to
|
|
15
|
+
* the protocol's container rules, see `conformRecord`),
|
|
15
16
|
* serializes it to IPC bytes, and returns { result: bytes }.
|
|
16
17
|
*/
|
|
17
18
|
export declare function wrapResult(values: Record<string, any>, innerSchema: VgiSchema | import("../../arrow/index.js").VgiSchema): {
|
|
@@ -7,6 +7,7 @@ import { type VgiSchema, type VgiBatch } from "../../arrow/index.js";
|
|
|
7
7
|
export declare function toUint8Array(val: any): Uint8Array;
|
|
8
8
|
/**
|
|
9
9
|
* Build a single-row RecordBatch from a {fieldName: value} dict matching the
|
|
10
|
-
* given schema. Auto-coerces JS numbers to BigInt for Int64 fields
|
|
10
|
+
* given schema. Auto-coerces JS numbers to BigInt for Int64 fields, and
|
|
11
|
+
* applies the protocol's container rules (`conformRecord`).
|
|
11
12
|
*/
|
|
12
13
|
export declare function buildSingleRowBatch(schema: VgiSchema, values: Record<string, any>): VgiBatch;
|
package/dist/rpc-server.d.ts
CHANGED
|
@@ -31,13 +31,13 @@ export interface HostingOptions {
|
|
|
31
31
|
*
|
|
32
32
|
* Each needs a distinct wire name, which may not be `vgi.v2` and may not
|
|
33
33
|
* use the reserved `vgi_rpc.` prefix: reflection is hosted automatically and
|
|
34
|
-
* `vgi_rpc.Identity.
|
|
34
|
+
* `vgi_rpc.Identity.v2` is enabled through {@link resolveToken} /
|
|
35
35
|
* {@link mintGrant}. Violations are a startup error naming this hook.
|
|
36
36
|
*/
|
|
37
37
|
hostedProtocols?: () => Iterable<Protocol>;
|
|
38
38
|
/**
|
|
39
39
|
* Resolve an opaque bearer credential to the identity it authenticates as.
|
|
40
|
-
* Supplying it hosts `vgi_rpc.Identity.
|
|
40
|
+
* Supplying it hosts `vgi_rpc.Identity.v2`'s `introspect_token` -- on HTTP,
|
|
41
41
|
* the transport that authenticates callers. Absent, the method is absent
|
|
42
42
|
* (not hosted-and-refusing), which keeps a dependency upgrade from growing a
|
|
43
43
|
* credential-to-identity oracle on every existing worker.
|
package/dist/serve-entry.js
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
function __accessProp(key) {
|
|
7
|
+
return this[key];
|
|
8
|
+
}
|
|
9
|
+
var __toCommonJS = (from) => {
|
|
10
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
11
|
+
if (entry)
|
|
12
|
+
return entry;
|
|
13
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (var key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(entry, key))
|
|
17
|
+
__defProp(entry, key, {
|
|
18
|
+
get: __accessProp.bind(from, key),
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
__moduleCache.set(from, entry);
|
|
23
|
+
return entry;
|
|
24
|
+
};
|
|
25
|
+
var __moduleCache;
|
|
3
26
|
var __returnValue = (v) => v;
|
|
4
27
|
function __exportSetter(name, newValue) {
|
|
5
28
|
this[name] = __returnValue.bind(null, newValue);
|
|
@@ -26,6 +49,11 @@ var __esm = (fn, res, err) => () => {
|
|
|
26
49
|
};
|
|
27
50
|
|
|
28
51
|
// src/functions/storage-cf-do.ts
|
|
52
|
+
var exports_storage_cf_do = {};
|
|
53
|
+
__export(exports_storage_cf_do, {
|
|
54
|
+
FunctionStorageCfDo: () => FunctionStorageCfDo
|
|
55
|
+
});
|
|
56
|
+
|
|
29
57
|
class FunctionStorageCfDo {
|
|
30
58
|
_baseUrl;
|
|
31
59
|
_token;
|
|
@@ -471,7 +499,7 @@ function resolveStorageFromEnv() {
|
|
|
471
499
|
return new FunctionStorageSqlite;
|
|
472
500
|
}
|
|
473
501
|
if (backend === "cloudflare-do") {
|
|
474
|
-
init_storage_cf_do();
|
|
502
|
+
const { FunctionStorageCfDo } = (init_storage_cf_do(), __toCommonJS(exports_storage_cf_do));
|
|
475
503
|
return FunctionStorageCfDo.fromEnv();
|
|
476
504
|
}
|
|
477
505
|
throw new Error(`Unknown VGI_WORKER_SHARED_STORAGE backend: '${backend}'. Supported: 'memory', 'sqlite', 'cloudflare-do'.`);
|
|
@@ -512,6 +540,79 @@ var init_storage = __esm(() => {
|
|
|
512
540
|
});
|
|
513
541
|
});
|
|
514
542
|
|
|
543
|
+
// src/arrow/impl-arrowjs/index.ts
|
|
544
|
+
var exports_impl_arrowjs = {};
|
|
545
|
+
__export(exports_impl_arrowjs, {
|
|
546
|
+
DateUnit: () => DateUnit,
|
|
547
|
+
IntervalUnit: () => IntervalUnit,
|
|
548
|
+
TimeUnit: () => TimeUnit,
|
|
549
|
+
UnionMode: () => UnionMode,
|
|
550
|
+
adoptArrowJsShape: () => adoptArrowJsShape,
|
|
551
|
+
backend: () => backend,
|
|
552
|
+
batchFromColumns: () => batchFromColumns,
|
|
553
|
+
batchFromRows: () => batchFromRows,
|
|
554
|
+
batchToScalarDict: () => batchToScalarDict,
|
|
555
|
+
batchToSecretDict: () => batchToSecretDict,
|
|
556
|
+
binary: () => binary,
|
|
557
|
+
bool: () => bool,
|
|
558
|
+
buildStatisticsBatch: () => buildStatisticsBatch,
|
|
559
|
+
columnFromArray: () => columnFromArray,
|
|
560
|
+
date: () => date,
|
|
561
|
+
dateDay: () => dateDay,
|
|
562
|
+
dateMillisecond: () => dateMillisecond,
|
|
563
|
+
decimal: () => decimal,
|
|
564
|
+
decimal128: () => decimal128,
|
|
565
|
+
decimal256: () => decimal256,
|
|
566
|
+
decodeDictValue: () => decodeDictValue,
|
|
567
|
+
denseUnion: () => denseUnion,
|
|
568
|
+
deserializeBatch: () => deserializeBatch,
|
|
569
|
+
deserializeSchema: () => deserializeSchema,
|
|
570
|
+
dictionary: () => dictionary,
|
|
571
|
+
duration: () => duration,
|
|
572
|
+
emptyBatch: () => emptyBatch,
|
|
573
|
+
field: () => field,
|
|
574
|
+
filterBatch: () => filterBatch,
|
|
575
|
+
fixedSizeBinary: () => fixedSizeBinary,
|
|
576
|
+
fixedSizeList: () => fixedSizeList,
|
|
577
|
+
float16: () => float16,
|
|
578
|
+
float32: () => float32,
|
|
579
|
+
float64: () => float64,
|
|
580
|
+
int: () => int,
|
|
581
|
+
int16: () => int16,
|
|
582
|
+
int32: () => int32,
|
|
583
|
+
int64: () => int64,
|
|
584
|
+
int8: () => int8,
|
|
585
|
+
interval: () => interval,
|
|
586
|
+
iterRows: () => iterRows,
|
|
587
|
+
largeBinary: () => largeBinary,
|
|
588
|
+
largeUtf8: () => largeUtf8,
|
|
589
|
+
list: () => list,
|
|
590
|
+
map: () => map,
|
|
591
|
+
nullType: () => nullType,
|
|
592
|
+
projectBatch: () => projectBatch,
|
|
593
|
+
projectSchema: () => projectSchema,
|
|
594
|
+
readCanonicalValue: () => readCanonicalValue,
|
|
595
|
+
safeNumber: () => safeNumber,
|
|
596
|
+
schema: () => schema,
|
|
597
|
+
serializeBatch: () => serializeBatch,
|
|
598
|
+
serializeSchema: () => serializeSchema,
|
|
599
|
+
sparseUnion: () => sparseUnion,
|
|
600
|
+
struct: () => struct,
|
|
601
|
+
time: () => time,
|
|
602
|
+
timeMicrosecond: () => timeMicrosecond,
|
|
603
|
+
timeMillisecond: () => timeMillisecond,
|
|
604
|
+
timeNanosecond: () => timeNanosecond,
|
|
605
|
+
timeSecond: () => timeSecond,
|
|
606
|
+
timestamp: () => timestamp,
|
|
607
|
+
uint16: () => uint16,
|
|
608
|
+
uint32: () => uint32,
|
|
609
|
+
uint64: () => uint64,
|
|
610
|
+
uint8: () => uint8,
|
|
611
|
+
union: () => union,
|
|
612
|
+
utf8: () => utf8,
|
|
613
|
+
withBatchMetadata: () => withBatchMetadata
|
|
614
|
+
});
|
|
615
|
+
|
|
515
616
|
// src/serve-entry.ts
|
|
516
617
|
import {
|
|
517
618
|
irohForwardedHeaderIdentityProvider,
|
|
@@ -551,6 +652,21 @@ var TypeId = {
|
|
|
551
652
|
LargeUtf8: 20,
|
|
552
653
|
Dictionary: -1
|
|
553
654
|
};
|
|
655
|
+
function isInt(t) {
|
|
656
|
+
return t.typeId === TypeId.Int;
|
|
657
|
+
}
|
|
658
|
+
function isFloat(t) {
|
|
659
|
+
return t.typeId === TypeId.Float;
|
|
660
|
+
}
|
|
661
|
+
function isBinary(t) {
|
|
662
|
+
return t.typeId === TypeId.Binary || t.typeId === TypeId.LargeBinary;
|
|
663
|
+
}
|
|
664
|
+
function isUtf8(t) {
|
|
665
|
+
return t.typeId === TypeId.Utf8 || t.typeId === TypeId.LargeUtf8;
|
|
666
|
+
}
|
|
667
|
+
function isBool(t) {
|
|
668
|
+
return t.typeId === TypeId.Bool;
|
|
669
|
+
}
|
|
554
670
|
function isDecimal(t) {
|
|
555
671
|
return t.typeId === TypeId.Decimal;
|
|
556
672
|
}
|
|
@@ -563,6 +679,9 @@ function isStruct(t) {
|
|
|
563
679
|
function isMap(t) {
|
|
564
680
|
return t.typeId === TypeId.Map;
|
|
565
681
|
}
|
|
682
|
+
function isDictionary(t) {
|
|
683
|
+
return t.typeId === TypeId.Dictionary;
|
|
684
|
+
}
|
|
566
685
|
function typeSignature(t) {
|
|
567
686
|
if (t == null)
|
|
568
687
|
return "null";
|
|
@@ -599,79 +718,6 @@ function typeSignature(t) {
|
|
|
599
718
|
return Array.isArray(a.children) ? `${t.typeId}<${kids()}>` : String(t.typeId);
|
|
600
719
|
}
|
|
601
720
|
}
|
|
602
|
-
// src/arrow/impl-arrowjs/index.ts
|
|
603
|
-
var exports_impl_arrowjs = {};
|
|
604
|
-
__export(exports_impl_arrowjs, {
|
|
605
|
-
DateUnit: () => DateUnit,
|
|
606
|
-
IntervalUnit: () => IntervalUnit,
|
|
607
|
-
TimeUnit: () => TimeUnit,
|
|
608
|
-
UnionMode: () => UnionMode,
|
|
609
|
-
adoptArrowJsShape: () => adoptArrowJsShape,
|
|
610
|
-
backend: () => backend,
|
|
611
|
-
batchFromColumns: () => batchFromColumns,
|
|
612
|
-
batchFromRows: () => batchFromRows,
|
|
613
|
-
batchToScalarDict: () => batchToScalarDict,
|
|
614
|
-
batchToSecretDict: () => batchToSecretDict,
|
|
615
|
-
binary: () => binary,
|
|
616
|
-
bool: () => bool,
|
|
617
|
-
buildStatisticsBatch: () => buildStatisticsBatch,
|
|
618
|
-
columnFromArray: () => columnFromArray,
|
|
619
|
-
date: () => date,
|
|
620
|
-
dateDay: () => dateDay,
|
|
621
|
-
dateMillisecond: () => dateMillisecond,
|
|
622
|
-
decimal: () => decimal,
|
|
623
|
-
decimal128: () => decimal128,
|
|
624
|
-
decimal256: () => decimal256,
|
|
625
|
-
decodeDictValue: () => decodeDictValue,
|
|
626
|
-
denseUnion: () => denseUnion,
|
|
627
|
-
deserializeBatch: () => deserializeBatch,
|
|
628
|
-
deserializeSchema: () => deserializeSchema,
|
|
629
|
-
dictionary: () => dictionary,
|
|
630
|
-
duration: () => duration,
|
|
631
|
-
emptyBatch: () => emptyBatch,
|
|
632
|
-
field: () => field,
|
|
633
|
-
filterBatch: () => filterBatch,
|
|
634
|
-
fixedSizeBinary: () => fixedSizeBinary,
|
|
635
|
-
fixedSizeList: () => fixedSizeList,
|
|
636
|
-
float16: () => float16,
|
|
637
|
-
float32: () => float32,
|
|
638
|
-
float64: () => float64,
|
|
639
|
-
int: () => int,
|
|
640
|
-
int16: () => int16,
|
|
641
|
-
int32: () => int32,
|
|
642
|
-
int64: () => int64,
|
|
643
|
-
int8: () => int8,
|
|
644
|
-
interval: () => interval,
|
|
645
|
-
iterRows: () => iterRows,
|
|
646
|
-
largeBinary: () => largeBinary,
|
|
647
|
-
largeUtf8: () => largeUtf8,
|
|
648
|
-
list: () => list,
|
|
649
|
-
map: () => map,
|
|
650
|
-
nullType: () => nullType,
|
|
651
|
-
projectBatch: () => projectBatch,
|
|
652
|
-
projectSchema: () => projectSchema,
|
|
653
|
-
readCanonicalValue: () => readCanonicalValue,
|
|
654
|
-
safeNumber: () => safeNumber,
|
|
655
|
-
schema: () => schema,
|
|
656
|
-
serializeBatch: () => serializeBatch,
|
|
657
|
-
serializeSchema: () => serializeSchema,
|
|
658
|
-
sparseUnion: () => sparseUnion,
|
|
659
|
-
struct: () => struct,
|
|
660
|
-
time: () => time,
|
|
661
|
-
timeMicrosecond: () => timeMicrosecond,
|
|
662
|
-
timeMillisecond: () => timeMillisecond,
|
|
663
|
-
timeNanosecond: () => timeNanosecond,
|
|
664
|
-
timeSecond: () => timeSecond,
|
|
665
|
-
timestamp: () => timestamp,
|
|
666
|
-
uint16: () => uint16,
|
|
667
|
-
uint32: () => uint32,
|
|
668
|
-
uint64: () => uint64,
|
|
669
|
-
uint8: () => uint8,
|
|
670
|
-
union: () => union,
|
|
671
|
-
utf8: () => utf8,
|
|
672
|
-
withBatchMetadata: () => withBatchMetadata
|
|
673
|
-
});
|
|
674
|
-
|
|
675
721
|
// src/arrow/impl-arrowjs/schema.ts
|
|
676
722
|
import {
|
|
677
723
|
Schema as A_Schema,
|
|
@@ -2638,6 +2684,116 @@ function deserializeArguments(bytes) {
|
|
|
2638
2684
|
}
|
|
2639
2685
|
return new Arguments(positional, named, sch);
|
|
2640
2686
|
}
|
|
2687
|
+
// src/codec/conform.ts
|
|
2688
|
+
var OPTIONAL_ITEM_FIELDS = new Set(["argument_names"]);
|
|
2689
|
+
function children(type) {
|
|
2690
|
+
return type.children ?? [];
|
|
2691
|
+
}
|
|
2692
|
+
function mapValueType(type) {
|
|
2693
|
+
const entries = children(type)[0].type;
|
|
2694
|
+
return children(entries)[1].type;
|
|
2695
|
+
}
|
|
2696
|
+
function mapPairs(raw) {
|
|
2697
|
+
if (Array.isArray(raw))
|
|
2698
|
+
return raw.map((e) => Array.isArray(e) ? [e[0], e[1]] : [e?.key, e?.value]);
|
|
2699
|
+
if (raw instanceof Map)
|
|
2700
|
+
return Array.from(raw.entries());
|
|
2701
|
+
if (typeof raw[Symbol.iterator] === "function")
|
|
2702
|
+
return Array.from(raw);
|
|
2703
|
+
return Object.entries(raw);
|
|
2704
|
+
}
|
|
2705
|
+
function zeroValue(type) {
|
|
2706
|
+
if (isUtf8(type) || isDictionary(type))
|
|
2707
|
+
return "";
|
|
2708
|
+
if (isBinary(type))
|
|
2709
|
+
return new Uint8Array(0);
|
|
2710
|
+
if (isBool(type))
|
|
2711
|
+
return false;
|
|
2712
|
+
if (isInt(type))
|
|
2713
|
+
return type.bitWidth === 64 ? 0n : 0;
|
|
2714
|
+
if (isFloat(type))
|
|
2715
|
+
return 0;
|
|
2716
|
+
if (isList(type) || isMap(type))
|
|
2717
|
+
return [];
|
|
2718
|
+
if (isStruct(type)) {
|
|
2719
|
+
const out = {};
|
|
2720
|
+
for (const c of children(type))
|
|
2721
|
+
out[c.name] = c.nullable ? null : conformValue(c.type, undefined, false, c.name);
|
|
2722
|
+
return out;
|
|
2723
|
+
}
|
|
2724
|
+
return null;
|
|
2725
|
+
}
|
|
2726
|
+
var HAS_CONTAINER = new WeakMap;
|
|
2727
|
+
function hasContainer(type) {
|
|
2728
|
+
const cached = HAS_CONTAINER.get(type);
|
|
2729
|
+
if (cached !== undefined)
|
|
2730
|
+
return cached;
|
|
2731
|
+
let has = isList(type) || isMap(type);
|
|
2732
|
+
if (!has && isStruct(type))
|
|
2733
|
+
has = children(type).some((c) => hasContainer(c.type));
|
|
2734
|
+
HAS_CONTAINER.set(type, has);
|
|
2735
|
+
return has;
|
|
2736
|
+
}
|
|
2737
|
+
function conformValue(type, value, nullable, name) {
|
|
2738
|
+
if (value == null) {
|
|
2739
|
+
if (nullable)
|
|
2740
|
+
return value ?? null;
|
|
2741
|
+
if (isList(type) || isMap(type))
|
|
2742
|
+
return [];
|
|
2743
|
+
return value;
|
|
2744
|
+
}
|
|
2745
|
+
if (!hasContainer(type))
|
|
2746
|
+
return value;
|
|
2747
|
+
if (isList(type)) {
|
|
2748
|
+
const itemType = children(type)[0].type;
|
|
2749
|
+
const itemsNullable = OPTIONAL_ITEM_FIELDS.has(name);
|
|
2750
|
+
const items = Array.isArray(value) ? value : Array.from(value);
|
|
2751
|
+
let changed = !Array.isArray(value);
|
|
2752
|
+
const out = items.map((item) => {
|
|
2753
|
+
const next = item == null && !itemsNullable ? zeroValue(itemType) : conformValue(itemType, item, true, name);
|
|
2754
|
+
if (next !== item)
|
|
2755
|
+
changed = true;
|
|
2756
|
+
return next;
|
|
2757
|
+
});
|
|
2758
|
+
return changed ? out : value;
|
|
2759
|
+
}
|
|
2760
|
+
if (isMap(type)) {
|
|
2761
|
+
const valueType = mapValueType(type);
|
|
2762
|
+
const pairs = mapPairs(value);
|
|
2763
|
+
let changed = false;
|
|
2764
|
+
const out = pairs.map(([k, v]) => {
|
|
2765
|
+
const next = v == null ? zeroValue(valueType) : conformValue(valueType, v, true, name);
|
|
2766
|
+
if (next !== v)
|
|
2767
|
+
changed = true;
|
|
2768
|
+
return [k, next];
|
|
2769
|
+
});
|
|
2770
|
+
return changed ? out : value;
|
|
2771
|
+
}
|
|
2772
|
+
if (isStruct(type)) {
|
|
2773
|
+
let out = null;
|
|
2774
|
+
for (const c of children(type)) {
|
|
2775
|
+
const v = value[c.name];
|
|
2776
|
+
const next = conformValue(c.type, v, c.nullable, c.name);
|
|
2777
|
+
if (next !== v) {
|
|
2778
|
+
(out ??= { ...value })[c.name] = next;
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
return out ?? value;
|
|
2782
|
+
}
|
|
2783
|
+
return value;
|
|
2784
|
+
}
|
|
2785
|
+
function conformRecord(schema, obj) {
|
|
2786
|
+
let out = null;
|
|
2787
|
+
for (const f of schema.fields) {
|
|
2788
|
+
const v = obj[f.name];
|
|
2789
|
+
const next = conformValue(f.type, v, f.nullable, f.name);
|
|
2790
|
+
if (next !== v) {
|
|
2791
|
+
(out ??= { ...obj })[f.name] = next;
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
return out ?? obj;
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2641
2797
|
// src/protocol/serializers/shared.ts
|
|
2642
2798
|
function toUint8Array2(val) {
|
|
2643
2799
|
if (typeof val === "string")
|
|
@@ -5436,7 +5592,8 @@ function normalizeRequestSchemaPaths(params) {
|
|
|
5436
5592
|
}
|
|
5437
5593
|
function wrapResult(values, innerSchema) {
|
|
5438
5594
|
const a = innerSchema;
|
|
5439
|
-
const
|
|
5595
|
+
const row = conformRecord(a, values);
|
|
5596
|
+
const batch = batchFromColumns(Object.fromEntries(a.fields.map((f) => [f.name, [row[f.name] ?? null]])), a);
|
|
5440
5597
|
return { result: serializeBatch(batch) };
|
|
5441
5598
|
}
|
|
5442
5599
|
function overloadContext(req, catalogInterface) {
|
|
@@ -5459,21 +5616,24 @@ function overloadContext(req, catalogInterface) {
|
|
|
5459
5616
|
|
|
5460
5617
|
// src/errors.ts
|
|
5461
5618
|
class VgiError extends Error {
|
|
5462
|
-
|
|
5619
|
+
errorCode;
|
|
5620
|
+
constructor(message, code) {
|
|
5463
5621
|
super(message);
|
|
5464
5622
|
this.name = "VgiError";
|
|
5623
|
+
if (code !== undefined)
|
|
5624
|
+
this.errorCode = code;
|
|
5465
5625
|
}
|
|
5466
5626
|
}
|
|
5467
5627
|
class ArgumentValidationError extends VgiError {
|
|
5468
5628
|
constructor(message) {
|
|
5469
|
-
super(message);
|
|
5629
|
+
super(message, "INVALID_ARGUMENT");
|
|
5470
5630
|
this.name = "ArgumentValidationError";
|
|
5471
5631
|
}
|
|
5472
5632
|
}
|
|
5473
5633
|
|
|
5474
5634
|
class NoCatalogError extends VgiError {
|
|
5475
5635
|
constructor() {
|
|
5476
|
-
super("No catalog is configured for this worker");
|
|
5636
|
+
super("No catalog is configured for this worker", "UNIMPLEMENTED");
|
|
5477
5637
|
this.name = "NoCatalogError";
|
|
5478
5638
|
}
|
|
5479
5639
|
}
|
|
@@ -7323,7 +7483,7 @@ function hex(buf) {
|
|
|
7323
7483
|
|
|
7324
7484
|
// src/codec/asd.ts
|
|
7325
7485
|
function encodeASD(schema, obj) {
|
|
7326
|
-
return serializeBatch(batchFromRows([sortMapsForSchema(schema, obj)], schema));
|
|
7486
|
+
return serializeBatch(batchFromRows([sortMapsForSchema(schema, conformRecord(schema, obj))], schema));
|
|
7327
7487
|
}
|
|
7328
7488
|
function compareCodePoints(a, b) {
|
|
7329
7489
|
const n = Math.min(a.length, b.length);
|
|
@@ -7340,7 +7500,7 @@ function compareCodePoints(a, b) {
|
|
|
7340
7500
|
}
|
|
7341
7501
|
return a.length - b.length;
|
|
7342
7502
|
}
|
|
7343
|
-
function
|
|
7503
|
+
function mapPairs2(raw) {
|
|
7344
7504
|
if (Array.isArray(raw))
|
|
7345
7505
|
return raw.map((e) => Array.isArray(e) ? [e[0], e[1]] : [e?.key, e?.value]);
|
|
7346
7506
|
if (raw instanceof Map)
|
|
@@ -7375,7 +7535,7 @@ function sortMapsForType(type, value) {
|
|
|
7375
7535
|
if (isMap(type)) {
|
|
7376
7536
|
const entries = type.children[0].type;
|
|
7377
7537
|
const valueType = entries.children[1].type;
|
|
7378
|
-
return
|
|
7538
|
+
return mapPairs2(value).map(([k, v]) => [k, sortMapsForType(valueType, v)]).sort((x, y) => compareKeys(x[0], y[0]));
|
|
7379
7539
|
}
|
|
7380
7540
|
if (isList(type)) {
|
|
7381
7541
|
const child = type.children[0].type;
|
|
@@ -7703,7 +7863,7 @@ async function checkReservedAttachOptions(catalog) {
|
|
|
7703
7863
|
var ATTACH_TICKET_PREFIX = "vgia1.";
|
|
7704
7864
|
var ATTACH_TICKET_OPTION = RESERVED_ATTACH_OPTION;
|
|
7705
7865
|
var ATTACH_TICKETS_PROTOCOL_NAME = "vgi.attach_tickets.v1";
|
|
7706
|
-
var ATTACH_TICKETS_PROTOCOL_VERSION = "
|
|
7866
|
+
var ATTACH_TICKETS_PROTOCOL_VERSION = "2.0.0";
|
|
7707
7867
|
var TICKET_ENVELOPE_VERSION = 1;
|
|
7708
7868
|
var MAX_OPTIONS_BYTES = 16 * 1024;
|
|
7709
7869
|
var MAX_TICKET_CHARS = 32 * 1024;
|
|
@@ -7978,8 +8138,19 @@ var SEAL_ATTACH_REQUEST_SCHEMA = schema2([
|
|
|
7978
8138
|
]);
|
|
7979
8139
|
var ATTACH_TICKET_SCHEMA = schema2([
|
|
7980
8140
|
field2("ticket", utf82(), false),
|
|
7981
|
-
field2("expires_at",
|
|
8141
|
+
field2("expires_at", timestamp2(TimeUnit2.MICROSECOND, "UTC"), true)
|
|
7982
8142
|
]);
|
|
8143
|
+
function expiresAtMicros(value) {
|
|
8144
|
+
if (value === null)
|
|
8145
|
+
return null;
|
|
8146
|
+
const ms = value.getTime();
|
|
8147
|
+
if (!Number.isFinite(ms))
|
|
8148
|
+
throw new TypeError("AttachTicket.expires_at must be a valid Date or null");
|
|
8149
|
+
return BigInt(ms) * 1000n;
|
|
8150
|
+
}
|
|
8151
|
+
function encodeAttachTicket(ticket) {
|
|
8152
|
+
return serializeBatch(batchFromColumns({ ticket: [ticket.ticket], expires_at: [expiresAtMicros(ticket.expires_at)] }, ATTACH_TICKET_SCHEMA));
|
|
8153
|
+
}
|
|
7983
8154
|
function resolveTicketMaxTtl(grantKeys, env) {
|
|
7984
8155
|
if (grantKeys)
|
|
7985
8156
|
return Math.trunc(grantKeys.maxTtlSeconds);
|
|
@@ -8066,7 +8237,7 @@ async function sealAttach2(config, request, auth) {
|
|
|
8066
8237
|
} catch (e) {
|
|
8067
8238
|
throw new AttachTicketRequestError("seal_attach request is invalid", [["request", e.message]]);
|
|
8068
8239
|
}
|
|
8069
|
-
return { ticket: token, expires_at: expiresAt === 0 ?
|
|
8240
|
+
return { ticket: token, expires_at: expiresAt === 0 ? null : new Date(expiresAt * 1000) };
|
|
8070
8241
|
}
|
|
8071
8242
|
function buildAttachTicketsProtocol(config) {
|
|
8072
8243
|
const p = new Protocol2(ATTACH_TICKETS_PROTOCOL_NAME, { protocolVersion: ATTACH_TICKETS_PROTOCOL_VERSION });
|
|
@@ -8077,8 +8248,7 @@ function buildAttachTicketsProtocol(config) {
|
|
|
8077
8248
|
handler: async (params, ctx) => {
|
|
8078
8249
|
const request = unwrapRequest(params.request);
|
|
8079
8250
|
const sealed = await sealAttach2(config, request, ctx?.auth);
|
|
8080
|
-
|
|
8081
|
-
return { result: serializeBatch(batch) };
|
|
8251
|
+
return { result: encodeAttachTicket(sealed) };
|
|
8082
8252
|
}
|
|
8083
8253
|
});
|
|
8084
8254
|
return p;
|
|
@@ -8605,7 +8775,7 @@ function validatedHostedProtocols(hosting, primary) {
|
|
|
8605
8775
|
}
|
|
8606
8776
|
const name = p.name;
|
|
8607
8777
|
if (name.startsWith(RESERVED_PREFIX)) {
|
|
8608
|
-
throw new Error(`${owner} entry ${index} is named '${name}', which claims the reserved '${RESERVED_PREFIX}' prefix. ` + "Framework protocols are not supplied through this hook: reflection is hosted automatically, and " + "vgi_rpc.Identity.
|
|
8778
|
+
throw new Error(`${owner} entry ${index} is named '${name}', which claims the reserved '${RESERVED_PREFIX}' prefix. ` + "Framework protocols are not supplied through this hook: reflection is hosted automatically, and " + "vgi_rpc.Identity.v2 is enabled by supplying resolveToken and/or mintGrant.");
|
|
8609
8779
|
}
|
|
8610
8780
|
if (!/^[A-Za-z_][A-Za-z0-9_.]*$/.test(name)) {
|
|
8611
8781
|
throw new Error(`${owner} entry ${index}: protocol name '${name}' is not an identifier, optionally dot-qualified ` + "(e.g. 'acme.Reports.v1').");
|
|
@@ -8655,7 +8825,7 @@ function resolveIntrospectPrincipals(explicit, env) {
|
|
|
8655
8825
|
principals = raw.split(",").map((p) => p.trim()).filter((p) => p !== "");
|
|
8656
8826
|
}
|
|
8657
8827
|
if (principals.length === 0) {
|
|
8658
|
-
throw new Error("This worker supplies resolveToken, which hosts the vgi_rpc.Identity.
|
|
8828
|
+
throw new Error("This worker supplies resolveToken, which hosts the vgi_rpc.Identity.v2 protocol, but no " + `introspector allowlist was configured. Set ${INTROSPECT_PRINCIPALS_ENV} (comma-separated) or pass ` + `introspectPrincipals.
|
|
8659
8829
|
|
|
8660
8830
|
` + "There is no permissive default on purpose: introspection is a separate capability from " + "authentication, and allowing every authenticated caller lets any user resolve any other user's " + "credential to its owner. Remove resolveToken to leave the protocol unhosted entirely.");
|
|
8661
8831
|
}
|
|
@@ -8890,4 +9060,4 @@ export {
|
|
|
8890
9060
|
serveVgiWorker
|
|
8891
9061
|
};
|
|
8892
9062
|
|
|
8893
|
-
//# debugId=
|
|
9063
|
+
//# debugId=8C488693F22A8E5A64756E2164756E21
|