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

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,39 @@ 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
+ }, "strip", z$1.ZodTypeAny, {
22274
+ type: "checkbox";
22275
+ key: string;
22276
+ label: string;
22277
+ }, {
22278
+ type: "checkbox";
22279
+ key: string;
22280
+ label: string;
22248
22281
  }>]>;
22249
22282
  declare const CharacteristicsSchemeSchema: z$1.ZodArray<z$1.ZodDiscriminatedUnion<"type", [z$1.ZodObject<{
22250
22283
  key: z$1.ZodString;
@@ -22325,6 +22358,39 @@ declare const CharacteristicsSchemeSchema: z$1.ZodArray<z$1.ZodDiscriminatedUnio
22325
22358
  key: string;
22326
22359
  label: string;
22327
22360
  required?: boolean | undefined;
22361
+ }>, z$1.ZodObject<{
22362
+ key: z$1.ZodString;
22363
+ label: z$1.ZodString;
22364
+ type: z$1.ZodLiteral<"toggle">;
22365
+ required: z$1.ZodDefault<z$1.ZodBoolean>;
22366
+ true_label: z$1.ZodString;
22367
+ false_label: z$1.ZodString;
22368
+ }, "strip", z$1.ZodTypeAny, {
22369
+ type: "toggle";
22370
+ key: string;
22371
+ label: string;
22372
+ required: boolean;
22373
+ true_label: string;
22374
+ false_label: string;
22375
+ }, {
22376
+ type: "toggle";
22377
+ key: string;
22378
+ label: string;
22379
+ true_label: string;
22380
+ false_label: string;
22381
+ required?: boolean | undefined;
22382
+ }>, z$1.ZodObject<{
22383
+ key: z$1.ZodString;
22384
+ label: z$1.ZodString;
22385
+ type: z$1.ZodLiteral<"checkbox">;
22386
+ }, "strip", z$1.ZodTypeAny, {
22387
+ type: "checkbox";
22388
+ key: string;
22389
+ label: string;
22390
+ }, {
22391
+ type: "checkbox";
22392
+ key: string;
22393
+ label: string;
22328
22394
  }>]>, "many">;
22329
22395
  type Characteristic = z$1.infer<typeof CharacteristicSchema>;
22330
22396
  type CharacteristicsScheme = z$1.infer<typeof CharacteristicsSchemeSchema>;
@@ -22412,6 +22478,39 @@ declare const CreateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22412
22478
  key: string;
22413
22479
  label: string;
22414
22480
  required?: boolean | undefined;
22481
+ }>, z$1.ZodObject<{
22482
+ key: z$1.ZodString;
22483
+ label: z$1.ZodString;
22484
+ type: z$1.ZodLiteral<"toggle">;
22485
+ required: z$1.ZodDefault<z$1.ZodBoolean>;
22486
+ true_label: z$1.ZodString;
22487
+ false_label: z$1.ZodString;
22488
+ }, "strip", z$1.ZodTypeAny, {
22489
+ type: "toggle";
22490
+ key: string;
22491
+ label: string;
22492
+ required: boolean;
22493
+ true_label: string;
22494
+ false_label: string;
22495
+ }, {
22496
+ type: "toggle";
22497
+ key: string;
22498
+ label: string;
22499
+ true_label: string;
22500
+ false_label: string;
22501
+ required?: boolean | undefined;
22502
+ }>, z$1.ZodObject<{
22503
+ key: z$1.ZodString;
22504
+ label: z$1.ZodString;
22505
+ type: z$1.ZodLiteral<"checkbox">;
22506
+ }, "strip", z$1.ZodTypeAny, {
22507
+ type: "checkbox";
22508
+ key: string;
22509
+ label: string;
22510
+ }, {
22511
+ type: "checkbox";
22512
+ key: string;
22513
+ label: string;
22415
22514
  }>]>, "many">>>;
22416
22515
  }, "strip", z$1.ZodTypeAny, {
22417
22516
  name: string;
@@ -22439,6 +22538,17 @@ declare const CreateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22439
22538
  key: string;
22440
22539
  label: string;
22441
22540
  required: boolean;
22541
+ } | {
22542
+ type: "toggle";
22543
+ key: string;
22544
+ label: string;
22545
+ required: boolean;
22546
+ true_label: string;
22547
+ false_label: string;
22548
+ } | {
22549
+ type: "checkbox";
22550
+ key: string;
22551
+ label: string;
22442
22552
  })[] | null | undefined;
