From 4b99fd777ad8709a8c993b7fa52fd7897299b35b Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Fri, 31 May 2024 15:39:36 +0200 Subject: [PATCH] Migrate @data/demo from Core --- src/data/demo/addresses.ts | 43 +++++++++ src/data/demo/attributes.ts | 128 +++++++++++++++++++++++++++ src/data/demo/boPages.ts | 7 ++ src/data/demo/brandAdresses.ts | 22 +++++ src/data/demo/brands.ts | 18 ++++ src/data/demo/carriers.ts | 39 ++++++++ src/data/demo/cmsPage.ts | 44 +++++++++ src/data/demo/contacts.ts | 16 ++++ src/data/demo/employeeRoles.ts | 16 ++++ src/data/demo/employees.ts | 14 +++ src/data/demo/features.ts | 42 +++++++++ src/data/demo/hooks.ts | 8 ++ src/data/demo/imageTypes.ts | 26 ++++++ src/data/demo/languages.ts | 123 +++++++++++++++++++++++++ src/data/demo/linkWidgets.ts | 19 ++++ src/data/demo/moduleCategories.ts | 8 ++ src/data/demo/modules.ts | 19 +++- src/data/demo/orderReturnStatuses.ts | 24 +++++ src/data/demo/searchAliases.ts | 12 +++ src/data/demo/searchEngines.ts | 19 ++++ src/data/demo/seoPages.ts | 32 +++++++ src/data/demo/shoppingCarts.ts | 41 +++++++++ src/data/demo/sqlTables.ts | 20 +++++ src/data/demo/stores.ts | 42 +++++++++ src/data/demo/suppliers.ts | 16 ++++ src/data/demo/taxOptions.ts | 93 +++++++++++++++++++ src/data/faker/attribute.ts | 68 ++++++++++++++ src/data/faker/attributeValue.ts | 66 ++++++++++++++ src/data/faker/brand.ts | 95 ++++++++++++++++++++ src/data/faker/brandAddress.ts | 79 +++++++++++++++++ src/data/faker/cmsPage.ts | 65 ++++++++++++++ src/data/faker/contact.ts | 56 ++++++++++++ src/data/faker/employee.ts | 85 ++++++++++++++++++ src/data/faker/employeeRole.ts | 20 +++++ src/data/faker/feature.ts | 51 +++++++++++ src/data/faker/featureValue.ts | 42 +++++++++ src/data/faker/hook.ts | 24 +++++ src/data/faker/imageType.ts | 64 ++++++++++++++ src/data/faker/language.ts | 65 ++++++++++++++ src/data/faker/linkWidget.ts | 50 +++++++++++ src/data/faker/order.ts | 11 ++- src/data/faker/orderReturnStatus.ts | 32 +++++++ src/data/faker/searchAlias.ts | 25 ++++++ src/data/faker/searchEngine.ts | 30 +++++++ src/data/faker/seoPage.ts | 65 ++++++++++++++ src/data/faker/shoppingCart.ts | 42 +++++++++ src/data/faker/sqlTable.ts | 23 +++++ src/data/faker/store.ts | 104 ++++++++++++++++++++++ src/data/faker/supplier.ts | 118 ++++++++++++++++++++++++ src/data/faker/taxOption.ts | 38 ++++++++ src/data/types/attribute.ts | 31 +++++++ src/data/types/brand.ts | 20 +++++ src/data/types/brandAddress.ts | 16 ++++ src/data/types/cmsPage.ts | 14 +++ src/data/types/contact.ts | 11 +++ src/data/types/employee.ts | 23 +++++ src/data/types/employeeRole.ts | 5 ++ src/data/types/feature.ts | 24 +++++ src/data/types/hook.ts | 6 ++ src/data/types/imageType.ts | 20 +++++ src/data/types/language.ts | 14 +++ src/data/types/linkWidget.ts | 21 +++++ src/data/types/module.ts | 14 ++- src/data/types/orderReturnStatus.ts | 7 ++ src/data/types/searchAlias.ts | 6 ++ src/data/types/searchEngine.ts | 7 ++ src/data/types/seoPage.ts | 14 +++ src/data/types/shoppingCart.ts | 26 ++++++ src/data/types/sqlTable.ts | 6 ++ src/data/types/store.ts | 22 +++++ src/data/types/supplier.ts | 24 +++++ src/data/types/taxOption.ts | 9 ++ src/index.ts | 53 +++++++++++ 73 files changed, 2597 insertions(+), 5 deletions(-) create mode 100644 src/data/demo/addresses.ts create mode 100644 src/data/demo/attributes.ts create mode 100644 src/data/demo/boPages.ts create mode 100644 src/data/demo/brandAdresses.ts create mode 100644 src/data/demo/brands.ts create mode 100644 src/data/demo/carriers.ts create mode 100644 src/data/demo/cmsPage.ts create mode 100644 src/data/demo/contacts.ts create mode 100644 src/data/demo/employeeRoles.ts create mode 100644 src/data/demo/employees.ts create mode 100644 src/data/demo/features.ts create mode 100644 src/data/demo/hooks.ts create mode 100644 src/data/demo/imageTypes.ts create mode 100644 src/data/demo/languages.ts create mode 100644 src/data/demo/linkWidgets.ts create mode 100644 src/data/demo/moduleCategories.ts create mode 100644 src/data/demo/orderReturnStatuses.ts create mode 100644 src/data/demo/searchAliases.ts create mode 100644 src/data/demo/searchEngines.ts create mode 100644 src/data/demo/seoPages.ts create mode 100644 src/data/demo/shoppingCarts.ts create mode 100644 src/data/demo/sqlTables.ts create mode 100644 src/data/demo/stores.ts create mode 100644 src/data/demo/suppliers.ts create mode 100644 src/data/demo/taxOptions.ts create mode 100644 src/data/faker/attribute.ts create mode 100644 src/data/faker/attributeValue.ts create mode 100644 src/data/faker/brand.ts create mode 100644 src/data/faker/brandAddress.ts create mode 100644 src/data/faker/cmsPage.ts create mode 100644 src/data/faker/contact.ts create mode 100644 src/data/faker/employee.ts create mode 100644 src/data/faker/employeeRole.ts create mode 100644 src/data/faker/feature.ts create mode 100644 src/data/faker/featureValue.ts create mode 100644 src/data/faker/hook.ts create mode 100644 src/data/faker/imageType.ts create mode 100644 src/data/faker/language.ts create mode 100644 src/data/faker/linkWidget.ts create mode 100644 src/data/faker/orderReturnStatus.ts create mode 100644 src/data/faker/searchAlias.ts create mode 100644 src/data/faker/searchEngine.ts create mode 100644 src/data/faker/seoPage.ts create mode 100644 src/data/faker/shoppingCart.ts create mode 100644 src/data/faker/sqlTable.ts create mode 100644 src/data/faker/store.ts create mode 100644 src/data/faker/supplier.ts create mode 100644 src/data/faker/taxOption.ts create mode 100644 src/data/types/attribute.ts create mode 100644 src/data/types/brand.ts create mode 100644 src/data/types/brandAddress.ts create mode 100644 src/data/types/cmsPage.ts create mode 100644 src/data/types/contact.ts create mode 100644 src/data/types/employee.ts create mode 100644 src/data/types/employeeRole.ts create mode 100644 src/data/types/feature.ts create mode 100644 src/data/types/hook.ts create mode 100644 src/data/types/imageType.ts create mode 100644 src/data/types/language.ts create mode 100644 src/data/types/linkWidget.ts create mode 100644 src/data/types/orderReturnStatus.ts create mode 100644 src/data/types/searchAlias.ts create mode 100644 src/data/types/searchEngine.ts create mode 100644 src/data/types/seoPage.ts create mode 100644 src/data/types/shoppingCart.ts create mode 100644 src/data/types/sqlTable.ts create mode 100644 src/data/types/store.ts create mode 100644 src/data/types/supplier.ts create mode 100644 src/data/types/taxOption.ts diff --git a/src/data/demo/addresses.ts b/src/data/demo/addresses.ts new file mode 100644 index 00000000..1e38fc64 --- /dev/null +++ b/src/data/demo/addresses.ts @@ -0,0 +1,43 @@ +import FakerAddress from '@data/faker/address'; + +export default { + address_1: new FakerAddress({ + id: 1, + firstName: 'Anonymous', + lastName: 'Anonymous', + address: 'Anonymous', + postalCode: '00000', + city: 'Anonymous', + country: 'France', + }), + address_2: new FakerAddress({ + id: 2, + name: 'Mon adresse', + firstName: 'John', + lastName: 'DOE', + company: 'My Company', + address: '16, Main street', + secondAddress: '2nd floor', + postalCode: '75002', + city: 'Paris', + country: 'France', + phone: '0102030405', + }), + address_5: new FakerAddress({ + id: 5, + dni: '', + alias: 'My address', + firstName: 'John', + lastName: 'DOE', + company: 'My Company', + vatNumber: '', + address: '16, Main street', + secondAddress: '2nd floor', + postalCode: '33133', + city: 'Miami', + state: 'Florida', + country: 'United States', + phone: '0102030405', + other: '', + }), +}; diff --git a/src/data/demo/attributes.ts b/src/data/demo/attributes.ts new file mode 100644 index 00000000..f3dbabfa --- /dev/null +++ b/src/data/demo/attributes.ts @@ -0,0 +1,128 @@ +import AttributeData from '@data/faker/attribute'; +import AttributeValueData from '@data/faker/attributeValue'; + +export default { + size: new AttributeData({ + id: 1, + name: 'Size', + values: [ + // 0 : small + new AttributeValueData({ + id: 1, + value: 'S', + position: 1, + }), + // 1 : medium + new AttributeValueData({ + id: 1, + value: 'M', + position: 1, + }), + // 2 : large + new AttributeValueData({ + id: 1, + value: 'L', + position: 1, + }), + // 3 : xLarge + new AttributeValueData({ + id: 1, + value: 'XL', + position: 1, + }), + ], + position: 1, + }), + color: new AttributeData({ + id: 2, + name: 'Color', + values: [ + // 0 : grey + new AttributeValueData({ + id: 5, value: 'Grey', color: '#AAB2BD', position: 1, + }), + // 1 : taupe + new AttributeValueData({ + id: 6, value: 'Taupe', color: '#CFC4A6', position: 2, + }), + // 2 : beige + new AttributeValueData({ + id: 7, value: 'Beige', color: '#f5f5dc', position: 3, + }), + // 3 : white + new AttributeValueData({ + id: 8, value: 'White', color: '#ffffff', position: 4, + }), + // 4 : offWhite + new AttributeValueData({ + id: 9, value: 'Off White', color: '#faebd7', position: 5, + }), + // 5 : red + new AttributeValueData({ + id: 10, value: 'Red', color: '#E84C3D', position: 6, + }), + // 6 : black + new AttributeValueData({ + id: 11, value: 'Black', color: '#434A54', position: 7, + }), + // 7 : camel + new AttributeValueData({ + id: 12, value: 'Camel', color: '#C19A6B', position: 8, + }), + // 8 : orange + new AttributeValueData({ + id: 13, value: 'Orange', color: '#F39C11', position: 9, + }), + // 9 : blue + new AttributeValueData({ + id: 14, value: 'Blue', color: '#5D9CEC', position: 10, + }), + // 10 : green + new AttributeValueData({ + id: 15, value: 'Green', color: '#A0D468', position: 11, + }), + // 11 : yellow + new AttributeValueData({ + id: 16, value: 'Yellow', color: '#F1C40F', position: 12, + }), + // 12 : brown + new AttributeValueData({ + id: 17, value: 'Brown', color: '#964B00', position: 13, + }), + // 13 : pink + new AttributeValueData({ + id: 18, value: 'Pink', color: '#FCCACD', position: 14, + }), + ], + position: 2, + }), + dimension: new AttributeData({ + id: 3, + name: 'Dimension', + values: [ + // 0 : first + new AttributeValueData({id: 19, value: '40*60cm', position: 1}), + // 1 : second + new AttributeValueData({id: 20, value: '60*90cm', position: 2}), + // 2 : third + new AttributeValueData({id: 21, value: '80*120cm', position: 3}), + ], + position: 3, + }), + paperType: new AttributeData({ + id: 4, + name: 'Paper Type', + values: [ + // 0 : ruled + new AttributeValueData({id: 22, value: 'Rules', position: 1}), + // 1 : plain + new AttributeValueData({id: 23, value: 'Plain', position: 2}), + // 2 : squared + new AttributeValueData({id: 24, value: 'Squared', position: 3}), + // 3 : doted + new AttributeValueData({id: 25, value: 'Doted', position: 4}), + ], + position: 4, + displayed: true, + }), +}; diff --git a/src/data/demo/boPages.ts b/src/data/demo/boPages.ts new file mode 100644 index 00000000..e58be625 --- /dev/null +++ b/src/data/demo/boPages.ts @@ -0,0 +1,7 @@ +export default { + pages: [ + 'Dashboard', + 'Orders', + 'Products', + ], +}; diff --git a/src/data/demo/brandAdresses.ts b/src/data/demo/brandAdresses.ts new file mode 100644 index 00000000..a9a6aee2 --- /dev/null +++ b/src/data/demo/brandAdresses.ts @@ -0,0 +1,22 @@ +import BrandAddressData from '@data/faker/brandAddress'; + +export default { + brandAddress_3: new BrandAddressData({ + id: 3, + brandName: '', + firstName: 'supplier', + lastName: 'supplier', + postalCode: '10153', + city: 'New York', + country: 'United States', + }), + brandAddress_4: new BrandAddressData({ + id: 4, + brandName: 'Studio Design', + firstName: 'manufacturer', + lastName: 'manufacturer', + postalCode: '10154', + city: 'New York', + country: 'United States', + }), +}; diff --git a/src/data/demo/brands.ts b/src/data/demo/brands.ts new file mode 100644 index 00000000..0a3e3893 --- /dev/null +++ b/src/data/demo/brands.ts @@ -0,0 +1,18 @@ +import BrandData from '@data/faker/brand'; + +export default { + brand_1: new BrandData({ + id: 1, + name: 'Studio Design', + addresses: 1, + products: 9, + enabled: true, + }), + brand_2: new BrandData({ + id: 2, + name: 'Graphic Corner', + addresses: 0, + products: 9, + enabled: true, + }), +}; diff --git a/src/data/demo/carriers.ts b/src/data/demo/carriers.ts new file mode 100644 index 00000000..75031b70 --- /dev/null +++ b/src/data/demo/carriers.ts @@ -0,0 +1,39 @@ +import FakerCarrier from '@data/faker/carrier'; + +export default { + clickAndCollect: new FakerCarrier({ + id: 1, + name: 'Click and collect', + delay: 'Pick up in-store', + enable: true, + freeShipping: true, + position: 1, + }), + myCarrier: new FakerCarrier({ + id: 2, + name: 'My carrier', + delay: 'Delivery next day!', + priceTTC: 8.40, + price: 7.00, + enable: true, + freeShipping: false, + position: 2, + }), + myCheapCarrier: new FakerCarrier({ + id: 3, + name: 'My cheap carrier', + delay: 'Buy more to pay less!', + enable: false, + freeShipping: false, + priceTTC: 6.00, + position: 3, + }), + myLightCarrier: new FakerCarrier({ + id: 4, + name: 'My light carrier', + delay: 'The lighter the cheaper!', + enable: false, + freeShipping: false, + position: 4, + }), +}; diff --git a/src/data/demo/cmsPage.ts b/src/data/demo/cmsPage.ts new file mode 100644 index 00000000..313b62ff --- /dev/null +++ b/src/data/demo/cmsPage.ts @@ -0,0 +1,44 @@ +import FakerCMSPage from '@data/faker/cmsPage'; + +export default { + delivery: new FakerCMSPage({ + id: 1, + url: 'delivery', + title: 'Delivery', + metaTitle: '', + position: 1, + displayed: true, + }), + legalNotice: new FakerCMSPage({ + id: 2, + url: 'legal-notice', + title: 'Legal Notice', + metaTitle: '', + position: 2, + displayed: true, + }), + termsAndCondition: new FakerCMSPage({ + id: 3, + url: 'terms-and-conditions-of-use', + title: 'Terms and conditions of use', + metaTitle: '', + position: 3, + displayed: true, + }), + aboutUs: new FakerCMSPage({ + id: 4, + url: 'about-us', + title: 'About us', + metaTitle: '', + position: 4, + displayed: true, + }), + securePayment: new FakerCMSPage({ + id: 5, + url: 'secure-payment', + title: 'Secure payment', + metaTitle: '', + position: 5, + displayed: true, + }), +}; diff --git a/src/data/demo/contacts.ts b/src/data/demo/contacts.ts new file mode 100644 index 00000000..66c8a14a --- /dev/null +++ b/src/data/demo/contacts.ts @@ -0,0 +1,16 @@ +import FakerContact from '@data/faker/contact'; + +export default { + webmaster: new FakerContact({ + id: 1, + title: 'Webmaster', + email: 'demo@prestashop.com', + description: 'If a technical problem occurs on this website', + }), + customerService: new FakerContact({ + id: 2, + title: 'Customer service', + email: 'demo@prestashop.com', + description: 'For any question about a product, an order', + }), +}; diff --git a/src/data/demo/employeeRoles.ts b/src/data/demo/employeeRoles.ts new file mode 100644 index 00000000..298ea5db --- /dev/null +++ b/src/data/demo/employeeRoles.ts @@ -0,0 +1,16 @@ +import FakerEmployeeRole from '@data/faker/employeeRole'; + +export default [ + new FakerEmployeeRole({ + name: 'SuperAdmin', + }), + new FakerEmployeeRole({ + name: 'Logistician', + }), + new FakerEmployeeRole({ + name: 'Translator', + }), + new FakerEmployeeRole({ + name: 'Salesman', + }), +]; diff --git a/src/data/demo/employees.ts b/src/data/demo/employees.ts new file mode 100644 index 00000000..c2302130 --- /dev/null +++ b/src/data/demo/employees.ts @@ -0,0 +1,14 @@ +import FakerEmployee from '@data/faker/employee'; + +export default { + defaultEmployee: new FakerEmployee({ + id: 1, + firstName: global.BO.FIRSTNAME, + lastName: global.BO.LASTNAME, + email: global.BO.EMAIL, + password: global.BO.PASSWD, + defaultPage: 'Dashboard', + language: 'English (English)', + active: true, + }), +}; diff --git a/src/data/demo/features.ts b/src/data/demo/features.ts new file mode 100644 index 00000000..f915a2be --- /dev/null +++ b/src/data/demo/features.ts @@ -0,0 +1,42 @@ +import FakerFeature from '@data/faker/feature'; +import FakerFeatureValue from '@data/faker/featureValue'; + +export default { + composition: new FakerFeature({ + id: 1, + position: 1, + name: 'Composition', + values: [ + new FakerFeatureValue({ + id: 1, + value: 'Polyester', + }), + new FakerFeatureValue({ + id: 2, + value: 'Wool', + }), + new FakerFeatureValue({ + id: 3, + value: 'Ceramic', + }), + new FakerFeatureValue({ + id: 4, + value: 'Cotton', + }), + new FakerFeatureValue({ + id: 5, + value: 'Recycled cardboard', + }), + new FakerFeatureValue({ + id: 6, + value: 'Matt paper', + }), + ], + }), + property: new FakerFeature({ + id: 2, + position: 2, + name: 'Property', + values: [], + }), +}; diff --git a/src/data/demo/hooks.ts b/src/data/demo/hooks.ts new file mode 100644 index 00000000..45ada5d3 --- /dev/null +++ b/src/data/demo/hooks.ts @@ -0,0 +1,8 @@ +import FakerHook from '@data/faker/hook'; + +export default { + displayFooter: new FakerHook({ + id: 37, + name: 'displayFooter', + }), +}; diff --git a/src/data/demo/imageTypes.ts b/src/data/demo/imageTypes.ts new file mode 100644 index 00000000..60ba516b --- /dev/null +++ b/src/data/demo/imageTypes.ts @@ -0,0 +1,26 @@ +import FakerImageType from '@data/faker/imageType'; + +export default { + imageType_1: new FakerImageType({ + id: 1, + name: 'cart_default', + width: 125, + height: 125, + productsStatus: true, + categoriesStatus: false, + manufacturersStatus: false, + suppliersStatus: false, + storesStatus: false, + }), + imageType_2: new FakerImageType({ + id: 2, + name: 'small_default', + width: 98, + height: 98, + productsStatus: true, + categoriesStatus: true, + manufacturersStatus: true, + suppliersStatus: true, + storesStatus: false, + }), +}; diff --git a/src/data/demo/languages.ts b/src/data/demo/languages.ts new file mode 100644 index 00000000..3ae35e72 --- /dev/null +++ b/src/data/demo/languages.ts @@ -0,0 +1,123 @@ +import FakerLanguage from '@data/faker/language'; + +export default { + english: new FakerLanguage({ + id: 1, + name: 'English (English)', + isoCode: 'en', + languageCode: 'en-us', + dateFormat: 'm/d/Y', + fullDateFormat: 'm/d/Y H:i:s', + isRtl: false, + enabled: true, + }), + french: new FakerLanguage({ + id: 2, + name: 'Français (French)', + isoCode: 'fr', + languageCode: 'fr', + dateFormat: 'd/m/Y', + fullDateFormat: 'd/m/Y H:i:s', + isRtl: false, + enabled: true, + }), + spanish: new FakerLanguage({ + name: 'Español (Spanish)', + isoCode: 'es', + languageCode: 'es-es', + dateFormat: 'd/m/Y', + fullDateFormat: 'd/m/Y H:i:s', + flag: 'flag.png', + noPicture: 'noPicture.png', + isRtl: false, + enabled: true, + }), + deutsch: new FakerLanguage({ + name: 'Deutsch (German)', + isoCode: 'de', + languageCode: 'de-de', + dateFormat: 'd.m.Y', + fullDateFormat: 'd.m.Y H:i:s', + flag: 'flag.png', + noPicture: 'noPicture.png', + isRtl: false, + enabled: true, + }), + turkish: new FakerLanguage({ + name: 'Türkçe (Turkish)', + isoCode: 'tr', + languageCode: 'tr-tr', + dateFormat: 'Y-m-d', + fullDateFormat: 'Y-m-d H:i:s', + flag: 'flag.png', + noPicture: 'noPicture.png', + isRtl: false, + enabled: true, + }), + spanishAR: new FakerLanguage({ + name: 'Español AR (Spanish)', + isoCode: 'ag', + languageCode: 'es-ar', + dateFormat: 'Y-m-d', + fullDateFormat: 'Y-m-d H:i:s', + flag: 'flag.png', + noPicture: 'noPicture.png', + isRtl: false, + enabled: true, + }), + dutch: new FakerLanguage({ + name: 'Nederlands (Dutch)', + isoCode: 'nl', + languageCode: 'nl-nl', + dateFormat: 'd-m-Y', + fullDateFormat: 'd-m-Y H:i:s', + flag: 'flag.png', + noPicture: 'noPicture.png', + isRtl: false, + enabled: true, + }), + portuguese: new FakerLanguage({ + name: 'Português BR (Portuguese)', + isoCode: 'br', + languageCode: 'pt-br', + dateFormat: 'Y-m-d', + fullDateFormat: 'Y-m-d H:i:s', + flag: 'flag.png', + noPicture: 'noPicture.png', + isRtl: false, + enabled: true, + }), + croatian: new FakerLanguage({ + name: 'Hrvatski (Croatian)', + isoCode: 'hr', + languageCode: 'hr-hr', + dateFormat: 'Y-m-d', + fullDateFormat: 'Y-m-d H:i:s', + flag: 'flag.png', + noPicture: 'noPicture.png', + isRtl: false, + enabled: true, + }), + simplifiedChinese: new FakerLanguage({ + name: '中文 (Simplified Chinese)', + isoCode: 'zh', + languageCode: 'zh-cn', + dateFormat: 'Y-m-d', + fullDateFormat: 'Y-m-d H:i:s', + flag: 'flag.png', + noPicture: 'noPicture.png', + isRtl: false, + enabled: true, + }), + traditionalChinese: new FakerLanguage({ + name: '繁體中文 (Traditional Chinese)', + isoCode: 'tw', + languageCode: 'zh-tw', + dateFormat: 'Y-m-d', + fullDateFormat: 'Y-m-d H:i:s', + flag: 'flag.png', + noPicture: 'noPicture.png', + isRtl: false, + enabled: true, + }), +}; diff --git a/src/data/demo/linkWidgets.ts b/src/data/demo/linkWidgets.ts new file mode 100644 index 00000000..4eaf0ae9 --- /dev/null +++ b/src/data/demo/linkWidgets.ts @@ -0,0 +1,19 @@ +import FakerLinkWidget from '@data/faker/linkWidget'; +import dataHooks from '@data/demo/hooks'; + +export default { + demo_1: new FakerLinkWidget({ + name: 'Footer test block', + frName: 'Footer test block', + hook: dataHooks.displayFooter, + contentPages: ['Delivery'], + productsPages: ['New products'], + staticPages: ['Contact us'], + customPages: [ + { + name: 'Home in footer', + url: global.FO.URL, + }, + ], + }), +}; diff --git a/src/data/demo/moduleCategories.ts b/src/data/demo/moduleCategories.ts new file mode 100644 index 00000000..7b0362d2 --- /dev/null +++ b/src/data/demo/moduleCategories.ts @@ -0,0 +1,8 @@ +export default [ + 'Administration', + 'Design & Navigation', + 'Promotions & Marketing', + 'Payment', + 'Traffic & Marketplaces', + 'Theme modules', +]; diff --git a/src/data/demo/modules.ts b/src/data/demo/modules.ts index f4008b56..132daffd 100644 --- a/src/data/demo/modules.ts +++ b/src/data/demo/modules.ts @@ -17,6 +17,10 @@ export default { tag: 'ps_cashondelivery', name: 'Cash on delivery (COD)', }), + psCategoryProducts: new FakerModule({ + tag: 'ps_categoryproducts', + name: 'Products in the same category', + }), psCheckPayment: new FakerModule({ tag: 'ps_checkpayment', name: 'Payments by check', @@ -24,7 +28,7 @@ export default { psEmailAlerts: new FakerModule({ tag: 'ps_emailalerts', name: 'Mail alerts', - releaseZip: 'https://github.com/PrestaShop/ps_emailalerts/releases/download/v2.4.2/ps_emailalerts.zip', + releaseZip: 'https://github.com/PrestaShop/ps_emailalerts/releases/download/v3.0.0/ps_emailalerts.zip', }), psEmailSubscription: new FakerModule({ tag: 'ps_emailsubscription', @@ -33,11 +37,20 @@ export default { psFacetedSearch: new FakerModule({ tag: 'ps_facetedsearch', name: 'Faceted search', - releaseZip: 'https://github.com/PrestaShop/ps_facetedsearch/releases/download/v3.14.1/ps_facetedsearch.zip', + releaseZip: 'https://github.com/PrestaShop/ps_facetedsearch/releases/download/v3.15.1/ps_facetedsearch.zip', + }), + psGdpr: new FakerModule({ + tag: 'psgdpr', + name: 'Official GDPR compliance', + }), + psNewProducts: new FakerModule({ + tag: 'ps_newproducts', + name: 'New products', }), psThemeCusto: new FakerModule({ tag: 'ps_themecusto', name: 'Theme Customization', + releaseZip: 'https://github.com/PrestaShop/ps_themecusto/releases/download/v1.2.4/ps_themecusto.zip', }), contactForm: new FakerModule({ tag: 'contactform', @@ -58,6 +71,6 @@ export default { keycloak: new FakerModule({ tag: 'keycloak_connector_demo', name: 'Keycloak OAuth2 connector demo', - releaseZip: 'https://github.com/PrestaShop/keycloak_connector_demo/releases/download/v1.0.4/keycloak_connector_demo.zip', + releaseZip: 'https://github.com/PrestaShop/keycloak_connector_demo/releases/download/v1.1.0/keycloak_connector_demo.zip', }), }; diff --git a/src/data/demo/orderReturnStatuses.ts b/src/data/demo/orderReturnStatuses.ts new file mode 100644 index 00000000..1badbb01 --- /dev/null +++ b/src/data/demo/orderReturnStatuses.ts @@ -0,0 +1,24 @@ +import FakerOrderReturnStatus from '@data/faker/orderReturnStatus'; + +export default { + waitingForConfirmation: new FakerOrderReturnStatus({ + id: 1, + name: 'Waiting for confirmation', + }), + waitingForPackage: new FakerOrderReturnStatus({ + id: 2, + name: 'Waiting for package', + }), + packageReceived: new FakerOrderReturnStatus({ + id: 3, + name: 'Package received', + }), + returnDenied: new FakerOrderReturnStatus({ + id: 4, + name: 'Return denied', + }), + returnCompleted: new FakerOrderReturnStatus({ + id: 5, + name: 'Return completed', + }), +}; diff --git a/src/data/demo/searchAliases.ts b/src/data/demo/searchAliases.ts new file mode 100644 index 00000000..163588e3 --- /dev/null +++ b/src/data/demo/searchAliases.ts @@ -0,0 +1,12 @@ +import FakerSearchAlias from '@data/faker/searchAlias'; + +export default { + bloose: new FakerSearchAlias({ + alias: 'bloose', + result: 'blouse', + }), + blues: new FakerSearchAlias({ + alias: 'blues', + result: 'blouse', + }), +}; diff --git a/src/data/demo/searchEngines.ts b/src/data/demo/searchEngines.ts new file mode 100644 index 00000000..e44a2c67 --- /dev/null +++ b/src/data/demo/searchEngines.ts @@ -0,0 +1,19 @@ +import FakerSearchEngine from '@data/faker/searchEngine'; + +export default { + google: new FakerSearchEngine({ + id: 1, + server: 'google', + queryKey: 'q', + }), + lycos: new FakerSearchEngine({ + id: 8, + server: 'lycos', + queryKey: 'query', + }), + voila: new FakerSearchEngine({ + id: 11, + server: 'voila', + queryKey: 'rdata', + }), +}; diff --git a/src/data/demo/seoPages.ts b/src/data/demo/seoPages.ts new file mode 100644 index 00000000..9cafcd4d --- /dev/null +++ b/src/data/demo/seoPages.ts @@ -0,0 +1,32 @@ +import FakerSeoPage from '@data/faker/seoPage'; + +export default { + pageNotFound: new FakerSeoPage({ + id: 1, + page: 'pagenotfound', + title: '404 error', + friendlyUrl: 'page-not-found', + }), + best_sales: new FakerSeoPage({ + id: 2, + page: 'best-sales', + title: 'Best sales', + friendlyUrl: 'best-sales', + }), + contact: new FakerSeoPage({ + id: 3, + page: 'contact', + title: 'Contact us', + friendlyUrl: 'contact-us', + }), + orderReturn: new FakerSeoPage({ + page: 'order-return', + title: 'Order return', + friendlyUrl: 'order-return', + }), + pdfOrderReturn: new FakerSeoPage({ + page: 'pdf-order-return', + title: 'Pdf order return', + friendlyUrl: 'pdf-order-return', + }), +}; diff --git a/src/data/demo/shoppingCarts.ts b/src/data/demo/shoppingCarts.ts new file mode 100644 index 00000000..72c1d023 --- /dev/null +++ b/src/data/demo/shoppingCarts.ts @@ -0,0 +1,41 @@ +import dataCarriers from '@data/demo/carriers'; +import dataCustomers from '@data/demo/customers'; +import FakerShoppingCart from '@data/faker/shoppingCart'; + +export default [ + new FakerShoppingCart({ + id: 1, + orderID: 1, + customer: dataCustomers.johnDoe, + carrier: dataCarriers.myCarrier, + online: false, + }), + new FakerShoppingCart({ + id: 2, + orderID: 2, + customer: dataCustomers.johnDoe, + carrier: dataCarriers.myCarrier, + online: false, + }), + new FakerShoppingCart({ + id: 3, + orderID: 3, + customer: dataCustomers.johnDoe, + carrier: dataCarriers.myCarrier, + online: false, + }), + new FakerShoppingCart({ + id: 4, + orderID: 4, + customer: dataCustomers.johnDoe, + carrier: dataCarriers.myCarrier, + online: false, + }), + new FakerShoppingCart({ + id: 5, + orderID: 5, + customer: dataCustomers.johnDoe, + carrier: dataCarriers.myCarrier, + online: false, + }), +]; diff --git a/src/data/demo/sqlTables.ts b/src/data/demo/sqlTables.ts new file mode 100644 index 00000000..8a0a1859 --- /dev/null +++ b/src/data/demo/sqlTables.ts @@ -0,0 +1,20 @@ +import FakerSqlTable from '@data/faker/sqlTable'; + +export default { + ps_access: new FakerSqlTable({ + name: 'ps_access', + columns: [ + 'id_profile', + 'id_authorization_role', + ], + }), + ps_alias: new FakerSqlTable({ + name: 'ps_alias', + columns: [ + 'id_alias', + 'alias', + 'search', + 'active', + ], + }), +}; diff --git a/src/data/demo/stores.ts b/src/data/demo/stores.ts new file mode 100644 index 00000000..fb185e5c --- /dev/null +++ b/src/data/demo/stores.ts @@ -0,0 +1,42 @@ +import FakerStore from '@data/faker/store'; + +export default { + store_1: new FakerStore({ + id: 1, + name: 'Dade County', + address1: '3030 SW 8th St Miami', + address2: '', + postcode: '33135', + city: 'Miami', + country: 'United States', + state: 'Florida', + phone: '', + fax: '', + status: true, + }), + store_2: new FakerStore({ + id: 2, + name: 'E Fort Lauderdale', + address1: '1000 Northeast 4th Ave Fort Lauderdale', + address2: '', + postcode: ' 33304', + city: 'Miami', + country: 'United States', + state: 'Florida', + phone: '', + fax: '', + status: true, + }), + contact: new FakerStore({ + name: global.INSTALL.SHOP_NAME, + email: global.BO.EMAIL, + registrationNumber: ' ', + address1: '', + address2: '', + postcode: '', + city: '', + country: 'France', + phone: '', + fax: '', + }), +}; diff --git a/src/data/demo/suppliers.ts b/src/data/demo/suppliers.ts new file mode 100644 index 00000000..a0894e51 --- /dev/null +++ b/src/data/demo/suppliers.ts @@ -0,0 +1,16 @@ +import FakerSupplier from '@data/faker/supplier'; + +export default { + fashion: new FakerSupplier({ + id: 1, + name: 'Fashion supplier', + products: 17, + enabled: true, + }), + accessories: new FakerSupplier({ + id: 2, + name: 'Accessories supplier', + products: 5, + enabled: true, + }), +}; diff --git a/src/data/demo/taxOptions.ts b/src/data/demo/taxOptions.ts new file mode 100644 index 00000000..e5476732 --- /dev/null +++ b/src/data/demo/taxOptions.ts @@ -0,0 +1,93 @@ +import FakerTaxOption from '@data/faker/taxOption'; + +export default [ + new FakerTaxOption({ + enabled: true, + displayInShoppingCart: false, + basedOn: 'Delivery address', + useEcoTax: true, + }), + new FakerTaxOption({ + enabled: true, + displayInShoppingCart: false, + basedOn: 'Delivery address', + useEcoTax: true, + ecoTax: 'EU VAT For Virtual Products', + }), + new FakerTaxOption({ + enabled: true, + displayInShoppingCart: false, + basedOn: 'Delivery address', + useEcoTax: true, + ecoTax: 'FR Taux réduit (10%)', + }), + new FakerTaxOption({ + enabled: true, + displayInShoppingCart: false, + basedOn: 'Delivery address', + useEcoTax: true, + ecoTax: 'FR Taux réduit (5.5%)', + }), + new FakerTaxOption({ + enabled: true, + displayInShoppingCart: false, + basedOn: 'Delivery address', + useEcoTax: true, + ecoTax: 'FR Taux standard (20%)', + }), + new FakerTaxOption({ + enabled: true, + displayInShoppingCart: false, + basedOn: 'Delivery address', + useEcoTax: true, + ecoTax: 'FR Taux super réduit (2.1%)', + }), + new FakerTaxOption({ + enabled: true, + displayInShoppingCart: false, + basedOn: 'Invoice address', + useEcoTax: true, + ecoTax: 'EU VAT For Virtual Products', + }), + new FakerTaxOption({ + enabled: true, + displayInShoppingCart: false, + basedOn: 'Invoice address', + useEcoTax: true, + ecoTax: 'FR Taux réduit (10%)', + }), + new FakerTaxOption({ + enabled: true, + displayInShoppingCart: false, + basedOn: 'Invoice address', + useEcoTax: true, + ecoTax: 'FR Taux réduit (5.5%)', + }), + new FakerTaxOption({ + enabled: true, + displayInShoppingCart: false, + basedOn: 'Invoice address', + useEcoTax: true, + ecoTax: 'FR Taux standard (20%)', + }), + new FakerTaxOption({ + enabled: true, + displayInShoppingCart: false, + basedOn: 'Invoice address', + useEcoTax: true, + ecoTax: 'FR Taux super réduit (2.1%)', + }), + new FakerTaxOption({ + enabled: true, + displayInShoppingCart: false, + basedOn: 'Invoice address', + useEcoTax: true, + ecoTax: 'No tax', + }), + new FakerTaxOption({ + enabled: true, + displayInShoppingCart: false, + basedOn: 'Delivery address', + useEcoTax: false, + }), +]; diff --git a/src/data/faker/attribute.ts b/src/data/faker/attribute.ts new file mode 100644 index 00000000..b464535c --- /dev/null +++ b/src/data/faker/attribute.ts @@ -0,0 +1,68 @@ +import FakerAttributeValue from '@data/faker/attributeValue'; +import {type AttributeCreator} from '@data/types/attribute'; + +import {faker} from '@faker-js/faker'; + +const attributeTypes: string[] = ['Drop-down list', 'Radio buttons', 'Color or texture']; + +/** + * Create new attribute to use on attribute form on BO + * @class + */ +export default class FakerAttribute { + public readonly id: number; + + public readonly position: number; + + public readonly name: string; + + public readonly publicName: string; + + public readonly url: string; + + public readonly metaTitle: string; + + public readonly indexable: boolean; + + public readonly displayed: boolean; + + public readonly attributeType: string; + + public readonly values: FakerAttributeValue[]; + + /** + * Constructor for class AttributeData + * @param attributeToCreate {Object} Could be used to force the value of some members + */ + constructor(attributeToCreate: AttributeCreator = {}) { + /** @type {number} ID of the attribute */ + this.id = attributeToCreate.id || 0; + + /** @type {number} Position of the attribute */ + this.position = attributeToCreate.position || 0; + + /** @type {string} Name of the attribute */ + this.name = attributeToCreate.name || `${faker.lorem.word()}${faker.commerce.productMaterial()}`; + + /** @type {string} Public name of the attribute */ + this.publicName = attributeToCreate.publicName || this.name; + + /** @type {string} Name used on the attribute URL */ + this.url = attributeToCreate.url || this.name.replace(/\s/gi, '-'); + + /** @type {string} Attribute meta title */ + this.metaTitle = attributeToCreate.metaTitle || faker.lorem.word(); + + /** @type {boolean} True for the attribute to be indexed */ + this.indexable = attributeToCreate.indexable === undefined ? true : attributeToCreate.indexable; + + /** @type {boolean} True for the attribute to be displayed */ + this.displayed = attributeToCreate.displayed === undefined ? true : attributeToCreate.displayed; + + /** @type {string} Type of the attribute 'Drop-down list'/'Radio buttons'/'Color or texture' */ + this.attributeType = attributeToCreate.attributeType || faker.helpers.arrayElement(attributeTypes); + + /** @type {FakerAttributeValue[]} */ + this.values = attributeToCreate.values || []; + } +} diff --git a/src/data/faker/attributeValue.ts b/src/data/faker/attributeValue.ts new file mode 100644 index 00000000..6f2b213c --- /dev/null +++ b/src/data/faker/attributeValue.ts @@ -0,0 +1,66 @@ +import {AttributeValueCreator} from '@data/types/attribute'; + +import {faker} from '@faker-js/faker'; + +const attributesNames: string[] = ['Size', 'Color', 'Dimension', 'Paper Type']; + +/** + * Create new attribute value to use on attribute value form on BO + * @class + */ +export default class FakerAttributeValue { + public readonly id: number; + + public readonly position: number; + + public attributeID: number; + + public readonly attributeName: string; + + public readonly value: string; + + public readonly url: string; + + public readonly metaTitle: string; + + public readonly color: string; + + public readonly textureFileName: string; + + /** + * Constructor for class ValueData + * @param valueToCreate {Object} Could be used to force the value of some members + */ + constructor(valueToCreate: AttributeValueCreator = {}) { + /** @type {number} ID */ + this.id = valueToCreate.id || 0; + + /** @type {number} Position */ + this.position = valueToCreate.position || 0; + + /** @type {number} ID of the parent attribute */ + this.attributeID = valueToCreate.attributeID || 0; + + /** @type {string} Name of the parent attribute */ + this.attributeName = valueToCreate.attributeName || faker.helpers.arrayElement(attributesNames); + + /** @type {string} Name of the value */ + this.value = valueToCreate.value || `${faker.lorem.word()}${faker.commerce.productMaterial()}`; + + /** @type {string} Name used on the value URL */ + this.url = valueToCreate.url || this.value.replace(/\s/gi, '-'); + + /** @type {string} Attribute value meta title */ + this.metaTitle = valueToCreate.metaTitle || faker.lorem.word(); + + /** @type {string} if the attribute type is color, hexadecimal value of the color */ + this.color = valueToCreate.color || faker.internet.color(); + + /** @type {string} if the attribute type is texture, filename of the texture */ + this.textureFileName = valueToCreate.textureFileName || faker.system.commonFileName('txt'); + } + + setAttributeId(attributeId: number): void { + this.attributeID = attributeId; + } +} diff --git a/src/data/faker/brand.ts b/src/data/faker/brand.ts new file mode 100644 index 00000000..e8675859 --- /dev/null +++ b/src/data/faker/brand.ts @@ -0,0 +1,95 @@ +import type BrandCreator from '@data/types/brand'; + +import {faker} from '@faker-js/faker'; + +/** + * Create new brand to use in brand form on BO + * @class + */ +export default class FakerBrand { + public readonly id: number; + + public readonly name: string; + + public readonly logo: string; + + public readonly shortDescription: string; + + public readonly shortDescriptionFr: string; + + public readonly description: string; + + public readonly descriptionFr: string; + + public readonly metaTitle: string; + + public readonly metaTitleFr: string; + + public readonly metaDescription: string; + + public readonly metaDescriptionFr: string; + + public readonly metaKeywords: string[]; + + public readonly metaKeywordsFr: string[]; + + public readonly enabled: boolean; + + public addresses: number; + + public readonly products: number; + + /** + * Constructor for class BrandData + * @param brandToCreate {BrandCreator} Could be used to force the value of some members + */ + constructor(brandToCreate: BrandCreator = {}) { + /** @type {number} ID of the brand */ + this.id = brandToCreate.id || 0; + + /** @type {string} Name of the brand */ + this.name = brandToCreate.name || faker.company.name(); + + /** @type {string} Logo name of the brand */ + this.logo = brandToCreate.logo || `${this.name.replace(/[^\w\s]/gi, '')}.png`; + + /** @type {string} Short description of the brand */ + this.shortDescription = brandToCreate.shortDescription || faker.lorem.sentence(); + + /** @type {string} French short description of the brand */ + this.shortDescriptionFr = brandToCreate.shortDescriptionFr || this.shortDescription; + + /** @type {string} Description of the brand */ + this.description = brandToCreate.description || faker.lorem.sentence(); + + /** @type {string} French description of the brand */ + this.descriptionFr = brandToCreate.descriptionFr || this.description; + + /** @type {string} Meta title of the brand */ + this.metaTitle = brandToCreate.metaTitle || this.name; + + /** @type {string} French meta title of the brand */ + this.metaTitleFr = brandToCreate.metaTitleFr || this.metaTitle; + + /** @type {string} Meta description of the brand */ + this.metaDescription = brandToCreate.metaDescription || faker.lorem.sentence(); + + /** @type {string} French meta description of the brand */ + this.metaDescriptionFr = brandToCreate.metaDescriptionFr || this.metaDescription; + + /** @type {Array} Meta Keywords of the brand */ + this.metaKeywords = brandToCreate.metaKeywords || [faker.lorem.word(), faker.lorem.word()]; + + /** @type {Array} French meta keywords of the brand */ + this.metaKeywordsFr = brandToCreate.metaKeywordsFr || this.metaKeywords; + + /** @type {boolean} Status of the brand */ + this.enabled = brandToCreate.enabled === undefined ? true : brandToCreate.enabled; + + /** @type {number} How much addresses has the brand */ + this.addresses = brandToCreate.addresses || 0; + + /** @type {number} How much products has the brand */ + this.products = brandToCreate.products || 0; + } +} diff --git a/src/data/faker/brandAddress.ts b/src/data/faker/brandAddress.ts new file mode 100644 index 00000000..d15540f6 --- /dev/null +++ b/src/data/faker/brandAddress.ts @@ -0,0 +1,79 @@ +import type BrandAddressCreator from '@data/types/brandAddress'; +import dataCountries from '@data/demo/countries'; +import type FakerCountry from '@data/faker/country'; + +import {fakerFR as faker} from '@faker-js/faker'; + +const countriesNames: string[] = Object.values(dataCountries).map((country: FakerCountry) => country.name); + +/** + * Create new brand address to use in brand address form on BO + * @class + */ +export default class BrandAddressData { + public readonly id: number; + + public readonly brandName: string; + + public readonly firstName: string; + + public readonly lastName: string; + + public readonly address: string; + + public readonly secondaryAddress: string; + + public readonly postalCode: string; + + public readonly city: string; + + public readonly country: string; + + public readonly homePhone: string; + + public readonly mobilePhone: string; + + public readonly other: string; + + /** + * Constructor for class brandAddressData + * @param brandAddressToCreate {BrandAddressCreator} Could be used to force the value of some members + */ + constructor(brandAddressToCreate: BrandAddressCreator = {}) { + /** @type {number} ID */ + this.id = brandAddressToCreate.id || 0; + + /** @type {string} Associated brand to the address */ + this.brandName = brandAddressToCreate.brandName || '--'; + + /** @type {string} Linked address firstname */ + this.firstName = brandAddressToCreate.firstName || faker.person.firstName(); + + /** @type {string} Linked address lastname */ + this.lastName = brandAddressToCreate.lastName || faker.person.lastName(); + + /** @type {string} Address first line */ + this.address = brandAddressToCreate.address || faker.location.streetAddress(); + + /** @type {string} Address second line */ + this.secondaryAddress = brandAddressToCreate.secondaryAddress || faker.location.secondaryAddress(); + + /** @type {string} Address postal code (default to this format #####) */ + this.postalCode = brandAddressToCreate.postalCode || faker.location.zipCode(); + + /** @type {string} Address city name */ + this.city = brandAddressToCreate.city || faker.location.city(); + + /** @type {string} Address country name */ + this.country = brandAddressToCreate.country || faker.helpers.arrayElement(countriesNames); + + /** @type {string} Home phone number linked to the address */ + this.homePhone = brandAddressToCreate.homePhone || faker.phone.number(); + + /** @type {string} Mobile phone number linked to the address */ + this.mobilePhone = brandAddressToCreate.mobilePhone || faker.phone.number(); + + /** @type {string} Other information to add on address */ + this.other = brandAddressToCreate.other || ''; + } +} diff --git a/src/data/faker/cmsPage.ts b/src/data/faker/cmsPage.ts new file mode 100644 index 00000000..9e2cf6c4 --- /dev/null +++ b/src/data/faker/cmsPage.ts @@ -0,0 +1,65 @@ +import CmsPageCreator from '@data/types/cmsPage'; + +import {faker} from '@faker-js/faker'; + +/** + * Create new cms page to use on creation cms page form on BO + * @class + */ +export default class FakerCMSPage { + public readonly id: number; + + public readonly title: string; + + public readonly metaTitle: string; + + public readonly metaDescription: string; + + public readonly metaKeywords: string; + + public readonly content: string; + + public readonly url: string; + + public readonly displayed: boolean; + + public readonly position: number; + + public readonly indexation: boolean; + + /** + * Constructor for class CMSPageData + * @param pageToCreate {CmsPageCreator} Could be used to force the value of some members + */ + constructor(pageToCreate: CmsPageCreator = {}) { + /** @type {number} ID of the page */ + this.id = pageToCreate.id || 0; + + /** @type {string} Title of the page */ + this.title = pageToCreate.title || faker.lorem.word(); + + /** @type {string} Meta title of the page */ + this.metaTitle = pageToCreate.metaTitle || faker.lorem.word(); + + /** @type {string} Meta description for the page */ + this.metaDescription = pageToCreate.metaDescription || faker.lorem.sentence(); + + /** @type {string} Meta keyword for the page */ + this.metaKeywords = pageToCreate.metaKeywords || faker.lorem.word(); + + /** @type {string} Content of the page */ + this.content = pageToCreate.content || faker.lorem.sentence(); + + /** @type {string} Meta title of the page */ + this.url = pageToCreate.url || ''; + + /** @type {boolean} True to display the page on FO */ + this.displayed = pageToCreate.displayed === undefined ? true : pageToCreate.displayed; + + /** @type {number} Position */ + this.position = pageToCreate.position === undefined ? 0 : pageToCreate.position; + + /** @type {boolean} True to index the page */ + this.indexation = pageToCreate.indexation === undefined ? true : pageToCreate.indexation; + } +} diff --git a/src/data/faker/contact.ts b/src/data/faker/contact.ts new file mode 100644 index 00000000..e871d577 --- /dev/null +++ b/src/data/faker/contact.ts @@ -0,0 +1,56 @@ +import ContactCreator from '@data/types/contact'; + +import {faker} from '@faker-js/faker'; + +/** + * Create new contact to use on creation contact form on BO + * @class + */ +export default class FakerContact { + public readonly id: number; + + public readonly firstName: string; + + public readonly lastName: string; + + public readonly title: string; + + public readonly email: string; + + public readonly saveMessage: boolean; + + public readonly description: string; + + /** + * Constructor for class ContactData + * @param contactToCreate {ContactCreator} Could be used to force the value of some members + */ + constructor(contactToCreate: ContactCreator = {}) { + /** @type {number} ID of the contact */ + this.id = contactToCreate.id || 0; + + /** @type {string} Firstname of the contact */ + this.firstName = contactToCreate.firstName || faker.person.firstName(); + + /** @type {string} Lastname of the contact */ + this.lastName = contactToCreate.lastName || faker.person.lastName(); + + /** @type {string} Title of the contact */ + this.title = contactToCreate.title || `${this.firstName} ${this.lastName}`; + + /** @type {string} Email of the contact */ + this.email = contactToCreate.email || faker.internet.email( + { + firstName: this.firstName, + lastName: this.lastName, + provider: 'prestashop.com', + }, + ); + + /** @type {boolean} True to save messages sent for the contact */ + this.saveMessage = contactToCreate.saveMessage === undefined ? true : contactToCreate.saveMessage; + + /** @type {string} Description of the contact */ + this.description = contactToCreate.description || faker.lorem.sentence(); + } +} diff --git a/src/data/faker/employee.ts b/src/data/faker/employee.ts new file mode 100644 index 00000000..cd8c5845 --- /dev/null +++ b/src/data/faker/employee.ts @@ -0,0 +1,85 @@ +import dataLanguages from '@data/demo/languages'; +import dataBOPages from '@data/demo/boPages'; +import dataEmployeeRoles from '@data/demo/employeeRoles'; +import FakerLanguage from '@data/faker/language'; +import FakerEmployeeRole from '@data/faker/employeeRole'; +import {type EmployeeCreator} from '@data/types/employee'; + +import {faker} from '@faker-js/faker'; + +const profileNames: string[] = Object.values(dataEmployeeRoles).map((profile: FakerEmployeeRole) => profile.name); +const languagesNames: string[] = Object.values(dataLanguages).map((lang: FakerLanguage) => lang.name); + +/** + * Create new employee to use on creation form on employee page on BO + * @class + */ +export default class FakerEmployee { + public readonly id: number; + + public firstName: string; + + public lastName: string; + + public email: string; + + public password: string; + + public defaultPage: string; + + public language: string; + + public readonly active: boolean; + + public readonly permissionProfile: string; + + public avatarFile: string|null; + + public enableGravatar: boolean; + + /** + * Constructor for class EmployeeData + * @param employeeToCreate {EmployeeCreator} Could be used to force the value of some members + */ + constructor(employeeToCreate: EmployeeCreator = {}) { + /** @type {number} Employee ID */ + this.id = employeeToCreate.id || 0; + + /** @type {string} Employee firstname */ + this.firstName = employeeToCreate.firstName || faker.person.firstName(); + + /** @type {string} Employee lastname */ + this.lastName = employeeToCreate.lastName || faker.person.lastName().replace('\'', ''); + + /** @type {string} Email of the employee */ + this.email = employeeToCreate.email || faker.internet.email( + { + firstName: this.firstName, + lastName: this.lastName, + provider: 'prestashop.com', + }, + ); + + /** @type {string} Password for the employee account */ + this.password = employeeToCreate.password || 'prestashop_demo'; + + /** @type {string} Default page where employee should access after login */ + this.defaultPage = employeeToCreate.defaultPage || faker.helpers.arrayElement(dataBOPages.pages); + + /** @type {string} Default BO language for the employee */ + this.language = employeeToCreate.language + || faker.helpers.arrayElement(languagesNames.slice(0, 2)); + + /** @type {boolean} Status of the employee */ + this.active = employeeToCreate.active === undefined ? true : employeeToCreate.active; + + /** @type {string} Permission profile to set on the employee */ + this.permissionProfile = employeeToCreate.permissionProfile || faker.helpers.arrayElement(profileNames); + + /** @type {string|null} Path of the avatar of the employee */ + this.avatarFile = employeeToCreate.avatarFile || null; + + /** @type {boolean} Enable Gravatar */ + this.enableGravatar = employeeToCreate.enableGravatar === undefined ? false : employeeToCreate.enableGravatar; + } +} diff --git a/src/data/faker/employeeRole.ts b/src/data/faker/employeeRole.ts new file mode 100644 index 00000000..941eadc3 --- /dev/null +++ b/src/data/faker/employeeRole.ts @@ -0,0 +1,20 @@ +import type EmployeeRoleCreator from '@data/types/employeeRole'; + +import {faker} from '@faker-js/faker'; + +/** + * Create new role to use on creation form on role page on BO + * @class + */ +export default class FakerEmployeeRole { + public readonly name: string; + + /** + * Constructor for class FakerEmployeeRole + * @param roleToCreate {EmployeeRoleCreator} Could be used to force the value of some members + */ + constructor(roleToCreate: EmployeeRoleCreator = {}) { + /** @type {string} Name of the profile */ + this.name = roleToCreate.name || faker.person.jobType(); + } +} diff --git a/src/data/faker/feature.ts b/src/data/faker/feature.ts new file mode 100644 index 00000000..83a267cb --- /dev/null +++ b/src/data/faker/feature.ts @@ -0,0 +1,51 @@ +import type FakerFeatureValue from '@data/faker/featureValue'; +import {type FeatureCreator} from '@data/types/feature'; + +import {faker} from '@faker-js/faker'; + +/** + * Create new feature to use on feature form on BO + * @class + */ +export default class FakerFeature { + public readonly id: number; + + public readonly position: number; + + public readonly url: string; + + public readonly name: string; + + public readonly metaTitle: string; + + public readonly indexable: boolean; + + public readonly values: FakerFeatureValue[]; + + /** + * Constructor for class FeatureData + * @param featureToCreate {FeatureCreator} Could be used to force the value of some members + */ + constructor(featureToCreate: FeatureCreator = {}) { + /** @type {number} ID of the feature */ + this.id = featureToCreate.id || 0; + + /** @type {number} Position of the feature */ + this.position = featureToCreate.position || 0; + + /** @type {string} Name of the feature */ + this.name = featureToCreate.name || faker.lorem.word(); + + /** @type {string} Name used on the feature URL */ + this.url = featureToCreate.url || this.name.replace(/\s/gi, '-'); + + /** @type {string} Feature meta title */ + this.metaTitle = featureToCreate.metaTitle || faker.lorem.word(); + + /** @type {boolean} True for the feature to be indexed */ + this.indexable = featureToCreate.indexable === undefined ? true : featureToCreate.indexable; + + /** @type {FakerFeatureValue[]} */ + this.values = featureToCreate.values || []; + } +} diff --git a/src/data/faker/featureValue.ts b/src/data/faker/featureValue.ts new file mode 100644 index 00000000..a7d032d3 --- /dev/null +++ b/src/data/faker/featureValue.ts @@ -0,0 +1,42 @@ +import type {FeatureValueCreator} from '@data/types/feature'; + +import {faker} from '@faker-js/faker'; + +const featuresNames: string[] = ['Composition', 'Property']; + +/** + * Create new feature value to use on feature value form on BO + * @class + */ +export default class FakerFeatureValue { + public readonly id:number; + + public readonly featureName:string; + + public readonly value:string; + + public readonly url:string; + + public readonly metaTitle:string; + + /** + * Constructor for class ValueData + * @param valueToCreate {FeatureValueCreator} Could be used to force the value of some members + */ + constructor(valueToCreate: FeatureValueCreator = {}) { + /** @type {number} ID of the feature */ + this.id = valueToCreate.id || 0; + + /** @type {string} Name of the parent feature */ + this.featureName = valueToCreate.featureName || faker.helpers.arrayElement(featuresNames); + + /** @type {string} Name of the value */ + this.value = valueToCreate.value || `${faker.lorem.word()}${faker.commerce.productMaterial()}`; + + /** @type {string} Name used on the value URL */ + this.url = valueToCreate.url || this.value.replace(/\s/gi, '-'); + + /** @type {string} Feature value meta title */ + this.metaTitle = valueToCreate.metaTitle || faker.lorem.word(); + } +} diff --git a/src/data/faker/hook.ts b/src/data/faker/hook.ts new file mode 100644 index 00000000..0d8c606b --- /dev/null +++ b/src/data/faker/hook.ts @@ -0,0 +1,24 @@ +import type HookCreator from '@data/types/hook'; + +import {faker} from '@faker-js/faker'; + +/** + * @class + */ +export default class FakerHook { + public readonly id: number; + + public readonly name: string; + + /** + * Constructor for class HookData + * @param valueToCreate {HookCreator} Could be used to force the value of some members + */ + constructor(valueToCreate: HookCreator = {}) { + /** @type {number} */ + this.id = valueToCreate.id || 0; + + /** @type {string} Name of the currency */ + this.name = valueToCreate.name || faker.word.noun(); + } +} diff --git a/src/data/faker/imageType.ts b/src/data/faker/imageType.ts new file mode 100644 index 00000000..ca88bea8 --- /dev/null +++ b/src/data/faker/imageType.ts @@ -0,0 +1,64 @@ +import {faker} from '@faker-js/faker'; +import {ImageTypeCreator} from '@data/types/imageType'; + +/** + * Create new image type to use on creation form on image type page on BO + * @class + */ +export default class FakerImageType { + public readonly id: number; + + public readonly name: string; + + public readonly width: number; + + public readonly height: number; + + public readonly productsStatus: boolean; + + public readonly categoriesStatus: boolean; + + public readonly manufacturersStatus: boolean; + + public readonly suppliersStatus: boolean; + + public readonly storesStatus: boolean; + + /** + * Constructor for class ImageTypeData + * @param imageTypeToCreate {ImageTypeCreator} Could be used to force the value of some members + */ + constructor(imageTypeToCreate: ImageTypeCreator = {}) { + /** @type {number} ID of the image type */ + this.id = imageTypeToCreate.id || 0; + + /** @type {string} Name of the image type */ + this.name = imageTypeToCreate.name || faker.lorem.word(); + + /** @type {number} Image width */ + this.width = imageTypeToCreate.width || faker.number.int({min: 100, max: 200}); + + /** @type {number} Image height */ + this.height = imageTypeToCreate.height || faker.number.int({min: 100, max: 200}); + + /** @type {boolean} To activate type for products */ + this.productsStatus = imageTypeToCreate.productsStatus === undefined + ? true : imageTypeToCreate.productsStatus; + + /** @type {boolean} To activate type for categories */ + this.categoriesStatus = imageTypeToCreate.categoriesStatus === undefined + ? true : imageTypeToCreate.categoriesStatus; + + /** @type {boolean} To activate type for manufacturers */ + this.manufacturersStatus = imageTypeToCreate.manufacturersStatus === undefined + ? true : imageTypeToCreate.manufacturersStatus; + + /** @type {boolean} To activate type for suppliers */ + this.suppliersStatus = imageTypeToCreate.suppliersStatus === undefined + ? true : imageTypeToCreate.suppliersStatus; + + /** @type {boolean} To activate type for stores */ + this.storesStatus = imageTypeToCreate.storesStatus === undefined + ? true : imageTypeToCreate.storesStatus; + } +} diff --git a/src/data/faker/language.ts b/src/data/faker/language.ts new file mode 100644 index 00000000..a78f5356 --- /dev/null +++ b/src/data/faker/language.ts @@ -0,0 +1,65 @@ +import LanguageCreator from '@data/types/language'; + +import {faker} from '@faker-js/faker'; + +/** + * Create new language to use on creation form on language page on BO + * @class + */ +export default class FakerLanguage { + public readonly id: number; + + public readonly name: string; + + public readonly isoCode: string; + + public readonly languageCode: string; + + public readonly dateFormat: string; + + public readonly fullDateFormat: string; + + public readonly isRtl: boolean; + + public readonly enabled: boolean; + + public readonly flag: string; + + public readonly noPicture: string; + + /** + * Constructor for class LanguageData + * @param LanguageToCreate {LanguageCreator} Could be used to force the value of some members + */ + constructor(LanguageToCreate: LanguageCreator = {}) { + /** @type {string} ID of the language */ + this.id = LanguageToCreate.id || 0; + + /** @type {string} Name of the language */ + this.name = LanguageToCreate.name || `test_language_${faker.lorem.word()}`; + + /** @type {string} Iso code of the language */ + this.isoCode = LanguageToCreate.isoCode || 'en'; + + /** @type {string} Language of the code */ + this.languageCode = LanguageToCreate.languageCode || this.isoCode; + + /** @type {string} Date format for the chosen language */ + this.dateFormat = LanguageToCreate.dateFormat || 'Y-m-d'; + + /** @type {string} Full date format for the chosen language */ + this.fullDateFormat = LanguageToCreate.fullDateFormat || 'Y-m-d H:i:s'; + + /** @type {boolean} True if it's a right to left language */ + this.isRtl = LanguageToCreate.isRtl === undefined ? false : LanguageToCreate.isRtl; + + /** @type {boolean} Status of the language */ + this.enabled = LanguageToCreate.enabled === undefined ? true : LanguageToCreate.enabled; + + /** @type {string} Language flag path */ + this.flag = LanguageToCreate.flag || `flag_${this.name}.png`; + + /** @type {string} Language no picture path */ + this.noPicture = LanguageToCreate.noPicture || `no_picture_${this.name}.png`; + } +} diff --git a/src/data/faker/linkWidget.ts b/src/data/faker/linkWidget.ts new file mode 100644 index 00000000..c6826a56 --- /dev/null +++ b/src/data/faker/linkWidget.ts @@ -0,0 +1,50 @@ +import dataHooks from '@data/demo/hooks'; +import type FakerHook from '@data/faker/hook'; +import {LinkWidgetCreator, LinkWidgetPage} from '@data/types/linkWidget'; +import {faker} from '@faker-js/faker'; + +/** + * @class + */ +export default class FakerLinkWidget { + public readonly name: string; + + public readonly frName: string; + + public readonly hook: FakerHook; + + public readonly contentPages: string[]; + + public readonly productsPages: string[]; + + public readonly staticPages: string[]; + + public readonly customPages: LinkWidgetPage[]; + + /** + * Constructor for class HookData + * @param valueToCreate {LinkWidgetCreator} Could be used to force the value of some members + */ + constructor(valueToCreate: LinkWidgetCreator = {}) { + /** @type {string} */ + this.name = valueToCreate.name || faker.word.noun(); + + /** @type {string} */ + this.frName = valueToCreate.frName || this.name; + + /** @type {FakerHook} */ + this.hook = valueToCreate.hook || faker.helpers.arrayElement([dataHooks.displayFooter]); + + /** @type {string[]} */ + this.contentPages = valueToCreate.contentPages || []; + + /** @type {string[]} */ + this.productsPages = valueToCreate.productsPages || []; + + /** @type {string[]} */ + this.staticPages = valueToCreate.staticPages || []; + + /** @type {LinkWidgetPage[]} */ + this.customPages = valueToCreate.customPages || []; + } +} diff --git a/src/data/faker/order.ts b/src/data/faker/order.ts index 2d617170..1ba3b456 100644 --- a/src/data/faker/order.ts +++ b/src/data/faker/order.ts @@ -17,7 +17,7 @@ import {faker} from '@faker-js/faker'; export default class FakerOrder { public readonly id: number; - public readonly reference: string; + public reference: string; public readonly newClient: boolean; @@ -100,4 +100,13 @@ export default class FakerOrder { freeShipping: false, }; } + + /** + * @param {string} reference + */ + setReference(reference: string): this { + this.reference = reference; + + return this; + } } diff --git a/src/data/faker/orderReturnStatus.ts b/src/data/faker/orderReturnStatus.ts new file mode 100644 index 00000000..65d3d4a2 --- /dev/null +++ b/src/data/faker/orderReturnStatus.ts @@ -0,0 +1,32 @@ +import OrderReturnStatusCreator from '@data/types/orderReturnStatus'; + +import {faker} from '@faker-js/faker'; + +/** + * Create new order return status to use on creation form on order return status page on BO + * @class + */ +export default class FakerOrderReturnStatus { + public readonly id: number; + + public readonly name: string; + + public readonly color: string; + + /** + * Constructor for class FakerOrderReturnStatus + * @param orderReturnStatusToCreate {Object} Could be used to force the value of some members + */ + constructor(orderReturnStatusToCreate: OrderReturnStatusCreator = {}) { + /** @type {number} ID of the status */ + this.id = orderReturnStatusToCreate.id || 0; + + /** @type {string} Name of the status (Max 32 characters) */ + this.name = (orderReturnStatusToCreate.name || `order_return_status_${faker.lorem.word({ + length: {min: 1, max: 12}, + })}`).substring(0, 32); + + /** @type {string} Hexadecimal value for the status */ + this.color = orderReturnStatusToCreate.color || faker.internet.color(); + } +} diff --git a/src/data/faker/searchAlias.ts b/src/data/faker/searchAlias.ts new file mode 100644 index 00000000..4f07d79d --- /dev/null +++ b/src/data/faker/searchAlias.ts @@ -0,0 +1,25 @@ +import type SearchAliasCreator from '@data/types/searchAlias'; + +import {faker} from '@faker-js/faker'; + +/** + * Create new alias to use on alias creation form on search page on BO + * @class + */ +export default class FakerSearchAlias { + public readonly alias: string; + + public readonly result: string; + + /** + * Constructor for class FakerSearchAlias + * @param aliasToCreate {Object} Could be used to force the value of some members + */ + constructor(aliasToCreate: SearchAliasCreator = {}) { + /** @type {string} Name of the alias */ + this.alias = aliasToCreate.alias || `alias_${faker.lorem.word()}`; + + /** @type {string} Result to display on the search */ + this.result = aliasToCreate.result || `result_${faker.lorem.word()}`; + } +} diff --git a/src/data/faker/searchEngine.ts b/src/data/faker/searchEngine.ts new file mode 100644 index 00000000..52a6a487 --- /dev/null +++ b/src/data/faker/searchEngine.ts @@ -0,0 +1,30 @@ +import type SearchEngineCreator from '@data/types/searchEngine'; + +import {faker} from '@faker-js/faker'; + +/** + * Create new search engine to use on search engine creation form on BO + * @class + */ +export default class FakerSearchEngine { + public readonly id: number; + + public readonly server: string; + + public readonly queryKey: string; + + /** + * Constructor for class FakerSearchEngine + * @param searchEngineToCreate {SearchEngineCreator} Could be used to force the value of some members + */ + constructor(searchEngineToCreate: SearchEngineCreator = {}) { + /** @type {number} ID of the engine */ + this.id = searchEngineToCreate.id || 0; + + /** @type {string} Server of the engine */ + this.server = searchEngineToCreate.server || `test_${faker.internet.domainWord()}`; + + /** @type {string} Key to use on the search */ + this.queryKey = searchEngineToCreate.queryKey || 'qTest_'; + } +} diff --git a/src/data/faker/seoPage.ts b/src/data/faker/seoPage.ts new file mode 100644 index 00000000..44d9db45 --- /dev/null +++ b/src/data/faker/seoPage.ts @@ -0,0 +1,65 @@ +import type SeoPageCreator from '@data/types/seoPage'; + +import {faker} from '@faker-js/faker'; + +/** + * Create new Seo page to use on seo page creation form on BO + * @class + */ +export default class FakerSeoPage { + public readonly id: number; + + public readonly page: string; + + public readonly title: string; + + public readonly frTitle: string; + + public readonly metaDescription: string; + + public readonly frMetaDescription: string; + + public readonly metaKeywords: string[]; + + public readonly frMetaKeywords: string[]; + + public readonly friendlyUrl: string; + + public readonly frFriendlyUrl: string; + + /** + * Constructor for class FakerSeoPage + * @param seoPageToCreate {SeoPageCreator} Could be used to force the value of some members + */ + constructor(seoPageToCreate: SeoPageCreator) { + /** @type {number} ID */ + this.id = seoPageToCreate.id || 0; + + /** @type {string} Page name from form list */ + this.page = seoPageToCreate.page; + + /** @type {string} Title of the page to add */ + this.title = seoPageToCreate.title || faker.lorem.word(); + + /** @type {string} French title of the page to add */ + this.frTitle = seoPageToCreate.frTitle || this.title; + + /** @type {string} Meta description of the page */ + this.metaDescription = seoPageToCreate.metaDescription || faker.lorem.sentence(); + + /** @type {string} French meta description of the page */ + this.frMetaDescription = seoPageToCreate.frMetaDescription || this.metaDescription; + + /** @type {Array} Meta keywords of the page */ + this.metaKeywords = seoPageToCreate.metaKeywords || [faker.lorem.word(), faker.lorem.word()]; + + /** @type {Array} French meta keywords of the page */ + this.frMetaKeywords = seoPageToCreate.frMetaKeywords || this.metaKeywords; + + /** @type {string} Friendly url to display when accessing the page */ + this.friendlyUrl = seoPageToCreate.friendlyUrl || this.page.replace(/ /g, '-'); + + /** @type {string} French friendly url */ + this.frFriendlyUrl = seoPageToCreate.frFriendlyUrl || this.friendlyUrl; + } +} diff --git a/src/data/faker/shoppingCart.ts b/src/data/faker/shoppingCart.ts new file mode 100644 index 00000000..277af209 --- /dev/null +++ b/src/data/faker/shoppingCart.ts @@ -0,0 +1,42 @@ +import dataCarriers from '@data/demo/carriers'; +import dataCustomers from '@data/demo/customers'; +import type FakerCarrier from '@data/faker/carrier'; +import type FakerCustomer from '@data/faker/customer'; +import type {ShoppingCartCreator} from '@data/types/shoppingCart'; + +/** + * Create new tax rule to use on tax rule form on BO + * @class + */ +export default class FakerShoppingCart { + public readonly id: number; + + public readonly orderID: number; + + public readonly customer: FakerCustomer; + + public readonly carrier: FakerCarrier; + + public readonly online: boolean; + + /** + * Constructor for class FakerShoppingCart + * @param valueToCreate {ShoppingCartCreator} Could be used to force the value of some members + */ + constructor(valueToCreate: ShoppingCartCreator = {}) { + /** @type {number} ID */ + this.id = valueToCreate.id || 0; + + /** @type {number} Order ID */ + this.orderID = valueToCreate.orderID || 0; + + /** @type {FakerCustomer} Customer */ + this.customer = valueToCreate.customer || dataCustomers.johnDoe; + + /** @type {FakerCarrier} Carrier */ + this.carrier = valueToCreate.carrier || dataCarriers.myCarrier; + + /** @type {boolean} */ + this.online = valueToCreate.online || true; + } +} diff --git a/src/data/faker/sqlTable.ts b/src/data/faker/sqlTable.ts new file mode 100644 index 00000000..8a718aeb --- /dev/null +++ b/src/data/faker/sqlTable.ts @@ -0,0 +1,23 @@ +import type FakerSqlTable from '@data/types/sqlTable'; + +/** + * Create new sql table + * @class + */ +export default class SqlTableData { + public readonly name: string; + + public readonly columns: string[]; + + /** + * Constructor for class SqlTableData + * @param sqlTableToCreate {FakerSqlTable} Could be used to force the value of some members + */ + constructor(sqlTableToCreate: FakerSqlTable = {}) { + /** @type {string} Name of the table */ + this.name = sqlTableToCreate.name || ''; + + /** @type {string[]} Columns of the query */ + this.columns = sqlTableToCreate.columns || []; + } +} diff --git a/src/data/faker/store.ts b/src/data/faker/store.ts new file mode 100644 index 00000000..4aebacc6 --- /dev/null +++ b/src/data/faker/store.ts @@ -0,0 +1,104 @@ +import StoreCreator from '@data/types/store'; +import {fakerFR as faker} from '@faker-js/faker'; + +/** + * Create new store to use on store creation form on BO + * @class + */ +export default class FakerStore { + public id: number; + + public name: string; + + public address1: string; + + public address2: string; + + public postcode: string; + + public city: string; + + public state: string; + + public country: string; + + public latitude: string; + + public longitude: string; + + public phone: string; + + public fax: string; + + public registrationNumber: string; + + public email: string; + + public note: string; + + public status: boolean; + + public hours: string[]; + + public picture: string|null; + + /** + * Constructor for class FakerStore + * @param storeToCreate {StoreCreator} Could be used to force the value of some members + */ + constructor(storeToCreate: StoreCreator = {}) { + /** @type {number} Name of the store */ + this.id = storeToCreate.id || 0; + + /** @type {string} Name of the store */ + this.name = storeToCreate.name || faker.company.name(); + + /** @type {string} First line address of the store */ + this.address1 = storeToCreate.address1 || faker.location.streetAddress(); + + /** @type {string} Second line address of the store */ + this.address2 = storeToCreate.address2 || faker.location.secondaryAddress(); + + /** @type {string} Postal code of the store */ + this.postcode = storeToCreate.postcode || faker.location.zipCode('#####'); + + /** @type {string} City for the address of the store */ + this.city = storeToCreate.city || faker.location.city(); + + /** @type {string} State for the address of the store */ + this.state = storeToCreate.state || faker.location.state(); + + /** @type {string} Country of the address of the store */ + this.country = storeToCreate.country || 'France'; + + /** @type {string} Latitude of the address of the store */ + this.latitude = storeToCreate.latitude || faker.location.latitude().toString(); + + /** @type {string} Longitude of the address of the store */ + this.longitude = storeToCreate.longitude || faker.location.longitude().toString(); + + /** @type {string} Phone number of the store (default format 01########) */ + this.phone = storeToCreate.phone || faker.phone.number(); + + /** @type {string} Fax number of the store default format 01########) */ + this.fax = storeToCreate.fax || faker.phone.number(); + + /** @type {string} Registration number of the store */ + this.registrationNumber = storeToCreate.registrationNumber || faker.finance.accountNumber(); + + /** @type {string} Email to contact the store */ + this.email = storeToCreate.email || faker.internet.email(); + + /** @type {string} Note to add information on the store */ + this.note = storeToCreate.note || faker.lorem.sentence(); + + /** @type {boolean} Status of the store */ + this.status = storeToCreate.status === undefined ? true : storeToCreate.status; + + /** @type {Array} Opening hours of the store */ + this.hours = storeToCreate.hours || new Array(7).fill('10:00 - 18:00', 0, 7); + + /** @type {string|null} Picture of the store */ + this.picture = storeToCreate.picture || null; + } +} diff --git a/src/data/faker/supplier.ts b/src/data/faker/supplier.ts new file mode 100644 index 00000000..04862586 --- /dev/null +++ b/src/data/faker/supplier.ts @@ -0,0 +1,118 @@ +import dataCountries from '@data/demo/countries'; +import type FakerCountry from '@data/faker/country'; +import SupplierCreator from '@data/types/supplier'; +import {fakerFR as faker} from '@faker-js/faker'; + +const countriesNames: string[] = Object.values(dataCountries).map((country: FakerCountry) => country.name); + +/** + * Create new supplier to use on supplier creation form on BO + * @class + */ +export default class FakerSupplier { + public id: number; + + public name: string; + + public description: string; + + public descriptionFr: string; + + public homePhone: string; + + public mobilePhone: string; + + public address: string; + + public secondaryAddress: string; + + public postalCode: string; + + public city: string; + + public country: string; + + public logo: string; + + public metaTitle: string; + + public metaTitleFr: string; + + public metaDescription: string; + + public metaDescriptionFr: string; + + public metaKeywords: string[]; + + public metaKeywordsFr: string[]; + + public enabled: boolean; + + public products: number; + + /** + * Constructor for class FakerSupplier + * @param supplierToCreate {SupplierCreator} Could be used to force the value of some members + */ + constructor(supplierToCreate: SupplierCreator = {}) { + /** @type {number} ID of the supplier */ + this.id = supplierToCreate.id || 0; + + /** @type {string} Name of the supplier */ + this.name = (supplierToCreate.name || faker.company.name()).substring(0, 63); + + /** @type {string} Description of the supplier */ + this.description = supplierToCreate.description || faker.lorem.sentence(); + + /** @type {string} French description of the supplier */ + this.descriptionFr = supplierToCreate.descriptionFr || this.description; + + /** @type {string} Home phone number of the supplier (default format 01########) */ + this.homePhone = supplierToCreate.homePhone || faker.phone.number(); + + /** @type {string} Mobile phone number of the supplier (default format 01########) */ + this.mobilePhone = supplierToCreate.mobilePhone || faker.phone.number(); + + /** @type {string} First line address of the supplier */ + this.address = supplierToCreate.address || faker.location.streetAddress(); + + /** @type {string} Second line address of the supplier */ + this.secondaryAddress = supplierToCreate.secondaryAddress || faker.location.secondaryAddress(); + + /** @type {string} Postal code of the supplier */ + this.postalCode = supplierToCreate.postalCode || faker.location.zipCode().replace('.', '-'); + + /** @type {string} City for the address of the supplier */ + this.city = supplierToCreate.city || faker.location.city(); + + /** @type {string} Country for the address of the supplier */ + this.country = supplierToCreate.country || faker.helpers.arrayElement(countriesNames); + + /** @type {string} Logo name/path of the supplier */ + this.logo = supplierToCreate.logo || `${this.name.replace(/[^\w\s]/gi, '')}.png`; + + /** @type {string} Meta title of the supplier */ + this.metaTitle = supplierToCreate.metaTitle || this.name; + + /** @type {string} French meta title of the supplier */ + this.metaTitleFr = supplierToCreate.metaTitleFr || this.metaTitle; + + /** @type {string} Meta description of the supplier */ + this.metaDescription = supplierToCreate.metaDescription || faker.lorem.sentence(); + + /** @type {string} French meta description of the supplier */ + this.metaDescriptionFr = supplierToCreate.metaDescriptionFr || this.metaDescription; + + /** @type {Array} Meta keywords of the supplier */ + this.metaKeywords = supplierToCreate.metaKeywords || [faker.lorem.word(), faker.lorem.word()]; + + /** @type {Array} French meta keywords of the supplier */ + this.metaKeywordsFr = supplierToCreate.metaKeywordsFr || this.metaKeywords; + + /** @type {boolean} Status of the supplier */ + this.enabled = supplierToCreate.enabled === undefined ? true : supplierToCreate.enabled; + + /** @type {number} Number of products associated */ + this.products = supplierToCreate.products || 0; + } +} diff --git a/src/data/faker/taxOption.ts b/src/data/faker/taxOption.ts new file mode 100644 index 00000000..2a9eb994 --- /dev/null +++ b/src/data/faker/taxOption.ts @@ -0,0 +1,38 @@ +import TaxOptionCreator from '@data/types/taxOption'; + +/** + * Create new tax to use on tax form on BO + * @class + */ +export default class FakerTaxOption { + public readonly enabled: boolean; + + public readonly displayInShoppingCart: boolean; + + public readonly basedOn: string; + + public readonly useEcoTax: boolean; + + public readonly ecoTax: string|null; + + /** + * Constructor for class FakerTaxOption + * @param valueToCreate {TaxOptionCreator} Could be used to force the value of some members + */ + constructor(valueToCreate: TaxOptionCreator = {}) { + /** @type {boolean} Status */ + this.enabled = valueToCreate.enabled === undefined ? true : valueToCreate.enabled; + + /** @type {boolean} Status */ + this.displayInShoppingCart = valueToCreate.displayInShoppingCart === undefined ? false : valueToCreate.displayInShoppingCart; + + /** @type {string} Name of the tax */ + this.basedOn = valueToCreate.basedOn || ''; + + /** @type {boolean} */ + this.useEcoTax = valueToCreate.useEcoTax || false; + + /** @type {string|null} Eco Tax */ + this.ecoTax = valueToCreate.ecoTax || null; + } +} diff --git a/src/data/types/attribute.ts b/src/data/types/attribute.ts new file mode 100644 index 00000000..60f7f35c --- /dev/null +++ b/src/data/types/attribute.ts @@ -0,0 +1,31 @@ +import type AttributeValueData from '@data/faker/attributeValue'; + +type AttributeCreator = { + id?: number + position?: number + name?: string + publicName?: string + url?: string + metaTitle?: string + indexable?: boolean + displayed?: boolean + attributeType?: string + values?: AttributeValueData[] +}; + +type AttributeValueCreator = { + id?: number + position?: number + attributeID?: number; + attributeName?: string; + value?: string; + url?: string; + metaTitle?: string; + color?: string; + textureFileName?: string; +}; + +export type { + AttributeCreator, + AttributeValueCreator, +}; diff --git a/src/data/types/brand.ts b/src/data/types/brand.ts new file mode 100644 index 00000000..d5e02dce --- /dev/null +++ b/src/data/types/brand.ts @@ -0,0 +1,20 @@ +type BrandCreator = { + id?: number + name?: string + logo?: string + shortDescription?: string + shortDescriptionFr?: string + description?: string + descriptionFr?: string + metaTitle?: string + metaTitleFr?: string + metaDescription?: string + metaDescriptionFr?: string + metaKeywords?: string[] + metaKeywordsFr?: string[] + enabled?: boolean + addresses?: number + products?: number + }; + +export default BrandCreator; diff --git a/src/data/types/brandAddress.ts b/src/data/types/brandAddress.ts new file mode 100644 index 00000000..1999309c --- /dev/null +++ b/src/data/types/brandAddress.ts @@ -0,0 +1,16 @@ +type BrandAddressCreator = { + id?: number + brandName?: string; + firstName?: string; + lastName?: string; + address?: string; + secondaryAddress?: string; + postalCode?: string; + city?: string; + country?: string; + homePhone?: string; + mobilePhone?: string; + other?: string; + }; + +export default BrandAddressCreator; diff --git a/src/data/types/cmsPage.ts b/src/data/types/cmsPage.ts new file mode 100644 index 00000000..5a1367be --- /dev/null +++ b/src/data/types/cmsPage.ts @@ -0,0 +1,14 @@ +type CmsPageCreator = { + id?: number + title?: string + metaTitle?: string + metaDescription?: string + metaKeywords?: string + content?: string + url?: string + displayed?: boolean + position?: number + indexation?: boolean + }; + +export default CmsPageCreator; diff --git a/src/data/types/contact.ts b/src/data/types/contact.ts new file mode 100644 index 00000000..0282594b --- /dev/null +++ b/src/data/types/contact.ts @@ -0,0 +1,11 @@ +type ContactCreator = { + id?: number + firstName?: string + lastName?: string + title?: string + email?: string + saveMessage?: boolean + description?: string +}; + +export default ContactCreator; diff --git a/src/data/types/employee.ts b/src/data/types/employee.ts new file mode 100644 index 00000000..c1a04ced --- /dev/null +++ b/src/data/types/employee.ts @@ -0,0 +1,23 @@ +type EmployeeCreator = { + id?: number + firstName?: string + lastName?: string + email?: string + password?: string + defaultPage?: string + language?: string + active?: boolean + permissionProfile?: string + avatarFile?: string|null + enableGravatar?: boolean + }; + + type EmployeePermission = { + className: string + accesses: string[] + } + +export type { + EmployeeCreator, + EmployeePermission, +}; diff --git a/src/data/types/employeeRole.ts b/src/data/types/employeeRole.ts new file mode 100644 index 00000000..b39944f4 --- /dev/null +++ b/src/data/types/employeeRole.ts @@ -0,0 +1,5 @@ +type EmployeeRoleCreator = { + name?: string +}; + +export default EmployeeRoleCreator; diff --git a/src/data/types/feature.ts b/src/data/types/feature.ts new file mode 100644 index 00000000..bc7b2cea --- /dev/null +++ b/src/data/types/feature.ts @@ -0,0 +1,24 @@ +import type FeatureValueData from '@data/faker/featureValue'; + +type FeatureCreator = { + id?: number + position?: number + name?: string + url?: string + metaTitle?: string + indexable?: boolean + values?: FeatureValueData[]; +}; + +type FeatureValueCreator = { + id?: number + featureName?: string; + value?: string; + url?: string; + metaTitle?: string; +}; + +export type { + FeatureCreator, + FeatureValueCreator, +}; diff --git a/src/data/types/hook.ts b/src/data/types/hook.ts new file mode 100644 index 00000000..dc23e198 --- /dev/null +++ b/src/data/types/hook.ts @@ -0,0 +1,6 @@ +type HookCreator = { + id?: number + name?: string + }; + +export default HookCreator; diff --git a/src/data/types/imageType.ts b/src/data/types/imageType.ts new file mode 100644 index 00000000..4d45944e --- /dev/null +++ b/src/data/types/imageType.ts @@ -0,0 +1,20 @@ +type ImageTypeCreator = { + id?: number + name?: string + width?: number + height?: number + productsStatus?: boolean + categoriesStatus?: boolean + manufacturersStatus?: boolean + suppliersStatus?: boolean + storesStatus?: boolean + }; + + type ImageTypeRegenerationSpecific = 'categories'|'manufacturers'|'suppliers'|'products'|'stores'; + type ImageTypeRegeneration = 'categories'|'manufacturers'|'suppliers'|'products'|'stores'|'all'; + +export type { + ImageTypeCreator, + ImageTypeRegeneration, + ImageTypeRegenerationSpecific, +}; diff --git a/src/data/types/language.ts b/src/data/types/language.ts new file mode 100644 index 00000000..3b717ffe --- /dev/null +++ b/src/data/types/language.ts @@ -0,0 +1,14 @@ +type LanguageCreator = { + id?: number + name?: string + isoCode?: string + languageCode?: string + dateFormat?: string + fullDateFormat?: string + isRtl?: boolean + enabled?: boolean + flag?: string + noPicture?: string + }; + +export default LanguageCreator; diff --git a/src/data/types/linkWidget.ts b/src/data/types/linkWidget.ts new file mode 100644 index 00000000..55bc71c4 --- /dev/null +++ b/src/data/types/linkWidget.ts @@ -0,0 +1,21 @@ +import type FakerHook from '@data/faker/hook'; + +type LinkWidgetCreator = { + name?: string + frName?: string + hook?: FakerHook + contentPages?: string[] + productsPages?: string[] + staticPages?: string[] + customPages?: LinkWidgetPage[] +}; + +type LinkWidgetPage = { + name: string + url: string +}; + +export type { + LinkWidgetCreator, + LinkWidgetPage, +}; diff --git a/src/data/types/module.ts b/src/data/types/module.ts index 4a21a66d..6dc31427 100644 --- a/src/data/types/module.ts +++ b/src/data/types/module.ts @@ -1,5 +1,17 @@ -export type FakerModuleCreator = { +type FakerModuleCreator = { tag?: string name?: string releaseZip?: string +} + +type ModuleInfo = { + moduleId: number + technicalName: string + version: string + enabled: boolean +} + +export type { + FakerModuleCreator, + ModuleInfo, }; diff --git a/src/data/types/orderReturnStatus.ts b/src/data/types/orderReturnStatus.ts new file mode 100644 index 00000000..690c4219 --- /dev/null +++ b/src/data/types/orderReturnStatus.ts @@ -0,0 +1,7 @@ +type OrderReturnStatusCreator = { + id?: number + name?: string + color?: string + }; + +export default OrderReturnStatusCreator; diff --git a/src/data/types/searchAlias.ts b/src/data/types/searchAlias.ts new file mode 100644 index 00000000..c3023701 --- /dev/null +++ b/src/data/types/searchAlias.ts @@ -0,0 +1,6 @@ +type SearchAliasCreator = { + alias?: string + result?: string +}; + +export default SearchAliasCreator; diff --git a/src/data/types/searchEngine.ts b/src/data/types/searchEngine.ts new file mode 100644 index 00000000..e47cdd64 --- /dev/null +++ b/src/data/types/searchEngine.ts @@ -0,0 +1,7 @@ +type SearchEngineCreator = { + id?: number + server?: string + queryKey?: string + }; + +export default SearchEngineCreator; diff --git a/src/data/types/seoPage.ts b/src/data/types/seoPage.ts new file mode 100644 index 00000000..83c83285 --- /dev/null +++ b/src/data/types/seoPage.ts @@ -0,0 +1,14 @@ +type SeoPageCreator = { + id?: number + page: string + title?: string + frTitle?: string + metaDescription?: string + frMetaDescription?: string + metaKeywords?: string[] + frMetaKeywords?: string[] + friendlyUrl?: string + frFriendlyUrl?: string + }; + +export default SeoPageCreator; diff --git a/src/data/types/shoppingCart.ts b/src/data/types/shoppingCart.ts new file mode 100644 index 00000000..17fd3695 --- /dev/null +++ b/src/data/types/shoppingCart.ts @@ -0,0 +1,26 @@ +import type FakerCarrier from '@data/faker/carrier'; +import type FakerCustomer from '@data/faker/customer'; + +type ShoppingCartCreator = { + id?: number + orderID?: number + customer?: FakerCustomer + carrier?: FakerCarrier + online?: boolean +} + +type ShoppingCartDetails = { + id_cart?: number + id_order?: number + status?: string + lastname?: string + total?: string + carrier?: string + date?: string + online?: string +} + +export type { + ShoppingCartCreator, + ShoppingCartDetails, +}; diff --git a/src/data/types/sqlTable.ts b/src/data/types/sqlTable.ts new file mode 100644 index 00000000..0e41aa08 --- /dev/null +++ b/src/data/types/sqlTable.ts @@ -0,0 +1,6 @@ +type SqlTableCreator = { + name?: string + columns?: string[] +}; + +export default SqlTableCreator; diff --git a/src/data/types/store.ts b/src/data/types/store.ts new file mode 100644 index 00000000..32238f04 --- /dev/null +++ b/src/data/types/store.ts @@ -0,0 +1,22 @@ +type StoreCreator = { + id?: number + name?: string + address1?: string + address2?: string + postcode?: string + city?: string + state?: string + country?: string + latitude?: string + longitude?: string + phone?: string + fax?: string + registrationNumber?: string + email?: string + note?: string + status?: boolean + hours?: string[] + picture?: string +}; + +export default StoreCreator; diff --git a/src/data/types/supplier.ts b/src/data/types/supplier.ts new file mode 100644 index 00000000..1f3aeba0 --- /dev/null +++ b/src/data/types/supplier.ts @@ -0,0 +1,24 @@ +type SupplierCreator = { + id?: number + name?: string + description?: string + descriptionFr?: string + homePhone?: string + mobilePhone?: string + address?: string + secondaryAddress?: string + postalCode?: string + city?: string + country?: string + logo?: string + metaTitle?: string + metaTitleFr?: string + metaDescription?: string + metaDescriptionFr?: string + metaKeywords?: string[] + metaKeywordsFr?: string[] + enabled?: boolean + products?: number +}; + +export default SupplierCreator; diff --git a/src/data/types/taxOption.ts b/src/data/types/taxOption.ts new file mode 100644 index 00000000..398fc893 --- /dev/null +++ b/src/data/types/taxOption.ts @@ -0,0 +1,9 @@ +type TaxOptionCreator = { + enabled?: boolean + displayInShoppingCart?: boolean + basedOn?: string + useEcoTax?: boolean + ecoTax?: string|null +}; + +export default TaxOptionCreator; diff --git a/src/index.ts b/src/index.ts index f742bbf5..d66c1ed4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,6 +5,7 @@ export type { CarrierRangeZone, } from '@data/types/carrier'; export type {CartProductDetails} from '@data/types/cart'; +export type {EmployeePermission} from '@data/types/employee'; export type { GlobalInstall, GlobalFO, @@ -17,46 +18,98 @@ export type { GlobalMaildevConfig, GlobalKeycloakConfig, } from '@data/types/globals'; +export type {ImageTypeRegeneration, ImageTypeRegenerationSpecific} from '@data/types/imageType'; +export type {LinkWidgetPage} from '@data/types/linkWidget'; +export type {ModuleInfo} from '@data/types/module'; export type {OrderCreator} from '@data/types/order'; +export type {ShoppingCartDetails} from '@data/types/shoppingCart'; export type { PageWaitForSelectorOptionsState, WaitForNavigationWaitUntil, } from '@data/types/playwright'; +export {default as dataAddresses} from '@data/demo/addresses'; +export {default as dataAttributes} from '@data/demo/attributes'; +export {default as dataBOPages} from '@data/demo/boPages'; +export {default as dataBrandAddresses} from '@data/demo/brandAdresses'; +export {default as dataBrands} from '@data/demo/brands'; +export {default as dataCarriers} from '@data/demo/carriers'; export {default as dataCategories} from '@data/demo/categories'; +export {default as dataCMSPages} from '@data/demo/cmsPage'; +export {default as dataContacts} from '@data/demo/contacts'; export {default as dataCountries} from '@data/demo/countries'; export {default as dataCurrencies} from '@data/demo/currencies'; export {default as dataCustomers} from '@data/demo/customers'; +export {default as dataEmployeeRoles} from '@data/demo/employeeRoles'; +export {default as dataEmployees} from '@data/demo/employees'; +export {default as dataFeatures} from '@data/demo/features'; export {default as dataGroups} from '@data/demo/groups'; +export {default as dataHooks} from '@data/demo/hooks'; +export {default as dataImageTypes} from '@data/demo/imageTypes'; +export {default as dataLanguages} from '@data/demo/languages'; +export {default as dataLinkWidgets} from '@data/demo/linkWidgets'; +export {default as dataModuleCategories} from '@data/demo/moduleCategories'; export {default as dataModules} from '@data/demo/modules'; +export {default as dataOrderReturnStatuses} from '@data/demo/orderReturnStatuses'; export {default as dataOrderStatuses} from '@data/demo/orderStatuses'; export {default as dataOrders} from '@data/demo/orders'; export {default as dataPaymentMethods} from '@data/demo/paymentMethods'; export {default as dataProducts} from '@data/demo/products'; +export {default as dataSearchAliases} from '@data/demo/searchAliases'; +export {default as dataSearchEngines} from '@data/demo/searchEngines'; +export {default as dataSeoPages} from '@data/demo/seoPages'; +export {default as dataShoppingCarts} from '@data/demo/shoppingCarts'; export {default as dataSocialTitles} from '@data/demo/socialTitles'; +export {default as dataSqlTables} from '@data/demo/sqlTables'; export {default as dataStates} from '@data/demo/states'; +export {default as dataStores} from '@data/demo/stores'; +export {default as dataSuppliers} from '@data/demo/suppliers'; export {default as dataTaxes} from '@data/demo/tax'; +export {default as dataTaxOptions} from '@data/demo/taxOptions'; export {default as dataTaxRules} from '@data/demo/taxRule'; export {default as dataTaxRuleBehaviours} from '@data/demo/taxRuleBehaviour'; export {default as dataTitles} from '@data/demo/titles'; export {default as dataZones} from '@data/demo/zones'; export {default as FakerAddress} from '@data/faker/address'; +export {default as FakerAttribute} from '@data/faker/attribute'; +export {default as FakerAttributeValue} from '@data/faker/attributeValue'; +export {default as FakerBrand} from '@data/faker/brand'; +export {default as FakerBrandAddress} from '@data/faker/brandAddress'; export {default as FakerCarrier} from '@data/faker/carrier'; export {default as FakerCategory} from '@data/faker/category'; +export {default as FakerCMSPage} from '@data/faker/cmsPage'; +export {default as FakerContact} from '@data/faker/contact'; export {default as FakerCountry} from '@data/faker/country'; export {default as FakerCurrency} from '@data/faker/currency'; export {default as FakerCustomer} from '@data/faker/customer'; +export {default as FakerEmployee} from '@data/faker/employee'; +export {default as FakerEmployeeRole} from '@data/faker/employeeRole'; +export {default as FakerFeature} from '@data/faker/feature'; +export {default as FakerFeatureValue} from '@data/faker/featureValue'; export {default as FakerGroup} from '@data/faker/group'; +export {default as FakerHook} from '@data/faker/hook'; +export {default as FakerImageType} from '@data/faker/imageType'; +export {default as FakerLanguage} from '@data/faker/language'; +export {default as FakerLinkWidget} from '@data/faker/linkWidget'; export {default as FakerModule} from '@data/faker/module'; +export {default as FakerOrderReturnStatus} from '@data/faker/orderReturnStatus'; export {default as FakerOrderStatus} from '@data/faker/orderStatus'; export {default as FakerOrder} from '@data/faker/order'; export {default as FakerPaymentMethod} from '@data/faker/paymentMethod'; export {default as FakerProduct} from '@data/faker/product'; export {default as FakerProductReview} from '@data/faker/productReview'; +export {default as FakerSearchAlias} from '@data/faker/searchAlias'; +export {default as FakerSearchEngine} from '@data/faker/searchEngine'; +export {default as FakerSeoPage} from '@data/faker/seoPage'; +export {default as FakerShoppingCart} from '@data/faker/shoppingCart'; +export {default as FakerSqlTable} from '@data/faker/sqlTable'; export {default as FakerState} from '@data/faker/state'; +export {default as FakerStore} from '@data/faker/store'; +export {default as FakerSupplier} from '@data/faker/supplier'; export {default as FakerTaxRule} from '@data/faker/taxRule'; export {default as FakerTax} from '@data/faker/tax'; +export {default as FakerTaxOption} from '@data/faker/taxOption'; export {default as FakerTitle} from '@data/faker/title'; export {default as FakerZone} from '@data/faker/zone';