@meerkapp/wms-contracts 0.3.0-beta.2 → 0.3.0-beta.3

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 CHANGED
@@ -22245,6 +22245,42 @@ declare const CharacteristicSchema: z$1.ZodDiscriminatedUnion<"type", [z$1.ZodOb
22245
22245
  key: string;
22246
22246
  label: string;
22247
22247
  required?: boolean | undefined;
22248
+ }>, z$1.ZodObject<{
22249
+ key: z$1.ZodString;
22250
+ label: z$1.ZodString;
22251
+ type: z$1.ZodLiteral<"toggle">;
22252
+ required: z$1.ZodDefault<z$1.ZodBoolean>;
22253
+ true_label: z$1.ZodString;
22254
+ false_label: z$1.ZodString;
22255
+ }, "strip", z$1.ZodTypeAny, {
22256
+ type: "toggle";
22257
+ key: string;
22258
+ label: string;
22259
+ required: boolean;
22260
+ true_label: string;
22261
+ false_label: string;
22262
+ }, {
22263
+ type: "toggle";
22264
+ key: string;
22265
+ label: string;
22266
+ true_label: string;
22267
+ false_label: string;
22268
+ required?: boolean | undefined;
22269
+ }>, z$1.ZodObject<{
22270
+ key: z$1.ZodString;
22271
+ label: z$1.ZodString;
22272
+ type: z$1.ZodLiteral<"checkbox">;
22273
+ required: z$1.ZodDefault<z$1.ZodBoolean>;
22274
+ }, "strip", z$1.ZodTypeAny, {
22275
+ type: "checkbox";
22276
+ key: string;
22277
+ label: string;
22278
+ required: boolean;
22279
+ }, {
22280
+ type: "checkbox";
22281
+ key: string;
22282
+ label: string;
22283
+ required?: boolean | undefined;
22248
22284
  }>]>;
22249
22285
  declare const CharacteristicsSchemeSchema: z$1.ZodArray<z$1.ZodDiscriminatedUnion<"type", [z$1.ZodObject<{
22250
22286
  key: z$1.ZodString;
@@ -22325,6 +22361,42 @@ declare const CharacteristicsSchemeSchema: z$1.ZodArray<z$1.ZodDiscriminatedUnio
22325
22361
  key: string;
22326
22362
  label: string;
22327
22363
  required?: boolean | undefined;
22364
+ }>, z$1.ZodObject<{
22365
+ key: z$1.ZodString;
22366
+ label: z$1.ZodString;
22367
+ type: z$1.ZodLiteral<"toggle">;
22368
+ required: z$1.ZodDefault<z$1.ZodBoolean>;
22369
+ true_label: z$1.ZodString;
22370
+ false_label: z$1.ZodString;
22371
+ }, "strip", z$1.ZodTypeAny, {
22372
+ type: "toggle";
22373
+ key: string;
22374
+ label: string;
22375
+ required: boolean;
22376
+ true_label: string;
22377
+ false_label: string;
22378
+ }, {
22379
+ type: "toggle";
22380
+ key: string;
22381
+ label: string;
22382
+ true_label: string;
22383
+ false_label: string;
22384
+ required?: boolean | undefined;
22385
+ }>, z$1.ZodObject<{
22386
+ key: z$1.ZodString;
22387
+ label: z$1.ZodString;
22388
+ type: z$1.ZodLiteral<"checkbox">;
22389
+ required: z$1.ZodDefault<z$1.ZodBoolean>;
22390
+ }, "strip", z$1.ZodTypeAny, {
22391
+ type: "checkbox";
22392
+ key: string;
22393
+ label: string;
22394
+ required: boolean;
22395
+ }, {
22396
+ type: "checkbox";
22397
+ key: string;
22398
+ label: string;
22399
+ required?: boolean | undefined;
22328
22400
  }>]>, "many">;
22329
22401
  type Characteristic = z$1.infer<typeof CharacteristicSchema>;
22330
22402
  type CharacteristicsScheme = z$1.infer<typeof CharacteristicsSchemeSchema>;
@@ -22412,6 +22484,42 @@ declare const CreateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22412
22484
  key: string;
22413
22485
  label: string;
22414
22486
  required?: boolean | undefined;
