@lightspeed/crane-api 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/types.d.ts ADDED
@@ -0,0 +1,622 @@
1
+ /// <reference types="vite/client" />
2
+
3
+
4
+
5
+
6
+ type ActionLinkType
7
+ = 'SCROLL_TO_TILE'
8
+ | 'HYPER_LINK'
9
+ | 'MAIL_LINK'
10
+ | 'TEL_LINK'
11
+ | 'GO_TO_STORE'
12
+ | 'GO_TO_STORE_LINK'
13
+ | 'GO_TO_PAGE'
14
+ | 'GO_TO_CATEGORY'
15
+ | 'GO_TO_CATEGORY_LINK';
16
+
17
+ interface ButtonContentData {
18
+ readonly title: string;
19
+ readonly type: ActionLinkType;
20
+ readonly link?: string;
21
+ readonly email?: string;
22
+ readonly phone?: string;
23
+ readonly tileId?: string;
24
+ readonly pageId?: string;
25
+ readonly pageUrl?: string;
26
+ }
27
+
28
+ interface ImageInfoData {
29
+ readonly url: string;
30
+ readonly width: number;
31
+ readonly height: number;
32
+ }
33
+
34
+ interface ImageBorderInfoData {
35
+ readonly homogeneity: boolean;
36
+ readonly color: {
37
+ readonly r: number;
38
+ readonly g: number;
39
+ readonly b: number;
40
+ readonly a: number;
41
+ };
42
+ }
43
+
44
+ interface ImageContentData {
45
+ readonly bucket: string;
46
+ readonly borderInfo: ImageBorderInfoData;
47
+ readonly set: Record<string, ImageInfoData>;
48
+ }
49
+
50
+ interface ToggleContentData {
51
+ readonly enabled: boolean;
52
+ }
53
+
54
+ const ProductSelectionType = {
55
+ CATEGORY: 'CATEGORY',
56
+ MANUAL: 'MANUAL',
57
+ } as const;
58
+
59
+ const CategorySelectionType = {
60
+ ROOT: 'ROOT',
61
+ MANUAL: 'MANUAL',
62
+ } as const;
63
+
64
+ type CategorySelectionType = keyof typeof CategorySelectionType;
65
+
66
+ interface CategorySelectorData {
67
+ readonly categories: {
68
+ readonly categoryIds: Array<number>;
69
+ readonly items: Array<CategoryItemData>;
70
+ readonly selectionType: CategorySelectionType;
71
+ };
72
+ }
73
+
74
+ interface ProductSelectorData {
75
+ readonly product?: {
76
+ readonly id: number;
77
+ };
78
+ readonly products?: {
79
+ readonly productIds: Array<number>;
80
+ readonly selectionType: keyof typeof ProductSelectionType;
81
+ };
82
+ readonly categoryId?: number;
83
+ }
84
+
85
+ interface ActionLink {
86
+ id: string;
87
+ title?: string;
88
+ type?: ActionLinkType;
89
+ link?: string;
90
+ email?: string;
91
+ phone?: string;
92
+ tileIdForScroll?: string;
93
+ pageIdForNavigate?: string;
94
+ showStoreCategories?: boolean;
95
+ isSubmenuOpened?: boolean;
96
+ categoryId?: number;
97
+ performAction?: () => void;
98
+ }
99
+
100
+ interface MenuContentData {
101
+ readonly items: ReadonlyArray<ActionLink>;
102
+ }
103
+
104
+ type LogoType = 'TEXT' | 'IMAGE';
105
+
106
+ interface LogoContentData {
107
+ readonly type: LogoType;
108
+ readonly text: string;
109
+ readonly image: ImageContentData;
110
+ }
111
+
112
+ type GlobalColorsString
113
+ = 'global.color.title'
114
+ | 'global.color.body'
115
+ | 'global.color.button'
116
+ | 'global.color.link'
117
+ | 'global.color.background';
118
+
119
+ type GlobalFontsString
120
+ = 'global.fontFamily.title'
121
+ | 'global.fontFamily.body';
122
+
123
+ type GlobalTextSizeString
124
+ = 'global.textSize.title'
125
+ | 'global.textSize.subtitle'
126
+ | 'global.textSize.body';
127
+
128
+ interface HSLColor {
129
+ h: number;
130
+ s: number;
131
+ l: number;
132
+ a: number;
133
+ }
134
+
135
+ interface RGBAColor {
136
+ r: number;
137
+ g: number;
138
+ b: number;
139
+ a: number;
140
+ }
141
+
142
+ // Note: We should check if RGBAColor has abbreviations or full names
143
+ interface RGBAColorNamed {
144
+ red: number;
145
+ green: number;
146
+ blue: number;
147
+ alpha: number;
148
+ }
149
+
150
+ interface Color {
151
+ raw: string;
152
+ hex: string;
153
+ hsl: HSLColor;
154
+ rgba: RGBAColor;
155
+ auto?: boolean;
156
+ }
157
+
158
+ interface SolidColor {
159
+ color: Color | GlobalColorsString | undefined;
160
+ }
161
+
162
+ interface GradientColor {
163
+ fromColor: Color | GlobalColorsString | undefined;
164
+ toColor: Color | GlobalColorsString | undefined;
165
+ }
166
+
167
+ interface TextDesignData {
168
+ font: string | GlobalFontsString | undefined;
169
+ size: number | GlobalTextSizeString | undefined;
170
+ bold: boolean | undefined;
171
+ italic: boolean | undefined;
172
+ color: Color | GlobalColorsString | undefined;
173
+ visible: boolean;
174
+ }
175
+
176
+ interface TextareaDesignData extends TextDesignData {
177
+ readonly whiteSpace: string;
178
+ }
179
+
180
+ type CapitalizationType
181
+ = 'none'
182
+ | 'all'
183
+ | 'small';
184
+
185
+ interface Frame {
186
+ visible: boolean;
187
+ width: number | undefined;
188
+ color: Color | GlobalColorsString | undefined;
189
+ }
190
+
191
+ interface LogoDesignData {
192
+ font: string | GlobalFontsString | undefined;
193
+ size: number | GlobalTextSizeString | undefined;
194
+ bold: boolean | undefined;
195
+ italic: boolean | undefined;
196
+ color: Color | GlobalColorsString | undefined;
197
+ visible: boolean;
198
+ spacing: number | undefined;
199
+ capitalization: CapitalizationType | undefined;
200
+ frame: Frame | undefined;
201
+ }
202
+
203
+ type ButtonAppearance
204
+ = 'solid-button'
205
+ | 'outline-button'
206
+ | 'text-link';
207
+
208
+ type ButtonSize
209
+ = 'small'
210
+ | 'medium'
211
+ | 'large';
212
+
213
+ type ButtonStyle
214
+ = 'round-corner'
215
+ | 'rectangle'
216
+ | 'pill';
217
+
218
+ interface ButtonDesignData {
219
+ appearance: ButtonAppearance | undefined;
220
+ font: string | GlobalFontsString | undefined;
221
+ size: ButtonSize | undefined;
222
+ style: ButtonStyle | undefined;
223
+ color: Color | GlobalColorsString | undefined;
224
+ visible: boolean;
225
+ }
226
+
227
+ type OverlayType
228
+ = 'solid'
229
+ | 'gradient'
230
+ | 'none';
231
+
232
+ interface Overlay {
233
+ type: OverlayType | undefined;
234
+ solid: SolidColor | undefined;
235
+ gradient: GradientColor | undefined;
236
+ }
237
+
238
+ interface ImageDesignData {
239
+ overlay: Overlay | undefined;
240
+ visible: boolean;
241
+ }
242
+
243
+ interface SelectboxDesignData {
244
+ value: string | undefined;
245
+ }
246
+
247
+ interface ToggleDesignData {
248
+ enabled: boolean | undefined;
249
+ }
250
+
251
+ type BackgroundType
252
+ = 'solid'
253
+ | 'gradient';
254
+
255
+ interface Background {
256
+ type: BackgroundType | undefined;
257
+ solid: SolidColor | undefined;
258
+ gradient: GradientColor | undefined;
259
+ }
260
+
261
+ interface BackgroundDesignData {
262
+ background: Background | undefined;
263
+ }
264
+
265
+ type MapEditorContentTypes = {
266
+ readonly INPUTBOX: string;
267
+ readonly TEXTAREA: string;
268
+ readonly BUTTON: ButtonContentData;
269
+ readonly IMAGE: ImageContentData;
270
+ readonly TOGGLE: ToggleContentData;
271
+ readonly SELECTBOX: string;
272
+ readonly MENU: MenuContentData;
273
+ readonly LOGO: LogoContentData;
274
+ };
275
+
276
+ interface InputboxContentEditor {
277
+ readonly type: 'INPUTBOX';
278
+ readonly label: Record<string, string>;
279
+ readonly placeholder: Record<string, string>;
280
+ }
281
+
282
+ interface TextareaContentEditor {
283
+ readonly type: 'TEXTAREA';
284
+ readonly label: Record<string, string>;
285
+ readonly placeholder: Record<string, string>;
286
+ }
287
+
288
+ interface ReportAbuse {
289
+ readonly title: string;
290
+ readonly url: string | undefined;
291
+ readonly target: string | undefined;
292
+ }
293
+
294
+ interface MadeWith {
295
+ readonly url: string | undefined;
296
+ readonly target: string | undefined;
297
+ readonly icon: string | undefined;
298
+ readonly poweredBy: string | undefined;
299
+ readonly company: string | undefined;
300
+ }
301
+
302
+ interface Language {
303
+ readonly code: string;
304
+ readonly description: string;
305
+ readonly main: boolean;
306
+ readonly selected: boolean;
307
+ readonly url: string;
308
+ }
309
+
310
+ interface Account {
311
+ readonly title: string | undefined;
312
+ readonly url: string | undefined;
313
+ readonly target: string | undefined;
314
+ }
315
+
316
+ interface Cart {
317
+ readonly url: string | undefined;
318
+ readonly count: number;
319
+ }
320
+
321
+ interface LegalPage {
322
+ readonly title: string | undefined;
323
+ readonly url: string | undefined;
324
+ }
325
+
326
+ interface SiteContent {
327
+ readonly isPreviewMode: boolean;
328
+ readonly reportAbuse?: ReportAbuse;
329
+ readonly madeWith?: MadeWith;
330
+ readonly languages?: Language[];
331
+ readonly account?: Account;
332
+ readonly cart?: Cart;
333
+ readonly legalPages?: LegalPage[];
334
+ }
335
+
336
+ interface ImageBorderInfo {
337
+ readonly homogeneity?: boolean;
338
+ readonly dominatingColor?: {
339
+ readonly red?: number;
340
+ readonly green?: number;
341
+ readonly blue?: number;
342
+ readonly alpha?: number;
343
+ };
344
+ }
345
+
346
+ interface AlternativeProductImage {
347
+ readonly imageUrl?: string;
348
+ readonly thumbnailImageUrl?: string;
349
+ readonly fullImageUrl?: string;
350
+ readonly imageBorderInfo?: ImageBorderInfo;
351
+ readonly alt?: string;
352
+ }
353
+
354
+ interface LowestPrice {
355
+ readonly priceFormatted: string;
356
+ readonly label: string;
357
+ readonly countDateFromCreate: string;
358
+ }
359
+
360
+ interface RibbonSettings {
361
+ readonly text: string;
362
+ readonly color: RGBAColorNamed;
363
+ }
364
+
365
+ type ProductLegalInfoType = 'TAX_EXEMPT_BUSINESS' | 'TAX_INCLUDED' | 'TERMS_LINK';
366
+
367
+ interface ProductLegalInfo {
368
+ readonly type: ProductLegalInfoType;
369
+ readonly text: string;
370
+ readonly url?: string;
371
+ readonly urlTarget?: string;
372
+ }
373
+
374
+ interface RecurringChargeSettings {
375
+ readonly subscriptionPriceWithSignUpFee?: number;
376
+ readonly subscriptionPriceWithSignUpFeeFormatted?: string;
377
+ }
378
+
379
+ interface SubscriptionSettings {
380
+ readonly subscriptionAllowed: boolean;
381
+ readonly oneTimePurchaseAllowed: boolean;
382
+ readonly recurringChargeSettings: RecurringChargeSettings[];
383
+ readonly oneTimePurchasePrice?: number;
384
+ readonly oneTimePurchasePriceFormatted?: string;
385
+ readonly oneTimePurchaseMarkupPercent?: number;
386
+ }
387
+
388
+ interface ProductRatingItem {
389
+ readonly rating?: number;
390
+ readonly reviewsPublished?: number;
391
+ readonly isHideRating?: boolean;
392
+ readonly isHideCount?: boolean;
393
+ readonly isHideReviewFullStars?: boolean;
394
+ }
395
+
396
+ interface ProductListComponentItem {
397
+ readonly id: number;
398
+ readonly name: string;
399
+ readonly url: string;
400
+ readonly imageUrl?: string;
401
+ readonly thumbnailImageUrl?: string;
402
+ readonly fullImageUrl?: string;
403
+ readonly imageBorderInfo: ImageBorderInfo;
404
+ readonly alternativeProductImage?: AlternativeProductImage;
405
+ readonly description?: string;
406
+ readonly price: number;
407
+ readonly comparePrice?: number;
408
+ readonly formattedPrice: string;
409
+ readonly formattedComparePrice?: string;
410
+ readonly lowestPrice?: LowestPrice;
411
+ readonly zeroPrice?: boolean;
412
+ readonly inStock: boolean;
413
+ readonly subtitle?: string;
414
+ readonly sku?: string;
415
+ readonly quantity?: number;
416
+ readonly ribbon?: RibbonSettings;
417
+ readonly nameYourPriceEnabled?: boolean;
418
+ readonly attributeValues?: string[];
419
+ readonly legalInfos?: ProductLegalInfo[];
420
+ readonly isSampleProduct?: boolean;
421
+ readonly subscriptionSettings?: SubscriptionSettings;
422
+ readonly preorder?: boolean;
423
+ readonly alt?: string;
424
+ readonly productRating?: ProductRatingItem;
425
+ readonly categoryName?: string;
426
+ readonly enabled?: boolean;
427
+ readonly isOnSale: boolean;
428
+ readonly defaultCategoryId?: number;
429
+ readonly categoryIds?: number[];
430
+ }
431
+
432
+ interface CategoryListComponentItem {
433
+ readonly id: number;
434
+ readonly name: string;
435
+ readonly url: string;
436
+ readonly imageUrl?: string;
437
+ readonly thumbnailImageUrl?: string;
438
+ readonly imageBorderInfo?: ImageBorderInfo;
439
+ readonly alt?: string;
440
+ readonly productsCount: number;
441
+ }
442
+
443
+ interface CategoryTree {
444
+ readonly id: number;
445
+ readonly name: string;
446
+ readonly nameTranslated: Record<string, string>;
447
+ readonly urlPath: string;
448
+ readonly enabled: boolean;
449
+ readonly children: CategoryTree[];
450
+ }
451
+
452
+ type CategoryTreeWithoutChildren = Omit<CategoryTree, 'children' | 'urlPath'>;
453
+ interface CategoryItemData extends CategoryTreeWithoutChildren {
454
+ itemId?: string;
455
+ parentId?: number;
456
+ customName?: string;
457
+ }
458
+
459
+ interface CategoryCollectionItem extends CategoryItemData, CategoryListComponentItem {
460
+ selectionType: CategorySelectionType;
461
+ }
462
+
463
+ interface CategoryCollectionItemElement extends CategoryItemData, CategoryListComponentItem {
464
+ readonly label: string;
465
+ readonly showCategory: boolean;
466
+ }
467
+
468
+ interface Category {
469
+ readonly categories?: CategoryListComponentItem[];
470
+ readonly categoryTree?: CategoryTree[];
471
+ }
472
+
473
+ interface StoreData {
474
+ readonly categories: CategoryListComponentItem[];
475
+ readonly products: ProductListComponentItem[];
476
+ }
477
+
478
+ interface ExternalContentData {
479
+ readonly site?: SiteContent;
480
+ readonly category?: Category;
481
+ readonly storeData?: StoreData;
482
+ }
483
+
484
+ interface ButtonContentEditor {
485
+ readonly type: 'BUTTON';
486
+ readonly label: Record<string, string>;
487
+ }
488
+
489
+ interface ImageContentEditor {
490
+ readonly type: 'IMAGE';
491
+ readonly label: Record<string, string>;
492
+ }
493
+
494
+ interface ToggleContentEditor {
495
+ readonly type: 'TOGGLE';
496
+ readonly label: Record<string, string>;
497
+ readonly description?: Record<string, string>;
498
+ }
499
+
500
+ interface SelectboxContentOption {
501
+ readonly value: string;
502
+ readonly label: Record<string, string>;
503
+ }
504
+
505
+ interface SelectboxContentEditor {
506
+ readonly type: 'SELECTBOX';
507
+ readonly label: Record<string, string>;
508
+ readonly placeholder: Record<string, string>;
509
+ readonly description?: Record<string, string>;
510
+ readonly options: ReadonlyArray<SelectboxOption>;
511
+ }
512
+
513
+ interface MenuContentEditor {
514
+ readonly type: 'MENU';
515
+ readonly label: Record<string, string>;
516
+ readonly items: ReadonlyArray<ActionLink>;
517
+ }
518
+
519
+ interface NavigationMenuContentEditor {
520
+ readonly type: 'NAVIGATION_MENU';
521
+ }
522
+
523
+ interface LogoContentEditor {
524
+ readonly type: 'LOGO';
525
+ readonly label: Record<string, string>;
526
+ }
527
+
528
+ type ContentEditor
529
+ = TextContentEditor
530
+ | MultilineTextContentEditor
531
+ | ButtonContentEditor
532
+ | ImageContentEditor
533
+ | ToggleContentEditor
534
+ | SelectboxContentEditor
535
+ | MenuContentEditor
536
+ | NavigationMenuContentEditor
537
+ | LogoContentEditor;
538
+
539
+ type InferContentType<T extends Record<string, ContentEditor>> = {
540
+ readonly [P in keyof T]: MapEditorContentTypes[T[P]['type']]
541
+ };
542
+
543
+ type MapEditorDesignTypes = {
544
+ readonly TEXT: string;
545
+ readonly BUTTON: string;
546
+ readonly IMAGE: string;
547
+ readonly TOGGLE: string;
548
+ readonly SELECTBOX: string;
549
+ readonly BACKGROUND: string;
550
+ readonly COLOR_PICKER: string;
551
+ readonly LOGO: string;
552
+ readonly DIVIDER: string;
553
+ };
554
+
555
+ interface TextDesignEditor {
556
+ readonly type: 'TEXT';
557
+ readonly label: string | Record<string, string>;
558
+ defaults: Record<string, unknown>;
559
+ }
560
+
561
+ interface ButtonDesignEditor {
562
+ readonly type: 'BUTTON';
563
+ readonly label: string | Record<string, string>;
564
+ defaults: Record<string, unknown>;
565
+ }
566
+
567
+ interface ImageDesignEditor {
568
+ readonly type: 'IMAGE';
569
+ readonly label: string | Record<string, string>;
570
+ defaults: Record<string, unknown>;
571
+ }
572
+
573
+ interface ToggleDesignEditor {
574
+ readonly type: 'TOGGLE';
575
+ readonly label: string | Record<string, string>;
576
+ defaults: Record<string, unknown>;
577
+ }
578
+
579
+ interface SelectboxDesignEditor {
580
+ readonly type: 'SELECTBOX';
581
+ readonly label: string | Record<string, string>;
582
+ defaults: Record<string, unknown>;
583
+ }
584
+
585
+ interface BackgroundDesignEditor {
586
+ readonly type: 'BACKGROUND';
587
+ readonly label: string | Record<string, string>;
588
+ defaults: Record<string, unknown>;
589
+ }
590
+
591
+ interface ColorPickerDesignEditor {
592
+ readonly type: 'COLOR_PICKER';
593
+ defaults: Record<string, unknown>;
594
+ }
595
+
596
+ interface LogoDesignEditor {
597
+ readonly type: 'LOGO';
598
+ readonly label?: string | Record<string, string>;
599
+ defaults: Record<string, unknown>;
600
+ }
601
+
602
+ interface DividerDesignEditor {
603
+ readonly type: 'DIVIDER';
604
+ readonly label: string | Record<string, string>;
605
+ }
606
+
607
+ type DesignEditor
608
+ = TextDesignEditor
609
+ | ButtonDesignEditor
610
+ | ImageDesignEditor
611
+ | ToggleDesignEditor
612
+ | SelectboxDesignEditor
613
+ | BackgroundDesignEditor
614
+ | ColorPickerDesignEditor
615
+ | LogoDesignEditor
616
+ | DividerDesignEditor;
617
+
618
+ type InferDesignType<T extends Record<string, DesignEditor>> = {
619
+ readonly [P in keyof T]: MapEditorDesignTypes[T[P]['type']]
620
+ };
621
+
622
+ type SettingsEditor = DesignEditor | ContentEditor;