@riverbankcms/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1892 -0
- package/dist/cli/index.js +327 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/client/analytics.d.mts +103 -0
- package/dist/client/analytics.d.ts +103 -0
- package/dist/client/analytics.js +197 -0
- package/dist/client/analytics.js.map +1 -0
- package/dist/client/analytics.mjs +169 -0
- package/dist/client/analytics.mjs.map +1 -0
- package/dist/client/bookings.d.mts +89 -0
- package/dist/client/bookings.d.ts +89 -0
- package/dist/client/bookings.js +34 -0
- package/dist/client/bookings.js.map +1 -0
- package/dist/client/bookings.mjs +11 -0
- package/dist/client/bookings.mjs.map +1 -0
- package/dist/client/client.d.mts +195 -0
- package/dist/client/client.d.ts +195 -0
- package/dist/client/client.js +606 -0
- package/dist/client/client.js.map +1 -0
- package/dist/client/client.mjs +572 -0
- package/dist/client/client.mjs.map +1 -0
- package/dist/client/hooks.d.mts +71 -0
- package/dist/client/hooks.d.ts +71 -0
- package/dist/client/hooks.js +264 -0
- package/dist/client/hooks.js.map +1 -0
- package/dist/client/hooks.mjs +235 -0
- package/dist/client/hooks.mjs.map +1 -0
- package/dist/client/rendering/client.d.mts +1 -0
- package/dist/client/rendering/client.d.ts +1 -0
- package/dist/client/rendering/client.js +33 -0
- package/dist/client/rendering/client.js.map +1 -0
- package/dist/client/rendering/client.mjs +8 -0
- package/dist/client/rendering/client.mjs.map +1 -0
- package/dist/client/usePage-BvKAa3Zw.d.mts +366 -0
- package/dist/client/usePage-BvKAa3Zw.d.ts +366 -0
- package/dist/server/chunk-2RW5HAQQ.mjs +86 -0
- package/dist/server/chunk-2RW5HAQQ.mjs.map +1 -0
- package/dist/server/chunk-3KKZVGH4.mjs +179 -0
- package/dist/server/chunk-3KKZVGH4.mjs.map +1 -0
- package/dist/server/chunk-4Z3GPTCS.js +179 -0
- package/dist/server/chunk-4Z3GPTCS.js.map +1 -0
- package/dist/server/chunk-4Z5FBFRL.mjs +211 -0
- package/dist/server/chunk-4Z5FBFRL.mjs.map +1 -0
- package/dist/server/chunk-ADREPXFU.js +86 -0
- package/dist/server/chunk-ADREPXFU.js.map +1 -0
- package/dist/server/chunk-F472SMKX.js +140 -0
- package/dist/server/chunk-F472SMKX.js.map +1 -0
- package/dist/server/chunk-GWBMJPLH.mjs +57 -0
- package/dist/server/chunk-GWBMJPLH.mjs.map +1 -0
- package/dist/server/chunk-JB4LIEFS.js +85 -0
- package/dist/server/chunk-JB4LIEFS.js.map +1 -0
- package/dist/server/chunk-PEAXKTDU.mjs +140 -0
- package/dist/server/chunk-PEAXKTDU.mjs.map +1 -0
- package/dist/server/chunk-QQ6U4QX6.js +120 -0
- package/dist/server/chunk-QQ6U4QX6.js.map +1 -0
- package/dist/server/chunk-R5YGLRUG.mjs +122 -0
- package/dist/server/chunk-R5YGLRUG.mjs.map +1 -0
- package/dist/server/chunk-SW7LE4M3.js +211 -0
- package/dist/server/chunk-SW7LE4M3.js.map +1 -0
- package/dist/server/chunk-W3K7LVPS.mjs +120 -0
- package/dist/server/chunk-W3K7LVPS.mjs.map +1 -0
- package/dist/server/chunk-WKG57P2H.mjs +85 -0
- package/dist/server/chunk-WKG57P2H.mjs.map +1 -0
- package/dist/server/chunk-YHEZMVTS.js +122 -0
- package/dist/server/chunk-YHEZMVTS.js.map +1 -0
- package/dist/server/chunk-YXDDFG3N.js +57 -0
- package/dist/server/chunk-YXDDFG3N.js.map +1 -0
- package/dist/server/components.d.mts +49 -0
- package/dist/server/components.d.ts +49 -0
- package/dist/server/components.js +22 -0
- package/dist/server/components.js.map +1 -0
- package/dist/server/components.mjs +22 -0
- package/dist/server/components.mjs.map +1 -0
- package/dist/server/config-validation.d.mts +300 -0
- package/dist/server/config-validation.d.ts +300 -0
- package/dist/server/config-validation.js +50 -0
- package/dist/server/config-validation.js.map +1 -0
- package/dist/server/config-validation.mjs +50 -0
- package/dist/server/config-validation.mjs.map +1 -0
- package/dist/server/config.d.mts +38 -0
- package/dist/server/config.d.ts +38 -0
- package/dist/server/config.js +44 -0
- package/dist/server/config.js.map +1 -0
- package/dist/server/config.mjs +44 -0
- package/dist/server/config.mjs.map +1 -0
- package/dist/server/data.d.mts +108 -0
- package/dist/server/data.d.ts +108 -0
- package/dist/server/data.js +15 -0
- package/dist/server/data.js.map +1 -0
- package/dist/server/data.mjs +15 -0
- package/dist/server/data.mjs.map +1 -0
- package/dist/server/index-B0yI_V6Z.d.mts +18 -0
- package/dist/server/index-C6M0Wfjq.d.ts +18 -0
- package/dist/server/index.d.mts +5 -0
- package/dist/server/index.d.ts +5 -0
- package/dist/server/index.js +12 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/index.mjs +12 -0
- package/dist/server/index.mjs.map +1 -0
- package/dist/server/loadContent-CJcbYF3J.d.ts +152 -0
- package/dist/server/loadContent-zhlL4YSE.d.mts +152 -0
- package/dist/server/loadPage-BYmVMk0V.d.ts +216 -0
- package/dist/server/loadPage-CCf15nt8.d.mts +216 -0
- package/dist/server/loadPage-DVH3DW6E.js +9 -0
- package/dist/server/loadPage-DVH3DW6E.js.map +1 -0
- package/dist/server/loadPage-PHQZ6XQZ.mjs +9 -0
- package/dist/server/loadPage-PHQZ6XQZ.mjs.map +1 -0
- package/dist/server/metadata.d.mts +135 -0
- package/dist/server/metadata.d.ts +135 -0
- package/dist/server/metadata.js +68 -0
- package/dist/server/metadata.js.map +1 -0
- package/dist/server/metadata.mjs +68 -0
- package/dist/server/metadata.mjs.map +1 -0
- package/dist/server/rendering/server.d.mts +83 -0
- package/dist/server/rendering/server.d.ts +83 -0
- package/dist/server/rendering/server.js +14 -0
- package/dist/server/rendering/server.js.map +1 -0
- package/dist/server/rendering/server.mjs +14 -0
- package/dist/server/rendering/server.mjs.map +1 -0
- package/dist/server/rendering.d.mts +12 -0
- package/dist/server/rendering.d.ts +12 -0
- package/dist/server/rendering.js +40 -0
- package/dist/server/rendering.js.map +1 -0
- package/dist/server/rendering.mjs +40 -0
- package/dist/server/rendering.mjs.map +1 -0
- package/dist/server/routing.d.mts +115 -0
- package/dist/server/routing.d.ts +115 -0
- package/dist/server/routing.js +57 -0
- package/dist/server/routing.js.map +1 -0
- package/dist/server/routing.mjs +57 -0
- package/dist/server/routing.mjs.map +1 -0
- package/dist/server/server.d.mts +9 -0
- package/dist/server/server.d.ts +9 -0
- package/dist/server/server.js +21 -0
- package/dist/server/server.js.map +1 -0
- package/dist/server/server.mjs +21 -0
- package/dist/server/server.mjs.map +1 -0
- package/dist/server/theme-bridge.d.mts +232 -0
- package/dist/server/theme-bridge.d.ts +232 -0
- package/dist/server/theme-bridge.js +231 -0
- package/dist/server/theme-bridge.js.map +1 -0
- package/dist/server/theme-bridge.mjs +231 -0
- package/dist/server/theme-bridge.mjs.map +1 -0
- package/dist/server/theme.d.mts +40 -0
- package/dist/server/theme.d.ts +40 -0
- package/dist/server/theme.js +17 -0
- package/dist/server/theme.js.map +1 -0
- package/dist/server/theme.mjs +17 -0
- package/dist/server/theme.mjs.map +1 -0
- package/dist/server/types-BCeqWtI2.d.mts +333 -0
- package/dist/server/types-BCeqWtI2.d.ts +333 -0
- package/dist/server/types-Bbo01M7P.d.mts +76 -0
- package/dist/server/types-Bbo01M7P.d.ts +76 -0
- package/dist/server/types-C6gmRHLe.d.mts +150 -0
- package/dist/server/types-C6gmRHLe.d.ts +150 -0
- package/package.json +147 -0
- package/src/styles/index.css +10 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/will/Projects/Business/cms/builder/packages/sdk/dist/server/theme.js","../../src/theme/index.ts"],"names":[],"mappings":"AAAA;ACkBO,SAAS,UAAA,CAAW,KAAA,EAAgC,OAAA,EAA6B;AACtF,EAAA,MAAM,cAAA,mBAAgB,OAAA,UAAA,CAAY,OAAO,SAAA,IAAa,YAAA,EAAc,QAAA,CAAS,gBAAA,EAAkB,IAAA,GAAA;AAE/F,EAAA,GAAA,CAAI,CAAC,aAAA,EAAe;AAClB,IAAA,OAAA,CAAQ,IAAA,CAAK,yDAAyD,CAAA;AACtE,IAAA,MAAA;AAAA,EACF;AAIA,EAAA,aAAA,CAAc,YAAA,CAAa,oBAAA,EAAsB,IAAA,CAAK,SAAA,CAAU,KAAK,CAAC,CAAA;AAIxE;AAiBO,SAAS,WAAA,CAAY,QAAA,EAAmC,CAAC,CAAA,EAA4B;AAI1F,EAAA,OAAO,EAAE,GAAG,QAAQ,CAAA;AACtB;AD1CA;AACE;AACA;AACF,mEAAC","file":"/Users/will/Projects/Business/cms/builder/packages/sdk/dist/server/theme.js","sourcesContent":[null,"/**\n * Theme utilities for Riverbank CMS\n *\n * These utilities help you work with Builder themes in your application.\n */\n\n/**\n * Apply a Builder theme to the DOM by injecting CSS variables\n *\n * @param theme - The theme object from Riverbank CMS\n * @param element - The element to apply the theme to (default: document.documentElement)\n *\n * @example\n * ```ts\n * const site = await client.getSite({ slug: 'my-site' });\n * applyTheme(site.theme);\n * ```\n */\nexport function applyTheme(theme: Record<string, unknown>, element?: HTMLElement): void {\n const targetElement = element ?? (typeof document !== 'undefined' ? document.documentElement : null);\n\n if (!targetElement) {\n console.warn('[Builder SDK] Cannot apply theme: no document available');\n return;\n }\n\n // Theme application will use the theme runtime from @riverbankcms/blocks\n // For now, we'll set a data attribute that the theme runtime can pick up\n targetElement.setAttribute('data-builder-theme', JSON.stringify(theme));\n\n // Note: Full CSS variable injection will be implemented once we\n // finalize the theme transformation API from @riverbankcms/blocks\n}\n\n/**\n * Create a theme object with type-safe defaults\n *\n * @param partial - Partial theme configuration\n * @returns Complete theme object\n *\n * @example\n * ```ts\n * const customTheme = createTheme({\n * colors: {\n * primary: '#007bff',\n * },\n * });\n * ```\n */\nexport function createTheme(partial: Record<string, unknown> = {}): Record<string, unknown> {\n // For now, return the partial as-is\n // Full theme creation with defaults will be implemented once we\n // finalize the theme structure from @riverbankcms/blocks\n return { ...partial };\n}\n\n/**\n * Re-export theme types from @riverbankcms/blocks when available\n */\nexport type Theme = Record<string, unknown>;\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/theme/index.ts
|
|
2
|
+
function applyTheme(theme, element) {
|
|
3
|
+
const targetElement = element ?? (typeof document !== "undefined" ? document.documentElement : null);
|
|
4
|
+
if (!targetElement) {
|
|
5
|
+
console.warn("[Builder SDK] Cannot apply theme: no document available");
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
targetElement.setAttribute("data-builder-theme", JSON.stringify(theme));
|
|
9
|
+
}
|
|
10
|
+
function createTheme(partial = {}) {
|
|
11
|
+
return { ...partial };
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
applyTheme,
|
|
15
|
+
createTheme
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=theme.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/theme/index.ts"],"sourcesContent":["/**\n * Theme utilities for Riverbank CMS\n *\n * These utilities help you work with Builder themes in your application.\n */\n\n/**\n * Apply a Builder theme to the DOM by injecting CSS variables\n *\n * @param theme - The theme object from Riverbank CMS\n * @param element - The element to apply the theme to (default: document.documentElement)\n *\n * @example\n * ```ts\n * const site = await client.getSite({ slug: 'my-site' });\n * applyTheme(site.theme);\n * ```\n */\nexport function applyTheme(theme: Record<string, unknown>, element?: HTMLElement): void {\n const targetElement = element ?? (typeof document !== 'undefined' ? document.documentElement : null);\n\n if (!targetElement) {\n console.warn('[Builder SDK] Cannot apply theme: no document available');\n return;\n }\n\n // Theme application will use the theme runtime from @riverbankcms/blocks\n // For now, we'll set a data attribute that the theme runtime can pick up\n targetElement.setAttribute('data-builder-theme', JSON.stringify(theme));\n\n // Note: Full CSS variable injection will be implemented once we\n // finalize the theme transformation API from @riverbankcms/blocks\n}\n\n/**\n * Create a theme object with type-safe defaults\n *\n * @param partial - Partial theme configuration\n * @returns Complete theme object\n *\n * @example\n * ```ts\n * const customTheme = createTheme({\n * colors: {\n * primary: '#007bff',\n * },\n * });\n * ```\n */\nexport function createTheme(partial: Record<string, unknown> = {}): Record<string, unknown> {\n // For now, return the partial as-is\n // Full theme creation with defaults will be implemented once we\n // finalize the theme structure from @riverbankcms/blocks\n return { ...partial };\n}\n\n/**\n * Re-export theme types from @riverbankcms/blocks when available\n */\nexport type Theme = Record<string, unknown>;\n"],"mappings":";AAkBO,SAAS,WAAW,OAAgC,SAA6B;AACtF,QAAM,gBAAgB,YAAY,OAAO,aAAa,cAAc,SAAS,kBAAkB;AAE/F,MAAI,CAAC,eAAe;AAClB,YAAQ,KAAK,yDAAyD;AACtE;AAAA,EACF;AAIA,gBAAc,aAAa,sBAAsB,KAAK,UAAU,KAAK,CAAC;AAIxE;AAiBO,SAAS,YAAY,UAAmC,CAAC,GAA4B;AAI1F,SAAO,EAAE,GAAG,QAAQ;AACtB;","names":[]}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { SdkCustomBlock, FieldDefinition } from '@riverbankcms/blocks';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SDK Site Configuration Types
|
|
5
|
+
*
|
|
6
|
+
* These types define the schema for SDK site configuration that can be
|
|
7
|
+
* declared in code and exposed to the dashboard via /.builder/config.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* SDK-defined theme palette.
|
|
12
|
+
*
|
|
13
|
+
* SDK sites define their own color palette with semantic token names.
|
|
14
|
+
* These tokens can then be referenced in style configurations.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* palette: {
|
|
19
|
+
* primary: '#6d28d9',
|
|
20
|
+
* secondary: '#4c1d95',
|
|
21
|
+
* accent: '#FF007F',
|
|
22
|
+
* highlight: '#facc15',
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
type SdkThemePalette = Record<string, string>;
|
|
27
|
+
/**
|
|
28
|
+
* SDK-defined theme configuration.
|
|
29
|
+
*
|
|
30
|
+
* This allows SDK sites to define their own theme that's used for
|
|
31
|
+
* token resolution in the editor and at render time.
|
|
32
|
+
*/
|
|
33
|
+
interface SdkThemeConfig {
|
|
34
|
+
/**
|
|
35
|
+
* Color palette mapping token names to CSS color values.
|
|
36
|
+
* Token names are arbitrary and defined by the SDK site.
|
|
37
|
+
*/
|
|
38
|
+
palette: SdkThemePalette;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Allowed spacing values in section styles.
|
|
42
|
+
*/
|
|
43
|
+
type SectionSpacing = 'compact' | 'default' | 'spacious';
|
|
44
|
+
/**
|
|
45
|
+
* Allowed container max-width values.
|
|
46
|
+
*/
|
|
47
|
+
type ContainerMaxWidth = 'narrow' | 'default' | 'wide' | 'full';
|
|
48
|
+
/**
|
|
49
|
+
* Allowed container alignment values.
|
|
50
|
+
*/
|
|
51
|
+
type ContainerAlignment = 'left' | 'center' | 'right';
|
|
52
|
+
/**
|
|
53
|
+
* A curated background color option for section styles.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* sectionBackgrounds: [
|
|
58
|
+
* { id: 'primary', label: 'Purple', token: 'primary' },
|
|
59
|
+
* { id: 'accent', label: 'Pink', token: 'accent' },
|
|
60
|
+
* ]
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
interface SectionBackground {
|
|
64
|
+
/** Unique identifier for this background option */
|
|
65
|
+
id: string;
|
|
66
|
+
/** Display name shown in the editor UI */
|
|
67
|
+
label: string;
|
|
68
|
+
/** Reference to a token in the theme palette */
|
|
69
|
+
token: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Configuration for which section style options are available.
|
|
73
|
+
*
|
|
74
|
+
* Each option can be:
|
|
75
|
+
* - `false`: Hide the option entirely from the editor
|
|
76
|
+
* - `true`: Show all supported values for that option
|
|
77
|
+
* - Array: Show only the specified values (for options that support arrays)
|
|
78
|
+
*/
|
|
79
|
+
interface SectionOptionsConfig {
|
|
80
|
+
/** Enable/disable background color selection */
|
|
81
|
+
backgroundColor?: boolean;
|
|
82
|
+
/** Enable/disable background image selection */
|
|
83
|
+
backgroundImage?: boolean;
|
|
84
|
+
/** Enable/disable background gradient selection */
|
|
85
|
+
backgroundGradient?: boolean;
|
|
86
|
+
/** Control available spacing values, or disable entirely */
|
|
87
|
+
spacing?: SectionSpacing[] | boolean;
|
|
88
|
+
/** Enable/disable text color selection */
|
|
89
|
+
textColor?: boolean;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Configuration for which container style options are available.
|
|
93
|
+
*
|
|
94
|
+
* Each option can be:
|
|
95
|
+
* - `false`: Hide the option entirely from the editor
|
|
96
|
+
* - `true`: Show all supported values for that option
|
|
97
|
+
* - Array: Show only the specified values
|
|
98
|
+
*/
|
|
99
|
+
interface ContainerOptionsConfig {
|
|
100
|
+
/** Control available max-width values, or disable entirely */
|
|
101
|
+
maxWidth?: ContainerMaxWidth[] | boolean;
|
|
102
|
+
/** Control available alignment values, or disable entirely */
|
|
103
|
+
alignment?: ContainerAlignment[] | boolean;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Site-level style configuration for SDK sites.
|
|
107
|
+
*
|
|
108
|
+
* This allows SDK sites to curate which styling options are available
|
|
109
|
+
* to editors in the section styles panel.
|
|
110
|
+
*/
|
|
111
|
+
interface SiteStyleConfig {
|
|
112
|
+
/**
|
|
113
|
+
* Curated list of background colors available in section styles.
|
|
114
|
+
* If not specified, falls back to theme colors (current behavior).
|
|
115
|
+
*/
|
|
116
|
+
sectionBackgrounds?: SectionBackground[];
|
|
117
|
+
/**
|
|
118
|
+
* Which section style options are enabled.
|
|
119
|
+
* Options not listed or set to false are hidden from editors.
|
|
120
|
+
*/
|
|
121
|
+
sectionOptions?: SectionOptionsConfig;
|
|
122
|
+
/**
|
|
123
|
+
* Container style constraints.
|
|
124
|
+
*/
|
|
125
|
+
containerOptions?: ContainerOptionsConfig;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* A select option for SDK-provided field options.
|
|
129
|
+
*/
|
|
130
|
+
interface FieldSelectOption {
|
|
131
|
+
/** The value stored when this option is selected */
|
|
132
|
+
value: string;
|
|
133
|
+
/** Display label shown in the dropdown */
|
|
134
|
+
label: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Configuration for a specific field within a block.
|
|
138
|
+
*
|
|
139
|
+
* Currently supports overriding select options, but designed
|
|
140
|
+
* for future extensions (defaultValue, required, etc.).
|
|
141
|
+
*/
|
|
142
|
+
interface BlockFieldConfig {
|
|
143
|
+
/** Override select options for this field */
|
|
144
|
+
options?: FieldSelectOption[];
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Per-block field configurations.
|
|
148
|
+
*
|
|
149
|
+
* Maps block IDs to field configurations, where each field config
|
|
150
|
+
* is keyed by field ID.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* {
|
|
155
|
+
* 'block.embed': {
|
|
156
|
+
* layout: {
|
|
157
|
+
* options: [
|
|
158
|
+
* { value: 'showcase', label: 'Showcase Grid' },
|
|
159
|
+
* { value: 'list', label: 'Simple List' },
|
|
160
|
+
* ]
|
|
161
|
+
* }
|
|
162
|
+
* }
|
|
163
|
+
* }
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
type BlockFieldOptionsMap = Record<string, Record<string, BlockFieldConfig>>;
|
|
167
|
+
/**
|
|
168
|
+
* Configuration for extending a built-in block with additional fields.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```typescript
|
|
172
|
+
* {
|
|
173
|
+
* fields: [
|
|
174
|
+
* {
|
|
175
|
+
* id: 'layout',
|
|
176
|
+
* type: 'select',
|
|
177
|
+
* label: 'Layout',
|
|
178
|
+
* defaultValue: 'default',
|
|
179
|
+
* options: [
|
|
180
|
+
* { value: 'default', label: 'Default' },
|
|
181
|
+
* { value: 'wide', label: 'Wide' },
|
|
182
|
+
* ],
|
|
183
|
+
* },
|
|
184
|
+
* ],
|
|
185
|
+
* }
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
interface BlockFieldExtension {
|
|
189
|
+
/**
|
|
190
|
+
* Additional fields to append to the block's form.
|
|
191
|
+
* Uses the same field definition format as block manifests.
|
|
192
|
+
* All field types are supported.
|
|
193
|
+
*
|
|
194
|
+
* Note: If a field is marked as `required: true`, it MUST have a `defaultValue`.
|
|
195
|
+
* This ensures existing blocks without this field can still be edited.
|
|
196
|
+
*/
|
|
197
|
+
fields: FieldDefinition[];
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Map of block IDs to their field extensions.
|
|
201
|
+
* Block IDs must be system blocks (e.g., 'block.bodyText', 'block.hero').
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* {
|
|
206
|
+
* 'block.bodyText': {
|
|
207
|
+
* fields: [
|
|
208
|
+
* { id: 'layout', type: 'select', label: 'Layout', ... },
|
|
209
|
+
* ],
|
|
210
|
+
* },
|
|
211
|
+
* 'block.hero': {
|
|
212
|
+
* fields: [
|
|
213
|
+
* { id: 'videoBackground', type: 'media', label: 'Video Background', ... },
|
|
214
|
+
* ],
|
|
215
|
+
* },
|
|
216
|
+
* }
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
type BlockFieldExtensionsMap = Record<string, BlockFieldExtension>;
|
|
220
|
+
/**
|
|
221
|
+
* Top-level SDK site configuration.
|
|
222
|
+
*
|
|
223
|
+
* This is the complete configuration that SDK sites define in their
|
|
224
|
+
* `riverbank.config.ts` file and expose via the `/.builder/config` endpoint.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* // riverbank.config.ts
|
|
229
|
+
* import { defineConfig } from '@riverbankcms/sdk/config';
|
|
230
|
+
*
|
|
231
|
+
* export default defineConfig({
|
|
232
|
+
* siteId: '123e4567-e89b-12d3-a456-426614174000',
|
|
233
|
+
* theme: {
|
|
234
|
+
* palette: {
|
|
235
|
+
* primary: '#6d28d9',
|
|
236
|
+
* secondary: '#4c1d95',
|
|
237
|
+
* accent: '#FF007F',
|
|
238
|
+
* highlight: '#facc15',
|
|
239
|
+
* },
|
|
240
|
+
* },
|
|
241
|
+
* styles: {
|
|
242
|
+
* sectionBackgrounds: [
|
|
243
|
+
* { id: 'primary', label: 'Purple', token: 'primary' },
|
|
244
|
+
* { id: 'accent', label: 'Pink', token: 'accent' },
|
|
245
|
+
* ],
|
|
246
|
+
* sectionOptions: {
|
|
247
|
+
* backgroundColor: true,
|
|
248
|
+
* backgroundImage: false,
|
|
249
|
+
* spacing: ['compact', 'default', 'spacious'],
|
|
250
|
+
* },
|
|
251
|
+
* },
|
|
252
|
+
* blockFieldOptions: {
|
|
253
|
+
* 'block.embed': {
|
|
254
|
+
* layout: {
|
|
255
|
+
* options: [
|
|
256
|
+
* { value: 'showcase', label: 'Showcase Grid' },
|
|
257
|
+
* { value: 'list', label: 'Simple List' },
|
|
258
|
+
* ]
|
|
259
|
+
* }
|
|
260
|
+
* }
|
|
261
|
+
* },
|
|
262
|
+
* });
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
interface RiverbankSiteConfig {
|
|
266
|
+
/** Site UUID from the dashboard - identifies which site this config belongs to */
|
|
267
|
+
siteId: string;
|
|
268
|
+
/** SDK-defined theme with color palette for token resolution */
|
|
269
|
+
theme?: SdkThemeConfig;
|
|
270
|
+
/** Style configuration for curating editor options */
|
|
271
|
+
styles?: SiteStyleConfig;
|
|
272
|
+
/**
|
|
273
|
+
* Custom blocks defined by the SDK site.
|
|
274
|
+
* These blocks appear in the block picker and are edited via CMS forms.
|
|
275
|
+
* SDK sites MUST provide blockOverrides for rendering.
|
|
276
|
+
*/
|
|
277
|
+
customBlocks?: SdkCustomBlock[];
|
|
278
|
+
/**
|
|
279
|
+
* Per-block field options.
|
|
280
|
+
*
|
|
281
|
+
* Allows SDK sites to define which options are available for specific
|
|
282
|
+
* fields in specific blocks. Widgets with `ui.widget: 'sdkSelect'`
|
|
283
|
+
* will use these options when available, falling back to field defaults.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```typescript
|
|
287
|
+
* blockFieldOptions: {
|
|
288
|
+
* 'block.embed': {
|
|
289
|
+
* layout: {
|
|
290
|
+
* options: [
|
|
291
|
+
* { value: 'showcase', label: 'Showcase Grid' },
|
|
292
|
+
* { value: 'list', label: 'Simple List' },
|
|
293
|
+
* ]
|
|
294
|
+
* }
|
|
295
|
+
* }
|
|
296
|
+
* }
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
blockFieldOptions?: BlockFieldOptionsMap;
|
|
300
|
+
/**
|
|
301
|
+
* Per-block field extensions.
|
|
302
|
+
*
|
|
303
|
+
* Allows SDK sites to add custom fields to built-in block types.
|
|
304
|
+
* Extended fields appear at the end of the block's editing form
|
|
305
|
+
* and their values are accessible in `blockOverrides` via the `content` prop.
|
|
306
|
+
*
|
|
307
|
+
* Note: Extended field IDs must not conflict with existing block fields.
|
|
308
|
+
* Required fields must have a `defaultValue` to support existing blocks.
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```typescript
|
|
312
|
+
* blockFieldExtensions: {
|
|
313
|
+
* 'block.bodyText': {
|
|
314
|
+
* fields: [
|
|
315
|
+
* {
|
|
316
|
+
* id: 'layout',
|
|
317
|
+
* type: 'select',
|
|
318
|
+
* label: 'Layout',
|
|
319
|
+
* defaultValue: 'default',
|
|
320
|
+
* options: [
|
|
321
|
+
* { value: 'default', label: 'Default' },
|
|
322
|
+
* { value: 'wide', label: 'Wide' },
|
|
323
|
+
* ],
|
|
324
|
+
* },
|
|
325
|
+
* ],
|
|
326
|
+
* },
|
|
327
|
+
* }
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
blockFieldExtensions?: BlockFieldExtensionsMap;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export type { BlockFieldConfig as B, ContainerOptionsConfig as C, FieldSelectOption as F, RiverbankSiteConfig as R, SiteStyleConfig as S, SectionBackground as a, SectionOptionsConfig as b, SectionSpacing as c, ContainerMaxWidth as d, ContainerAlignment as e, SdkThemeConfig as f, SdkThemePalette as g, BlockFieldOptionsMap as h, BlockFieldExtension as i, BlockFieldExtensionsMap as j };
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { SdkCustomBlock, FieldDefinition } from '@riverbankcms/blocks';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SDK Site Configuration Types
|
|
5
|
+
*
|
|
6
|
+
* These types define the schema for SDK site configuration that can be
|
|
7
|
+
* declared in code and exposed to the dashboard via /.builder/config.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* SDK-defined theme palette.
|
|
12
|
+
*
|
|
13
|
+
* SDK sites define their own color palette with semantic token names.
|
|
14
|
+
* These tokens can then be referenced in style configurations.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* palette: {
|
|
19
|
+
* primary: '#6d28d9',
|
|
20
|
+
* secondary: '#4c1d95',
|
|
21
|
+
* accent: '#FF007F',
|
|
22
|
+
* highlight: '#facc15',
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
type SdkThemePalette = Record<string, string>;
|
|
27
|
+
/**
|
|
28
|
+
* SDK-defined theme configuration.
|
|
29
|
+
*
|
|
30
|
+
* This allows SDK sites to define their own theme that's used for
|
|
31
|
+
* token resolution in the editor and at render time.
|
|
32
|
+
*/
|
|
33
|
+
interface SdkThemeConfig {
|
|
34
|
+
/**
|
|
35
|
+
* Color palette mapping token names to CSS color values.
|
|
36
|
+
* Token names are arbitrary and defined by the SDK site.
|
|
37
|
+
*/
|
|
38
|
+
palette: SdkThemePalette;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Allowed spacing values in section styles.
|
|
42
|
+
*/
|
|
43
|
+
type SectionSpacing = 'compact' | 'default' | 'spacious';
|
|
44
|
+
/**
|
|
45
|
+
* Allowed container max-width values.
|
|
46
|
+
*/
|
|
47
|
+
type ContainerMaxWidth = 'narrow' | 'default' | 'wide' | 'full';
|
|
48
|
+
/**
|
|
49
|
+
* Allowed container alignment values.
|
|
50
|
+
*/
|
|
51
|
+
type ContainerAlignment = 'left' | 'center' | 'right';
|
|
52
|
+
/**
|
|
53
|
+
* A curated background color option for section styles.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* sectionBackgrounds: [
|
|
58
|
+
* { id: 'primary', label: 'Purple', token: 'primary' },
|
|
59
|
+
* { id: 'accent', label: 'Pink', token: 'accent' },
|
|
60
|
+
* ]
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
interface SectionBackground {
|
|
64
|
+
/** Unique identifier for this background option */
|
|
65
|
+
id: string;
|
|
66
|
+
/** Display name shown in the editor UI */
|
|
67
|
+
label: string;
|
|
68
|
+
/** Reference to a token in the theme palette */
|
|
69
|
+
token: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Configuration for which section style options are available.
|
|
73
|
+
*
|
|
74
|
+
* Each option can be:
|
|
75
|
+
* - `false`: Hide the option entirely from the editor
|
|
76
|
+
* - `true`: Show all supported values for that option
|
|
77
|
+
* - Array: Show only the specified values (for options that support arrays)
|
|
78
|
+
*/
|
|
79
|
+
interface SectionOptionsConfig {
|
|
80
|
+
/** Enable/disable background color selection */
|
|
81
|
+
backgroundColor?: boolean;
|
|
82
|
+
/** Enable/disable background image selection */
|
|
83
|
+
backgroundImage?: boolean;
|
|
84
|
+
/** Enable/disable background gradient selection */
|
|
85
|
+
backgroundGradient?: boolean;
|
|
86
|
+
/** Control available spacing values, or disable entirely */
|
|
87
|
+
spacing?: SectionSpacing[] | boolean;
|
|
88
|
+
/** Enable/disable text color selection */
|
|
89
|
+
textColor?: boolean;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Configuration for which container style options are available.
|
|
93
|
+
*
|
|
94
|
+
* Each option can be:
|
|
95
|
+
* - `false`: Hide the option entirely from the editor
|
|
96
|
+
* - `true`: Show all supported values for that option
|
|
97
|
+
* - Array: Show only the specified values
|
|
98
|
+
*/
|
|
99
|
+
interface ContainerOptionsConfig {
|
|
100
|
+
/** Control available max-width values, or disable entirely */
|
|
101
|
+
maxWidth?: ContainerMaxWidth[] | boolean;
|
|
102
|
+
/** Control available alignment values, or disable entirely */
|
|
103
|
+
alignment?: ContainerAlignment[] | boolean;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Site-level style configuration for SDK sites.
|
|
107
|
+
*
|
|
108
|
+
* This allows SDK sites to curate which styling options are available
|
|
109
|
+
* to editors in the section styles panel.
|
|
110
|
+
*/
|
|
111
|
+
interface SiteStyleConfig {
|
|
112
|
+
/**
|
|
113
|
+
* Curated list of background colors available in section styles.
|
|
114
|
+
* If not specified, falls back to theme colors (current behavior).
|
|
115
|
+
*/
|
|
116
|
+
sectionBackgrounds?: SectionBackground[];
|
|
117
|
+
/**
|
|
118
|
+
* Which section style options are enabled.
|
|
119
|
+
* Options not listed or set to false are hidden from editors.
|
|
120
|
+
*/
|
|
121
|
+
sectionOptions?: SectionOptionsConfig;
|
|
122
|
+
/**
|
|
123
|
+
* Container style constraints.
|
|
124
|
+
*/
|
|
125
|
+
containerOptions?: ContainerOptionsConfig;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* A select option for SDK-provided field options.
|
|
129
|
+
*/
|
|
130
|
+
interface FieldSelectOption {
|
|
131
|
+
/** The value stored when this option is selected */
|
|
132
|
+
value: string;
|
|
133
|
+
/** Display label shown in the dropdown */
|
|
134
|
+
label: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Configuration for a specific field within a block.
|
|
138
|
+
*
|
|
139
|
+
* Currently supports overriding select options, but designed
|
|
140
|
+
* for future extensions (defaultValue, required, etc.).
|
|
141
|
+
*/
|
|
142
|
+
interface BlockFieldConfig {
|
|
143
|
+
/** Override select options for this field */
|
|
144
|
+
options?: FieldSelectOption[];
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Per-block field configurations.
|
|
148
|
+
*
|
|
149
|
+
* Maps block IDs to field configurations, where each field config
|
|
150
|
+
* is keyed by field ID.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* {
|
|
155
|
+
* 'block.embed': {
|
|
156
|
+
* layout: {
|
|
157
|
+
* options: [
|
|
158
|
+
* { value: 'showcase', label: 'Showcase Grid' },
|
|
159
|
+
* { value: 'list', label: 'Simple List' },
|
|
160
|
+
* ]
|
|
161
|
+
* }
|
|
162
|
+
* }
|
|
163
|
+
* }
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
type BlockFieldOptionsMap = Record<string, Record<string, BlockFieldConfig>>;
|
|
167
|
+
/**
|
|
168
|
+
* Configuration for extending a built-in block with additional fields.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```typescript
|
|
172
|
+
* {
|
|
173
|
+
* fields: [
|
|
174
|
+
* {
|
|
175
|
+
* id: 'layout',
|
|
176
|
+
* type: 'select',
|
|
177
|
+
* label: 'Layout',
|
|
178
|
+
* defaultValue: 'default',
|
|
179
|
+
* options: [
|
|
180
|
+
* { value: 'default', label: 'Default' },
|
|
181
|
+
* { value: 'wide', label: 'Wide' },
|
|
182
|
+
* ],
|
|
183
|
+
* },
|
|
184
|
+
* ],
|
|
185
|
+
* }
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
interface BlockFieldExtension {
|
|
189
|
+
/**
|
|
190
|
+
* Additional fields to append to the block's form.
|
|
191
|
+
* Uses the same field definition format as block manifests.
|
|
192
|
+
* All field types are supported.
|
|
193
|
+
*
|
|
194
|
+
* Note: If a field is marked as `required: true`, it MUST have a `defaultValue`.
|
|
195
|
+
* This ensures existing blocks without this field can still be edited.
|
|
196
|
+
*/
|
|
197
|
+
fields: FieldDefinition[];
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Map of block IDs to their field extensions.
|
|
201
|
+
* Block IDs must be system blocks (e.g., 'block.bodyText', 'block.hero').
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* {
|
|
206
|
+
* 'block.bodyText': {
|
|
207
|
+
* fields: [
|
|
208
|
+
* { id: 'layout', type: 'select', label: 'Layout', ... },
|
|
209
|
+
* ],
|
|
210
|
+
* },
|
|
211
|
+
* 'block.hero': {
|
|
212
|
+
* fields: [
|
|
213
|
+
* { id: 'videoBackground', type: 'media', label: 'Video Background', ... },
|
|
214
|
+
* ],
|
|
215
|
+
* },
|
|
216
|
+
* }
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
type BlockFieldExtensionsMap = Record<string, BlockFieldExtension>;
|
|
220
|
+
/**
|
|
221
|
+
* Top-level SDK site configuration.
|
|
222
|
+
*
|
|
223
|
+
* This is the complete configuration that SDK sites define in their
|
|
224
|
+
* `riverbank.config.ts` file and expose via the `/.builder/config` endpoint.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* // riverbank.config.ts
|
|
229
|
+
* import { defineConfig } from '@riverbankcms/sdk/config';
|
|
230
|
+
*
|
|
231
|
+
* export default defineConfig({
|
|
232
|
+
* siteId: '123e4567-e89b-12d3-a456-426614174000',
|
|
233
|
+
* theme: {
|
|
234
|
+
* palette: {
|
|
235
|
+
* primary: '#6d28d9',
|
|
236
|
+
* secondary: '#4c1d95',
|
|
237
|
+
* accent: '#FF007F',
|
|
238
|
+
* highlight: '#facc15',
|
|
239
|
+
* },
|
|
240
|
+
* },
|
|
241
|
+
* styles: {
|
|
242
|
+
* sectionBackgrounds: [
|
|
243
|
+
* { id: 'primary', label: 'Purple', token: 'primary' },
|
|
244
|
+
* { id: 'accent', label: 'Pink', token: 'accent' },
|
|
245
|
+
* ],
|
|
246
|
+
* sectionOptions: {
|
|
247
|
+
* backgroundColor: true,
|
|
248
|
+
* backgroundImage: false,
|
|
249
|
+
* spacing: ['compact', 'default', 'spacious'],
|
|
250
|
+
* },
|
|
251
|
+
* },
|
|
252
|
+
* blockFieldOptions: {
|
|
253
|
+
* 'block.embed': {
|
|
254
|
+
* layout: {
|
|
255
|
+
* options: [
|
|
256
|
+
* { value: 'showcase', label: 'Showcase Grid' },
|
|
257
|
+
* { value: 'list', label: 'Simple List' },
|
|
258
|
+
* ]
|
|
259
|
+
* }
|
|
260
|
+
* }
|
|
261
|
+
* },
|
|
262
|
+
* });
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
interface RiverbankSiteConfig {
|
|
266
|
+
/** Site UUID from the dashboard - identifies which site this config belongs to */
|
|
267
|
+
siteId: string;
|
|
268
|
+
/** SDK-defined theme with color palette for token resolution */
|
|
269
|
+
theme?: SdkThemeConfig;
|
|
270
|
+
/** Style configuration for curating editor options */
|
|
271
|
+
styles?: SiteStyleConfig;
|
|
272
|
+
/**
|
|
273
|
+
* Custom blocks defined by the SDK site.
|
|
274
|
+
* These blocks appear in the block picker and are edited via CMS forms.
|
|
275
|
+
* SDK sites MUST provide blockOverrides for rendering.
|
|
276
|
+
*/
|
|
277
|
+
customBlocks?: SdkCustomBlock[];
|
|
278
|
+
/**
|
|
279
|
+
* Per-block field options.
|
|
280
|
+
*
|
|
281
|
+
* Allows SDK sites to define which options are available for specific
|
|
282
|
+
* fields in specific blocks. Widgets with `ui.widget: 'sdkSelect'`
|
|
283
|
+
* will use these options when available, falling back to field defaults.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```typescript
|
|
287
|
+
* blockFieldOptions: {
|
|
288
|
+
* 'block.embed': {
|
|
289
|
+
* layout: {
|
|
290
|
+
* options: [
|
|
291
|
+
* { value: 'showcase', label: 'Showcase Grid' },
|
|
292
|
+
* { value: 'list', label: 'Simple List' },
|
|
293
|
+
* ]
|
|
294
|
+
* }
|
|
295
|
+
* }
|
|
296
|
+
* }
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
blockFieldOptions?: BlockFieldOptionsMap;
|
|
300
|
+
/**
|
|
301
|
+
* Per-block field extensions.
|
|
302
|
+
*
|
|
303
|
+
* Allows SDK sites to add custom fields to built-in block types.
|
|
304
|
+
* Extended fields appear at the end of the block's editing form
|
|
305
|
+
* and their values are accessible in `blockOverrides` via the `content` prop.
|
|
306
|
+
*
|
|
307
|
+
* Note: Extended field IDs must not conflict with existing block fields.
|
|
308
|
+
* Required fields must have a `defaultValue` to support existing blocks.
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```typescript
|
|
312
|
+
* blockFieldExtensions: {
|
|
313
|
+
* 'block.bodyText': {
|
|
314
|
+
* fields: [
|
|
315
|
+
* {
|
|
316
|
+
* id: 'layout',
|
|
317
|
+
* type: 'select',
|
|
318
|
+
* label: 'Layout',
|
|
319
|
+
* defaultValue: 'default',
|
|
320
|
+
* options: [
|
|
321
|
+
* { value: 'default', label: 'Default' },
|
|
322
|
+
* { value: 'wide', label: 'Wide' },
|
|
323
|
+
* ],
|
|
324
|
+
* },
|
|
325
|
+
* ],
|
|
326
|
+
* },
|
|
327
|
+
* }
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
blockFieldExtensions?: BlockFieldExtensionsMap;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export type { BlockFieldConfig as B, ContainerOptionsConfig as C, FieldSelectOption as F, RiverbankSiteConfig as R, SiteStyleConfig as S, SectionBackground as a, SectionOptionsConfig as b, SectionSpacing as c, ContainerMaxWidth as d, ContainerAlignment as e, SdkThemeConfig as f, SdkThemePalette as g, BlockFieldOptionsMap as h, BlockFieldExtension as i, BlockFieldExtensionsMap as j };
|