22487
+ }>, z$1.ZodObject<{
22488
+ key: z$1.ZodString;
22489
+ label: z$1.ZodString;
22490
+ type: z$1.ZodLiteral<"toggle">;
22491
+ required: z$1.ZodDefault<z$1.ZodBoolean>;
22492
+ true_label: z$1.ZodString;
22493
+ false_label: z$1.ZodString;
22494
+ }, "strip", z$1.ZodTypeAny, {
22495
+ type: "toggle";
22496
+ key: string;
22497
+ label: string;
22498
+ required: boolean;
22499
+ true_label: string;
22500
+ false_label: string;
22501
+ }, {
22502
+ type: "toggle";
22503
+ key: string;
22504
+ label: string;
22505
+ true_label: string;
22506
+ false_label: string;
22507
+ required?: boolean | undefined;
22508
+ }>, z$1.ZodObject<{
22509
+ key: z$1.ZodString;
22510
+ label: z$1.ZodString;
22511
+ type: z$1.ZodLiteral<"checkbox">;
22512
+ required: z$1.ZodDefault<z$1.ZodBoolean>;
22513
+ }, "strip", z$1.ZodTypeAny, {
22514
+ type: "checkbox";
22515
+ key: string;
22516
+ label: string;
22517
+ required: boolean;
22518
+ }, {
22519
+ type: "checkbox";
22520
+ key: string;
22521
+ label: string;
22522
+ required?: boolean | undefined;
22415
22523
  }>]>, "many">>>;
22416
22524
  }, "strip", z$1.ZodTypeAny, {
22417
22525
  name: string;
@@ -22439,6 +22547,18 @@ declare const CreateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22439
22547
  key: string;
22440
22548
  label: string;
22441
22549
  required: boolean;
22550
+ } | {
22551
+ type: "toggle";
22552
+ key: string;
22553
+ label: string;
22554
+ required: boolean;
22555
+ true_label: string;
22556
+ false_label: string;
22557
+ } | {
22558
+ type: "checkbox";
22559
+ key: string;
22560
+ label: string;
22561
+ required: boolean;
22442
22562
  })[] | null | undefined;
22443
22563
  }, {
22444
22564
  name: string;
@@ -22466,6 +22586,18 @@ declare const CreateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22466
22586
  key: string;
22467
22587
  label: string;
22468
22588
  required?: boolean | undefined;
22589
+ } | {
22590
+ type: "toggle";
22591
+ key: string;
22592
+ label: string;
22593
+ true_label: string;
22594
+ false_label: string;
22595
+ required?: boolean | undefined;
22596
+ } | {
22597
+ type: "checkbox";
22598
+ key: string;
22599
+ label: string;
22600
+ required?: boolean | undefined;
22469
22601
  })[] | null | undefined;
22470
22602
  }>, {
22471
22603
  name: string;
@@ -22493,6 +22625,18 @@ declare const CreateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22493
22625
  key: string;
22494
22626
  label: string;
22495
22627
  required: boolean;
22628
+ } | {
22629
+ type: "toggle";
22630
+ key: string;
22631
+ label: string;
22632
+ required: boolean;
22633
+ true_label: string;
22634
+ false_label: string;
22635
+ } | {
22636
+ type: "checkbox";
22637
+ key: string;
22638
+ label: string;
22639
+ required: boolean;
22496
22640
  })[] | null | undefined;
22497
22641
  }, {
22498
22642
  name: string;
@@ -22520,6 +22664,18 @@ declare const CreateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22520
22664
  key: string;
22521
22665
  label: string;
22522
22666
  required?: boolean | undefined;
22667
+ } | {
22668
+ type: "toggle";
22669
+ key: string;
22670
+ label: string;
22671
+ true_label: string;
22672
+ false_label: string;
22673
+ required?: boolean | undefined;
22674
+ } | {
22675
+ type: "checkbox";
22676
+ key: string;
22677
+ label: string;
22678
+ required?: boolean | undefined;
22523
22679
  })[] | null | undefined;
22524
22680
  }>, {
22525
22681
  name: string;
@@ -22547,6 +22703,18 @@ declare const CreateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22547
22703
  key: string;
22548
22704
  label: string;
22549
22705
  required: boolean;
22706
+ } | {
22707
+ type: "toggle";
22708
+ key: string;
22709
+ label: string;
22710
+ required: boolean;
22711
+ true_label: string;
22712
+ false_label: string;
22713
+ } | {
22714
+ type: "checkbox";
22715
+ key: string;
22716
+ label: string;
22717
+ required: boolean;
22550
22718
  })[] | null | undefined;