22443
22553
  }, {
22444
22554
  name: string;
@@ -22466,6 +22576,17 @@ declare const CreateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22466
22576
  key: string;
22467
22577
  label: string;
22468
22578
  required?: boolean | undefined;
22579
+ } | {
22580
+ type: "toggle";
22581
+ key: string;
22582
+ label: string;
22583
+ true_label: string;
22584
+ false_label: string;
22585
+ required?: boolean | undefined;
22586
+ } | {
22587
+ type: "checkbox";
22588
+ key: string;
22589
+ label: string;
22469
22590
  })[] | null | undefined;
22470
22591
  }>, {
22471
22592
  name: string;
@@ -22493,6 +22614,17 @@ declare const CreateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22493
22614
  key: string;
22494
22615
  label: string;
22495
22616
  required: boolean;
22617
+ } | {
22618
+ type: "toggle";
22619
+ key: string;
22620
+ label: string;
22621
+ required: boolean;
22622
+ true_label: string;
22623
+ false_label: string;
22624
+ } | {
22625
+ type: "checkbox";
22626
+ key: string;
22627
+ label: string;
22496
22628
  })[] | null | undefined;
22497
22629
  }, {
22498
22630
  name: string;
@@ -22520,6 +22652,17 @@ declare const CreateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22520
22652
  key: string;
22521
22653
  label: string;
22522
22654
  required?: boolean | undefined;
22655
+ } | {
22656
+ type: "toggle";
22657
+ key: string;
22658
+ label: string;
22659
+ true_label: string;
22660
+ false_label: string;
22661
+ required?: boolean | undefined;
22662
+ } | {
22663
+ type: "checkbox";
22664
+ key: string;
22665
+ label: string;
22523
22666
  })[] | null | undefined;
22524
22667
  }>, {
22525
22668
  name: string;
@@ -22547,6 +22690,17 @@ declare const CreateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22547
22690
  key: string;
22548
22691
  label: string;
22549
22692
  required: boolean;
22693
+ } | {
22694
+ type: "toggle";
22695
+ key: string;
22696
+ label: string;
22697
+ required: boolean;
22698
+ true_label: string;
22699
+ false_label: string;
22700
+ } | {
22701
+ type: "checkbox";
22702
+ key: string;
22703
+ label: string;
22550
22704
  })[] | null | undefined;
22551
22705
  }, {
22552
22706
  name: string;
@@ -22574,6 +22728,17 @@ declare const CreateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22574
22728
  key: string;
22575
22729
  label: string;
22576
22730
  required?: boolean | undefined;
22731
+ } | {
22732
+ type: "toggle";
22733
+ key: string;
22734
+ label: string;
22735
+ true_label: string;
22736
+ false_label: string;
22737
+ required?: boolean | undefined;
22738
+ } | {
22739
+ type: "checkbox";
22740
+ key: string;
22741
+ label: string;
22577
22742
  })[] | null | undefined;
22578
22743
  }>;
22579
22744
  declare const UpdateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObject<{
@@ -22660,6 +22825,39 @@ declare const UpdateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22660
22825
  key: string;
22661
22826
  label: string;
22662
22827
  required?: boolean | undefined;
22828
+ }>, z$1.ZodObject<{
22829
+ key: z$1.ZodString;
22830
+ label: z$1.ZodString;
22831
+ type: z$1.ZodLiteral<"toggle">;
22832
+ required: z$1.ZodDefault<z$1.ZodBoolean>;
22833
+ true_label: z$1.ZodString;
22834
+ false_label: z$1.ZodString;
22835
+ }, "strip", z$1.ZodTypeAny, {
22836
+ type: "toggle";
22837
+ key: string;
22838
+ label: string;
22839
+ required: boolean;
22840
+ true_label: string;
22841
+ false_label: string;
22842
+ }, {
22843
+ type: "toggle";
22844
+ key: string;
22845
+ label: string;
22846
+ true_label: string;
22847
+ false_label: string;
22848
+ required?: boolean | undefined;
22849
+ }>, z$1.ZodObject<{
22850
+ key: z$1.ZodString;
22851
+ label: z$1.ZodString;
22852
+ type: z$1.ZodLiteral<"checkbox">;
22853
+ }, "strip", z$1.ZodTypeAny, {
22854
+ type: "checkbox";
22855
+ key: string;
22856
+ label: string;
22857
+ }, {
22858
+ type: "checkbox";
22859
+ key: string;
22860
+ label: string;
22663
22861
  }>]>, "many">>>>;
22664
22862
  }, "strip", z$1.ZodTypeAny, {
22665
22863
  name?: string | undefined;
@@ -22687,6 +22885,17 @@ declare const UpdateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22687
22885
  key: string;
22688
22886
  label: string;
22689
22887
  required: boolean;
22888
+ } | {
22889
+ type: "toggle";
22890
+ key: string;
22891
+ label: string;
22892
+ required: boolean;
22893
+ true_label: string;
22894
+ false_label: string;
22895
+ } | {
22896
+ type: "checkbox";
22897
+ key: string;
22898
+ label: string;
22690
22899
  })[] | null | undefined;
