@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
package/dist/src/core/index.cjs
CHANGED
|
@@ -2110,7 +2110,7 @@ function readValue(callback, reader, options) {
|
|
|
2110
2110
|
...owned.shape === void 0 ? {} : { shape: owned.shape },
|
|
2111
2111
|
...owned.limit === void 0 ? {} : { limit: owned.limit },
|
|
2112
2112
|
...owned.received === void 0 ? {} : { received: owned.received },
|
|
2113
|
-
...owned.faults
|
|
2113
|
+
...isAuditFaults(owned.faults) ? { faults: owned.faults } : {}
|
|
2114
2114
|
};
|
|
2115
2115
|
throw new ContractError(`${diagnostics.value.reader}: ${diagnostics.value.subject} could not be read`, {
|
|
2116
2116
|
code: diagnostics.value.code,
|
|
@@ -5154,6 +5154,27 @@ function isAuditFault(value) {
|
|
|
5154
5154
|
"symbol"
|
|
5155
5155
|
]))));
|
|
5156
5156
|
}
|
|
5157
|
+
/**
|
|
5158
|
+
* Determines whether a value is a dense list of {@link AuditFault} values.
|
|
5159
|
+
*
|
|
5160
|
+
* @remarks
|
|
5161
|
+
* Reads each index as an own member, in order, and stops at the first hole or the first entry
|
|
5162
|
+
* that `isAuditFault` refuses. An empty list passes.
|
|
5163
|
+
*
|
|
5164
|
+
* @param value - The value to inspect
|
|
5165
|
+
* @returns True if the value is a dense array whose every entry is an audit fault; false otherwise
|
|
5166
|
+
*
|
|
5167
|
+
* @example
|
|
5168
|
+
* ```ts
|
|
5169
|
+
* isAuditFaults([{ reason: 'hidden', path: ['note'] }]) // true
|
|
5170
|
+
* isAuditFaults([]) // true
|
|
5171
|
+
* isAuditFaults([{ reason: 'hidden' }]) // false
|
|
5172
|
+
* isAuditFaults('hidden') // false
|
|
5173
|
+
* ```
|
|
5174
|
+
*/
|
|
5175
|
+
function isAuditFaults(value) {
|
|
5176
|
+
return holds(() => INTRINSICS.array(value) && INTRINSICS.reflect.apply(INTRINSICS.find, value, [(entry, index) => !INTRINSICS.own(value, index) || !isAuditFault(entry)]) === -1);
|
|
5177
|
+
}
|
|
5157
5178
|
/** Determines whether a value is a `Map`.
|
|
5158
5179
|
*
|
|
5159
5180
|
* @param value - The value to inspect
|
|
@@ -5897,7 +5918,7 @@ function isContractError(value) {
|
|
|
5897
5918
|
const received = INTRINSICS.own(context, "received") ? INTRINSICS.reflect.read(context, "received") : void 0;
|
|
5898
5919
|
if (received !== void 0 && typeof received !== "string") return false;
|
|
5899
5920
|
const faults = INTRINSICS.own(context, "faults") ? INTRINSICS.reflect.read(context, "faults") : void 0;
|
|
5900
|
-
return faults === void 0 ||
|
|
5921
|
+
return faults === void 0 || isAuditFaults(faults);
|
|
5901
5922
|
} catch {
|
|
5902
5923
|
return false;
|
|
5903
5924
|
}
|
|
@@ -5991,22 +6012,18 @@ var JSONCloner = class JSONCloner {
|
|
|
5991
6012
|
while (this.#pending.length > 0) {
|
|
5992
6013
|
const frame = this.#pending[this.#pending.length - 1];
|
|
5993
6014
|
if (frame === void 0) continue;
|
|
5994
|
-
|
|
5995
|
-
const entry = frame.entries[
|
|
6015
|
+
const index = frame.index;
|
|
6016
|
+
const entry = frame.entries[index];
|
|
5996
6017
|
if (entry === void 0) {
|
|
5997
6018
|
INTRINSICS.freeze(frame.clone);
|
|
5998
6019
|
omitVisited(this.#active, frame.source);
|
|
5999
6020
|
this.#pending.pop();
|
|
6000
6021
|
continue;
|
|
6001
6022
|
}
|
|
6002
|
-
frame.index
|
|
6023
|
+
frame.index = index + 1;
|
|
6003
6024
|
const clone = this.#capture(entry[1], budget);
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
enumerable: true,
|
|
6007
|
-
configurable: true,
|
|
6008
|
-
writable: true
|
|
6009
|
-
});
|
|
6025
|
+
if (frame.array) frame.clone[index] = clone;
|
|
6026
|
+
else frame.clone[entry[0]] = clone;
|
|
6010
6027
|
}
|
|
6011
6028
|
}
|
|
6012
6029
|
#capture(value, budget) {
|
|
@@ -6032,13 +6049,30 @@ var JSONCloner = class JSONCloner {
|
|
|
6032
6049
|
this.#refusePath("object is not a plain record", preview(source));
|
|
6033
6050
|
}
|
|
6034
6051
|
#schedule(source, array) {
|
|
6035
|
-
const clone = array ? [] : INTRINSICS.create(null);
|
|
6036
6052
|
admitVisited(this.#active, source);
|
|
6053
|
+
if (array) {
|
|
6054
|
+
const entries = this.#captureArray(source);
|
|
6055
|
+
const indices = {
|
|
6056
|
+
__proto__: null,
|
|
6057
|
+
length: entries.length
|
|
6058
|
+
};
|
|
6059
|
+
const clone = INTRINSICS.from(indices, () => null);
|
|
6060
|
+
this.#pending[this.#pending.length] = {
|
|
6061
|
+
source,
|
|
6062
|
+
clone,
|
|
6063
|
+
array,
|
|
6064
|
+
entries,
|
|
6065
|
+
index: 0
|
|
6066
|
+
};
|
|
6067
|
+
return clone;
|
|
6068
|
+
}
|
|
6069
|
+
const entries = this.#captureRecord(source);
|
|
6070
|
+
const clone = INTRINSICS.create(null);
|
|
6037
6071
|
this.#pending[this.#pending.length] = {
|
|
6038
6072
|
source,
|
|
6039
6073
|
clone,
|
|
6040
6074
|
array,
|
|
6041
|
-
entries
|
|
6075
|
+
entries,
|
|
6042
6076
|
index: 0
|
|
6043
6077
|
};
|
|
6044
6078
|
return clone;
|
|
@@ -6053,7 +6087,11 @@ var JSONCloner = class JSONCloner {
|
|
|
6053
6087
|
const owned = collectMembers(keysOutcome.value);
|
|
6054
6088
|
if (!matchesMember(owned, "length")) this.#refusePath("array own keys are not exact", preview(source));
|
|
6055
6089
|
if (keysOutcome.value.length !== lengthDescriptor.value + 1) this.#refusePath("array own keys are not exact", preview(source));
|
|
6056
|
-
|
|
6090
|
+
const indices = {
|
|
6091
|
+
__proto__: null,
|
|
6092
|
+
length: lengthDescriptor.value
|
|
6093
|
+
};
|
|
6094
|
+
return INTRINSICS.from(indices, (_entry, index) => {
|
|
6057
6095
|
const key = INTRINSICS.text(index);
|
|
6058
6096
|
if (!matchesMember(owned, key)) this.#refusePath("array own keys are not exact", preview(source));
|
|
6059
6097
|
const descriptorOutcome = attempt(() => INTRINSICS.reflect.describe(source, key));
|
|
@@ -6067,7 +6105,11 @@ var JSONCloner = class JSONCloner {
|
|
|
6067
6105
|
const keysOutcome = attempt(() => INTRINSICS.reflect.members(source));
|
|
6068
6106
|
if (isFailure(keysOutcome)) this.#refusePath("own keys could not be inspected", preview(source));
|
|
6069
6107
|
const names = keysOutcome.value;
|
|
6070
|
-
|
|
6108
|
+
const indices = {
|
|
6109
|
+
__proto__: null,
|
|
6110
|
+
length: names.length
|
|
6111
|
+
};
|
|
6112
|
+
return INTRINSICS.from(indices, (_entry, index) => {
|
|
6071
6113
|
const key = names[index];
|
|
6072
6114
|
if (typeof key !== "string") this.#refusePath(`record has a symbol property ${preview(key)}`, preview(key));
|
|
6073
6115
|
const descriptorOutcome = attempt(() => INTRINSICS.reflect.describe(source, key));
|
|
@@ -6106,10 +6148,13 @@ var JSONCloner = class JSONCloner {
|
|
|
6106
6148
|
}
|
|
6107
6149
|
#trace(key) {
|
|
6108
6150
|
const pending = this.#pending;
|
|
6109
|
-
const
|
|
6110
|
-
|
|
6151
|
+
const indices = {
|
|
6152
|
+
__proto__: null,
|
|
6153
|
+
length: key === void 0 ? pending.length : pending.length + 1
|
|
6154
|
+
};
|
|
6155
|
+
return INTRINSICS.from(indices, (_entry, index) => {
|
|
6111
6156
|
const frame = pending[index];
|
|
6112
|
-
const entry = frame?.entries
|
|
6157
|
+
const entry = frame?.entries[frame.index - 1];
|
|
6113
6158
|
return entry === void 0 ? key ?? "" : entry[0];
|
|
6114
6159
|
});
|
|
6115
6160
|
}
|
|
@@ -14329,6 +14374,7 @@ exports.isAsyncFunction = isAsyncFunction;
|
|
|
14329
14374
|
exports.isAsyncGeneratorFunction = isAsyncGeneratorFunction;
|
|
14330
14375
|
exports.isAsyncIterable = isAsyncIterable;
|
|
14331
14376
|
exports.isAuditFault = isAuditFault;
|
|
14377
|
+
exports.isAuditFaults = isAuditFaults;
|
|
14332
14378
|
exports.isBigInt = isBigInt;
|
|
14333
14379
|
exports.isBigInt64Array = isBigInt64Array;
|
|
14334
14380
|
exports.isBigUint64Array = isBigUint64Array;
|