@stripe/extensibility-sdk 0.25.0 → 0.26.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 +1 -28
- package/dist/config-values/generate.cjs +1 -1
- package/dist/config-values/generate.js +1 -1
- package/dist/extensibility-sdk-alpha.d.ts +2 -61
- package/dist/extensibility-sdk-beta.d.ts +2 -61
- package/dist/extensibility-sdk-extensions-internal.d.ts +1 -1
- package/dist/extensibility-sdk-internal.d.ts +6 -43
- package/dist/extensibility-sdk-public.d.ts +2 -61
- package/dist/extensibility-sdk-stdlib-alpha.d.ts +2 -61
- package/dist/extensibility-sdk-stdlib-beta.d.ts +2 -61
- package/dist/extensibility-sdk-stdlib-internal.d.ts +6 -43
- package/dist/extensibility-sdk-stdlib-public.d.ts +2 -61
- package/dist/index.cjs +25 -41
- package/dist/index.js +23 -36
- package/dist/stdlib/decimal.d.ts +1 -1
- package/dist/stdlib/index.cjs +25 -41
- package/dist/stdlib/index.d.ts +3 -3
- package/dist/stdlib/index.d.ts.map +1 -1
- package/dist/stdlib/index.js +23 -36
- package/dist/stdlib/refs.d.ts +1 -23
- package/dist/stdlib/refs.d.ts.map +1 -1
- package/dist/stdlib/scalars.d.ts +0 -18
- package/dist/stdlib/scalars.d.ts.map +1 -1
- package/dist/stdlib/transforms.d.ts +1 -1
- package/dist/stdlib/types.d.ts +5 -5
- package/dist/stdlib/types.d.ts.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -25,7 +25,7 @@ export declare const __brand: '__brand';
|
|
|
25
25
|
*
|
|
26
26
|
* Using a dedicated key (rather than the shared `__brand`) lets formspec's
|
|
27
27
|
* structural brand-detection distinguish `Decimal` from other SDK branded
|
|
28
|
-
* types (e.g., `Ref
|
|
28
|
+
* types (e.g., `Ref`) that also carry `[__brand]`.
|
|
29
29
|
*
|
|
30
30
|
* String-literal const (not `unique symbol`) so that independent
|
|
31
31
|
* declaration rollups (root vs subpath) produce structurally compatible
|
|
@@ -567,25 +567,6 @@ export declare interface IntegerCompanion {
|
|
|
567
567
|
*/
|
|
568
568
|
export declare type IntegerRoundDirection = 'ceil' | 'floor' | 'half-up' | 'round-down' | 'round-up';
|
|
569
569
|
|
|
570
|
-
/**
|
|
571
|
-
* Check whether a value is a `Decimal` instance.
|
|
572
|
-
*
|
|
573
|
-
* @remarks
|
|
574
|
-
* Use this instead of `instanceof` — the underlying class is not
|
|
575
|
-
* publicly exported, so `instanceof` checks are not available to
|
|
576
|
-
* consumers.
|
|
577
|
-
*
|
|
578
|
-
* @example
|
|
579
|
-
* ```ts
|
|
580
|
-
* if (isDecimal(value)) {
|
|
581
|
-
* value.add(Decimal.from('1')); // value is Decimal
|
|
582
|
-
* }
|
|
583
|
-
* ```
|
|
584
|
-
*
|
|
585
|
-
* @public
|
|
586
|
-
*/
|
|
587
|
-
export declare function isDecimal(value: unknown): value is Decimal;
|
|
588
|
-
|
|
589
570
|
/**
|
|
590
571
|
* Returns `true` if `value` conforms to the `PromiseLike` contract:
|
|
591
572
|
* a non-null object or function with a callable `then` method.
|
|
@@ -768,7 +749,7 @@ export declare const Ref: { create: <T extends { readonly object: string }>(step
|
|
|
768
749
|
/**
|
|
769
750
|
* Wraps a transformer so that a `null` / `undefined` result throws
|
|
770
751
|
* `WireParseError('Required field is missing')`, which `strategy.applyField`
|
|
771
|
-
* will catch and re-throw as
|
|
752
|
+
* will catch and re-throw as _WireReadError / _WireWriteError with field context.
|
|
772
753
|
*
|
|
773
754
|
* The inner transformer runs first, so strategies that backfill absent values
|
|
774
755
|
* (e.g. clock-aware `translateDateTime`) can satisfy the requirement.
|
|
@@ -815,27 +796,9 @@ export declare class _ShapeDescriptor<_S extends _ApplyStrategy = _ApplyStrategy
|
|
|
815
796
|
constructor(typeName: string, fields: _FieldDescriptor[], oneofFields?: _OneofFieldDescriptor[]);
|
|
816
797
|
}
|
|
817
798
|
|
|
818
|
-
/** A branded string representing a street address. @public */
|
|
819
|
-
export declare type StreetAddress = {
|
|
820
|
-
readonly [__brand]: 'StreetAddress';
|
|
821
|
-
readonly [__stripeType]: 'string';
|
|
822
|
-
} & string;
|
|
823
|
-
|
|
824
|
-
/** Factory for creating {@link (StreetAddress:type)} branded values. @public */
|
|
825
|
-
export declare const StreetAddress: { create: (address: string) => StreetAddress };
|
|
826
|
-
|
|
827
799
|
/** The type of the opaque Stripe type-tag key used in SDK scalar types. @public */
|
|
828
800
|
export declare type StripeTypeSymbol = typeof __stripeType;
|
|
829
801
|
|
|
830
|
-
/** A branded string representing an ISO 8601 datetime. @public */
|
|
831
|
-
export declare type Timestamp = {
|
|
832
|
-
readonly [__brand]: 'Timestamp';
|
|
833
|
-
readonly [__stripeType]: 'string';
|
|
834
|
-
} & string;
|
|
835
|
-
|
|
836
|
-
/** Factory for creating {@link (Timestamp:type)} branded values. @public */
|
|
837
|
-
export declare const Timestamp: { create: (value: string) => Timestamp };
|
|
838
|
-
|
|
839
802
|
/**
|
|
840
803
|
* Deep-freezes `value` and returns it typed as {@link DeepReadonly}`<T>`.
|
|
841
804
|
*
|
|
@@ -980,9 +943,9 @@ export declare class _UnionDescriptor<_S extends _ApplyStrategy = _ApplyStrategy
|
|
|
980
943
|
* Indicates malformed or unexpected data from the proto infrastructure —
|
|
981
944
|
* not a bug in the user's code.
|
|
982
945
|
*
|
|
983
|
-
* @
|
|
946
|
+
* @internal
|
|
984
947
|
*/
|
|
985
|
-
export declare class
|
|
948
|
+
export declare class _WireReadError extends Error {
|
|
986
949
|
/**
|
|
987
950
|
* Error class name for `instanceof`-free identification.
|
|
988
951
|
* @internal
|
|
@@ -995,9 +958,9 @@ export declare class WireReadError extends Error {
|
|
|
995
958
|
* Indicates that the user's code returned a value that cannot be translated
|
|
996
959
|
* back to wire format.
|
|
997
960
|
*
|
|
998
|
-
* @
|
|
961
|
+
* @internal
|
|
999
962
|
*/
|
|
1000
|
-
export declare class
|
|
963
|
+
export declare class _WireWriteError extends Error {
|
|
1001
964
|
/**
|
|
1002
965
|
* Error class name for `instanceof`-free identification.
|
|
1003
966
|
* @internal
|
|
@@ -404,25 +404,6 @@ export declare interface IntegerCompanion {
|
|
|
404
404
|
*/
|
|
405
405
|
export declare type IntegerRoundDirection = 'ceil' | 'floor' | 'half-up' | 'round-down' | 'round-up';
|
|
406
406
|
|
|
407
|
-
/**
|
|
408
|
-
* Check whether a value is a `Decimal` instance.
|
|
409
|
-
*
|
|
410
|
-
* @remarks
|
|
411
|
-
* Use this instead of `instanceof` — the underlying class is not
|
|
412
|
-
* publicly exported, so `instanceof` checks are not available to
|
|
413
|
-
* consumers.
|
|
414
|
-
*
|
|
415
|
-
* @example
|
|
416
|
-
* ```ts
|
|
417
|
-
* if (isDecimal(value)) {
|
|
418
|
-
* value.add(Decimal.from('1')); // value is Decimal
|
|
419
|
-
* }
|
|
420
|
-
* ```
|
|
421
|
-
*
|
|
422
|
-
* @public
|
|
423
|
-
*/
|
|
424
|
-
export declare function isDecimal(value: unknown): value is Decimal;
|
|
425
|
-
|
|
426
407
|
/* Excluded from this release type: _isPromiseLike */
|
|
427
408
|
|
|
428
409
|
/* Excluded from this release type: _JsonWireToType */
|
|
@@ -544,27 +525,9 @@ export declare type RoundDirection = 'ceil' | 'floor' | 'half-down' | 'half-even
|
|
|
544
525
|
|
|
545
526
|
/* Excluded from this release type: _ShapeDescriptor */
|
|
546
527
|
|
|
547
|
-
/** A branded string representing a street address. @public */
|
|
548
|
-
export declare type StreetAddress = {
|
|
549
|
-
readonly [__brand]: 'StreetAddress';
|
|
550
|
-
readonly [__stripeType]: 'string';
|
|
551
|
-
} & string;
|
|
552
|
-
|
|
553
|
-
/** Factory for creating {@link (StreetAddress:type)} branded values. @public */
|
|
554
|
-
export declare const StreetAddress: { create: (address: string) => StreetAddress };
|
|
555
|
-
|
|
556
528
|
/** The type of the opaque Stripe type-tag key used in SDK scalar types. @public */
|
|
557
529
|
export declare type StripeTypeSymbol = typeof __stripeType;
|
|
558
530
|
|
|
559
|
-
/** A branded string representing an ISO 8601 datetime. @public */
|
|
560
|
-
export declare type Timestamp = {
|
|
561
|
-
readonly [__brand]: 'Timestamp';
|
|
562
|
-
readonly [__stripeType]: 'string';
|
|
563
|
-
} & string;
|
|
564
|
-
|
|
565
|
-
/** Factory for creating {@link (Timestamp:type)} branded values. @public */
|
|
566
|
-
export declare const Timestamp: { create: (value: string) => Timestamp };
|
|
567
|
-
|
|
568
531
|
/**
|
|
569
532
|
* Deep-freezes `value` and returns it typed as {@link DeepReadonly}`<T>`.
|
|
570
533
|
*
|
|
@@ -609,30 +572,8 @@ export declare function toConst<T>(value: T): DeepReadonly<T>;
|
|
|
609
572
|
|
|
610
573
|
/* Excluded from this release type: _UnionDescriptor */
|
|
611
574
|
|
|
612
|
-
|
|
613
|
-
* Shared types and error classes for the transform pipeline.
|
|
614
|
-
* See transforms.ts for the module overview.
|
|
615
|
-
*/
|
|
616
|
-
/**
|
|
617
|
-
* Thrown when incoming wire data (proto → SDK) cannot be parsed.
|
|
618
|
-
* Indicates malformed or unexpected data from the proto infrastructure —
|
|
619
|
-
* not a bug in the user's code.
|
|
620
|
-
*
|
|
621
|
-
* @public
|
|
622
|
-
*/
|
|
623
|
-
export declare class WireReadError extends Error {
|
|
624
|
-
/* Excluded from this release type: name */
|
|
625
|
-
}
|
|
575
|
+
/* Excluded from this release type: _WireReadError */
|
|
626
576
|
|
|
627
|
-
|
|
628
|
-
* Thrown when outgoing SDK data (SDK → proto) cannot be serialized.
|
|
629
|
-
* Indicates that the user's code returned a value that cannot be translated
|
|
630
|
-
* back to wire format.
|
|
631
|
-
*
|
|
632
|
-
* @public
|
|
633
|
-
*/
|
|
634
|
-
export declare class WireWriteError extends Error {
|
|
635
|
-
/* Excluded from this release type: name */
|
|
636
|
-
}
|
|
577
|
+
/* Excluded from this release type: _WireWriteError */
|
|
637
578
|
|
|
638
579
|
export { }
|
package/dist/index.cjs
CHANGED
|
@@ -29,10 +29,6 @@ __export(src_exports, {
|
|
|
29
29
|
Integer: () => Integer,
|
|
30
30
|
PositiveInteger: () => PositiveInteger,
|
|
31
31
|
Ref: () => Ref,
|
|
32
|
-
StreetAddress: () => StreetAddress,
|
|
33
|
-
Timestamp: () => Timestamp,
|
|
34
|
-
WireReadError: () => WireReadError,
|
|
35
|
-
WireWriteError: () => WireWriteError,
|
|
36
32
|
_ConfigEnum: () => _ConfigEnum,
|
|
37
33
|
_JsonWireToType: () => _JsonWireToType,
|
|
38
34
|
_ProtoEnum: () => _ProtoEnum,
|
|
@@ -40,6 +36,8 @@ __export(src_exports, {
|
|
|
40
36
|
_ShapeDescriptor: () => _ShapeDescriptor,
|
|
41
37
|
_TypeToProtoWire: () => _TypeToProtoWire,
|
|
42
38
|
_UnionDescriptor: () => _UnionDescriptor,
|
|
39
|
+
_WireReadError: () => _WireReadError,
|
|
40
|
+
_WireWriteError: () => _WireWriteError,
|
|
43
41
|
_apply: () => _apply,
|
|
44
42
|
_applyConfig: () => _applyConfig,
|
|
45
43
|
_applyIncoming: () => _applyIncoming,
|
|
@@ -55,7 +53,6 @@ __export(src_exports, {
|
|
|
55
53
|
_translateMap: () => _translateMap,
|
|
56
54
|
_translateShape: () => _translateShape,
|
|
57
55
|
_translateUnion: () => _translateUnion,
|
|
58
|
-
isDecimal: () => isDecimal,
|
|
59
56
|
toConst: () => toConst
|
|
60
57
|
});
|
|
61
58
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -1164,16 +1161,6 @@ var PositiveInteger = {
|
|
|
1164
1161
|
return normalized;
|
|
1165
1162
|
}
|
|
1166
1163
|
};
|
|
1167
|
-
var StreetAddress = {
|
|
1168
|
-
create: (address) => {
|
|
1169
|
-
return address;
|
|
1170
|
-
}
|
|
1171
|
-
};
|
|
1172
|
-
var Timestamp = {
|
|
1173
|
-
create: (value) => {
|
|
1174
|
-
return value;
|
|
1175
|
-
}
|
|
1176
|
-
};
|
|
1177
1164
|
|
|
1178
1165
|
// src/stdlib/refs.ts
|
|
1179
1166
|
var Ref = {
|
|
@@ -1186,19 +1173,19 @@ var Ref = {
|
|
|
1186
1173
|
};
|
|
1187
1174
|
|
|
1188
1175
|
// src/stdlib/types.ts
|
|
1189
|
-
var
|
|
1176
|
+
var _WireReadError = class extends Error {
|
|
1190
1177
|
/**
|
|
1191
1178
|
* Error class name for `instanceof`-free identification.
|
|
1192
1179
|
* @internal
|
|
1193
1180
|
*/
|
|
1194
|
-
name = "
|
|
1181
|
+
name = "_WireReadError";
|
|
1195
1182
|
};
|
|
1196
|
-
var
|
|
1183
|
+
var _WireWriteError = class extends Error {
|
|
1197
1184
|
/**
|
|
1198
1185
|
* Error class name for `instanceof`-free identification.
|
|
1199
1186
|
* @internal
|
|
1200
1187
|
*/
|
|
1201
|
-
name = "
|
|
1188
|
+
name = "_WireWriteError";
|
|
1202
1189
|
};
|
|
1203
1190
|
var WireParseError = class extends Error {
|
|
1204
1191
|
name = "WireParseError";
|
|
@@ -1405,7 +1392,7 @@ function enumLookup(spec, value, direction) {
|
|
|
1405
1392
|
var _ProtoWireToType = {
|
|
1406
1393
|
_brand: "ProtoWireToType",
|
|
1407
1394
|
createNotObjectError(loc, received) {
|
|
1408
|
-
return new
|
|
1395
|
+
return new _WireReadError(`${loc}: Expected an object but received ${received}`);
|
|
1409
1396
|
},
|
|
1410
1397
|
applyField(typeName, desc, input, strategy) {
|
|
1411
1398
|
const from = desc.wire ?? desc.type;
|
|
@@ -1415,7 +1402,7 @@ var _ProtoWireToType = {
|
|
|
1415
1402
|
return [to, (desc.transform ?? _identity)(strategy, raw)];
|
|
1416
1403
|
} catch (e) {
|
|
1417
1404
|
if (e instanceof WireParseError)
|
|
1418
|
-
throw new
|
|
1405
|
+
throw new _WireReadError(`${typeName}.${desc.type}: ${e.message}`);
|
|
1419
1406
|
throw e;
|
|
1420
1407
|
}
|
|
1421
1408
|
},
|
|
@@ -1470,7 +1457,7 @@ var _ProtoWireToType = {
|
|
|
1470
1457
|
}
|
|
1471
1458
|
}
|
|
1472
1459
|
const loc = descriptor.typeName || "union";
|
|
1473
|
-
throw new
|
|
1460
|
+
throw new _WireReadError(`${loc}: No variant set`);
|
|
1474
1461
|
},
|
|
1475
1462
|
applyOneofField(typeName, oneof, input, strategy, result, excludeWireKeys) {
|
|
1476
1463
|
applyOneofFieldIncoming(typeName, oneof, input, strategy, result, excludeWireKeys);
|
|
@@ -1479,7 +1466,7 @@ var _ProtoWireToType = {
|
|
|
1479
1466
|
var _TypeToProtoWire = {
|
|
1480
1467
|
_brand: "TypeToProtoWire",
|
|
1481
1468
|
createNotObjectError(loc, received) {
|
|
1482
|
-
return new
|
|
1469
|
+
return new _WireWriteError(`${loc}: Expected an object but received ${received}`);
|
|
1483
1470
|
},
|
|
1484
1471
|
applyField(typeName, desc, input, strategy) {
|
|
1485
1472
|
const from = desc.type;
|
|
@@ -1489,7 +1476,7 @@ var _TypeToProtoWire = {
|
|
|
1489
1476
|
return [to, (desc.transform ?? _identity)(strategy, raw)];
|
|
1490
1477
|
} catch (e) {
|
|
1491
1478
|
if (e instanceof WireParseError)
|
|
1492
|
-
throw new
|
|
1479
|
+
throw new _WireWriteError(`${typeName}.${desc.type}: ${e.message}`);
|
|
1493
1480
|
throw e;
|
|
1494
1481
|
}
|
|
1495
1482
|
},
|
|
@@ -1529,20 +1516,20 @@ var _TypeToProtoWire = {
|
|
|
1529
1516
|
const discriminant = sdk[descriptor.discriminantFieldName];
|
|
1530
1517
|
if (typeof discriminant !== "string") {
|
|
1531
1518
|
const loc = descriptor.typeName || "union";
|
|
1532
|
-
throw new
|
|
1519
|
+
throw new _WireWriteError(
|
|
1533
1520
|
`${loc}: Expected a string '${descriptor.discriminantFieldName}' discriminant but received ${discriminant === void 0 ? "undefined" : typeof discriminant}`
|
|
1534
1521
|
);
|
|
1535
1522
|
}
|
|
1536
1523
|
if (discriminant === "other") {
|
|
1537
1524
|
const loc = descriptor.typeName || "union";
|
|
1538
|
-
throw new
|
|
1525
|
+
throw new _WireWriteError(
|
|
1539
1526
|
`${loc}: Cannot serialize 'other' variant back to wire format`
|
|
1540
1527
|
);
|
|
1541
1528
|
}
|
|
1542
1529
|
const branch = descriptor.branches.find((b) => b.typeKey === discriminant);
|
|
1543
1530
|
if (!branch) {
|
|
1544
1531
|
const loc = descriptor.typeName || "union";
|
|
1545
|
-
throw new
|
|
1532
|
+
throw new _WireWriteError(`${loc}: Unknown variant '${discriminant}'`);
|
|
1546
1533
|
}
|
|
1547
1534
|
const branchData = _apply(
|
|
1548
1535
|
new _ShapeDescriptor(descriptor.typeName, branch.shape),
|
|
@@ -1571,7 +1558,7 @@ function _configAppContextFromContext(ctx) {
|
|
|
1571
1558
|
var _JsonWireToType = {
|
|
1572
1559
|
_brand: "JsonWireToType",
|
|
1573
1560
|
createNotObjectError(loc, received) {
|
|
1574
|
-
return new
|
|
1561
|
+
return new _WireReadError(`${loc}: Expected an object but received ${received}`);
|
|
1575
1562
|
},
|
|
1576
1563
|
applyField(typeName, desc, input, strategy) {
|
|
1577
1564
|
const key = desc.type;
|
|
@@ -1580,7 +1567,7 @@ var _JsonWireToType = {
|
|
|
1580
1567
|
return [key, (desc.transform ?? _identity)(strategy, raw)];
|
|
1581
1568
|
} catch (e) {
|
|
1582
1569
|
if (e instanceof WireParseError)
|
|
1583
|
-
throw new
|
|
1570
|
+
throw new _WireReadError(`${typeName}.${desc.type}: ${e.message}`);
|
|
1584
1571
|
throw e;
|
|
1585
1572
|
}
|
|
1586
1573
|
},
|
|
@@ -1635,7 +1622,7 @@ function applyOneofFieldIncoming(typeName, oneof, input, strategy, result, exclu
|
|
|
1635
1622
|
}
|
|
1636
1623
|
} catch (e) {
|
|
1637
1624
|
if (e instanceof WireParseError) {
|
|
1638
|
-
throw new
|
|
1625
|
+
throw new _WireReadError(
|
|
1639
1626
|
`${typeName}.${oneof.discriminant}(${branch.typeKey}): ${e.message}`
|
|
1640
1627
|
);
|
|
1641
1628
|
}
|
|
@@ -1653,30 +1640,30 @@ function applyOneofFieldIncoming(typeName, oneof, input, strategy, result, exclu
|
|
|
1653
1640
|
}
|
|
1654
1641
|
}
|
|
1655
1642
|
if (!oneof.optional) {
|
|
1656
|
-
throw new
|
|
1643
|
+
throw new _WireReadError(`${typeName}.${oneof.discriminant}: no variant set`);
|
|
1657
1644
|
}
|
|
1658
1645
|
}
|
|
1659
1646
|
function applyOneofFieldOutgoing(typeName, oneof, input, strategy, result) {
|
|
1660
1647
|
const discriminant = Object.hasOwn(input, oneof.discriminant) ? input[oneof.discriminant] : void 0;
|
|
1661
1648
|
if (discriminant === void 0 || discriminant === null) {
|
|
1662
1649
|
if (!oneof.optional) {
|
|
1663
|
-
throw new
|
|
1650
|
+
throw new _WireWriteError(`${typeName}.${oneof.discriminant}: no variant set`);
|
|
1664
1651
|
}
|
|
1665
1652
|
return;
|
|
1666
1653
|
}
|
|
1667
1654
|
if (typeof discriminant !== "string") {
|
|
1668
|
-
throw new
|
|
1655
|
+
throw new _WireWriteError(
|
|
1669
1656
|
`${typeName}.${oneof.discriminant}: expected string discriminant but received ${typeof discriminant}`
|
|
1670
1657
|
);
|
|
1671
1658
|
}
|
|
1672
1659
|
if (discriminant === "other") {
|
|
1673
|
-
throw new
|
|
1660
|
+
throw new _WireWriteError(
|
|
1674
1661
|
`${typeName}.${oneof.discriminant}: cannot serialize 'other' variant back to wire format`
|
|
1675
1662
|
);
|
|
1676
1663
|
}
|
|
1677
1664
|
const branch = oneof.branches.find((b) => b.typeKey === discriminant);
|
|
1678
1665
|
if (!branch) {
|
|
1679
|
-
throw new
|
|
1666
|
+
throw new _WireWriteError(
|
|
1680
1667
|
`${typeName}.${oneof.discriminant}: unknown variant '${discriminant}'`
|
|
1681
1668
|
);
|
|
1682
1669
|
}
|
|
@@ -1686,7 +1673,7 @@ function applyOneofFieldOutgoing(typeName, oneof, input, strategy, result) {
|
|
|
1686
1673
|
result[branch.wireKey] = transformed ?? {};
|
|
1687
1674
|
} catch (e) {
|
|
1688
1675
|
if (e instanceof WireParseError) {
|
|
1689
|
-
throw new
|
|
1676
|
+
throw new _WireWriteError(
|
|
1690
1677
|
`${typeName}.${oneof.discriminant}(${branch.typeKey}): ${e.message}`
|
|
1691
1678
|
);
|
|
1692
1679
|
}
|
|
@@ -4056,10 +4043,6 @@ var CustomAction2;
|
|
|
4056
4043
|
Integer,
|
|
4057
4044
|
PositiveInteger,
|
|
4058
4045
|
Ref,
|
|
4059
|
-
StreetAddress,
|
|
4060
|
-
Timestamp,
|
|
4061
|
-
WireReadError,
|
|
4062
|
-
WireWriteError,
|
|
4063
4046
|
_ConfigEnum,
|
|
4064
4047
|
_JsonWireToType,
|
|
4065
4048
|
_ProtoEnum,
|
|
@@ -4067,6 +4050,8 @@ var CustomAction2;
|
|
|
4067
4050
|
_ShapeDescriptor,
|
|
4068
4051
|
_TypeToProtoWire,
|
|
4069
4052
|
_UnionDescriptor,
|
|
4053
|
+
_WireReadError,
|
|
4054
|
+
_WireWriteError,
|
|
4070
4055
|
_apply,
|
|
4071
4056
|
_applyConfig,
|
|
4072
4057
|
_applyIncoming,
|
|
@@ -4082,6 +4067,5 @@ var CustomAction2;
|
|
|
4082
4067
|
_translateMap,
|
|
4083
4068
|
_translateShape,
|
|
4084
4069
|
_translateUnion,
|
|
4085
|
-
isDecimal,
|
|
4086
4070
|
toConst
|
|
4087
4071
|
});
|
package/dist/index.js
CHANGED
|
@@ -1108,16 +1108,6 @@ var PositiveInteger = {
|
|
|
1108
1108
|
return normalized;
|
|
1109
1109
|
}
|
|
1110
1110
|
};
|
|
1111
|
-
var StreetAddress = {
|
|
1112
|
-
create: (address) => {
|
|
1113
|
-
return address;
|
|
1114
|
-
}
|
|
1115
|
-
};
|
|
1116
|
-
var Timestamp = {
|
|
1117
|
-
create: (value) => {
|
|
1118
|
-
return value;
|
|
1119
|
-
}
|
|
1120
|
-
};
|
|
1121
1111
|
|
|
1122
1112
|
// src/stdlib/refs.ts
|
|
1123
1113
|
var Ref = {
|
|
@@ -1130,19 +1120,19 @@ var Ref = {
|
|
|
1130
1120
|
};
|
|
1131
1121
|
|
|
1132
1122
|
// src/stdlib/types.ts
|
|
1133
|
-
var
|
|
1123
|
+
var _WireReadError = class extends Error {
|
|
1134
1124
|
/**
|
|
1135
1125
|
* Error class name for `instanceof`-free identification.
|
|
1136
1126
|
* @internal
|
|
1137
1127
|
*/
|
|
1138
|
-
name = "
|
|
1128
|
+
name = "_WireReadError";
|
|
1139
1129
|
};
|
|
1140
|
-
var
|
|
1130
|
+
var _WireWriteError = class extends Error {
|
|
1141
1131
|
/**
|
|
1142
1132
|
* Error class name for `instanceof`-free identification.
|
|
1143
1133
|
* @internal
|
|
1144
1134
|
*/
|
|
1145
|
-
name = "
|
|
1135
|
+
name = "_WireWriteError";
|
|
1146
1136
|
};
|
|
1147
1137
|
var WireParseError = class extends Error {
|
|
1148
1138
|
name = "WireParseError";
|
|
@@ -1349,7 +1339,7 @@ function enumLookup(spec, value, direction) {
|
|
|
1349
1339
|
var _ProtoWireToType = {
|
|
1350
1340
|
_brand: "ProtoWireToType",
|
|
1351
1341
|
createNotObjectError(loc, received) {
|
|
1352
|
-
return new
|
|
1342
|
+
return new _WireReadError(`${loc}: Expected an object but received ${received}`);
|
|
1353
1343
|
},
|
|
1354
1344
|
applyField(typeName, desc, input, strategy) {
|
|
1355
1345
|
const from = desc.wire ?? desc.type;
|
|
@@ -1359,7 +1349,7 @@ var _ProtoWireToType = {
|
|
|
1359
1349
|
return [to, (desc.transform ?? _identity)(strategy, raw)];
|
|
1360
1350
|
} catch (e) {
|
|
1361
1351
|
if (e instanceof WireParseError)
|
|
1362
|
-
throw new
|
|
1352
|
+
throw new _WireReadError(`${typeName}.${desc.type}: ${e.message}`);
|
|
1363
1353
|
throw e;
|
|
1364
1354
|
}
|
|
1365
1355
|
},
|
|
@@ -1414,7 +1404,7 @@ var _ProtoWireToType = {
|
|
|
1414
1404
|
}
|
|
1415
1405
|
}
|
|
1416
1406
|
const loc = descriptor.typeName || "union";
|
|
1417
|
-
throw new
|
|
1407
|
+
throw new _WireReadError(`${loc}: No variant set`);
|
|
1418
1408
|
},
|
|
1419
1409
|
applyOneofField(typeName, oneof, input, strategy, result, excludeWireKeys) {
|
|
1420
1410
|
applyOneofFieldIncoming(typeName, oneof, input, strategy, result, excludeWireKeys);
|
|
@@ -1423,7 +1413,7 @@ var _ProtoWireToType = {
|
|
|
1423
1413
|
var _TypeToProtoWire = {
|
|
1424
1414
|
_brand: "TypeToProtoWire",
|
|
1425
1415
|
createNotObjectError(loc, received) {
|
|
1426
|
-
return new
|
|
1416
|
+
return new _WireWriteError(`${loc}: Expected an object but received ${received}`);
|
|
1427
1417
|
},
|
|
1428
1418
|
applyField(typeName, desc, input, strategy) {
|
|
1429
1419
|
const from = desc.type;
|
|
@@ -1433,7 +1423,7 @@ var _TypeToProtoWire = {
|
|
|
1433
1423
|
return [to, (desc.transform ?? _identity)(strategy, raw)];
|
|
1434
1424
|
} catch (e) {
|
|
1435
1425
|
if (e instanceof WireParseError)
|
|
1436
|
-
throw new
|
|
1426
|
+
throw new _WireWriteError(`${typeName}.${desc.type}: ${e.message}`);
|
|
1437
1427
|
throw e;
|
|
1438
1428
|
}
|
|
1439
1429
|
},
|
|
@@ -1473,20 +1463,20 @@ var _TypeToProtoWire = {
|
|
|
1473
1463
|
const discriminant = sdk[descriptor.discriminantFieldName];
|
|
1474
1464
|
if (typeof discriminant !== "string") {
|
|
1475
1465
|
const loc = descriptor.typeName || "union";
|
|
1476
|
-
throw new
|
|
1466
|
+
throw new _WireWriteError(
|
|
1477
1467
|
`${loc}: Expected a string '${descriptor.discriminantFieldName}' discriminant but received ${discriminant === void 0 ? "undefined" : typeof discriminant}`
|
|
1478
1468
|
);
|
|
1479
1469
|
}
|
|
1480
1470
|
if (discriminant === "other") {
|
|
1481
1471
|
const loc = descriptor.typeName || "union";
|
|
1482
|
-
throw new
|
|
1472
|
+
throw new _WireWriteError(
|
|
1483
1473
|
`${loc}: Cannot serialize 'other' variant back to wire format`
|
|
1484
1474
|
);
|
|
1485
1475
|
}
|
|
1486
1476
|
const branch = descriptor.branches.find((b) => b.typeKey === discriminant);
|
|
1487
1477
|
if (!branch) {
|
|
1488
1478
|
const loc = descriptor.typeName || "union";
|
|
1489
|
-
throw new
|
|
1479
|
+
throw new _WireWriteError(`${loc}: Unknown variant '${discriminant}'`);
|
|
1490
1480
|
}
|
|
1491
1481
|
const branchData = _apply(
|
|
1492
1482
|
new _ShapeDescriptor(descriptor.typeName, branch.shape),
|
|
@@ -1515,7 +1505,7 @@ function _configAppContextFromContext(ctx) {
|
|
|
1515
1505
|
var _JsonWireToType = {
|
|
1516
1506
|
_brand: "JsonWireToType",
|
|
1517
1507
|
createNotObjectError(loc, received) {
|
|
1518
|
-
return new
|
|
1508
|
+
return new _WireReadError(`${loc}: Expected an object but received ${received}`);
|
|
1519
1509
|
},
|
|
1520
1510
|
applyField(typeName, desc, input, strategy) {
|
|
1521
1511
|
const key = desc.type;
|
|
@@ -1524,7 +1514,7 @@ var _JsonWireToType = {
|
|
|
1524
1514
|
return [key, (desc.transform ?? _identity)(strategy, raw)];
|
|
1525
1515
|
} catch (e) {
|
|
1526
1516
|
if (e instanceof WireParseError)
|
|
1527
|
-
throw new
|
|
1517
|
+
throw new _WireReadError(`${typeName}.${desc.type}: ${e.message}`);
|
|
1528
1518
|
throw e;
|
|
1529
1519
|
}
|
|
1530
1520
|
},
|
|
@@ -1579,7 +1569,7 @@ function applyOneofFieldIncoming(typeName, oneof, input, strategy, result, exclu
|
|
|
1579
1569
|
}
|
|
1580
1570
|
} catch (e) {
|
|
1581
1571
|
if (e instanceof WireParseError) {
|
|
1582
|
-
throw new
|
|
1572
|
+
throw new _WireReadError(
|
|
1583
1573
|
`${typeName}.${oneof.discriminant}(${branch.typeKey}): ${e.message}`
|
|
1584
1574
|
);
|
|
1585
1575
|
}
|
|
@@ -1597,30 +1587,30 @@ function applyOneofFieldIncoming(typeName, oneof, input, strategy, result, exclu
|
|
|
1597
1587
|
}
|
|
1598
1588
|
}
|
|
1599
1589
|
if (!oneof.optional) {
|
|
1600
|
-
throw new
|
|
1590
|
+
throw new _WireReadError(`${typeName}.${oneof.discriminant}: no variant set`);
|
|
1601
1591
|
}
|
|
1602
1592
|
}
|
|
1603
1593
|
function applyOneofFieldOutgoing(typeName, oneof, input, strategy, result) {
|
|
1604
1594
|
const discriminant = Object.hasOwn(input, oneof.discriminant) ? input[oneof.discriminant] : void 0;
|
|
1605
1595
|
if (discriminant === void 0 || discriminant === null) {
|
|
1606
1596
|
if (!oneof.optional) {
|
|
1607
|
-
throw new
|
|
1597
|
+
throw new _WireWriteError(`${typeName}.${oneof.discriminant}: no variant set`);
|
|
1608
1598
|
}
|
|
1609
1599
|
return;
|
|
1610
1600
|
}
|
|
1611
1601
|
if (typeof discriminant !== "string") {
|
|
1612
|
-
throw new
|
|
1602
|
+
throw new _WireWriteError(
|
|
1613
1603
|
`${typeName}.${oneof.discriminant}: expected string discriminant but received ${typeof discriminant}`
|
|
1614
1604
|
);
|
|
1615
1605
|
}
|
|
1616
1606
|
if (discriminant === "other") {
|
|
1617
|
-
throw new
|
|
1607
|
+
throw new _WireWriteError(
|
|
1618
1608
|
`${typeName}.${oneof.discriminant}: cannot serialize 'other' variant back to wire format`
|
|
1619
1609
|
);
|
|
1620
1610
|
}
|
|
1621
1611
|
const branch = oneof.branches.find((b) => b.typeKey === discriminant);
|
|
1622
1612
|
if (!branch) {
|
|
1623
|
-
throw new
|
|
1613
|
+
throw new _WireWriteError(
|
|
1624
1614
|
`${typeName}.${oneof.discriminant}: unknown variant '${discriminant}'`
|
|
1625
1615
|
);
|
|
1626
1616
|
}
|
|
@@ -1630,7 +1620,7 @@ function applyOneofFieldOutgoing(typeName, oneof, input, strategy, result) {
|
|
|
1630
1620
|
result[branch.wireKey] = transformed ?? {};
|
|
1631
1621
|
} catch (e) {
|
|
1632
1622
|
if (e instanceof WireParseError) {
|
|
1633
|
-
throw new
|
|
1623
|
+
throw new _WireWriteError(
|
|
1634
1624
|
`${typeName}.${oneof.discriminant}(${branch.typeKey}): ${e.message}`
|
|
1635
1625
|
);
|
|
1636
1626
|
}
|
|
@@ -3999,10 +3989,6 @@ export {
|
|
|
3999
3989
|
Integer,
|
|
4000
3990
|
PositiveInteger,
|
|
4001
3991
|
Ref,
|
|
4002
|
-
StreetAddress,
|
|
4003
|
-
Timestamp,
|
|
4004
|
-
WireReadError,
|
|
4005
|
-
WireWriteError,
|
|
4006
3992
|
_ConfigEnum,
|
|
4007
3993
|
_JsonWireToType,
|
|
4008
3994
|
_ProtoEnum,
|
|
@@ -4010,6 +3996,8 @@ export {
|
|
|
4010
3996
|
_ShapeDescriptor,
|
|
4011
3997
|
_TypeToProtoWire,
|
|
4012
3998
|
_UnionDescriptor,
|
|
3999
|
+
_WireReadError,
|
|
4000
|
+
_WireWriteError,
|
|
4013
4001
|
_apply,
|
|
4014
4002
|
_applyConfig,
|
|
4015
4003
|
_applyIncoming,
|
|
@@ -4025,6 +4013,5 @@ export {
|
|
|
4025
4013
|
_translateMap,
|
|
4026
4014
|
_translateShape,
|
|
4027
4015
|
_translateUnion,
|
|
4028
|
-
isDecimal,
|
|
4029
4016
|
toConst
|
|
4030
4017
|
};
|
package/dist/stdlib/decimal.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { Integer } from './scalars.js';
|
|
|
5
5
|
*
|
|
6
6
|
* Using a dedicated key (rather than the shared `__brand`) lets formspec's
|
|
7
7
|
* structural brand-detection distinguish `Decimal` from other SDK branded
|
|
8
|
-
* types (e.g., `Ref
|
|
8
|
+
* types (e.g., `Ref`) that also carry `[__brand]`.
|
|
9
9
|
*
|
|
10
10
|
* String-literal const (not `unique symbol`) so that independent
|
|
11
11
|
* declaration rollups (root vs subpath) produce structurally compatible
|