@orkestrel/contract 0.0.25 → 0.0.26
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 +64 -18
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +20 -0
- package/dist/src/core/index.d.ts +20 -0
- package/dist/src/core/index.js +64 -19
- package/dist/src/core/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -3400,6 +3400,26 @@ export declare function isAsyncIterable<T = unknown>(value: unknown): value is A
|
|
|
3400
3400
|
*/
|
|
3401
3401
|
export declare function isAuditFault(value: unknown): value is AuditFault;
|
|
3402
3402
|
|
|
3403
|
+
/**
|
|
3404
|
+
* Determines whether a value is a dense list of {@link AuditFault} values.
|
|
3405
|
+
*
|
|
3406
|
+
* @remarks
|
|
3407
|
+
* Reads each index as an own member, in order, and stops at the first hole or the first entry
|
|
3408
|
+
* that `isAuditFault` refuses. An empty list passes.
|
|
3409
|
+
*
|
|
3410
|
+
* @param value - The value to inspect
|
|
3411
|
+
* @returns True if the value is a dense array whose every entry is an audit fault; false otherwise
|
|
3412
|
+
*
|
|
3413
|
+
* @example
|
|
3414
|
+
* ```ts
|
|
3415
|
+
* isAuditFaults([{ reason: 'hidden', path: ['note'] }]) // true
|
|
3416
|
+
* isAuditFaults([]) // true
|
|
3417
|
+
* isAuditFaults([{ reason: 'hidden' }]) // false
|
|
3418
|
+
* isAuditFaults('hidden') // false
|
|
3419
|
+
* ```
|
|
3420
|
+
*/
|
|
3421
|
+
export declare function isAuditFaults(value: unknown): value is readonly AuditFault[];
|
|
3422
|
+
|
|
3403
3423
|
/** Determines whether a value is a bigint.
|
|
3404
3424
|
*
|
|
3405
3425
|
* @param value - The value to inspect
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -3400,6 +3400,26 @@ export declare function isAsyncIterable<T = unknown>(value: unknown): value is A
|
|
|
3400
3400
|
*/
|
|
3401
3401
|
export declare function isAuditFault(value: unknown): value is AuditFault;
|
|
3402
3402
|
|
|
3403
|
+
/**
|
|
3404
|
+
* Determines whether a value is a dense list of {@link AuditFault} values.
|
|
3405
|
+
*
|
|
3406
|
+
* @remarks
|
|
3407
|
+
* Reads each index as an own member, in order, and stops at the first hole or the first entry
|
|
3408
|
+
* that `isAuditFault` refuses. An empty list passes.
|
|
3409
|
+
*
|
|
3410
|
+
* @param value - The value to inspect
|
|
3411
|
+
* @returns True if the value is a dense array whose every entry is an audit fault; false otherwise
|
|
3412
|
+
*
|
|
3413
|
+
* @example
|
|
3414
|
+
* ```ts
|
|
3415
|
+
* isAuditFaults([{ reason: 'hidden', path: ['note'] }]) // true
|
|
3416
|
+
* isAuditFaults([]) // true
|
|
3417
|
+
* isAuditFaults([{ reason: 'hidden' }]) // false
|
|
3418
|
+
* isAuditFaults('hidden') // false
|
|
3419
|
+
* ```
|
|
3420
|
+
*/
|
|
3421
|
+
export declare function isAuditFaults(value: unknown): value is readonly AuditFault[];
|
|
3422
|
+
|
|
3403
3423
|
/** Determines whether a value is a bigint.
|
|
3404
3424
|
*
|
|
3405
3425
|
* @param value - The value to inspect
|
package/dist/src/core/index.js
CHANGED
|
@@ -2109,7 +2109,7 @@ function readValue(callback, reader, options) {
|
|
|
2109
2109
|
...owned.shape === void 0 ? {} : { shape: owned.shape },
|
|
2110
2110
|
...owned.limit === void 0 ? {} : { limit: owned.limit },
|
|
2111
2111
|
...owned.received === void 0 ? {} : { received: owned.received },
|
|
2112
|
-
...owned.faults
|
|
2112
|
+
...isAuditFaults(owned.faults) ? { faults: owned.faults } : {}
|
|
2113
2113
|
};
|
|
2114
2114
|
throw new ContractError(`${diagnostics.value.reader}: ${diagnostics.value.subject} could not be read`, {
|
|
2115
2115
|
code: diagnostics.value.code,
|
|
@@ -5153,6 +5153,27 @@ function isAuditFault(value) {
|
|
|
5153
5153
|
"symbol"
|
|
5154
5154
|
]))));
|
|
5155
5155
|
}
|
|
5156
|
+
/**
|
|
5157
|
+
* Determines whether a value is a dense list of {@link AuditFault} values.
|
|
5158
|
+
*
|
|
5159
|
+
* @remarks
|
|
5160
|
+
* Reads each index as an own member, in order, and stops at the first hole or the first entry
|
|
5161
|
+
* that `isAuditFault` refuses. An empty list passes.
|
|
5162
|
+
*
|
|
5163
|
+
* @param value - The value to inspect
|
|
5164
|
+
* @returns True if the value is a dense array whose every entry is an audit fault; false otherwise
|
|
5165
|
+
*
|
|
5166
|
+
* @example
|
|
5167
|
+
* ```ts
|
|
5168
|
+
* isAuditFaults([{ reason: 'hidden', path: ['note'] }]) // true
|
|
5169
|
+
* isAuditFaults([]) // true
|
|
5170
|
+
* isAuditFaults([{ reason: 'hidden' }]) // false
|
|
5171
|
+
* isAuditFaults('hidden') // false
|
|
5172
|
+
* ```
|
|
5173
|
+
*/
|
|
5174
|
+
function isAuditFaults(value) {
|
|
5175
|
+
return holds(() => INTRINSICS.array(value) && INTRINSICS.reflect.apply(INTRINSICS.find, value, [(entry, index) => !INTRINSICS.own(value, index) || !isAuditFault(entry)]) === -1);
|
|
5176
|
+
}
|
|
5156
5177
|
/** Determines whether a value is a `Map`.
|
|
5157
5178
|
*
|
|
5158
5179
|
* @param value - The value to inspect
|
|
@@ -5896,7 +5917,7 @@ function isContractError(value) {
|
|
|
5896
5917
|
const received = INTRINSICS.own(context, "received") ? INTRINSICS.reflect.read(context, "received") : void 0;
|
|
5897
5918
|
if (received !== void 0 && typeof received !== "string") return false;
|
|
5898
5919
|
const faults = INTRINSICS.own(context, "faults") ? INTRINSICS.reflect.read(context, "faults") : void 0;
|
|
5899
|
-
return faults === void 0 ||
|
|
5920
|
+
return faults === void 0 || isAuditFaults(faults);
|
|
5900
5921
|
} catch {
|
|
5901
5922
|
return false;
|
|
5902
5923
|
}
|
|
@@ -5990,22 +6011,18 @@ var JSONCloner = class JSONCloner {
|
|
|
5990
6011
|
while (this.#pending.length > 0) {
|
|
5991
6012
|
const frame = this.#pending[this.#pending.length - 1];
|
|
5992
6013
|
if (frame === void 0) continue;
|
|
5993
|
-
|
|
5994
|
-
const entry = frame.entries[
|
|
6014
|
+
const index = frame.index;
|
|
6015
|
+
const entry = frame.entries[index];
|
|
5995
6016
|
if (entry === void 0) {
|
|
5996
6017
|
INTRINSICS.freeze(frame.clone);
|
|
5997
6018
|
omitVisited(this.#active, frame.source);
|
|
5998
6019
|
this.#pending.pop();
|
|
5999
6020
|
continue;
|
|
6000
6021
|
}
|
|
6001
|
-
frame.index
|
|
6022
|
+
frame.index = index + 1;
|
|
6002
6023
|
const clone = this.#capture(entry[1], budget);
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
enumerable: true,
|
|
6006
|
-
configurable: true,
|
|
6007
|
-
writable: true
|
|
6008
|
-
});
|
|
6024
|
+
if (frame.array) frame.clone[index] = clone;
|
|
6025
|
+
else frame.clone[entry[0]] = clone;
|
|
6009
6026
|
}
|
|
6010
6027
|
}
|
|
6011
6028
|
#capture(value, budget) {
|
|
@@ -6031,13 +6048,30 @@ var JSONCloner = class JSONCloner {
|
|
|
6031
6048
|
this.#refusePath("object is not a plain record", preview(source));
|
|
6032
6049
|
}
|
|
6033
6050
|
#schedule(source, array) {
|
|
6034
|
-
const clone = array ? [] : INTRINSICS.create(null);
|
|
6035
6051
|
admitVisited(this.#active, source);
|
|
6052
|
+
if (array) {
|
|
6053
|
+
const entries = this.#captureArray(source);
|
|
6054
|
+
const indices = {
|
|
6055
|
+
__proto__: null,
|
|
6056
|
+
length: entries.length
|
|
6057
|
+
};
|
|
6058
|
+
const clone = INTRINSICS.from(indices, () => null);
|
|
6059
|
+
this.#pending[this.#pending.length] = {
|
|
6060
|
+
source,
|
|
6061
|
+
clone,
|
|
6062
|
+
array,
|
|
6063
|
+
entries,
|
|
6064
|
+
index: 0
|
|
6065
|
+
};
|
|
6066
|
+
return clone;
|
|
6067
|
+
}
|
|
6068
|
+
const entries = this.#captureRecord(source);
|
|
6069
|
+
const clone = INTRINSICS.create(null);
|
|
6036
6070
|
this.#pending[this.#pending.length] = {
|
|
6037
6071
|
source,
|
|
6038
6072
|
clone,
|
|
6039
6073
|
array,
|
|
6040
|
-
entries
|
|
6074
|
+
entries,
|
|
6041
6075
|
index: 0
|
|
6042
6076
|
};
|
|
6043
6077
|
return clone;
|
|
@@ -6052,7 +6086,11 @@ var JSONCloner = class JSONCloner {
|
|
|
6052
6086
|
const owned = collectMembers(keysOutcome.value);
|
|
6053
6087
|
if (!matchesMember(owned, "length")) this.#refusePath("array own keys are not exact", preview(source));
|
|
6054
6088
|
if (keysOutcome.value.length !== lengthDescriptor.value + 1) this.#refusePath("array own keys are not exact", preview(source));
|
|
6055
|
-
|
|
6089
|
+
const indices = {
|
|
6090
|
+
__proto__: null,
|
|
6091
|
+
length: lengthDescriptor.value
|
|
6092
|
+
};
|
|
6093
|
+
return INTRINSICS.from(indices, (_entry, index) => {
|
|
6056
6094
|
const key = INTRINSICS.text(index);
|
|
6057
6095
|
if (!matchesMember(owned, key)) this.#refusePath("array own keys are not exact", preview(source));
|
|
6058
6096
|
const descriptorOutcome = attempt(() => INTRINSICS.reflect.describe(source, key));
|
|
@@ -6066,7 +6104,11 @@ var JSONCloner = class JSONCloner {
|
|
|
6066
6104
|
const keysOutcome = attempt(() => INTRINSICS.reflect.members(source));
|
|
6067
6105
|
if (isFailure(keysOutcome)) this.#refusePath("own keys could not be inspected", preview(source));
|
|
6068
6106
|
const names = keysOutcome.value;
|
|
6069
|
-
|
|
6107
|
+
const indices = {
|
|
6108
|
+
__proto__: null,
|
|
6109
|
+
length: names.length
|
|
6110
|
+
};
|
|
6111
|
+
return INTRINSICS.from(indices, (_entry, index) => {
|
|
6070
6112
|
const key = names[index];
|
|
6071
6113
|
if (typeof key !== "string") this.#refusePath(`record has a symbol property ${preview(key)}`, preview(key));
|
|
6072
6114
|
const descriptorOutcome = attempt(() => INTRINSICS.reflect.describe(source, key));
|
|
@@ -6105,10 +6147,13 @@ var JSONCloner = class JSONCloner {
|
|
|
6105
6147
|
}
|
|
6106
6148
|
#trace(key) {
|
|
6107
6149
|
const pending = this.#pending;
|
|
6108
|
-
const
|
|
6109
|
-
|
|
6150
|
+
const indices = {
|
|
6151
|
+
__proto__: null,
|
|
6152
|
+
length: key === void 0 ? pending.length : pending.length + 1
|
|
6153
|
+
};
|
|
6154
|
+
return INTRINSICS.from(indices, (_entry, index) => {
|
|
6110
6155
|
const frame = pending[index];
|
|
6111
|
-
const entry = frame?.entries
|
|
6156
|
+
const entry = frame?.entries[frame.index - 1];
|
|
6112
6157
|
return entry === void 0 ? key ?? "" : entry[0];
|
|
6113
6158
|
});
|
|
6114
6159
|
}
|
|
@@ -14218,6 +14263,6 @@ function schemaToShape(schema, options) {
|
|
|
14218
14263
|
});
|
|
14219
14264
|
}, "schemaToShape");
|
|
14220
14265
|
}
|
|
14221
|
-
export { CHOICE_LIMIT, CLONE_NODE_LIMIT, COMPILE_DEPTH_LIMIT, COMPILE_NODE_LIMIT, CONTRACT_CODES, CONTRACT_ERROR_BRAND, ContractCompiler, ContractError, DATE_LENGTH, FAULT_CONSTRAINTS, FAULT_KINDS, FAULT_LIMIT, FAULT_LIST_LIMIT, FAULT_SCHEMA_LIMIT, FAULT_TEXT_LIMIT, FORMAT_MAX_LENGTH, FORMAT_PATTERNS, GENERATION_ATTEMPT_LIMIT, GUARD_DEPTH_LIMIT, INFER_BREADTH_LIMIT, INFER_DEPTH_LIMIT, INFER_ENUM_LIMIT, INTRINSICS, JSONCloner, JSON_SCHEMA_TYPES, KEY_PLAN_LIMIT, NAME_LIMIT, NODE_LIMIT, PRESENCE_MASK_LIMIT, PREVIEW_LIMIT, SCHEMA_ANNOTATIONS, SHAPE_FIELDS, STRICT_SCHEMA_KEYWORDS, STRING_LIMIT, SchemaCloner, ShapeCloner, ShapeValidator, TEXT_LIMIT, admitMember, admitValue, admitVisited, andOf, appendEntries, arrayOf, arrayShape, attempt, auditFaultShape, booleanShape, boundsOf, buildArrayFaults, buildKeyPlan, buildNumberFaults, buildPathKey, buildPositions, buildSampleMemo, buildStringFaults, canonicalStringify, classifyFormat, cloneJSONRecord, cloneJSONValue, cloneSchema, cloneShape, collectArrayEntries, collectEntries, collectMembers, comparePrimitives, compileAuditor, compileGenerator, compileGuard, compileParser, compileReporter, compileSchema, complementOf, computeMonthLength, computeSurrogatePairs, contain, createContract, dateShape, deriveLengthBounds, deriveRangeBounds, describeFaultLine, describeFaults, drawRandom, encodeLeaf, encodeParts, enumOf, enumerableKeys, enumerableSymbolCount, errorToMessage, escapeControls, escapeRegExp, extractForms, extractPath, extractSchema, failure, filterUncoveredFaults, functionShape, holds, inferPrimitiveEnum, instanceOf, integerShape, interfaceShape, intersectionOf, isArray, isArrayBuffer, isArrayBufferView, isAsyncFunction, isAsyncGeneratorFunction, isAsyncIterable, isAuditFault, isBigInt, isBigInt64Array, isBigUint64Array, isBoolean, isBoundedJSONRecord, isBoundedJSONValue, isCodedError, isConstructor, isContractError, isDataView, isDate, isDefined, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isError, isFailure, isFalse, isFault, isFaultPath, isFiniteNumber, isFloat32Array, isFloat64Array, isFunction, isGeneratorFunction, isInstance, isInt16Array, isInt32Array, isInt8Array, isInteger, isIterable, isJSONPrimitive, isJSONValue, isLiteralValue, isMap, isNonEmptyArray, isNonEmptyMap, isNonEmptyObject, isNonEmptySet, isNonEmptyString, isNonNegativeInteger, isNonNegativeNumber, isNull, isNullableBoolean, isNullableNumber, isNullableString, isNumber, isObject, isPromise, isPromiseLike, isRecord, isRegExp, isSafeInteger, isSet, isSharedArrayBuffer, isString, isSuccess, isSymbol, isTrue, isUint16Array, isUint32Array, isUint8Array, isUint8ClampedArray, isUndefined, isWeakMap, isWeakSet, isZeroArg, isZeroArgAsync, isZeroArgAsyncGenerator, isZeroArgGenerator, iterateIndices, jsonShape, keyOf, lazyOf, limitEntries, literalOf, literalShape, mapOf, matchOf, matchesCalendarDate, matchesEmptyRange, matchesEnumerableKeys, matchesExactKeys, matchesISOInstant, matchesJSONDepth, matchesJSONValue, matchesKeyPlan, matchesLosslessRepair, matchesMember, matchesPattern, matchesRecordBrand, matchesStepGuard, matchesStepKey, matchesStringLength, matchesUndefinedField, matchesUndefinedNode, matchesVisited, notOf, nullShape, nullableOf, nullableShape, numberShape, objectOf, objectShape, omitOf, omitVisited, oneOfShape, optionalOf, optionalShape, orOf, ownPattern, ownShape, parseArray, parseArrayField, parseBoolean, parseBooleanField, parseEnum, parseEnumField, parseEnumValues, parseInteger, parseIntegerField, parseJSON, parseJSONAs, parseJSONValue, parseJSONValueField, parseNull, parseNullField, parseNumber, parseNumberField, parseRecord, parseRecordField, parseString, parseStringField, pathOf, pickOf, pinMembers, preview, previewParts, previewText, rawShape, readArrayEntries, readGuardShape, readIndexView, readMapEntries, readOptions, readPattern, readPatternFlags, readPatternSource, readPresence, readSampleMemo, readSetEntries, readShapeMap, readValue, recordOf, recordShape, refusalToError, refuseExpansion, refuseOptionKeys, refuseValue, renderForm, renderList, renderPath, repairValue, resolveField, retainDepth, samplesToFormat, samplesToSchema, sanitizeBudget, sanitizeDepth, schemaToObject, schemaToParameters, schemaToShape, seededRandom, selectClosestFaults, setOf, settle, shapeShape, shapeToKind, sortValues, stringOf, stringShape, stringToFormat, success, transformOf, truncateFaultText, tupleOf, undefinedShape, unifySchemas, unionOf, unionShape, validateShape, valueToSchema, whereOf };
|
|
14266
|
+
export { CHOICE_LIMIT, CLONE_NODE_LIMIT, COMPILE_DEPTH_LIMIT, COMPILE_NODE_LIMIT, CONTRACT_CODES, CONTRACT_ERROR_BRAND, ContractCompiler, ContractError, DATE_LENGTH, FAULT_CONSTRAINTS, FAULT_KINDS, FAULT_LIMIT, FAULT_LIST_LIMIT, FAULT_SCHEMA_LIMIT, FAULT_TEXT_LIMIT, FORMAT_MAX_LENGTH, FORMAT_PATTERNS, GENERATION_ATTEMPT_LIMIT, GUARD_DEPTH_LIMIT, INFER_BREADTH_LIMIT, INFER_DEPTH_LIMIT, INFER_ENUM_LIMIT, INTRINSICS, JSONCloner, JSON_SCHEMA_TYPES, KEY_PLAN_LIMIT, NAME_LIMIT, NODE_LIMIT, PRESENCE_MASK_LIMIT, PREVIEW_LIMIT, SCHEMA_ANNOTATIONS, SHAPE_FIELDS, STRICT_SCHEMA_KEYWORDS, STRING_LIMIT, SchemaCloner, ShapeCloner, ShapeValidator, TEXT_LIMIT, admitMember, admitValue, admitVisited, andOf, appendEntries, arrayOf, arrayShape, attempt, auditFaultShape, booleanShape, boundsOf, buildArrayFaults, buildKeyPlan, buildNumberFaults, buildPathKey, buildPositions, buildSampleMemo, buildStringFaults, canonicalStringify, classifyFormat, cloneJSONRecord, cloneJSONValue, cloneSchema, cloneShape, collectArrayEntries, collectEntries, collectMembers, comparePrimitives, compileAuditor, compileGenerator, compileGuard, compileParser, compileReporter, compileSchema, complementOf, computeMonthLength, computeSurrogatePairs, contain, createContract, dateShape, deriveLengthBounds, deriveRangeBounds, describeFaultLine, describeFaults, drawRandom, encodeLeaf, encodeParts, enumOf, enumerableKeys, enumerableSymbolCount, errorToMessage, escapeControls, escapeRegExp, extractForms, extractPath, extractSchema, failure, filterUncoveredFaults, functionShape, holds, inferPrimitiveEnum, instanceOf, integerShape, interfaceShape, intersectionOf, isArray, isArrayBuffer, isArrayBufferView, isAsyncFunction, isAsyncGeneratorFunction, isAsyncIterable, isAuditFault, isAuditFaults, isBigInt, isBigInt64Array, isBigUint64Array, isBoolean, isBoundedJSONRecord, isBoundedJSONValue, isCodedError, isConstructor, isContractError, isDataView, isDate, isDefined, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isError, isFailure, isFalse, isFault, isFaultPath, isFiniteNumber, isFloat32Array, isFloat64Array, isFunction, isGeneratorFunction, isInstance, isInt16Array, isInt32Array, isInt8Array, isInteger, isIterable, isJSONPrimitive, isJSONValue, isLiteralValue, isMap, isNonEmptyArray, isNonEmptyMap, isNonEmptyObject, isNonEmptySet, isNonEmptyString, isNonNegativeInteger, isNonNegativeNumber, isNull, isNullableBoolean, isNullableNumber, isNullableString, isNumber, isObject, isPromise, isPromiseLike, isRecord, isRegExp, isSafeInteger, isSet, isSharedArrayBuffer, isString, isSuccess, isSymbol, isTrue, isUint16Array, isUint32Array, isUint8Array, isUint8ClampedArray, isUndefined, isWeakMap, isWeakSet, isZeroArg, isZeroArgAsync, isZeroArgAsyncGenerator, isZeroArgGenerator, iterateIndices, jsonShape, keyOf, lazyOf, limitEntries, literalOf, literalShape, mapOf, matchOf, matchesCalendarDate, matchesEmptyRange, matchesEnumerableKeys, matchesExactKeys, matchesISOInstant, matchesJSONDepth, matchesJSONValue, matchesKeyPlan, matchesLosslessRepair, matchesMember, matchesPattern, matchesRecordBrand, matchesStepGuard, matchesStepKey, matchesStringLength, matchesUndefinedField, matchesUndefinedNode, matchesVisited, notOf, nullShape, nullableOf, nullableShape, numberShape, objectOf, objectShape, omitOf, omitVisited, oneOfShape, optionalOf, optionalShape, orOf, ownPattern, ownShape, parseArray, parseArrayField, parseBoolean, parseBooleanField, parseEnum, parseEnumField, parseEnumValues, parseInteger, parseIntegerField, parseJSON, parseJSONAs, parseJSONValue, parseJSONValueField, parseNull, parseNullField, parseNumber, parseNumberField, parseRecord, parseRecordField, parseString, parseStringField, pathOf, pickOf, pinMembers, preview, previewParts, previewText, rawShape, readArrayEntries, readGuardShape, readIndexView, readMapEntries, readOptions, readPattern, readPatternFlags, readPatternSource, readPresence, readSampleMemo, readSetEntries, readShapeMap, readValue, recordOf, recordShape, refusalToError, refuseExpansion, refuseOptionKeys, refuseValue, renderForm, renderList, renderPath, repairValue, resolveField, retainDepth, samplesToFormat, samplesToSchema, sanitizeBudget, sanitizeDepth, schemaToObject, schemaToParameters, schemaToShape, seededRandom, selectClosestFaults, setOf, settle, shapeShape, shapeToKind, sortValues, stringOf, stringShape, stringToFormat, success, transformOf, truncateFaultText, tupleOf, undefinedShape, unifySchemas, unionOf, unionShape, validateShape, valueToSchema, whereOf };
|
|
14222
14267
|
|
|
14223
14268
|
//# sourceMappingURL=index.js.map
|