22551
22719
  }, {
22552
22720
  name: string;
@@ -22574,6 +22742,18 @@ declare const CreateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22574
22742
  key: string;
22575
22743
  label: string;
22576
22744
  required?: boolean | undefined;
22745
+ } | {
22746
+ type: "toggle";
22747
+ key: string;
22748
+ label: string;
22749
+ true_label: string;
22750
+ false_label: string;
22751
+ required?: boolean | undefined;
22752
+ } | {
22753
+ type: "checkbox";
22754
+ key: string;
22755
+ label: string;
22756
+ required?: boolean | undefined;
22577
22757
  })[] | null | undefined;
22578
22758
  }>;
22579
22759
  declare const UpdateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObject<{
@@ -22660,6 +22840,42 @@ declare const UpdateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22660
22840
  key: string;
22661
22841
  label: string;
22662
22842
  required?: boolean | undefined;
22843
+ }>, z$1.ZodObject<{
22844
+ key: z$1.ZodString;
22845
+ label: z$1.ZodString;
22846
+ type: z$1.ZodLiteral<"toggle">;
22847
+ required: z$1.ZodDefault<z$1.ZodBoolean>;
22848
+ true_label: z$1.ZodString;
22849
+ false_label: z$1.ZodString;
22850
+ }, "strip", z$1.ZodTypeAny, {
22851
+ type: "toggle";
22852
+ key: string;
22853
+ label: string;
22854
+ required: boolean;
22855
+ true_label: string;
22856
+ false_label: string;
22857
+ }, {
22858
+ type: "toggle";
22859
+ key: string;
22860
+ label: string;
22861
+ true_label: string;
22862
+ false_label: string;
22863
+ required?: boolean | undefined;
22864
+ }>, z$1.ZodObject<{
22865
+ key: z$1.ZodString;
22866
+ label: z$1.ZodString;
22867
+ type: z$1.ZodLiteral<"checkbox">;
22868
+ required: z$1.ZodDefault<z$1.ZodBoolean>;
22869
+ }, "strip", z$1.ZodTypeAny, {
22870
+ type: "checkbox";
22871
+ key: string;
22872
+ label: string;
22873
+ required: boolean;
22874
+ }, {
22875
+ type: "checkbox";
22876
+ key: string;
22877
+ label: string;
22878
+ required?: boolean | undefined;
22663
22879
  }>]>, "many">>>>;
22664
22880
  }, "strip", z$1.ZodTypeAny, {
22665
22881
  name?: string | undefined;
@@ -22687,6 +22903,18 @@ declare const UpdateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22687
22903
  key: string;
22688
22904
  label: string;
22689
22905
  required: boolean;
22906
+ } | {
22907
+ type: "toggle";
22908
+ key: string;
22909
+ label: string;
22910
+ required: boolean;
22911
+ true_label: string;
22912
+ false_label: string;
22913
+ } | {
22914
+ type: "checkbox";
22915
+ key: string;
22916
+ label: string;
22917
+ required: boolean;
22690
22918
  })[] | null | undefined;
22691
22919
  }, {
22692
22920
  name?: string | undefined;
@@ -22714,6 +22942,18 @@ declare const UpdateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22714
22942
  key: string;
22715
22943
  label: string;
22716
22944
  required?: boolean | undefined;
22945
+ } | {
22946
+ type: "toggle";
22947
+ key: string;
22948
+ label: string;
22949
+ true_label: string;
22950
+ false_label: string;
22951
+ required?: boolean | undefined;
22952
+ } | {
22953
+ type: "checkbox";
22954
+ key: string;
22955
+ label: string;
22956
+ required?: boolean | undefined;
22717
22957
  })[] | null | undefined;
22718
22958
  }>, {
22719
22959
  name?: string | undefined;
@@ -22741,6 +22981,18 @@ declare const UpdateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22741
22981
  key: string;
22742
22982
  label: string;
22743
22983
  required: boolean;
22984
+ } | {
22985
+ type: "toggle";
22986
+ key: string;
22987
+ label: string;
22988
+ required: boolean;
22989
+ true_label: string;
22990
+ false_label: string;
22991
+ } | {
22992
+ type: "checkbox";
22993
+ key: string;
22994
+ label: string;
22995
+ required: boolean;
22744
22996
  })[] | null | undefined;
22745
22997
  }, {
22746
22998
  name?: string | undefined;
@@ -22768,6 +23020,18 @@ declare const UpdateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22768
23020
  key: string;
22769
23021
  label: string;
22770
23022
  required?: boolean | undefined;
23023
+ } | {
23024
+ type: "toggle";
23025
+ key: string;
23026
+ label: string;
23027
+ true_label: string;
23028
+ false_label: string;
23029
+ required?: boolean | undefined;
23030
+ } | {
23031
+ type: "checkbox";
23032
+ key: string;
23033
+ label: string;
23034
+ required?: boolean | undefined;
22771
23035
  })[] | null | undefined;
