@hale-bopp/valentino-engine 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/bin/valentino.js +1 -1
- package/dist/core/editor.d.ts +80 -0
- package/dist/core/editor.d.ts.map +1 -0
- package/dist/core/editor.js +421 -0
- package/dist/core/editor.js.map +1 -0
- package/dist/core/gallery.d.ts +53 -0
- package/dist/core/gallery.d.ts.map +1 -0
- package/dist/core/gallery.js +123 -0
- package/dist/core/gallery.js.map +1 -0
- package/dist/core/gallery.test.d.ts +2 -0
- package/dist/core/gallery.test.d.ts.map +1 -0
- package/dist/core/gallery.test.js +127 -0
- package/dist/core/gallery.test.js.map +1 -0
- package/dist/core/page-generator.d.ts +85 -0
- package/dist/core/page-generator.d.ts.map +1 -0
- package/dist/core/page-generator.js +353 -0
- package/dist/core/page-generator.js.map +1 -0
- package/dist/core/page-generator.test.d.ts +2 -0
- package/dist/core/page-generator.test.d.ts.map +1 -0
- package/dist/core/page-generator.test.js +138 -0
- package/dist/core/page-generator.test.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template Gallery — Pure helpers for enumerating catalog entries.
|
|
3
|
+
* PBI #610 — Provides gallery-ready metadata from ValentinoCatalogV1.
|
|
4
|
+
*
|
|
5
|
+
* No DOM, no fetch — pure functions only.
|
|
6
|
+
* The consumer (portal) renders the gallery UI.
|
|
7
|
+
*/
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Helpers
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
/** Convert a kebab-case or camelCase ID to a human-readable name */
|
|
12
|
+
function humanize(id) {
|
|
13
|
+
return id
|
|
14
|
+
.replace(/[-_]/g, ' ')
|
|
15
|
+
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
16
|
+
.replace(/\b\w/g, c => c.toUpperCase())
|
|
17
|
+
.trim();
|
|
18
|
+
}
|
|
19
|
+
function uniqueSectionTypes(sections) {
|
|
20
|
+
return [...new Set(sections.map(s => s.type))];
|
|
21
|
+
}
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// Entry builders
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
function blueprintToEntry(id, entry) {
|
|
26
|
+
const spec = entry.spec;
|
|
27
|
+
return {
|
|
28
|
+
id,
|
|
29
|
+
kind: 'blueprint',
|
|
30
|
+
name: humanize(id),
|
|
31
|
+
description: `Blueprint: ${spec.sections.length} sections, profile ${spec.profile || 'generic'}`,
|
|
32
|
+
profile: spec.profile,
|
|
33
|
+
themeId: spec.themeId,
|
|
34
|
+
sectionCount: spec.sections.length,
|
|
35
|
+
sectionTypes: uniqueSectionTypes(spec.sections),
|
|
36
|
+
governanceTier: entry.governance?.tier,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function templateToEntry(id, entry) {
|
|
40
|
+
return {
|
|
41
|
+
id,
|
|
42
|
+
kind: 'template',
|
|
43
|
+
name: humanize(id),
|
|
44
|
+
description: `Template: profile ${entry.page?.profile || 'generic'}`,
|
|
45
|
+
profile: entry.page?.profile,
|
|
46
|
+
themeId: entry.page?.themeId,
|
|
47
|
+
sectionCount: 0,
|
|
48
|
+
sectionTypes: [],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function manifestPageToEntry(page, pageSpec) {
|
|
52
|
+
const sections = pageSpec?.sections || [];
|
|
53
|
+
return {
|
|
54
|
+
id: page.id,
|
|
55
|
+
kind: 'page',
|
|
56
|
+
name: humanize(page.id),
|
|
57
|
+
description: `Page: ${page.route}`,
|
|
58
|
+
profile: pageSpec?.profile,
|
|
59
|
+
themeId: pageSpec?.themeId,
|
|
60
|
+
sectionCount: sections.length,
|
|
61
|
+
sectionTypes: uniqueSectionTypes(sections),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
// Public API
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
/**
|
|
68
|
+
* List all gallery entries from a catalog.
|
|
69
|
+
* Returns blueprints first, then templates.
|
|
70
|
+
*/
|
|
71
|
+
export function listCatalogEntries(catalog) {
|
|
72
|
+
const entries = [];
|
|
73
|
+
for (const [id, entry] of Object.entries(catalog.pageBlueprints)) {
|
|
74
|
+
entries.push(blueprintToEntry(id, entry));
|
|
75
|
+
}
|
|
76
|
+
for (const [id, entry] of Object.entries(catalog.templates)) {
|
|
77
|
+
entries.push(templateToEntry(id, entry));
|
|
78
|
+
}
|
|
79
|
+
return entries;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* List gallery entries from a pages manifest (existing pages as starting points).
|
|
83
|
+
* Optionally provide a specs map (pageId -> PageSpecV1) for richer metadata.
|
|
84
|
+
*/
|
|
85
|
+
export function listPageEntries(manifest, specs) {
|
|
86
|
+
return manifest.pages
|
|
87
|
+
.filter(p => p.status === 'published')
|
|
88
|
+
.map(p => manifestPageToEntry(p, specs?.get(p.id)));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* List all gallery entries: catalog + manifest pages.
|
|
92
|
+
*/
|
|
93
|
+
export function listAllGalleryEntries(catalog, manifest, specs) {
|
|
94
|
+
const entries = listCatalogEntries(catalog);
|
|
95
|
+
if (manifest) {
|
|
96
|
+
entries.push(...listPageEntries(manifest, specs));
|
|
97
|
+
}
|
|
98
|
+
return entries;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Filter gallery entries by criteria.
|
|
102
|
+
*/
|
|
103
|
+
export function filterGalleryEntries(entries, filter) {
|
|
104
|
+
return entries.filter(entry => {
|
|
105
|
+
if (filter.kind) {
|
|
106
|
+
const kinds = Array.isArray(filter.kind) ? filter.kind : [filter.kind];
|
|
107
|
+
if (!kinds.includes(entry.kind))
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
if (filter.profile && entry.profile !== filter.profile)
|
|
111
|
+
return false;
|
|
112
|
+
if (filter.sectionType && !entry.sectionTypes.includes(filter.sectionType))
|
|
113
|
+
return false;
|
|
114
|
+
if (filter.search) {
|
|
115
|
+
const q = filter.search.toLowerCase();
|
|
116
|
+
if (!entry.name.toLowerCase().includes(q) && !entry.description.toLowerCase().includes(q)) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=gallery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gallery.js","sourceRoot":"","sources":["../../src/core/gallery.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA6CH,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,oEAAoE;AACpE,SAAS,QAAQ,CAAC,EAAU;IACxB,OAAO,EAAE;SACJ,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;SACnC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;SACtC,IAAI,EAAE,CAAC;AAChB,CAAC;AAED,SAAS,kBAAkB,CAAC,QAAuB;IAC/C,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E,SAAS,gBAAgB,CAAC,EAAU,EAAE,KAAkC;IACpE,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACxB,OAAO;QACH,EAAE;QACF,IAAI,EAAE,WAAW;QACjB,IAAI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oBAAoB,CAChC,OAAuB,EACvB,MAAqB;IAErB,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;QAC1B,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YACd,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACvE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;gBAAE,OAAO,KAAK,CAAC;QAClD,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,KAAK,MAAM,CAAC,OAAO;YAAE,OAAO,KAAK,CAAC;QACrE,IAAI,MAAM,CAAC,WAAW,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC;YAAE,OAAO,KAAK,CAAC;QACzF,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YACtC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxF,OAAO,KAAK,CAAC;YACjB,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gallery.test.d.ts","sourceRoot":"","sources":["../../src/core/gallery.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { listCatalogEntries, listPageEntries, listAllGalleryEntries, filterGalleryEntries } from './gallery.js';
|
|
3
|
+
const catalog = {
|
|
4
|
+
version: '1',
|
|
5
|
+
templates: {
|
|
6
|
+
'product-tpl': { page: { profile: 'product-surface', themeId: 'dark' } },
|
|
7
|
+
},
|
|
8
|
+
sectionPresets: {},
|
|
9
|
+
transitionProfiles: {},
|
|
10
|
+
pageBlueprints: {
|
|
11
|
+
'landing-bp': {
|
|
12
|
+
spec: {
|
|
13
|
+
version: '1',
|
|
14
|
+
id: 'landing-bp',
|
|
15
|
+
profile: 'home-signature',
|
|
16
|
+
sections: [
|
|
17
|
+
{ type: 'hero', titleKey: 'bp.hero.title' },
|
|
18
|
+
{ type: 'cards', variant: 'catalog', items: [{ titleKey: 'bp.card1' }] },
|
|
19
|
+
{ type: 'cta', titleKey: 'bp.cta.title' },
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
'about-bp': {
|
|
24
|
+
spec: {
|
|
25
|
+
version: '1',
|
|
26
|
+
id: 'about-bp',
|
|
27
|
+
profile: 'reading-manifesto',
|
|
28
|
+
sections: [
|
|
29
|
+
{ type: 'hero', titleKey: 'about.hero.title' },
|
|
30
|
+
{ type: 'manifesto', contentPrefix: 'about.manifesto' },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
governance: { tier: 'standard' },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
const manifest = {
|
|
38
|
+
version: '1',
|
|
39
|
+
pages: [
|
|
40
|
+
{ id: 'home', route: '/', spec: 'home.json', status: 'published' },
|
|
41
|
+
{ id: 'draft-page', route: '/draft', spec: 'draft.json', status: 'draft' },
|
|
42
|
+
{ id: 'about', route: '/about', spec: 'about.json', status: 'published' },
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
describe('listCatalogEntries', () => {
|
|
46
|
+
it('returns blueprints and templates', () => {
|
|
47
|
+
const entries = listCatalogEntries(catalog);
|
|
48
|
+
expect(entries).toHaveLength(3); // 2 blueprints + 1 template
|
|
49
|
+
});
|
|
50
|
+
it('blueprints have section metadata', () => {
|
|
51
|
+
const entries = listCatalogEntries(catalog);
|
|
52
|
+
const landing = entries.find(e => e.id === 'landing-bp');
|
|
53
|
+
expect(landing).toBeDefined();
|
|
54
|
+
expect(landing.kind).toBe('blueprint');
|
|
55
|
+
expect(landing.sectionCount).toBe(3);
|
|
56
|
+
expect(landing.sectionTypes).toContain('hero');
|
|
57
|
+
expect(landing.sectionTypes).toContain('cards');
|
|
58
|
+
expect(landing.sectionTypes).toContain('cta');
|
|
59
|
+
});
|
|
60
|
+
it('templates have kind template', () => {
|
|
61
|
+
const entries = listCatalogEntries(catalog);
|
|
62
|
+
const tpl = entries.find(e => e.id === 'product-tpl');
|
|
63
|
+
expect(tpl).toBeDefined();
|
|
64
|
+
expect(tpl.kind).toBe('template');
|
|
65
|
+
expect(tpl.profile).toBe('product-surface');
|
|
66
|
+
});
|
|
67
|
+
it('includes governance tier', () => {
|
|
68
|
+
const entries = listCatalogEntries(catalog);
|
|
69
|
+
const about = entries.find(e => e.id === 'about-bp');
|
|
70
|
+
expect(about.governanceTier).toBe('standard');
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
describe('listPageEntries', () => {
|
|
74
|
+
it('returns only published pages', () => {
|
|
75
|
+
const entries = listPageEntries(manifest);
|
|
76
|
+
expect(entries).toHaveLength(2);
|
|
77
|
+
expect(entries.map(e => e.id)).toContain('home');
|
|
78
|
+
expect(entries.map(e => e.id)).toContain('about');
|
|
79
|
+
expect(entries.map(e => e.id)).not.toContain('draft-page');
|
|
80
|
+
});
|
|
81
|
+
it('entries have kind page', () => {
|
|
82
|
+
const entries = listPageEntries(manifest);
|
|
83
|
+
expect(entries.every(e => e.kind === 'page')).toBe(true);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
describe('listAllGalleryEntries', () => {
|
|
87
|
+
it('combines catalog and manifest', () => {
|
|
88
|
+
const entries = listAllGalleryEntries(catalog, manifest);
|
|
89
|
+
expect(entries.length).toBe(5); // 2 bp + 1 tpl + 2 published pages
|
|
90
|
+
});
|
|
91
|
+
it('works with catalog only', () => {
|
|
92
|
+
const entries = listAllGalleryEntries(catalog);
|
|
93
|
+
expect(entries).toHaveLength(3);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
describe('filterGalleryEntries', () => {
|
|
97
|
+
const all = listAllGalleryEntries(catalog, manifest);
|
|
98
|
+
it('filters by kind', () => {
|
|
99
|
+
const blueprints = filterGalleryEntries(all, { kind: 'blueprint' });
|
|
100
|
+
expect(blueprints).toHaveLength(2);
|
|
101
|
+
expect(blueprints.every(e => e.kind === 'blueprint')).toBe(true);
|
|
102
|
+
});
|
|
103
|
+
it('filters by multiple kinds', () => {
|
|
104
|
+
const result = filterGalleryEntries(all, { kind: ['blueprint', 'template'] });
|
|
105
|
+
expect(result).toHaveLength(3);
|
|
106
|
+
});
|
|
107
|
+
it('filters by profile', () => {
|
|
108
|
+
const result = filterGalleryEntries(all, { profile: 'home-signature' });
|
|
109
|
+
expect(result.length).toBeGreaterThanOrEqual(1);
|
|
110
|
+
expect(result.every(e => e.profile === 'home-signature')).toBe(true);
|
|
111
|
+
});
|
|
112
|
+
it('filters by section type', () => {
|
|
113
|
+
const result = filterGalleryEntries(all, { sectionType: 'manifesto' });
|
|
114
|
+
expect(result.length).toBeGreaterThanOrEqual(1);
|
|
115
|
+
expect(result.every(e => e.sectionTypes.includes('manifesto'))).toBe(true);
|
|
116
|
+
});
|
|
117
|
+
it('filters by search text', () => {
|
|
118
|
+
const result = filterGalleryEntries(all, { search: 'landing' });
|
|
119
|
+
expect(result.length).toBeGreaterThanOrEqual(1);
|
|
120
|
+
});
|
|
121
|
+
it('combines filters', () => {
|
|
122
|
+
const result = filterGalleryEntries(all, { kind: 'blueprint', profile: 'home-signature' });
|
|
123
|
+
expect(result).toHaveLength(1);
|
|
124
|
+
expect(result[0].id).toBe('landing-bp');
|
|
125
|
+
});
|
|
126
|
+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CAAC;QACvE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;QAChD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;QAC9B,MAAM,MAAM,GAAG,oBAAoB,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;QAChE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;QACxB,MAAM,MAAM,GAAG,oBAAoB,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC;QAC3F,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Page Generator — Pure prompt-to-PageSpec engine.
|
|
3
|
+
* PBI #608 — Generates valid PageSpecV1 from natural language prompts.
|
|
4
|
+
*
|
|
5
|
+
* Two modes:
|
|
6
|
+
* - Local (rule-based): parses prompt, composes sections from templates. Always works, zero API.
|
|
7
|
+
* - LLM (callback): delegates to an external LLM via user-provided function, validates output.
|
|
8
|
+
*
|
|
9
|
+
* No fetch, no DOM, no LLM client — pure functions only.
|
|
10
|
+
* The consumer wires in the LLM integration (portal uses llm-client.mjs).
|
|
11
|
+
*/
|
|
12
|
+
import type { PageSpecV1, SectionSpec, PageProfileSpec, ValentinoCatalogV1 } from './types.js';
|
|
13
|
+
export type PageIntent = {
|
|
14
|
+
/** Detected page type */
|
|
15
|
+
pageType: 'landing' | 'product' | 'service' | 'about' | 'generic';
|
|
16
|
+
/** Detected profile mapping */
|
|
17
|
+
profile: PageProfileSpec;
|
|
18
|
+
/** Sections the user wants (in order) */
|
|
19
|
+
sectionIntents: SectionIntent[];
|
|
20
|
+
/** Extracted title (if any) */
|
|
21
|
+
title?: string;
|
|
22
|
+
/** Raw items/features mentioned */
|
|
23
|
+
items: string[];
|
|
24
|
+
/** Raw steps mentioned */
|
|
25
|
+
steps: string[];
|
|
26
|
+
};
|
|
27
|
+
export type SectionIntent = {
|
|
28
|
+
type: SectionSpec['type'];
|
|
29
|
+
/** Items specific to this section (e.g., card titles) */
|
|
30
|
+
items?: string[];
|
|
31
|
+
/** Steps specific to this section */
|
|
32
|
+
steps?: string[];
|
|
33
|
+
};
|
|
34
|
+
export type GeneratePageOptions = {
|
|
35
|
+
/** Page ID (required) */
|
|
36
|
+
id: string;
|
|
37
|
+
/** Optional catalog for blueprint resolution */
|
|
38
|
+
catalog?: ValentinoCatalogV1;
|
|
39
|
+
/** Optional LLM callback — receives prompt, returns raw PageSpecV1 JSON */
|
|
40
|
+
llm?: (prompt: string, context: LlmContext) => Promise<unknown>;
|
|
41
|
+
/** Optional blueprint ID to use as base */
|
|
42
|
+
blueprintId?: string;
|
|
43
|
+
};
|
|
44
|
+
export type LlmContext = {
|
|
45
|
+
intent: PageIntent;
|
|
46
|
+
sectionTypes: string[];
|
|
47
|
+
exampleSpec: PageSpecV1;
|
|
48
|
+
};
|
|
49
|
+
export type GeneratePageResult = {
|
|
50
|
+
spec: PageSpecV1;
|
|
51
|
+
mode: 'local' | 'llm';
|
|
52
|
+
intent: PageIntent;
|
|
53
|
+
warnings: string[];
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Parse a natural language prompt into a structured PageIntent.
|
|
57
|
+
*/
|
|
58
|
+
export declare function parsePrompt(prompt: string): PageIntent;
|
|
59
|
+
/**
|
|
60
|
+
* Generate a PageSpecV1 from a natural language prompt.
|
|
61
|
+
*
|
|
62
|
+
* If `options.llm` is provided, tries LLM first with automatic fallback to local.
|
|
63
|
+
* Without `options.llm`, uses rule-based local generation (always works).
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* // Local mode (no API needed)
|
|
68
|
+
* const result = await generatePageSpec(
|
|
69
|
+
* "Landing page per un ristorante con hero, 3 card e CTA",
|
|
70
|
+
* { id: 'restaurant-landing' }
|
|
71
|
+
* );
|
|
72
|
+
*
|
|
73
|
+
* // LLM mode (with fallback)
|
|
74
|
+
* const result = await generatePageSpec(
|
|
75
|
+
* "Landing page per un ristorante con hero, 3 card e CTA",
|
|
76
|
+
* { id: 'restaurant-landing', llm: myLlmFunction }
|
|
77
|
+
* );
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function generatePageSpec(prompt: string, options: GeneratePageOptions): Promise<GeneratePageResult>;
|
|
81
|
+
/**
|
|
82
|
+
* Synchronous local-only generation. Useful when you don't need LLM.
|
|
83
|
+
*/
|
|
84
|
+
export declare function generatePageSpecLocal(prompt: string, options: Omit<GeneratePageOptions, 'llm'>): GeneratePageResult;
|
|
85
|
+
//# sourceMappingURL=page-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-generator.d.ts","sourceRoot":"","sources":["../../src/core/page-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACR,UAAU,EACV,WAAW,EACX,eAAe,EASf,kBAAkB,EACrB,MAAM,YAAY,CAAC;AAQpB,MAAM,MAAM,UAAU,GAAG;IACrB,yBAAyB;IACzB,QAAQ,EAAE,SAAS,GAAG,SAA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