22691
22900
  }, {
22692
22901
  name?: string | undefined;
@@ -22714,6 +22923,17 @@ declare const UpdateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22714
22923
  key: string;
22715
22924
  label: string;
22716
22925
  required?: boolean | undefined;
22926
+ } | {
22927
+ type: "toggle";
22928
+ key: string;
22929
+ label: string;
22930
+ true_label: string;
22931
+ false_label: string;
22932
+ required?: boolean | undefined;
22933
+ } | {
22934
+ type: "checkbox";
22935
+ key: string;
22936
+ label: string;
22717
22937
  })[] | null | undefined;
22718
22938
  }>, {
22719
22939
  name?: string | undefined;
@@ -22741,6 +22961,17 @@ declare const UpdateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22741
22961
  key: string;
22742
22962
  label: string;
22743
22963
  required: boolean;
22964
+ } | {
22965
+ type: "toggle";
22966
+ key: string;
22967
+ label: string;
22968
+ required: boolean;
22969
+ true_label: string;
22970
+ false_label: string;
22971
+ } | {
22972
+ type: "checkbox";
22973
+ key: string;
22974
+ label: string;
22744
22975
  })[] | null | undefined;
22745
22976
  }, {
22746
22977
  name?: string | undefined;
@@ -22768,6 +22999,17 @@ declare const UpdateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22768
22999
  key: string;
22769
23000
  label: string;
22770
23001
  required?: boolean | undefined;
23002
+ } | {
23003
+ type: "toggle";
23004
+ key: string;
23005
+ label: string;
23006
+ true_label: string;
23007
+ false_label: string;
23008
+ required?: boolean | undefined;
23009
+ } | {
23010
+ type: "checkbox";
23011
+ key: string;
23012
+ label: string;
22771
23013
  })[] | null | undefined;
22772
23014
  }>, {
22773
23015
  name?: string | undefined;
@@ -22795,6 +23037,17 @@ declare const UpdateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22795
23037
  key: string;
22796
23038
  label: string;
22797
23039
  required: boolean;
23040
+ } | {
23041
+ type: "toggle";
23042
+ key: string;
23043
+ label: string;
23044
+ required: boolean;
23045
+ true_label: string;
23046
+ false_label: string;
23047
+ } | {
23048
+ type: "checkbox";
23049
+ key: string;
23050
+ label: string;
22798
23051
  })[] | null | undefined;
22799
23052
  }, {
22800
23053
  name?: string | undefined;
@@ -22822,6 +23075,17 @@ declare const UpdateProductTypeSchema: z$1.ZodEffects<z$1.ZodEffects<z$1.ZodObje
22822
23075
  key: string;
22823
23076
  label: string;
22824
23077
  required?: boolean | undefined;
23078
+ } | {
23079
+ type: "toggle";
23080
+ key: string;
23081
+ label: string;
23082
+ true_label: string;
23083
+ false_label: string;
23084
+ required?: boolean | undefined;
23085
+ } | {
23086
+ type: "checkbox";
23087
+ key: string;
23088
+ label: string;
22825
23089
  })[] | null | undefined;
22826
23090
  }>;
22827
23091
  declare const ProductTypeSchema: z$1.ZodObject<{
@@ -22910,6 +23174,39 @@ declare const ProductTypeSchema: z$1.ZodObject<{
22910
23174
  key: string;
22911
23175
  label: string;
22912
23176
  required?: boolean | undefined;
23177
+ }>, z$1.ZodObject<{
23178
+ key: z$1.ZodString;
23179
+ label: z$1.ZodString;
23180
+ type: z$1.ZodLiteral<"toggle">;
23181
+ required: z$1.ZodDefault<z$1.ZodBoolean>;
23182
+ true_label: z$1.ZodString;
23183
+ false_label: z$1.ZodString;
23184
+ }, "strip", z$1.ZodTypeAny, {
23185
+ type: "toggle";
23186
+ key: string;
23187
+ label: string;
23188
+ required: boolean;
23189
+ true_label: string;
23190
+ false_label: string;
23191
+ }, {
23192
+ type: "toggle";
23193
+ key: string;
23194
+ label: string;
23195
+ true_label: string;
23196
+ false_label: string;
23197
+ required?: boolean | undefined;
23198
+ }>, z$1.ZodObject<{
23199
+ key: z$1.ZodString;
23200
+ label: z$1.ZodString;
23201
+ type: z$1.ZodLiteral<"checkbox">;
23202
+ }, "strip", z$1.ZodTypeAny, {
23203
+ type: "checkbox";
23204
+ key: string;
23205
+ label: string;
23206
+ }, {
23207
+ type: "checkbox";
23208
+ key: string;
23209
+ label: string;
22913
23210
  }>]>, "many">>;