22772
23036
  }>, {
22773
23037
  name?: string | undefined;
@@ -22795,6 +23059,18 @@ declare const UpdateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22795
23059
  key: string;
22796
23060
  label: string;
22797
23061
  required: boolean;
23062
+ } | {
23063
+ type: "toggle";
23064
+ key: string;
23065
+ label: string;
23066
+ required: boolean;
23067
+ true_label: string;
23068
+ false_label: string;
23069
+ } | {
23070
+ type: "checkbox";
23071
+ key: string;
23072
+ label: string;
23073
+ required: boolean;
22798
23074
  })[] | null | undefined;
22799
23075
  }, {
22800
23076
  name?: string | undefined;
@@ -22822,6 +23098,18 @@ declare const UpdateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22822
23098
  key: string;
22823
23099
  label: string;
22824
23100
  required?: boolean | undefined;
23101
+ } | {
23102
+ type: "toggle";
23103
+ key: string;
23104
+ label: string;
23105
+ true_label: string;
23106
+ false_label: string;
23107
+ required?: boolean | undefined;
23108
+ } | {
23109
+ type: "checkbox";
23110
+ key: string;
23111
+ label: string;
23112
+ required?: boolean | undefined;
22825
23113
  })[] | null | undefined;
22826
23114
  }>;
22827
23115
  declare const ProductTypeSchema: z$1.ZodObject<{
@@ -22910,6 +23198,42 @@ declare const ProductTypeSchema: z$1.ZodObject<{
22910
23198
  key: string;
22911
23199
  label: string;
22912
23200
  required?: boolean | undefined;
23201
+ }>, z$1.ZodObject<{
23202
+ key: z$1.ZodString;
23203
+ label: z$1.ZodString;
23204
+ type: z$1.ZodLiteral<"toggle">;
23205
+ required: z$1.ZodDefault<z$1.ZodBoolean>;
23206
+ true_label: z$1.ZodString;
23207
+ false_label: z$1.ZodString;
23208
+ }, "strip", z$1.ZodTypeAny, {
23209
+ type: "toggle";
23210
+ key: string;
23211
+ label: string;
23212
+ required: boolean;
23213
+ true_label: string;
23214
+ false_label: string;
23215
+ }, {
23216
+ type: "toggle";
23217
+ key: string;
23218
+ label: string;
23219
+ true_label: string;
23220
+ false_label: string;
23221
+ required?: boolean | undefined;
23222
+ }>, z$1.ZodObject<{
23223
+ key: z$1.ZodString;
23224
+ label: z$1.ZodString;
23225
+ type: z$1.ZodLiteral<"checkbox">;
23226
+ required: z$1.ZodDefault<z$1.ZodBoolean>;
23227
+ }, "strip", z$1.ZodTypeAny, {
23228
+ type: "checkbox";
23229
+ key: string;
23230
+ label: string;
23231
+ required: boolean;
23232
+ }, {
23233
+ type: "checkbox";
23234
+ key: string;
23235
+ label: string;
23236
+ required?: boolean | undefined;
22913
23237
  }>]>, "many">>;
22914
23238
  updatedAt: z$1.ZodString;
22915
23239
  }, "strip", z$1.ZodTypeAny, {
@@ -22940,6 +23264,18 @@ declare const ProductTypeSchema: z$1.ZodObject<{
22940
23264
  key: string;
22941
23265
  label: string;
22942
23266
  required: boolean;
23267
+ } | {
23268
+ type: "toggle";
23269
+ key: string;
23270
+ label: string;
23271
+ required: boolean;
23272
+ true_label: string;
23273
+ false_label: string;
23274
+ } | {
23275
+ type: "checkbox";
23276
+ key: string;
23277
+ label: string;
23278
+ required: boolean;
22943
23279
  })[] | null;
22944
23280
  skuCounter: number;
22945
23281
  }, {
@@ -22970,6 +23306,18 @@ declare const ProductTypeSchema: z$1.ZodObject<{
22970
23306
  key: string;
22971
23307
  label: string;
22972
23308
  required?: boolean | undefined;
23309
+ } | {
23310
+ type: "toggle";
23311
+ key: string;
23312
+ label: string;
23313
+ true_label: string;
23314
+ false_label: string;
23315
+ required?: boolean | undefined;
23316
+ } | {
23317
+ type: "checkbox";
23318
+ key: string;
23319
+ label: string;
23320
+ required?: boolean | undefined;
22973
23321
  })[] | null;
