@decantr/registry 1.0.0-beta.1 → 1.0.0-beta.11
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/LICENSE +21 -0
- package/dist/index.d.ts +288 -31
- package/dist/index.js +239 -11
- package/dist/index.js.map +1 -1
- package/package.json +8 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Decantr AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
CHANGED
|
@@ -31,40 +31,82 @@ interface Pattern {
|
|
|
31
31
|
imports: string;
|
|
32
32
|
example: string;
|
|
33
33
|
};
|
|
34
|
+
visual_brief?: string;
|
|
35
|
+
composition?: Record<string, string>;
|
|
36
|
+
motion?: {
|
|
37
|
+
micro?: Record<string, string>;
|
|
38
|
+
transitions?: Record<string, string>;
|
|
39
|
+
ambient?: Record<string, string>;
|
|
40
|
+
};
|
|
41
|
+
responsive?: {
|
|
42
|
+
mobile?: string;
|
|
43
|
+
tablet?: string;
|
|
44
|
+
desktop?: string;
|
|
45
|
+
};
|
|
46
|
+
accessibility?: {
|
|
47
|
+
role?: string;
|
|
48
|
+
'aria-label'?: string;
|
|
49
|
+
keyboard?: string[];
|
|
50
|
+
announcements?: string[];
|
|
51
|
+
focus_management?: string;
|
|
52
|
+
};
|
|
53
|
+
layout_hints?: Record<string, string>;
|
|
54
|
+
category?: string;
|
|
34
55
|
}
|
|
56
|
+
type ArchetypeRole = 'primary' | 'gateway' | 'public' | 'auxiliary';
|
|
35
57
|
interface ArchetypePage {
|
|
36
58
|
id: string;
|
|
37
|
-
default_layout: string
|
|
59
|
+
default_layout: (string | {
|
|
60
|
+
pattern: string;
|
|
61
|
+
preset?: string;
|
|
62
|
+
as?: string;
|
|
63
|
+
})[];
|
|
38
64
|
shell: string;
|
|
39
65
|
}
|
|
66
|
+
interface SeoHints {
|
|
67
|
+
schema_org?: string[];
|
|
68
|
+
meta_priorities?: string[];
|
|
69
|
+
}
|
|
40
70
|
interface Archetype {
|
|
41
71
|
id: string;
|
|
42
72
|
version: string;
|
|
43
73
|
name: string;
|
|
44
74
|
description: string;
|
|
45
75
|
tags: string[];
|
|
76
|
+
role: ArchetypeRole;
|
|
46
77
|
pages: ArchetypePage[];
|
|
47
78
|
features: string[];
|
|
48
79
|
dependencies: {
|
|
49
80
|
patterns: Record<string, string>;
|
|
50
|
-
recipes: Record<string, string>;
|
|
51
81
|
};
|
|
82
|
+
seo_hints?: SeoHints;
|
|
83
|
+
classification?: {
|
|
84
|
+
triggers: {
|
|
85
|
+
primary: string[];
|
|
86
|
+
secondary: string[];
|
|
87
|
+
negative: string[];
|
|
88
|
+
};
|
|
89
|
+
implies: string[];
|
|
90
|
+
weight: number;
|
|
91
|
+
tier: string;
|
|
92
|
+
};
|
|
93
|
+
page_briefs?: Record<string, string>;
|
|
52
94
|
}
|
|
53
|
-
interface
|
|
95
|
+
interface ThemeSpatial {
|
|
54
96
|
density_bias: number;
|
|
55
97
|
content_gap_shift: number;
|
|
56
98
|
section_padding: string;
|
|
57
99
|
card_wrapping: 'always' | 'minimal' | 'none';
|
|
58
100
|
surface_override: string | null;
|
|
59
101
|
}
|
|
60
|
-
interface
|
|
102
|
+
interface ThemeEffects {
|
|
61
103
|
enabled: boolean;
|
|
62
104
|
intensity: 'subtle' | 'moderate' | 'bold';
|
|
63
105
|
type_mapping: Record<string, string[]>;
|
|
64
106
|
component_fallback: Record<string, string>;
|
|
65
107
|
intensity_values?: Record<string, Record<string, string>>;
|
|
66
108
|
}
|
|
67
|
-
interface
|
|
109
|
+
interface ThemeShell {
|
|
68
110
|
preferred: string[];
|
|
69
111
|
nav_style: string;
|
|
70
112
|
root?: string;
|
|
@@ -75,40 +117,189 @@ interface RecipeShell {
|
|
|
75
117
|
headerHeight?: string;
|
|
76
118
|
};
|
|
77
119
|
}
|
|
78
|
-
|
|
120
|
+
type ComposeEntry = string | {
|
|
121
|
+
archetype: string;
|
|
122
|
+
prefix: string;
|
|
123
|
+
role?: ArchetypeRole;
|
|
124
|
+
};
|
|
125
|
+
interface Blueprint {
|
|
79
126
|
id: string;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
avoid: string[];
|
|
89
|
-
default_presets?: Record<string, string>;
|
|
127
|
+
name: string;
|
|
128
|
+
description?: string;
|
|
129
|
+
archetype: string;
|
|
130
|
+
compose?: ComposeEntry[];
|
|
131
|
+
theme: {
|
|
132
|
+
id: string;
|
|
133
|
+
mode?: string;
|
|
134
|
+
shape?: string;
|
|
90
135
|
};
|
|
91
|
-
|
|
92
|
-
|
|
136
|
+
personality?: string;
|
|
137
|
+
pages: Array<{
|
|
138
|
+
id: string;
|
|
139
|
+
layout: string[];
|
|
140
|
+
shell?: string;
|
|
93
141
|
}>;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
142
|
+
features?: string[];
|
|
143
|
+
version?: string;
|
|
144
|
+
voice?: {
|
|
145
|
+
tone?: string;
|
|
146
|
+
cta_verbs?: string[];
|
|
147
|
+
avoid?: string[];
|
|
148
|
+
empty_states?: string;
|
|
149
|
+
errors?: string;
|
|
150
|
+
loading?: string;
|
|
151
|
+
metrics_format?: string;
|
|
152
|
+
};
|
|
153
|
+
responsive_strategy?: {
|
|
154
|
+
breakpoints?: string[];
|
|
155
|
+
navigation?: Record<string, string>;
|
|
156
|
+
data_display?: Record<string, string>;
|
|
97
157
|
};
|
|
98
158
|
}
|
|
99
|
-
|
|
159
|
+
interface Shell {
|
|
160
|
+
id: string;
|
|
161
|
+
name: string;
|
|
162
|
+
description?: string;
|
|
163
|
+
root?: string;
|
|
164
|
+
nav?: string;
|
|
165
|
+
header?: string;
|
|
166
|
+
nav_style?: string;
|
|
167
|
+
dimensions?: {
|
|
168
|
+
navWidth?: string;
|
|
169
|
+
headerHeight?: string;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
type ContentType = 'pattern' | 'archetype' | 'theme' | 'blueprint' | 'shell';
|
|
100
173
|
interface ResolvedContent<T> {
|
|
101
174
|
item: T;
|
|
102
|
-
source: 'local' | '
|
|
175
|
+
source: 'local' | 'core';
|
|
103
176
|
path: string;
|
|
104
177
|
}
|
|
178
|
+
type CvdMode = 'deuteranopia' | 'protanopia' | 'tritanopia' | 'achromatopsia';
|
|
179
|
+
interface ThemeTokens {
|
|
180
|
+
base?: Record<string, string>;
|
|
181
|
+
cvd?: Partial<Record<CvdMode, Record<string, string>>>;
|
|
182
|
+
}
|
|
183
|
+
interface Theme {
|
|
184
|
+
id: string;
|
|
185
|
+
name: string;
|
|
186
|
+
description?: string;
|
|
187
|
+
tags?: string[];
|
|
188
|
+
personality?: string;
|
|
189
|
+
seed?: Record<string, string>;
|
|
190
|
+
palette?: Record<string, Record<string, string>>;
|
|
191
|
+
modes?: string[];
|
|
192
|
+
shapes?: string[];
|
|
193
|
+
cvd_support?: CvdMode[];
|
|
194
|
+
tokens?: ThemeTokens;
|
|
195
|
+
decantr_compat?: string;
|
|
196
|
+
source?: string;
|
|
197
|
+
decorators?: Record<string, string>;
|
|
198
|
+
treatments?: Record<string, Record<string, string>>;
|
|
199
|
+
spatial?: ThemeSpatial;
|
|
200
|
+
shell?: ThemeShell;
|
|
201
|
+
effects?: ThemeEffects;
|
|
202
|
+
motion?: {
|
|
203
|
+
preference?: string;
|
|
204
|
+
reduce_motion?: boolean;
|
|
205
|
+
entrance?: string;
|
|
206
|
+
timing?: string;
|
|
207
|
+
durations?: Record<string, string>;
|
|
208
|
+
};
|
|
209
|
+
typography?: {
|
|
210
|
+
scale?: string;
|
|
211
|
+
heading_weight?: number;
|
|
212
|
+
body_weight?: number;
|
|
213
|
+
mono?: string;
|
|
214
|
+
};
|
|
215
|
+
radius?: {
|
|
216
|
+
philosophy?: string;
|
|
217
|
+
base?: number;
|
|
218
|
+
};
|
|
219
|
+
compositions?: Record<string, {
|
|
220
|
+
shell: string;
|
|
221
|
+
description: string;
|
|
222
|
+
effects?: string[];
|
|
223
|
+
}>;
|
|
224
|
+
pattern_preferences?: {
|
|
225
|
+
prefer: string[];
|
|
226
|
+
avoid: string[];
|
|
227
|
+
default_presets?: Record<string, string>;
|
|
228
|
+
};
|
|
229
|
+
decorator_definitions?: Record<string, {
|
|
230
|
+
description: string;
|
|
231
|
+
intent: string;
|
|
232
|
+
suggested_properties?: Record<string, string>;
|
|
233
|
+
pairs_with?: string[];
|
|
234
|
+
usage?: string[];
|
|
235
|
+
}>;
|
|
236
|
+
}
|
|
237
|
+
type ApiContentType = 'patterns' | 'themes' | 'blueprints' | 'archetypes' | 'shells';
|
|
238
|
+
interface ContentListResponse<T = Record<string, unknown>> {
|
|
239
|
+
items: T[];
|
|
240
|
+
total: number;
|
|
241
|
+
}
|
|
242
|
+
interface ContentItem {
|
|
243
|
+
id: string;
|
|
244
|
+
slug: string;
|
|
245
|
+
namespace: string;
|
|
246
|
+
type: string;
|
|
247
|
+
version: string;
|
|
248
|
+
data: Record<string, unknown>;
|
|
249
|
+
visibility: 'public' | 'private';
|
|
250
|
+
status: 'pending' | 'approved' | 'rejected' | 'published';
|
|
251
|
+
created_at: string;
|
|
252
|
+
updated_at: string;
|
|
253
|
+
published_at?: string;
|
|
254
|
+
}
|
|
255
|
+
interface PublishPayload {
|
|
256
|
+
type: ApiContentType;
|
|
257
|
+
slug: string;
|
|
258
|
+
namespace: string;
|
|
259
|
+
version: string;
|
|
260
|
+
data: Record<string, unknown>;
|
|
261
|
+
visibility?: 'public' | 'private';
|
|
262
|
+
}
|
|
263
|
+
interface PublishResponse {
|
|
264
|
+
id: string;
|
|
265
|
+
slug: string;
|
|
266
|
+
namespace: string;
|
|
267
|
+
type: string;
|
|
268
|
+
status: string;
|
|
269
|
+
}
|
|
270
|
+
interface SearchParams {
|
|
271
|
+
q: string;
|
|
272
|
+
type?: string;
|
|
273
|
+
namespace?: string;
|
|
274
|
+
limit?: number;
|
|
275
|
+
offset?: number;
|
|
276
|
+
}
|
|
277
|
+
interface SearchResponse {
|
|
278
|
+
results: Array<{
|
|
279
|
+
id: string;
|
|
280
|
+
type: string;
|
|
281
|
+
slug: string;
|
|
282
|
+
namespace: string;
|
|
283
|
+
name: string;
|
|
284
|
+
description: string;
|
|
285
|
+
version: string;
|
|
286
|
+
}>;
|
|
287
|
+
total: number;
|
|
288
|
+
}
|
|
289
|
+
interface UserProfile {
|
|
290
|
+
id: string;
|
|
291
|
+
email: string;
|
|
292
|
+
tier: 'free' | 'pro' | 'team' | 'enterprise';
|
|
293
|
+
reputation_score: number;
|
|
294
|
+
trusted: boolean;
|
|
295
|
+
}
|
|
105
296
|
|
|
106
297
|
type ContentMap = {
|
|
107
298
|
pattern: Pattern;
|
|
108
299
|
archetype: Archetype;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
300
|
+
theme: Theme;
|
|
301
|
+
blueprint: Blueprint;
|
|
302
|
+
shell: Shell;
|
|
112
303
|
};
|
|
113
304
|
interface ResolverOptions {
|
|
114
305
|
contentRoot: string;
|
|
@@ -124,7 +315,7 @@ interface ResolvedPreset {
|
|
|
124
315
|
layout: PatternPreset['layout'];
|
|
125
316
|
code: PatternPreset['code'];
|
|
126
317
|
}
|
|
127
|
-
declare function resolvePatternPreset(pattern: Pattern, explicitPreset?: string,
|
|
318
|
+
declare function resolvePatternPreset(pattern: Pattern, explicitPreset?: string, themeDefaultPresets?: Record<string, string>): ResolvedPreset;
|
|
128
319
|
|
|
129
320
|
type HookType = 'search' | 'filter' | 'selection' | 'sort';
|
|
130
321
|
interface WiringSignal {
|
|
@@ -144,13 +335,79 @@ interface WiringResult {
|
|
|
144
335
|
props: Record<string, Record<string, string>>;
|
|
145
336
|
hookProps: Record<string, Record<string, string>>;
|
|
146
337
|
}
|
|
338
|
+
/**
|
|
339
|
+
* IO declaration for a pattern, used by the data-driven wiring system.
|
|
340
|
+
*/
|
|
341
|
+
interface PatternIOEntry {
|
|
342
|
+
id: string;
|
|
343
|
+
io: PatternIO;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* A dynamically derived wiring edge between two patterns based on shared IO signals.
|
|
347
|
+
*/
|
|
348
|
+
interface IOWiringEdge {
|
|
349
|
+
producer: string;
|
|
350
|
+
consumer: string;
|
|
351
|
+
signals: string[];
|
|
352
|
+
}
|
|
147
353
|
declare const WIRING_RULES: WiringRule[];
|
|
148
|
-
|
|
354
|
+
/**
|
|
355
|
+
* Derive wiring edges from pattern IO declarations.
|
|
356
|
+
* If pattern A produces signal X and pattern B consumes signal X, an edge is created.
|
|
357
|
+
* Only patterns present in the layout are considered.
|
|
358
|
+
*/
|
|
359
|
+
declare function deriveIOWirings(layoutIds: string[], patternIOMap: Map<string, PatternIO>): IOWiringEdge[];
|
|
360
|
+
/**
|
|
361
|
+
* Build a PatternIO map from an array of PatternIOEntry objects.
|
|
362
|
+
*/
|
|
363
|
+
declare function buildIOMap(entries: PatternIOEntry[]): Map<string, PatternIO>;
|
|
364
|
+
/**
|
|
365
|
+
* Detect wirings from a layout. Uses hardcoded WIRING_RULES for detailed
|
|
366
|
+
* signal/prop information. When a patternIOMap is provided, also derives
|
|
367
|
+
* IO-based wirings and merges them (hardcoded rules take precedence for
|
|
368
|
+
* pairs they cover).
|
|
369
|
+
*/
|
|
370
|
+
declare function detectWirings(layout: LayoutItem[], patternIOMap?: Map<string, PatternIO>): WiringResult[];
|
|
149
371
|
|
|
372
|
+
interface RegistryAPIClientOptions {
|
|
373
|
+
baseUrl?: string;
|
|
374
|
+
apiKey?: string;
|
|
375
|
+
timeoutMs?: number;
|
|
376
|
+
cacheTtlMs?: number;
|
|
377
|
+
}
|
|
378
|
+
declare class RegistryAPIClient {
|
|
379
|
+
private baseUrl;
|
|
380
|
+
private apiKey;
|
|
381
|
+
private timeoutMs;
|
|
382
|
+
private cacheTtlMs;
|
|
383
|
+
private cache;
|
|
384
|
+
constructor(options?: RegistryAPIClientOptions);
|
|
385
|
+
private buildHeaders;
|
|
386
|
+
private fetchWithTimeout;
|
|
387
|
+
private request;
|
|
388
|
+
private getCached;
|
|
389
|
+
private setCache;
|
|
390
|
+
clearCache(): void;
|
|
391
|
+
checkHealth(): Promise<boolean>;
|
|
392
|
+
listContent<T = Record<string, unknown>>(type: ApiContentType, params?: {
|
|
393
|
+
namespace?: string;
|
|
394
|
+
limit?: number;
|
|
395
|
+
offset?: number;
|
|
396
|
+
}): Promise<ContentListResponse<T>>;
|
|
397
|
+
getContent<T = Record<string, unknown>>(type: ApiContentType, namespace: string, slug: string): Promise<T>;
|
|
398
|
+
getPattern(namespace: string, slug: string): Promise<Pattern>;
|
|
399
|
+
getArchetype(namespace: string, slug: string): Promise<Archetype>;
|
|
400
|
+
getTheme(namespace: string, slug: string): Promise<Theme>;
|
|
401
|
+
getBlueprint(namespace: string, slug: string): Promise<Blueprint>;
|
|
402
|
+
getShell(namespace: string, slug: string): Promise<Shell>;
|
|
403
|
+
search(params: SearchParams): Promise<SearchResponse>;
|
|
404
|
+
getProfile(): Promise<UserProfile>;
|
|
405
|
+
publishContent(payload: PublishPayload): Promise<PublishResponse>;
|
|
406
|
+
getMyContent(): Promise<ContentListResponse<ContentItem>>;
|
|
407
|
+
getSchema(name?: string): Promise<Record<string, unknown>>;
|
|
408
|
+
}
|
|
150
409
|
interface RegistryClientOptions {
|
|
151
410
|
baseUrl?: string;
|
|
152
|
-
cacheDir?: string;
|
|
153
|
-
cacheTtl?: number;
|
|
154
411
|
}
|
|
155
412
|
interface SearchResult {
|
|
156
413
|
id: string;
|
|
@@ -166,4 +423,4 @@ interface RegistryClient {
|
|
|
166
423
|
}
|
|
167
424
|
declare function createRegistryClient(options?: RegistryClientOptions): RegistryClient;
|
|
168
425
|
|
|
169
|
-
export { type Archetype, type ArchetypePage, type ContentResolver, type ContentType, type HookType, type Pattern, type PatternIO, type
|
|
426
|
+
export { type ApiContentType, type Archetype, type ArchetypePage, type ArchetypeRole, type Blueprint, type ComposeEntry, type ContentItem, type ContentListResponse, type ContentResolver, type ContentType, type CvdMode, type HookType, type IOWiringEdge, type Pattern, type PatternIO, type PatternIOEntry, type PatternPreset, type PublishPayload, type PublishResponse, RegistryAPIClient, type RegistryAPIClientOptions, type RegistryClient, type RegistryClientOptions, type ResolvedContent, type ResolvedPreset, type ResolverOptions, type SearchParams, type SearchResponse, type SearchResult, type Shell, type Theme, type ThemeEffects, type ThemeShell, type ThemeSpatial, type ThemeTokens, type UserProfile, WIRING_RULES, type WiringResult, type WiringRule, type WiringSignal, buildIOMap, createRegistryClient, createResolver, deriveIOWirings, detectWirings, resolvePatternPreset };
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,9 @@ import { join } from "path";
|
|
|
4
4
|
var TYPE_DIRS = {
|
|
5
5
|
pattern: "patterns",
|
|
6
6
|
archetype: "archetypes",
|
|
7
|
-
recipe: "recipes",
|
|
8
7
|
theme: "themes",
|
|
9
|
-
blueprint: "blueprints"
|
|
8
|
+
blueprint: "blueprints",
|
|
9
|
+
shell: "shells"
|
|
10
10
|
};
|
|
11
11
|
async function tryLoadJson(filePath) {
|
|
12
12
|
try {
|
|
@@ -27,7 +27,10 @@ function createResolver(options) {
|
|
|
27
27
|
const item = await tryLoadJson(filePath);
|
|
28
28
|
if (item) return { item, source: "local", path: filePath };
|
|
29
29
|
}
|
|
30
|
-
const
|
|
30
|
+
const mainPath = join(contentRoot, dir, fileName);
|
|
31
|
+
const mainItem = await tryLoadJson(mainPath);
|
|
32
|
+
if (mainItem) return { item: mainItem, source: "core", path: mainPath };
|
|
33
|
+
const corePath = join(contentRoot, "core", dir, fileName);
|
|
31
34
|
const coreItem = await tryLoadJson(corePath);
|
|
32
35
|
if (coreItem) return { item: coreItem, source: "core", path: corePath };
|
|
33
36
|
return null;
|
|
@@ -36,7 +39,7 @@ function createResolver(options) {
|
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
// src/pattern.ts
|
|
39
|
-
function resolvePatternPreset(pattern, explicitPreset,
|
|
42
|
+
function resolvePatternPreset(pattern, explicitPreset, themeDefaultPresets) {
|
|
40
43
|
const presets = pattern.presets;
|
|
41
44
|
const hasPresets = Object.keys(presets).length > 0;
|
|
42
45
|
if (!hasPresets) {
|
|
@@ -48,9 +51,9 @@ function resolvePatternPreset(pattern, explicitPreset, recipeDefaultPresets) {
|
|
|
48
51
|
}
|
|
49
52
|
let presetName = explicitPreset;
|
|
50
53
|
if (presetName && !presets[presetName]) presetName = void 0;
|
|
51
|
-
if (!presetName &&
|
|
52
|
-
const
|
|
53
|
-
if (presets[
|
|
54
|
+
if (!presetName && themeDefaultPresets?.[pattern.id]) {
|
|
55
|
+
const themeName = themeDefaultPresets[pattern.id];
|
|
56
|
+
if (presets[themeName]) presetName = themeName;
|
|
54
57
|
}
|
|
55
58
|
if (!presetName) presetName = pattern.default_preset;
|
|
56
59
|
if (!presetName || !presets[presetName]) presetName = Object.keys(presets)[0];
|
|
@@ -110,28 +113,250 @@ function getPatternId(item) {
|
|
|
110
113
|
if ("pattern" in item) return item.pattern;
|
|
111
114
|
return null;
|
|
112
115
|
}
|
|
113
|
-
function
|
|
116
|
+
function deriveIOWirings(layoutIds, patternIOMap) {
|
|
117
|
+
const edges = [];
|
|
118
|
+
const layoutSet = new Set(layoutIds);
|
|
119
|
+
for (const producerId of layoutIds) {
|
|
120
|
+
const producerIO = patternIOMap.get(producerId);
|
|
121
|
+
if (!producerIO?.produces?.length) continue;
|
|
122
|
+
for (const consumerId of layoutIds) {
|
|
123
|
+
if (producerId === consumerId) continue;
|
|
124
|
+
if (!layoutSet.has(consumerId)) continue;
|
|
125
|
+
const consumerIO = patternIOMap.get(consumerId);
|
|
126
|
+
if (!consumerIO?.consumes?.length) continue;
|
|
127
|
+
const shared = producerIO.produces.filter(
|
|
128
|
+
(signal) => consumerIO.consumes.includes(signal)
|
|
129
|
+
);
|
|
130
|
+
if (shared.length > 0) {
|
|
131
|
+
edges.push({ producer: producerId, consumer: consumerId, signals: shared });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return edges;
|
|
136
|
+
}
|
|
137
|
+
function buildIOMap(entries) {
|
|
138
|
+
const map = /* @__PURE__ */ new Map();
|
|
139
|
+
for (const entry of entries) {
|
|
140
|
+
map.set(entry.id, entry.io);
|
|
141
|
+
}
|
|
142
|
+
return map;
|
|
143
|
+
}
|
|
144
|
+
function detectWirings(layout, patternIOMap) {
|
|
114
145
|
const patternIds = layout.map(getPatternId).filter((id) => id !== null);
|
|
115
146
|
const results = [];
|
|
147
|
+
const coveredPairs = /* @__PURE__ */ new Set();
|
|
116
148
|
for (const rule of WIRING_RULES) {
|
|
117
149
|
const [a, b] = rule.pair;
|
|
118
150
|
if (patternIds.includes(a) && patternIds.includes(b)) {
|
|
119
151
|
results.push({ rule, signals: rule.signals, props: rule.props, hookProps: rule.hookProps });
|
|
152
|
+
coveredPairs.add(`${a}:${b}`);
|
|
153
|
+
coveredPairs.add(`${b}:${a}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (patternIOMap) {
|
|
157
|
+
const ioEdges = deriveIOWirings(patternIds, patternIOMap);
|
|
158
|
+
for (const edge of ioEdges) {
|
|
159
|
+
const pairKey = `${edge.producer}:${edge.consumer}`;
|
|
160
|
+
if (coveredPairs.has(pairKey)) continue;
|
|
161
|
+
coveredPairs.add(pairKey);
|
|
162
|
+
const signals = edge.signals.map((sig) => {
|
|
163
|
+
const camel = toCamelCase(sig);
|
|
164
|
+
return {
|
|
165
|
+
name: `page${capitalize(camel)}`,
|
|
166
|
+
init: "''",
|
|
167
|
+
hookType: classifySignal(sig)
|
|
168
|
+
};
|
|
169
|
+
});
|
|
170
|
+
const producerProps = {};
|
|
171
|
+
const consumerProps = {};
|
|
172
|
+
const producerHookProps = {};
|
|
173
|
+
const consumerHookProps = {};
|
|
174
|
+
for (const sig of edge.signals) {
|
|
175
|
+
const camel = toCamelCase(sig);
|
|
176
|
+
const stateName = `page${capitalize(camel)}`;
|
|
177
|
+
const setterName = `set${capitalize(stateName)}`;
|
|
178
|
+
producerProps[`on${capitalize(camel)}`] = setterName;
|
|
179
|
+
consumerProps[sig] = stateName;
|
|
180
|
+
producerHookProps[sig] = sig;
|
|
181
|
+
consumerHookProps[sig] = sig;
|
|
182
|
+
}
|
|
183
|
+
const rule = {
|
|
184
|
+
pair: [edge.producer, edge.consumer],
|
|
185
|
+
signals,
|
|
186
|
+
props: { [edge.producer]: producerProps, [edge.consumer]: consumerProps },
|
|
187
|
+
hookProps: { [edge.producer]: producerHookProps, [edge.consumer]: consumerHookProps }
|
|
188
|
+
};
|
|
189
|
+
results.push({ rule, signals, props: rule.props, hookProps: rule.hookProps });
|
|
120
190
|
}
|
|
121
191
|
}
|
|
122
192
|
return results;
|
|
123
193
|
}
|
|
194
|
+
function toCamelCase(str) {
|
|
195
|
+
return str.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
196
|
+
}
|
|
197
|
+
function capitalize(str) {
|
|
198
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
199
|
+
}
|
|
200
|
+
function classifySignal(signal) {
|
|
201
|
+
const normalized = toCamelCase(signal);
|
|
202
|
+
if (normalized === "search") return "search";
|
|
203
|
+
if (normalized === "selection") return "selection";
|
|
204
|
+
if (normalized === "sort") return "sort";
|
|
205
|
+
return "filter";
|
|
206
|
+
}
|
|
124
207
|
|
|
125
|
-
// src/client.ts
|
|
208
|
+
// src/api-client.ts
|
|
209
|
+
var DEFAULT_BASE_URL = "https://api.decantr.ai/v1";
|
|
210
|
+
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
211
|
+
var DEFAULT_CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
212
|
+
var RegistryAPIClient = class {
|
|
213
|
+
baseUrl;
|
|
214
|
+
apiKey;
|
|
215
|
+
timeoutMs;
|
|
216
|
+
cacheTtlMs;
|
|
217
|
+
cache = /* @__PURE__ */ new Map();
|
|
218
|
+
constructor(options = {}) {
|
|
219
|
+
this.baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
|
|
220
|
+
this.apiKey = options.apiKey;
|
|
221
|
+
this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
222
|
+
this.cacheTtlMs = options.cacheTtlMs ?? DEFAULT_CACHE_TTL_MS;
|
|
223
|
+
}
|
|
224
|
+
// ── HTTP helpers ──
|
|
225
|
+
buildHeaders() {
|
|
226
|
+
const headers = {
|
|
227
|
+
"Accept": "application/json"
|
|
228
|
+
};
|
|
229
|
+
if (this.apiKey) {
|
|
230
|
+
headers["X-API-Key"] = this.apiKey;
|
|
231
|
+
}
|
|
232
|
+
return headers;
|
|
233
|
+
}
|
|
234
|
+
async fetchWithTimeout(url, init) {
|
|
235
|
+
const controller = new AbortController();
|
|
236
|
+
const timeout = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
237
|
+
try {
|
|
238
|
+
return await fetch(url, { ...init, signal: controller.signal });
|
|
239
|
+
} finally {
|
|
240
|
+
clearTimeout(timeout);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
async request(path, init) {
|
|
244
|
+
const url = `${this.baseUrl}${path}`;
|
|
245
|
+
const response = await this.fetchWithTimeout(url, {
|
|
246
|
+
...init,
|
|
247
|
+
headers: { ...this.buildHeaders(), ...init?.headers }
|
|
248
|
+
});
|
|
249
|
+
if (!response.ok) {
|
|
250
|
+
const body = await response.text().catch(() => "");
|
|
251
|
+
throw new Error(`API ${response.status}: ${body || response.statusText}`);
|
|
252
|
+
}
|
|
253
|
+
return response.json();
|
|
254
|
+
}
|
|
255
|
+
// ── Cache helpers ──
|
|
256
|
+
getCached(key) {
|
|
257
|
+
const entry = this.cache.get(key);
|
|
258
|
+
if (!entry) return null;
|
|
259
|
+
if (Date.now() - entry.timestamp > this.cacheTtlMs) {
|
|
260
|
+
this.cache.delete(key);
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
return entry.data;
|
|
264
|
+
}
|
|
265
|
+
setCache(key, data) {
|
|
266
|
+
this.cache.set(key, { data, timestamp: Date.now() });
|
|
267
|
+
}
|
|
268
|
+
clearCache() {
|
|
269
|
+
this.cache.clear();
|
|
270
|
+
}
|
|
271
|
+
// ── Health ──
|
|
272
|
+
async checkHealth() {
|
|
273
|
+
try {
|
|
274
|
+
const url = this.baseUrl.replace(/\/v1$/, "/health");
|
|
275
|
+
const response = await this.fetchWithTimeout(url);
|
|
276
|
+
return response.ok;
|
|
277
|
+
} catch {
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// ── Content fetching (public) ──
|
|
282
|
+
async listContent(type, params) {
|
|
283
|
+
const cacheKey = `list:${type}:${JSON.stringify(params ?? {})}`;
|
|
284
|
+
const cached = this.getCached(cacheKey);
|
|
285
|
+
if (cached) return cached;
|
|
286
|
+
const searchParams = new URLSearchParams();
|
|
287
|
+
if (params?.namespace) searchParams.set("namespace", params.namespace);
|
|
288
|
+
if (params?.limit) searchParams.set("limit", String(params.limit));
|
|
289
|
+
if (params?.offset) searchParams.set("offset", String(params.offset));
|
|
290
|
+
const query = searchParams.toString();
|
|
291
|
+
const path = `/${type}${query ? `?${query}` : ""}`;
|
|
292
|
+
const result = await this.request(path);
|
|
293
|
+
this.setCache(cacheKey, result);
|
|
294
|
+
return result;
|
|
295
|
+
}
|
|
296
|
+
async getContent(type, namespace, slug) {
|
|
297
|
+
const cacheKey = `get:${type}:${namespace}:${slug}`;
|
|
298
|
+
const cached = this.getCached(cacheKey);
|
|
299
|
+
if (cached) return cached;
|
|
300
|
+
const raw = await this.request(`/${type}/${namespace}/${slug}`);
|
|
301
|
+
const unwrapped = raw.data ?? raw;
|
|
302
|
+
this.setCache(cacheKey, unwrapped);
|
|
303
|
+
return unwrapped;
|
|
304
|
+
}
|
|
305
|
+
// ── Typed convenience methods ──
|
|
306
|
+
async getPattern(namespace, slug) {
|
|
307
|
+
return this.getContent("patterns", namespace, slug);
|
|
308
|
+
}
|
|
309
|
+
async getArchetype(namespace, slug) {
|
|
310
|
+
return this.getContent("archetypes", namespace, slug);
|
|
311
|
+
}
|
|
312
|
+
async getTheme(namespace, slug) {
|
|
313
|
+
return this.getContent("themes", namespace, slug);
|
|
314
|
+
}
|
|
315
|
+
async getBlueprint(namespace, slug) {
|
|
316
|
+
return this.getContent("blueprints", namespace, slug);
|
|
317
|
+
}
|
|
318
|
+
async getShell(namespace, slug) {
|
|
319
|
+
return this.getContent("shells", namespace, slug);
|
|
320
|
+
}
|
|
321
|
+
// ── Search ──
|
|
322
|
+
async search(params) {
|
|
323
|
+
const searchParams = new URLSearchParams({ q: params.q });
|
|
324
|
+
if (params.type) searchParams.set("type", params.type);
|
|
325
|
+
if (params.namespace) searchParams.set("namespace", params.namespace);
|
|
326
|
+
if (params.limit) searchParams.set("limit", String(params.limit));
|
|
327
|
+
if (params.offset) searchParams.set("offset", String(params.offset));
|
|
328
|
+
return this.request(`/search?${searchParams}`);
|
|
329
|
+
}
|
|
330
|
+
// ── Authenticated endpoints ──
|
|
331
|
+
async getProfile() {
|
|
332
|
+
return this.request("/me");
|
|
333
|
+
}
|
|
334
|
+
async publishContent(payload) {
|
|
335
|
+
return this.request("/content", {
|
|
336
|
+
method: "POST",
|
|
337
|
+
headers: { "Content-Type": "application/json" },
|
|
338
|
+
body: JSON.stringify(payload)
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
async getMyContent() {
|
|
342
|
+
return this.request("/my/content");
|
|
343
|
+
}
|
|
344
|
+
// ── Schema ──
|
|
345
|
+
async getSchema(name = "essence.v3.json") {
|
|
346
|
+
return this.request(`/schema/${name}`);
|
|
347
|
+
}
|
|
348
|
+
};
|
|
126
349
|
function createRegistryClient(options = {}) {
|
|
127
|
-
const baseUrl = options.baseUrl ?? "https://decantr
|
|
350
|
+
const baseUrl = options.baseUrl ?? "https://api.decantr.ai/v1";
|
|
128
351
|
return {
|
|
129
352
|
async search(query, type) {
|
|
130
353
|
const params = new URLSearchParams({ q: query });
|
|
131
354
|
if (type) params.set("type", type);
|
|
132
355
|
const res = await fetch(`${baseUrl}/search?${params}`);
|
|
133
356
|
if (!res.ok) return [];
|
|
134
|
-
|
|
357
|
+
const data = await res.json();
|
|
358
|
+
if (Array.isArray(data)) return data;
|
|
359
|
+
return data.results ?? [];
|
|
135
360
|
},
|
|
136
361
|
async fetch(type, id, version) {
|
|
137
362
|
const url = version ? `${baseUrl}/content/${type}/${id}/${version}` : `${baseUrl}/content/${type}/${id}`;
|
|
@@ -142,9 +367,12 @@ function createRegistryClient(options = {}) {
|
|
|
142
367
|
};
|
|
143
368
|
}
|
|
144
369
|
export {
|
|
370
|
+
RegistryAPIClient,
|
|
145
371
|
WIRING_RULES,
|
|
372
|
+
buildIOMap,
|
|
146
373
|
createRegistryClient,
|
|
147
374
|
createResolver,
|
|
375
|
+
deriveIOWirings,
|
|
148
376
|
detectWirings,
|
|
149
377
|
resolvePatternPreset
|
|
150
378
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/resolver.ts","../src/pattern.ts","../src/wiring.ts","../src/client.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport type { Pattern, Archetype, Recipe, ContentType, ResolvedContent } from './types.js';\n\ntype ContentMap = {\n pattern: Pattern;\n archetype: Archetype;\n recipe: Recipe;\n theme: Record<string, unknown>;\n blueprint: Record<string, unknown>;\n};\n\nexport interface ResolverOptions {\n contentRoot: string;\n overridePaths?: string[];\n}\n\nexport interface ContentResolver {\n resolve<T extends ContentType>(type: T, id: string): Promise<ResolvedContent<ContentMap[T]> | null>;\n}\n\nconst TYPE_DIRS: Record<ContentType, string> = {\n pattern: 'patterns',\n archetype: 'archetypes',\n recipe: 'recipes',\n theme: 'themes',\n blueprint: 'blueprints',\n};\n\nasync function tryLoadJson<T>(filePath: string): Promise<T | null> {\n try {\n const content = await readFile(filePath, 'utf-8');\n return JSON.parse(content) as T;\n } catch {\n return null;\n }\n}\n\nexport function createResolver(options: ResolverOptions): ContentResolver {\n const { contentRoot, overridePaths = [] } = options;\n return {\n async resolve<T extends ContentType>(type: T, id: string): Promise<ResolvedContent<ContentMap[T]> | null> {\n const dir = TYPE_DIRS[type];\n const fileName = `${id}.json`;\n for (const overridePath of overridePaths) {\n const filePath = join(overridePath, dir, fileName);\n const item = await tryLoadJson<ContentMap[T]>(filePath);\n if (item) return { item, source: 'local', path: filePath };\n }\n const corePath = join(contentRoot, dir, fileName);\n const coreItem = await tryLoadJson<ContentMap[T]>(corePath);\n if (coreItem) return { item: coreItem, source: 'core', path: corePath };\n return null;\n },\n };\n}\n","import type { Pattern, PatternPreset } from './types.js';\n\nexport interface ResolvedPreset {\n preset: string;\n layout: PatternPreset['layout'];\n code: PatternPreset['code'];\n}\n\nexport function resolvePatternPreset(\n pattern: Pattern,\n explicitPreset?: string,\n recipeDefaultPresets?: Record<string, string>,\n): ResolvedPreset {\n const presets = pattern.presets;\n const hasPresets = Object.keys(presets).length > 0;\n\n if (!hasPresets) {\n return {\n preset: '',\n layout: { layout: 'row', atoms: '' },\n code: pattern.code ?? { imports: '', example: '' },\n };\n }\n\n let presetName = explicitPreset;\n if (presetName && !presets[presetName]) presetName = undefined;\n if (!presetName && recipeDefaultPresets?.[pattern.id]) {\n const recipeName = recipeDefaultPresets[pattern.id];\n if (presets[recipeName]) presetName = recipeName;\n }\n if (!presetName) presetName = pattern.default_preset;\n if (!presetName || !presets[presetName]) presetName = Object.keys(presets)[0];\n\n const preset = presets[presetName];\n return { preset: presetName, layout: preset.layout, code: preset.code };\n}\n","import type { LayoutItem, PatternRef } from '@decantr/essence-spec';\n\n// AUTO: hookType classifies each signal for custom hook generation\nexport type HookType = 'search' | 'filter' | 'selection' | 'sort';\n\nexport interface WiringSignal { name: string; init: string; hookType: HookType }\n\nexport interface WiringRule {\n pair: [string, string];\n signals: WiringSignal[];\n props: Record<string, Record<string, string>>;\n // AUTO: hookProps maps pattern IDs to hook variable names passed as props\n hookProps: Record<string, Record<string, string>>;\n}\n\nexport interface WiringResult {\n rule: WiringRule;\n signals: WiringSignal[];\n props: Record<string, Record<string, string>>;\n hookProps: Record<string, Record<string, string>>;\n}\n\nexport const WIRING_RULES: WiringRule[] = [\n {\n pair: ['filter-bar', 'data-table'],\n signals: [\n { name: 'pageSearch', init: \"''\", hookType: 'search' },\n { name: 'pageStatus', init: \"'all'\", hookType: 'filter' },\n ],\n props: {\n 'filter-bar': { onSearch: 'setPageSearch', onCategory: 'setPageStatus' },\n 'data-table': { search: 'pageSearch', status: 'pageStatus' },\n },\n hookProps: {\n 'filter-bar': { search: 'search', filters: 'filters' },\n 'data-table': { search: 'search', filters: 'filters' },\n },\n },\n {\n pair: ['filter-bar', 'activity-feed'],\n signals: [\n { name: 'pageSearch', init: \"''\", hookType: 'search' },\n { name: 'pageView', init: \"'all'\", hookType: 'filter' },\n ],\n props: {\n 'filter-bar': { onSearch: 'setPageSearch', onView: 'setPageView' },\n 'activity-feed': { search: 'pageSearch', view: 'pageView' },\n },\n hookProps: {\n 'filter-bar': { search: 'search', filters: 'filters' },\n 'activity-feed': { search: 'search', filters: 'filters' },\n },\n },\n {\n pair: ['filter-bar', 'card-grid'],\n signals: [\n { name: 'pageSearch', init: \"''\", hookType: 'search' },\n ],\n props: {\n 'filter-bar': { onSearch: 'setPageSearch' },\n 'card-grid': { search: 'pageSearch' },\n },\n hookProps: {\n 'filter-bar': { search: 'search' },\n 'card-grid': { search: 'search' },\n },\n },\n];\n\nfunction getPatternId(item: LayoutItem): string | null {\n if (typeof item === 'string') return item;\n if ('pattern' in item) return (item as PatternRef).pattern;\n return null;\n}\n\nexport function detectWirings(layout: LayoutItem[]): WiringResult[] {\n const patternIds = layout.map(getPatternId).filter((id): id is string => id !== null);\n const results: WiringResult[] = [];\n for (const rule of WIRING_RULES) {\n const [a, b] = rule.pair;\n if (patternIds.includes(a) && patternIds.includes(b)) {\n results.push({ rule, signals: rule.signals, props: rule.props, hookProps: rule.hookProps });\n }\n }\n return results;\n}\n","export interface RegistryClientOptions {\n baseUrl?: string;\n cacheDir?: string;\n cacheTtl?: number;\n}\n\nexport interface SearchResult {\n id: string;\n type: string;\n name: string;\n description: string;\n version: string;\n tags: string[];\n}\n\nexport interface RegistryClient {\n search(query: string, type?: string): Promise<SearchResult[]>;\n fetch(type: string, id: string, version?: string): Promise<unknown>;\n}\n\nexport function createRegistryClient(options: RegistryClientOptions = {}): RegistryClient {\n const baseUrl = options.baseUrl ?? 'https://decantr-registry.fly.dev/v1';\n return {\n async search(query: string, type?: string): Promise<SearchResult[]> {\n const params = new URLSearchParams({ q: query });\n if (type) params.set('type', type);\n const res = await fetch(`${baseUrl}/search?${params}`);\n if (!res.ok) return [];\n return res.json() as Promise<SearchResult[]>;\n },\n async fetch(type: string, id: string, version?: string): Promise<unknown> {\n const url = version ? `${baseUrl}/content/${type}/${id}/${version}` : `${baseUrl}/content/${type}/${id}`;\n const res = await fetch(url);\n if (!res.ok) return null;\n return res.json();\n },\n };\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,YAAY;AAoBrB,IAAM,YAAyC;AAAA,EAC7C,SAAS;AAAA,EACT,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,WAAW;AACb;AAEA,eAAe,YAAe,UAAqC;AACjE,MAAI;AACF,UAAM,UAAU,MAAM,SAAS,UAAU,OAAO;AAChD,WAAO,KAAK,MAAM,OAAO;AAAA,EAC3B,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,eAAe,SAA2C;AACxE,QAAM,EAAE,aAAa,gBAAgB,CAAC,EAAE,IAAI;AAC5C,SAAO;AAAA,IACL,MAAM,QAA+B,MAAS,IAA4D;AACxG,YAAM,MAAM,UAAU,IAAI;AAC1B,YAAM,WAAW,GAAG,EAAE;AACtB,iBAAW,gBAAgB,eAAe;AACxC,cAAM,WAAW,KAAK,cAAc,KAAK,QAAQ;AACjD,cAAM,OAAO,MAAM,YAA2B,QAAQ;AACtD,YAAI,KAAM,QAAO,EAAE,MAAM,QAAQ,SAAS,MAAM,SAAS;AAAA,MAC3D;AACA,YAAM,WAAW,KAAK,aAAa,KAAK,QAAQ;AAChD,YAAM,WAAW,MAAM,YAA2B,QAAQ;AAC1D,UAAI,SAAU,QAAO,EAAE,MAAM,UAAU,QAAQ,QAAQ,MAAM,SAAS;AACtE,aAAO;AAAA,IACT;AAAA,EACF;AACF;;;AC/CO,SAAS,qBACd,SACA,gBACA,sBACgB;AAChB,QAAM,UAAU,QAAQ;AACxB,QAAM,aAAa,OAAO,KAAK,OAAO,EAAE,SAAS;AAEjD,MAAI,CAAC,YAAY;AACf,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,Q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AwC;AAClE,YAAM,SAAS,IAAI,gBAAgB,EAAE,GAAG,MAAM,CAAC;AAC/C,UAAI,KAAM,QAAO,IAAI,QAAQ,IAAI;AACjC,YAAM,MAAM,MAAM,MAAM,GAAG,OAAO,WAAW,MAAM,EAAE;AACrD,UAAI,CAAC,IAAI,GAAI,QAAO,CAAC;AACrB,aAAO,IAAI,KAAK;AAAA,IAClB;AAAA,IACA,MAAM,MAAM,MAAc,IAAY,SAAoC;AACxE,YAAM,MAAM,UAAU,GAAG,OAAO,YAAY,IAAI,IAAI,EAAE,IAAI,OAAO,KAAK,GAAG,OAAO,YAAY,IAAI,IAAI,EAAE;AACtG,YAAM,MAAM,MAAM,MAAM,GAAG;AAC3B,UAAI,CAAC,IAAI,GAAI,QAAO;AACpB,aAAO,IAAI,KAAK;AAAA,IAClB;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/resolver.ts","../src/pattern.ts","../src/wiring.ts","../src/api-client.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport type { Pattern, Archetype, Theme, Blueprint, Shell, ContentType, ResolvedContent } from './types.js';\n\ntype ContentMap = {\n pattern: Pattern;\n archetype: Archetype;\n theme: Theme;\n blueprint: Blueprint;\n shell: Shell;\n};\n\nexport interface ResolverOptions {\n contentRoot: string;\n overridePaths?: string[];\n}\n\nexport interface ContentResolver {\n resolve<T extends ContentType>(type: T, id: string): Promise<ResolvedContent<ContentMap[T]> | null>;\n}\n\nconst TYPE_DIRS: Record<ContentType, string> = {\n pattern: 'patterns',\n archetype: 'archetypes',\n theme: 'themes',\n blueprint: 'blueprints',\n shell: 'shells',\n};\n\nasync function tryLoadJson<T>(filePath: string): Promise<T | null> {\n try {\n const content = await readFile(filePath, 'utf-8');\n return JSON.parse(content) as T;\n } catch {\n return null;\n }\n}\n\nexport function createResolver(options: ResolverOptions): ContentResolver {\n const { contentRoot, overridePaths = [] } = options;\n return {\n async resolve<T extends ContentType>(type: T, id: string): Promise<ResolvedContent<ContentMap[T]> | null> {\n const dir = TYPE_DIRS[type];\n const fileName = `${id}.json`;\n for (const overridePath of overridePaths) {\n const filePath = join(overridePath, dir, fileName);\n const item = await tryLoadJson<ContentMap[T]>(filePath);\n if (item) return { item, source: 'local', path: filePath };\n }\n // Check main content directory\n const mainPath = join(contentRoot, dir, fileName);\n const mainItem = await tryLoadJson<ContentMap[T]>(mainPath);\n if (mainItem) return { item: mainItem, source: 'core', path: mainPath };\n\n // Check content/core/{type}/ as fallback\n const corePath = join(contentRoot, 'core', dir, fileName);\n const coreItem = await tryLoadJson<ContentMap[T]>(corePath);\n if (coreItem) return { item: coreItem, source: 'core', path: corePath };\n\n return null;\n },\n };\n}\n","import type { Pattern, PatternPreset } from './types.js';\n\nexport interface ResolvedPreset {\n preset: string;\n layout: PatternPreset['layout'];\n code: PatternPreset['code'];\n}\n\nexport function resolvePatternPreset(\n pattern: Pattern,\n explicitPreset?: string,\n themeDefaultPresets?: Record<string, string>,\n): ResolvedPreset {\n const presets = pattern.presets;\n const hasPresets = Object.keys(presets).length > 0;\n\n if (!hasPresets) {\n return {\n preset: '',\n layout: { layout: 'row', atoms: '' },\n code: pattern.code ?? { imports: '', example: '' },\n };\n }\n\n let presetName = explicitPreset;\n if (presetName && !presets[presetName]) presetName = undefined;\n if (!presetName && themeDefaultPresets?.[pattern.id]) {\n const themeName = themeDefaultPresets[pattern.id];\n if (presets[themeName]) presetName = themeName;\n }\n if (!presetName) presetName = pattern.default_preset;\n if (!presetName || !presets[presetName]) presetName = Object.keys(presets)[0];\n\n const preset = presets[presetName];\n return { preset: presetName, layout: preset.layout, code: preset.code };\n}\n","import type { LayoutItem, PatternRef } from '@decantr/essence-spec';\nimport type { PatternIO } from './types.js';\n\n// AUTO: hookType classifies each signal for custom hook generation\nexport type HookType = 'search' | 'filter' | 'selection' | 'sort';\n\nexport interface WiringSignal { name: string; init: string; hookType: HookType }\n\nexport interface WiringRule {\n pair: [string, string];\n signals: WiringSignal[];\n props: Record<string, Record<string, string>>;\n // AUTO: hookProps maps pattern IDs to hook variable names passed as props\n hookProps: Record<string, Record<string, string>>;\n}\n\nexport interface WiringResult {\n rule: WiringRule;\n signals: WiringSignal[];\n props: Record<string, Record<string, string>>;\n hookProps: Record<string, Record<string, string>>;\n}\n\n/**\n * IO declaration for a pattern, used by the data-driven wiring system.\n */\nexport interface PatternIOEntry {\n id: string;\n io: PatternIO;\n}\n\n/**\n * A dynamically derived wiring edge between two patterns based on shared IO signals.\n */\nexport interface IOWiringEdge {\n producer: string;\n consumer: string;\n signals: string[];\n}\n\nexport const WIRING_RULES: WiringRule[] = [\n {\n pair: ['filter-bar', 'data-table'],\n signals: [\n { name: 'pageSearch', init: \"''\", hookType: 'search' },\n { name: 'pageStatus', init: \"'all'\", hookType: 'filter' },\n ],\n props: {\n 'filter-bar': { onSearch: 'setPageSearch', onCategory: 'setPageStatus' },\n 'data-table': { search: 'pageSearch', status: 'pageStatus' },\n },\n hookProps: {\n 'filter-bar': { search: 'search', filters: 'filters' },\n 'data-table': { search: 'search', filters: 'filters' },\n },\n },\n {\n pair: ['filter-bar', 'activity-feed'],\n signals: [\n { name: 'pageSearch', init: \"''\", hookType: 'search' },\n { name: 'pageView', init: \"'all'\", hookType: 'filter' },\n ],\n props: {\n 'filter-bar': { onSearch: 'setPageSearch', onView: 'setPageView' },\n 'activity-feed': { search: 'pageSearch', view: 'pageView' },\n },\n hookProps: {\n 'filter-bar': { search: 'search', filters: 'filters' },\n 'activity-feed': { search: 'search', filters: 'filters' },\n },\n },\n {\n pair: ['filter-bar', 'card-grid'],\n signals: [\n { name: 'pageSearch', init: \"''\", hookType: 'search' },\n ],\n props: {\n 'filter-bar': { onSearch: 'setPageSearch' },\n 'card-grid': { search: 'pageSearch' },\n },\n hookProps: {\n 'filter-bar': { search: 'search' },\n 'card-grid': { search: 'search' },\n },\n },\n];\n\nfunction getPatternId(item: LayoutItem): string | null {\n if (typeof item === 'string') return item;\n if ('pattern' in item) return (item as PatternRef).pattern;\n return null;\n}\n\n/**\n * Derive wiring edges from pattern IO declarations.\n * If pattern A produces signal X and pattern B consumes signal X, an edge is created.\n * Only patterns present in the layout are considered.\n */\nexport function deriveIOWirings(\n layoutIds: string[],\n patternIOMap: Map<string, PatternIO>,\n): IOWiringEdge[] {\n const edges: IOWiringEdge[] = [];\n const layoutSet = new Set(layoutIds);\n\n for (const producerId of layoutIds) {\n const producerIO = patternIOMap.get(producerId);\n if (!producerIO?.produces?.length) continue;\n\n for (const consumerId of layoutIds) {\n if (producerId === consumerId) continue;\n if (!layoutSet.has(consumerId)) continue;\n const consumerIO = patternIOMap.get(consumerId);\n if (!consumerIO?.consumes?.length) continue;\n\n const shared = producerIO.produces.filter(\n (signal) => consumerIO.consumes!.includes(signal),\n );\n if (shared.length > 0) {\n edges.push({ producer: producerId, consumer: consumerId, signals: shared });\n }\n }\n }\n\n return edges;\n}\n\n/**\n * Build a PatternIO map from an array of PatternIOEntry objects.\n */\nexport function buildIOMap(entries: PatternIOEntry[]): Map<string, PatternIO> {\n const map = new Map<string, PatternIO>();\n for (const entry of entries) {\n map.set(entry.id, entry.io);\n }\n return map;\n}\n\n/**\n * Detect wirings from a layout. Uses hardcoded WIRING_RULES for detailed\n * signal/prop information. When a patternIOMap is provided, also derives\n * IO-based wirings and merges them (hardcoded rules take precedence for\n * pairs they cover).\n */\nexport function detectWirings(\n layout: LayoutItem[],\n patternIOMap?: Map<string, PatternIO>,\n): WiringResult[] {\n const patternIds = layout.map(getPatternId).filter((id): id is string => id !== null);\n const results: WiringResult[] = [];\n const coveredPairs = new Set<string>();\n\n // Apply hardcoded rules first (these have detailed signal/prop info)\n for (const rule of WIRING_RULES) {\n const [a, b] = rule.pair;\n if (patternIds.includes(a) && patternIds.includes(b)) {\n results.push({ rule, signals: rule.signals, props: rule.props, hookProps: rule.hookProps });\n coveredPairs.add(`${a}:${b}`);\n coveredPairs.add(`${b}:${a}`);\n }\n }\n\n // If IO map provided, derive additional wirings from IO declarations\n if (patternIOMap) {\n const ioEdges = deriveIOWirings(patternIds, patternIOMap);\n for (const edge of ioEdges) {\n const pairKey = `${edge.producer}:${edge.consumer}`;\n if (coveredPairs.has(pairKey)) continue;\n coveredPairs.add(pairKey);\n\n // Generate a synthetic WiringRule from IO signals\n const signals: WiringSignal[] = edge.signals.map((sig) => {\n const camel = toCamelCase(sig);\n return {\n name: `page${capitalize(camel)}`,\n init: \"''\",\n hookType: classifySignal(sig),\n };\n });\n\n const producerProps: Record<string, string> = {};\n const consumerProps: Record<string, string> = {};\n const producerHookProps: Record<string, string> = {};\n const consumerHookProps: Record<string, string> = {};\n\n for (const sig of edge.signals) {\n const camel = toCamelCase(sig);\n const stateName = `page${capitalize(camel)}`;\n const setterName = `set${capitalize(stateName)}`;\n producerProps[`on${capitalize(camel)}`] = setterName;\n consumerProps[sig] = stateName;\n producerHookProps[sig] = sig;\n consumerHookProps[sig] = sig;\n }\n\n const rule: WiringRule = {\n pair: [edge.producer, edge.consumer],\n signals,\n props: { [edge.producer]: producerProps, [edge.consumer]: consumerProps },\n hookProps: { [edge.producer]: producerHookProps, [edge.consumer]: consumerHookProps },\n };\n\n results.push({ rule, signals, props: rule.props, hookProps: rule.hookProps });\n }\n }\n\n return results;\n}\n\n/**\n * Convert a kebab-case string to camelCase.\n */\nfunction toCamelCase(str: string): string {\n return str.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase());\n}\n\n/**\n * Capitalize the first letter of a string.\n */\nfunction capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\n/**\n * Classify a signal name into a HookType for code generation.\n */\nfunction classifySignal(signal: string): HookType {\n const normalized = toCamelCase(signal);\n if (normalized === 'search') return 'search';\n if (normalized === 'selection') return 'selection';\n if (normalized === 'sort') return 'sort';\n return 'filter';\n}\n","import type {\n Pattern,\n Archetype,\n Theme,\n Blueprint,\n Shell,\n ApiContentType,\n ContentListResponse,\n ContentItem,\n PublishPayload,\n PublishResponse,\n SearchParams,\n SearchResponse,\n UserProfile,\n} from './types.js';\n\nconst DEFAULT_BASE_URL = 'https://api.decantr.ai/v1';\nconst DEFAULT_TIMEOUT_MS = 30000;\nconst DEFAULT_CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutes\n\ninterface CacheEntry<T> {\n data: T;\n timestamp: number;\n}\n\nexport interface RegistryAPIClientOptions {\n baseUrl?: string;\n apiKey?: string;\n timeoutMs?: number;\n cacheTtlMs?: number;\n}\n\nexport class RegistryAPIClient {\n private baseUrl: string;\n private apiKey: string | undefined;\n private timeoutMs: number;\n private cacheTtlMs: number;\n private cache = new Map<string, CacheEntry<unknown>>();\n\n constructor(options: RegistryAPIClientOptions = {}) {\n this.baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;\n this.apiKey = options.apiKey;\n this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n this.cacheTtlMs = options.cacheTtlMs ?? DEFAULT_CACHE_TTL_MS;\n }\n\n // ── HTTP helpers ──\n\n private buildHeaders(): Record<string, string> {\n const headers: Record<string, string> = {\n 'Accept': 'application/json',\n };\n if (this.apiKey) {\n headers['X-API-Key'] = this.apiKey;\n }\n return headers;\n }\n\n private async fetchWithTimeout(url: string, init?: RequestInit): Promise<Response> {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), this.timeoutMs);\n try {\n return await fetch(url, { ...init, signal: controller.signal });\n } finally {\n clearTimeout(timeout);\n }\n }\n\n private async request<T>(path: string, init?: RequestInit): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n const response = await this.fetchWithTimeout(url, {\n ...init,\n headers: { ...this.buildHeaders(), ...init?.headers },\n });\n if (!response.ok) {\n const body = await response.text().catch(() => '');\n throw new Error(`API ${response.status}: ${body || response.statusText}`);\n }\n return response.json() as Promise<T>;\n }\n\n // ── Cache helpers ──\n\n private getCached<T>(key: string): T | null {\n const entry = this.cache.get(key) as CacheEntry<T> | undefined;\n if (!entry) return null;\n if (Date.now() - entry.timestamp > this.cacheTtlMs) {\n this.cache.delete(key);\n return null;\n }\n return entry.data;\n }\n\n private setCache<T>(key: string, data: T): void {\n this.cache.set(key, { data, timestamp: Date.now() });\n }\n\n clearCache(): void {\n this.cache.clear();\n }\n\n // ── Health ──\n\n async checkHealth(): Promise<boolean> {\n try {\n const url = this.baseUrl.replace(/\\/v1$/, '/health');\n const response = await this.fetchWithTimeout(url);\n return response.ok;\n } catch {\n return false;\n }\n }\n\n // ── Content fetching (public) ──\n\n async listContent<T = Record<string, unknown>>(\n type: ApiContentType,\n params?: { namespace?: string; limit?: number; offset?: number }\n ): Promise<ContentListResponse<T>> {\n const cacheKey = `list:${type}:${JSON.stringify(params ?? {})}`;\n const cached = this.getCached<ContentListResponse<T>>(cacheKey);\n if (cached) return cached;\n\n const searchParams = new URLSearchParams();\n if (params?.namespace) searchParams.set('namespace', params.namespace);\n if (params?.limit) searchParams.set('limit', String(params.limit));\n if (params?.offset) searchParams.set('offset', String(params.offset));\n\n const query = searchParams.toString();\n const path = `/${type}${query ? `?${query}` : ''}`;\n const result = await this.request<ContentListResponse<T>>(path);\n this.setCache(cacheKey, result);\n return result;\n }\n\n async getContent<T = Record<string, unknown>>(\n type: ApiContentType,\n namespace: string,\n slug: string\n ): Promise<T> {\n const cacheKey = `get:${type}:${namespace}:${slug}`;\n const cached = this.getCached<T>(cacheKey);\n if (cached) return cached;\n\n const raw = await this.request<T>(`/${type}/${namespace}/${slug}`);\n // API returns { id, type, slug, data: {...actual content...} } — unwrap\n const unwrapped = ((raw as any).data ?? raw) as T;\n this.setCache(cacheKey, unwrapped);\n return unwrapped;\n }\n\n // ── Typed convenience methods ──\n\n async getPattern(namespace: string, slug: string): Promise<Pattern> {\n return this.getContent<Pattern>('patterns', namespace, slug);\n }\n\n async getArchetype(namespace: string, slug: string): Promise<Archetype> {\n return this.getContent<Archetype>('archetypes', namespace, slug);\n }\n\n async getTheme(namespace: string, slug: string): Promise<Theme> {\n return this.getContent<Theme>('themes', namespace, slug);\n }\n\n async getBlueprint(namespace: string, slug: string): Promise<Blueprint> {\n return this.getContent<Blueprint>('blueprints', namespace, slug);\n }\n\n async getShell(namespace: string, slug: string): Promise<Shell> {\n return this.getContent<Shell>('shells', namespace, slug);\n }\n\n // ── Search ──\n\n async search(params: SearchParams): Promise<SearchResponse> {\n const searchParams = new URLSearchParams({ q: params.q });\n if (params.type) searchParams.set('type', params.type);\n if (params.namespace) searchParams.set('namespace', params.namespace);\n if (params.limit) searchParams.set('limit', String(params.limit));\n if (params.offset) searchParams.set('offset', String(params.offset));\n\n return this.request<SearchResponse>(`/search?${searchParams}`);\n }\n\n // ── Authenticated endpoints ──\n\n async getProfile(): Promise<UserProfile> {\n return this.request<UserProfile>('/me');\n }\n\n async publishContent(payload: PublishPayload): Promise<PublishResponse> {\n return this.request<PublishResponse>('/content', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(payload),\n });\n }\n\n async getMyContent(): Promise<ContentListResponse<ContentItem>> {\n return this.request<ContentListResponse<ContentItem>>('/my/content');\n }\n\n // ── Schema ──\n\n async getSchema(name: string = 'essence.v3.json'): Promise<Record<string, unknown>> {\n return this.request<Record<string, unknown>>(`/schema/${name}`);\n }\n}\n\n// ── Lightweight registry client (merged from client.ts) ──\n\nexport interface RegistryClientOptions {\n baseUrl?: string;\n}\n\nexport interface SearchResult {\n id: string;\n type: string;\n name: string;\n description: string;\n version: string;\n tags: string[];\n}\n\nexport interface RegistryClient {\n search(query: string, type?: string): Promise<SearchResult[]>;\n fetch(type: string, id: string, version?: string): Promise<unknown>;\n}\n\nexport function createRegistryClient(options: RegistryClientOptions = {}): RegistryClient {\n const baseUrl = options.baseUrl ?? 'https://api.decantr.ai/v1';\n return {\n async search(query: string, type?: string): Promise<SearchResult[]> {\n const params = new URLSearchParams({ q: query });\n if (type) params.set('type', type);\n const res = await fetch(`${baseUrl}/search?${params}`);\n if (!res.ok) return [];\n const data = await res.json() as { results?: SearchResult[]; total?: number } | SearchResult[];\n // API returns { total, results } wrapper\n if (Array.isArray(data)) return data;\n return (data as { results: SearchResult[] }).results ?? [];\n },\n async fetch(type: string, id: string, version?: string): Promise<unknown> {\n const url = version ? `${baseUrl}/content/${type}/${id}/${version}` : `${baseUrl}/content/${type}/${id}`;\n const res = await fetch(url);\n if (!res.ok) return null;\n return res.json();\n },\n };\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,YAAY;AAoBrB,IAAM,YAAyC;AAAA,EAC7C,SAAS;AAAA,EACT,WAAW;AAAA,EACX,OAAO;AAAA,EACP,WAAW;AAAA,EACX,OAAO;AACT;AAEA,eAAe,YAAe,UAAqC;AACjE,MAAI;AACF,UAAM,UAAU,MAAM,SAAS,UAAU,OAAO;AAChD,WAAO,KAAK,MAAM,OAAO;AAAA,EAC3B,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,eAAe,SAA2C;AACxE,QAAM,EAAE,aAAa,gBAAgB,CAAC,EAAE,IAAI;AAC5C,SAAO;AAAA,IACL,MAAM,QAA+B,MAAS,IAA4D;AACxG,YAAM,MAAM,UAAU,IAAI;AAC1B,YAAM,WAAW,GAAG,EAAE;AACtB,iBAAW,gBAAgB,eAAe;AACxC,cAAM,WAAW,KAAK,cAAc,KAAK,QAAQ;AACjD,cAAM,OAAO,MAAM,YAA2B,QAAQ;AACtD,YAAI,KAAM,QAAO,EAAE,MAAM,QAAQ,SAAS,MAAM,SAAS;AAAA,MAC3D;AAEA,YAAM,WAAW,KAAK,aAAa,KAAK,QAAQ;AAChD,YAAM,WAAW,MAAM,YAA2B,QAAQ;AAC1D,UAAI,SAAU,QAAO,EAAE,MAAM,UAAU,QAAQ,QAAQ,MAAM,SAAS;AAGtE,YAAM,WAAW,KAAK,aAAa,QAAQ,KAAK,QAAQ;AACxD,YAAM,WAAW,MAAM,YAA2B,QAAQ;AAC1D,UAAI,SAAU,QAAO,EAAE,MAAM,UAAU,QAAQ,QAAQ,MAAM,SAAS;AAEtE,aAAO;AAAA,IAC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+1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decantr/registry",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.11",
|
|
4
4
|
"description": "Registry format, content resolver, and wiring rules for Decantr",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -18,16 +18,18 @@
|
|
|
18
18
|
"types": "./dist/index.d.ts"
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
-
"files": [
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
22
24
|
"publishConfig": {
|
|
23
25
|
"access": "public"
|
|
24
26
|
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@decantr/essence-spec": "1.0.0-beta.11"
|
|
29
|
+
},
|
|
25
30
|
"scripts": {
|
|
26
31
|
"build": "tsup",
|
|
27
32
|
"test": "vitest run",
|
|
28
33
|
"test:watch": "vitest"
|
|
29
|
-
},
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"@decantr/essence-spec": "workspace:*"
|
|
32
34
|
}
|
|
33
|
-
}
|
|
35
|
+
}
|