@clay-design-system/registry 0.0.0-stage → 0.14.1

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.
@@ -0,0 +1,232 @@
1
+ import type { DatabaseSync } from 'node:sqlite';
2
+
3
+ export declare const allowedChildren: (sectionIdOrAlias: string) => {
4
+ itemTypes: CompactRecord[];
5
+ components: CompactRecord[];
6
+ mediaSlots: unknown[];
7
+ };
8
+
9
+ export declare const assetUrl: (idOrAlias: string, opts?: {
10
+ format?: "svg" | "png";
11
+ variant?: string;
12
+ }) => string | null;
13
+
14
+ export declare const assetVariants: (idOrAlias: string) => {
15
+ variant: string;
16
+ id: string;
17
+ }[];
18
+
19
+ export declare interface CompactHit extends CompactRecord {
20
+ score: number;
21
+ /** K11: file-level asset twins folded into this hit. */
22
+ folded?: string[];
23
+ }
24
+
25
+ export declare interface CompactLinks {
26
+ /** `<import_path>#<export_name>` */
27
+ import?: string;
28
+ story?: string;
29
+ /**
30
+ * A Figma url. Prefers a link of the record itself (`variant ''`), then any variant's link; within each, role order
31
+ * desktop → showcase → component-set → node (lowest variant, then ref, first). Absent when the record has no figma link with a url.
32
+ */
33
+ figma?: string;
34
+ /** The Figma variable id (`VariableID:2751:137`) of a token's `''` (else first) variable link. Tokens' variable links carry no url. */
35
+ figmaVariable?: string;
36
+ /** default svg ?? png */
37
+ cdn?: string;
38
+ }
39
+
40
+ export declare interface CompactRecord {
41
+ id: string;
42
+ kind: string;
43
+ subkind?: string;
44
+ name: string;
45
+ scope: string;
46
+ status: string;
47
+ summary: string;
48
+ links?: CompactLinks;
49
+ }
50
+
51
+ export declare const componentsUsingToken: (tokenIdOrAlias: string) => CompactRecord[];
52
+
53
+ /** Absolute path of the shipped SQLite database. */
54
+ export declare const DB_PATH: string;
55
+
56
+ export declare interface FullRecord extends Omit<RecordRow, 'rid'> {
57
+ aliases: {
58
+ alias: string;
59
+ type: string;
60
+ }[];
61
+ links: LinkRow[];
62
+ relations: {
63
+ out: (Omit<RelationRow, 'from_id'> & {
64
+ target?: CompactRecord;
65
+ })[];
66
+ in: (Omit<RelationRow, 'to_id' | 'to_ref'> & {
67
+ target: CompactRecord;
68
+ })[];
69
+ };
70
+ renders: Omit<RenderRow, 'html'>[] | RenderRow[];
71
+ }
72
+
73
+ export declare function get(idOrAlias: string, opts: GetOptions & {
74
+ as: 'unit';
75
+ }): KbUnitLike | null;
76
+
77
+ export declare function get(idOrAlias: string, opts: GetOptions & {
78
+ detail: true;
79
+ }): FullRecord | null;
80
+
81
+ export declare function get(idOrAlias: string, opts?: GetOptions): CompactRecord | FullRecord | KbUnitLike | null;
82
+
83
+ export declare interface GetOptions {
84
+ detail?: boolean;
85
+ /** Return the KB unit exactly as `knowledge/clay-kb.json` holds it (round-trip contract). */
86
+ as?: 'unit';
87
+ /** With detail: include render HTML. */
88
+ html?: boolean;
89
+ }
90
+
91
+ /** A KB unit as the compiled KB holds it (`file` = the hand-written unit file). */
92
+ export declare type KbUnitLike = Unit & {
93
+ file?: string;
94
+ };
95
+
96
+ export declare type LinkRow = { record_id: string; type: string; role: string; variant: string; ref: string; url: string | null; name: string | null; status: string; verified_at: string | null; confidence: string | null; source: string; note: string | null; file_key: string | null; node_id: string | null; node_type: string | null; variable_id: string | null; collection: string | null; mode: string | null; story_id: string | null; export_name: string | null; import_path: string | null; path: string | null; anchor: string | null; public_id: string | null; brand: string | null; format: string | null; width: number | null; height: number | null; bytes: number | null; content_hash: string | null;}
97
+
98
+ export declare const list: (kind: string, filter?: ListFilter) => CompactRecord[];
99
+
100
+ export declare interface ListFilter {
101
+ scope?: string;
102
+ status?: string;
103
+ limit?: number;
104
+ }
105
+
106
+ /** The package's registry (or the database at `path`), opened once. */
107
+ export declare function openRegistry(path?: string): Registry;
108
+
109
+ export declare const pageRecipe: (idOrAlias: string) => {
110
+ ord: number;
111
+ ref: string;
112
+ record: CompactRecord | null;
113
+ }[];
114
+
115
+ export declare type RecordRow = { rid: number; id: string; entity_id: string | null; kind: string; subkind: string | null; name: string; scope: string; status: string; visibility: string; authority: string; topic: string; summary: string; when_to_use: string | null; when_not_to_use: string | null; body: string; stages: ('design' | 'structure' | 'mapping' | 'assets' | 'copy' | 'page-file' | 'ux' | 'qa' | 'static' | 'fidelity')[]; modes: string[] | null; entities: string[]; severity: string | null; enforcement: string[] | null; tags: string[]; facts: unknown; data: unknown; handbook_id: string | null; source_path: string; source_anchor: string | null; generated_by: string | null; unit_file: string | null; verified_at: string; content_hash: string;}
116
+
117
+ /** Absolute path of the shipped records dump (JSON lines, links and outgoing relations inlined). */
118
+ export declare const RECORDS_PATH: string;
119
+
120
+ /** A read-only handle on a registry database; opens the package's own database unless given a path. */
121
+ export declare class Registry extends Registry_2 {
122
+ constructor(path?: string);
123
+ }
124
+
125
+ declare class Registry_2 {
126
+ readonly path: string;
127
+ readonly db: DatabaseSync;
128
+ private stats?;
129
+ private entityNames?;
130
+ constructor(path?: string);
131
+ close(): void;
132
+ meta(key: string): string | undefined;
133
+ /** Record id for an id or alias (entity id, handbook id), or null. */
134
+ resolve(idOrAlias: string): string | null;
135
+ /**
136
+ * Every record as the KB unit it was built from (`get(id, { as: 'unit' })` for all of them), sorted by id, in two queries.
137
+ * The `clay` CLI and the MCP server read their knowledge base from here.
138
+ */
139
+ allUnits(): KbUnitLike[];
140
+ private row;
141
+ private linksOf;
142
+ private compactLinks;
143
+ compact(r: Pick<RecordRow, 'id' | 'kind' | 'subkind' | 'name' | 'scope' | 'status' | 'summary'>): CompactRecord;
144
+ search(query: string, opts?: SearchOptions): CompactHit[];
145
+ /** Raw hits, the same shape `clay search` returns (parity tests compare these). */
146
+ searchHits(query: string, opts?: SearchOptions): SearchHit[];
147
+ get(idOrAlias: string, opts: GetOptions & {
148
+ as: 'unit';
149
+ }): KbUnitLike | null;
150
+ get(idOrAlias: string, opts: GetOptions & {
151
+ detail: true;
152
+ }): FullRecord | null;
153
+ get(idOrAlias: string, opts?: GetOptions): CompactRecord | FullRecord | KbUnitLike | null;
154
+ private compactOf;
155
+ list(kind: string, filter?: ListFilter): CompactRecord[];
156
+ related(idOrAlias: string, opts?: RelatedOptions): {
157
+ direction: 'out' | 'in';
158
+ type: string;
159
+ ord: number;
160
+ record: CompactRecord;
161
+ }[];
162
+ /** The variants a logo family offers, read from each file's `data` (customer: the key after the brand; integration: `default`; product: the whole key). */
163
+ assetVariants(idOrAlias: string): {
164
+ variant: string;
165
+ id: string;
166
+ }[];
167
+ /** The cdn URL of an asset. A logo family resolves to its file in `variant` (none given: `default`, then the first file; an unmatched variant: null). */
168
+ assetUrl(idOrAlias: string, opts?: {
169
+ format?: 'svg' | 'png';
170
+ variant?: string;
171
+ }): string | null;
172
+ /** The record's own cdn file in `variant` (the cdn rows' `variant` column; '' = the record itself). */
173
+ private ownCdnUrl;
174
+ componentsUsingToken(tokenIdOrAlias: string): CompactRecord[];
175
+ /** What a section can hold: its item types, the components its layouts nest, and its media slots (from handbook data). */
176
+ allowedChildren(sectionIdOrAlias: string): {
177
+ itemTypes: CompactRecord[];
178
+ components: CompactRecord[];
179
+ mediaSlots: unknown[];
180
+ };
181
+ /** The ordered sections / layouts a recipe (or, from 1B, a page) is composed of. */
182
+ pageRecipe(idOrAlias: string): {
183
+ ord: number;
184
+ ref: string;
185
+ record: CompactRecord | null;
186
+ }[];
187
+ }
188
+
189
+ export declare const related: (idOrAlias: string, opts?: RelatedOptions) => {
190
+ direction: "out" | "in";
191
+ type: string;
192
+ ord: number;
193
+ record: CompactRecord;
194
+ }[];
195
+
196
+ export declare interface RelatedOptions {
197
+ type?: string | string[];
198
+ direction?: 'out' | 'in' | 'both';
199
+ kind?: string[];
200
+ }
201
+
202
+ export declare type RelationRow = { from_id: string; type: string; to_id: string | null; to_ref: string; ord: number; source: string;}
203
+
204
+ export declare type RenderRow = { record_id: unknown; variant: unknown; theme: unknown; engine: unknown; story_id: unknown; html: unknown; html_hash: unknown; input_hash: unknown; css_refs: unknown; png_1440: unknown; png_375: unknown; mirror_url: unknown; interactive: number; version: unknown; checked_at: unknown;}
205
+
206
+ export declare const search: (query: string, opts?: SearchOptions) => CompactHit[];
207
+
208
+ export declare interface SearchHit {
209
+ id: string;
210
+ score: number;
211
+ kind: string;
212
+ authority: string;
213
+ summary: string;
214
+ /** K11: near-duplicate asset units folded into this hit (file-level variants of one registry entry). */
215
+ aliases?: string[];
216
+ }
217
+
218
+ export declare interface SearchOptions {
219
+ k?: number;
220
+ kind?: string[];
221
+ scope?: string[];
222
+ stage?: string[];
223
+ mode?: 'A' | 'B';
224
+ /** Entity ids (`section:FeaturesSection`); a unit matches when it carries any of them. */
225
+ entity?: string[];
226
+ authority?: string[];
227
+ includeBackground?: boolean;
228
+ }
229
+
230
+ declare type Unit = { id: string; kind: 'section' | 'layout' | 'rule' | 'component' | 'limit' | 'item-type' | 'token' | 'breakpoint' | 'page' | 'skill' | 'asset' | 'recipe' | 'policy' | 'gotcha' | 'procedure' | 'brand-fact' | 'stat' | 'background'; scope: 'web' | 'email' | 'ds' | 'shared'; topic: string; authority: 'background' | 'canonical' | 'derived' | 'guidance'; stages: ('design' | 'structure' | 'mapping' | 'assets' | 'copy' | 'page-file' | 'ux' | 'qa' | 'static' | 'fidelity')[]; entities: string[]; summary: string; body: string; source: { path: string; anchor?: string | undefined; generatedBy?: string | undefined; }; status: 'deprecated' | 'active'; verifiedAt: string; subkind?: 'agent' | 'shape' | 'atom' | 'molecule' | 'primitive' | 'icon' | 'logo' | 'logo-file' | 'badge' | 'image' | 'token-group' | undefined; modes?: ('A' | 'B')[] | undefined; when?: string | undefined; notWhen?: string | undefined; severity?: 'Critical' | 'Major' | 'Minor' | undefined; enforcement?: ('qa' | 'lint' | 'script' | 'test' | 'review' | 'types')[] | undefined; relations?: { supersedes?: string[] | undefined; conflictsWith?: string[] | undefined; seeAlso?: string[] | undefined; precedence?: string[] | undefined; } | undefined; visibility?: 'public' | 'internal' | undefined; handbookId?: string | undefined; data?: unknown; facts?: unknown;}
231
+
232
+ export { }