cmssy-cli 0.18.6 → 0.19.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/config.d.ts +1 -1
- package/dist/types/block-config.d.ts +197 -1
- package/dist/types/block-config.d.ts.map +1 -1
- package/package.json +1 -1
package/config.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { defineBlock, defineTemplate } from "./dist/utils/block-config.js";
|
|
2
|
-
export type { BlockConfig, TemplateConfig, FieldConfig, FieldType, BaseFieldConfig, SelectFieldConfig, RepeaterFieldConfig, } from "./dist/types/block-config.js";
|
|
2
|
+
export type { BlockConfig, TemplateConfig, FieldConfig, FieldType, BaseFieldConfig, SelectFieldConfig, RepeaterFieldConfig, BlockRequires, LayoutSlotType, FieldGroupConfig, ShowWhenCondition, FieldValidation, ValidationPattern, WorkspaceModule, FeatureFlag, } from "./dist/types/block-config.js";
|
|
@@ -1,11 +1,110 @@
|
|
|
1
1
|
export type FieldType = "singleLine" | "multiLine" | "richText" | "numeric" | "date" | "media" | "link" | "select" | "multiselect" | "boolean" | "color" | "slider" | "repeater";
|
|
2
|
+
/**
|
|
3
|
+
* Built-in validation patterns for common use cases.
|
|
4
|
+
*/
|
|
5
|
+
export type ValidationPattern = "email" | "url" | "phone" | "slug";
|
|
6
|
+
/**
|
|
7
|
+
* Extended validation configuration for fields.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* validation: {
|
|
11
|
+
* minLength: 3,
|
|
12
|
+
* maxLength: 100,
|
|
13
|
+
* pattern: "email",
|
|
14
|
+
* message: "Please enter a valid email address"
|
|
15
|
+
* }
|
|
16
|
+
*/
|
|
17
|
+
export interface FieldValidation {
|
|
18
|
+
/** Minimum length for string fields */
|
|
19
|
+
minLength?: number;
|
|
20
|
+
/** Maximum length for string fields */
|
|
21
|
+
maxLength?: number;
|
|
22
|
+
/** Minimum value for numeric fields */
|
|
23
|
+
min?: number;
|
|
24
|
+
/** Maximum value for numeric fields */
|
|
25
|
+
max?: number;
|
|
26
|
+
/** Validation pattern - built-in name or custom regex string */
|
|
27
|
+
pattern?: ValidationPattern | string;
|
|
28
|
+
/** Custom error message shown when validation fails */
|
|
29
|
+
message?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Condition for showing/hiding a field based on another field's value.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Show only when showCta is true
|
|
36
|
+
* showWhen: { field: "showCta", equals: true }
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* // Show only when layout is "custom"
|
|
40
|
+
* showWhen: { field: "layout", equals: "custom" }
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // Show when description is not empty
|
|
44
|
+
* showWhen: { field: "description", notEmpty: true }
|
|
45
|
+
*/
|
|
46
|
+
export interface ShowWhenCondition {
|
|
47
|
+
/** Field key to check (relative to current scope, or use "parent.field" for parent context) */
|
|
48
|
+
field: string;
|
|
49
|
+
/** Show when field equals this value */
|
|
50
|
+
equals?: unknown;
|
|
51
|
+
/** Show when field does not equal this value */
|
|
52
|
+
notEquals?: unknown;
|
|
53
|
+
/** Show when field value is not empty (truthy, non-empty string/array) */
|
|
54
|
+
notEmpty?: boolean;
|
|
55
|
+
/** Show when field value is empty (falsy, empty string/array) */
|
|
56
|
+
isEmpty?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Configuration for a field group.
|
|
60
|
+
* Groups organize related fields into collapsible sections in the editor.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* groups: {
|
|
64
|
+
* logo: { label: "Logo", icon: "Image" },
|
|
65
|
+
* cta: { label: "Call to Action", icon: "MousePointer", collapsed: true },
|
|
66
|
+
* }
|
|
67
|
+
*/
|
|
68
|
+
export interface FieldGroupConfig {
|
|
69
|
+
/** Display label for the group */
|
|
70
|
+
label: string;
|
|
71
|
+
/** Lucide icon name (e.g., "Image", "MousePointer", "Palette") */
|
|
72
|
+
icon?: string;
|
|
73
|
+
/** Whether the group is collapsed by default */
|
|
74
|
+
collapsed?: boolean;
|
|
75
|
+
/** Optional description shown below the group header */
|
|
76
|
+
description?: string;
|
|
77
|
+
}
|
|
2
78
|
export interface BaseFieldConfig {
|
|
3
79
|
type: FieldType;
|
|
4
80
|
label: string;
|
|
5
81
|
required?: boolean;
|
|
6
82
|
placeholder?: string;
|
|
7
|
-
defaultValue?:
|
|
83
|
+
defaultValue?: unknown;
|
|
8
84
|
helpText?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Assign this field to a group.
|
|
87
|
+
* The group must be defined in the block's `groups` configuration.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* group: "logo" // Field appears in the "logo" group
|
|
91
|
+
*/
|
|
92
|
+
group?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Conditionally show this field based on another field's value.
|
|
95
|
+
* When condition is not met, the field is hidden in the editor.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* showWhen: { field: "showCta", equals: true }
|
|
99
|
+
*/
|
|
100
|
+
showWhen?: ShowWhenCondition;
|
|
101
|
+
/**
|
|
102
|
+
* Extended validation rules for this field.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* validation: { minLength: 3, maxLength: 100 }
|
|
106
|
+
*/
|
|
107
|
+
validation?: FieldValidation;
|
|
9
108
|
}
|
|
10
109
|
export interface SelectFieldConfig extends BaseFieldConfig {
|
|
11
110
|
type: "select";
|
|
@@ -21,14 +120,111 @@ export interface RepeaterFieldConfig extends BaseFieldConfig {
|
|
|
21
120
|
schema: Record<string, FieldConfig>;
|
|
22
121
|
}
|
|
23
122
|
export type FieldConfig = BaseFieldConfig | SelectFieldConfig | RepeaterFieldConfig;
|
|
123
|
+
/**
|
|
124
|
+
* Available workspace modules that blocks can require.
|
|
125
|
+
* If a module is required but not enabled in the workspace, the block won't be usable.
|
|
126
|
+
*/
|
|
127
|
+
export type WorkspaceModule = "pim" | "crm" | "forms" | "analytics" | "newsletter" | "ecommerce";
|
|
128
|
+
/**
|
|
129
|
+
* Available feature flags that blocks can require.
|
|
130
|
+
* Features are workspace-level settings that can be enabled/disabled.
|
|
131
|
+
*/
|
|
132
|
+
export type FeatureFlag = "ai-generation" | "ai-translation" | "advanced-seo" | "a-b-testing" | "personalization";
|
|
133
|
+
/**
|
|
134
|
+
* Platform features and requirements that a block needs.
|
|
135
|
+
* These are validated at import time and passed via the `context` prop at runtime.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* requires: {
|
|
139
|
+
* auth: true, // Access to auth state
|
|
140
|
+
* modules: ['pim', 'ecommerce'], // Requires PIM and ecommerce modules
|
|
141
|
+
* permissions: ['media:write'], // Requires media write permission
|
|
142
|
+
* features: ['ai-generation'], // Requires AI generation feature
|
|
143
|
+
* }
|
|
144
|
+
*/
|
|
145
|
+
export interface BlockRequires {
|
|
146
|
+
/** Request auth context (isAuthenticated, customer, logout) */
|
|
147
|
+
auth?: boolean;
|
|
148
|
+
/** Request current language */
|
|
149
|
+
language?: boolean;
|
|
150
|
+
/** Request workspace info */
|
|
151
|
+
workspace?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Required workspace modules.
|
|
154
|
+
* Block won't be usable if any required module is not enabled.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* modules: ['pim', 'ecommerce']
|
|
158
|
+
*/
|
|
159
|
+
modules?: WorkspaceModule[];
|
|
160
|
+
/**
|
|
161
|
+
* Required user permissions to use this block.
|
|
162
|
+
* Format: "resource:action" (e.g., "media:write", "pages:publish")
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* permissions: ['media:write', 'pages:publish']
|
|
166
|
+
*/
|
|
167
|
+
permissions?: string[];
|
|
168
|
+
/**
|
|
169
|
+
* Required feature flags.
|
|
170
|
+
* Block won't be usable if any required feature is not enabled.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* features: ['ai-generation']
|
|
174
|
+
*/
|
|
175
|
+
features?: FeatureFlag[];
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Layout slot type for blocks that should be rendered as site-wide layout elements.
|
|
179
|
+
* - "header": Rendered at the top of every page
|
|
180
|
+
* - "footer": Rendered at the bottom of every page
|
|
181
|
+
*/
|
|
182
|
+
export type LayoutSlotType = "header" | "footer";
|
|
24
183
|
export interface BlockConfig {
|
|
25
184
|
name: string;
|
|
26
185
|
description?: string;
|
|
27
186
|
longDescription?: string;
|
|
28
187
|
category: string;
|
|
29
188
|
tags?: string[];
|
|
189
|
+
/**
|
|
190
|
+
* Field group definitions for organizing the schema.
|
|
191
|
+
* Groups create collapsible sections in the properties panel.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* groups: {
|
|
195
|
+
* logo: { label: "Logo", icon: "Image" },
|
|
196
|
+
* cta: { label: "Call to Action", collapsed: true },
|
|
197
|
+
* style: { label: "Styling", icon: "Palette", collapsed: true },
|
|
198
|
+
* }
|
|
199
|
+
*/
|
|
200
|
+
groups?: Record<string, FieldGroupConfig>;
|
|
201
|
+
/**
|
|
202
|
+
* Schema defining the block's editable fields.
|
|
203
|
+
* Use the `group` property on fields to organize them into groups.
|
|
204
|
+
*/
|
|
30
205
|
schema: Record<string, FieldConfig>;
|
|
206
|
+
/** Whether block requires client-side rendering (default: false = SSR) */
|
|
31
207
|
interactive?: boolean;
|
|
208
|
+
/**
|
|
209
|
+
* If set, this block is a layout block that will be rendered on every page.
|
|
210
|
+
* When imported to a workspace, it will automatically create/update the corresponding LayoutSlot.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* layoutSlot: "header" // This block will be used as the site header
|
|
214
|
+
* layoutSlot: "footer" // This block will be used as the site footer
|
|
215
|
+
*/
|
|
216
|
+
layoutSlot?: LayoutSlotType;
|
|
217
|
+
/**
|
|
218
|
+
* Platform features this block needs.
|
|
219
|
+
* Requested features are passed via the `context` prop.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* requires: {
|
|
223
|
+
* auth: true, // Access to auth state (customer, logout)
|
|
224
|
+
* language: true, // Access to current language
|
|
225
|
+
* }
|
|
226
|
+
*/
|
|
227
|
+
requires?: BlockRequires;
|
|
32
228
|
pricing?: {
|
|
33
229
|
licenseType: "free" | "paid";
|
|
34
230
|
priceCents?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block-config.d.ts","sourceRoot":"","sources":["../../src/types/block-config.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GACjB,YAAY,GACZ,WAAW,GACX,UAAU,GACV,SAAS,GACT,MAAM,GACN,OAAO,GACP,MAAM,GACN,QAAQ,GACR,aAAa,GACb,SAAS,GACT,OAAO,GACP,QAAQ,GACR,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"block-config.d.ts","sourceRoot":"","sources":["../../src/types/block-config.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GACjB,YAAY,GACZ,WAAW,GACX,UAAU,GACV,SAAS,GACT,MAAM,GACN,OAAO,GACP,MAAM,GACN,QAAQ,GACR,aAAa,GACb,SAAS,GACT,OAAO,GACP,QAAQ,GACR,UAAU,CAAC;AAMf;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAEnE;;;;;;;;;;GAUG;AACH,MAAM,WAAW,eAAe;IAC9B,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAAC;IACrC,uDAAuD;IACvD,OAAO,CAAC,EAAE,M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