@artisan-commerce/builders 0.7.0-canary.49 → 0.7.0-canary.50
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/bundle.cjs.js +21 -19
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.d.ts +11 -12
- package/dist/bundle.esm.js +21 -20
- package/dist/bundle.esm.js.map +1 -1
- package/dist/bundle.umd.js +21 -19
- package/dist/bundle.umd.js.map +1 -1
- package/dist/noop.cjs.js +4 -0
- package/dist/noop.cjs.js.map +1 -1
- package/dist/noop.esm.js +4 -1
- package/dist/noop.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/bundle.d.ts
CHANGED
|
@@ -502,15 +502,7 @@ declare const fillNumber: (num: string, max?: number) => string;
|
|
|
502
502
|
* @param {T[]} arr An array of generic items
|
|
503
503
|
* @returns {T} A random item of the array passed as param
|
|
504
504
|
*/
|
|
505
|
-
declare const chooseRandom: <T>(
|
|
506
|
-
/**
|
|
507
|
-
* Chooses a random enum value of the enum provided.
|
|
508
|
-
*
|
|
509
|
-
* @since 0.1.0
|
|
510
|
-
* @param {T} anEnum An enum
|
|
511
|
-
* @returns {T[keyof T]} A random item of the enum passed as param
|
|
512
|
-
*/
|
|
513
|
-
declare const chooseRandomEnum: <T>(anEnum: T) => T[keyof T];
|
|
505
|
+
declare const chooseRandom: <T = string>(array?: readonly T[] | undefined) => T;
|
|
514
506
|
/**
|
|
515
507
|
* Generates a random currency symbol.
|
|
516
508
|
*
|
|
@@ -562,7 +554,6 @@ declare const common_builder_genMobilPhone: typeof genMobilPhone;
|
|
|
562
554
|
declare const common_builder_genCountry: typeof genCountry;
|
|
563
555
|
declare const common_builder_fillNumber: typeof fillNumber;
|
|
564
556
|
declare const common_builder_chooseRandom: typeof chooseRandom;
|
|
565
|
-
declare const common_builder_chooseRandomEnum: typeof chooseRandomEnum;
|
|
566
557
|
declare const common_builder_genSymbol: typeof genSymbol;
|
|
567
558
|
declare const common_builder_genIP: typeof genIP;
|
|
568
559
|
declare const common_builder_genItems: typeof genItems;
|
|
@@ -606,7 +597,6 @@ declare namespace common_builder {
|
|
|
606
597
|
common_builder_genCountry as genCountry,
|
|
607
598
|
common_builder_fillNumber as fillNumber,
|
|
608
599
|
common_builder_chooseRandom as chooseRandom,
|
|
609
|
-
common_builder_chooseRandomEnum as chooseRandomEnum,
|
|
610
600
|
common_builder_genSymbol as genSymbol,
|
|
611
601
|
common_builder_genIP as genIP,
|
|
612
602
|
common_builder_genItems as genItems,
|
|
@@ -2966,4 +2956,13 @@ declare namespace vendor_builder {
|
|
|
2966
2956
|
};
|
|
2967
2957
|
}
|
|
2968
2958
|
|
|
2969
|
-
|
|
2959
|
+
declare const seed: <T extends number | number[] | undefined = undefined>(seed?: T | undefined) => T extends number ? number : T extends number[] ? number[] : number;
|
|
2960
|
+
|
|
2961
|
+
declare const instance_utils_seed: typeof seed;
|
|
2962
|
+
declare namespace instance_utils {
|
|
2963
|
+
export {
|
|
2964
|
+
instance_utils_seed as seed,
|
|
2965
|
+
};
|
|
2966
|
+
}
|
|
2967
|
+
|
|
2968
|
+
export { instance_utils as Builders, account_builder as accountBuilders, banner_builder as bannerBuilders, billingData_builder as billingDataBuilders, catalogue_builder as catalogueBuilders, category_builder as categoryBuilders, country_builder as countryBuilders, coupon_builder as couponBuilders, fulfillment_builder as fulfillmentBuilders, image_builder as imageBuilders, notification_builder as notificationBuilders, order_builder as orderBuilders, payment_builder as paymentBuilders, product_builder as productBuilders, settings_builder as settingsBuilders, shippingAddress_builder as shippingAddressBuilders, shoppingCart_builder as shoppingCartBuilders, store_builder as storeBuilders, user_builder as userBuilders, common_builder as utils, vendor_builder as vendorBuilders };
|
package/dist/bundle.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ import { faker } from '@faker-js/faker';
|
|
|
2
2
|
import btoa from 'btoa';
|
|
3
3
|
|
|
4
4
|
const genItems = (builder, quantity) => {
|
|
5
|
-
const num = quantity != null ? quantity :
|
|
5
|
+
const num = quantity != null ? quantity : faker.datatype.number({ min: 1, max: 10 });
|
|
6
6
|
const items = [];
|
|
7
7
|
for (let i = 0; i < num; i++) {
|
|
8
8
|
items.push(builder());
|
|
@@ -62,7 +62,7 @@ const genBiasBoolean = (bias) => {
|
|
|
62
62
|
if (bias > 1 || bias < 0) {
|
|
63
63
|
throw new Error(`Bias must be a number between 0 and 1. Value ${bias} is not valid`);
|
|
64
64
|
}
|
|
65
|
-
const random =
|
|
65
|
+
const random = faker.datatype.number({ min: 0, max: 1, precision: 4 });
|
|
66
66
|
return random <= bias;
|
|
67
67
|
};
|
|
68
68
|
const genDocument = (digits) => {
|
|
@@ -118,16 +118,7 @@ const fillNumber = (num, max) => {
|
|
|
118
118
|
}
|
|
119
119
|
return newId;
|
|
120
120
|
};
|
|
121
|
-
const chooseRandom =
|
|
122
|
-
return arr[Math.floor(Math.random() * arr.length)];
|
|
123
|
-
};
|
|
124
|
-
const chooseRandomEnum = (anEnum) => {
|
|
125
|
-
const enumValues = Object.keys(anEnum);
|
|
126
|
-
const randomIndex = Math.floor(Math.random() * enumValues.length);
|
|
127
|
-
const randomEnumKey = enumValues[randomIndex];
|
|
128
|
-
const randomEnumValue = anEnum[randomEnumKey];
|
|
129
|
-
return randomEnumValue;
|
|
130
|
-
};
|
|
121
|
+
const chooseRandom = faker.helpers.arrayElement;
|
|
131
122
|
const genSymbol = chooseRandom(["$", "S/", "$b", "Bs"]);
|
|
132
123
|
const genIP = faker.internet.ip;
|
|
133
124
|
|
|
@@ -171,7 +162,6 @@ var common_builder = /*#__PURE__*/Object.freeze({
|
|
|
171
162
|
genCountry: genCountry,
|
|
172
163
|
fillNumber: fillNumber,
|
|
173
164
|
chooseRandom: chooseRandom,
|
|
174
|
-
chooseRandomEnum: chooseRandomEnum,
|
|
175
165
|
genSymbol: genSymbol,
|
|
176
166
|
genIP: genIP,
|
|
177
167
|
genItems: genItems
|
|
@@ -419,7 +409,7 @@ const buildCatalogue = (overrides = {}) => {
|
|
|
419
409
|
}, overrides);
|
|
420
410
|
};
|
|
421
411
|
const genCatalogues = (quantity) => {
|
|
422
|
-
const num = quantity != null ? quantity :
|
|
412
|
+
const num = quantity != null ? quantity : genNumber({ min: 1, max: 10 });
|
|
423
413
|
let options = [...catalogueOptions];
|
|
424
414
|
const catalogues = [];
|
|
425
415
|
for (let i = 0; i < num; i++) {
|
|
@@ -509,7 +499,7 @@ const buildBaseProduct = (overrides = {}) => {
|
|
|
509
499
|
addDirectlyToCart: genBiasBoolean(0.5),
|
|
510
500
|
coverUrl: "",
|
|
511
501
|
description: faker.lorem.lines(2),
|
|
512
|
-
images: genCDNImages(
|
|
502
|
+
images: genCDNImages(genNumber({ min: 1, max: 5 })),
|
|
513
503
|
measure: "unit",
|
|
514
504
|
name: faker.commerce.productName(),
|
|
515
505
|
outOfService: false,
|
|
@@ -555,7 +545,7 @@ const buildProductAnswer = (overrides = {}, loop = 1) => {
|
|
|
555
545
|
}, overrides);
|
|
556
546
|
};
|
|
557
547
|
const genProductAnswers = (quantity, loop = 1) => {
|
|
558
|
-
const num = quantity != null ? quantity :
|
|
548
|
+
const num = quantity != null ? quantity : genNumber({ min: 1, max: 6 });
|
|
559
549
|
const productAnswers = [];
|
|
560
550
|
for (let i = 0; i < num; i++) {
|
|
561
551
|
const productAnswer = buildProductAnswer({}, loop);
|
|
@@ -584,7 +574,7 @@ const buildProductQuestion = (overrides = {}, loop = 1) => {
|
|
|
584
574
|
}, overrides);
|
|
585
575
|
};
|
|
586
576
|
const genProductQuestions = (quantity, loop = 1) => {
|
|
587
|
-
const num = quantity != null ? quantity :
|
|
577
|
+
const num = quantity != null ? quantity : genNumber({ min: 1, max: 5 });
|
|
588
578
|
const productQuestions = [];
|
|
589
579
|
for (let i = 0; i < num; i++) {
|
|
590
580
|
const productQuestion = buildProductQuestion({}, loop);
|
|
@@ -619,7 +609,7 @@ const buildCartProductAnswer = (questionId, overrides = {}) => {
|
|
|
619
609
|
}), overrides);
|
|
620
610
|
};
|
|
621
611
|
const genCartProductAnswers = (quantity) => {
|
|
622
|
-
const num = quantity != null ? quantity :
|
|
612
|
+
const num = quantity != null ? quantity : genNumber({ min: 1, max: 5 });
|
|
623
613
|
const cartProductAnswers = [];
|
|
624
614
|
for (let i = 0; i < num; i++) {
|
|
625
615
|
const cartProductAnswer = buildCartProductAnswer(i.toString());
|
|
@@ -1528,7 +1518,7 @@ const buildCartStore = (overrides = {}) => {
|
|
|
1528
1518
|
}), overrides);
|
|
1529
1519
|
};
|
|
1530
1520
|
const genCartStores = (quantity) => {
|
|
1531
|
-
const num = quantity != null ? quantity :
|
|
1521
|
+
const num = quantity != null ? quantity : genNumber({ min: 1, max: 1 });
|
|
1532
1522
|
const cartStores = {};
|
|
1533
1523
|
for (let i = 0; i < num; i++) {
|
|
1534
1524
|
const cartStore = buildCartStore();
|
|
@@ -2603,5 +2593,16 @@ var payment_builder = /*#__PURE__*/Object.freeze({
|
|
|
2603
2593
|
genCardInscriptions: genCardInscriptions
|
|
2604
2594
|
});
|
|
2605
2595
|
|
|
2606
|
-
|
|
2596
|
+
const seed = (seed2) => {
|
|
2597
|
+
if (!faker)
|
|
2598
|
+
throw new Error("Faker not found");
|
|
2599
|
+
return faker.seed(seed2);
|
|
2600
|
+
};
|
|
2601
|
+
|
|
2602
|
+
var instance_utils = /*#__PURE__*/Object.freeze({
|
|
2603
|
+
__proto__: null,
|
|
2604
|
+
seed: seed
|
|
2605
|
+
});
|
|
2606
|
+
|
|
2607
|
+
export { instance_utils as Builders, account_builder as accountBuilders, banner_builder as bannerBuilders, billingData_builder as billingDataBuilders, catalogue_builder as catalogueBuilders, category_builder as categoryBuilders, country_builder as countryBuilders, coupon_builder as couponBuilders, fulfillment_builder as fulfillmentBuilders, image_builder as imageBuilders, notification_builder as notificationBuilders, order_builder as orderBuilders, payment_builder as paymentBuilders, product_builder as productBuilders, settings_builder as settingsBuilders, shippingAddress_builder as shippingAddressBuilders, shoppingCart_builder as shoppingCartBuilders, store_builder as storeBuilders, user_builder as userBuilders, common_builder as utils, vendor_builder as vendorBuilders };
|
|
2607
2608
|
//# sourceMappingURL=bundle.esm.js.map
|