@cmssy/cli 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/LICENSE +21 -0
- package/README.md +649 -0
- package/config.d.ts +2 -0
- package/config.js +2 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +236 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/add-source.d.ts +7 -0
- package/dist/commands/add-source.d.ts.map +1 -0
- package/dist/commands/add-source.js +238 -0
- package/dist/commands/add-source.js.map +1 -0
- package/dist/commands/build.d.ts +7 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +105 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/configure.d.ts +6 -0
- package/dist/commands/configure.d.ts.map +1 -0
- package/dist/commands/configure.js +42 -0
- package/dist/commands/configure.js.map +1 -0
- package/dist/commands/create.d.ts +18 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +444 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/dev.d.ts +6 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +962 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +362 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/migrate.d.ts +2 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +227 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/package.d.ts +7 -0
- package/dist/commands/package.d.ts.map +1 -0
- package/dist/commands/package.js +136 -0
- package/dist/commands/package.js.map +1 -0
- package/dist/commands/publish.d.ts +13 -0
- package/dist/commands/publish.d.ts.map +1 -0
- package/dist/commands/publish.js +910 -0
- package/dist/commands/publish.js.map +1 -0
- package/dist/commands/sync.d.ts +6 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +208 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/commands/upload.d.ts +7 -0
- package/dist/commands/upload.d.ts.map +1 -0
- package/dist/commands/upload.js +126 -0
- package/dist/commands/upload.js.map +1 -0
- package/dist/commands/workspaces.d.ts +2 -0
- package/dist/commands/workspaces.d.ts.map +1 -0
- package/dist/commands/workspaces.js +67 -0
- package/dist/commands/workspaces.js.map +1 -0
- package/dist/dev-ui/app.js +1284 -0
- package/dist/dev-ui/index.html +1511 -0
- package/dist/dev-ui-react/App.tsx +164 -0
- package/dist/dev-ui-react/__tests__/previewData.test.ts +193 -0
- package/dist/dev-ui-react/components/BlocksList.tsx +232 -0
- package/dist/dev-ui-react/components/Editor.tsx +469 -0
- package/dist/dev-ui-react/components/Preview.tsx +146 -0
- package/dist/dev-ui-react/hooks/useBlocks.ts +80 -0
- package/dist/dev-ui-react/index.html +13 -0
- package/dist/dev-ui-react/main.tsx +8 -0
- package/dist/dev-ui-react/styles.css +856 -0
- package/dist/dev-ui-react/types.ts +45 -0
- package/dist/types/block-config.d.ts +315 -0
- package/dist/types/block-config.d.ts.map +1 -0
- package/dist/types/block-config.js +8 -0
- package/dist/types/block-config.js.map +1 -0
- package/dist/utils/block-config.d.ts +10 -0
- package/dist/utils/block-config.d.ts.map +1 -0
- package/dist/utils/block-config.js +199 -0
- package/dist/utils/block-config.js.map +1 -0
- package/dist/utils/blocks-meta-cache.d.ts +28 -0
- package/dist/utils/blocks-meta-cache.d.ts.map +1 -0
- package/dist/utils/blocks-meta-cache.js +72 -0
- package/dist/utils/blocks-meta-cache.js.map +1 -0
- package/dist/utils/builder.d.ts +34 -0
- package/dist/utils/builder.d.ts.map +1 -0
- package/dist/utils/builder.js +140 -0
- package/dist/utils/builder.js.map +1 -0
- package/dist/utils/cmssy-config.d.ts +16 -0
- package/dist/utils/cmssy-config.d.ts.map +1 -0
- package/dist/utils/cmssy-config.js +19 -0
- package/dist/utils/cmssy-config.js.map +1 -0
- package/dist/utils/config.d.ts +9 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +46 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/field-schema.d.ts +12 -0
- package/dist/utils/field-schema.d.ts.map +1 -0
- package/dist/utils/field-schema.js +202 -0
- package/dist/utils/field-schema.js.map +1 -0
- package/dist/utils/graphql.d.ts +8 -0
- package/dist/utils/graphql.d.ts.map +1 -0
- package/dist/utils/graphql.js +118 -0
- package/dist/utils/graphql.js.map +1 -0
- package/dist/utils/publish-helpers.d.ts +35 -0
- package/dist/utils/publish-helpers.d.ts.map +1 -0
- package/dist/utils/publish-helpers.js +141 -0
- package/dist/utils/publish-helpers.js.map +1 -0
- package/dist/utils/scanner.d.ts +36 -0
- package/dist/utils/scanner.d.ts.map +1 -0
- package/dist/utils/scanner.js +140 -0
- package/dist/utils/scanner.js.map +1 -0
- package/dist/utils/type-generator.d.ts +9 -0
- package/dist/utils/type-generator.d.ts.map +1 -0
- package/dist/utils/type-generator.js +85 -0
- package/dist/utils/type-generator.js.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface Block {
|
|
2
|
+
type: 'block' | 'template';
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
category?: string;
|
|
7
|
+
tags?: string[];
|
|
8
|
+
version: string;
|
|
9
|
+
hasConfig?: boolean;
|
|
10
|
+
schema?: Record<string, FieldConfig>;
|
|
11
|
+
pages?: TemplatePage[];
|
|
12
|
+
layoutSlots?: LayoutSlot[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface FieldConfig {
|
|
16
|
+
type: string;
|
|
17
|
+
label: string;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
defaultValue?: unknown;
|
|
21
|
+
helpText?: string;
|
|
22
|
+
options?: Array<{ label: string; value: string }>;
|
|
23
|
+
schema?: Record<string, FieldConfig>;
|
|
24
|
+
minItems?: number;
|
|
25
|
+
maxItems?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface TemplatePage {
|
|
29
|
+
name: string;
|
|
30
|
+
slug: string;
|
|
31
|
+
blocksCount: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface LayoutSlot {
|
|
35
|
+
slot: 'header' | 'footer';
|
|
36
|
+
type: string;
|
|
37
|
+
content?: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface Filters {
|
|
41
|
+
search: string;
|
|
42
|
+
type: 'all' | 'block' | 'template';
|
|
43
|
+
category: string;
|
|
44
|
+
tags: string[];
|
|
45
|
+
}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
export type FieldType = "singleLine" | "multiLine" | "richText" | "numeric" | "date" | "media" | "link" | "select" | "multiselect" | "boolean" | "color" | "slider" | "repeater" | "pageSelector";
|
|
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
|
+
export interface BaseFieldConfig {
|
|
59
|
+
type: FieldType;
|
|
60
|
+
label: string;
|
|
61
|
+
required?: boolean;
|
|
62
|
+
placeholder?: string;
|
|
63
|
+
defaultValue?: unknown;
|
|
64
|
+
helpText?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Assign this field to a group.
|
|
67
|
+
* Fields with the same group value will be organized together in a collapsible section.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* group: "Logo" // Field appears in the "Logo" group
|
|
71
|
+
*/
|
|
72
|
+
group?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Conditionally show this field based on another field's value.
|
|
75
|
+
* When condition is not met, the field is hidden in the editor.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* showWhen: { field: "showCta", equals: true }
|
|
79
|
+
*/
|
|
80
|
+
showWhen?: ShowWhenCondition;
|
|
81
|
+
/**
|
|
82
|
+
* Extended validation rules for this field.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* validation: { minLength: 3, maxLength: 100 }
|
|
86
|
+
*/
|
|
87
|
+
validation?: FieldValidation;
|
|
88
|
+
}
|
|
89
|
+
export interface SelectFieldConfig extends BaseFieldConfig {
|
|
90
|
+
type: "select";
|
|
91
|
+
options: Array<{
|
|
92
|
+
label: string;
|
|
93
|
+
value: string;
|
|
94
|
+
}>;
|
|
95
|
+
}
|
|
96
|
+
export interface RepeaterFieldConfig extends BaseFieldConfig {
|
|
97
|
+
type: "repeater";
|
|
98
|
+
minItems?: number;
|
|
99
|
+
maxItems?: number;
|
|
100
|
+
schema: Record<string, FieldConfig>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Media field configuration.
|
|
104
|
+
* Media field values are plain string URLs (matching backend convention).
|
|
105
|
+
*/
|
|
106
|
+
export interface MediaFieldConfig extends Omit<BaseFieldConfig, "defaultValue"> {
|
|
107
|
+
type: "media";
|
|
108
|
+
/** URL string */
|
|
109
|
+
defaultValue?: string;
|
|
110
|
+
/** Accepted file types (e.g., "image/*,video/*") */
|
|
111
|
+
accept?: string;
|
|
112
|
+
/** Maximum file size in bytes */
|
|
113
|
+
maxSize?: number;
|
|
114
|
+
}
|
|
115
|
+
export type FieldConfig = BaseFieldConfig | SelectFieldConfig | RepeaterFieldConfig | MediaFieldConfig;
|
|
116
|
+
/**
|
|
117
|
+
* Available workspace modules that blocks can require.
|
|
118
|
+
* If a module is required but not enabled in the workspace, the block won't be usable.
|
|
119
|
+
*/
|
|
120
|
+
export type WorkspaceModule = "pim" | "crm" | "forms" | "analytics" | "newsletter" | "ecommerce";
|
|
121
|
+
/**
|
|
122
|
+
* Available feature flags that blocks can require.
|
|
123
|
+
* Features are workspace-level settings that can be enabled/disabled.
|
|
124
|
+
*/
|
|
125
|
+
export type FeatureFlag = "ai-generation" | "ai-translation" | "advanced-seo" | "a-b-testing" | "personalization";
|
|
126
|
+
/**
|
|
127
|
+
* Platform features and requirements that a block needs.
|
|
128
|
+
* These are validated at import time and passed via the `context` prop at runtime.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* requires: {
|
|
132
|
+
* auth: true, // Access to auth state
|
|
133
|
+
* modules: ['pim', 'ecommerce'], // Requires PIM and ecommerce modules
|
|
134
|
+
* permissions: ['media:write'], // Requires media write permission
|
|
135
|
+
* features: ['ai-generation'], // Requires AI generation feature
|
|
136
|
+
* }
|
|
137
|
+
*/
|
|
138
|
+
export interface BlockRequires {
|
|
139
|
+
/** Request auth context (isAuthenticated, customer, logout) */
|
|
140
|
+
auth?: boolean;
|
|
141
|
+
/** Request current language */
|
|
142
|
+
language?: boolean;
|
|
143
|
+
/** Request workspace info */
|
|
144
|
+
workspace?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Required workspace modules.
|
|
147
|
+
* Block won't be usable if any required module is not enabled.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* modules: ['pim', 'ecommerce']
|
|
151
|
+
*/
|
|
152
|
+
modules?: WorkspaceModule[];
|
|
153
|
+
/**
|
|
154
|
+
* Required user permissions to use this block.
|
|
155
|
+
* Format: "resource:action" (e.g., "media:write", "pages:publish")
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* permissions: ['media:write', 'pages:publish']
|
|
159
|
+
*/
|
|
160
|
+
permissions?: string[];
|
|
161
|
+
/**
|
|
162
|
+
* Required feature flags.
|
|
163
|
+
* Block won't be usable if any required feature is not enabled.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* features: ['ai-generation']
|
|
167
|
+
*/
|
|
168
|
+
features?: FeatureFlag[];
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Layout position type for blocks that should be rendered as site-wide layout elements.
|
|
172
|
+
* These positions support hierarchical inheritance from parent pages.
|
|
173
|
+
*
|
|
174
|
+
* - "header": Rendered at the top of every page (full width)
|
|
175
|
+
* - "footer": Rendered at the bottom of every page (full width)
|
|
176
|
+
* - "sidebar_left": Rendered on the left side of the content area
|
|
177
|
+
* - "sidebar_right": Rendered on the right side of the content area
|
|
178
|
+
* - "top": Rendered above the main content (within content area)
|
|
179
|
+
* - "bottom": Rendered below the main content (within content area)
|
|
180
|
+
*/
|
|
181
|
+
export type LayoutPosition = "header" | "footer" | "sidebar_left" | "sidebar_right" | "top" | "bottom";
|
|
182
|
+
export interface BlockConfig {
|
|
183
|
+
name: string;
|
|
184
|
+
description?: string;
|
|
185
|
+
longDescription?: string;
|
|
186
|
+
category: string;
|
|
187
|
+
tags?: string[];
|
|
188
|
+
/**
|
|
189
|
+
* Schema defining the block's editable fields.
|
|
190
|
+
* Use the `group` property on individual fields to organize them into collapsible sections.
|
|
191
|
+
*/
|
|
192
|
+
schema: Record<string, FieldConfig>;
|
|
193
|
+
/** Whether block requires client-side rendering (default: false = SSR) */
|
|
194
|
+
interactive?: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* If set, this block is a layout block that can be placed in the specified position.
|
|
197
|
+
* Layout blocks support hierarchical inheritance from parent pages.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* layoutPosition: "header" // This block will be used as the site header
|
|
201
|
+
* layoutPosition: "footer" // This block will be used as the site footer
|
|
202
|
+
* layoutPosition: "sidebar_left" // This block will be used as the left sidebar
|
|
203
|
+
*/
|
|
204
|
+
layoutPosition?: LayoutPosition;
|
|
205
|
+
/**
|
|
206
|
+
* Platform features this block needs.
|
|
207
|
+
* Requested features are passed via the `context` prop.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* requires: {
|
|
211
|
+
* auth: true, // Access to auth state (customer, logout)
|
|
212
|
+
* language: true, // Access to current language
|
|
213
|
+
* }
|
|
214
|
+
*/
|
|
215
|
+
requires?: BlockRequires;
|
|
216
|
+
pricing?: {
|
|
217
|
+
licenseType: "free" | "paid";
|
|
218
|
+
priceCents?: number;
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* A block instance within a template page.
|
|
223
|
+
*/
|
|
224
|
+
export interface TemplateBlockInstance {
|
|
225
|
+
/** Block type reference (e.g., "hero", "pricing-cards", "@vendor/blocks.hero") */
|
|
226
|
+
type: string;
|
|
227
|
+
/** Block content/props */
|
|
228
|
+
content?: Record<string, unknown>;
|
|
229
|
+
/** Block settings */
|
|
230
|
+
settings?: Record<string, unknown>;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* A page blueprint within a template.
|
|
234
|
+
*/
|
|
235
|
+
export interface TemplatePageBlueprint {
|
|
236
|
+
/** Page display name */
|
|
237
|
+
name: string;
|
|
238
|
+
/** URL-friendly slug */
|
|
239
|
+
slug: string;
|
|
240
|
+
/** Page type (optional, e.g., "home", "about", "contact") */
|
|
241
|
+
pageType?: string;
|
|
242
|
+
/** Blocks on this page */
|
|
243
|
+
blocks: TemplateBlockInstance[];
|
|
244
|
+
/** Page metadata */
|
|
245
|
+
metadata?: Record<string, unknown>;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Layout slot for site-wide elements.
|
|
249
|
+
* Supports all layout positions for hierarchical inheritance.
|
|
250
|
+
*/
|
|
251
|
+
export interface TemplateLayoutSlot {
|
|
252
|
+
/** Layout position */
|
|
253
|
+
slot: LayoutPosition;
|
|
254
|
+
/** Block type to use */
|
|
255
|
+
type: string;
|
|
256
|
+
/** Block content/props */
|
|
257
|
+
content?: Record<string, unknown>;
|
|
258
|
+
/** Block order within the position (for multiple blocks in same position) */
|
|
259
|
+
order?: number;
|
|
260
|
+
/** Whether this block is active (default: true) */
|
|
261
|
+
isActive?: boolean;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Theme configuration for template.
|
|
265
|
+
*/
|
|
266
|
+
export interface TemplateTheme {
|
|
267
|
+
colors?: Record<string, string>;
|
|
268
|
+
fonts?: Record<string, string>;
|
|
269
|
+
spacing?: Record<string, string>;
|
|
270
|
+
borderRadius?: Record<string, string>;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Template configuration - defines a complete website structure.
|
|
274
|
+
*/
|
|
275
|
+
export interface TemplateConfig {
|
|
276
|
+
/** Template display name */
|
|
277
|
+
name: string;
|
|
278
|
+
/** Template description */
|
|
279
|
+
description?: string;
|
|
280
|
+
/** Long description for marketplace */
|
|
281
|
+
longDescription?: string;
|
|
282
|
+
/** Category (e.g., "business", "portfolio", "ecommerce") */
|
|
283
|
+
category?: string;
|
|
284
|
+
/** Tags for search */
|
|
285
|
+
tags?: string[];
|
|
286
|
+
/**
|
|
287
|
+
* Pages in this template.
|
|
288
|
+
* Each page defines its structure and blocks.
|
|
289
|
+
*/
|
|
290
|
+
pages: TemplatePageBlueprint[];
|
|
291
|
+
/**
|
|
292
|
+
* Layout slots (header/footer) shared across all pages.
|
|
293
|
+
*/
|
|
294
|
+
layoutSlots?: TemplateLayoutSlot[];
|
|
295
|
+
/**
|
|
296
|
+
* Theme configuration.
|
|
297
|
+
*/
|
|
298
|
+
theme?: TemplateTheme;
|
|
299
|
+
/**
|
|
300
|
+
* Optional schema for template-level settings.
|
|
301
|
+
* These are settings that apply to the whole template (e.g., brand colors).
|
|
302
|
+
*/
|
|
303
|
+
schema?: Record<string, FieldConfig>;
|
|
304
|
+
/** Pricing configuration */
|
|
305
|
+
pricing?: {
|
|
306
|
+
licenseType: "free" | "paid";
|
|
307
|
+
priceCents?: number;
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
export type ResourceConfig = BlockConfig | TemplateConfig;
|
|
311
|
+
/**
|
|
312
|
+
* Type guard to check if config is a TemplateConfig
|
|
313
|
+
*/
|
|
314
|
+
export declare function isTemplateConfig(config: ResourceConfig): config is TemplateConfig;
|
|
315
|
+
//# sourceMappingURL=block-config.d.ts.map
|
|
@@ -0,0 +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,GACV,cAAc,CAAC;AAMnB;;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,MAAM,CAAC;CAClB;AAMD;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,iBAAiB;IAChC,+FAA+F;IAC/F,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gDAAgD;IAChD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iEAAiE;IACjE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAMD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,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,EAAE,MAAM,EAAE,CAAC;IAEhB;;;OAGG;IACH,KAAK,EAAE,qBAAqB,EAAE,CAAC;IAE/B;;OAEG;IACH,WAAW,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAEnC;;OAEG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IAEtB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAErC,4BAA4B;IAC5B,OAAO,CAAC,EAAE;QACR,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;QAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,cAAc,CAAC;AAE1D;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,IAAI,cAAc,CAEjF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block-config.js","sourceRoot":"","sources":["../../src/types/block-config.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAyZ9C;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAsB;IACrD,OAAO,OAAO,IAAI,MAAM,IAAI,KAAK,CAAC,OAAO,CAAE,MAAyB,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BlockConfig, FieldConfig, ResourceConfig, TemplateConfig } from "../types/block-config.js";
|
|
2
|
+
export declare function defineBlock(config: BlockConfig): BlockConfig;
|
|
3
|
+
export declare function defineTemplate(config: TemplateConfig): TemplateConfig;
|
|
4
|
+
export declare function loadBlockConfig(blockPath: string): Promise<ResourceConfig | null>;
|
|
5
|
+
export declare function validateSchema(schema: Record<string, FieldConfig>, blockPath: string): Promise<{
|
|
6
|
+
valid: boolean;
|
|
7
|
+
errors: string[];
|
|
8
|
+
}>;
|
|
9
|
+
export declare function generatePackageJsonMetadata(config: ResourceConfig, packageType: "block" | "template"): any;
|
|
10
|
+
//# sourceMappingURL=block-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block-config.d.ts","sourceRoot":"","sources":["../../src/utils/block-config.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,WAAW,EACX,WAAW,EAEX,cAAc,EAEd,cAAc,EACf,MAAM,0BAA0B,CAAC;AAIlC,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAE5D;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAErE;AAGD,wBAAsB,eAAe,CACnC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAoFhC;AAGD,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACnC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAqF/C;AAGD,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,cAAc,EACtB,WAAW,EAAE,OAAO,GAAG,UAAU,GAChC,GAAG,CAoBL"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { execSync } from "child_process";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { getFieldTypes, isValidFieldType } from "./field-schema.js";
|
|
6
|
+
// Helper function for type-safe config authoring
|
|
7
|
+
export function defineBlock(config) {
|
|
8
|
+
return config;
|
|
9
|
+
}
|
|
10
|
+
export function defineTemplate(config) {
|
|
11
|
+
return config;
|
|
12
|
+
}
|
|
13
|
+
// Load block.config.ts dynamically
|
|
14
|
+
export async function loadBlockConfig(blockPath) {
|
|
15
|
+
const configPath = path.join(blockPath, "block.config.ts");
|
|
16
|
+
if (!fs.existsSync(configPath)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
// Find tsx binary - try multiple locations
|
|
21
|
+
const cliPath = path.dirname(path.dirname(new URL(import.meta.url).pathname));
|
|
22
|
+
// Possible locations for tsx binary
|
|
23
|
+
const possibleTsxPaths = [
|
|
24
|
+
path.join(cliPath, "..", "node_modules", ".bin", "tsx"), // CLI's node_modules (dist -> root)
|
|
25
|
+
path.join(cliPath, "..", "..", "node_modules", ".bin", "tsx"), // If symlinked
|
|
26
|
+
path.join(process.cwd(), "node_modules", ".bin", "tsx"), // Project's node_modules
|
|
27
|
+
];
|
|
28
|
+
let tsxBinary = possibleTsxPaths.find((p) => fs.existsSync(p));
|
|
29
|
+
// If not found, use npx as fallback
|
|
30
|
+
if (!tsxBinary) {
|
|
31
|
+
tsxBinary = "npx -y tsx"; // Use npx with -y to auto-install if needed
|
|
32
|
+
}
|
|
33
|
+
const cacheDir = path.join(process.cwd(), ".cmssy", "cache");
|
|
34
|
+
fs.ensureDirSync(cacheDir);
|
|
35
|
+
// Create a mock cmssy-cli/config module in cache
|
|
36
|
+
const mockConfigPath = path.join(cacheDir, "cmssy-cli-config.mjs");
|
|
37
|
+
const mockConfig = `export const defineBlock = (config) => config;\nexport const defineTemplate = (config) => config;`;
|
|
38
|
+
fs.writeFileSync(mockConfigPath, mockConfig);
|
|
39
|
+
// Read original config and replace import path to point to mock
|
|
40
|
+
const configContent = fs.readFileSync(configPath, "utf-8");
|
|
41
|
+
const modifiedConfig = configContent.replace(/from\s+['"]cmssy-cli\/config['"]/g, `from '${mockConfigPath.replace(/\\/g, "/")}'`);
|
|
42
|
+
// Write modified config to temp file
|
|
43
|
+
const tempConfigPath = path.join(cacheDir, `temp-${path.basename(configPath)}`);
|
|
44
|
+
fs.writeFileSync(tempConfigPath, modifiedConfig);
|
|
45
|
+
// Execute with tsx - use --eval to import and output
|
|
46
|
+
const evalCode = `import cfg from '${tempConfigPath.replace(/\\/g, "/")}'; console.log(JSON.stringify(cfg.default || cfg));`;
|
|
47
|
+
// Build command - handle both direct binary path and npx
|
|
48
|
+
const command = tsxBinary.includes("npx")
|
|
49
|
+
? `${tsxBinary} --eval "${evalCode}"`
|
|
50
|
+
: `"${tsxBinary}" --eval "${evalCode}"`;
|
|
51
|
+
const output = execSync(command, {
|
|
52
|
+
encoding: "utf-8",
|
|
53
|
+
cwd: process.cwd(),
|
|
54
|
+
env: {
|
|
55
|
+
...process.env,
|
|
56
|
+
NODE_ENV: "development",
|
|
57
|
+
},
|
|
58
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
59
|
+
});
|
|
60
|
+
// Clean up
|
|
61
|
+
fs.removeSync(tempConfigPath);
|
|
62
|
+
fs.removeSync(mockConfigPath);
|
|
63
|
+
// Parse JSON output
|
|
64
|
+
const lines = output.trim().split("\n");
|
|
65
|
+
const jsonLine = lines[lines.length - 1];
|
|
66
|
+
const config = JSON.parse(jsonLine);
|
|
67
|
+
return config;
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
throw new Error(`Failed to load block.config.ts at ${configPath}: ${error.message}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Validate schema against backend field types
|
|
74
|
+
export async function validateSchema(schema, blockPath) {
|
|
75
|
+
const errors = [];
|
|
76
|
+
const fieldTypes = await getFieldTypes();
|
|
77
|
+
function validateField(key, field, parentPath = "") {
|
|
78
|
+
const fullPath = parentPath ? `${parentPath}.${key}` : key;
|
|
79
|
+
// Check if field type is valid
|
|
80
|
+
if (!isValidFieldType(field.type, fieldTypes)) {
|
|
81
|
+
errors.push(`Invalid field type "${field.type}" for field "${fullPath}". Valid types: ${fieldTypes
|
|
82
|
+
.map((ft) => ft.type)
|
|
83
|
+
.join(", ")}`);
|
|
84
|
+
}
|
|
85
|
+
// Validate repeater nested schema
|
|
86
|
+
if (field.type === "repeater") {
|
|
87
|
+
const repeaterField = field;
|
|
88
|
+
if (!repeaterField.schema || typeof repeaterField.schema !== "object") {
|
|
89
|
+
errors.push(`Repeater field "${fullPath}" must have a "schema" property`);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
// Recursively validate nested schema
|
|
93
|
+
Object.entries(repeaterField.schema).forEach(([nestedKey, nestedField]) => {
|
|
94
|
+
validateField(nestedKey, nestedField, fullPath);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
// Validate minItems/maxItems
|
|
98
|
+
if (repeaterField.minItems !== undefined && repeaterField.minItems < 0) {
|
|
99
|
+
errors.push(`Repeater field "${fullPath}" has invalid minItems (must be >= 0)`);
|
|
100
|
+
}
|
|
101
|
+
if (repeaterField.maxItems !== undefined && repeaterField.maxItems < 1) {
|
|
102
|
+
errors.push(`Repeater field "${fullPath}" has invalid maxItems (must be >= 1)`);
|
|
103
|
+
}
|
|
104
|
+
if (repeaterField.minItems &&
|
|
105
|
+
repeaterField.maxItems &&
|
|
106
|
+
repeaterField.minItems > repeaterField.maxItems) {
|
|
107
|
+
errors.push(`Repeater field "${fullPath}" has minItems > maxItems`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Validate select options
|
|
111
|
+
if (field.type === "select") {
|
|
112
|
+
const selectField = field;
|
|
113
|
+
if (!selectField.options ||
|
|
114
|
+
!Array.isArray(selectField.options) ||
|
|
115
|
+
selectField.options.length === 0) {
|
|
116
|
+
errors.push(`Select field "${fullPath}" must have at least one option`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Warn about required fields with default values
|
|
120
|
+
if (field.required && field.defaultValue !== undefined) {
|
|
121
|
+
console.warn(chalk.yellow(`Warning: Field "${fullPath}" is required but has a defaultValue. The defaultValue will be ignored.`));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
Object.entries(schema).forEach(([key, field]) => {
|
|
125
|
+
validateField(key, field);
|
|
126
|
+
});
|
|
127
|
+
return { valid: errors.length === 0, errors };
|
|
128
|
+
}
|
|
129
|
+
// Generate package.json cmssy section from block.config.ts
|
|
130
|
+
export function generatePackageJsonMetadata(config, packageType) {
|
|
131
|
+
// Convert schema to legacy schemaFields format (if schema exists)
|
|
132
|
+
const schemaFields = config.schema ? convertSchemaToLegacyFormat(config.schema) : [];
|
|
133
|
+
// Extract default content from schema
|
|
134
|
+
const defaultContent = config.schema ? extractDefaultContent(config.schema) : {};
|
|
135
|
+
return {
|
|
136
|
+
packageType,
|
|
137
|
+
displayName: config.name,
|
|
138
|
+
description: config.description,
|
|
139
|
+
longDescription: config.longDescription,
|
|
140
|
+
category: config.category || (packageType === "template" ? "pages" : "other"),
|
|
141
|
+
tags: config.tags || [],
|
|
142
|
+
interactive: config.interactive || false,
|
|
143
|
+
pricing: config.pricing || { licenseType: "free" },
|
|
144
|
+
schemaFields,
|
|
145
|
+
defaultContent,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function convertSchemaToLegacyFormat(schema) {
|
|
149
|
+
const fields = [];
|
|
150
|
+
function convertField(key, field) {
|
|
151
|
+
const baseField = {
|
|
152
|
+
key,
|
|
153
|
+
type: field.type,
|
|
154
|
+
label: field.label,
|
|
155
|
+
required: field.required || false,
|
|
156
|
+
};
|
|
157
|
+
// Add defaultValue if present
|
|
158
|
+
if (field.defaultValue !== undefined) {
|
|
159
|
+
baseField.defaultValue = field.defaultValue;
|
|
160
|
+
}
|
|
161
|
+
// Add placeholder if present
|
|
162
|
+
if (field.placeholder) {
|
|
163
|
+
baseField.placeholder = field.placeholder;
|
|
164
|
+
}
|
|
165
|
+
if (field.type === "select") {
|
|
166
|
+
const selectField = field;
|
|
167
|
+
baseField.options = selectField.options;
|
|
168
|
+
}
|
|
169
|
+
if (field.type === "repeater") {
|
|
170
|
+
const repeaterField = field;
|
|
171
|
+
const nestedFields = convertSchemaToLegacyFormat(repeaterField.schema);
|
|
172
|
+
baseField.minItems = repeaterField.minItems;
|
|
173
|
+
baseField.maxItems = repeaterField.maxItems;
|
|
174
|
+
baseField.itemSchema = {
|
|
175
|
+
type: "object",
|
|
176
|
+
fields: nestedFields,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
return baseField;
|
|
180
|
+
}
|
|
181
|
+
Object.entries(schema).forEach(([key, field]) => {
|
|
182
|
+
fields.push(convertField(key, field));
|
|
183
|
+
});
|
|
184
|
+
return fields;
|
|
185
|
+
}
|
|
186
|
+
function extractDefaultContent(schema) {
|
|
187
|
+
const content = {};
|
|
188
|
+
Object.entries(schema).forEach(([key, field]) => {
|
|
189
|
+
if (field.defaultValue !== undefined) {
|
|
190
|
+
content[key] = field.defaultValue;
|
|
191
|
+
}
|
|
192
|
+
else if (field.type === "repeater") {
|
|
193
|
+
// Repeaters default to empty array
|
|
194
|
+
content[key] = [];
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
return content;
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=block-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block-config.js","sourceRoot":"","sources":["../../src/utils/block-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AASxB,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEpE,iDAAiD;AACjD,MAAM,UAAU,WAAW,CAAC,MAAmB;IAC7C,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,MAAsB;IACnD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,mCAAmC;AACnC,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,SAAiB;IAEjB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;IAE3D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,O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,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,qBAAqB,CAAC,MAAmC;IAChE,MAAM,OAAO,GAAQ,EAAE,CAAC;IAExB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC9C,IAAI,KAAK,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC;QACpC,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACrC,mCAAmC;YACnC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ResourceConfig } from "../types/block-config.js";
|
|
2
|
+
export interface BlockMeta {
|
|
3
|
+
type: "block" | "template";
|
|
4
|
+
category?: string;
|
|
5
|
+
tags?: string[];
|
|
6
|
+
displayName?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
version?: string;
|
|
9
|
+
updatedAt: string;
|
|
10
|
+
}
|
|
11
|
+
export interface BlocksMetaCache {
|
|
12
|
+
version: 1;
|
|
13
|
+
blocks: Record<string, BlockMeta>;
|
|
14
|
+
}
|
|
15
|
+
export declare function loadMetaCache(cwd?: string): BlocksMetaCache;
|
|
16
|
+
export declare function saveMetaCache(cache: BlocksMetaCache, cwd?: string): void;
|
|
17
|
+
export declare function updateBlockInCache(name: string, type: "block" | "template", config: ResourceConfig | null, version?: string, cwd?: string): void;
|
|
18
|
+
export declare function removeBlockFromCache(name: string, cwd?: string): void;
|
|
19
|
+
export declare function getBlockMeta(name: string, cwd?: string): BlockMeta | null;
|
|
20
|
+
/**
|
|
21
|
+
* Get all unique categories from cache
|
|
22
|
+
*/
|
|
23
|
+
export declare function getCachedCategories(cwd?: string): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Get all unique tags from cache
|
|
26
|
+
*/
|
|
27
|
+
export declare function getCachedTags(cwd?: string): string[];
|
|
28
|
+
//# sourceMappingURL=blocks-meta-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks-meta-cache.d.ts","sourceRoot":"","sources":["../../src/utils/blocks-meta-cache.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI1D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,CAAC,CAAC;IACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACnC;AAMD,wBAAgB,aAAa,CAAC,GAAG,SAAgB,GAAG,eAAe,CAYlE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,SAAgB,GAAG,IAAI,CAI/E;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,GAAG,UAAU,EAC1B,MAAM,EAAE,cAAc,GAAG,IAAI,EAC7B,OAAO,CAAC,EAAE,MAAM,EAChB,GAAG,SAAgB,GAClB,IAAI,CAcN;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAgB,GAAG,IAAI,C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