@tangle-network/agent-provider-tangle 1.4.0 → 1.5.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/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/tangle-contract-safety.d.ts +19 -0
- package/dist/tangle-contract-safety.js +25 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export type { TangleExactProcessOptions } from "./tangle-types.js";
|
|
2
|
+
export { JsonBoundError } from "./tangle-contract-safety.js";
|
|
3
|
+
export type { JsonBoundRule, JsonBoundViolation } from "./tangle-contract-safety.js";
|
|
2
4
|
export * from "./tangle-types.js";
|
|
3
5
|
export { createTangleProvider } from "./tangle-provider.js";
|
|
4
6
|
export { DEFAULT_TANGLE_READY_TIMEOUT_MS } from "./tangle-readiness.js";
|
package/dist/index.js
CHANGED
|
@@ -52,6 +52,25 @@ export declare function describeJsonBoundViolation(violation: JsonBoundViolation
|
|
|
52
52
|
* profile, the metadata, or a providerOptions map — which is how three children settled on five
|
|
53
53
|
* words that identified nothing.
|
|
54
54
|
*/
|
|
55
|
+
/**
|
|
56
|
+
* A value refused by a JSON bound, as an error a consumer can classify without reading text.
|
|
57
|
+
*
|
|
58
|
+
* Every refusal in this package was a plain `Error` with a message, and the runtime that
|
|
59
|
+
* supervises these environments classifies a failed retained execution from the error's
|
|
60
|
+
* STRUCTURE — class name, `code`, status — never its message, because this package's messages
|
|
61
|
+
* are not a contract. So a bound refusal reached its journal under the one name reserved for an
|
|
62
|
+
* execution nobody can observe, telling the operator to reconcile before retrying when nothing
|
|
63
|
+
* had run and nothing needed reconciling (agent-runtime#1204, exhibit 6).
|
|
64
|
+
*
|
|
65
|
+
* `name` and `code` are stable; `message` stays the operator-facing line and may change. The
|
|
66
|
+
* violation is carried whole so a reader can act on the rule and the path without parsing.
|
|
67
|
+
*/
|
|
68
|
+
export declare class JsonBoundError extends Error {
|
|
69
|
+
readonly code: "JSON_BOUND_VIOLATION";
|
|
70
|
+
readonly label: string;
|
|
71
|
+
readonly violation: JsonBoundViolation;
|
|
72
|
+
constructor(label: string, violation: JsonBoundViolation, message: string);
|
|
73
|
+
}
|
|
55
74
|
export declare function assertBoundedJson(value: unknown, label?: string): void;
|
|
56
75
|
/** Keep a late-created provider handle reachable when an abort wins the race. */
|
|
57
76
|
export declare function attachCleanupHandle(error: unknown, handle: unknown, cleanupError?: unknown): void;
|
|
@@ -186,6 +186,30 @@ export function describeJsonBoundViolation(violation) {
|
|
|
186
186
|
* profile, the metadata, or a providerOptions map — which is how three children settled on five
|
|
187
187
|
* words that identified nothing.
|
|
188
188
|
*/
|
|
189
|
+
/**
|
|
190
|
+
* A value refused by a JSON bound, as an error a consumer can classify without reading text.
|
|
191
|
+
*
|
|
192
|
+
* Every refusal in this package was a plain `Error` with a message, and the runtime that
|
|
193
|
+
* supervises these environments classifies a failed retained execution from the error's
|
|
194
|
+
* STRUCTURE — class name, `code`, status — never its message, because this package's messages
|
|
195
|
+
* are not a contract. So a bound refusal reached its journal under the one name reserved for an
|
|
196
|
+
* execution nobody can observe, telling the operator to reconcile before retrying when nothing
|
|
197
|
+
* had run and nothing needed reconciling (agent-runtime#1204, exhibit 6).
|
|
198
|
+
*
|
|
199
|
+
* `name` and `code` are stable; `message` stays the operator-facing line and may change. The
|
|
200
|
+
* violation is carried whole so a reader can act on the rule and the path without parsing.
|
|
201
|
+
*/
|
|
202
|
+
export class JsonBoundError extends Error {
|
|
203
|
+
code = "JSON_BOUND_VIOLATION";
|
|
204
|
+
label;
|
|
205
|
+
violation;
|
|
206
|
+
constructor(label, violation, message) {
|
|
207
|
+
super(message);
|
|
208
|
+
this.name = "JsonBoundError";
|
|
209
|
+
this.label = label;
|
|
210
|
+
this.violation = violation;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
189
213
|
export function assertBoundedJson(value, label = "value") {
|
|
190
214
|
const violation = firstJsonBoundViolation(value);
|
|
191
215
|
if (violation === undefined)
|
|
@@ -194,7 +218,7 @@ export function assertBoundedJson(value, label = "value") {
|
|
|
194
218
|
// oversized, and "exceeds" sends the reader after a size problem that does not exist.
|
|
195
219
|
const verdict = violation.limit === undefined ? "violates" : "exceeds";
|
|
196
220
|
const message = `${label} ${verdict} its JSON bound: ${describeJsonBoundViolation(violation)}`;
|
|
197
|
-
throw new
|
|
221
|
+
throw new JsonBoundError(label, violation, message.length > MAX_BOUND_MESSAGE_LENGTH
|
|
198
222
|
? `${message.slice(0, MAX_BOUND_MESSAGE_LENGTH - 3)}...`
|
|
199
223
|
: message);
|
|
200
224
|
}
|