@autotelic/protocol 0.0.0-stage → 0.1.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.
Files changed (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +183 -2
  3. package/dist/baseline.d.ts +41 -0
  4. package/dist/baseline.d.ts.map +1 -0
  5. package/dist/baseline.js +62 -0
  6. package/dist/baseline.js.map +1 -0
  7. package/dist/catalog.d.ts +275 -0
  8. package/dist/catalog.d.ts.map +1 -0
  9. package/dist/catalog.js +437 -0
  10. package/dist/catalog.js.map +1 -0
  11. package/dist/compat.d.ts +12 -0
  12. package/dist/compat.d.ts.map +1 -0
  13. package/dist/compat.js +104 -0
  14. package/dist/compat.js.map +1 -0
  15. package/dist/config.d.ts +179 -0
  16. package/dist/config.d.ts.map +1 -0
  17. package/dist/config.js +302 -0
  18. package/dist/config.js.map +1 -0
  19. package/dist/decode.d.ts +32 -0
  20. package/dist/decode.d.ts.map +1 -0
  21. package/dist/decode.js +71 -0
  22. package/dist/decode.js.map +1 -0
  23. package/dist/doc.d.ts +105 -0
  24. package/dist/doc.d.ts.map +1 -0
  25. package/dist/doc.js +159 -0
  26. package/dist/doc.js.map +1 -0
  27. package/dist/graph.d.ts +139 -0
  28. package/dist/graph.d.ts.map +1 -0
  29. package/dist/graph.js +258 -0
  30. package/dist/graph.js.map +1 -0
  31. package/dist/index.d.ts +22 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +22 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/intent.d.ts +32 -0
  36. package/dist/intent.d.ts.map +1 -0
  37. package/dist/intent.js +54 -0
  38. package/dist/intent.js.map +1 -0
  39. package/dist/json.d.ts +3 -0
  40. package/dist/json.d.ts.map +1 -0
  41. package/dist/json.js +18 -0
  42. package/dist/json.js.map +1 -0
  43. package/dist/lexicon.d.ts +58 -0
  44. package/dist/lexicon.d.ts.map +1 -0
  45. package/dist/lexicon.js +176 -0
  46. package/dist/lexicon.js.map +1 -0
  47. package/dist/patterns.d.ts +65 -0
  48. package/dist/patterns.d.ts.map +1 -0
  49. package/dist/patterns.js +166 -0
  50. package/dist/patterns.js.map +1 -0
  51. package/dist/recipes.d.ts +34 -0
  52. package/dist/recipes.d.ts.map +1 -0
  53. package/dist/recipes.js +74 -0
  54. package/dist/recipes.js.map +1 -0
  55. package/dist/report.d.ts +218 -0
  56. package/dist/report.d.ts.map +1 -0
  57. package/dist/report.js +330 -0
  58. package/dist/report.js.map +1 -0
  59. package/dist/version.d.ts +9 -0
  60. package/dist/version.d.ts.map +1 -0
  61. package/dist/version.js +9 -0
  62. package/dist/version.js.map +1 -0
  63. package/package.json +45 -3
  64. package/schema/baseline.json +29 -0
  65. package/schema/catalog.json +206 -0
  66. package/schema/cutlist.config.json +103 -0
  67. package/schema/intent.json +43 -0
  68. package/schema/jig.config.json +56 -0
  69. package/schema/manifest.json +67 -0
  70. package/schema/menu.json +169 -0
  71. package/schema/onboarding.json +25 -0
  72. package/schema/patterns.json +141 -0
  73. package/schema/recipes.json +57 -0
  74. package/schema/report.json +141 -0
package/dist/graph.js ADDED
@@ -0,0 +1,258 @@
1
+ import { comparableSignatureOf, similarityOf, } from "./catalog.js";
2
+ /** Whether this catalog carries render edges at all — a catalog written before they landed does not. */
3
+ export const hasRenderEdges = (catalog) => catalog.components.some((component) => component.renders !== undefined);
4
+ const refOf = (component) => ({
5
+ path: component.path,
6
+ name: component.name,
7
+ });
8
+ const SOURCE_EXTENSION = /\.(?:tsx?|jsx?)$/u;
9
+ const normalize = (value) => value.trim().toLowerCase();
10
+ /**
11
+ * Every part the query could mean, most specific tier first.
12
+ *
13
+ * Tiers rather than one fuzzy score: an id or a path is an address, a name is a guess, and
14
+ * a suffix is a guess with an address's tail. Keeping them apart is what lets a caller say
15
+ * "three parts are called Button" instead of picking one silently.
16
+ */
17
+ export const findParts = (catalog, query) => {
18
+ const needle = normalize(query);
19
+ if (needle === "")
20
+ return [];
21
+ const withoutExtension = needle.replace(SOURCE_EXTENSION, "");
22
+ const matches = [
23
+ (component) => component.id !== undefined &&
24
+ (normalize(component.id) === needle || normalize(component.id) === withoutExtension),
25
+ (component) => normalize(component.path) === needle || normalize(component.path) === withoutExtension,
26
+ (component) => normalize(component.name) === needle,
27
+ (component) => {
28
+ const path = normalize(component.path).replace(SOURCE_EXTENSION, "");
29
+ return path.endsWith(`/${withoutExtension}`);
30
+ },
31
+ ];
32
+ for (const test of matches) {
33
+ const found = catalog.components
34
+ .filter(test)
35
+ .sort((left, right) => left.path.localeCompare(right.path));
36
+ if (found.length > 0)
37
+ return found;
38
+ }
39
+ return [];
40
+ };
41
+ const componentAt = (catalog, path) => catalog.components.find((component) => component.path === path);
42
+ /**
43
+ * `page -> parts`, as a person asks it: "what does this screen render today?"
44
+ *
45
+ * Direct children are what the route's own JSX names. The transitive list is the rest of
46
+ * what appears on screen — a mock author who stops at the direct list re-invents `Table`
47
+ * because `SetupTable` renders it one level down. Breadth-first, edge order preserved, so
48
+ * the answer is the reading order of the file rather than a hash's.
49
+ */
50
+ export const partsOfPage = ({ catalog, page, }) => {
51
+ const subject = componentAt(catalog, page);
52
+ if (subject === undefined)
53
+ return undefined;
54
+ const nameOf = new Map(catalog.components.map((component) => [component.path, component.name]));
55
+ const reached = (edge, via) => ({
56
+ path: edge.part,
57
+ name: nameOf.get(edge.part) ?? edge.part,
58
+ tag: edge.tag,
59
+ line: edge.line,
60
+ ...(via === undefined ? {} : { via }),
61
+ });
62
+ const direct = (subject.renders ?? []).map((edge) => reached(edge));
63
+ const seen = new Set([subject.path, ...direct.map((edge) => edge.path)]);
64
+ const transitive = [];
65
+ // A queue of (path, via) pairs: the `via` a part is reached through is the direct child
66
+ // whose subtree contains it, which is the thing a person navigates by.
67
+ const queue = direct.map((edge) => ({
68
+ path: edge.path,
69
+ via: edge.path,
70
+ }));
71
+ while (queue.length > 0) {
72
+ const current = queue.shift();
73
+ if (current === undefined)
74
+ break;
75
+ const component = componentAt(catalog, current.path);
76
+ for (const edge of component?.renders ?? []) {
77
+ if (seen.has(edge.part))
78
+ continue;
79
+ seen.add(edge.part);
80
+ transitive.push(reached(edge, current.via));
81
+ queue.push({ path: edge.part, via: current.via });
82
+ }
83
+ }
84
+ return { page: refOf(subject), direct, transitive, edges: hasRenderEdges(catalog) };
85
+ };
86
+ /**
87
+ * `part -> pages`, as a mock reviewer asks it: "where does this appear on screen?"
88
+ *
89
+ * The import graph answers with modules; a reviewer wants routes. Walking the render edges
90
+ * upward stops at the route rather than continuing into whatever imports it, because a
91
+ * route is where the question ends — it is the thing a person can open.
92
+ */
93
+ export const pagesOfPart = ({ catalog, part, }) => {
94
+ const subject = componentAt(catalog, part);
95
+ if (subject === undefined)
96
+ return undefined;
97
+ const parents = new Map();
98
+ for (const component of catalog.components) {
99
+ for (const edge of component.renders ?? []) {
100
+ const set = parents.get(edge.part) ?? new Set();
101
+ set.add(component.path);
102
+ parents.set(edge.part, set);
103
+ }
104
+ }
105
+ const nameOf = new Map(catalog.components.map((component) => [component.path, component.name]));
106
+ const direct = [...(parents.get(part) ?? [])]
107
+ .sort((left, right) => left.localeCompare(right))
108
+ .map((path) => ({ path, name: nameOf.get(path) ?? path }));
109
+ const routes = [];
110
+ const visited = new Set([part]);
111
+ const queue = direct.map((parent) => ({ path: parent.path, via: [] }));
112
+ while (queue.length > 0) {
113
+ const current = queue.shift();
114
+ if (current === undefined)
115
+ break;
116
+ if (visited.has(current.path))
117
+ continue;
118
+ visited.add(current.path);
119
+ const component = componentAt(catalog, current.path);
120
+ if (component === undefined)
121
+ continue;
122
+ if (component.kind === "route") {
123
+ routes.push({
124
+ path: component.path,
125
+ name: component.name,
126
+ // The chain is recorded child-to-parent while walking up; a reader reads it down.
127
+ via: [...current.via].reverse(),
128
+ });
129
+ continue;
130
+ }
131
+ for (const parent of parents.get(current.path) ?? []) {
132
+ queue.push({ path: parent, via: [...current.via, component.path] });
133
+ }
134
+ }
135
+ routes.sort((left, right) => left.path.localeCompare(right.path));
136
+ return { part: refOf(subject), direct, routes, edges: hasRenderEdges(catalog) };
137
+ };
138
+ /**
139
+ * The words in a part's name, lowercased and singular.
140
+ *
141
+ * `TablePanel` → `table`, `panel`; `PerTreeRatesSection` → `per`, `tree`, `rate`, `section`.
142
+ * Splitting is mechanical (case boundaries and separators) and the "s" strip is the one
143
+ * piece of English this does: `Rates` and `Rate` are the same word, and a mock author
144
+ * spelling one of them plural is not evidence of a different concept.
145
+ *
146
+ * No synonym table. `Modal` is not `Dialog` by any rule this can defend; a tool that
147
+ * guessed would be confidently wrong exactly where the author is least able to check.
148
+ */
149
+ const nameTokens = (name) => {
150
+ const spaced = name
151
+ .replace(/([a-z0-9])([A-Z])/gu, "$1 $2")
152
+ .replace(/([A-Z]+)([A-Z][a-z])/gu, "$1 $2")
153
+ .toLowerCase();
154
+ const tokens = new Set();
155
+ for (const token of spaced.split(/[^a-z0-9]+/u)) {
156
+ if (token.length < 2)
157
+ continue;
158
+ tokens.add(token.length > 3 && token.endsWith("s") ? token.slice(0, -1) : token);
159
+ }
160
+ return tokens;
161
+ };
162
+ /**
163
+ * How much two names share, 0–1.
164
+ *
165
+ * The denominator is the smaller name, not the union: `TablePanel` after `Table` is not a
166
+ * worse match because it added a word, and a union would punish exactly that. A token
167
+ * counts when the other side has it or a word containing it (`map` in `mapbox`), because
168
+ * a compound spelling is how this vocabulary grows.
169
+ */
170
+ export const nameSimilarity = ({ left, right, }) => {
171
+ if (normalize(left) === normalize(right))
172
+ return 1;
173
+ const a = nameTokens(left);
174
+ const b = nameTokens(right);
175
+ if (a.size === 0 || b.size === 0)
176
+ return 0;
177
+ const [small, large] = a.size <= b.size ? [a, b] : [b, a];
178
+ let shared = 0;
179
+ for (const token of small) {
180
+ // A four-letter prefix is a compound spelling (`field` in `fieldwork`), not a
181
+ // coincidence. Below that, `tab` sits inside `table` and the rule starts inventing
182
+ // evidence, so the shorter side must be exact.
183
+ if ([...large].some((other) => other === token || (token.length >= 4 && other.startsWith(token)))) {
184
+ shared += 1;
185
+ }
186
+ }
187
+ return shared / large.size;
188
+ };
189
+ /**
190
+ * Rank the catalog against a signature.
191
+ *
192
+ * The structural metric is the duplicate join's, not a second one: if `similar` used props,
193
+ * or the raw skeleton with React's own hooks, it would answer differently from the duplicate
194
+ * report a reviewer already trusts. `shared` is returned because "why" is what a person acts
195
+ * on; a score alone is not reviewable.
196
+ */
197
+ export const similarToSignature = ({ catalog, signature, name, exclude, kinds, limit = 10, threshold = 0.2, }) => {
198
+ const subject = comparableSignatureOf(signature);
199
+ if (subject.size === 0 && name === undefined)
200
+ return [];
201
+ const field = new Set(kinds ?? ["component", "provider"]);
202
+ const scored = [];
203
+ for (const component of catalog.components) {
204
+ if (component.path === exclude)
205
+ continue;
206
+ if (!field.has(component.kind ?? "component"))
207
+ continue;
208
+ const candidate = comparableSignatureOf(component.signature);
209
+ const skeletonScore = subject.size === 0 || candidate.size === 0
210
+ ? 0
211
+ : similarityOf({ left: subject, right: candidate });
212
+ const nameScore = name === undefined ? 0 : nameSimilarity({ left: name, right: component.name });
213
+ const score = Math.max(skeletonScore, nameScore);
214
+ if (score < threshold)
215
+ continue;
216
+ const basis = nameScore >= threshold && skeletonScore >= threshold
217
+ ? "name+skeleton"
218
+ : skeletonScore >= nameScore && skeletonScore >= threshold
219
+ ? "skeleton"
220
+ : "name";
221
+ scored.push({
222
+ path: component.path,
223
+ name: component.name,
224
+ score,
225
+ basis,
226
+ nameScore,
227
+ skeletonScore,
228
+ shared: [...subject]
229
+ .filter((token) => candidate.has(token))
230
+ .sort((left, right) => left.localeCompare(right)),
231
+ unshared: [...subject]
232
+ .filter((token) => !candidate.has(token))
233
+ .sort((left, right) => left.localeCompare(right)),
234
+ });
235
+ }
236
+ return scored
237
+ .sort((left, right) => right.score - left.score ||
238
+ (componentAt(catalog, right.path)?.usedBy ?? 0) -
239
+ (componentAt(catalog, left.path)?.usedBy ?? 0) ||
240
+ left.path.localeCompare(right.path))
241
+ .slice(0, limit);
242
+ };
243
+ /** `similar <part>`, the catalog-only case: the subject is a part the crawler already saw. */
244
+ export const similarParts = ({ catalog, part, limit, threshold, }) => {
245
+ const subject = componentAt(catalog, part);
246
+ if (subject === undefined)
247
+ return [];
248
+ return similarToSignature({
249
+ catalog,
250
+ signature: subject.signature,
251
+ name: subject.name,
252
+ exclude: subject.path,
253
+ kinds: [subject.kind ?? "component"],
254
+ ...(limit === undefined ? {} : { limit }),
255
+ ...(threshold === undefined ? {} : { threshold }),
256
+ });
257
+ };
258
+ //# sourceMappingURL=graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.js","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,YAAY,GAKb,MAAM,cAAc,CAAA;AAqCrB,wGAAwG;AACxG,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAW,EAAE,CAC1D,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,KAAK,SAAS,CAAC,CAAA;AAuDzE,MAAM,KAAK,GAAG,CAAC,SAA2B,EAAW,EAAE,CAAC,CAAC;IACvD,IAAI,EAAE,SAAS,CAAC,IAAI;IACpB,IAAI,EAAE,SAAS,CAAC,IAAI;CACrB,CAAC,CAAA;AAEF,MAAM,gBAAgB,GAAG,mBAAmB,CAAA;AAE5C,MAAM,SAAS,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;AAEvE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAE,KAAa,EAAmC,EAAE;IAC5F,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;IAC/B,IAAI,MAAM,KAAK,EAAE;QAAE,OAAO,EAAE,CAAA;IAC5B,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,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AE,SAAS,EAAE,CAAC;KAClD,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * `@autotelic/protocol` — the lexicons the conformance tools agree on, as pure types, JSON
3
+ * Schema, and pure helpers.
4
+ *
5
+ * This package is deliberately not a tool: it has no dependencies and no runtime beyond
6
+ * pure functions. The engines agree on bytes; they never import each other. A record's
7
+ * lexicon — not this module — is the contract, and `lexicon.ts` is the registry of them.
8
+ */
9
+ export * from "./lexicon.ts";
10
+ export * from "./decode.ts";
11
+ export * from "./json.ts";
12
+ export * from "./report.ts";
13
+ export * from "./baseline.ts";
14
+ export * from "./config.ts";
15
+ export * from "./intent.ts";
16
+ export * from "./patterns.ts";
17
+ export * from "./recipes.ts";
18
+ export * from "./catalog.ts";
19
+ export * from "./graph.ts";
20
+ export * from "./doc.ts";
21
+ export * from "./compat.ts";
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * `@autotelic/protocol` — the lexicons the conformance tools agree on, as pure types, JSON
3
+ * Schema, and pure helpers.
4
+ *
5
+ * This package is deliberately not a tool: it has no dependencies and no runtime beyond
6
+ * pure functions. The engines agree on bytes; they never import each other. A record's
7
+ * lexicon — not this module — is the contract, and `lexicon.ts` is the registry of them.
8
+ */
9
+ export * from "./lexicon.js";
10
+ export * from "./decode.js";
11
+ export * from "./json.js";
12
+ export * from "./report.js";
13
+ export * from "./baseline.js";
14
+ export * from "./config.js";
15
+ export * from "./intent.js";
16
+ export * from "./patterns.js";
17
+ export * from "./recipes.js";
18
+ export * from "./catalog.js";
19
+ export * from "./graph.js";
20
+ export * from "./doc.js";
21
+ export * from "./compat.js";
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA"}
@@ -0,0 +1,32 @@
1
+ /** Where a part is in its life. Absent means the repo has not said. */
2
+ export type PartStatus = "stable" | "beta" | "experimental" | "deprecated";
3
+ export declare const PART_STATUSES: ReadonlyArray<PartStatus>;
4
+ /** The authored half of a menu entry, as stored in `intent/<key>.json`. */
5
+ export interface Intent {
6
+ /** One line on what this part is for. */
7
+ readonly summary?: string;
8
+ /** The situation the part is the right answer for. */
9
+ readonly whenToUse?: string;
10
+ /** The situation it is the wrong answer for, and what to do instead. */
11
+ readonly whenNotToUse?: string;
12
+ /** Named states the part handles: loading, empty, error, disabled. */
13
+ readonly states?: ReadonlyArray<string>;
14
+ /** The lifecycle a consumer can rely on. */
15
+ readonly status?: PartStatus;
16
+ /** Real call sites or canonical snippets that show the approved use. */
17
+ readonly examples?: ReadonlyArray<string>;
18
+ /** What to reach for instead, when a near-duplicate or a retirement exists. */
19
+ readonly useInstead?: ReadonlyArray<string>;
20
+ }
21
+ /**
22
+ * Read one intent record, or `undefined` when it says nothing usable.
23
+ *
24
+ * Every field is optional, and a malformed optional field degrades to absent rather
25
+ * than taking the whole record with it. The one thing that is not tolerated is a record
26
+ * that answers nothing: treating that as intent would hide it from the `_(undocumented)_`
27
+ * flag, which is the only place the absence is visible.
28
+ */
29
+ export declare const decodeIntent: (value: unknown) => Intent | undefined;
30
+ /** Whether an intent record carries anything a reader can act on. */
31
+ export declare const hasIntent: (intent: Intent | undefined) => boolean;
32
+ //# sourceMappingURL=intent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intent.d.ts","sourceRoot":"","sources":["../src/intent.ts"],"names":[],"mappings":"AAeA,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,MAAM,GAAG,cAAc,GAAG,YAAY,CAAA;AAE1E,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,UAAU,CAKnD,CAAA;AAED,2EAA2E;AAC3E,MAAM,WAAW,MAAM;IACrB,yCAAyC;IACzC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,sDAAsD;IACtD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,wEAAwE;IACxE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,sEAAsE;IACtE,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACvC,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAA;IAC5B,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACzC,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAC5C;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,UAAW,OAAO,KAAG,MAAM,GAAG,SA6BtD,CAAA;AAED,qEAAqE;AACrE,eAAO,MAAM,SAAS,WAAY,MAAM,GAAG,SAAS,YAQX,CAAA"}
package/dist/intent.js ADDED
@@ -0,0 +1,54 @@
1
+ import { isRecord, oneOf, str, strings } from "./decode.js";
2
+ export const PART_STATUSES = [
3
+ "stable",
4
+ "beta",
5
+ "experimental",
6
+ "deprecated",
7
+ ];
8
+ /**
9
+ * Read one intent record, or `undefined` when it says nothing usable.
10
+ *
11
+ * Every field is optional, and a malformed optional field degrades to absent rather
12
+ * than taking the whole record with it. The one thing that is not tolerated is a record
13
+ * that answers nothing: treating that as intent would hide it from the `_(undocumented)_`
14
+ * flag, which is the only place the absence is visible.
15
+ */
16
+ export const decodeIntent = (value) => {
17
+ if (!isRecord(value))
18
+ return undefined;
19
+ const summary = str(value.summary);
20
+ const whenToUse = str(value.whenToUse);
21
+ const whenNotToUse = str(value.whenNotToUse);
22
+ const states = strings(value.states);
23
+ const status = oneOf(value.status, PART_STATUSES);
24
+ const examples = strings(value.examples);
25
+ const useInstead = strings(value.useInstead);
26
+ if (summary === undefined &&
27
+ whenToUse === undefined &&
28
+ whenNotToUse === undefined &&
29
+ states === undefined &&
30
+ status === undefined &&
31
+ examples === undefined &&
32
+ useInstead === undefined) {
33
+ return undefined;
34
+ }
35
+ return {
36
+ ...(summary === undefined ? {} : { summary }),
37
+ ...(whenToUse === undefined ? {} : { whenToUse }),
38
+ ...(whenNotToUse === undefined ? {} : { whenNotToUse }),
39
+ ...(states === undefined ? {} : { states }),
40
+ ...(status === undefined ? {} : { status }),
41
+ ...(examples === undefined ? {} : { examples }),
42
+ ...(useInstead === undefined ? {} : { useInstead }),
43
+ };
44
+ };
45
+ /** Whether an intent record carries anything a reader can act on. */
46
+ export const hasIntent = (intent) => intent !== undefined &&
47
+ (intent.summary !== undefined ||
48
+ intent.whenToUse !== undefined ||
49
+ intent.whenNotToUse !== undefined ||
50
+ (intent.states?.length ?? 0) > 0 ||
51
+ intent.status !== undefined ||
52
+ (intent.examples?.length ?? 0) > 0 ||
53
+ (intent.useInstead?.length ?? 0) > 0);
54
+ //# sourceMappingURL=intent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intent.js","sourceRoot":"","sources":["../src/intent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAkB3D,MAAM,CAAC,MAAM,aAAa,GAA8B;IACtD,QAAQ;IACR,MAAM;IACN,cAAc;IACd,YAAY;CACb,CAAA;AAoBD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAc,EAAsB,EAAE;IACjE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IACtC,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAClC,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;IACtC,MAAM,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;IAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IACpC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IACjD,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IACxC,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;IAC5C,IACE,OAAO,KAAK,SAAS;QACrB,SAAS,KAAK,SAAS;QACvB,YAAY,KAAK,SAAS;QAC1B,MAAM,KAAK,SAAS;QACpB,MAAM,KAAK,SAAS;QACpB,QAAQ,KAAK,SAAS;QACtB,UAAU,KAAK,SAAS,EACxB,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,OAAO;QACL,G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dist/json.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ /** Parse JSON, answering `undefined` for malformed text instead of throwing. */
2
+ export declare const parseJson: (text: string) => unknown;
3
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AASA,gFAAgF;AAChF,eAAO,MAAM,SAAS,SAAU,MAAM,KAAG,OAMxC,CAAA"}
package/dist/json.js ADDED
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Text to value, without a throw.
3
+ *
4
+ * Both cutlist's staleness gate and jig's baseline read committed JSON. A malformed file
5
+ * must degrade to a miss, not kill the run. The try/catch used to be spelled twice, which
6
+ * is the kind of copy a format can own: the seam that says what a record looks like can
7
+ * also say how its bytes become one.
8
+ */
9
+ /** Parse JSON, answering `undefined` for malformed text instead of throwing. */
10
+ export const parseJson = (text) => {
11
+ try {
12
+ return JSON.parse(text);
13
+ }
14
+ catch {
15
+ return undefined;
16
+ }
17
+ };
18
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,gFAAgF;AAChF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAY,EAAW,EAAE;IACjD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAY,CAAA;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC,CAAA"}
@@ -0,0 +1,58 @@
1
+ /** Every lexicon name. Adding one is the breaking-change escape hatch. */
2
+ export declare const LEXICON_NAMES: readonly ["report", "baseline", "catalog", "manifest", "menu", "intent", "patterns", "recipes", "onboarding", "cutlist.config", "jig.config"];
3
+ /** The name of a record's contract. */
4
+ export type LexiconName = (typeof LEXICON_NAMES)[number];
5
+ /** Who owns the truth behind a lexicon. */
6
+ export type LexiconKind = "authored" | "derived" | "accepted";
7
+ /** One lexicon, as the registry knows it. */
8
+ export interface Lexicon {
9
+ readonly name: LexiconName;
10
+ /** The schema version, bumped on any published shape change (additive included). */
11
+ readonly version: number;
12
+ readonly kind: LexiconKind;
13
+ /** The package that is the source of truth for the record's meaning. */
14
+ readonly owner: string;
15
+ /** Repository-relative path to the language-neutral JSON Schema. */
16
+ readonly schema: string;
17
+ /** Repository-relative directory holding the golden and malformed fixtures. */
18
+ readonly fixture: string;
19
+ /** One sentence a stranger can act on. */
20
+ readonly summary: string;
21
+ }
22
+ /**
23
+ * The reference a tool-written record carries: which lexicon, at which version.
24
+ *
25
+ * It lives INSIDE the record rather than in a sidecar so a reader that only has the
26
+ * bytes — a script in another language, a future tool replacing `plumb` — can tell what
27
+ * it is holding without a registry lookup. The registry is how our own readers resolve
28
+ * the name; the bytes are how everyone else does.
29
+ */
30
+ export interface LexiconRef {
31
+ readonly name: LexiconName;
32
+ readonly version: number;
33
+ }
34
+ /** The registry, keyed by name. Frozen so a reader cannot mutate the contract. */
35
+ export declare const LEXICONS: Readonly<Record<LexiconName, Lexicon>>;
36
+ /** A record's reference to its lexicon, at the registry's current version. */
37
+ export declare const lexiconRef: (name: LexiconName) => LexiconRef;
38
+ /** Whether an untrusted value is one of the known lexicon names. */
39
+ export declare const isLexiconName: (value: unknown) => value is LexiconName;
40
+ /**
41
+ * Whether an untrusted value is a well-formed reference — shape only, not a registry
42
+ * lookup, so a record naming a lexicon we have never heard of still parses as a ref and
43
+ * is then rejected by name.
44
+ */
45
+ export declare const isLexiconRef: (value: unknown) => value is LexiconRef;
46
+ /** Whether a reference names the given lexicon (any version). */
47
+ export declare const names: (ref: LexiconRef, name: LexiconName) => boolean;
48
+ /**
49
+ * Whether a reader that understands `known` at `knownVersion` can read a record written
50
+ * as `seen`: the same name, at a version the reader is not older than. A newer version is
51
+ * readable only because the evolution rule makes every change additive; a record from an
52
+ * older version is always readable.
53
+ */
54
+ export declare const isReadable: ({ seen, known, }: {
55
+ readonly seen: LexiconRef;
56
+ readonly known: LexiconRef;
57
+ }) => boolean;
58
+ //# sourceMappingURL=lexicon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lexicon.d.ts","sourceRoot":"","sources":["../src/lexicon.ts"],"names":[],"mappings":"AA2BA,0EAA0E;AAC1E,eAAO,MAAM,aAAa,YACxB,QAAQ,EACR,UAAU,EACV,SAAS,EACT,UAAU,EACV,MAAM,EACN,QAAQ,EACR,UAAU,EACV,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,YAAY,CACJ,CAAA;AAEV,uCAAuC;AACvC,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAA;AAExD,2CAA2C;AAC3C,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,CAAA;AAE7D,6CAA6C;AAC7C,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;IAC1B,oFAAoF;IACpF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAyGD,kFAAkF;AAClF,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAY,CAAA;AAExE,8EAA8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