22974
23322
  skuCounter: number;
22975
23323
  }>;
package/dist/index.js CHANGED
@@ -10496,20 +10496,37 @@ var SelectCharacteristicSchema = z882.object({
10496
10496
  required: z882.boolean().default(false),
10497
10497
  options: z882.array(SelectOptionSchema).min(1)
10498
10498
  });
10499
+ var ToggleCharacteristicSchema = z882.object({
10500
+ key: z882.string().min(1),
10501
+ label: z882.string().min(1),
10502
+ type: z882.literal("toggle"),
10503
+ required: z882.boolean().default(false),
10504
+ true_label: z882.string().min(1),
10505
+ false_label: z882.string().min(1)
10506
+ });
10507
+ var CheckboxCharacteristicSchema = z882.object({
10508
+ key: z882.string().min(1),
10509
+ label: z882.string().min(1),
10510
+ type: z882.literal("checkbox"),
10511
+ required: z882.boolean().default(false)
10512
+ });
10499
10513
  var CharacteristicSchema = z882.discriminatedUnion("type", [
10500
10514
  NumberCharacteristicSchema,
10501
- SelectCharacteristicSchema
10515
+ SelectCharacteristicSchema,
10516
+ ToggleCharacteristicSchema,
10517
+ CheckboxCharacteristicSchema
10502
10518
  ]);
10503
10519
  var CharacteristicsSchemeSchema = z882.array(CharacteristicSchema);
10504
10520
  var SKU_TEMPLATE_REGEX = /^(\{(brand|counter)(?::\d+)?\}|\{[a-z_]+(?::\d+)?\}|[^{}]+)+$/;
10505
10521
  var RESERVED_SKU_KEYS = /* @__PURE__ */ new Set(["brand", "counter"]);
10522
+ var SKU_COMPATIBLE_TYPES = /* @__PURE__ */ new Set(["number", "select", "toggle"]);
10506
10523
  function validateSkuTemplate(data) {
10507
10524
  if (data.skuMode !== "CUSTOM" || !data.skuTemplate || !data.characteristicsScheme) return true;
10508
- const requiredKeys = new Set(
10509
- data.characteristicsScheme.filter((c) => c.required).map((c) => c.key)
10525
+ const skuCompatibleKeys = new Set(
10526
+ data.characteristicsScheme.filter((c) => c.required && SKU_COMPATIBLE_TYPES.has(c.type)).map((c) => c.key)
10510
10527
  );
10511
10528
  const templateKeys = [...data.skuTemplate.matchAll(/\{([a-z_]+)(?::\d+)?\}/g)].map(([, key]) => key).filter((key) => !RESERVED_SKU_KEYS.has(key));
10512
- return templateKeys.every((key) => requiredKeys.has(key));
10529
+ return templateKeys.every((key) => skuCompatibleKeys.has(key));
10513
10530
  }
10514
10531
  var ProductTypeBaseSchema = z882.object({
10515
10532
  name: z882.string().min(1),
@@ -10522,14 +10539,14 @@ var CreateProductTypeSchema = ProductTypeBaseSchema.refine(
10522
10539
  (data) => !(data.skuMode === "CUSTOM" && !data.skuTemplate),
10523
10540
  { message: "skuTemplate is required for CUSTOM sku mode", path: ["skuTemplate"] }
10524
10541
  ).refine(validateSkuTemplate, {
10525
- message: "All characteristic keys in skuTemplate must be required characteristics",
10542
+ message: "All keys in skuTemplate must be required characteristics of type number, select or toggle",
10526
10543
  path: ["skuTemplate"]
10527
10544
  });
10528
10545
  var UpdateProductTypeSchema = ProductTypeBaseSchema.partial().refine(
10529
10546
  (data) => !(data.skuMode === "CUSTOM" && data.skuTemplate === null),
10530
10547
  { message: "skuTemplate cannot be null for CUSTOM sku mode", path: ["skuTemplate"] }
10531
10548
  ).refine(validateSkuTemplate, {
10532
- message: "All characteristic keys in skuTemplate must be required characteristics",
10549
+ message: "All keys in skuTemplate must be required characteristics of type number, select or toggle",
10533
10550
  path: ["skuTemplate"]
10534
10551
  });
10535
10552
  var ProductTypeSchema = z882.object({