@nuvler/theme-sdk 1.0.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 ADDED
@@ -0,0 +1,24 @@
1
+ # @nuvler/theme-sdk
2
+
3
+ Contrato público compartilhado entre temas Nuvler e o Store.
4
+
5
+ ```ts
6
+ import { defineTheme, THEME_API_VERSION, THEME_RUNTIME_VERSION } from "@nuvler/theme-sdk";
7
+
8
+ export const theme = defineTheme({
9
+ manifest: {
10
+ schemaVersion: 1,
11
+ id: "meu-tema",
12
+ name: "Meu tema",
13
+ version: "1.0.0",
14
+ runtimeVersion: THEME_RUNTIME_VERSION,
15
+ sdkVersion: `^${THEME_API_VERSION}`,
16
+ entry: "src/theme.tsx",
17
+ styles: ["src/theme.css"],
18
+ },
19
+ // tokens, template e components
20
+ });
21
+ ```
22
+
23
+ `version` identifica a versão imutável do tema. `runtimeVersion` identifica o
24
+ protocolo `mount/unmount` e `sdkVersion` declara a faixa do SDK aceita.
@@ -0,0 +1,396 @@
1
+ import type { ComponentType, ReactNode } from "react";
2
+ export declare const THEME_SCHEMA_VERSION: 1;
3
+ export declare const THEME_API_VERSION: "1.0.0";
4
+ export declare const THEME_RUNTIME_VERSION: "1";
5
+ export interface ThemeApiCompatibility {
6
+ themeApi: string;
7
+ }
8
+ export interface ThemeManifest {
9
+ schemaVersion: typeof THEME_SCHEMA_VERSION;
10
+ id: string;
11
+ name: string;
12
+ /** Versão do tema, independente da versão da Theme API. */
13
+ version: string;
14
+ runtimeVersion: typeof THEME_RUNTIME_VERSION;
15
+ sdkVersion: string;
16
+ entry: string;
17
+ styles?: string[];
18
+ }
19
+ /** Manifesto imutável entregue junto ao bundle publicado no Registry. */
20
+ export interface ThemeArtifactManifest {
21
+ schemaVersion: typeof THEME_SCHEMA_VERSION;
22
+ id: string;
23
+ name: string;
24
+ version: string;
25
+ runtimeVersion: typeof THEME_RUNTIME_VERSION;
26
+ sdkVersion: string;
27
+ entry: "./theme.js";
28
+ style?: "./theme.css";
29
+ }
30
+ export interface ThemeImage {
31
+ url: string | null;
32
+ alt: string | null;
33
+ width: number | null;
34
+ height: number | null;
35
+ }
36
+ export interface ThemeStore {
37
+ name: string;
38
+ slug: string;
39
+ }
40
+ export interface ThemeSiteColors {
41
+ primary: string;
42
+ secondary: string;
43
+ background: string;
44
+ text: string;
45
+ }
46
+ export interface ThemeSettings {
47
+ id?: string;
48
+ colors: ThemeSiteColors;
49
+ layout: {
50
+ containerWidth: number;
51
+ borderRadius: number;
52
+ };
53
+ }
54
+ export interface ThemeContact {
55
+ email?: string;
56
+ phone?: string;
57
+ whatsapp?: string;
58
+ address?: string;
59
+ }
60
+ export interface ThemeSiteSettings {
61
+ siteName: string;
62
+ description: string | null;
63
+ logo: ThemeImage | null;
64
+ favicon: ThemeImage | null;
65
+ contact: ThemeContact;
66
+ social: {
67
+ instagram?: string;
68
+ facebook?: string;
69
+ youtube?: string;
70
+ tiktok?: string;
71
+ };
72
+ floatingWhatsapp?: {
73
+ enabled: boolean;
74
+ label?: string;
75
+ message: string;
76
+ };
77
+ catalog?: {
78
+ showProductsWithoutImage: boolean;
79
+ showDescription: boolean;
80
+ showCategory: boolean;
81
+ productsPerPage: 12 | 24 | 36 | 48;
82
+ desktopColumns: 3 | 4;
83
+ };
84
+ theme?: ThemeSettings | null;
85
+ }
86
+ /** Dados do site no contexto portátil de preview. */
87
+ export interface ThemeContextSite {
88
+ modules: string[];
89
+ settings: ThemeSiteSettings | null;
90
+ }
91
+ /** Dados entregues aos componentes do Store. */
92
+ export interface ThemeSite extends ThemeContextSite {
93
+ tenant: ThemeStore;
94
+ }
95
+ export type ThemeHomeSectionType = "hero" | "banner-carousel" | "image-text" | "rich-text" | "cta" | "services-grid" | "blog-grid" | "cases-grid" | "products-grid" | "products-carousel";
96
+ export interface ThemeHomeSection {
97
+ id?: string;
98
+ type: ThemeHomeSectionType;
99
+ enabled: boolean;
100
+ order: number;
101
+ data: Record<string, unknown>;
102
+ }
103
+ export interface ThemeHome {
104
+ title: string;
105
+ slug: string;
106
+ content: {
107
+ version: number;
108
+ sections: ThemeHomeSection[];
109
+ };
110
+ publishedAt: string;
111
+ }
112
+ export interface ThemeCategory {
113
+ name: string;
114
+ slug: string;
115
+ description: string | null;
116
+ image: ThemeImage | null;
117
+ order: number;
118
+ level: number;
119
+ children: ThemeCategory[];
120
+ }
121
+ export interface ThemeProduct {
122
+ title: string;
123
+ slug: string;
124
+ description: string;
125
+ sku: string;
126
+ price: number | null;
127
+ promotionalPrice: number | null;
128
+ stockQuantity: number | null;
129
+ brand: string;
130
+ model: string;
131
+ ean: string;
132
+ image: ThemeImage | null;
133
+ images: ThemeImage[];
134
+ categories: ThemeCategory[];
135
+ variantOptions: Array<{
136
+ name: string;
137
+ values: string[];
138
+ }>;
139
+ variants: Array<{
140
+ id: string | null;
141
+ name: string;
142
+ sku: string;
143
+ active: boolean;
144
+ image: ThemeImage | null;
145
+ values: Array<{
146
+ name: string;
147
+ value: string;
148
+ }>;
149
+ }>;
150
+ publishedAt: string | null;
151
+ }
152
+ export interface ThemePagination {
153
+ page: number;
154
+ limit: number;
155
+ total: number;
156
+ totalPages: number;
157
+ hasPreviousPage: boolean;
158
+ hasNextPage: boolean;
159
+ }
160
+ export interface ThemePageSummary {
161
+ title: string;
162
+ slug: string;
163
+ publishedAt: string | null;
164
+ }
165
+ export type ThemeNavigationPage = ThemePageSummary;
166
+ export interface ThemeEditorialItem {
167
+ title: string;
168
+ slug: string;
169
+ description: string;
170
+ image?: ThemeImage | null;
171
+ thumbnail?: ThemeImage | null;
172
+ coverImage?: ThemeImage | null;
173
+ category?: {
174
+ name?: string;
175
+ title?: string;
176
+ slug?: string | null;
177
+ } | null;
178
+ publishedAt: string | null;
179
+ }
180
+ export interface ThemeContext {
181
+ schemaVersion: typeof THEME_SCHEMA_VERSION;
182
+ store: ThemeStore;
183
+ site: ThemeContextSite;
184
+ navigation: {
185
+ pages: ThemeNavigationPage[];
186
+ categories: ThemeCategory[];
187
+ };
188
+ home: ThemeHome;
189
+ catalog: {
190
+ products: ThemeProduct[];
191
+ pagination?: ThemePagination;
192
+ };
193
+ editorial: {
194
+ posts: ThemeEditorialItem[];
195
+ services: ThemeEditorialItem[];
196
+ cases: ThemeEditorialItem[];
197
+ };
198
+ }
199
+ export interface SiteTemplate {
200
+ announcement: string;
201
+ footerTagline: string;
202
+ footerNavigationLabel: string;
203
+ footerNote: string;
204
+ socialLabel: string;
205
+ benefits: ReadonlyArray<{
206
+ title: string;
207
+ description: string;
208
+ }>;
209
+ fallbackSections(modules: readonly string[]): ThemeHomeSection[];
210
+ primaryAction(modules: readonly string[]): {
211
+ label: string;
212
+ href: string;
213
+ };
214
+ }
215
+ export interface HeaderProps {
216
+ site: ThemeSite;
217
+ categories: ThemeCategory[];
218
+ pages: ThemePageSummary[];
219
+ template: SiteTemplate;
220
+ cart?: ReactNode;
221
+ suggestionsEndpoint?: string;
222
+ suggestionsQueryParam?: string;
223
+ searchProducts?: (query: string) => Promise<ThemeProduct[]>;
224
+ }
225
+ export interface FooterProps {
226
+ site: ThemeSite;
227
+ pages: ThemePageSummary[];
228
+ template: SiteTemplate;
229
+ }
230
+ export interface HomeProps {
231
+ sections: ThemeHomeSection[];
232
+ products: ThemeProduct[];
233
+ posts: ThemeEditorialItem[];
234
+ services: ThemeEditorialItem[];
235
+ cases: ThemeEditorialItem[];
236
+ site: ThemeSite;
237
+ template: SiteTemplate;
238
+ }
239
+ export interface ProductGridProps {
240
+ products: ThemeProduct[];
241
+ columns?: 3 | 4;
242
+ showCategory?: boolean;
243
+ showDescription?: boolean;
244
+ }
245
+ export interface ThemeCartItem {
246
+ productSlug: string;
247
+ title: string;
248
+ sku: string;
249
+ variantId?: string | null;
250
+ variantName?: string;
251
+ image?: ThemeImage | null;
252
+ unitPrice?: number | null;
253
+ }
254
+ export interface ProductDetailProps {
255
+ product: ThemeProduct;
256
+ contact?: ThemeContact;
257
+ productUrl: string | null;
258
+ descriptionContent: ReactNode;
259
+ onAddToCart?: (item: ThemeCartItem) => void;
260
+ }
261
+ export interface ThemeLinkProps {
262
+ href: string;
263
+ children: ReactNode;
264
+ className?: string;
265
+ }
266
+ export interface ThemeImageProps {
267
+ image: ThemeImage | null;
268
+ fallbackAlt: string;
269
+ className?: string;
270
+ priority?: boolean;
271
+ }
272
+ export interface ThemeRuntimeAdapters {
273
+ Link: ComponentType<ThemeLinkProps>;
274
+ Image: ComponentType<ThemeImageProps>;
275
+ searchProducts?: (query: string) => Promise<ThemeProduct[]>;
276
+ }
277
+ export type ThemeRoute = {
278
+ type: "home";
279
+ } | {
280
+ type: "loading";
281
+ pathname: string;
282
+ } | {
283
+ type: "not-found";
284
+ pathname: string;
285
+ } | {
286
+ type: "catalog";
287
+ products: ThemeProduct[];
288
+ categories: ThemeCategory[];
289
+ pagination: ThemePagination;
290
+ search: string;
291
+ categorySlug: string | null;
292
+ categoryPath: string[];
293
+ variants: string[];
294
+ facets: Array<{
295
+ name: string;
296
+ values: Array<{
297
+ value: string;
298
+ count: number;
299
+ }>;
300
+ }>;
301
+ } | {
302
+ type: "product";
303
+ product: ThemeProduct;
304
+ } | {
305
+ type: "editorial-list";
306
+ title: string;
307
+ basePath: string;
308
+ items: ThemeEditorialItem[];
309
+ } | {
310
+ type: "editorial-detail";
311
+ basePath: string;
312
+ item: ThemeEditorialItem;
313
+ } | {
314
+ type: "page";
315
+ title: string;
316
+ };
317
+ export interface ThemeCustomer {
318
+ id: string;
319
+ name?: string;
320
+ email?: string;
321
+ }
322
+ export interface ThemeRuntimeSdk {
323
+ cart: {
324
+ add(item: ThemeCartItem): void;
325
+ remove(itemKey: string): void;
326
+ };
327
+ navigation: {
328
+ navigate(href: string): void;
329
+ };
330
+ analytics: {
331
+ track(event: string, properties?: Record<string, unknown>): void;
332
+ };
333
+ customer: {
334
+ getCurrent(): Promise<ThemeCustomer | null>;
335
+ };
336
+ catalog: {
337
+ searchProducts(query: string): Promise<ThemeProduct[]>;
338
+ };
339
+ }
340
+ export interface ThemeRuntimeMountOptions {
341
+ element: HTMLElement;
342
+ page: ThemeRoute;
343
+ data: ThemeContext;
344
+ settings: ThemeSettings | null;
345
+ sdk: ThemeRuntimeSdk;
346
+ }
347
+ export interface ThemeRuntimeUnmountOptions {
348
+ element: HTMLElement;
349
+ }
350
+ export interface NuvlerThemeRuntime {
351
+ mount(options: ThemeRuntimeMountOptions): void;
352
+ unmount(options: ThemeRuntimeUnmountOptions): void;
353
+ }
354
+ export interface ThemeRuntimeRelease {
355
+ theme: {
356
+ id: string;
357
+ slug: string;
358
+ name: string;
359
+ };
360
+ release: {
361
+ id: string;
362
+ version: string;
363
+ runtimeVersion: string;
364
+ sdkVersion: string;
365
+ integrity: string;
366
+ };
367
+ assets: {
368
+ manifest: string;
369
+ script: string;
370
+ scriptIntegrity: string | null;
371
+ style: string | null;
372
+ styleIntegrity: string | null;
373
+ };
374
+ }
375
+ /** Contrato do componente raiz usado pelo preview e pelo artefato compilado. */
376
+ export interface NuvlerThemeProps {
377
+ context: ThemeContext;
378
+ adapters: ThemeRuntimeAdapters;
379
+ route?: ThemeRoute;
380
+ settings?: ThemeSettings | null;
381
+ sdk?: ThemeRuntimeSdk;
382
+ }
383
+ export type NuvlerThemeComponent = ComponentType<NuvlerThemeProps>;
384
+ export interface NuvlerStoreThemeDefinition {
385
+ manifest: ThemeManifest;
386
+ tokens: Omit<ThemeSettings, "id">;
387
+ template: SiteTemplate;
388
+ components: {
389
+ Header: ComponentType<HeaderProps>;
390
+ Footer: ComponentType<FooterProps>;
391
+ Home: ComponentType<HomeProps>;
392
+ ProductGrid: ComponentType<ProductGridProps>;
393
+ ProductDetail: ComponentType<ProductDetailProps>;
394
+ };
395
+ }
396
+ export declare function defineTheme<const TTheme extends NuvlerStoreThemeDefinition>(theme: TTheme): TTheme;
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export const THEME_SCHEMA_VERSION = 1;
2
+ export const THEME_API_VERSION = "1.0.0";
3
+ export const THEME_RUNTIME_VERSION = "1";
4
+ export function defineTheme(theme) {
5
+ return theme;
6
+ }
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAU,CAAC;AAC/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAgB,CAAC;AAClD,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAY,CAAC;AAmalD,MAAM,UAAU,WAAW,CAAkD,KAAa;IACxF,OAAO,KAAK,CAAC;AACf,CAAC"}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@nuvler/theme-sdk",
3
+ "version": "1.0.0",
4
+ "description": "Contrato público para temas da plataforma Nuvler",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": ["dist", "README.md"],
16
+ "scripts": {
17
+ "build": "tsc -p tsconfig.json",
18
+ "typecheck": "tsc -p tsconfig.json --noEmit"
19
+ },
20
+ "peerDependencies": {
21
+ "react": "^19.0.0"
22
+ },
23
+ "peerDependenciesMeta": {
24
+ "react": {
25
+ "optional": true
26
+ }
27
+ },
28
+ "devDependencies": {
29
+ "@types/react": "^19.0.0",
30
+ "react": "19.2.8"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "engines": {
36
+ "node": "^20.19.0 || >=22.12.0"
37
+ }
38
+ }