@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.
@@ -2860,6 +2860,20 @@ export declare function isGeneratorFunction(value: unknown): value is (...args:
2860
2860
  * wraps the check in {@link holds} (see ./helpers.js) so any such throw
2861
2861
  * yields `false` instead of escaping.
2862
2862
  *
2863
+ * Narrows `value` to `InstanceType<C>`, which reads the constructor's last
2864
+ * construct signature. Accepts the same constructors as `instanceOf`: a public
2865
+ * or abstract construct signature returning an object (or `any`). A class with a
2866
+ * private or protected constructor and the bare `AnyConstructor` are refused at the call.
2867
+ * A value typed `Function` cannot be passed because the `Function` interface has
2868
+ * no construct signature. The constructor `Function` can be passed through
2869
+ * `FunctionConstructor`'s construct signature and narrows to `Function`.
2870
+ * The false branch drops each member of the declared union that is a subtype
2871
+ * of the instance type and keeps the rest, so a subclass that adds no member
2872
+ * narrows its base out as well (and a subclass that adds only an optional member
2873
+ * does not). A constructor whose instance type admits
2874
+ * primitives structurally, such as `Object`, makes the false branch unsound;
2875
+ * use `isObject` for that check.
2876
+ *
2863
2877
  * @param value - The value to test
2864
2878
  * @param ctor - The constructor to test against
2865
2879
  * @returns True if `value instanceof ctor`; false otherwise, including on a
@@ -2871,7 +2885,7 @@ export declare function isGeneratorFunction(value: unknown): value is (...args:
2871
2885
  * isInstance({}, Date) // false
2872
2886
  * ```
2873
2887
  */
2874
- export declare function isInstance<C>(value: unknown, ctor: C): value is InstanceType<C & AnyConstructor<object>>;
2888
+ export declare function isInstance<C extends abstract new (...args: never) => object>(value: unknown, ctor: C): value is InstanceType<C>;
2875
2889
 
2876
2890
  /** Determines whether a value is an `Int16Array`.
2877
2891
  *
@@ -2860,6 +2860,20 @@ export declare function isGeneratorFunction(value: unknown): value is (...args:
2860
2860
  * wraps the check in {@link holds} (see ./helpers.js) so any such throw
2861
2861
  * yields `false` instead of escaping.
2862
2862
  *
2863
+ * Narrows `value` to `InstanceType<C>`, which reads the constructor's last
2864
+ * construct signature. Accepts the same constructors as `instanceOf`: a public
2865
+ * or abstract construct signature returning an object (or `any`). A class with a
2866
+ * private or protected constructor and the bare `AnyConstructor` are refused at the call.
2867
+ * A value typed `Function` cannot be passed because the `Function` interface has
2868
+ * no construct signature. The constructor `Function` can be passed through
2869
+ * `FunctionConstructor`'s construct signature and narrows to `Function`.
2870
+ * The false branch drops each member of the declared union that is a subtype
2871
+ * of the instance type and keeps the rest, so a subclass that adds no member
2872
+ * narrows its base out as well (and a subclass that adds only an optional member
2873
+ * does not). A constructor whose instance type admits
2874
+ * primitives structurally, such as `Object`, makes the false branch unsound;
2875
+ * use `isObject` for that check.
2876
+ *
2863
2877
  * @param value - The value to test
2864
2878
  * @param ctor - The constructor to test against
2865
2879
  * @returns True if `value instanceof ctor`; false otherwise, including on a
@@ -2871,7 +2885,7 @@ export declare function isGeneratorFunction(value: unknown): value is (...args:
2871
2885
  * isInstance({}, Date) // false
2872
2886
  * ```
2873
2887
  */
2874
- export declare function isInstance<C>(value: unknown, ctor: C): value is InstanceType<C & AnyConstructor<object>>;
2888
+ export declare function isInstance<C extends abstract new (...args: never) => object>(value: unknown, ctor: C): value is InstanceType<C>;
2875
2889
 
2876
2890
  /** Determines whether a value is an `Int16Array`.
2877
2891
  *
@@ -905,6 +905,20 @@ function isNullableBoolean(value) {
905
905
  * wraps the check in {@link holds} (see ./helpers.js) so any such throw
906
906
  * yields `false` instead of escaping.
907
907
  *
908
+ * Narrows `value` to `InstanceType<C>`, which reads the constructor's last
909
+ * construct signature. Accepts the same constructors as `instanceOf`: a public
910
+ * or abstract construct signature returning an object (or `any`). A class with a
911
+ * private or protected constructor and the bare `AnyConstructor` are refused at the call.
912
+ * A value typed `Function` cannot be passed because the `Function` interface has
913
+ * no construct signature. The constructor `Function` can be passed through
914
+ * `FunctionConstructor`'s construct signature and narrows to `Function`.
915
+ * The false branch drops each member of the declared union that is a subtype
916
+ * of the instance type and keeps the rest, so a subclass that adds no member
917
+ * narrows its base out as well (and a subclass that adds only an optional member
918
+ * does not). A constructor whose instance type admits
919
+ * primitives structurally, such as `Object`, makes the false branch unsound;
920
+ * use `isObject` for that check.
921
+ *
908
922
  * @param value - The value to test
909
923
  * @param ctor - The constructor to test against
910
924
  * @returns True if `value instanceof ctor`; false otherwise, including on a
@@ -9885,7 +9899,36 @@ var SchemaShaper = class SchemaShaper {
9885
9899
  }
9886
9900
  if (variants.length > 0) return INTRINSICS.reflect.apply(unionShape, void 0, variants);
9887
9901
  }
9888
- const type = isString(schema.type) ? schema.type : void 0;
9902
+ const category = schema.type;
9903
+ if (isArray(category)) {
9904
+ const members = [];
9905
+ const seen = collectMembers([]);
9906
+ for (let index = 0; index < category.length; index += 1) {
9907
+ const member = parseEnum(category[index], JSON_SCHEMA_TYPES);
9908
+ if (member === void 0) return rawShape(description === void 0 ? {} : { description });
9909
+ if (matchesMember(seen, member)) continue;
9910
+ admitMember(seen, member);
9911
+ members[members.length] = member;
9912
+ }
9913
+ if (members.length === 0 || members.length > 256) return rawShape(description === void 0 ? {} : { description });
9914
+ const variants = [];
9915
+ for (let index = 0; index < members.length; index += 1) {
9916
+ const member = members[index];
9917
+ if (member === void 0) continue;
9918
+ variants[variants.length] = this.#build({
9919
+ ...schema,
9920
+ type: member
9921
+ }, depth);
9922
+ }
9923
+ const first = variants[0];
9924
+ if (variants.length === 1 && first !== void 0) return first;
9925
+ const union = INTRINSICS.reflect.apply(unionShape, void 0, variants);
9926
+ return description === void 0 ? union : INTRINSICS.freeze({
9927
+ ...union,
9928
+ description
9929
+ });
9930
+ }
9931
+ const type = isString(category) ? schema.type : void 0;
9889
9932
  if (type === "string") return stringShape({
9890
9933
  ...deriveLengthBounds(schema.minLength, schema.maxLength),
9891
9934
  ...description === void 0 ? {} : { description }