@ecomweb/sdk 0.3.0 → 0.5.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/dist/index.d.ts +487 -983
- package/dist/index.js +1730 -620
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -244,7 +244,7 @@ var emailBrandingShape = {
|
|
|
244
244
|
var emailBrandingSchema = z3.object(emailBrandingShape);
|
|
245
245
|
|
|
246
246
|
// src/types/store.ts
|
|
247
|
-
import { z as
|
|
247
|
+
import { z as z5 } from "zod";
|
|
248
248
|
|
|
249
249
|
// src/types/embedded-script.ts
|
|
250
250
|
import { z as z4 } from "zod";
|
|
@@ -268,247 +268,25 @@ var createEmbeddedScriptSchema = embeddedScriptSchema.pick({
|
|
|
268
268
|
});
|
|
269
269
|
var updateEmbeddedScriptSchema = createEmbeddedScriptSchema.partial();
|
|
270
270
|
|
|
271
|
-
// src/types/storefront-builder.ts
|
|
272
|
-
import { z as z5 } from "zod";
|
|
273
|
-
var sectionTypeSchema = z5.enum([
|
|
274
|
-
"hero_banner",
|
|
275
|
-
"category_grid",
|
|
276
|
-
"collection_grid",
|
|
277
|
-
"featured_products",
|
|
278
|
-
"text_with_image",
|
|
279
|
-
"rich_text",
|
|
280
|
-
"newsletter_signup"
|
|
281
|
-
]);
|
|
282
|
-
var sectionStyleSchema = z5.object({
|
|
283
|
-
background_color: z5.string().optional(),
|
|
284
|
-
text_color: z5.string().optional(),
|
|
285
|
-
padding_top: z5.string().optional(),
|
|
286
|
-
padding_right: z5.string().optional(),
|
|
287
|
-
padding_bottom: z5.string().optional(),
|
|
288
|
-
padding_left: z5.string().optional(),
|
|
289
|
-
margin_top: z5.string().optional(),
|
|
290
|
-
margin_right: z5.string().optional(),
|
|
291
|
-
margin_bottom: z5.string().optional(),
|
|
292
|
-
margin_left: z5.string().optional(),
|
|
293
|
-
text_align: z5.enum(["left", "center", "right", "justify"]).optional(),
|
|
294
|
-
max_width: z5.enum(["full", "xl", "lg", "md"]).optional()
|
|
295
|
-
});
|
|
296
|
-
var heroBannerItemSchema = z5.object({
|
|
297
|
-
id: z5.string(),
|
|
298
|
-
title: z5.string().optional(),
|
|
299
|
-
subtitle: z5.string().optional(),
|
|
300
|
-
image_url: z5.string().min(1),
|
|
301
|
-
link_url: z5.string().optional(),
|
|
302
|
-
button_text: z5.string().optional()
|
|
303
|
-
});
|
|
304
|
-
var heroBannerConfigSchema = z5.object({
|
|
305
|
-
banners: z5.array(heroBannerItemSchema).default([]),
|
|
306
|
-
autoplay: z5.boolean().default(true),
|
|
307
|
-
autoplay_interval: z5.number().min(1e3).max(3e4).default(5e3)
|
|
308
|
-
});
|
|
309
|
-
var categoryGridConfigSchema = z5.object({
|
|
310
|
-
category_ids: z5.array(z5.number()).default([]),
|
|
311
|
-
columns: z5.union([z5.literal(2), z5.literal(3), z5.literal(4), z5.literal(6)]).default(4),
|
|
312
|
-
show_names: z5.boolean().default(true),
|
|
313
|
-
show_count: z5.boolean().default(false),
|
|
314
|
-
title: z5.string().optional()
|
|
315
|
-
});
|
|
316
|
-
var collectionGridConfigSchema = z5.object({
|
|
317
|
-
collection_ids: z5.array(z5.number()).default([]),
|
|
318
|
-
columns: z5.union([z5.literal(2), z5.literal(3), z5.literal(4), z5.literal(6)]).default(4),
|
|
319
|
-
show_names: z5.boolean().default(true),
|
|
320
|
-
show_count: z5.boolean().default(false),
|
|
321
|
-
title: z5.string().optional()
|
|
322
|
-
});
|
|
323
|
-
var featuredProductsConfigSchema = z5.object({
|
|
324
|
-
collection_slug: z5.string().optional(),
|
|
325
|
-
product_ids: z5.array(z5.number()).optional(),
|
|
326
|
-
limit: z5.number().min(1).max(48).default(12),
|
|
327
|
-
columns: z5.union([z5.literal(2), z5.literal(3), z5.literal(4), z5.literal(6)]).default(4),
|
|
328
|
-
title: z5.string().optional()
|
|
329
|
-
});
|
|
330
|
-
var textWithImageConfigSchema = z5.object({
|
|
331
|
-
content: z5.string().default(""),
|
|
332
|
-
image_url: z5.string().default(""),
|
|
333
|
-
image_position: z5.enum(["left", "right"]).default("right")
|
|
334
|
-
});
|
|
335
|
-
var richTextConfigSchema = z5.object({
|
|
336
|
-
content: z5.string().default("")
|
|
337
|
-
});
|
|
338
|
-
var newsletterSignupConfigSchema = z5.object({
|
|
339
|
-
title: z5.string().optional(),
|
|
340
|
-
description: z5.string().optional(),
|
|
341
|
-
button_text: z5.string().optional()
|
|
342
|
-
});
|
|
343
|
-
var sectionConfigSchema = z5.union([
|
|
344
|
-
heroBannerConfigSchema,
|
|
345
|
-
categoryGridConfigSchema,
|
|
346
|
-
collectionGridConfigSchema,
|
|
347
|
-
featuredProductsConfigSchema,
|
|
348
|
-
textWithImageConfigSchema,
|
|
349
|
-
richTextConfigSchema,
|
|
350
|
-
newsletterSignupConfigSchema
|
|
351
|
-
]);
|
|
352
|
-
var builderSectionSchema = z5.object({
|
|
353
|
-
id: z5.string(),
|
|
354
|
-
type: sectionTypeSchema,
|
|
355
|
-
title: z5.string().optional(),
|
|
356
|
-
is_visible: z5.boolean().default(true),
|
|
357
|
-
content: z5.record(z5.string(), z5.any()).default({}),
|
|
358
|
-
style: sectionStyleSchema.default({})
|
|
359
|
-
});
|
|
360
|
-
var SECTION_CONFIG_SCHEMAS = {
|
|
361
|
-
hero_banner: heroBannerConfigSchema,
|
|
362
|
-
category_grid: categoryGridConfigSchema,
|
|
363
|
-
collection_grid: collectionGridConfigSchema,
|
|
364
|
-
featured_products: featuredProductsConfigSchema,
|
|
365
|
-
text_with_image: textWithImageConfigSchema,
|
|
366
|
-
rich_text: richTextConfigSchema,
|
|
367
|
-
newsletter_signup: newsletterSignupConfigSchema
|
|
368
|
-
};
|
|
369
|
-
function parseSectionContent(type, content) {
|
|
370
|
-
return SECTION_CONFIG_SCHEMAS[type].parse(content);
|
|
371
|
-
}
|
|
372
|
-
var WIDGET_REGISTRY = {
|
|
373
|
-
hero_banner: {
|
|
374
|
-
type: "hero_banner",
|
|
375
|
-
name: "section_types.hero_banner",
|
|
376
|
-
icon: "Image",
|
|
377
|
-
description: "type_descriptions.hero_banner",
|
|
378
|
-
category: "media",
|
|
379
|
-
defaultContent: { banners: [], autoplay: true, autoplay_interval: 5e3 },
|
|
380
|
-
defaultStyle: { padding_top: "0", padding_bottom: "0" }
|
|
381
|
-
},
|
|
382
|
-
category_grid: {
|
|
383
|
-
type: "category_grid",
|
|
384
|
-
name: "section_types.category_grid",
|
|
385
|
-
icon: "Grid3X3",
|
|
386
|
-
description: "type_descriptions.category_grid",
|
|
387
|
-
category: "commerce",
|
|
388
|
-
defaultContent: { category_ids: [], columns: 4, show_names: true, show_count: false, title: "" },
|
|
389
|
-
defaultStyle: { padding_top: "2rem", padding_bottom: "2rem" }
|
|
390
|
-
},
|
|
391
|
-
collection_grid: {
|
|
392
|
-
type: "collection_grid",
|
|
393
|
-
name: "section_types.collection_grid",
|
|
394
|
-
icon: "Grid3X3",
|
|
395
|
-
description: "type_descriptions.collection_grid",
|
|
396
|
-
category: "commerce",
|
|
397
|
-
defaultContent: {
|
|
398
|
-
collection_ids: [],
|
|
399
|
-
columns: 4,
|
|
400
|
-
show_names: true,
|
|
401
|
-
show_count: false,
|
|
402
|
-
title: ""
|
|
403
|
-
},
|
|
404
|
-
defaultStyle: { padding_top: "2rem", padding_bottom: "2rem" }
|
|
405
|
-
},
|
|
406
|
-
featured_products: {
|
|
407
|
-
type: "featured_products",
|
|
408
|
-
name: "section_types.featured_products",
|
|
409
|
-
icon: "Package",
|
|
410
|
-
description: "type_descriptions.featured_products",
|
|
411
|
-
category: "commerce",
|
|
412
|
-
defaultContent: { collection_slug: "", limit: 12, columns: 4, title: "" },
|
|
413
|
-
defaultStyle: { padding_top: "2rem", padding_bottom: "2rem" }
|
|
414
|
-
},
|
|
415
|
-
text_with_image: {
|
|
416
|
-
type: "text_with_image",
|
|
417
|
-
name: "section_types.text_with_image",
|
|
418
|
-
icon: "LayoutList",
|
|
419
|
-
description: "type_descriptions.text_with_image",
|
|
420
|
-
category: "content",
|
|
421
|
-
defaultContent: { content: "", image_url: "", image_position: "right" },
|
|
422
|
-
defaultStyle: { padding_top: "2rem", padding_bottom: "2rem" }
|
|
423
|
-
},
|
|
424
|
-
rich_text: {
|
|
425
|
-
type: "rich_text",
|
|
426
|
-
name: "section_types.rich_text",
|
|
427
|
-
icon: "Type",
|
|
428
|
-
description: "type_descriptions.rich_text",
|
|
429
|
-
category: "content",
|
|
430
|
-
defaultContent: { content: "" },
|
|
431
|
-
defaultStyle: { padding_top: "2rem", padding_bottom: "2rem", max_width: "lg" }
|
|
432
|
-
},
|
|
433
|
-
newsletter_signup: {
|
|
434
|
-
type: "newsletter_signup",
|
|
435
|
-
name: "section_types.newsletter_signup",
|
|
436
|
-
icon: "Mail",
|
|
437
|
-
description: "type_descriptions.newsletter_signup",
|
|
438
|
-
category: "engagement",
|
|
439
|
-
defaultContent: { title: "", description: "", button_text: "" },
|
|
440
|
-
defaultStyle: { padding_top: "2rem", padding_bottom: "2rem", max_width: "lg" }
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
var headerConfigSchema = z5.object({
|
|
444
|
-
show_logo: z5.boolean().default(true),
|
|
445
|
-
show_search: z5.boolean().default(true),
|
|
446
|
-
show_cart: z5.boolean().default(true),
|
|
447
|
-
show_auth: z5.boolean().default(true),
|
|
448
|
-
main_menu_ref: z5.string().optional(),
|
|
449
|
-
background_color: z5.string().optional(),
|
|
450
|
-
text_color: z5.string().optional(),
|
|
451
|
-
// Topbar (announcement bar above header)
|
|
452
|
-
topbar_message: z5.string().optional(),
|
|
453
|
-
topbar_container_class: z5.string().optional()
|
|
454
|
-
});
|
|
455
|
-
var footerConfigSchema = z5.object({
|
|
456
|
-
show_logo: z5.boolean().default(true),
|
|
457
|
-
show_social_links: z5.boolean().default(true),
|
|
458
|
-
customer_support_menu_ref: z5.string().optional(),
|
|
459
|
-
about_us_menu_ref: z5.string().optional(),
|
|
460
|
-
copyright_text: z5.string().optional(),
|
|
461
|
-
background_color: z5.string().optional(),
|
|
462
|
-
text_color: z5.string().optional()
|
|
463
|
-
});
|
|
464
|
-
var builderThemeConfigSchema = z5.object({
|
|
465
|
-
// Legacy fields (preserved for backward compat)
|
|
466
|
-
menu: z5.object({
|
|
467
|
-
main_menu: z5.string().optional(),
|
|
468
|
-
customer_support_menu: z5.string().optional(),
|
|
469
|
-
about_us_menu: z5.string().optional()
|
|
470
|
-
}).optional(),
|
|
471
|
-
topbar: z5.object({
|
|
472
|
-
message: z5.string().optional(),
|
|
473
|
-
container_class: z5.string().optional()
|
|
474
|
-
}).optional(),
|
|
475
|
-
homepage: z5.object({
|
|
476
|
-
collection_slug: z5.string().optional()
|
|
477
|
-
}).optional(),
|
|
478
|
-
checkout: z5.object({
|
|
479
|
-
term_link: z5.string().optional(),
|
|
480
|
-
policy_link: z5.string().optional()
|
|
481
|
-
}).optional(),
|
|
482
|
-
// Builder fields
|
|
483
|
-
sections: z5.array(builderSectionSchema).optional(),
|
|
484
|
-
header: headerConfigSchema.optional(),
|
|
485
|
-
footer: footerConfigSchema.optional()
|
|
486
|
-
}).passthrough();
|
|
487
|
-
var themeVersionSchema = z5.object({
|
|
488
|
-
id: z5.number(),
|
|
489
|
-
name: z5.string(),
|
|
490
|
-
theme_config_snapshot: builderThemeConfigSchema,
|
|
491
|
-
created_by: z5.string(),
|
|
492
|
-
created_at: z5.string(),
|
|
493
|
-
updated_at: z5.string()
|
|
494
|
-
});
|
|
495
|
-
|
|
496
271
|
// src/types/store.ts
|
|
497
|
-
var storeSchema =
|
|
272
|
+
var storeSchema = z5.object({
|
|
498
273
|
id: idSchema,
|
|
499
274
|
user_id: uuidSchema,
|
|
500
|
-
name:
|
|
501
|
-
description:
|
|
275
|
+
name: z5.string().min(1),
|
|
276
|
+
description: z5.string().optional().nullable(),
|
|
502
277
|
status: storeStatusSchema.default("pending")
|
|
503
278
|
}).extend(timestampSchema.shape).extend(deletedAtSchema.shape);
|
|
504
|
-
var storeConfigSchema =
|
|
279
|
+
var storeConfigSchema = z5.object({
|
|
505
280
|
id: idSchema,
|
|
506
281
|
store_id: idSchema,
|
|
507
|
-
subdomain:
|
|
508
|
-
custom_domain:
|
|
282
|
+
subdomain: z5.string().optional().nullable(),
|
|
283
|
+
custom_domain: z5.string().optional().nullable()
|
|
509
284
|
}).extend(timestampSchema.shape);
|
|
510
|
-
var
|
|
511
|
-
|
|
285
|
+
var legalLinksSchema = z5.object({
|
|
286
|
+
terms: z5.string().optional().nullable(),
|
|
287
|
+
privacy: z5.string().optional().nullable()
|
|
288
|
+
}).optional().nullable();
|
|
289
|
+
var storeSettingsSchema = z5.object({
|
|
512
290
|
id: idSchema,
|
|
513
291
|
store_id: idSchema,
|
|
514
292
|
logo_url: urlSchema,
|
|
@@ -518,21 +296,21 @@ var storeSettingsSchema = z6.object({
|
|
|
518
296
|
shopee_link: urlSchema,
|
|
519
297
|
facebook_link: urlSchema,
|
|
520
298
|
instagram_link: urlSchema,
|
|
521
|
-
google_analytics_key:
|
|
522
|
-
shop_introduction:
|
|
523
|
-
tagline:
|
|
524
|
-
blog_title:
|
|
525
|
-
is_blog_enabled:
|
|
526
|
-
currency_code:
|
|
527
|
-
review_requests_enabled:
|
|
299
|
+
google_analytics_key: z5.string().optional().nullable(),
|
|
300
|
+
shop_introduction: z5.string().optional().nullable(),
|
|
301
|
+
tagline: z5.string().optional().nullable(),
|
|
302
|
+
blog_title: z5.string().optional().nullable(),
|
|
303
|
+
is_blog_enabled: z5.boolean().optional().nullable(),
|
|
304
|
+
currency_code: z5.string().min(3).max(3).default("VND").optional().nullable(),
|
|
305
|
+
review_requests_enabled: z5.boolean().optional().nullable(),
|
|
528
306
|
/**
|
|
529
307
|
* Wrap the order sequence to form Order.order_code. A null prefix means
|
|
530
308
|
* the store never configured one and takes the default "#"; an empty
|
|
531
309
|
* string means the merchant deliberately cleared it.
|
|
532
310
|
*/
|
|
533
|
-
order_number_prefix:
|
|
534
|
-
order_number_suffix:
|
|
535
|
-
|
|
311
|
+
order_number_prefix: z5.string().optional().nullable(),
|
|
312
|
+
order_number_suffix: z5.string().optional().nullable(),
|
|
313
|
+
legal_links: legalLinksSchema
|
|
536
314
|
}).extend(emailBrandingShape).extend(optionalTimestampSchema.shape);
|
|
537
315
|
var createStoreSchema = storeSchema.omit({
|
|
538
316
|
id: true,
|
|
@@ -560,52 +338,51 @@ var updateStoreSettingsSchema = createStoreSettingsSchema.partial().omit({
|
|
|
560
338
|
var storeWithRelationsSchema = storeSchema.extend({
|
|
561
339
|
store_config: storeConfigSchema.optional().nullable(),
|
|
562
340
|
store_settings: storeSettingsSchema.optional().nullable(),
|
|
563
|
-
|
|
564
|
-
embedded_scripts: z6.array(embeddedScriptSchema).optional()
|
|
341
|
+
embedded_scripts: z5.array(embeddedScriptSchema).optional()
|
|
565
342
|
});
|
|
566
343
|
|
|
567
344
|
// src/types/product.ts
|
|
568
|
-
import { z as
|
|
345
|
+
import { z as z8 } from "zod";
|
|
569
346
|
|
|
570
347
|
// src/types/product-review.ts
|
|
571
|
-
import { z as
|
|
348
|
+
import { z as z7 } from "zod";
|
|
572
349
|
|
|
573
350
|
// src/types/pagination.ts
|
|
574
|
-
import { z as
|
|
575
|
-
var paginationMetaSchema =
|
|
576
|
-
total:
|
|
577
|
-
limit:
|
|
578
|
-
offset:
|
|
579
|
-
page:
|
|
580
|
-
totalPages:
|
|
581
|
-
hasNext:
|
|
582
|
-
hasPrev:
|
|
583
|
-
});
|
|
584
|
-
var paginatedResponseSchema = (itemSchema2) =>
|
|
585
|
-
data:
|
|
351
|
+
import { z as z6 } from "zod";
|
|
352
|
+
var paginationMetaSchema = z6.object({
|
|
353
|
+
total: z6.uint32(),
|
|
354
|
+
limit: z6.int32().positive(),
|
|
355
|
+
offset: z6.uint32(),
|
|
356
|
+
page: z6.int32().positive(),
|
|
357
|
+
totalPages: z6.uint32(),
|
|
358
|
+
hasNext: z6.boolean(),
|
|
359
|
+
hasPrev: z6.boolean()
|
|
360
|
+
});
|
|
361
|
+
var paginatedResponseSchema = (itemSchema2) => z6.object({
|
|
362
|
+
data: z6.array(itemSchema2),
|
|
586
363
|
meta: paginationMetaSchema
|
|
587
364
|
});
|
|
588
|
-
var baseQueryParamsSchema =
|
|
589
|
-
limit:
|
|
590
|
-
offset:
|
|
591
|
-
search:
|
|
592
|
-
sort_by:
|
|
365
|
+
var baseQueryParamsSchema = z6.object({
|
|
366
|
+
limit: z6.int32().min(1).max(100).optional(),
|
|
367
|
+
offset: z6.uint32().optional(),
|
|
368
|
+
search: z6.string().optional(),
|
|
369
|
+
sort_by: z6.string().optional(),
|
|
593
370
|
sort_order: sortOrderSchema.optional(),
|
|
594
371
|
created_after: timestampSchema.optional(),
|
|
595
372
|
created_before: timestampSchema.optional(),
|
|
596
373
|
updated_after: timestampSchema.optional(),
|
|
597
374
|
updated_before: timestampSchema.optional()
|
|
598
375
|
});
|
|
599
|
-
var baseDeleteOptionsSchema =
|
|
600
|
-
soft_delete:
|
|
601
|
-
reason:
|
|
602
|
-
force:
|
|
376
|
+
var baseDeleteOptionsSchema = z6.object({
|
|
377
|
+
soft_delete: z6.boolean().optional(),
|
|
378
|
+
reason: z6.string().optional(),
|
|
379
|
+
force: z6.boolean().optional()
|
|
603
380
|
});
|
|
604
|
-
var baseDeleteResultSchema =
|
|
605
|
-
success:
|
|
606
|
-
type:
|
|
607
|
-
message:
|
|
608
|
-
entity_id:
|
|
381
|
+
var baseDeleteResultSchema = z6.object({
|
|
382
|
+
success: z6.boolean(),
|
|
383
|
+
type: z6.enum(["soft", "hard"]),
|
|
384
|
+
message: z6.string(),
|
|
385
|
+
entity_id: z6.union([z6.number(), z6.string()]),
|
|
609
386
|
deleted_at: timestampSchema.optional()
|
|
610
387
|
});
|
|
611
388
|
var PAGINATION_DEFAULTS = {
|
|
@@ -619,8 +396,8 @@ var validatePaginationMeta = (data) => {
|
|
|
619
396
|
try {
|
|
620
397
|
return paginationMetaSchema.parse(data);
|
|
621
398
|
} catch (error) {
|
|
622
|
-
if (error instanceof
|
|
623
|
-
throw new Error(
|
|
399
|
+
if (error instanceof z6.ZodError) {
|
|
400
|
+
throw new Error(z6.prettifyError(error));
|
|
624
401
|
}
|
|
625
402
|
throw error;
|
|
626
403
|
}
|
|
@@ -629,19 +406,19 @@ var safeParsePaginationMeta = (data) => paginationMetaSchema.safeParse(data);
|
|
|
629
406
|
var safeParseBaseQueryParams = (data) => baseQueryParamsSchema.safeParse(data);
|
|
630
407
|
|
|
631
408
|
// src/types/product-review.ts
|
|
632
|
-
var reviewStatusSchema =
|
|
409
|
+
var reviewStatusSchema = z7.enum([
|
|
633
410
|
"PENDING",
|
|
634
411
|
"APPROVED",
|
|
635
412
|
"REJECTED",
|
|
636
413
|
"HIDDEN"
|
|
637
414
|
]);
|
|
638
|
-
var productReviewReplySchema =
|
|
415
|
+
var productReviewReplySchema = z7.object({
|
|
639
416
|
id: uuidSchema,
|
|
640
417
|
review_id: uuidSchema,
|
|
641
|
-
content:
|
|
418
|
+
content: z7.string().min(1),
|
|
642
419
|
author_id: uuidSchema,
|
|
643
|
-
author_name:
|
|
644
|
-
is_visible:
|
|
420
|
+
author_name: z7.string().min(1),
|
|
421
|
+
is_visible: z7.boolean().default(true)
|
|
645
422
|
}).extend(timestampSchema.shape).extend(deletedAtSchema.shape);
|
|
646
423
|
var createProductReviewReplySchema = productReviewReplySchema.omit({
|
|
647
424
|
id: true,
|
|
@@ -650,34 +427,34 @@ var createProductReviewReplySchema = productReviewReplySchema.omit({
|
|
|
650
427
|
deleted_at: true
|
|
651
428
|
});
|
|
652
429
|
var updateProductReviewReplySchema = productReviewReplySchema.partial().omit({ id: true, review_id: true, created_at: true });
|
|
653
|
-
var productReviewSchema =
|
|
430
|
+
var productReviewSchema = z7.object({
|
|
654
431
|
id: uuidSchema,
|
|
655
|
-
product_id:
|
|
656
|
-
product_name:
|
|
657
|
-
variant_id:
|
|
658
|
-
variant_name:
|
|
659
|
-
order_id:
|
|
660
|
-
order_number:
|
|
432
|
+
product_id: z7.bigint(),
|
|
433
|
+
product_name: z7.string().min(1),
|
|
434
|
+
variant_id: z7.bigint().optional().nullable(),
|
|
435
|
+
variant_name: z7.string().optional().nullable(),
|
|
436
|
+
order_id: z7.bigint().optional().nullable(),
|
|
437
|
+
order_number: z7.bigint().optional().nullable(),
|
|
661
438
|
user_id: uuidSchema.optional().nullable(),
|
|
662
|
-
reviewer_name:
|
|
439
|
+
reviewer_name: z7.string().min(1),
|
|
663
440
|
reviewer_email: emailSchema,
|
|
664
|
-
reviewer_avatar:
|
|
665
|
-
is_verified_buyer:
|
|
666
|
-
rating:
|
|
667
|
-
title:
|
|
668
|
-
content:
|
|
669
|
-
pros:
|
|
670
|
-
cons:
|
|
671
|
-
media:
|
|
441
|
+
reviewer_avatar: z7.string().url().optional().nullable(),
|
|
442
|
+
is_verified_buyer: z7.boolean().default(false),
|
|
443
|
+
rating: z7.int32().min(1).max(5),
|
|
444
|
+
title: z7.string().max(200).optional().nullable(),
|
|
445
|
+
content: z7.string().min(1),
|
|
446
|
+
pros: z7.array(z7.string()).default([]),
|
|
447
|
+
cons: z7.array(z7.string()).default([]),
|
|
448
|
+
media: z7.array(z7.any()).default([]),
|
|
672
449
|
status: reviewStatusSchema.default("PENDING"),
|
|
673
|
-
moderation_notes:
|
|
450
|
+
moderation_notes: z7.string().optional().nullable(),
|
|
674
451
|
approved_by: uuidSchema.optional().nullable(),
|
|
675
|
-
approved_at:
|
|
676
|
-
rejected_reason:
|
|
677
|
-
is_featured:
|
|
678
|
-
is_pinned:
|
|
679
|
-
display_order:
|
|
680
|
-
review_date:
|
|
452
|
+
approved_at: z7.iso.datetime().optional().nullable(),
|
|
453
|
+
rejected_reason: z7.string().optional().nullable(),
|
|
454
|
+
is_featured: z7.boolean().default(false),
|
|
455
|
+
is_pinned: z7.boolean().default(false),
|
|
456
|
+
display_order: z7.int32().optional().nullable(),
|
|
457
|
+
review_date: z7.iso.datetime().optional().nullable()
|
|
681
458
|
}).extend(timestampSchema.shape).extend(deletedAtSchema.shape);
|
|
682
459
|
var createProductReviewSchema = productReviewSchema.omit({
|
|
683
460
|
id: true,
|
|
@@ -687,43 +464,43 @@ var createProductReviewSchema = productReviewSchema.omit({
|
|
|
687
464
|
});
|
|
688
465
|
var updateProductReviewSchema = productReviewSchema.partial().omit({ id: true, created_at: true });
|
|
689
466
|
var productReviewWithRepliesSchema = productReviewSchema.extend({
|
|
690
|
-
review_replies:
|
|
467
|
+
review_replies: z7.array(productReviewReplySchema).optional()
|
|
691
468
|
});
|
|
692
|
-
var productReviewStatsSchema =
|
|
469
|
+
var productReviewStatsSchema = z7.object({
|
|
693
470
|
id: idSchema,
|
|
694
|
-
product_id:
|
|
695
|
-
total_reviews:
|
|
696
|
-
verified_reviews:
|
|
697
|
-
reviews_with_media:
|
|
698
|
-
reviews_with_reply:
|
|
699
|
-
average_rating:
|
|
700
|
-
rating_1_count:
|
|
701
|
-
rating_2_count:
|
|
702
|
-
rating_3_count:
|
|
703
|
-
rating_4_count:
|
|
704
|
-
rating_5_count:
|
|
705
|
-
last_review_at:
|
|
706
|
-
last_calculated_at:
|
|
707
|
-
updated_at:
|
|
471
|
+
product_id: z7.bigint(),
|
|
472
|
+
total_reviews: z7.int32().default(0),
|
|
473
|
+
verified_reviews: z7.int32().default(0),
|
|
474
|
+
reviews_with_media: z7.int32().default(0),
|
|
475
|
+
reviews_with_reply: z7.int32().default(0),
|
|
476
|
+
average_rating: z7.float64().default(0),
|
|
477
|
+
rating_1_count: z7.int32().default(0),
|
|
478
|
+
rating_2_count: z7.int32().default(0),
|
|
479
|
+
rating_3_count: z7.int32().default(0),
|
|
480
|
+
rating_4_count: z7.int32().default(0),
|
|
481
|
+
rating_5_count: z7.int32().default(0),
|
|
482
|
+
last_review_at: z7.iso.datetime().optional().nullable(),
|
|
483
|
+
last_calculated_at: z7.iso.datetime(),
|
|
484
|
+
updated_at: z7.iso.datetime()
|
|
708
485
|
});
|
|
709
486
|
var productReviewFiltersSchema = baseQueryParamsSchema.extend({
|
|
710
487
|
id: uuidSchema.optional(),
|
|
711
|
-
product_id:
|
|
488
|
+
product_id: z7.bigint().optional(),
|
|
712
489
|
user_id: uuidSchema.optional(),
|
|
713
|
-
rating:
|
|
714
|
-
min_rating:
|
|
715
|
-
max_rating:
|
|
490
|
+
rating: z7.int32().min(1).max(5).optional(),
|
|
491
|
+
min_rating: z7.int32().min(1).max(5).optional(),
|
|
492
|
+
max_rating: z7.int32().min(1).max(5).optional(),
|
|
716
493
|
status: reviewStatusSchema.optional(),
|
|
717
|
-
is_verified_buyer:
|
|
494
|
+
is_verified_buyer: z7.boolean().optional(),
|
|
718
495
|
reviewer_email: emailSchema.optional(),
|
|
719
|
-
reviewer_name:
|
|
720
|
-
has_media:
|
|
721
|
-
include_replies:
|
|
496
|
+
reviewer_name: z7.string().optional(),
|
|
497
|
+
has_media: z7.boolean().optional(),
|
|
498
|
+
include_replies: z7.boolean().optional()
|
|
722
499
|
});
|
|
723
500
|
var productReviewReplyFiltersSchema = baseQueryParamsSchema.extend({
|
|
724
501
|
id: uuidSchema.optional(),
|
|
725
502
|
review_id: uuidSchema.optional(),
|
|
726
|
-
is_visible:
|
|
503
|
+
is_visible: z7.boolean().optional(),
|
|
727
504
|
author_id: uuidSchema.optional()
|
|
728
505
|
});
|
|
729
506
|
|
|
@@ -808,60 +585,60 @@ function unavailable(level) {
|
|
|
808
585
|
}
|
|
809
586
|
|
|
810
587
|
// src/types/product.ts
|
|
811
|
-
var productSchema =
|
|
588
|
+
var productSchema = z8.object({
|
|
812
589
|
id: idSchema,
|
|
813
|
-
name:
|
|
814
|
-
slug:
|
|
815
|
-
description:
|
|
590
|
+
name: z8.string().min(1),
|
|
591
|
+
slug: z8.string().max(255).optional().nullable(),
|
|
592
|
+
description: z8.string().optional().nullable(),
|
|
816
593
|
status: productStatusSchema.default("active"),
|
|
817
594
|
category_id: idSchema.optional().nullable(),
|
|
818
|
-
is_featured:
|
|
595
|
+
is_featured: z8.boolean().default(false),
|
|
819
596
|
min_price: moneySchema.optional().nullable(),
|
|
820
597
|
max_price: moneySchema.optional().nullable(),
|
|
821
|
-
variant_mode:
|
|
822
|
-
external_id:
|
|
598
|
+
variant_mode: z8.string(),
|
|
599
|
+
external_id: z8.string().optional().nullable(),
|
|
823
600
|
images: jsonSchema
|
|
824
601
|
// Array of image objects
|
|
825
602
|
}).extend(timestampSchema.shape);
|
|
826
|
-
var productVariantSchema =
|
|
603
|
+
var productVariantSchema = z8.object({
|
|
827
604
|
id: idSchema,
|
|
828
605
|
product_id: idSchema,
|
|
829
606
|
sku_id: idSchema,
|
|
830
|
-
seller_sku:
|
|
831
|
-
external_id:
|
|
607
|
+
seller_sku: z8.string().optional().nullable(),
|
|
608
|
+
external_id: z8.string().optional().nullable(),
|
|
832
609
|
price: moneySchema,
|
|
833
|
-
inventory:
|
|
834
|
-
track_inventory:
|
|
835
|
-
inventory_policy:
|
|
610
|
+
inventory: z8.int32().default(0),
|
|
611
|
+
track_inventory: z8.boolean().default(true),
|
|
612
|
+
inventory_policy: z8.enum(INVENTORY_POLICIES).default("deny"),
|
|
836
613
|
// z.number(), not moneySchema: unit costs carry up to 4 decimals, and
|
|
837
614
|
// moneySchema (2 decimals) would reject a valid cost.
|
|
838
|
-
cost_per_item:
|
|
615
|
+
cost_per_item: z8.number().nonnegative().nullable().optional(),
|
|
839
616
|
weight: decimalSchema.optional().nullable(),
|
|
840
617
|
dimensions: dimensionsSchema,
|
|
841
|
-
is_default:
|
|
618
|
+
is_default: z8.boolean().default(false),
|
|
842
619
|
status: variantStatusSchema.default("active")
|
|
843
620
|
}).extend(timestampSchema.shape);
|
|
844
|
-
var variantOptionSchema =
|
|
621
|
+
var variantOptionSchema = z8.object({
|
|
845
622
|
id: idSchema,
|
|
846
|
-
name:
|
|
623
|
+
name: z8.string().min(1),
|
|
847
624
|
sort_order: positionOrderSchema
|
|
848
625
|
}).extend(timestampSchema.shape);
|
|
849
|
-
var variantOptionValueSchema =
|
|
626
|
+
var variantOptionValueSchema = z8.object({
|
|
850
627
|
id: idSchema,
|
|
851
628
|
option_id: idSchema,
|
|
852
|
-
value:
|
|
853
|
-
display_value:
|
|
854
|
-
image_url:
|
|
629
|
+
value: z8.string().min(1),
|
|
630
|
+
display_value: z8.string().min(1),
|
|
631
|
+
image_url: z8.string().default(""),
|
|
855
632
|
sort_order: positionOrderSchema,
|
|
856
|
-
swatch_type:
|
|
857
|
-
swatch_value:
|
|
633
|
+
swatch_type: z8.enum(["none", "color", "image"]).default("none"),
|
|
634
|
+
swatch_value: z8.string().default("")
|
|
858
635
|
}).extend(timestampSchema.shape);
|
|
859
|
-
var productVariantCombinationSchema =
|
|
636
|
+
var productVariantCombinationSchema = z8.object({
|
|
860
637
|
id: idSchema,
|
|
861
638
|
variant_id: idSchema,
|
|
862
639
|
option_id: idSchema,
|
|
863
640
|
option_value_id: idSchema,
|
|
864
|
-
created_at:
|
|
641
|
+
created_at: z8.iso.datetime()
|
|
865
642
|
});
|
|
866
643
|
var createProductSchema = productSchema.omit({
|
|
867
644
|
id: true,
|
|
@@ -909,35 +686,35 @@ var updateVariantOptionValueSchema = variantOptionValueSchema.omit({
|
|
|
909
686
|
}).partial().omit({
|
|
910
687
|
option_id: true
|
|
911
688
|
});
|
|
912
|
-
var productVariantCombinationEntrySchema =
|
|
689
|
+
var productVariantCombinationEntrySchema = z8.object({
|
|
913
690
|
attributes: variantOptionSchema,
|
|
914
691
|
attribute_values: variantOptionValueSchema
|
|
915
692
|
});
|
|
916
693
|
var productVariantWithCombinationsSchema = productVariantSchema.extend(
|
|
917
694
|
{
|
|
918
|
-
combinations:
|
|
695
|
+
combinations: z8.array(productVariantCombinationEntrySchema).optional()
|
|
919
696
|
}
|
|
920
697
|
);
|
|
921
|
-
var attributeLinkValueSchema =
|
|
922
|
-
key:
|
|
923
|
-
display:
|
|
924
|
-
swatch_type:
|
|
925
|
-
swatch_value:
|
|
926
|
-
attribute_value_id:
|
|
927
|
-
});
|
|
928
|
-
var attributeLinkSchema =
|
|
929
|
-
id:
|
|
930
|
-
position:
|
|
931
|
-
group:
|
|
932
|
-
is_visible:
|
|
933
|
-
is_variation:
|
|
934
|
-
attribute_id:
|
|
935
|
-
custom_name:
|
|
936
|
-
name:
|
|
937
|
-
values:
|
|
698
|
+
var attributeLinkValueSchema = z8.object({
|
|
699
|
+
key: z8.string(),
|
|
700
|
+
display: z8.string(),
|
|
701
|
+
swatch_type: z8.enum(["none", "color", "image"]),
|
|
702
|
+
swatch_value: z8.string(),
|
|
703
|
+
attribute_value_id: z8.number().nullable()
|
|
704
|
+
});
|
|
705
|
+
var attributeLinkSchema = z8.object({
|
|
706
|
+
id: z8.number(),
|
|
707
|
+
position: z8.number(),
|
|
708
|
+
group: z8.string().nullable(),
|
|
709
|
+
is_visible: z8.boolean(),
|
|
710
|
+
is_variation: z8.boolean(),
|
|
711
|
+
attribute_id: z8.number().nullable(),
|
|
712
|
+
custom_name: z8.string().nullable(),
|
|
713
|
+
name: z8.string(),
|
|
714
|
+
values: z8.array(attributeLinkValueSchema)
|
|
938
715
|
});
|
|
939
716
|
var productWithVariantsSchema = productSchema.extend({
|
|
940
|
-
variants:
|
|
717
|
+
variants: z8.array(productVariantWithCombinationsSchema).optional()
|
|
941
718
|
});
|
|
942
719
|
var productWithReviewStatsSchema = productSchema.extend({
|
|
943
720
|
review_stats: productReviewStatsSchema.optional().nullable()
|
|
@@ -947,17 +724,17 @@ var productWithVariantsAndReviewStatsSchema = productWithVariantsSchema.extend({
|
|
|
947
724
|
});
|
|
948
725
|
|
|
949
726
|
// src/types/category.ts
|
|
950
|
-
import { z as
|
|
951
|
-
var categorySchema =
|
|
727
|
+
import { z as z9 } from "zod";
|
|
728
|
+
var categorySchema = z9.object({
|
|
952
729
|
id: idSchema,
|
|
953
|
-
name:
|
|
954
|
-
slug:
|
|
955
|
-
description:
|
|
730
|
+
name: z9.string().min(1),
|
|
731
|
+
slug: z9.string().optional().nullable(),
|
|
732
|
+
description: z9.string().optional().nullable(),
|
|
956
733
|
image_url: urlSchema,
|
|
957
734
|
parent_id: idSchema.optional().nullable(),
|
|
958
735
|
sort_order: positionOrderSchema,
|
|
959
|
-
is_active:
|
|
960
|
-
external_cat_id:
|
|
736
|
+
is_active: z9.boolean().default(true),
|
|
737
|
+
external_cat_id: z9.string().optional().nullable()
|
|
961
738
|
}).extend(optionalTimestampSchema.shape);
|
|
962
739
|
var createCategorySchema = categorySchema.omit({
|
|
963
740
|
id: true,
|
|
@@ -966,47 +743,47 @@ var createCategorySchema = categorySchema.omit({
|
|
|
966
743
|
});
|
|
967
744
|
var updateCategorySchema = createCategorySchema.partial();
|
|
968
745
|
var categoryWithChildrenSchema = categorySchema.extend({
|
|
969
|
-
children:
|
|
746
|
+
children: z9.array(z9.lazy(() => categoryWithChildrenSchema)).optional()
|
|
970
747
|
});
|
|
971
|
-
var categoryTreeSchema =
|
|
748
|
+
var categoryTreeSchema = z9.array(
|
|
972
749
|
categoryWithChildrenSchema
|
|
973
750
|
);
|
|
974
751
|
|
|
975
752
|
// src/types/order.ts
|
|
976
|
-
import { z as
|
|
753
|
+
import { z as z10 } from "zod";
|
|
977
754
|
var ORDER_SOURCES = ["online", "pos", "phone", "admin"];
|
|
978
755
|
var ADMIN_ORDER_SOURCES = ["pos", "phone", "admin"];
|
|
979
|
-
var appliedPromotionSchema =
|
|
756
|
+
var appliedPromotionSchema = z10.object({
|
|
980
757
|
promotion_id: idSchema,
|
|
981
|
-
promotion_name:
|
|
758
|
+
promotion_name: z10.string().optional().nullable(),
|
|
982
759
|
discount_amount: moneySchema.optional().nullable(),
|
|
983
760
|
shipping_discount: moneySchema.optional().nullable()
|
|
984
761
|
});
|
|
985
|
-
var orderItemSchema =
|
|
762
|
+
var orderItemSchema = z10.object({
|
|
986
763
|
id: idSchema,
|
|
987
764
|
order_id: idSchema.optional().nullable(),
|
|
988
765
|
product_id: idSchema.optional().nullable(),
|
|
989
|
-
product_name:
|
|
990
|
-
product_image:
|
|
991
|
-
quantity:
|
|
766
|
+
product_name: z10.string().min(1),
|
|
767
|
+
product_image: z10.string().optional().nullable(),
|
|
768
|
+
quantity: z10.int32().min(1).default(1),
|
|
992
769
|
price: moneySchema,
|
|
993
770
|
original_price: moneySchema.optional().nullable(),
|
|
994
771
|
total: moneySchema,
|
|
995
772
|
discount: moneySchema.optional().nullable(),
|
|
996
|
-
applied_promotions:
|
|
773
|
+
applied_promotions: z10.array(appliedPromotionSchema).optional(),
|
|
997
774
|
variant_id: idSchema.optional().nullable(),
|
|
998
|
-
variant_name:
|
|
999
|
-
created_at:
|
|
775
|
+
variant_name: z10.string().optional().nullable(),
|
|
776
|
+
created_at: z10.iso.datetime().optional().nullable()
|
|
1000
777
|
});
|
|
1001
|
-
var orderSchema =
|
|
778
|
+
var orderSchema = z10.object({
|
|
1002
779
|
id: idSchema,
|
|
1003
780
|
user_id: uuidSchema.optional().nullable(),
|
|
1004
|
-
customer_name:
|
|
781
|
+
customer_name: z10.string().min(1),
|
|
1005
782
|
customer_email: emailSchema.nullable(),
|
|
1006
783
|
customer_phone: phoneSchema,
|
|
1007
|
-
customer_avatar:
|
|
784
|
+
customer_avatar: z10.string().optional().nullable(),
|
|
1008
785
|
// DEPRECATED: Legacy status field for backward compatibility
|
|
1009
|
-
status:
|
|
786
|
+
status: z10.string().optional().nullable(),
|
|
1010
787
|
// NEW: Separate status fields managed by state machines
|
|
1011
788
|
order_status: orderStatusSchema,
|
|
1012
789
|
fulfillment_status: fulfillmentStatusSchema,
|
|
@@ -1021,25 +798,25 @@ var orderSchema = z11.object({
|
|
|
1021
798
|
tax: moneySchema.default(0),
|
|
1022
799
|
discount: moneySchema.default(0),
|
|
1023
800
|
total: moneySchema.default(0),
|
|
1024
|
-
shipping_street:
|
|
1025
|
-
shipping_city:
|
|
1026
|
-
shipping_district:
|
|
1027
|
-
shipping_ward:
|
|
1028
|
-
shipping_postal_code:
|
|
1029
|
-
tracking_number:
|
|
1030
|
-
notes:
|
|
801
|
+
shipping_street: z10.string().min(1),
|
|
802
|
+
shipping_city: z10.string().min(1),
|
|
803
|
+
shipping_district: z10.string().optional().nullable(),
|
|
804
|
+
shipping_ward: z10.string().optional().nullable(),
|
|
805
|
+
shipping_postal_code: z10.string().optional().nullable(),
|
|
806
|
+
tracking_number: z10.string().optional().nullable(),
|
|
807
|
+
notes: z10.string().optional().nullable(),
|
|
1031
808
|
order_number: idSchema,
|
|
1032
|
-
order_code:
|
|
1033
|
-
items:
|
|
1034
|
-
applied_promotions:
|
|
1035
|
-
shipping_method_name:
|
|
1036
|
-
shipping_city_name:
|
|
1037
|
-
shipping_ward_name:
|
|
1038
|
-
source:
|
|
1039
|
-
created_by:
|
|
809
|
+
order_code: z10.string(),
|
|
810
|
+
items: z10.array(orderItemSchema).optional(),
|
|
811
|
+
applied_promotions: z10.array(appliedPromotionSchema).optional(),
|
|
812
|
+
shipping_method_name: z10.string().optional().nullable(),
|
|
813
|
+
shipping_city_name: z10.string().optional().nullable(),
|
|
814
|
+
shipping_ward_name: z10.string().optional().nullable(),
|
|
815
|
+
source: z10.enum(ORDER_SOURCES).default("online"),
|
|
816
|
+
created_by: z10.object({
|
|
1040
817
|
id: uuidSchema,
|
|
1041
|
-
name:
|
|
1042
|
-
email:
|
|
818
|
+
name: z10.string().nullable(),
|
|
819
|
+
email: z10.string().nullable()
|
|
1043
820
|
}).nullable().optional()
|
|
1044
821
|
}).extend(optionalTimestampSchema.shape);
|
|
1045
822
|
var createOrderSchema = orderSchema.omit({
|
|
@@ -1091,14 +868,14 @@ var updateOrderItemSchema = orderItemSchema.omit({
|
|
|
1091
868
|
order_id: true
|
|
1092
869
|
});
|
|
1093
870
|
var orderWithItemsSchema = orderSchema.extend({
|
|
1094
|
-
items:
|
|
871
|
+
items: z10.array(orderItemSchema).optional()
|
|
1095
872
|
});
|
|
1096
|
-
var customerOrderSummarySchema =
|
|
873
|
+
var customerOrderSummarySchema = z10.object({
|
|
1097
874
|
customer_email: emailSchema,
|
|
1098
|
-
customer_name:
|
|
1099
|
-
total_orders:
|
|
875
|
+
customer_name: z10.string(),
|
|
876
|
+
total_orders: z10.int32(),
|
|
1100
877
|
total_spent: moneySchema,
|
|
1101
|
-
last_order_date:
|
|
878
|
+
last_order_date: z10.iso.datetime().optional().nullable()
|
|
1102
879
|
});
|
|
1103
880
|
|
|
1104
881
|
// src/types/order-timeline.ts
|
|
@@ -1119,23 +896,23 @@ var ORDER_ACTOR_TYPES = [
|
|
|
1119
896
|
];
|
|
1120
897
|
|
|
1121
898
|
// src/types/promotion.ts
|
|
1122
|
-
import { z as
|
|
1123
|
-
var PromotionModeSchema =
|
|
1124
|
-
var PromotionTypeSchema =
|
|
899
|
+
import { z as z11 } from "zod";
|
|
900
|
+
var PromotionModeSchema = z11.enum(["DISCOUNT_CODE", "AUTOMATIC"]);
|
|
901
|
+
var PromotionTypeSchema = z11.enum([
|
|
1125
902
|
"PRODUCT_DISCOUNT",
|
|
1126
903
|
"CART_DISCOUNT",
|
|
1127
904
|
"FREE_SHIPPING",
|
|
1128
905
|
"FIXED_PRICE",
|
|
1129
906
|
"GIFT"
|
|
1130
907
|
]);
|
|
1131
|
-
var DiscountMethodSchema =
|
|
1132
|
-
var ConditionTypeSchema =
|
|
908
|
+
var DiscountMethodSchema = z11.enum(["PERCENTAGE", "FIXED_AMOUNT"]);
|
|
909
|
+
var ConditionTypeSchema = z11.enum([
|
|
1133
910
|
"PRODUCT",
|
|
1134
911
|
"CATEGORY",
|
|
1135
912
|
"VARIANT",
|
|
1136
913
|
"NONE"
|
|
1137
914
|
]);
|
|
1138
|
-
var PromotionStatusSchema =
|
|
915
|
+
var PromotionStatusSchema = z11.enum([
|
|
1139
916
|
"DRAFT",
|
|
1140
917
|
"ACTIVE",
|
|
1141
918
|
"EXPIRED",
|
|
@@ -1168,87 +945,87 @@ var PromotionStatus = {
|
|
|
1168
945
|
EXPIRED: "EXPIRED",
|
|
1169
946
|
DISABLED: "DISABLED"
|
|
1170
947
|
};
|
|
1171
|
-
var PromotionSchema =
|
|
1172
|
-
id:
|
|
1173
|
-
name:
|
|
948
|
+
var PromotionSchema = z11.object({
|
|
949
|
+
id: z11.number().int().positive(),
|
|
950
|
+
name: z11.string().min(1).max(255),
|
|
1174
951
|
mode: PromotionModeSchema,
|
|
1175
|
-
code:
|
|
1176
|
-
description:
|
|
1177
|
-
start_at:
|
|
1178
|
-
end_at:
|
|
952
|
+
code: z11.string().min(1).max(50).optional(),
|
|
953
|
+
description: z11.string().max(1e3).optional(),
|
|
954
|
+
start_at: z11.string().datetime(),
|
|
955
|
+
end_at: z11.string().datetime().optional(),
|
|
1179
956
|
status: PromotionStatusSchema,
|
|
1180
957
|
type: PromotionTypeSchema,
|
|
1181
958
|
condition_type: ConditionTypeSchema,
|
|
1182
|
-
target_ids:
|
|
1183
|
-
min_amount:
|
|
1184
|
-
min_quantity:
|
|
959
|
+
target_ids: z11.array(z11.string().uuid()).optional(),
|
|
960
|
+
min_amount: z11.number().positive().optional(),
|
|
961
|
+
min_quantity: z11.number().int().positive().optional(),
|
|
1185
962
|
discount_method: DiscountMethodSchema.optional(),
|
|
1186
|
-
discount_value:
|
|
1187
|
-
max_discount_amount:
|
|
1188
|
-
fixed_price:
|
|
1189
|
-
gift_product_ids:
|
|
1190
|
-
gift_quantity:
|
|
1191
|
-
usage_limit:
|
|
1192
|
-
usage_limit_per_user:
|
|
1193
|
-
checkout_suggestion_enabled:
|
|
1194
|
-
created_at:
|
|
1195
|
-
updated_at:
|
|
1196
|
-
created_by:
|
|
1197
|
-
updated_by:
|
|
1198
|
-
});
|
|
1199
|
-
var CreatePromotionSchema =
|
|
1200
|
-
name:
|
|
963
|
+
discount_value: z11.number().nonnegative().optional(),
|
|
964
|
+
max_discount_amount: z11.number().nonnegative().optional(),
|
|
965
|
+
fixed_price: z11.number().nonnegative().optional(),
|
|
966
|
+
gift_product_ids: z11.array(z11.string().uuid()),
|
|
967
|
+
gift_quantity: z11.number().int().positive().optional(),
|
|
968
|
+
usage_limit: z11.number().int().positive().optional(),
|
|
969
|
+
usage_limit_per_user: z11.number().int().positive().optional(),
|
|
970
|
+
checkout_suggestion_enabled: z11.boolean().optional(),
|
|
971
|
+
created_at: z11.string().datetime(),
|
|
972
|
+
updated_at: z11.string().datetime(),
|
|
973
|
+
created_by: z11.string().uuid().optional(),
|
|
974
|
+
updated_by: z11.string().uuid().optional()
|
|
975
|
+
});
|
|
976
|
+
var CreatePromotionSchema = z11.object({
|
|
977
|
+
name: z11.string().min(1, "T\xEAn khuy\u1EBFn m\xE3i l\xE0 b\u1EAFt bu\u1ED9c").max(255),
|
|
1201
978
|
mode: PromotionModeSchema,
|
|
1202
|
-
code:
|
|
1203
|
-
description:
|
|
1204
|
-
start_at:
|
|
1205
|
-
end_at:
|
|
979
|
+
code: z11.string().min(1).max(50).optional(),
|
|
980
|
+
description: z11.string().max(1e3).optional(),
|
|
981
|
+
start_at: z11.iso.datetime(),
|
|
982
|
+
end_at: z11.iso.datetime().optional(),
|
|
1206
983
|
type: PromotionTypeSchema,
|
|
1207
984
|
condition_type: ConditionTypeSchema,
|
|
1208
|
-
target_ids:
|
|
985
|
+
target_ids: z11.array(z11.uuid()).optional().superRefine((ids, ctx) => {
|
|
1209
986
|
const conditionType = ctx.parent?.condition_type;
|
|
1210
987
|
if (conditionType === "NONE") {
|
|
1211
988
|
return true;
|
|
1212
989
|
}
|
|
1213
990
|
return ids && ids.length > 0;
|
|
1214
991
|
}),
|
|
1215
|
-
min_amount:
|
|
1216
|
-
min_quantity:
|
|
992
|
+
min_amount: z11.number().positive().optional(),
|
|
993
|
+
min_quantity: z11.number().int().positive().optional(),
|
|
1217
994
|
discount_method: DiscountMethodSchema.optional(),
|
|
1218
|
-
discount_value:
|
|
1219
|
-
max_discount_amount:
|
|
1220
|
-
fixed_price:
|
|
1221
|
-
gift_product_ids:
|
|
1222
|
-
gift_quantity:
|
|
1223
|
-
usage_limit:
|
|
1224
|
-
usage_limit_per_user:
|
|
1225
|
-
checkout_suggestion_enabled:
|
|
995
|
+
discount_value: z11.number().nonnegative().optional(),
|
|
996
|
+
max_discount_amount: z11.number().nonnegative().optional(),
|
|
997
|
+
fixed_price: z11.number().nonnegative().optional(),
|
|
998
|
+
gift_product_ids: z11.array(z11.uuid()).optional(),
|
|
999
|
+
gift_quantity: z11.number().int().positive().optional(),
|
|
1000
|
+
usage_limit: z11.number().int().positive().optional(),
|
|
1001
|
+
usage_limit_per_user: z11.number().int().positive().optional(),
|
|
1002
|
+
checkout_suggestion_enabled: z11.boolean().optional()
|
|
1226
1003
|
});
|
|
1227
1004
|
var UpdatePromotionSchema = CreatePromotionSchema.partial().extend({
|
|
1228
1005
|
status: PromotionStatusSchema.optional()
|
|
1229
1006
|
});
|
|
1230
1007
|
var PromotionWithDiscountSchema = PromotionSchema.extend({
|
|
1231
|
-
discount_amount:
|
|
1232
|
-
});
|
|
1233
|
-
var PromotionStatisticsSchema =
|
|
1234
|
-
total_promotions:
|
|
1235
|
-
active_promotions:
|
|
1236
|
-
draft_promotions:
|
|
1237
|
-
expired_promotions:
|
|
1238
|
-
disabled_promotions:
|
|
1239
|
-
total_usage:
|
|
1240
|
-
total_discount_amount:
|
|
1241
|
-
top_promotions:
|
|
1242
|
-
});
|
|
1243
|
-
var PaginatedPromotionsResponseSchema =
|
|
1244
|
-
data:
|
|
1008
|
+
discount_amount: z11.number().optional()
|
|
1009
|
+
});
|
|
1010
|
+
var PromotionStatisticsSchema = z11.object({
|
|
1011
|
+
total_promotions: z11.number().int().nonnegative(),
|
|
1012
|
+
active_promotions: z11.number().int().nonnegative(),
|
|
1013
|
+
draft_promotions: z11.number().int().nonnegative(),
|
|
1014
|
+
expired_promotions: z11.number().int().nonnegative(),
|
|
1015
|
+
disabled_promotions: z11.number().int().nonnegative(),
|
|
1016
|
+
total_usage: z11.number().int().nonnegative(),
|
|
1017
|
+
total_discount_amount: z11.number().nonnegative(),
|
|
1018
|
+
top_promotions: z11.array(PromotionSchema)
|
|
1019
|
+
});
|
|
1020
|
+
var PaginatedPromotionsResponseSchema = z11.object({
|
|
1021
|
+
data: z11.array(PromotionSchema),
|
|
1245
1022
|
meta: paginationMetaSchema
|
|
1246
1023
|
});
|
|
1247
|
-
var PromotionQueryParamsSchema =
|
|
1248
|
-
limit:
|
|
1249
|
-
offset:
|
|
1250
|
-
order:
|
|
1251
|
-
sort:
|
|
1024
|
+
var PromotionQueryParamsSchema = z11.object({
|
|
1025
|
+
limit: z11.number().int().positive().optional(),
|
|
1026
|
+
offset: z11.number().int().nonnegative().optional(),
|
|
1027
|
+
order: z11.enum(["asc", "desc"]).optional(),
|
|
1028
|
+
sort: z11.enum([
|
|
1252
1029
|
"name",
|
|
1253
1030
|
"start_at",
|
|
1254
1031
|
"end_at",
|
|
@@ -1257,10 +1034,10 @@ var PromotionQueryParamsSchema = z12.object({
|
|
|
1257
1034
|
"created_at",
|
|
1258
1035
|
"updated_at"
|
|
1259
1036
|
]).optional(),
|
|
1260
|
-
search:
|
|
1261
|
-
status:
|
|
1262
|
-
type:
|
|
1263
|
-
mode:
|
|
1037
|
+
search: z11.string().max(255).optional(),
|
|
1038
|
+
status: z11.union([PromotionStatusSchema, z11.literal("all")]).optional(),
|
|
1039
|
+
type: z11.union([PromotionTypeSchema, z11.literal("all")]).optional(),
|
|
1040
|
+
mode: z11.union([PromotionModeSchema, z11.literal("all")]).optional()
|
|
1264
1041
|
});
|
|
1265
1042
|
var PROMOTION_MODE_LABELS = {
|
|
1266
1043
|
DISCOUNT_CODE: "M\xE3 gi\u1EA3m gi\xE1",
|
|
@@ -1308,71 +1085,71 @@ var PROMOTION_MODE_COLORS = {
|
|
|
1308
1085
|
};
|
|
1309
1086
|
|
|
1310
1087
|
// src/types/blog.ts
|
|
1311
|
-
import { z as
|
|
1312
|
-
var tocItemSchema =
|
|
1313
|
-
id:
|
|
1314
|
-
level:
|
|
1315
|
-
textContent:
|
|
1316
|
-
pos:
|
|
1088
|
+
import { z as z12 } from "zod";
|
|
1089
|
+
var tocItemSchema = z12.object({
|
|
1090
|
+
id: z12.string(),
|
|
1091
|
+
level: z12.number().int().min(1).max(6),
|
|
1092
|
+
textContent: z12.string(),
|
|
1093
|
+
pos: z12.number().int()
|
|
1317
1094
|
});
|
|
1318
|
-
var blogCategorySchema =
|
|
1095
|
+
var blogCategorySchema = z12.object({
|
|
1319
1096
|
id: idSchema,
|
|
1320
|
-
name:
|
|
1097
|
+
name: z12.string().min(1).max(100),
|
|
1321
1098
|
slug: slugSchema.max(100),
|
|
1322
|
-
description:
|
|
1099
|
+
description: z12.string().optional().nullable(),
|
|
1323
1100
|
color: colorSchema,
|
|
1324
1101
|
sort_order: positionOrderSchema
|
|
1325
1102
|
}).extend(optionalTimestampSchema.shape);
|
|
1326
|
-
var blogTagSchema =
|
|
1103
|
+
var blogTagSchema = z12.object({
|
|
1327
1104
|
id: idSchema,
|
|
1328
|
-
name:
|
|
1105
|
+
name: z12.string().min(1).max(50),
|
|
1329
1106
|
slug: slugSchema.max(50)
|
|
1330
1107
|
}).extend(optionalTimestampSchema.shape);
|
|
1331
|
-
var blogPostSchema =
|
|
1108
|
+
var blogPostSchema = z12.object({
|
|
1332
1109
|
id: idSchema,
|
|
1333
|
-
title:
|
|
1110
|
+
title: z12.string().min(1).max(255),
|
|
1334
1111
|
slug: slugSchema.max(255),
|
|
1335
|
-
content:
|
|
1336
|
-
toc:
|
|
1337
|
-
excerpt:
|
|
1112
|
+
content: z12.string().optional().nullable(),
|
|
1113
|
+
toc: z12.array(tocItemSchema).optional().nullable(),
|
|
1114
|
+
excerpt: z12.string().optional().nullable(),
|
|
1338
1115
|
featured_image_url: urlSchema,
|
|
1339
1116
|
status: blogPostStatusSchema.default("draft"),
|
|
1340
|
-
is_featured:
|
|
1341
|
-
scheduled_at:
|
|
1342
|
-
published_at:
|
|
1117
|
+
is_featured: z12.boolean().default(false),
|
|
1118
|
+
scheduled_at: z12.iso.datetime().optional().nullable(),
|
|
1119
|
+
published_at: z12.iso.datetime().optional().nullable(),
|
|
1343
1120
|
author_id: uuidSchema.optional().nullable(),
|
|
1344
|
-
view_count:
|
|
1345
|
-
reading_time:
|
|
1121
|
+
view_count: z12.int32().default(0),
|
|
1122
|
+
reading_time: z12.int32().default(0)
|
|
1346
1123
|
}).extend(optionalTimestampSchema.shape);
|
|
1347
|
-
var blogCommentSchema =
|
|
1124
|
+
var blogCommentSchema = z12.object({
|
|
1348
1125
|
id: idSchema,
|
|
1349
1126
|
blog_post_id: idSchema.optional().nullable(),
|
|
1350
1127
|
parent_comment_id: idSchema.optional().nullable(),
|
|
1351
|
-
author_name:
|
|
1128
|
+
author_name: z12.string().min(1).max(100),
|
|
1352
1129
|
author_email: emailSchema,
|
|
1353
|
-
author_website:
|
|
1354
|
-
content:
|
|
1355
|
-
is_approved:
|
|
1356
|
-
created_at:
|
|
1130
|
+
author_website: z12.url().max(255).optional().nullable(),
|
|
1131
|
+
content: z12.string().min(1),
|
|
1132
|
+
is_approved: z12.boolean().default(false),
|
|
1133
|
+
created_at: z12.iso.datetime().optional().nullable()
|
|
1357
1134
|
});
|
|
1358
|
-
var blogSettingsSchema =
|
|
1135
|
+
var blogSettingsSchema = z12.object({
|
|
1359
1136
|
id: idSchema,
|
|
1360
|
-
is_enabled:
|
|
1361
|
-
blog_title:
|
|
1362
|
-
blog_description:
|
|
1363
|
-
posts_per_page:
|
|
1364
|
-
allow_comments:
|
|
1365
|
-
moderate_comments:
|
|
1366
|
-
show_author:
|
|
1367
|
-
show_reading_time:
|
|
1368
|
-
enable_rss:
|
|
1369
|
-
custom_css:
|
|
1137
|
+
is_enabled: z12.boolean().default(true),
|
|
1138
|
+
blog_title: z12.string().max(255).default("Blog"),
|
|
1139
|
+
blog_description: z12.string().optional().nullable(),
|
|
1140
|
+
posts_per_page: z12.int32().default(10),
|
|
1141
|
+
allow_comments: z12.boolean().default(true),
|
|
1142
|
+
moderate_comments: z12.boolean().default(true),
|
|
1143
|
+
show_author: z12.boolean().default(true),
|
|
1144
|
+
show_reading_time: z12.boolean().default(true),
|
|
1145
|
+
enable_rss: z12.boolean().default(true),
|
|
1146
|
+
custom_css: z12.string().optional().nullable()
|
|
1370
1147
|
}).extend(optionalTimestampSchema.shape);
|
|
1371
|
-
var blogPostCategorySchema =
|
|
1148
|
+
var blogPostCategorySchema = z12.object({
|
|
1372
1149
|
blog_post_id: idSchema,
|
|
1373
1150
|
blog_category_id: idSchema
|
|
1374
1151
|
});
|
|
1375
|
-
var blogPostTagSchema =
|
|
1152
|
+
var blogPostTagSchema = z12.object({
|
|
1376
1153
|
blog_post_id: idSchema,
|
|
1377
1154
|
blog_tag_id: idSchema
|
|
1378
1155
|
});
|
|
@@ -1409,29 +1186,29 @@ var updateBlogCommentSchema = createBlogCommentSchema.partial().omit({
|
|
|
1409
1186
|
});
|
|
1410
1187
|
var updateBlogSettingsSchema = createBlogSettingsSchema.partial();
|
|
1411
1188
|
var blogPostWithRelationsSchema = blogPostSchema.extend({
|
|
1412
|
-
blog_categories:
|
|
1413
|
-
blog_tags:
|
|
1414
|
-
blog_comments:
|
|
1189
|
+
blog_categories: z12.array(blogCategorySchema).optional(),
|
|
1190
|
+
blog_tags: z12.array(blogTagSchema).optional(),
|
|
1191
|
+
blog_comments: z12.array(blogCommentSchema).optional()
|
|
1415
1192
|
});
|
|
1416
|
-
var blogCommentWithRepliesSchemaInner =
|
|
1193
|
+
var blogCommentWithRepliesSchemaInner = z12.lazy(
|
|
1417
1194
|
() => blogCommentSchema.extend({
|
|
1418
|
-
replies:
|
|
1195
|
+
replies: z12.array(blogCommentWithRepliesSchemaInner).optional()
|
|
1419
1196
|
})
|
|
1420
1197
|
);
|
|
1421
1198
|
var blogCommentWithRepliesSchema = blogCommentWithRepliesSchemaInner;
|
|
1422
1199
|
|
|
1423
1200
|
// src/types/banner.ts
|
|
1424
|
-
import { z as
|
|
1425
|
-
var bannerSchema =
|
|
1201
|
+
import { z as z13 } from "zod";
|
|
1202
|
+
var bannerSchema = z13.object({
|
|
1426
1203
|
id: idSchema,
|
|
1427
|
-
title:
|
|
1428
|
-
subtitle:
|
|
1204
|
+
title: z13.string().min(1),
|
|
1205
|
+
subtitle: z13.string().optional().nullable(),
|
|
1429
1206
|
image_url: strictUrlSchema,
|
|
1430
1207
|
link_url: urlSchema,
|
|
1431
|
-
button_text:
|
|
1208
|
+
button_text: z13.string().optional().nullable(),
|
|
1432
1209
|
position: positionOrderSchema,
|
|
1433
|
-
is_active:
|
|
1434
|
-
metadata:
|
|
1210
|
+
is_active: z13.boolean().default(true),
|
|
1211
|
+
metadata: z13.any()
|
|
1435
1212
|
}).extend(optionalTimestampSchema.shape);
|
|
1436
1213
|
var createBannerSchema = bannerSchema.omit({
|
|
1437
1214
|
id: true,
|
|
@@ -1439,19 +1216,19 @@ var createBannerSchema = bannerSchema.omit({
|
|
|
1439
1216
|
updated_at: true
|
|
1440
1217
|
});
|
|
1441
1218
|
var updateBannerSchema = createBannerSchema.partial();
|
|
1442
|
-
var updateBannerPositionSchema =
|
|
1219
|
+
var updateBannerPositionSchema = z13.object({
|
|
1443
1220
|
id: idSchema,
|
|
1444
|
-
position:
|
|
1221
|
+
position: z13.int32()
|
|
1445
1222
|
});
|
|
1446
1223
|
|
|
1447
1224
|
// src/types/content.ts
|
|
1448
|
-
import { z as
|
|
1449
|
-
var contentPageSchema =
|
|
1225
|
+
import { z as z14 } from "zod";
|
|
1226
|
+
var contentPageSchema = z14.object({
|
|
1450
1227
|
id: idSchema,
|
|
1451
|
-
title:
|
|
1452
|
-
content:
|
|
1453
|
-
is_published:
|
|
1454
|
-
page_type:
|
|
1228
|
+
title: z14.string().min(1),
|
|
1229
|
+
content: z14.string().optional().nullable(),
|
|
1230
|
+
is_published: z14.boolean().default(false),
|
|
1231
|
+
page_type: z14.string().optional().nullable(),
|
|
1455
1232
|
sort_order: positionOrderSchema,
|
|
1456
1233
|
slug: slugSchema.max(255)
|
|
1457
1234
|
}).extend(timestampSchema.shape);
|
|
@@ -1467,87 +1244,87 @@ var updateContentPageSchema = contentPageSchema.omit({
|
|
|
1467
1244
|
}).partial();
|
|
1468
1245
|
|
|
1469
1246
|
// src/types/theme-schema.ts
|
|
1470
|
-
import { z as
|
|
1247
|
+
import { z as z15 } from "zod";
|
|
1471
1248
|
var THEME_HEX_COLOR = /^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
|
|
1472
1249
|
var SETTING_ID = /^[a-z][a-z0-9_]*$/;
|
|
1473
|
-
var primitive =
|
|
1474
|
-
var visibleIfSchema =
|
|
1475
|
-
setting:
|
|
1250
|
+
var primitive = z15.union([z15.string(), z15.number(), z15.boolean()]);
|
|
1251
|
+
var visibleIfSchema = z15.object({
|
|
1252
|
+
setting: z15.string().regex(SETTING_ID),
|
|
1476
1253
|
equals: primitive.optional(),
|
|
1477
1254
|
not_equals: primitive.optional(),
|
|
1478
|
-
is_set:
|
|
1255
|
+
is_set: z15.boolean().optional()
|
|
1479
1256
|
}).refine(
|
|
1480
1257
|
(v) => [v.equals, v.not_equals, v.is_set].filter((x) => x !== void 0).length === 1,
|
|
1481
1258
|
{ message: "visible_if needs exactly one of equals, not_equals, is_set" }
|
|
1482
1259
|
);
|
|
1483
1260
|
var base = {
|
|
1484
|
-
id:
|
|
1485
|
-
label:
|
|
1486
|
-
info:
|
|
1261
|
+
id: z15.string().regex(SETTING_ID, "setting ids are snake_case"),
|
|
1262
|
+
label: z15.string().min(1),
|
|
1263
|
+
info: z15.string().optional(),
|
|
1487
1264
|
visible_if: visibleIfSchema.optional()
|
|
1488
1265
|
};
|
|
1489
|
-
var itemSchema =
|
|
1490
|
-
|
|
1266
|
+
var itemSchema = z15.discriminatedUnion("type", [
|
|
1267
|
+
z15.object({
|
|
1491
1268
|
...base,
|
|
1492
|
-
type:
|
|
1493
|
-
default:
|
|
1494
|
-
placeholder:
|
|
1269
|
+
type: z15.literal("text"),
|
|
1270
|
+
default: z15.string().optional(),
|
|
1271
|
+
placeholder: z15.string().optional()
|
|
1495
1272
|
}),
|
|
1496
|
-
|
|
1273
|
+
z15.object({
|
|
1497
1274
|
...base,
|
|
1498
|
-
type:
|
|
1499
|
-
default:
|
|
1500
|
-
placeholder:
|
|
1275
|
+
type: z15.literal("textarea"),
|
|
1276
|
+
default: z15.string().optional(),
|
|
1277
|
+
placeholder: z15.string().optional()
|
|
1501
1278
|
}),
|
|
1502
|
-
|
|
1279
|
+
z15.object({
|
|
1503
1280
|
...base,
|
|
1504
|
-
type:
|
|
1505
|
-
default:
|
|
1281
|
+
type: z15.literal("richtext"),
|
|
1282
|
+
default: z15.string().optional()
|
|
1506
1283
|
}),
|
|
1507
|
-
|
|
1508
|
-
|
|
1284
|
+
z15.object({ ...base, type: z15.literal("url"), default: z15.string().optional() }),
|
|
1285
|
+
z15.object({
|
|
1509
1286
|
...base,
|
|
1510
|
-
type:
|
|
1511
|
-
default:
|
|
1287
|
+
type: z15.literal("color"),
|
|
1288
|
+
default: z15.string().regex(THEME_HEX_COLOR).optional()
|
|
1512
1289
|
}),
|
|
1513
|
-
|
|
1290
|
+
z15.object({
|
|
1514
1291
|
...base,
|
|
1515
|
-
type:
|
|
1516
|
-
default:
|
|
1292
|
+
type: z15.literal("menu"),
|
|
1293
|
+
default: z15.string().optional()
|
|
1517
1294
|
}),
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1295
|
+
z15.object({ ...base, type: z15.literal("image_picker") }),
|
|
1296
|
+
z15.object({ ...base, type: z15.literal("collection") }),
|
|
1297
|
+
z15.object({
|
|
1521
1298
|
...base,
|
|
1522
|
-
type:
|
|
1523
|
-
default:
|
|
1299
|
+
type: z15.literal("checkbox"),
|
|
1300
|
+
default: z15.boolean().optional()
|
|
1524
1301
|
}),
|
|
1525
|
-
|
|
1302
|
+
z15.object({
|
|
1526
1303
|
...base,
|
|
1527
|
-
type:
|
|
1528
|
-
default:
|
|
1529
|
-
min:
|
|
1530
|
-
max:
|
|
1304
|
+
type: z15.literal("number"),
|
|
1305
|
+
default: z15.number().optional(),
|
|
1306
|
+
min: z15.number().optional(),
|
|
1307
|
+
max: z15.number().optional()
|
|
1531
1308
|
}),
|
|
1532
|
-
|
|
1309
|
+
z15.object({
|
|
1533
1310
|
...base,
|
|
1534
|
-
type:
|
|
1535
|
-
min:
|
|
1536
|
-
max:
|
|
1537
|
-
step:
|
|
1538
|
-
unit:
|
|
1539
|
-
default:
|
|
1311
|
+
type: z15.literal("range"),
|
|
1312
|
+
min: z15.number(),
|
|
1313
|
+
max: z15.number(),
|
|
1314
|
+
step: z15.number().positive(),
|
|
1315
|
+
unit: z15.string().optional(),
|
|
1316
|
+
default: z15.number()
|
|
1540
1317
|
}),
|
|
1541
|
-
|
|
1318
|
+
z15.object({
|
|
1542
1319
|
...base,
|
|
1543
|
-
type:
|
|
1544
|
-
options:
|
|
1545
|
-
default:
|
|
1320
|
+
type: z15.literal("select"),
|
|
1321
|
+
options: z15.array(z15.object({ value: z15.string(), label: z15.string().min(1) })).min(1),
|
|
1322
|
+
default: z15.string().optional()
|
|
1546
1323
|
}),
|
|
1547
|
-
|
|
1548
|
-
|
|
1324
|
+
z15.object({ type: z15.literal("header"), content: z15.string().min(1) }),
|
|
1325
|
+
z15.object({ type: z15.literal("paragraph"), content: z15.string().min(1) })
|
|
1549
1326
|
]);
|
|
1550
|
-
var themeSchemaSchema =
|
|
1327
|
+
var themeSchemaSchema = z15.array(z15.object({ name: z15.string().min(1), settings: z15.array(itemSchema) })).superRefine((groups, ctx) => {
|
|
1551
1328
|
const settings = groups.flatMap((g) => g.settings).filter(isSetting);
|
|
1552
1329
|
const ids = /* @__PURE__ */ new Set();
|
|
1553
1330
|
for (const s of settings) {
|
|
@@ -1609,7 +1386,7 @@ function parseThemeSchema(input) {
|
|
|
1609
1386
|
const result = themeSchemaSchema.safeParse(input);
|
|
1610
1387
|
if (!result.success) {
|
|
1611
1388
|
throw new Error(`Invalid theme schema:
|
|
1612
|
-
${
|
|
1389
|
+
${z15.prettifyError(result.error)}`);
|
|
1613
1390
|
}
|
|
1614
1391
|
return result.data;
|
|
1615
1392
|
}
|
|
@@ -1686,6 +1463,1259 @@ function isSettingVisible(setting, values) {
|
|
|
1686
1463
|
return value !== rule.not_equals;
|
|
1687
1464
|
}
|
|
1688
1465
|
|
|
1466
|
+
// src/types/metafield-engine.ts
|
|
1467
|
+
var METAFIELD_OWNER_TYPES = [
|
|
1468
|
+
"product",
|
|
1469
|
+
"variant",
|
|
1470
|
+
"collection",
|
|
1471
|
+
"customer",
|
|
1472
|
+
"order",
|
|
1473
|
+
"page",
|
|
1474
|
+
"blog_post",
|
|
1475
|
+
"location",
|
|
1476
|
+
"shop"
|
|
1477
|
+
];
|
|
1478
|
+
var METAFIELD_BASE_TYPES = [
|
|
1479
|
+
"single_line_text",
|
|
1480
|
+
"multi_line_text",
|
|
1481
|
+
"rich_text",
|
|
1482
|
+
"email",
|
|
1483
|
+
"integer",
|
|
1484
|
+
"decimal",
|
|
1485
|
+
"date",
|
|
1486
|
+
"date_time",
|
|
1487
|
+
"url",
|
|
1488
|
+
"link",
|
|
1489
|
+
"weight",
|
|
1490
|
+
"volume",
|
|
1491
|
+
"dimension",
|
|
1492
|
+
"boolean",
|
|
1493
|
+
"color",
|
|
1494
|
+
"rating",
|
|
1495
|
+
"money",
|
|
1496
|
+
"language",
|
|
1497
|
+
"json",
|
|
1498
|
+
"file",
|
|
1499
|
+
"image",
|
|
1500
|
+
"video",
|
|
1501
|
+
"product",
|
|
1502
|
+
"variant",
|
|
1503
|
+
"collection",
|
|
1504
|
+
"page",
|
|
1505
|
+
"blog_post",
|
|
1506
|
+
"customer",
|
|
1507
|
+
"order",
|
|
1508
|
+
"metaobject_reference",
|
|
1509
|
+
"mixed_reference"
|
|
1510
|
+
];
|
|
1511
|
+
var BASE_TYPE_SET = new Set(METAFIELD_BASE_TYPES);
|
|
1512
|
+
function isMetafieldType(value) {
|
|
1513
|
+
if (typeof value !== "string") return false;
|
|
1514
|
+
const base2 = value.startsWith("list.") ? value.slice(5) : value;
|
|
1515
|
+
return BASE_TYPE_SET.has(base2);
|
|
1516
|
+
}
|
|
1517
|
+
function isListType(type) {
|
|
1518
|
+
return type.startsWith("list.");
|
|
1519
|
+
}
|
|
1520
|
+
function baseTypeOf(type) {
|
|
1521
|
+
return isListType(type) ? type.slice(5) : type;
|
|
1522
|
+
}
|
|
1523
|
+
var METAFIELD_TYPE_GROUPS = [
|
|
1524
|
+
{
|
|
1525
|
+
group: "text",
|
|
1526
|
+
types: ["single_line_text", "multi_line_text", "rich_text", "email"]
|
|
1527
|
+
},
|
|
1528
|
+
{ group: "media", types: ["file", "image", "video"] },
|
|
1529
|
+
{
|
|
1530
|
+
group: "reference",
|
|
1531
|
+
types: [
|
|
1532
|
+
"blog_post",
|
|
1533
|
+
"collection",
|
|
1534
|
+
"customer",
|
|
1535
|
+
"metaobject_reference",
|
|
1536
|
+
"order",
|
|
1537
|
+
"page",
|
|
1538
|
+
"product",
|
|
1539
|
+
"variant"
|
|
1540
|
+
]
|
|
1541
|
+
},
|
|
1542
|
+
{ group: "link", types: ["link", "url"] },
|
|
1543
|
+
{ group: "date_time", types: ["date", "date_time"] },
|
|
1544
|
+
{ group: "number", types: ["integer", "decimal", "rating", "money"] },
|
|
1545
|
+
{ group: "measurement", types: ["weight", "volume", "dimension"] },
|
|
1546
|
+
{ group: "other", types: ["boolean", "color", "language"] },
|
|
1547
|
+
{ group: "advanced", types: ["json", "mixed_reference"] }
|
|
1548
|
+
];
|
|
1549
|
+
var RESOURCE_REFERENCE_TYPES = [
|
|
1550
|
+
"product",
|
|
1551
|
+
"variant",
|
|
1552
|
+
"collection",
|
|
1553
|
+
"page",
|
|
1554
|
+
"blog_post",
|
|
1555
|
+
"customer",
|
|
1556
|
+
"order"
|
|
1557
|
+
];
|
|
1558
|
+
var METAOBJECT_REFERENCE_TYPES = [
|
|
1559
|
+
"metaobject_reference",
|
|
1560
|
+
"mixed_reference"
|
|
1561
|
+
];
|
|
1562
|
+
var MEDIA_TYPES = ["file", "image", "video"];
|
|
1563
|
+
var PRIVATE_REFERENCE_TYPES = ["customer", "order"];
|
|
1564
|
+
var METAFIELD_LIMITS = {
|
|
1565
|
+
definitions_per_owner_type: 100,
|
|
1566
|
+
pinned_per_owner_type: 20,
|
|
1567
|
+
metaobject_definitions: 100,
|
|
1568
|
+
fields_per_metaobject: 40,
|
|
1569
|
+
filter_keys: 5,
|
|
1570
|
+
value_bytes: 65536,
|
|
1571
|
+
list_items: 128,
|
|
1572
|
+
choices: 128,
|
|
1573
|
+
allowed_domains: 20,
|
|
1574
|
+
regex_length: 200,
|
|
1575
|
+
regex_value_length: 500,
|
|
1576
|
+
single_line_text_length: 5e3,
|
|
1577
|
+
multi_line_text_length: 65e3,
|
|
1578
|
+
link_text_length: 255,
|
|
1579
|
+
email_length: 254,
|
|
1580
|
+
name_length: 255,
|
|
1581
|
+
description_length: 5e3,
|
|
1582
|
+
mixed_reference_definitions_min: 2,
|
|
1583
|
+
mixed_reference_definitions_max: 10
|
|
1584
|
+
};
|
|
1585
|
+
function issue(path, code, message) {
|
|
1586
|
+
return { path, code, message };
|
|
1587
|
+
}
|
|
1588
|
+
function ok(value) {
|
|
1589
|
+
return { ok: true, value };
|
|
1590
|
+
}
|
|
1591
|
+
function fail(path, code, message) {
|
|
1592
|
+
return { ok: false, errors: [issue(path, code, message)] };
|
|
1593
|
+
}
|
|
1594
|
+
function joinPath(base2, segment) {
|
|
1595
|
+
if (typeof segment === "number") return `${base2}[${segment}]`;
|
|
1596
|
+
return base2 ? `${base2}.${segment}` : segment;
|
|
1597
|
+
}
|
|
1598
|
+
function isPlainObject(value) {
|
|
1599
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1600
|
+
}
|
|
1601
|
+
function hasOwn(object, key) {
|
|
1602
|
+
return Object.prototype.hasOwnProperty.call(object, key);
|
|
1603
|
+
}
|
|
1604
|
+
function unknownKeys(object, allowed, path) {
|
|
1605
|
+
return Object.keys(object).filter((key) => !allowed.includes(key)).map((key) => issue(joinPath(path, key), "unknown_key", `unknown key "${key}"`));
|
|
1606
|
+
}
|
|
1607
|
+
function codePoints(text) {
|
|
1608
|
+
return [...text].length;
|
|
1609
|
+
}
|
|
1610
|
+
var METAFIELD_KEY_PATTERN = /^[a-z0-9_]{2,64}$/;
|
|
1611
|
+
var METAOBJECT_TYPE_PATTERN = /^[a-z0-9_-]{2,64}$/;
|
|
1612
|
+
var ENTRY_HANDLE_PATTERN = /^[a-z0-9-]{1,255}$/;
|
|
1613
|
+
function asciiFold(text) {
|
|
1614
|
+
return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/\u0111/g, "d").replace(/\u0110/g, "D");
|
|
1615
|
+
}
|
|
1616
|
+
function slugify(text, separator, max) {
|
|
1617
|
+
const edge = new RegExp(`^${separator}+|${separator}+$`, "g");
|
|
1618
|
+
return asciiFold(text).toLowerCase().replace(/[^a-z0-9]+/g, separator).replace(edge, "").slice(0, max).replace(edge, "");
|
|
1619
|
+
}
|
|
1620
|
+
function toMetafieldKey(text) {
|
|
1621
|
+
return slugify(text, "_", 64);
|
|
1622
|
+
}
|
|
1623
|
+
function toEntryHandle(text) {
|
|
1624
|
+
const handle = slugify(text, "-", 255);
|
|
1625
|
+
return RESERVED_KEYS.includes(handle) ? "" : handle;
|
|
1626
|
+
}
|
|
1627
|
+
function isValidEntryHandle(handle) {
|
|
1628
|
+
return ENTRY_HANDLE_PATTERN.test(handle) && !RESERVED_KEYS.includes(handle);
|
|
1629
|
+
}
|
|
1630
|
+
function metafieldIdentifier(namespace, key) {
|
|
1631
|
+
return `${namespace}.${key}`;
|
|
1632
|
+
}
|
|
1633
|
+
var RESERVED_KEYS = ["__proto__", "constructor", "prototype"];
|
|
1634
|
+
function parseMetafieldIdentifier(identifier) {
|
|
1635
|
+
const parts = identifier.split(".");
|
|
1636
|
+
if (parts.length !== 2) return null;
|
|
1637
|
+
const [namespace, key] = parts;
|
|
1638
|
+
if (!METAFIELD_KEY_PATTERN.test(namespace) || !METAFIELD_KEY_PATTERN.test(key)) {
|
|
1639
|
+
return null;
|
|
1640
|
+
}
|
|
1641
|
+
if (RESERVED_KEYS.includes(namespace) || RESERVED_KEYS.includes(key)) return null;
|
|
1642
|
+
return { namespace, key };
|
|
1643
|
+
}
|
|
1644
|
+
function matchesPattern(pattern, text) {
|
|
1645
|
+
try {
|
|
1646
|
+
return new RegExp("^(?:" + pattern + ")$", "u").test(text);
|
|
1647
|
+
} catch {
|
|
1648
|
+
return false;
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
function textChecker(limit, singleLine) {
|
|
1652
|
+
return (value, v, _ctx, path) => {
|
|
1653
|
+
if (typeof value !== "string") return fail(path, "invalid_type", "must be text");
|
|
1654
|
+
if (singleLine && /[\r\n]/.test(value)) {
|
|
1655
|
+
return fail(path, "invalid_format", "must be a single line");
|
|
1656
|
+
}
|
|
1657
|
+
const length = codePoints(value);
|
|
1658
|
+
const cap = v.regex !== void 0 ? Math.min(limit, METAFIELD_LIMITS.regex_value_length) : limit;
|
|
1659
|
+
const max = Math.min(cap, v.max_length ?? cap);
|
|
1660
|
+
if (length > max) return fail(path, "too_long", `must be at most ${max} characters`);
|
|
1661
|
+
if (v.min_length !== void 0 && length < v.min_length) {
|
|
1662
|
+
return fail(path, "too_short", `must be at least ${v.min_length} characters`);
|
|
1663
|
+
}
|
|
1664
|
+
if (v.regex !== void 0 && !matchesPattern(v.regex, value)) {
|
|
1665
|
+
return fail(path, "pattern_mismatch", "does not match the required pattern");
|
|
1666
|
+
}
|
|
1667
|
+
if (v.choices !== void 0 && !v.choices.includes(value)) {
|
|
1668
|
+
return fail(path, "not_a_choice", `must be one of: ${v.choices.join(", ")}`);
|
|
1669
|
+
}
|
|
1670
|
+
return ok(value);
|
|
1671
|
+
};
|
|
1672
|
+
}
|
|
1673
|
+
var EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
1674
|
+
var checkEmail = (value, _v, _ctx, path) => {
|
|
1675
|
+
if (typeof value !== "string") return fail(path, "invalid_type", "must be text");
|
|
1676
|
+
const email = value.trim().toLowerCase();
|
|
1677
|
+
if (email.length > METAFIELD_LIMITS.email_length || !EMAIL.test(email)) {
|
|
1678
|
+
return fail(path, "invalid_format", "must be an email address");
|
|
1679
|
+
}
|
|
1680
|
+
return ok(email);
|
|
1681
|
+
};
|
|
1682
|
+
var checkInteger = (value, v, _ctx, path) => {
|
|
1683
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value)) {
|
|
1684
|
+
return fail(path, "invalid_type", "must be a whole number");
|
|
1685
|
+
}
|
|
1686
|
+
if (typeof v.min === "number" && value < v.min) {
|
|
1687
|
+
return fail(path, "too_small", `must be at least ${v.min}`);
|
|
1688
|
+
}
|
|
1689
|
+
if (typeof v.max === "number" && value > v.max) {
|
|
1690
|
+
return fail(path, "too_big", `must be at most ${v.max}`);
|
|
1691
|
+
}
|
|
1692
|
+
return ok(value === 0 ? 0 : value);
|
|
1693
|
+
};
|
|
1694
|
+
var DECIMAL_INPUT = /^[+-]?\d+(\.\d+)?$/;
|
|
1695
|
+
function normalizeDecimal(input) {
|
|
1696
|
+
let text;
|
|
1697
|
+
if (typeof input === "number") {
|
|
1698
|
+
if (!Number.isFinite(input)) return null;
|
|
1699
|
+
text = String(input);
|
|
1700
|
+
} else if (typeof input === "string") {
|
|
1701
|
+
text = input.trim();
|
|
1702
|
+
} else {
|
|
1703
|
+
return null;
|
|
1704
|
+
}
|
|
1705
|
+
if (text.length > 40 || !DECIMAL_INPUT.test(text)) return null;
|
|
1706
|
+
const negative = text.startsWith("-");
|
|
1707
|
+
if (text[0] === "-" || text[0] === "+") text = text.slice(1);
|
|
1708
|
+
const [whole, fraction = ""] = text.split(".");
|
|
1709
|
+
const integer = whole.replace(/^0+(?=\d)/, "");
|
|
1710
|
+
const decimals = fraction.replace(/0+$/, "");
|
|
1711
|
+
const magnitude = decimals ? `${integer}.${decimals}` : integer;
|
|
1712
|
+
return magnitude === "0" ? "0" : `${negative ? "-" : ""}${magnitude}`;
|
|
1713
|
+
}
|
|
1714
|
+
function compareDecimal(a, b) {
|
|
1715
|
+
const aNegative = a.startsWith("-");
|
|
1716
|
+
const bNegative = b.startsWith("-");
|
|
1717
|
+
if (aNegative !== bNegative) return aNegative ? -1 : 1;
|
|
1718
|
+
const sign = aNegative ? -1 : 1;
|
|
1719
|
+
const [aWhole, aFraction = ""] = (aNegative ? a.slice(1) : a).split(".");
|
|
1720
|
+
const [bWhole, bFraction = ""] = (bNegative ? b.slice(1) : b).split(".");
|
|
1721
|
+
let order;
|
|
1722
|
+
if (aWhole.length !== bWhole.length) {
|
|
1723
|
+
order = aWhole.length > bWhole.length ? 1 : -1;
|
|
1724
|
+
} else if (aWhole !== bWhole) {
|
|
1725
|
+
order = aWhole > bWhole ? 1 : -1;
|
|
1726
|
+
} else {
|
|
1727
|
+
const width = Math.max(aFraction.length, bFraction.length);
|
|
1728
|
+
const aPadded = aFraction.padEnd(width, "0");
|
|
1729
|
+
const bPadded = bFraction.padEnd(width, "0");
|
|
1730
|
+
order = aPadded === bPadded ? 0 : aPadded > bPadded ? 1 : -1;
|
|
1731
|
+
}
|
|
1732
|
+
return order === 0 ? 0 : order * sign;
|
|
1733
|
+
}
|
|
1734
|
+
var checkDecimal = (value, v, _ctx, path) => {
|
|
1735
|
+
const decimal = normalizeDecimal(value);
|
|
1736
|
+
if (decimal === null) return fail(path, "invalid_type", "must be a decimal number");
|
|
1737
|
+
const fraction = decimal.split(".")[1] ?? "";
|
|
1738
|
+
if (v.max_precision !== void 0 && fraction.length > v.max_precision) {
|
|
1739
|
+
return fail(path, "precision_exceeded", `must have at most ${v.max_precision} decimal places`);
|
|
1740
|
+
}
|
|
1741
|
+
if (typeof v.min === "string" && compareDecimal(decimal, v.min) < 0) {
|
|
1742
|
+
return fail(path, "too_small", `must be at least ${v.min}`);
|
|
1743
|
+
}
|
|
1744
|
+
if (typeof v.max === "string" && compareDecimal(decimal, v.max) > 0) {
|
|
1745
|
+
return fail(path, "too_big", `must be at most ${v.max}`);
|
|
1746
|
+
}
|
|
1747
|
+
return ok(decimal);
|
|
1748
|
+
};
|
|
1749
|
+
var checkBoolean = (value, _v, _ctx, path) => typeof value === "boolean" ? ok(value) : fail(path, "invalid_type", "must be true or false");
|
|
1750
|
+
var COLOR = /^#[0-9a-fA-F]{6}$/;
|
|
1751
|
+
var checkColor = (value, _v, _ctx, path) => typeof value === "string" && COLOR.test(value) ? ok(value.toLowerCase()) : fail(path, "invalid_format", "must be a hex color such as #1a2b3c");
|
|
1752
|
+
function isCalendarDate(year, month, day) {
|
|
1753
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
1754
|
+
date.setUTCFullYear(year, month - 1, day);
|
|
1755
|
+
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
|
|
1756
|
+
}
|
|
1757
|
+
var DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
1758
|
+
function normalizeDate(input) {
|
|
1759
|
+
if (typeof input !== "string") return null;
|
|
1760
|
+
const match = DATE.exec(input);
|
|
1761
|
+
if (!match || !isCalendarDate(+match[1], +match[2], +match[3])) return null;
|
|
1762
|
+
return input;
|
|
1763
|
+
}
|
|
1764
|
+
var DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,3})?)?(Z|[+-](\d{2}):(\d{2}))$/;
|
|
1765
|
+
function normalizeDateTime(input) {
|
|
1766
|
+
if (typeof input !== "string") return null;
|
|
1767
|
+
const match = DATE_TIME.exec(input);
|
|
1768
|
+
if (!match || !isCalendarDate(+match[1], +match[2], +match[3])) return null;
|
|
1769
|
+
if (+match[4] > 23 || +match[5] > 59 || +(match[6] ?? "0") > 59) return null;
|
|
1770
|
+
if (match[8] !== void 0 && (+match[8] > 23 || +match[9] > 59)) return null;
|
|
1771
|
+
const ms = Date.parse(input);
|
|
1772
|
+
if (Number.isNaN(ms)) return null;
|
|
1773
|
+
const iso = new Date(ms).toISOString();
|
|
1774
|
+
return /^\d{4}-/.test(iso) ? `${iso.slice(0, 19)}Z` : null;
|
|
1775
|
+
}
|
|
1776
|
+
function dateChecker(normalize, format) {
|
|
1777
|
+
return (value, v, _ctx, path) => {
|
|
1778
|
+
const normalized = normalize(value);
|
|
1779
|
+
if (normalized === null) return fail(path, "invalid_format", `must be ${format}`);
|
|
1780
|
+
if (typeof v.min === "string" && normalized < v.min) {
|
|
1781
|
+
return fail(path, "too_small", `must be on or after ${v.min}`);
|
|
1782
|
+
}
|
|
1783
|
+
if (typeof v.max === "string" && normalized > v.max) {
|
|
1784
|
+
return fail(path, "too_big", `must be on or before ${v.max}`);
|
|
1785
|
+
}
|
|
1786
|
+
return ok(normalized);
|
|
1787
|
+
};
|
|
1788
|
+
}
|
|
1789
|
+
var MAX_URL_LENGTH = 2048;
|
|
1790
|
+
var UNSAFE_URL_CHARS = /[\u0000-\u001f\u007f-\u009f"<>`\\]/;
|
|
1791
|
+
function parseHttpUrl(value) {
|
|
1792
|
+
if (typeof value !== "string" || value.length > MAX_URL_LENGTH || /\s/.test(value) || UNSAFE_URL_CHARS.test(value)) {
|
|
1793
|
+
return null;
|
|
1794
|
+
}
|
|
1795
|
+
try {
|
|
1796
|
+
const url = new URL(value);
|
|
1797
|
+
return url.protocol === "http:" || url.protocol === "https:" ? url : null;
|
|
1798
|
+
} catch {
|
|
1799
|
+
return null;
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
function hostAllowed(url, domains) {
|
|
1803
|
+
if (!domains) return true;
|
|
1804
|
+
const host = url.hostname.toLowerCase();
|
|
1805
|
+
return domains.some((domain) => host === domain || host.endsWith(`.${domain}`));
|
|
1806
|
+
}
|
|
1807
|
+
var checkUrl = (value, v, _ctx, path) => {
|
|
1808
|
+
const url = parseHttpUrl(value);
|
|
1809
|
+
if (!url) return fail(path, "invalid_format", "must be an http(s) URL");
|
|
1810
|
+
if (!hostAllowed(url, v.allowed_domains)) {
|
|
1811
|
+
return fail(path, "domain_not_allowed", `must be on ${(v.allowed_domains ?? []).join(", ")}`);
|
|
1812
|
+
}
|
|
1813
|
+
return ok(value);
|
|
1814
|
+
};
|
|
1815
|
+
var checkLink = (value, v, ctx, path) => {
|
|
1816
|
+
if (!isPlainObject(value)) {
|
|
1817
|
+
return fail(path, "invalid_type", "must be an object with url and text");
|
|
1818
|
+
}
|
|
1819
|
+
const extra = unknownKeys(value, ["url", "text"], path);
|
|
1820
|
+
if (extra.length) return { ok: false, errors: extra };
|
|
1821
|
+
const url = checkUrl(value.url, v, ctx, joinPath(path, "url"));
|
|
1822
|
+
if (!url.ok) return url;
|
|
1823
|
+
const text = value.text ?? "";
|
|
1824
|
+
if (typeof text !== "string") return fail(joinPath(path, "text"), "invalid_type", "must be text");
|
|
1825
|
+
if (codePoints(text) > METAFIELD_LIMITS.link_text_length) {
|
|
1826
|
+
return fail(
|
|
1827
|
+
joinPath(path, "text"),
|
|
1828
|
+
"too_long",
|
|
1829
|
+
`must be at most ${METAFIELD_LIMITS.link_text_length} characters`
|
|
1830
|
+
);
|
|
1831
|
+
}
|
|
1832
|
+
return ok({ url: url.value, text });
|
|
1833
|
+
};
|
|
1834
|
+
var LANGUAGE = /^([a-zA-Z]{2,3})(?:-([a-zA-Z]{4}))?(?:-([a-zA-Z]{2}|\d{3}))?$/;
|
|
1835
|
+
var checkLanguage = (value, _v, _ctx, path) => {
|
|
1836
|
+
const match = typeof value === "string" ? LANGUAGE.exec(value) : null;
|
|
1837
|
+
if (!match) {
|
|
1838
|
+
return fail(path, "invalid_format", "must be a language tag such as vi or en-US");
|
|
1839
|
+
}
|
|
1840
|
+
const script = match[2] ? match[2][0].toUpperCase() + match[2].slice(1).toLowerCase() : void 0;
|
|
1841
|
+
return ok([match[1].toLowerCase(), script, match[3]?.toUpperCase()].filter(Boolean).join("-"));
|
|
1842
|
+
};
|
|
1843
|
+
var checkJson = (value, _v, _ctx, path) => {
|
|
1844
|
+
let text;
|
|
1845
|
+
let nonFinite = false;
|
|
1846
|
+
try {
|
|
1847
|
+
text = JSON.stringify(value, (_key, item) => {
|
|
1848
|
+
if (typeof item === "number" && !Number.isFinite(item)) nonFinite = true;
|
|
1849
|
+
return item;
|
|
1850
|
+
});
|
|
1851
|
+
} catch {
|
|
1852
|
+
text = void 0;
|
|
1853
|
+
}
|
|
1854
|
+
if (nonFinite) return fail(path, "invalid_format", "must not contain NaN or Infinity");
|
|
1855
|
+
return text === void 0 ? fail(path, "invalid_type", "must be JSON") : ok(JSON.parse(text));
|
|
1856
|
+
};
|
|
1857
|
+
var MAX_RICH_ERRORS = 100;
|
|
1858
|
+
var MAILTO = /^mailto:[^\s@?&#,]+@[^\s@?&#,]+$/i;
|
|
1859
|
+
function richChildren(children, path, errors, each) {
|
|
1860
|
+
if (!Array.isArray(children)) {
|
|
1861
|
+
errors.push(issue(path, "invalid_type", "must be a list of nodes"));
|
|
1862
|
+
return [];
|
|
1863
|
+
}
|
|
1864
|
+
const out = [];
|
|
1865
|
+
for (let index = 0; index < children.length; index++) {
|
|
1866
|
+
if (errors.length >= MAX_RICH_ERRORS) break;
|
|
1867
|
+
const node = each(children[index], joinPath(path, index));
|
|
1868
|
+
if (node) out.push(node);
|
|
1869
|
+
}
|
|
1870
|
+
return out;
|
|
1871
|
+
}
|
|
1872
|
+
function richText(node, path, errors) {
|
|
1873
|
+
errors.push(...unknownKeys(node, ["type", "value", "bold", "italic"], path));
|
|
1874
|
+
if (typeof node.value !== "string") {
|
|
1875
|
+
errors.push(issue(joinPath(path, "value"), "invalid_type", "must be text"));
|
|
1876
|
+
return null;
|
|
1877
|
+
}
|
|
1878
|
+
for (const mark of ["bold", "italic"]) {
|
|
1879
|
+
if (node[mark] !== void 0 && typeof node[mark] !== "boolean") {
|
|
1880
|
+
errors.push(issue(joinPath(path, mark), "invalid_type", "must be true or false"));
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
const out = { type: "text", value: node.value };
|
|
1884
|
+
if (node.bold === true) out.bold = true;
|
|
1885
|
+
if (node.italic === true) out.italic = true;
|
|
1886
|
+
return out;
|
|
1887
|
+
}
|
|
1888
|
+
function richInline(node, path, errors) {
|
|
1889
|
+
if (!isPlainObject(node)) {
|
|
1890
|
+
errors.push(issue(path, "invalid_node", "must be a text or link node"));
|
|
1891
|
+
return null;
|
|
1892
|
+
}
|
|
1893
|
+
if (node.type === "text") return richText(node, path, errors);
|
|
1894
|
+
if (node.type === "link") {
|
|
1895
|
+
errors.push(...unknownKeys(node, ["type", "url", "title", "children"], path));
|
|
1896
|
+
const url = typeof node.url === "string" ? node.url : "";
|
|
1897
|
+
if (!parseHttpUrl(url) && !(url.length <= MAX_URL_LENGTH && MAILTO.test(url) && !UNSAFE_URL_CHARS.test(url))) {
|
|
1898
|
+
errors.push(issue(joinPath(path, "url"), "unsafe_url", "must be an http(s) or mailto link"));
|
|
1899
|
+
}
|
|
1900
|
+
if (node.title !== void 0 && typeof node.title !== "string") {
|
|
1901
|
+
errors.push(issue(joinPath(path, "title"), "invalid_type", "must be text"));
|
|
1902
|
+
}
|
|
1903
|
+
const children = richChildren(node.children, joinPath(path, "children"), errors, (child, at) => {
|
|
1904
|
+
if (isPlainObject(child) && child.type === "text") return richText(child, at, errors);
|
|
1905
|
+
errors.push(issue(joinPath(at, "type"), "invalid_node", "a link may only contain text"));
|
|
1906
|
+
return null;
|
|
1907
|
+
});
|
|
1908
|
+
const out = { type: "link", url, children };
|
|
1909
|
+
if (typeof node.title === "string") out.title = node.title;
|
|
1910
|
+
return out;
|
|
1911
|
+
}
|
|
1912
|
+
errors.push(
|
|
1913
|
+
issue(joinPath(path, "type"), "invalid_node", `unexpected node type ${JSON.stringify(String(node.type).slice(0, 40))}`)
|
|
1914
|
+
);
|
|
1915
|
+
return null;
|
|
1916
|
+
}
|
|
1917
|
+
function richBlock(node, path, errors) {
|
|
1918
|
+
if (!isPlainObject(node)) {
|
|
1919
|
+
errors.push(issue(path, "invalid_node", "must be a paragraph, heading or list node"));
|
|
1920
|
+
return null;
|
|
1921
|
+
}
|
|
1922
|
+
const inline = (child, at) => richInline(child, at, errors);
|
|
1923
|
+
const children = (at, from) => richChildren(from, joinPath(at, "children"), errors, inline);
|
|
1924
|
+
switch (node.type) {
|
|
1925
|
+
case "paragraph":
|
|
1926
|
+
errors.push(...unknownKeys(node, ["type", "children"], path));
|
|
1927
|
+
return { type: "paragraph", children: children(path, node.children) };
|
|
1928
|
+
case "heading": {
|
|
1929
|
+
errors.push(...unknownKeys(node, ["type", "level", "children"], path));
|
|
1930
|
+
const level = node.level;
|
|
1931
|
+
if (typeof level !== "number" || !Number.isInteger(level) || level < 1 || level > 6) {
|
|
1932
|
+
errors.push(issue(joinPath(path, "level"), "invalid_format", "must be 1 to 6"));
|
|
1933
|
+
}
|
|
1934
|
+
return { type: "heading", level, children: children(path, node.children) };
|
|
1935
|
+
}
|
|
1936
|
+
case "list": {
|
|
1937
|
+
errors.push(...unknownKeys(node, ["type", "listType", "children"], path));
|
|
1938
|
+
if (node.listType !== "ordered" && node.listType !== "unordered") {
|
|
1939
|
+
errors.push(issue(joinPath(path, "listType"), "invalid_format", "must be ordered or unordered"));
|
|
1940
|
+
}
|
|
1941
|
+
const items = richChildren(node.children, joinPath(path, "children"), errors, (child, at) => {
|
|
1942
|
+
if (!isPlainObject(child) || child.type !== "list-item") {
|
|
1943
|
+
errors.push(issue(at, "invalid_node", "must be a list-item node"));
|
|
1944
|
+
return null;
|
|
1945
|
+
}
|
|
1946
|
+
errors.push(...unknownKeys(child, ["type", "children"], at));
|
|
1947
|
+
return { type: "list-item", children: children(at, child.children) };
|
|
1948
|
+
});
|
|
1949
|
+
return { type: "list", listType: node.listType, children: items };
|
|
1950
|
+
}
|
|
1951
|
+
default:
|
|
1952
|
+
errors.push(
|
|
1953
|
+
issue(joinPath(path, "type"), "invalid_node", `unexpected node type ${JSON.stringify(String(node.type).slice(0, 40))}`)
|
|
1954
|
+
);
|
|
1955
|
+
return null;
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
var MAX_RICH_TOP_NODES = 2e3;
|
|
1959
|
+
function validateRichText(input, path = "") {
|
|
1960
|
+
if (!isPlainObject(input) || input.type !== "root") {
|
|
1961
|
+
return fail(path, "invalid_node", "must be a rich-text root node");
|
|
1962
|
+
}
|
|
1963
|
+
if (Array.isArray(input.children) && input.children.length > MAX_RICH_TOP_NODES) {
|
|
1964
|
+
return fail(path, "too_large", "has too many nodes");
|
|
1965
|
+
}
|
|
1966
|
+
const errors = unknownKeys(input, ["type", "children"], path);
|
|
1967
|
+
const children = richChildren(
|
|
1968
|
+
input.children,
|
|
1969
|
+
joinPath(path, "children"),
|
|
1970
|
+
errors,
|
|
1971
|
+
(child, at) => richBlock(child, at, errors)
|
|
1972
|
+
);
|
|
1973
|
+
return errors.length ? { ok: false, errors: errors.slice(0, MAX_RICH_ERRORS) } : ok({ type: "root", children });
|
|
1974
|
+
}
|
|
1975
|
+
function richTextLength(root) {
|
|
1976
|
+
let count = 0;
|
|
1977
|
+
const visit = (node) => {
|
|
1978
|
+
if (node.type === "text") count += codePoints(node.value);
|
|
1979
|
+
else node.children.forEach(visit);
|
|
1980
|
+
};
|
|
1981
|
+
for (const block of root.children) {
|
|
1982
|
+
if (block.type === "list") block.children.forEach((item) => item.children.forEach(visit));
|
|
1983
|
+
else block.children.forEach(visit);
|
|
1984
|
+
}
|
|
1985
|
+
return count;
|
|
1986
|
+
}
|
|
1987
|
+
var checkRichText = (value, v, _ctx, path) => {
|
|
1988
|
+
const tree = validateRichText(value, path);
|
|
1989
|
+
if (!tree.ok) return tree;
|
|
1990
|
+
if (v.max_length !== void 0 && richTextLength(tree.value) > v.max_length) {
|
|
1991
|
+
return fail(path, "too_long", `must be at most ${v.max_length} characters`);
|
|
1992
|
+
}
|
|
1993
|
+
return tree;
|
|
1994
|
+
};
|
|
1995
|
+
var MEASUREMENT_UNITS = {
|
|
1996
|
+
weight: { g: 1, kg: 1e3, oz: 28.349523125, lb: 453.59237 },
|
|
1997
|
+
volume: {
|
|
1998
|
+
ml: 1,
|
|
1999
|
+
cl: 10,
|
|
2000
|
+
l: 1e3,
|
|
2001
|
+
m3: 1e6,
|
|
2002
|
+
fl_oz: 29.5735295625,
|
|
2003
|
+
pt: 473.176473,
|
|
2004
|
+
qt: 946.352946,
|
|
2005
|
+
gal: 3785.411784
|
|
2006
|
+
},
|
|
2007
|
+
dimension: { mm: 1, cm: 10, m: 1e3, in: 25.4, ft: 304.8, yd: 914.4 }
|
|
2008
|
+
};
|
|
2009
|
+
function measurementInBaseUnit(measurement, type) {
|
|
2010
|
+
const units = MEASUREMENT_UNITS[type];
|
|
2011
|
+
return hasOwn(units, measurement.unit) ? Number(measurement.value) * units[measurement.unit] : null;
|
|
2012
|
+
}
|
|
2013
|
+
function measurementChecker(type) {
|
|
2014
|
+
const unitList = Object.keys(MEASUREMENT_UNITS[type]).join(", ");
|
|
2015
|
+
return (value, v, _ctx, path) => {
|
|
2016
|
+
if (!isPlainObject(value)) return fail(path, "invalid_type", "must be an object with value and unit");
|
|
2017
|
+
const extra = unknownKeys(value, ["value", "unit"], path);
|
|
2018
|
+
if (extra.length) return { ok: false, errors: extra };
|
|
2019
|
+
const amount = normalizeDecimal(value.value);
|
|
2020
|
+
if (amount === null) return fail(joinPath(path, "value"), "invalid_type", "must be a decimal number");
|
|
2021
|
+
if (typeof value.unit !== "string" || !hasOwn(MEASUREMENT_UNITS[type], value.unit)) {
|
|
2022
|
+
return fail(joinPath(path, "unit"), "invalid_unit", `must be one of: ${unitList}`);
|
|
2023
|
+
}
|
|
2024
|
+
const measurement = { value: amount, unit: value.unit };
|
|
2025
|
+
const base2 = measurementInBaseUnit(measurement, type);
|
|
2026
|
+
if (typeof v.min === "object" && v.min !== null) {
|
|
2027
|
+
const min = measurementInBaseUnit(v.min, type);
|
|
2028
|
+
if (min !== null && base2 < min) {
|
|
2029
|
+
return fail(path, "too_small", `must be at least ${v.min.value} ${v.min.unit}`);
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
if (typeof v.max === "object" && v.max !== null) {
|
|
2033
|
+
const max = measurementInBaseUnit(v.max, type);
|
|
2034
|
+
if (max !== null && base2 > max) {
|
|
2035
|
+
return fail(path, "too_big", `must be at most ${v.max.value} ${v.max.unit}`);
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
return ok(measurement);
|
|
2039
|
+
};
|
|
2040
|
+
}
|
|
2041
|
+
var checkRating = (value, v, _ctx, path) => {
|
|
2042
|
+
if (!isPlainObject(value)) {
|
|
2043
|
+
return fail(path, "invalid_type", "must be an object with value, scale_min and scale_max");
|
|
2044
|
+
}
|
|
2045
|
+
const extra = unknownKeys(value, ["value", "scale_min", "scale_max"], path);
|
|
2046
|
+
if (extra.length) return { ok: false, errors: extra };
|
|
2047
|
+
const parts = { value: "", scale_min: "", scale_max: "" };
|
|
2048
|
+
for (const key of ["value", "scale_min", "scale_max"]) {
|
|
2049
|
+
const decimal = normalizeDecimal(value[key]);
|
|
2050
|
+
if (decimal === null) return fail(joinPath(path, key), "invalid_type", "must be a decimal number");
|
|
2051
|
+
parts[key] = decimal;
|
|
2052
|
+
}
|
|
2053
|
+
if (v.scale_min !== void 0 && compareDecimal(parts.scale_min, v.scale_min) !== 0 || v.scale_max !== void 0 && compareDecimal(parts.scale_max, v.scale_max) !== 0) {
|
|
2054
|
+
return fail(path, "scale_mismatch", `must use the scale ${v.scale_min} to ${v.scale_max}`);
|
|
2055
|
+
}
|
|
2056
|
+
if (compareDecimal(parts.value, parts.scale_min) < 0) {
|
|
2057
|
+
return fail(joinPath(path, "value"), "too_small", `must be at least ${parts.scale_min}`);
|
|
2058
|
+
}
|
|
2059
|
+
if (compareDecimal(parts.value, parts.scale_max) > 0) {
|
|
2060
|
+
return fail(joinPath(path, "value"), "too_big", `must be at most ${parts.scale_max}`);
|
|
2061
|
+
}
|
|
2062
|
+
return ok(parts);
|
|
2063
|
+
};
|
|
2064
|
+
var checkMoney = (value, _v, ctx, path) => {
|
|
2065
|
+
if (!isPlainObject(value)) return fail(path, "invalid_type", "must be an object with amount and currency_code");
|
|
2066
|
+
const extra = unknownKeys(value, ["amount", "currency_code"], path);
|
|
2067
|
+
if (extra.length) return { ok: false, errors: extra };
|
|
2068
|
+
const amount = normalizeDecimal(value.amount);
|
|
2069
|
+
if (amount === null) return fail(joinPath(path, "amount"), "invalid_type", "must be a decimal number");
|
|
2070
|
+
const currency = typeof value.currency_code === "string" ? value.currency_code.toUpperCase() : "";
|
|
2071
|
+
const expected = ctx.currency_code.toUpperCase();
|
|
2072
|
+
if (currency !== expected) {
|
|
2073
|
+
return fail(joinPath(path, "currency_code"), "currency_mismatch", `must be ${expected}`);
|
|
2074
|
+
}
|
|
2075
|
+
return ok({ amount, currency_code: currency });
|
|
2076
|
+
};
|
|
2077
|
+
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
2078
|
+
var checkAsset = (value, _v, _ctx, path) => typeof value === "string" && UUID.test(value) ? ok(value.toLowerCase()) : fail(path, "invalid_format", "must be an asset id");
|
|
2079
|
+
function allowedFileKinds(type, validations) {
|
|
2080
|
+
switch (baseTypeOf(type)) {
|
|
2081
|
+
case "image":
|
|
2082
|
+
return ["image"];
|
|
2083
|
+
case "video":
|
|
2084
|
+
return ["video"];
|
|
2085
|
+
case "file":
|
|
2086
|
+
return validations.file_types ?? null;
|
|
2087
|
+
default:
|
|
2088
|
+
return null;
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
var ID = /^[1-9]\d{0,18}$/;
|
|
2092
|
+
var MAX_BIGINT = "9223372036854775807";
|
|
2093
|
+
function normalizeId(input) {
|
|
2094
|
+
if (typeof input === "number") {
|
|
2095
|
+
return Number.isSafeInteger(input) && input > 0 ? String(input) : null;
|
|
2096
|
+
}
|
|
2097
|
+
if (typeof input !== "string" || !ID.test(input)) return null;
|
|
2098
|
+
if (input.length === MAX_BIGINT.length && input > MAX_BIGINT) return null;
|
|
2099
|
+
return input;
|
|
2100
|
+
}
|
|
2101
|
+
var checkId = (value, _v, _ctx, path) => {
|
|
2102
|
+
const id = normalizeId(value);
|
|
2103
|
+
return id === null ? fail(path, "invalid_format", "must be a record id") : ok(id);
|
|
2104
|
+
};
|
|
2105
|
+
var CHECKERS = {
|
|
2106
|
+
single_line_text: textChecker(METAFIELD_LIMITS.single_line_text_length, true),
|
|
2107
|
+
multi_line_text: textChecker(METAFIELD_LIMITS.multi_line_text_length, false),
|
|
2108
|
+
rich_text: checkRichText,
|
|
2109
|
+
email: checkEmail,
|
|
2110
|
+
integer: checkInteger,
|
|
2111
|
+
decimal: checkDecimal,
|
|
2112
|
+
date: dateChecker(normalizeDate, "a date (YYYY-MM-DD)"),
|
|
2113
|
+
date_time: dateChecker(normalizeDateTime, "a date and time (YYYY-MM-DDTHH:mm:ssZ)"),
|
|
2114
|
+
url: checkUrl,
|
|
2115
|
+
link: checkLink,
|
|
2116
|
+
weight: measurementChecker("weight"),
|
|
2117
|
+
volume: measurementChecker("volume"),
|
|
2118
|
+
dimension: measurementChecker("dimension"),
|
|
2119
|
+
boolean: checkBoolean,
|
|
2120
|
+
color: checkColor,
|
|
2121
|
+
rating: checkRating,
|
|
2122
|
+
money: checkMoney,
|
|
2123
|
+
language: checkLanguage,
|
|
2124
|
+
json: checkJson,
|
|
2125
|
+
file: checkAsset,
|
|
2126
|
+
image: checkAsset,
|
|
2127
|
+
video: checkAsset,
|
|
2128
|
+
product: checkId,
|
|
2129
|
+
variant: checkId,
|
|
2130
|
+
collection: checkId,
|
|
2131
|
+
page: checkId,
|
|
2132
|
+
blog_post: checkId,
|
|
2133
|
+
customer: checkId,
|
|
2134
|
+
order: checkId,
|
|
2135
|
+
metaobject_reference: checkId,
|
|
2136
|
+
mixed_reference: checkId
|
|
2137
|
+
};
|
|
2138
|
+
function isBlankValue(value) {
|
|
2139
|
+
return value === null || value === void 0 || value === "" || Array.isArray(value) && value.length === 0;
|
|
2140
|
+
}
|
|
2141
|
+
var TEXT_BASE_TYPES = ["single_line_text", "multi_line_text", "email", "url"];
|
|
2142
|
+
function isBlankScalar(base2, value) {
|
|
2143
|
+
if (isBlankValue(value)) return true;
|
|
2144
|
+
if (typeof value === "string") return TEXT_BASE_TYPES.includes(base2) && value.trim() === "";
|
|
2145
|
+
return base2 === "rich_text" && isPlainObject(value) && value.type === "root" && Array.isArray(value.children) && value.children.length === 0;
|
|
2146
|
+
}
|
|
2147
|
+
function isBlankValueFor(type, value) {
|
|
2148
|
+
if (!isMetafieldType(type)) return isBlankValue(value);
|
|
2149
|
+
if (isListType(type)) return isBlankValue(value);
|
|
2150
|
+
return isBlankScalar(baseTypeOf(type), value);
|
|
2151
|
+
}
|
|
2152
|
+
function checkList(base2, checker, value, v, ctx, path) {
|
|
2153
|
+
if (!Array.isArray(value)) return fail(path, "invalid_type", "must be a list");
|
|
2154
|
+
const max = Math.min(METAFIELD_LIMITS.list_items, v.list_max ?? METAFIELD_LIMITS.list_items);
|
|
2155
|
+
if (value.length > max) return fail(path, "list_too_long", `must have at most ${max} items`);
|
|
2156
|
+
if (v.list_min !== void 0 && value.length < v.list_min) {
|
|
2157
|
+
return fail(path, "list_too_short", `must have at least ${v.list_min} items`);
|
|
2158
|
+
}
|
|
2159
|
+
const items = [];
|
|
2160
|
+
const errors = [];
|
|
2161
|
+
for (let index = 0; index < value.length; index++) {
|
|
2162
|
+
const item = value[index];
|
|
2163
|
+
const at = joinPath(path, index);
|
|
2164
|
+
const result = isBlankScalar(base2, item) ? fail(at, "blank", "is empty") : checker(item, v, ctx, at);
|
|
2165
|
+
if (result.ok) items.push(result.value);
|
|
2166
|
+
else errors.push(...result.errors);
|
|
2167
|
+
}
|
|
2168
|
+
return errors.length ? { ok: false, errors } : ok(items);
|
|
2169
|
+
}
|
|
2170
|
+
function isStorableJson(json) {
|
|
2171
|
+
for (const match of json.matchAll(/\\(?:u([0-9a-f]{4})|[^u])/g)) {
|
|
2172
|
+
const code = match[1] === void 0 ? -1 : parseInt(match[1], 16);
|
|
2173
|
+
if (code === 0 || code >= 55296 && code <= 57343) return false;
|
|
2174
|
+
}
|
|
2175
|
+
return true;
|
|
2176
|
+
}
|
|
2177
|
+
function byteLength(text) {
|
|
2178
|
+
return new TextEncoder().encode(text).length;
|
|
2179
|
+
}
|
|
2180
|
+
function validateMetafieldValue(type, validations, value, ctx, path = "") {
|
|
2181
|
+
if (!isMetafieldType(type)) return fail(path, "invalid_type", "is not a metafield type");
|
|
2182
|
+
if (!isPlainObject(validations)) validations = {};
|
|
2183
|
+
if (isBlankValueFor(type, value)) return fail(path, "blank", "is empty; send null to clear it");
|
|
2184
|
+
if (isListType(type) && Array.isArray(value) && value.length > 4 * METAFIELD_LIMITS.list_items) {
|
|
2185
|
+
return fail(path, "list_too_long", `must have at most ${METAFIELD_LIMITS.list_items} items`);
|
|
2186
|
+
}
|
|
2187
|
+
const base2 = baseTypeOf(type);
|
|
2188
|
+
const checker = hasOwn(CHECKERS, base2) ? CHECKERS[base2] : void 0;
|
|
2189
|
+
if (!checker) return fail(path, "invalid_type", `type ${String(type).slice(0, 40)} is not supported`);
|
|
2190
|
+
const result = isListType(type) ? checkList(base2, checker, value, validations, ctx, path) : checker(value, validations, ctx, path);
|
|
2191
|
+
if (!result.ok) return result;
|
|
2192
|
+
const json = JSON.stringify(result.value);
|
|
2193
|
+
if (!isStorableJson(json)) {
|
|
2194
|
+
return fail(path, "invalid_format", "contains characters that cannot be stored");
|
|
2195
|
+
}
|
|
2196
|
+
if (byteLength(json) > METAFIELD_LIMITS.value_bytes) {
|
|
2197
|
+
return fail(path, "too_large", `must be at most ${METAFIELD_LIMITS.value_bytes} bytes`);
|
|
2198
|
+
}
|
|
2199
|
+
return result;
|
|
2200
|
+
}
|
|
2201
|
+
var VALIDATION_KEYS = {
|
|
2202
|
+
single_line_text: ["min_length", "max_length", "regex", "choices"],
|
|
2203
|
+
multi_line_text: ["min_length", "max_length"],
|
|
2204
|
+
rich_text: ["max_length"],
|
|
2205
|
+
email: [],
|
|
2206
|
+
integer: ["min", "max"],
|
|
2207
|
+
decimal: ["min", "max", "max_precision"],
|
|
2208
|
+
date: ["min", "max"],
|
|
2209
|
+
date_time: ["min", "max"],
|
|
2210
|
+
url: ["allowed_domains"],
|
|
2211
|
+
link: ["allowed_domains"],
|
|
2212
|
+
weight: ["min", "max"],
|
|
2213
|
+
volume: ["min", "max"],
|
|
2214
|
+
dimension: ["min", "max"],
|
|
2215
|
+
boolean: [],
|
|
2216
|
+
color: [],
|
|
2217
|
+
rating: ["scale_min", "scale_max"],
|
|
2218
|
+
money: [],
|
|
2219
|
+
language: [],
|
|
2220
|
+
json: [],
|
|
2221
|
+
file: ["file_types"],
|
|
2222
|
+
image: [],
|
|
2223
|
+
video: [],
|
|
2224
|
+
product: [],
|
|
2225
|
+
variant: [],
|
|
2226
|
+
collection: [],
|
|
2227
|
+
page: [],
|
|
2228
|
+
blog_post: [],
|
|
2229
|
+
customer: [],
|
|
2230
|
+
order: [],
|
|
2231
|
+
metaobject_reference: ["metaobject_definition_id"],
|
|
2232
|
+
mixed_reference: ["metaobject_definition_ids"]
|
|
2233
|
+
};
|
|
2234
|
+
function isSafeRegex(pattern) {
|
|
2235
|
+
if (/\\[1-9]|\\k</.test(pattern)) return false;
|
|
2236
|
+
if (/\(\?<?[=!]/.test(pattern)) return false;
|
|
2237
|
+
let quantifiers = 0;
|
|
2238
|
+
let bars = 0;
|
|
2239
|
+
let afterQuantifier = false;
|
|
2240
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
2241
|
+
const char = pattern[i];
|
|
2242
|
+
const wasQuantifier = afterQuantifier;
|
|
2243
|
+
afterQuantifier = false;
|
|
2244
|
+
if (char === "\\") {
|
|
2245
|
+
const escaped = pattern[i + 1];
|
|
2246
|
+
i++;
|
|
2247
|
+
if ((escaped === "u" || escaped === "p" || escaped === "P") && pattern[i + 1] === "{") {
|
|
2248
|
+
const close = pattern.indexOf("}", i + 1);
|
|
2249
|
+
i = close === -1 ? pattern.length : close;
|
|
2250
|
+
}
|
|
2251
|
+
continue;
|
|
2252
|
+
}
|
|
2253
|
+
if (char === "[") {
|
|
2254
|
+
i++;
|
|
2255
|
+
while (i < pattern.length && pattern[i] !== "]") {
|
|
2256
|
+
if (pattern[i] === "\\") i++;
|
|
2257
|
+
i++;
|
|
2258
|
+
}
|
|
2259
|
+
continue;
|
|
2260
|
+
}
|
|
2261
|
+
if (char === "(") {
|
|
2262
|
+
if (pattern[i + 1] === "?") i++;
|
|
2263
|
+
continue;
|
|
2264
|
+
}
|
|
2265
|
+
if (char === ")") {
|
|
2266
|
+
const next = pattern[i + 1];
|
|
2267
|
+
if (next === "*" || next === "+") return false;
|
|
2268
|
+
if (next === "{" && /^\{\d+(,\d*)?\}/.test(pattern.slice(i + 1))) return false;
|
|
2269
|
+
continue;
|
|
2270
|
+
}
|
|
2271
|
+
if (char === "|") {
|
|
2272
|
+
bars++;
|
|
2273
|
+
} else if (char === "*" || char === "+" || char === "?") {
|
|
2274
|
+
if (!(char === "?" && wasQuantifier)) {
|
|
2275
|
+
quantifiers++;
|
|
2276
|
+
afterQuantifier = true;
|
|
2277
|
+
}
|
|
2278
|
+
} else if (char === "{") {
|
|
2279
|
+
const match = /^\{\d+(,\d*)?\}/.exec(pattern.slice(i));
|
|
2280
|
+
if (match) {
|
|
2281
|
+
if (match[1] !== void 0) quantifiers++;
|
|
2282
|
+
afterQuantifier = true;
|
|
2283
|
+
i += match[0].length - 1;
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
return quantifiers <= 2 && bars <= 4;
|
|
2288
|
+
}
|
|
2289
|
+
var HOSTNAME = /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
|
|
2290
|
+
var FILE_KINDS = ["image", "video", "document"];
|
|
2291
|
+
function normalizeBound(base2, input) {
|
|
2292
|
+
switch (base2) {
|
|
2293
|
+
case "integer":
|
|
2294
|
+
return typeof input === "number" && Number.isSafeInteger(input) ? input : null;
|
|
2295
|
+
case "decimal":
|
|
2296
|
+
return normalizeDecimal(input);
|
|
2297
|
+
case "date":
|
|
2298
|
+
return normalizeDate(input);
|
|
2299
|
+
case "date_time":
|
|
2300
|
+
return normalizeDateTime(input);
|
|
2301
|
+
case "weight":
|
|
2302
|
+
case "volume":
|
|
2303
|
+
case "dimension": {
|
|
2304
|
+
if (!isPlainObject(input) || Object.keys(input).some((k) => k !== "value" && k !== "unit")) return null;
|
|
2305
|
+
const amount = normalizeDecimal(input.value);
|
|
2306
|
+
if (amount === null || typeof input.unit !== "string" || !hasOwn(MEASUREMENT_UNITS[base2], input.unit)) {
|
|
2307
|
+
return null;
|
|
2308
|
+
}
|
|
2309
|
+
return { value: amount, unit: input.unit };
|
|
2310
|
+
}
|
|
2311
|
+
default:
|
|
2312
|
+
return null;
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
function compareBound(base2, a, b) {
|
|
2316
|
+
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
2317
|
+
if (typeof a === "object" && typeof b === "object") {
|
|
2318
|
+
const type = base2;
|
|
2319
|
+
return (measurementInBaseUnit(a, type) ?? 0) - (measurementInBaseUnit(b, type) ?? 0);
|
|
2320
|
+
}
|
|
2321
|
+
if (base2 === "decimal") return compareDecimal(a, b);
|
|
2322
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
2323
|
+
}
|
|
2324
|
+
function isWholeNumber(value, min, max) {
|
|
2325
|
+
return typeof value === "number" && Number.isInteger(value) && value >= min && value <= max;
|
|
2326
|
+
}
|
|
2327
|
+
function validateValidations(type, input, path = "validations") {
|
|
2328
|
+
if (!isMetafieldType(type)) return fail(path, "invalid_type", "is not a metafield type");
|
|
2329
|
+
const raw = input === void 0 || input === null ? {} : input;
|
|
2330
|
+
if (!isPlainObject(raw)) return fail(path, "invalid_type", "must be an object");
|
|
2331
|
+
const base2 = baseTypeOf(type);
|
|
2332
|
+
const allowed = [
|
|
2333
|
+
...VALIDATION_KEYS[base2],
|
|
2334
|
+
...isListType(type) ? ["list_min", "list_max"] : []
|
|
2335
|
+
];
|
|
2336
|
+
const errors = unknownKeys(raw, allowed, path);
|
|
2337
|
+
const out = {};
|
|
2338
|
+
const has = (key) => allowed.includes(key) && raw[key] !== void 0;
|
|
2339
|
+
const bad = (key, message, code = "invalid_validation") => errors.push(issue(joinPath(path, key), code, message));
|
|
2340
|
+
for (const key of ["min_length", "max_length"]) {
|
|
2341
|
+
if (!has(key)) continue;
|
|
2342
|
+
const cap = base2 === "single_line_text" ? METAFIELD_LIMITS.single_line_text_length : METAFIELD_LIMITS.multi_line_text_length;
|
|
2343
|
+
if (isWholeNumber(raw[key], 0, cap)) out[key] = raw[key];
|
|
2344
|
+
else bad(key, "must be a whole number of 0 or more");
|
|
2345
|
+
}
|
|
2346
|
+
if (has("regex")) {
|
|
2347
|
+
const pattern = raw.regex;
|
|
2348
|
+
if (typeof pattern !== "string" || pattern.length === 0 || pattern.length > METAFIELD_LIMITS.regex_length) {
|
|
2349
|
+
bad("regex", `must be 1 to ${METAFIELD_LIMITS.regex_length} characters`);
|
|
2350
|
+
} else if (!isSafeRegex(pattern)) {
|
|
2351
|
+
bad("regex", "is too complex: no backreferences or lookaround, no repetition after a group, at most 2 optional or repeated parts and 4 alternatives", "unsafe_regex");
|
|
2352
|
+
} else {
|
|
2353
|
+
try {
|
|
2354
|
+
new RegExp(pattern, "u");
|
|
2355
|
+
out.regex = pattern;
|
|
2356
|
+
} catch {
|
|
2357
|
+
bad("regex", "is not a valid pattern");
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
if (has("regex")) {
|
|
2362
|
+
const limit = METAFIELD_LIMITS.regex_value_length;
|
|
2363
|
+
if (out.max_length !== void 0 && out.max_length > limit) {
|
|
2364
|
+
bad("max_length", `must be at most ${limit} when a pattern applies`);
|
|
2365
|
+
} else if (out.regex !== void 0 && out.max_length === void 0) {
|
|
2366
|
+
out.max_length = limit;
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
if (out.min_length !== void 0 && out.max_length !== void 0 && out.min_length > out.max_length) {
|
|
2370
|
+
bad("min_length", "must not exceed max_length");
|
|
2371
|
+
}
|
|
2372
|
+
if (has("choices")) {
|
|
2373
|
+
const choices = raw.choices;
|
|
2374
|
+
if (!Array.isArray(choices) || choices.length === 0 || choices.length > METAFIELD_LIMITS.choices) {
|
|
2375
|
+
bad("choices", `must list 1 to ${METAFIELD_LIMITS.choices} values`);
|
|
2376
|
+
} else if (choices.some(
|
|
2377
|
+
(c) => typeof c !== "string" || c === "" || /[\r\n]/.test(c) || codePoints(c) > METAFIELD_LIMITS.single_line_text_length
|
|
2378
|
+
)) {
|
|
2379
|
+
bad("choices", "must be non-empty single-line text");
|
|
2380
|
+
} else if (new Set(choices).size !== choices.length) {
|
|
2381
|
+
bad("choices", "must not repeat a value");
|
|
2382
|
+
} else if (choices.some((c) => {
|
|
2383
|
+
const length = codePoints(c);
|
|
2384
|
+
if (length > METAFIELD_LIMITS.regex_value_length && out.regex !== void 0) return true;
|
|
2385
|
+
if (out.max_length !== void 0 && length > out.max_length) return true;
|
|
2386
|
+
if (out.min_length !== void 0 && length < out.min_length) return true;
|
|
2387
|
+
return out.regex !== void 0 && !matchesPattern(out.regex, c);
|
|
2388
|
+
})) {
|
|
2389
|
+
bad("choices", "includes a value the pattern or length rules reject");
|
|
2390
|
+
} else {
|
|
2391
|
+
out.choices = [...choices];
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
for (const key of ["min", "max"]) {
|
|
2395
|
+
if (!has(key)) continue;
|
|
2396
|
+
const bound = normalizeBound(base2, raw[key]);
|
|
2397
|
+
if (bound === null) bad(key, `is not a valid ${base2} bound`);
|
|
2398
|
+
else out[key] = bound;
|
|
2399
|
+
}
|
|
2400
|
+
if (out.min !== void 0 && out.max !== void 0 && compareBound(base2, out.min, out.max) > 0) {
|
|
2401
|
+
bad("min", "must not exceed max");
|
|
2402
|
+
}
|
|
2403
|
+
if (has("max_precision")) {
|
|
2404
|
+
if (isWholeNumber(raw.max_precision, 0, 9)) out.max_precision = raw.max_precision;
|
|
2405
|
+
else bad("max_precision", "must be a whole number from 0 to 9");
|
|
2406
|
+
}
|
|
2407
|
+
if (has("allowed_domains")) {
|
|
2408
|
+
const domains = raw.allowed_domains;
|
|
2409
|
+
const lowered = Array.isArray(domains) ? domains.map((d) => typeof d === "string" ? d.toLowerCase() : "") : [];
|
|
2410
|
+
if (!Array.isArray(domains) || domains.length === 0 || domains.length > METAFIELD_LIMITS.allowed_domains || lowered.some((d) => !HOSTNAME.test(d))) {
|
|
2411
|
+
bad("allowed_domains", `must list 1 to ${METAFIELD_LIMITS.allowed_domains} domains such as youtube.com`);
|
|
2412
|
+
} else {
|
|
2413
|
+
out.allowed_domains = [...new Set(lowered)];
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
if (base2 === "rating") {
|
|
2417
|
+
for (const key of ["scale_min", "scale_max"]) {
|
|
2418
|
+
if (raw[key] === void 0) {
|
|
2419
|
+
bad(key, "is required for a rating", "required");
|
|
2420
|
+
continue;
|
|
2421
|
+
}
|
|
2422
|
+
const decimal = normalizeDecimal(raw[key]);
|
|
2423
|
+
if (decimal === null) bad(key, "must be a decimal number");
|
|
2424
|
+
else out[key] = decimal;
|
|
2425
|
+
}
|
|
2426
|
+
if (out.scale_min !== void 0 && out.scale_max !== void 0 && compareDecimal(out.scale_min, out.scale_max) >= 0) {
|
|
2427
|
+
bad("scale_min", "must be below scale_max");
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
if (has("file_types")) {
|
|
2431
|
+
const kinds = raw.file_types;
|
|
2432
|
+
if (!Array.isArray(kinds) || kinds.length === 0 || kinds.some((k) => !FILE_KINDS.includes(k)) || new Set(kinds).size !== kinds.length) {
|
|
2433
|
+
bad("file_types", "must list image, video and/or document");
|
|
2434
|
+
} else {
|
|
2435
|
+
out.file_types = [...kinds];
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
if (base2 === "metaobject_reference") {
|
|
2439
|
+
const id = normalizeId(raw.metaobject_definition_id);
|
|
2440
|
+
if (raw.metaobject_definition_id === void 0) {
|
|
2441
|
+
bad("metaobject_definition_id", "is required", "required");
|
|
2442
|
+
} else if (id === null) {
|
|
2443
|
+
bad("metaobject_definition_id", "must be a metaobject definition id");
|
|
2444
|
+
} else {
|
|
2445
|
+
out.metaobject_definition_id = id;
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
if (base2 === "mixed_reference") {
|
|
2449
|
+
const ids = Array.isArray(raw.metaobject_definition_ids) ? raw.metaobject_definition_ids.map(normalizeId) : null;
|
|
2450
|
+
if (raw.metaobject_definition_ids === void 0) {
|
|
2451
|
+
bad("metaobject_definition_ids", "is required", "required");
|
|
2452
|
+
} else if (!ids || ids.length < METAFIELD_LIMITS.mixed_reference_definitions_min || ids.length > METAFIELD_LIMITS.mixed_reference_definitions_max || ids.some((id) => id === null) || new Set(ids).size !== ids.length) {
|
|
2453
|
+
bad(
|
|
2454
|
+
"metaobject_definition_ids",
|
|
2455
|
+
`must list ${METAFIELD_LIMITS.mixed_reference_definitions_min} to ${METAFIELD_LIMITS.mixed_reference_definitions_max} different definition ids`
|
|
2456
|
+
);
|
|
2457
|
+
} else {
|
|
2458
|
+
out.metaobject_definition_ids = ids;
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
for (const key of ["list_min", "list_max"]) {
|
|
2462
|
+
if (!has(key)) continue;
|
|
2463
|
+
if (isWholeNumber(raw[key], 0, METAFIELD_LIMITS.list_items)) out[key] = raw[key];
|
|
2464
|
+
else bad(key, `must be a whole number from 0 to ${METAFIELD_LIMITS.list_items}`);
|
|
2465
|
+
}
|
|
2466
|
+
if (out.list_min !== void 0 && out.list_max !== void 0 && out.list_min > out.list_max) {
|
|
2467
|
+
bad("list_min", "must not exceed list_max");
|
|
2468
|
+
}
|
|
2469
|
+
return errors.length ? { ok: false, errors } : ok(out);
|
|
2470
|
+
}
|
|
2471
|
+
function storefrontAccessAllowed(owner) {
|
|
2472
|
+
return owner !== "customer" && owner !== "order" && owner !== "location";
|
|
2473
|
+
}
|
|
2474
|
+
function allowedCustomerAccess(owner) {
|
|
2475
|
+
if (owner === "customer") return ["none", "read", "read_write"];
|
|
2476
|
+
if (owner === "order") return ["none", "read"];
|
|
2477
|
+
return ["none"];
|
|
2478
|
+
}
|
|
2479
|
+
var METAFIELD_DEFINITION_KEYS = [
|
|
2480
|
+
"owner_type",
|
|
2481
|
+
"namespace",
|
|
2482
|
+
"key",
|
|
2483
|
+
"name",
|
|
2484
|
+
"description",
|
|
2485
|
+
"type",
|
|
2486
|
+
"validations",
|
|
2487
|
+
"storefront_access",
|
|
2488
|
+
"customer_access"
|
|
2489
|
+
];
|
|
2490
|
+
function readName(value, path, errors) {
|
|
2491
|
+
const name = typeof value === "string" ? value.trim() : "";
|
|
2492
|
+
if (!name || codePoints(name) > METAFIELD_LIMITS.name_length) {
|
|
2493
|
+
errors.push(issue(path, "invalid_format", `must be 1 to ${METAFIELD_LIMITS.name_length} characters`));
|
|
2494
|
+
}
|
|
2495
|
+
return name;
|
|
2496
|
+
}
|
|
2497
|
+
function readDescription(value, path, errors) {
|
|
2498
|
+
if (value === void 0 || value === null) return null;
|
|
2499
|
+
if (typeof value !== "string" || codePoints(value) > METAFIELD_LIMITS.description_length) {
|
|
2500
|
+
errors.push(issue(path, "invalid_format", `must be text of at most ${METAFIELD_LIMITS.description_length} characters`));
|
|
2501
|
+
return null;
|
|
2502
|
+
}
|
|
2503
|
+
return value.trim() || null;
|
|
2504
|
+
}
|
|
2505
|
+
function readKey(value, path, errors, pattern = METAFIELD_KEY_PATTERN) {
|
|
2506
|
+
if (typeof value !== "string" || !pattern.test(value)) {
|
|
2507
|
+
errors.push(issue(path, "invalid_format", "must be 2 to 64 lowercase letters, digits or underscores"));
|
|
2508
|
+
return "";
|
|
2509
|
+
}
|
|
2510
|
+
if (RESERVED_KEYS.includes(value)) {
|
|
2511
|
+
errors.push(issue(path, "invalid_format", "is a reserved name"));
|
|
2512
|
+
return "";
|
|
2513
|
+
}
|
|
2514
|
+
return value;
|
|
2515
|
+
}
|
|
2516
|
+
function readBoolean(value, fallback, path, errors) {
|
|
2517
|
+
if (value === void 0) return fallback;
|
|
2518
|
+
if (typeof value !== "boolean") {
|
|
2519
|
+
errors.push(issue(path, "invalid_type", "must be true or false"));
|
|
2520
|
+
return fallback;
|
|
2521
|
+
}
|
|
2522
|
+
return value;
|
|
2523
|
+
}
|
|
2524
|
+
function readTypeAndValidations(input, path, errors) {
|
|
2525
|
+
if (!isMetafieldType(input.type)) {
|
|
2526
|
+
errors.push(issue(joinPath(path, "type"), "invalid_format", "is not a metafield type"));
|
|
2527
|
+
return null;
|
|
2528
|
+
}
|
|
2529
|
+
const validations = validateValidations(input.type, input.validations, joinPath(path, "validations"));
|
|
2530
|
+
if (!validations.ok) {
|
|
2531
|
+
errors.push(...validations.errors);
|
|
2532
|
+
return null;
|
|
2533
|
+
}
|
|
2534
|
+
return { type: input.type, validations: validations.value };
|
|
2535
|
+
}
|
|
2536
|
+
function validateMetafieldDefinition(input) {
|
|
2537
|
+
if (!isPlainObject(input)) return fail("", "invalid_type", "must be an object");
|
|
2538
|
+
const errors = unknownKeys(input, METAFIELD_DEFINITION_KEYS, "");
|
|
2539
|
+
const owner = input.owner_type;
|
|
2540
|
+
if (!METAFIELD_OWNER_TYPES.includes(owner)) {
|
|
2541
|
+
errors.push(issue("owner_type", "invalid_format", `must be one of: ${METAFIELD_OWNER_TYPES.join(", ")}`));
|
|
2542
|
+
}
|
|
2543
|
+
const namespace = readKey(input.namespace ?? "custom", "namespace", errors);
|
|
2544
|
+
const key = readKey(input.key, "key", errors);
|
|
2545
|
+
const name = readName(input.name, "name", errors);
|
|
2546
|
+
const description = readDescription(input.description, "description", errors);
|
|
2547
|
+
const typed = readTypeAndValidations(input, "", errors);
|
|
2548
|
+
const storefront = readBoolean(input.storefront_access, false, "storefront_access", errors);
|
|
2549
|
+
if (storefront && METAFIELD_OWNER_TYPES.includes(owner) && !storefrontAccessAllowed(owner)) {
|
|
2550
|
+
errors.push(issue("storefront_access", "not_allowed", `is not available for ${owner} metafields`));
|
|
2551
|
+
}
|
|
2552
|
+
const customer = input.customer_access ?? "none";
|
|
2553
|
+
if (!allowedCustomerAccess(owner).includes(customer)) {
|
|
2554
|
+
errors.push(issue("customer_access", "not_allowed", `must be one of: ${allowedCustomerAccess(owner).join(", ")}`));
|
|
2555
|
+
}
|
|
2556
|
+
if (errors.length || !typed) return { ok: false, errors };
|
|
2557
|
+
const out = {
|
|
2558
|
+
owner_type: owner,
|
|
2559
|
+
namespace,
|
|
2560
|
+
key,
|
|
2561
|
+
name,
|
|
2562
|
+
description,
|
|
2563
|
+
type: typed.type,
|
|
2564
|
+
validations: typed.validations,
|
|
2565
|
+
storefront_access: storefront,
|
|
2566
|
+
customer_access: customer
|
|
2567
|
+
};
|
|
2568
|
+
return storable(out);
|
|
2569
|
+
}
|
|
2570
|
+
function storable(out) {
|
|
2571
|
+
if (!isStorableJson(JSON.stringify(out))) {
|
|
2572
|
+
return fail("", "invalid_format", "contains characters that cannot be stored");
|
|
2573
|
+
}
|
|
2574
|
+
return ok(out);
|
|
2575
|
+
}
|
|
2576
|
+
var FILTERABLE_TYPES = ["single_line_text", "boolean", "integer", "date"];
|
|
2577
|
+
var METAOBJECT_DEFINITION_KEYS = [
|
|
2578
|
+
"type",
|
|
2579
|
+
"name",
|
|
2580
|
+
"description",
|
|
2581
|
+
"fields",
|
|
2582
|
+
"display_name_key",
|
|
2583
|
+
"filter_keys",
|
|
2584
|
+
"has_status",
|
|
2585
|
+
"storefront_access",
|
|
2586
|
+
"customer_access"
|
|
2587
|
+
];
|
|
2588
|
+
var FIELD_KEYS = ["key", "name", "description", "type", "required", "validations"];
|
|
2589
|
+
function readField(input, path, errors) {
|
|
2590
|
+
if (!isPlainObject(input)) {
|
|
2591
|
+
errors.push(issue(path, "invalid_type", "must be an object"));
|
|
2592
|
+
return null;
|
|
2593
|
+
}
|
|
2594
|
+
errors.push(...unknownKeys(input, FIELD_KEYS, path));
|
|
2595
|
+
const key = readKey(input.key, joinPath(path, "key"), errors);
|
|
2596
|
+
const name = readName(input.name, joinPath(path, "name"), errors);
|
|
2597
|
+
const description = readDescription(input.description, joinPath(path, "description"), errors);
|
|
2598
|
+
const required = readBoolean(input.required, false, joinPath(path, "required"), errors);
|
|
2599
|
+
const typed = readTypeAndValidations(input, path, errors);
|
|
2600
|
+
return typed ? { key, name, description, type: typed.type, required, validations: typed.validations } : null;
|
|
2601
|
+
}
|
|
2602
|
+
function validateMetaobjectDefinition(input) {
|
|
2603
|
+
if (!isPlainObject(input)) return fail("", "invalid_type", "must be an object");
|
|
2604
|
+
const errors = unknownKeys(input, METAOBJECT_DEFINITION_KEYS, "");
|
|
2605
|
+
const type = typeof input.type === "string" && METAOBJECT_TYPE_PATTERN.test(input.type) ? input.type : "";
|
|
2606
|
+
if (!type) {
|
|
2607
|
+
errors.push(issue("type", "invalid_format", "must be 2 to 64 lowercase letters, digits, underscores or hyphens"));
|
|
2608
|
+
} else if (RESERVED_KEYS.includes(type)) {
|
|
2609
|
+
errors.push(issue("type", "invalid_format", "is a reserved name"));
|
|
2610
|
+
}
|
|
2611
|
+
const name = readName(input.name, "name", errors);
|
|
2612
|
+
const description = readDescription(input.description, "description", errors);
|
|
2613
|
+
const fields = [];
|
|
2614
|
+
if (!Array.isArray(input.fields)) {
|
|
2615
|
+
errors.push(issue("fields", "invalid_type", "must be a list of fields"));
|
|
2616
|
+
} else if (input.fields.length === 0) {
|
|
2617
|
+
errors.push(issue("fields", "too_short", "must have at least 1 field"));
|
|
2618
|
+
} else if (input.fields.length > METAFIELD_LIMITS.fields_per_metaobject) {
|
|
2619
|
+
errors.push(issue("fields", "too_long", `must have at most ${METAFIELD_LIMITS.fields_per_metaobject} fields`));
|
|
2620
|
+
} else {
|
|
2621
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2622
|
+
input.fields.forEach((raw, index) => {
|
|
2623
|
+
const path = joinPath("fields", index);
|
|
2624
|
+
const field = readField(raw, path, errors);
|
|
2625
|
+
if (!field) return;
|
|
2626
|
+
if (seen.has(field.key)) errors.push(issue(joinPath(path, "key"), "duplicate", `"${field.key}" is used twice`));
|
|
2627
|
+
seen.add(field.key);
|
|
2628
|
+
fields.push(field);
|
|
2629
|
+
});
|
|
2630
|
+
}
|
|
2631
|
+
const byKey = new Map(fields.map((field) => [field.key, field]));
|
|
2632
|
+
const isSingleLine = (key) => byKey.get(key)?.type === "single_line_text";
|
|
2633
|
+
let displayNameKey;
|
|
2634
|
+
if (input.display_name_key === void 0) {
|
|
2635
|
+
displayNameKey = fields.find((field) => field.type === "single_line_text")?.key ?? null;
|
|
2636
|
+
} else if (input.display_name_key === null) {
|
|
2637
|
+
displayNameKey = null;
|
|
2638
|
+
} else if (typeof input.display_name_key === "string" && isSingleLine(input.display_name_key)) {
|
|
2639
|
+
displayNameKey = input.display_name_key;
|
|
2640
|
+
} else {
|
|
2641
|
+
displayNameKey = null;
|
|
2642
|
+
errors.push(issue("display_name_key", "invalid_format", "must name a single line text field"));
|
|
2643
|
+
}
|
|
2644
|
+
const filterKeys = [];
|
|
2645
|
+
const rawFilters = input.filter_keys ?? [];
|
|
2646
|
+
if (!Array.isArray(rawFilters)) {
|
|
2647
|
+
errors.push(issue("filter_keys", "invalid_type", "must be a list of field keys"));
|
|
2648
|
+
} else if (rawFilters.length > METAFIELD_LIMITS.filter_keys) {
|
|
2649
|
+
errors.push(issue("filter_keys", "too_long", `must have at most ${METAFIELD_LIMITS.filter_keys} keys`));
|
|
2650
|
+
} else {
|
|
2651
|
+
rawFilters.forEach((key, index) => {
|
|
2652
|
+
const path = joinPath("filter_keys", index);
|
|
2653
|
+
const field = typeof key === "string" ? byKey.get(key) : void 0;
|
|
2654
|
+
if (!field) errors.push(issue(path, "invalid_format", "must name a field of this definition"));
|
|
2655
|
+
else if (!FILTERABLE_TYPES.includes(field.type)) {
|
|
2656
|
+
errors.push(issue(path, "not_allowed", "only single line text, true or false, integer and date fields can be filters"));
|
|
2657
|
+
} else if (filterKeys.includes(field.key)) errors.push(issue(path, "duplicate", `"${field.key}" is listed twice`));
|
|
2658
|
+
else filterKeys.push(field.key);
|
|
2659
|
+
});
|
|
2660
|
+
}
|
|
2661
|
+
const hasStatus = readBoolean(input.has_status, true, "has_status", errors);
|
|
2662
|
+
const storefront = readBoolean(input.storefront_access, false, "storefront_access", errors);
|
|
2663
|
+
const customer = input.customer_access ?? "none";
|
|
2664
|
+
if (customer !== "none" && customer !== "read") {
|
|
2665
|
+
errors.push(issue("customer_access", "not_allowed", "must be none or read"));
|
|
2666
|
+
}
|
|
2667
|
+
if (errors.length) return { ok: false, errors };
|
|
2668
|
+
return storable({
|
|
2669
|
+
type,
|
|
2670
|
+
name,
|
|
2671
|
+
description,
|
|
2672
|
+
fields,
|
|
2673
|
+
display_name_key: displayNameKey,
|
|
2674
|
+
filter_keys: filterKeys,
|
|
2675
|
+
has_status: hasStatus,
|
|
2676
|
+
storefront_access: storefront,
|
|
2677
|
+
customer_access: customer
|
|
2678
|
+
});
|
|
2679
|
+
}
|
|
2680
|
+
function validateMetaobjectEntry(fields, input, ctx) {
|
|
2681
|
+
if (!Array.isArray(fields)) return fail("", "invalid_type", "fields must be a list");
|
|
2682
|
+
if (!isPlainObject(input)) return fail("", "invalid_type", "must be an object of field values");
|
|
2683
|
+
const errors = unknownKeys(input, fields.map((field) => field.key), "");
|
|
2684
|
+
const out = {};
|
|
2685
|
+
for (const field of fields) {
|
|
2686
|
+
const raw = hasOwn(input, field.key) ? input[field.key] : void 0;
|
|
2687
|
+
if (isBlankValueFor(field.type, raw)) {
|
|
2688
|
+
if (field.required) errors.push(issue(field.key, "required", "is required"));
|
|
2689
|
+
continue;
|
|
2690
|
+
}
|
|
2691
|
+
const result = validateMetafieldValue(field.type, field.validations, raw, ctx, field.key);
|
|
2692
|
+
if (result.ok) {
|
|
2693
|
+
Object.defineProperty(out, field.key, { value: result.value, enumerable: true, writable: true, configurable: true });
|
|
2694
|
+
} else errors.push(...result.errors);
|
|
2695
|
+
}
|
|
2696
|
+
if (!errors.length && byteLength(JSON.stringify(out)) > METAFIELD_LIMITS.value_bytes) {
|
|
2697
|
+
return fail("", "too_large", `must be at most ${METAFIELD_LIMITS.value_bytes} bytes`);
|
|
2698
|
+
}
|
|
2699
|
+
return errors.length ? { ok: false, errors } : ok(out);
|
|
2700
|
+
}
|
|
2701
|
+
function entryDisplayName(definition, fields, handle) {
|
|
2702
|
+
const value = definition.display_name_key ? fields[definition.display_name_key] : void 0;
|
|
2703
|
+
return typeof value === "string" && value.trim() ? [...value.trim()].slice(0, METAFIELD_LIMITS.name_length).join("") : handle;
|
|
2704
|
+
}
|
|
2705
|
+
function checkMetaobjectFieldChanges(before, after) {
|
|
2706
|
+
const prior = new Map(before.map((field) => [field.key, field]));
|
|
2707
|
+
const errors = after.flatMap((field, index) => {
|
|
2708
|
+
const old = prior.get(field.key);
|
|
2709
|
+
return old && old.type !== field.type ? [issue(joinPath(joinPath("fields", index), "type"), "immutable", `cannot change the type of "${field.key}"`)] : [];
|
|
2710
|
+
});
|
|
2711
|
+
if (errors.length) return { ok: false, errors };
|
|
2712
|
+
const kept = new Set(after.map((field) => field.key));
|
|
2713
|
+
return ok({
|
|
2714
|
+
removed: before.filter((field) => !kept.has(field.key)).map((field) => field.key),
|
|
2715
|
+
added: after.filter((field) => !prior.has(field.key)).map((field) => field.key)
|
|
2716
|
+
});
|
|
2717
|
+
}
|
|
2718
|
+
|
|
1689
2719
|
// src/modules/storage/image-transform.ts
|
|
1690
2720
|
var OBJECT_PREFIX = "/storage/v1/object/public/";
|
|
1691
2721
|
var RENDER_PREFIX = "/storage/v1/render/image/public/";
|
|
@@ -2095,6 +3125,42 @@ var ThemesApi = class {
|
|
|
2095
3125
|
}
|
|
2096
3126
|
};
|
|
2097
3127
|
|
|
3128
|
+
// src/modules/metaobjects/api.ts
|
|
3129
|
+
var EMPTY = { items: [], next_cursor: null };
|
|
3130
|
+
var MetaobjectsApi = class {
|
|
3131
|
+
constructor(publicHttp, authHttp) {
|
|
3132
|
+
this.publicHttp = publicHttp;
|
|
3133
|
+
this.authHttp = authHttp;
|
|
3134
|
+
}
|
|
3135
|
+
/**
|
|
3136
|
+
* Active entries of a metaobject type. A type that is unknown or hidden
|
|
3137
|
+
* from this reader lists as empty: the API answers 404 for both, the same
|
|
3138
|
+
* as a missing type, so it never reveals which types exist.
|
|
3139
|
+
*/
|
|
3140
|
+
async list(storeRef, type, params = {}) {
|
|
3141
|
+
const query = new URLSearchParams();
|
|
3142
|
+
for (const [key, value] of Object.entries(params.filter ?? {})) {
|
|
3143
|
+
query.append(`filter[${key}]`, String(value));
|
|
3144
|
+
}
|
|
3145
|
+
if (params.cursor) query.set("cursor", params.cursor);
|
|
3146
|
+
if (params.limit !== void 0) query.set("limit", String(params.limit));
|
|
3147
|
+
const search = query.toString();
|
|
3148
|
+
const http = params.as_customer ? this.authHttp : this.publicHttp;
|
|
3149
|
+
const res = await http.get(
|
|
3150
|
+
`/public/stores/${storeRef}/metaobjects/${encodeURIComponent(type)}${search ? `?${search}` : ""}`
|
|
3151
|
+
);
|
|
3152
|
+
return unwrapOrNull(res, [404]) ?? EMPTY;
|
|
3153
|
+
}
|
|
3154
|
+
/** One active entry by handle; null when it, or its type, is missing or hidden. */
|
|
3155
|
+
async get(storeRef, type, handle, options = {}) {
|
|
3156
|
+
const http = options.as_customer ? this.authHttp : this.publicHttp;
|
|
3157
|
+
const res = await http.get(
|
|
3158
|
+
`/public/stores/${storeRef}/metaobjects/${encodeURIComponent(type)}/${encodeURIComponent(handle)}`
|
|
3159
|
+
);
|
|
3160
|
+
return unwrapOrNull(res, [404]);
|
|
3161
|
+
}
|
|
3162
|
+
};
|
|
3163
|
+
|
|
2098
3164
|
// src/modules/search/api.ts
|
|
2099
3165
|
var SearchApi = class {
|
|
2100
3166
|
constructor(http) {
|
|
@@ -2286,6 +3352,24 @@ var CustomersApi = class {
|
|
|
2286
3352
|
payload
|
|
2287
3353
|
);
|
|
2288
3354
|
}
|
|
3355
|
+
/** The signed-in customer's metafields with customer access (spec §6.6). */
|
|
3356
|
+
async getMetafields(storeRef) {
|
|
3357
|
+
const res = await this.http.get(
|
|
3358
|
+
`/tenant/stores/${storeRef}/customers/metafields`
|
|
3359
|
+
);
|
|
3360
|
+
return unwrap(res);
|
|
3361
|
+
}
|
|
3362
|
+
/**
|
|
3363
|
+
* Writes read_write metafields; `value: null` clears one. Throws
|
|
3364
|
+
* METAFIELD_VALUE_INVALID (details.errors[] by path) or METAFIELD_NOT_WRITABLE.
|
|
3365
|
+
*/
|
|
3366
|
+
async updateMetafields(storeRef, values) {
|
|
3367
|
+
const res = await this.http.put(
|
|
3368
|
+
`/tenant/stores/${storeRef}/customers/metafields`,
|
|
3369
|
+
{ values }
|
|
3370
|
+
);
|
|
3371
|
+
return unwrap(res);
|
|
3372
|
+
}
|
|
2289
3373
|
};
|
|
2290
3374
|
|
|
2291
3375
|
// src/modules/addresses/api.ts
|
|
@@ -2741,6 +3825,7 @@ function createEcomwebSdk(options) {
|
|
|
2741
3825
|
blog: new BlogApi(publicHttp, authHttp),
|
|
2742
3826
|
stores: new StoresApi(publicHttp),
|
|
2743
3827
|
themes: new ThemesApi(publicHttp),
|
|
3828
|
+
metaobjects: new MetaobjectsApi(publicHttp, authHttp),
|
|
2744
3829
|
search: new SearchApi(publicHttp),
|
|
2745
3830
|
banners: new BannersApi(publicHttp),
|
|
2746
3831
|
shipping: new ShippingApi(publicHttp),
|
|
@@ -2779,6 +3864,8 @@ export {
|
|
|
2779
3864
|
DiscountMethodSchema,
|
|
2780
3865
|
EMAIL_COLOR_PATTERN,
|
|
2781
3866
|
EMAIL_PALETTE_DEFAULTS,
|
|
3867
|
+
ENTRY_HANDLE_PATTERN,
|
|
3868
|
+
FILTERABLE_TYPES,
|
|
2782
3869
|
INVENTORY_ADJUSTMENT_REASONS,
|
|
2783
3870
|
INVENTORY_ERROR_CODES,
|
|
2784
3871
|
INVENTORY_POLICIES,
|
|
@@ -2791,15 +3878,26 @@ export {
|
|
|
2791
3878
|
LEVEL_WARD,
|
|
2792
3879
|
MAX_RULES_PER_SET,
|
|
2793
3880
|
MAX_RULE_VALUE_ENTRIES,
|
|
3881
|
+
MEASUREMENT_UNITS,
|
|
3882
|
+
MEDIA_TYPES,
|
|
2794
3883
|
MERCHANT_ADJUSTMENT_REASONS,
|
|
3884
|
+
METAFIELD_BASE_TYPES,
|
|
3885
|
+
METAFIELD_KEY_PATTERN,
|
|
3886
|
+
METAFIELD_LIMITS,
|
|
3887
|
+
METAFIELD_OWNER_TYPES,
|
|
3888
|
+
METAFIELD_TYPE_GROUPS,
|
|
3889
|
+
METAOBJECT_REFERENCE_TYPES,
|
|
3890
|
+
METAOBJECT_TYPE_PATTERN,
|
|
2795
3891
|
MemoryTokenStorage,
|
|
2796
3892
|
MenusApi,
|
|
3893
|
+
MetaobjectsApi,
|
|
2797
3894
|
OBJECT_PREFIX,
|
|
2798
3895
|
ORDER_ACTOR_TYPES,
|
|
2799
3896
|
ORDER_EVENT_TYPES,
|
|
2800
3897
|
ORDER_SOURCES,
|
|
2801
3898
|
OrdersApi,
|
|
2802
3899
|
PAGINATION_DEFAULTS,
|
|
3900
|
+
PRIVATE_REFERENCE_TYPES,
|
|
2803
3901
|
PRODUCT_STATUS_LABELS,
|
|
2804
3902
|
PROMOTION_MODE_COLORS,
|
|
2805
3903
|
PROMOTION_MODE_LABELS,
|
|
@@ -2824,10 +3922,10 @@ export {
|
|
|
2824
3922
|
PromotionWithDiscountSchema,
|
|
2825
3923
|
PromotionsApi,
|
|
2826
3924
|
RENDER_PREFIX,
|
|
3925
|
+
RESOURCE_REFERENCE_TYPES,
|
|
2827
3926
|
RULE_FIELDS,
|
|
2828
3927
|
RedirectsApi,
|
|
2829
3928
|
ReviewsApi,
|
|
2830
|
-
SECTION_CONFIG_SCHEMAS,
|
|
2831
3929
|
SHIPPING_CONDITION_TYPES,
|
|
2832
3930
|
SHIPPING_DELIVERY_TYPES,
|
|
2833
3931
|
SHIPPING_RATE_TYPES,
|
|
@@ -2838,7 +3936,9 @@ export {
|
|
|
2838
3936
|
ThemesApi,
|
|
2839
3937
|
UNAVAILABLE_STATES,
|
|
2840
3938
|
UpdatePromotionSchema,
|
|
2841
|
-
|
|
3939
|
+
VALIDATION_KEYS,
|
|
3940
|
+
allowedCustomerAccess,
|
|
3941
|
+
allowedFileKinds,
|
|
2842
3942
|
allowedValuesFor,
|
|
2843
3943
|
appliedPromotionSchema,
|
|
2844
3944
|
assetBaseUrl,
|
|
@@ -2848,6 +3948,7 @@ export {
|
|
|
2848
3948
|
baseDeleteOptionsSchema,
|
|
2849
3949
|
baseDeleteResultSchema,
|
|
2850
3950
|
baseQueryParamsSchema,
|
|
3951
|
+
baseTypeOf,
|
|
2851
3952
|
blogCategorySchema,
|
|
2852
3953
|
blogCommentSchema,
|
|
2853
3954
|
blogCommentWithRepliesSchema,
|
|
@@ -2859,14 +3960,12 @@ export {
|
|
|
2859
3960
|
blogSettingsSchema,
|
|
2860
3961
|
blogTagSchema,
|
|
2861
3962
|
buildTransformQuery,
|
|
2862
|
-
builderSectionSchema,
|
|
2863
|
-
builderThemeConfigSchema,
|
|
2864
|
-
categoryGridConfigSchema,
|
|
2865
3963
|
categorySchema,
|
|
2866
3964
|
categoryTreeSchema,
|
|
2867
3965
|
categoryWithChildrenSchema,
|
|
2868
|
-
|
|
3966
|
+
checkMetaobjectFieldChanges,
|
|
2869
3967
|
colorSchema,
|
|
3968
|
+
compareDecimal,
|
|
2870
3969
|
contentPageSchema,
|
|
2871
3970
|
createAuthAwareHttpClient,
|
|
2872
3971
|
createBannerSchema,
|
|
@@ -2900,27 +3999,35 @@ export {
|
|
|
2900
3999
|
embeddedScriptPlacementSchema,
|
|
2901
4000
|
embeddedScriptSchema,
|
|
2902
4001
|
ensureSuccess,
|
|
2903
|
-
|
|
2904
|
-
footerConfigSchema,
|
|
4002
|
+
entryDisplayName,
|
|
2905
4003
|
fromObjectPublicUrlToRender,
|
|
2906
4004
|
fulfillmentStatusSchema,
|
|
2907
|
-
headerConfigSchema,
|
|
2908
|
-
heroBannerConfigSchema,
|
|
2909
|
-
heroBannerItemSchema,
|
|
2910
4005
|
idSchema,
|
|
2911
4006
|
integrationStatusSchema,
|
|
2912
4007
|
inventoryStatusSchema,
|
|
4008
|
+
isBlankValue,
|
|
4009
|
+
isBlankValueFor,
|
|
2913
4010
|
isEditableStatus,
|
|
4011
|
+
isListType,
|
|
4012
|
+
isMetafieldType,
|
|
2914
4013
|
isPublishableStatus,
|
|
2915
4014
|
isRuleField,
|
|
4015
|
+
isSafeRegex,
|
|
2916
4016
|
isSettingVisible,
|
|
2917
4017
|
isUnpublishedStatus,
|
|
4018
|
+
isValidEntryHandle,
|
|
2918
4019
|
jsonSchema,
|
|
2919
4020
|
legacyOrderStatusSchema,
|
|
2920
4021
|
legacyProductStatusSchema,
|
|
4022
|
+
legalLinksSchema,
|
|
4023
|
+
measurementInBaseUnit,
|
|
2921
4024
|
messageOutboxStatusSchema,
|
|
4025
|
+
metafieldIdentifier,
|
|
2922
4026
|
moneySchema,
|
|
2923
|
-
|
|
4027
|
+
normalizeDate,
|
|
4028
|
+
normalizeDateTime,
|
|
4029
|
+
normalizeDecimal,
|
|
4030
|
+
normalizeId,
|
|
2924
4031
|
onHand,
|
|
2925
4032
|
operatorsForField,
|
|
2926
4033
|
optionalTimestampSchema,
|
|
@@ -2932,7 +4039,7 @@ export {
|
|
|
2932
4039
|
paginatedResponseSchema,
|
|
2933
4040
|
paginationMetaSchema,
|
|
2934
4041
|
paginationSchema,
|
|
2935
|
-
|
|
4042
|
+
parseMetafieldIdentifier,
|
|
2936
4043
|
parseStorageUrl,
|
|
2937
4044
|
parseThemeSchema,
|
|
2938
4045
|
paymentMethodSchema,
|
|
@@ -2958,12 +4065,9 @@ export {
|
|
|
2958
4065
|
resolveThemeSettings,
|
|
2959
4066
|
reviewStatusSchema,
|
|
2960
4067
|
rewriteSupabaseUrl,
|
|
2961
|
-
|
|
4068
|
+
richTextLength,
|
|
2962
4069
|
safeParseBaseQueryParams,
|
|
2963
4070
|
safeParsePaginationMeta,
|
|
2964
|
-
sectionConfigSchema,
|
|
2965
|
-
sectionStyleSchema,
|
|
2966
|
-
sectionTypeSchema,
|
|
2967
4071
|
shippingStatusSchema,
|
|
2968
4072
|
slugSchema,
|
|
2969
4073
|
sortOrderSchema,
|
|
@@ -2973,14 +4077,14 @@ export {
|
|
|
2973
4077
|
storeSettingsSchema,
|
|
2974
4078
|
storeStatusSchema,
|
|
2975
4079
|
storeWithRelationsSchema,
|
|
4080
|
+
storefrontAccessAllowed,
|
|
2976
4081
|
strictUrlSchema,
|
|
2977
|
-
textWithImageConfigSchema,
|
|
2978
|
-
themeConfigSchema,
|
|
2979
4082
|
themeDefaults,
|
|
2980
4083
|
themeSchemaSchema,
|
|
2981
4084
|
themeSettings,
|
|
2982
|
-
themeVersionSchema,
|
|
2983
4085
|
timestampSchema,
|
|
4086
|
+
toEntryHandle,
|
|
4087
|
+
toMetafieldKey,
|
|
2984
4088
|
toObjectUrl,
|
|
2985
4089
|
toRenderUrl,
|
|
2986
4090
|
tocItemSchema,
|
|
@@ -3011,8 +4115,14 @@ export {
|
|
|
3011
4115
|
updateVariantOptionValueSchema,
|
|
3012
4116
|
urlSchema,
|
|
3013
4117
|
uuidSchema,
|
|
4118
|
+
validateMetafieldDefinition,
|
|
4119
|
+
validateMetafieldValue,
|
|
4120
|
+
validateMetaobjectDefinition,
|
|
4121
|
+
validateMetaobjectEntry,
|
|
3014
4122
|
validatePaginationMeta,
|
|
4123
|
+
validateRichText,
|
|
3015
4124
|
validateThemeValues,
|
|
4125
|
+
validateValidations,
|
|
3016
4126
|
valueKindFor,
|
|
3017
4127
|
variantOptionSchema,
|
|
3018
4128
|
variantOptionValueSchema,
|