@orkestrel/contract 0.0.17 → 0.0.19
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/src/core/index.cjs +44 -1
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +15 -1
- package/dist/src/core/index.d.ts +15 -1
- package/dist/src/core/index.js +44 -1
- package/dist/src/core/index.js.map +1 -1
- package/package.json +10 -10
package/dist/src/core/index.cjs
CHANGED
|
@@ -906,6 +906,20 @@ function isNullableBoolean(value) {
|
|
|
906
906
|
* wraps the check in {@link holds} (see ./helpers.js) so any such throw
|
|
907
907
|
* yields `false` instead of escaping.
|
|
908
908
|
*
|
|
909
|
+
* Narrows `value` to `InstanceType<C>`, which reads the constructor's last
|
|
910
|
+
* construct signature. Accepts the same constructors as `instanceOf`: a public
|
|
911
|
+
* or abstract construct signature returning an object (or `any`). A class with a
|
|
912
|
+
* private or protected constructor and the bare `AnyConstructor` are refused at the call.
|
|
913
|
+
* A value typed `Function` cannot be passed because the `Function` interface has
|
|
914
|
+
* no construct signature. The constructor `Function` can be passed through
|
|
915
|
+
* `FunctionConstructor`'s construct signature and narrows to `Function`.
|
|
916
|
+
* The false branch drops each member of the declared union that is a subtype
|
|
917
|
+
* of the instance type and keeps the rest, so a subclass that adds no member
|
|
918
|
+
* narrows its base out as well (and a subclass that adds only an optional member
|
|
919
|
+
* does not). A constructor whose instance type admits
|
|
920
|
+
* primitives structurally, such as `Object`, makes the false branch unsound;
|
|
921
|
+
* use `isObject` for that check.
|
|
922
|
+
*
|
|
909
923
|
* @param value - The value to test
|
|
910
924
|
* @param ctor - The constructor to test against
|
|
911
925
|
* @returns True if `value instanceof ctor`; false otherwise, including on a
|
|
@@ -9886,7 +9900,36 @@ var SchemaShaper = class SchemaShaper {
|
|
|
9886
9900
|
}
|
|
9887
9901
|
if (variants.length > 0) return INTRINSICS.reflect.apply(unionShape, void 0, variants);
|
|
9888
9902
|
}
|
|
9889
|
-
const
|
|
9903
|
+
const category = schema.type;
|
|
9904
|
+
if (isArray(category)) {
|
|
9905
|
+
const members = [];
|
|
9906
|
+
const seen = collectMembers([]);
|
|
9907
|
+
for (let index = 0; index < category.length; index += 1) {
|
|
9908
|
+
const member = parseEnum(category[index], JSON_SCHEMA_TYPES);
|
|
9909
|
+
if (member === void 0) return rawShape(description === void 0 ? {} : { description });
|
|
9910
|
+
if (matchesMember(seen, member)) continue;
|
|
9911
|
+
admitMember(seen, member);
|
|
9912
|
+
members[members.length] = member;
|
|
9913
|
+
}
|
|
9914
|
+
if (members.length === 0 || members.length > 256) return rawShape(description === void 0 ? {} : { description });
|
|
9915
|
+
const variants = [];
|
|
9916
|
+
for (let index = 0; index < members.length; index += 1) {
|
|
9917
|
+
const member = members[index];
|
|
9918
|
+
if (member === void 0) continue;
|
|
9919
|
+
variants[variants.length] = this.#build({
|
|
9920
|
+
...schema,
|
|
9921
|
+
type: member
|
|
9922
|
+
}, depth);
|
|
9923
|
+
}
|
|
9924
|
+
const first = variants[0];
|
|
9925
|
+
if (variants.length === 1 && first !== void 0) return first;
|
|
9926
|
+
const union = INTRINSICS.reflect.apply(unionShape, void 0, variants);
|
|
9927
|
+
return description === void 0 ? union : INTRINSICS.freeze({
|
|
9928
|
+
...union,
|
|
9929
|
+
description
|
|
9930
|
+
});
|
|
9931
|
+
}
|
|
9932
|
+
const type = isString(category) ? schema.type : void 0;
|
|
9890
9933
|
if (type === "string") return stringShape({
|
|
9891
9934
|
...deriveLengthBounds(schema.minLength, schema.maxLength),
|
|
9892
9935
|
...description === void 0 ? {} : { description }
|