22914
23211
  updatedAt: z$1.ZodString;
22915
23212
  }, "strip", z$1.ZodTypeAny, {
@@ -22940,6 +23237,17 @@ declare const ProductTypeSchema: z$1.ZodObject<{
22940
23237
  key: string;
22941
23238
  label: string;
22942
23239
  required: boolean;
23240
+ } | {
23241
+ type: "toggle";
23242
+ key: string;
23243
+ label: string;
23244
+ required: boolean;
23245
+ true_label: string;
23246
+ false_label: string;
23247
+ } | {
23248
+ type: "checkbox";
23249
+ key: string;
23250
+ label: string;
22943
23251
  })[] | null;
22944
23252
  skuCounter: number;
22945
23253
  }, {
@@ -22970,6 +23278,17 @@ declare const ProductTypeSchema: z$1.ZodObject<{
22970
23278
  key: string;
22971
23279
  label: string;
22972
23280
  required?: boolean | undefined;
23281
+ } | {
23282
+ type: "toggle";
23283
+ key: string;
23284
+ label: string;
23285
+ true_label: string;
23286
+ false_label: string;
23287
+ required?: boolean | undefined;
23288
+ } | {
23289
+ type: "checkbox";
23290
+ key: string;
23291
+ label: string;
22973
23292
  })[] | null;
22974
23293
  skuCounter: number;
22975
23294
  }>;
package/dist/index.js CHANGED
@@ -10496,20 +10496,36 @@ 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
+ });
10499
10512
  var CharacteristicSchema = z882.discriminatedUnion("type", [
10500
10513
  NumberCharacteristicSchema,
10501
- SelectCharacteristicSchema
10514
+ SelectCharacteristicSchema,
10515
+ ToggleCharacteristicSchema,
10516
+ CheckboxCharacteristicSchema
10502
10517
  ]);
10503
10518
  var CharacteristicsSchemeSchema = z882.array(CharacteristicSchema);
10504
10519
  var SKU_TEMPLATE_REGEX = /^(\{(brand|counter)(?::\d+)?\}|\{[a-z_]+(?::\d+)?\}|[^{}]+)+$/;
10505
10520
  var RESERVED_SKU_KEYS = /* @__PURE__ */ new Set(["brand", "counter"]);
10521
+ var SKU_COMPATIBLE_TYPES = /* @__PURE__ */ new Set(["number", "select", "toggle"]);
10506
10522
  function validateSkuTemplate(data) {
10507
10523
  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)
10524
+ const skuCompatibleKeys = new Set(
10525
+ data.characteristicsScheme.filter((c) => SKU_COMPATIBLE_TYPES.has(c.type) && "required" in c && c.required).map((c) => c.key)
10510
10526
  );
10511
10527
  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));
10528
+ return templateKeys.every((key) => skuCompatibleKeys.has(key));
10513
10529
  }
10514
10530
  var ProductTypeBaseSchema = z882.object({
10515
10531
  name: z882.string().min(1),
@@ -10522,14 +10538,14 @@ var CreateProductTypeSchema = ProductTypeBaseSchema.refine(
10522
10538
  (data) => !(data.skuMode === "CUSTOM" && !data.skuTemplate),
10523
10539
  { message: "skuTemplate is required for CUSTOM sku mode", path: ["skuTemplate"] }
10524
10540
  ).refine(validateSkuTemplate, {
10525
- message: "All characteristic keys in skuTemplate must be required characteristics",
10541
+ message: "All keys in skuTemplate must be required characteristics of type number, select or toggle",
10526
10542
  path: ["skuTemplate"]
10527
10543
  });
10528
10544
  var UpdateProductTypeSchema = ProductTypeBaseSchema.partial().refine(
10529
10545
  (data) => !(data.skuMode === "CUSTOM" && data.skuTemplate === null),
10530
10546
  { message: "skuTemplate cannot be null for CUSTOM sku mode", path: ["skuTemplate"] }
10531
10547
  ).refine(validateSkuTemplate, {
10532
- message: "All characteristic keys in skuTemplate must be required characteristics",
10548
+ message: "All keys in skuTemplate must be required characteristics of type number, select or toggle",
10533
10549
  path: ["skuTemplate"]
10534
10550
  });
10535
10551
  var ProductTypeSchema = z882.object({