@bcts/envelope-pattern 1.0.0-alpha.22 → 1.0.0-beta.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.cjs +1291 -826
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +101 -59
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +102 -60
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +1643 -1179
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +1315 -853
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -11
- package/src/error.ts +1 -1
- package/src/format.ts +19 -31
- package/src/parse/index.ts +17 -1010
- package/src/parse/leaf/array-parser.ts +36 -0
- package/src/parse/leaf/cbor-parser.ts +43 -0
- package/src/parse/leaf/date-parser.ts +81 -0
- package/src/parse/leaf/known-value-parser.ts +73 -0
- package/src/parse/leaf/null-parser.ts +16 -0
- package/src/parse/leaf/number-parser.ts +90 -0
- package/src/parse/leaf/tag-parser.ts +160 -0
- package/src/parse/meta/and-parser.ts +40 -0
- package/src/parse/meta/capture-parser.ts +50 -0
- package/src/parse/meta/group-parser.ts +77 -0
- package/src/parse/meta/not-parser.ts +30 -0
- package/src/parse/meta/or-parser.ts +36 -0
- package/src/parse/meta/primary-parser.ts +234 -0
- package/src/parse/meta/search-parser.ts +41 -0
- package/src/parse/meta/traverse-parser.ts +42 -0
- package/src/parse/structure/assertion-obj-parser.ts +44 -0
- package/src/parse/structure/assertion-parser.ts +22 -0
- package/src/parse/structure/assertion-pred-parser.ts +45 -0
- package/src/parse/structure/compressed-parser.ts +17 -0
- package/src/parse/structure/digest-parser.ts +132 -0
- package/src/parse/structure/elided-parser.ts +17 -0
- package/src/parse/structure/encrypted-parser.ts +17 -0
- package/src/parse/structure/node-parser.ts +54 -0
- package/src/parse/structure/object-parser.ts +32 -0
- package/src/parse/structure/obscured-parser.ts +17 -0
- package/src/parse/structure/predicate-parser.ts +32 -0
- package/src/parse/structure/subject-parser.ts +32 -0
- package/src/parse/structure/wrapped-parser.ts +36 -0
- package/src/pattern/dcbor-integration.ts +40 -8
- package/src/pattern/index.ts +29 -0
- package/src/pattern/leaf/array-pattern.ts +67 -169
- package/src/pattern/leaf/cbor-pattern.ts +37 -23
- package/src/pattern/leaf/index.ts +1 -1
- package/src/pattern/leaf/map-pattern.ts +21 -2
- package/src/pattern/leaf/tagged-pattern.ts +6 -1
- package/src/pattern/meta/search-pattern.ts +13 -38
- package/src/pattern/meta/traverse-pattern.ts +2 -2
- package/src/pattern/structure/assertions-pattern.ts +19 -53
- package/src/pattern/structure/digest-pattern.ts +18 -22
- package/src/pattern/structure/index.ts +3 -0
- package/src/pattern/structure/node-pattern.ts +10 -29
- package/src/pattern/structure/object-pattern.ts +2 -2
- package/src/pattern/structure/predicate-pattern.ts +2 -2
- package/src/pattern/structure/subject-pattern.ts +31 -4
- package/src/pattern/structure/wrapped-pattern.ts +28 -9
- package/src/pattern/vm.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bcts/envelope-pattern",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Pattern matching for Gordian Envelope structures",
|
|
6
6
|
"license": "BSD-2-Clause-Patent",
|
|
@@ -48,17 +48,19 @@
|
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@bcts/eslint": "^0.1.0",
|
|
50
50
|
"@bcts/tsconfig": "^0.1.0",
|
|
51
|
-
"eslint": "^10.
|
|
52
|
-
"tsdown": "^0.
|
|
53
|
-
"typedoc": "^0.28.
|
|
54
|
-
"typescript": "^
|
|
55
|
-
"vitest": "^4.
|
|
51
|
+
"eslint": "^10.2.1",
|
|
52
|
+
"tsdown": "^0.21.0",
|
|
53
|
+
"typedoc": "^0.28.19",
|
|
54
|
+
"typescript": "^6.0.3",
|
|
55
|
+
"vitest": "^4.1.5"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@bcts/
|
|
59
|
-
"@bcts/dcbor
|
|
60
|
-
"@bcts/dcbor-
|
|
61
|
-
"@bcts/
|
|
62
|
-
"@bcts/
|
|
58
|
+
"@bcts/components": "^1.0.0-beta.0",
|
|
59
|
+
"@bcts/dcbor": "^1.0.0-beta.0",
|
|
60
|
+
"@bcts/dcbor-parse": "^1.0.0-beta.0",
|
|
61
|
+
"@bcts/dcbor-pattern": "^1.0.0-beta.0",
|
|
62
|
+
"@bcts/envelope": "^1.0.0-beta.0",
|
|
63
|
+
"@bcts/known-values": "^1.0.0-beta.0",
|
|
64
|
+
"@bcts/rand": "^1.0.0-beta.0"
|
|
63
65
|
}
|
|
64
66
|
}
|
package/src/error.ts
CHANGED
package/src/format.ts
CHANGED
|
@@ -151,6 +151,14 @@ export function formatPathsOpts(): FormatPathsOptsBuilder {
|
|
|
151
151
|
/**
|
|
152
152
|
* Gets a summary of an envelope for display.
|
|
153
153
|
*
|
|
154
|
+
* Mirrors Rust `envelope_summary` in `format.rs`: defers to
|
|
155
|
+
* `Envelope::format_flat()` for nodes / wrapped / assertions and to
|
|
156
|
+
* `cbor.envelope_summary(usize::MAX, ...)` for raw CBOR leaves. The
|
|
157
|
+
* obscured cases (`elided` / `encrypted` / `compressed`) emit just the
|
|
158
|
+
* keyword. KnownValue envelopes look up the canonical name via
|
|
159
|
+
* `KnownValue.name()`, matching the Rust call to
|
|
160
|
+
* `KnownValuesStore::known_value_for_raw_value(value, …)`.
|
|
161
|
+
*
|
|
154
162
|
* @param env - The envelope to summarize
|
|
155
163
|
* @returns A string summary of the envelope
|
|
156
164
|
*/
|
|
@@ -160,37 +168,18 @@ export function envelopeSummary(env: Envelope): string {
|
|
|
160
168
|
|
|
161
169
|
let summary: string;
|
|
162
170
|
switch (c.type) {
|
|
163
|
-
case "node":
|
|
164
|
-
|
|
165
|
-
const assertions = env.assertions();
|
|
166
|
-
if (assertions.length > 0) {
|
|
167
|
-
const assertionSummaries = assertions.map((a) => {
|
|
168
|
-
const ac = a.case();
|
|
169
|
-
if (ac.type === "assertion") {
|
|
170
|
-
const pred = ac.assertion.predicate().summary(Number.MAX_SAFE_INTEGER);
|
|
171
|
-
const obj = ac.assertion.object().summary(Number.MAX_SAFE_INTEGER);
|
|
172
|
-
return `${pred}: ${obj}`;
|
|
173
|
-
}
|
|
174
|
-
return a.summary(Number.MAX_SAFE_INTEGER);
|
|
175
|
-
});
|
|
176
|
-
summary = `NODE ${subjectSummary} [ ${assertionSummaries.join(", ")} ]`;
|
|
177
|
-
} else {
|
|
178
|
-
summary = `NODE ${subjectSummary}`;
|
|
179
|
-
}
|
|
171
|
+
case "node":
|
|
172
|
+
summary = `NODE ${env.formatFlat()}`;
|
|
180
173
|
break;
|
|
181
|
-
}
|
|
182
174
|
case "leaf":
|
|
183
175
|
summary = `LEAF ${env.summary(Number.MAX_SAFE_INTEGER)}`;
|
|
184
176
|
break;
|
|
185
177
|
case "wrapped":
|
|
186
|
-
summary = `WRAPPED ${env.
|
|
178
|
+
summary = `WRAPPED ${env.formatFlat()}`;
|
|
187
179
|
break;
|
|
188
|
-
case "assertion":
|
|
189
|
-
|
|
190
|
-
const obj = c.assertion.object().summary(Number.MAX_SAFE_INTEGER);
|
|
191
|
-
summary = `ASSERTION ${pred}: ${obj}`;
|
|
180
|
+
case "assertion":
|
|
181
|
+
summary = `ASSERTION ${env.formatFlat()}`;
|
|
192
182
|
break;
|
|
193
|
-
}
|
|
194
183
|
case "elided":
|
|
195
184
|
summary = "ELIDED";
|
|
196
185
|
break;
|
|
@@ -254,10 +243,9 @@ export function formatPathOpt(
|
|
|
254
243
|
return truncateWithEllipsis(summary, opts.elementFormat.maxLength);
|
|
255
244
|
}
|
|
256
245
|
case "EnvelopeUR":
|
|
257
|
-
|
|
258
|
-
return element.digest().toString();
|
|
246
|
+
return element.urString();
|
|
259
247
|
case "DigestUR":
|
|
260
|
-
return element.digest().
|
|
248
|
+
return element.digest().urString();
|
|
261
249
|
}
|
|
262
250
|
}
|
|
263
251
|
|
|
@@ -277,11 +265,11 @@ export function formatPathOpt(
|
|
|
277
265
|
return lines.join("\n");
|
|
278
266
|
}
|
|
279
267
|
case "EnvelopeUR":
|
|
280
|
-
//
|
|
281
|
-
return path.map((element) => element.
|
|
268
|
+
// Single-line, space-separated envelope URs (mirrors Rust).
|
|
269
|
+
return path.map((element) => element.urString()).join(" ");
|
|
282
270
|
case "DigestUR":
|
|
283
|
-
// Single-line, space-separated digest
|
|
284
|
-
return path.map((element) => element.digest().
|
|
271
|
+
// Single-line, space-separated digest URs (mirrors Rust).
|
|
272
|
+
return path.map((element) => element.digest().urString()).join(" ");
|
|
285
273
|
}
|
|
286
274
|
}
|
|
287
275
|
|