@artisan-commerce/builders 0.7.0-canary.53 → 0.7.0-canary.55

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.
@@ -18,42 +18,60 @@ const genItems = (builder, quantity) => {
18
18
  return items;
19
19
  };
20
20
 
21
- const commonDocumentTypes = ["PASSPORT"];
22
- const ARDocumentTypes = [...commonDocumentTypes];
23
- const BODocumentTypes = [...commonDocumentTypes];
24
- const BRDocumentTypes = [...commonDocumentTypes];
25
- const CLDocumentTypes = [...commonDocumentTypes];
26
- const CODocumentTypes = [
27
- ...commonDocumentTypes,
21
+ const getCommonDocumentTypes = () => ["PASSPORT"];
22
+ const getARDocumentTypes = () => [
23
+ ...getCommonDocumentTypes()
24
+ ];
25
+ const getBODocumentTypes = () => [
26
+ ...getCommonDocumentTypes()
27
+ ];
28
+ const getBRDocumentTypes = () => [
29
+ ...getCommonDocumentTypes()
30
+ ];
31
+ const getCLDocumentTypes = () => [
32
+ ...getCommonDocumentTypes()
33
+ ];
34
+ const getCODocumentTypes = () => [
35
+ ...getCommonDocumentTypes(),
28
36
  "RUT",
29
37
  "NIT",
30
38
  "CE",
31
39
  "CC"
32
40
  ];
33
- const ECDocumentTypes = [
34
- ...commonDocumentTypes,
41
+ const getECDocumentTypes = () => [
42
+ ...getCommonDocumentTypes(),
35
43
  "CI",
36
44
  "RUC"
37
45
  ];
38
- const PYDocumentTypes = [...commonDocumentTypes];
39
- const PEDocumentTypes = [...commonDocumentTypes];
40
- const UYDocumentTypes = [...commonDocumentTypes];
41
- const VEDocumentTypes = [...commonDocumentTypes];
42
- const USDocumentTypes = [...commonDocumentTypes];
46
+ const getPYDocumentTypes = () => [
47
+ ...getCommonDocumentTypes()
48
+ ];
49
+ const getPEDocumentTypes = () => [
50
+ ...getCommonDocumentTypes()
51
+ ];
52
+ const getUYDocumentTypes = () => [
53
+ ...getCommonDocumentTypes()
54
+ ];
55
+ const getVEDocumentTypes = () => [
56
+ ...getCommonDocumentTypes()
57
+ ];
58
+ const getUSDocumentTypes = () => [
59
+ ...getCommonDocumentTypes()
60
+ ];
43
61
  const getPassword = (...args) => `!0_Oo${faker.faker.internet.password(...args)}`;
44
- const getUsername = faker.faker.internet.userName;
45
- const genId = faker.faker.datatype.uuid;
62
+ const getUsername = (...params) => faker.faker.internet.userName(...params);
63
+ const genId = (...params) => faker.faker.datatype.uuid(...params);
46
64
  const genNumericId = (...params) => +faker.faker.random.numeric(...params);
47
- const genWord = faker.faker.lorem.word;
48
- const genAddress = faker.faker.address.streetAddress;
49
- const genName = faker.faker.name.fullName;
50
- const genEmail = faker.faker.internet.email;
51
- const genCompanyName = faker.faker.company.name;
52
- const genParagraph = faker.faker.lorem.paragraph;
53
- const genTitle = () => faker.faker.lorem.slug(3);
54
- const genNumber = faker.faker.datatype.number;
55
- const getBoolean = faker.faker.datatype.boolean;
56
- const genCountryName = faker.faker.address.country;
65
+ const genWord = (...params) => faker.faker.lorem.word(...params);
66
+ const genAddress = (...params) => faker.faker.address.streetAddress(...params);
67
+ const genName = (...params) => faker.faker.name.fullName(...params);
68
+ const genEmail = (...params) => faker.faker.internet.email(...params);
69
+ const genCompanyName = (...params) => faker.faker.company.name(...params);
70
+ const genParagraph = (...params) => faker.faker.lorem.paragraph(...params);
71
+ const genTitle = (...params) => faker.faker.lorem.slug(...params);
72
+ const genNumber = (...params) => faker.faker.datatype.number(...params);
73
+ const getBoolean = (...params) => faker.faker.datatype.boolean(...params);
74
+ const genCountryName = (...params) => faker.faker.address.country(...params);
57
75
  const genRandomImage = (randomImageConfig) => {
58
76
  const { query = "product" } = randomImageConfig != null ? randomImageConfig : {};
59
77
  const { width = 300, height = 300 } = randomImageConfig != null ? randomImageConfig : {};
@@ -63,7 +81,7 @@ const genRandomImage = (randomImageConfig) => {
63
81
  return url;
64
82
  };
65
83
  const genWords = (words) => faker.faker.random.words(words);
66
- const genURL = faker.faker.internet.url;
84
+ const genURL = (...params) => faker.faker.internet.url(...params);
67
85
  const genDate = () => faker.faker.date.recent(7).toISOString();
68
86
  const genBase64 = () => btoa__default["default"](genWord());
69
87
  const genBiasBoolean = (bias) => {
@@ -83,27 +101,27 @@ const genDocument = (digits) => {
83
101
  const genDocumentType = (countryISOCode = "EC") => {
84
102
  switch (countryISOCode) {
85
103
  case "AR":
86
- return chooseRandom(ARDocumentTypes);
104
+ return chooseRandom(getARDocumentTypes());
87
105
  case "BO":
88
- return chooseRandom(BODocumentTypes);
106
+ return chooseRandom(getBODocumentTypes());
89
107
  case "BR":
90
- return chooseRandom(BRDocumentTypes);
108
+ return chooseRandom(getBRDocumentTypes());
91
109
  case "CL":
92
- return chooseRandom(CLDocumentTypes);
110
+ return chooseRandom(getCLDocumentTypes());
93
111
  case "CO":
94
- return chooseRandom(CODocumentTypes);
112
+ return chooseRandom(getCODocumentTypes());
95
113
  case "EC":
96
- return chooseRandom(ECDocumentTypes);
114
+ return chooseRandom(getECDocumentTypes());
97
115
  case "PY":
98
- return chooseRandom(PYDocumentTypes);
116
+ return chooseRandom(getPYDocumentTypes());
99
117
  case "PE":
100
- return chooseRandom(PEDocumentTypes);
118
+ return chooseRandom(getPEDocumentTypes());
101
119
  case "UY":
102
- return chooseRandom(UYDocumentTypes);
120
+ return chooseRandom(getUYDocumentTypes());
103
121
  case "VE":
104
- return chooseRandom(VEDocumentTypes);
122
+ return chooseRandom(getVEDocumentTypes());
105
123
  case "US":
106
- return chooseRandom(USDocumentTypes);
124
+ return chooseRandom(getUSDocumentTypes());
107
125
  default:
108
126
  throw new Error(`Builder genDocumentType: The given country ISO code "${countryISOCode}" is not a supported ISO code`);
109
127
  }
@@ -126,24 +144,24 @@ const fillNumber = (num, max) => {
126
144
  }
127
145
  return newId;
128
146
  };
129
- const chooseRandom = faker.faker.helpers.arrayElement;
130
- const genSymbol = chooseRandom(["$", "S/", "$b", "Bs"]);
131
- const genIP = faker.faker.internet.ip;
147
+ const chooseRandom = (array) => faker.faker.helpers.arrayElement(array);
148
+ const genSymbol = () => chooseRandom(["$", "S/", "$b", "Bs"]);
149
+ const genIP = (...params) => faker.faker.internet.ip(...params);
132
150
 
133
151
  var common_builder = /*#__PURE__*/Object.freeze({
134
152
  __proto__: null,
135
- commonDocumentTypes: commonDocumentTypes,
136
- ARDocumentTypes: ARDocumentTypes,
137
- BODocumentTypes: BODocumentTypes,
138
- BRDocumentTypes: BRDocumentTypes,
139
- CLDocumentTypes: CLDocumentTypes,
140
- CODocumentTypes: CODocumentTypes,
141
- ECDocumentTypes: ECDocumentTypes,
142
- PYDocumentTypes: PYDocumentTypes,
143
- PEDocumentTypes: PEDocumentTypes,
144
- UYDocumentTypes: UYDocumentTypes,
145
- VEDocumentTypes: VEDocumentTypes,
146
- USDocumentTypes: USDocumentTypes,
153
+ getCommonDocumentTypes: getCommonDocumentTypes,
154
+ getARDocumentTypes: getARDocumentTypes,
155
+ getBODocumentTypes: getBODocumentTypes,
156
+ getBRDocumentTypes: getBRDocumentTypes,
157
+ getCLDocumentTypes: getCLDocumentTypes,
158
+ getCODocumentTypes: getCODocumentTypes,
159
+ getECDocumentTypes: getECDocumentTypes,
160
+ getPYDocumentTypes: getPYDocumentTypes,
161
+ getPEDocumentTypes: getPEDocumentTypes,
162
+ getUYDocumentTypes: getUYDocumentTypes,
163
+ getVEDocumentTypes: getVEDocumentTypes,
164
+ getUSDocumentTypes: getUSDocumentTypes,
147
165
  getPassword: getPassword,
148
166
  getUsername: getUsername,
149
167
  genId: genId,
@@ -530,7 +548,7 @@ const genBaseProducts = (quantity) => {
530
548
  };
531
549
  const MODIFIER_TYPES = ["RADIO", "CHECKBOX", "QUANTITY", "CUSTOMIZED"];
532
550
  const buildProductAnswer = (overrides = {}, loop = 1) => {
533
- const withQuestions = genBiasBoolean(0.1) && loop < 3;
551
+ const withQuestions = genBiasBoolean(0.1) && loop < 2;
534
552
  const selectedRenderType = chooseRandom(MODIFIER_TYPES);
535
553
  const renderType = genBiasBoolean(0.9) ? null : selectedRenderType;
536
554
  const images = genCDNImages(void 0, { width: 60, height: 60 });
@@ -553,6 +571,8 @@ const buildProductAnswer = (overrides = {}, loop = 1) => {
553
571
  }, overrides);
554
572
  };
555
573
  const genProductAnswers = (quantity, loop = 1) => {
574
+ if (loop > 2)
575
+ return [];
556
576
  const num = quantity != null ? quantity : genNumber({ min: 1, max: 6 });
557
577
  const productAnswers = [];
558
578
  for (let i = 0; i < num; i++) {
@@ -582,6 +602,8 @@ const buildProductQuestion = (overrides = {}, loop = 1) => {
582
602
  }, overrides);
583
603
  };
584
604
  const genProductQuestions = (quantity, loop = 1) => {
605
+ if (loop > 2)
606
+ return [];
585
607
  const num = quantity != null ? quantity : genNumber({ min: 1, max: 5 });
586
608
  const productQuestions = [];
587
609
  for (let i = 0; i < num; i++) {
@@ -758,7 +780,7 @@ const buildCountryCurrency = (overrides = {}) => {
758
780
  return __spreadValues$b({
759
781
  id: genNumber({ min: 0, max: 999 }),
760
782
  name: chooseRandom(["USD", "EUR", "CHL"]),
761
- sign: genSymbol,
783
+ sign: genSymbol(),
762
784
  external_id: genId()
763
785
  }, overrides);
764
786
  };
@@ -1381,7 +1403,7 @@ const buildStore = (overrides = {}) => {
1381
1403
  isOpen: genBiasBoolean(0.99),
1382
1404
  maxOrderAmount: genNumber(50),
1383
1405
  minOrderAmount: genNumber(10),
1384
- orderSymbol: genSymbol,
1406
+ orderSymbol: genSymbol(),
1385
1407
  phone: genMobilPhone("593"),
1386
1408
  sponsored: genBiasBoolean(0.1),
1387
1409
  latitude: genNumber({ min: 0, max: 80, precision: 6 }),
@@ -1395,7 +1417,7 @@ const buildStore = (overrides = {}) => {
1395
1417
  isDefault: genBiasBoolean(0.1),
1396
1418
  active: genBiasBoolean(0.9),
1397
1419
  minOrder: genNumber(15),
1398
- minOrderSymbol: genSymbol,
1420
+ minOrderSymbol: genSymbol(),
1399
1421
  country: buildGenericStoreLocation(),
1400
1422
  location: buildStoreLocation(),
1401
1423
  catalogues: genCatalogues(),
@@ -1560,7 +1582,7 @@ const buildShippingCost = (overrides = {}) => {
1560
1582
  netPrice: genNumber(100),
1561
1583
  productId: genNumber(100),
1562
1584
  subtotalBeforeTaxes: genNumber(100),
1563
- symbol: genSymbol,
1585
+ symbol: genSymbol(),
1564
1586
  taxTotal: genNumber(100),
1565
1587
  taxes: genShippingCostTaxes(),
1566
1588
  total: genNumber(100)
@@ -1635,10 +1657,10 @@ var __spreadValues$4 = (a, b) => {
1635
1657
  }
1636
1658
  return a;
1637
1659
  };
1638
- const genStreetName = faker.faker.address.street;
1639
- const genStreetNumber = faker.faker.address.zipCode;
1640
- const genLatitude = faker.faker.address.latitude;
1641
- const genLongitude = faker.faker.address.longitude;
1660
+ const genStreetName = (...params) => faker.faker.address.street(...params);
1661
+ const genStreetNumber = (...params) => faker.faker.address.zipCode(...params);
1662
+ const genLatitude = (...params) => faker.faker.address.latitude(...params);
1663
+ const genLongitude = (...params) => faker.faker.address.longitude(...params);
1642
1664
  const buildField = (overrides = {}) => {
1643
1665
  return __spreadValues$4({
1644
1666
  id: genWord(),
@@ -1982,7 +2004,7 @@ const buildOrderStoreAdditionalInfo = (overrides = {}) => {
1982
2004
  sponsored: genBiasBoolean(0.1),
1983
2005
  timezone: "",
1984
2006
  channel_name: faker.faker.name.jobTitle(),
1985
- order_symbol: genSymbol,
2007
+ order_symbol: genSymbol(),
1986
2008
  external_id: genId(),
1987
2009
  is_drinks_store: genBiasBoolean(0.3),
1988
2010
  max_order_amount: genNumber(100),
@@ -2117,7 +2139,7 @@ const buildOrderProductPriceCategory = (overrides = {}) => {
2117
2139
  subtotal_without_taxes: genNumber(30),
2118
2140
  subtotal_zero: 0,
2119
2141
  product_id: genNumber(99999),
2120
- symbol: genSymbol,
2142
+ symbol: genSymbol(),
2121
2143
  tax_calcs: buildTaxCalculations(),
2122
2144
  tax_total: genNumber(12),
2123
2145
  total: genNumber(50)