@b2y/ecommerce-common 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +4 -4
  2. package/constants/AppConstants.js +6 -6
  3. package/constants/ReportConstants.js +14 -14
  4. package/constants/StatusMessageConstants.js +17 -17
  5. package/dbconnection/Connect.js +432 -432
  6. package/enum/AccessModeEnum.js +7 -7
  7. package/enum/AddressTypeEnum.js +6 -6
  8. package/enum/BillingCycleEnum.js +5 -5
  9. package/enum/BooleanEnum.js +4 -4
  10. package/enum/BulkImportStatusEnum.js +6 -6
  11. package/enum/EntityTypeEnum.js +11 -11
  12. package/enum/FeatureTypeEnum.js +6 -6
  13. package/enum/GenderEnum.js +7 -7
  14. package/enum/NotificationStatusEnum.js +5 -5
  15. package/enum/NotificationTypeEnum.js +9 -9
  16. package/enum/OrderStatusEnum.js +7 -7
  17. package/enum/PaymentMethodEnum.js +6 -6
  18. package/enum/PaymentStatusEnum.js +6 -6
  19. package/enum/PaymentTypeEnum.js +6 -6
  20. package/enum/PlatformEnum.js +4 -4
  21. package/enum/RegistrationStatusEnum.js +5 -5
  22. package/enum/SortByEnum.js +7 -7
  23. package/enum/SubscriptionStatusEnum.js +7 -7
  24. package/index.js +22 -22
  25. package/model/Address.js +95 -95
  26. package/model/AttributeType.js +50 -50
  27. package/model/AttributeValue.js +64 -64
  28. package/model/Banner.js +78 -78
  29. package/model/Brand.js +76 -76
  30. package/model/Cart.js +76 -76
  31. package/model/Category.js +72 -72
  32. package/model/CategoryAttributeType.js +62 -62
  33. package/model/Colour.js +52 -52
  34. package/model/Customer.js +94 -94
  35. package/model/DeviceToken.js +51 -51
  36. package/model/Document.js +73 -73
  37. package/model/DynamicUIComponent.js +52 -52
  38. package/model/Feedback.js +79 -79
  39. package/model/Inventory.js +83 -83
  40. package/model/NotificationHistory.js +67 -67
  41. package/model/Order.js +94 -94
  42. package/model/OrderItem.js +98 -98
  43. package/model/OrderItemHistory.js +69 -69
  44. package/model/OrderStatus.js +48 -48
  45. package/model/Payment.js +101 -101
  46. package/model/PaymentMethod.js +36 -36
  47. package/model/PaymentStatus.js +36 -36
  48. package/model/PaymentType.js +36 -36
  49. package/model/Permission.js +55 -55
  50. package/model/Product.js +87 -82
  51. package/model/ProductGroup.js +48 -48
  52. package/model/ProductImport.js +55 -55
  53. package/model/ProductImportFailureAudits.js +57 -57
  54. package/model/ProductSpecification.js +65 -65
  55. package/model/ProductVariant.js +75 -75
  56. package/model/ProductVariantAttribute.js +58 -58
  57. package/model/Role.js +61 -61
  58. package/model/RolePermissionMapping.js +63 -63
  59. package/model/SpecificationType.js +41 -41
  60. package/model/Store.js +99 -99
  61. package/model/StoreUserMapping.js +44 -44
  62. package/model/SubscriptionFeature.js +49 -49
  63. package/model/SubscriptionPlan.js +66 -66
  64. package/model/SubscriptionPlanFeature.js +48 -48
  65. package/model/Tenant.js +91 -91
  66. package/model/TenantSettings.js +47 -47
  67. package/model/TenantSubscription.js +73 -73
  68. package/model/User.js +132 -132
  69. package/model/WishList.js +62 -62
  70. package/package.json +29 -29
  71. package/utility/AppUtil.js +65 -65
  72. package/utility/DateUtil.js +55 -55
  73. package/utility/ExcelUtil.js +125 -125
  74. package/utility/LocationUtility.js +130 -130
  75. package/utility/OrderTimeFilterUtil.js +88 -88
  76. package/utility/PdfUtil.js +64 -64
  77. package/utility/QueryUtil.js +261 -261
  78. package/utility/Razorpay.js +65 -65
  79. package/utility/ResolveAccessMode.js +38 -38
  80. package/utility/VariantPriceUtil.js +54 -54
@@ -1,88 +1,88 @@
1
- const AppConstants = require('../constants/AppConstants');
2
- class OrderTimeFilterUtil {
3
- static getDateRange(filter) {
4
- if (!filter) return null;
5
-
6
- const today = new Date();
7
- let startDate, endDate;
8
-
9
- switch (filter.toLowerCase()) {
10
- case AppConstants.LAST_30DAYS.toLowerCase():
11
- startDate = new Date(today);
12
- startDate.setDate(today.getDate() - 30);
13
- startDate.setHours(0, 0, 0, 0);
14
- endDate = new Date(today);
15
- endDate.setHours(23, 59, 59, 999);
16
- break;
17
-
18
- case AppConstants.LAST_6MONTHS.toLowerCase():
19
- startDate = new Date(today);
20
- startDate.setMonth(today.getMonth() - 6);
21
- startDate.setHours(0, 0, 0, 0);
22
- endDate = new Date(today);
23
- endDate.setHours(23, 59, 59, 999);
24
- break;
25
-
26
- case AppConstants.OLDER.toLowerCase():
27
- startDate = new Date(1970, 0, 1);
28
- endDate = new Date(today);
29
- break;
30
-
31
- default:
32
- const year = parseInt(filter);
33
- if (!isNaN(year)) {
34
- return this.getYearRange(year);
35
- }
36
- return null;
37
- }
38
-
39
- return { startDate, endDate };
40
- }
41
-
42
- static getYearRange(year) {
43
- const today = new Date();
44
- const startDate = new Date(year, 0, 1);
45
-
46
- if (year === today.getFullYear()) {
47
- const endDate = new Date(today);
48
- endDate.setHours(23, 59, 59, 999);
49
- return { startDate, endDate };
50
- }
51
-
52
- return {
53
- startDate,
54
- endDate: new Date(year, 11, 31, 23, 59, 59, 999)
55
- };
56
- }
57
-
58
- static isValidFilter(filter) {
59
- if (!filter) return false;
60
-
61
- const validFilters = [
62
- AppConstants.LAST_30DAYS.toLowerCase(),
63
- AppConstants.LAST_6MONTHS.toLowerCase(),
64
- AppConstants.OLDER.toLowerCase()
65
- ];
66
-
67
- if (validFilters.includes(filter.toLowerCase())) {
68
- return true;
69
- }
70
-
71
- const year = parseInt(filter);
72
- const currentYear = new Date().getFullYear();
73
- return !isNaN(year) && year <= currentYear && year;
74
- }
75
-
76
- static buildWhereCondition(filter, Sequelize) {
77
- const dateRange = this.getDateRange(filter);
78
- if (!dateRange) return null;
79
-
80
- return {
81
- [Sequelize.Op.gte]: dateRange.startDate,
82
- [Sequelize.Op.lte]: dateRange.endDate
83
- };
84
- }
85
-
86
- }
87
- module.exports = OrderTimeFilterUtil;
88
-
1
+ const AppConstants = require('../constants/AppConstants');
2
+ class OrderTimeFilterUtil {
3
+ static getDateRange(filter) {
4
+ if (!filter) return null;
5
+
6
+ const today = new Date();
7
+ let startDate, endDate;
8
+
9
+ switch (filter.toLowerCase()) {
10
+ case AppConstants.LAST_30DAYS.toLowerCase():
11
+ startDate = new Date(today);
12
+ startDate.setDate(today.getDate() - 30);
13
+ startDate.setHours(0, 0, 0, 0);
14
+ endDate = new Date(today);
15
+ endDate.setHours(23, 59, 59, 999);
16
+ break;
17
+
18
+ case AppConstants.LAST_6MONTHS.toLowerCase():
19
+ startDate = new Date(today);
20
+ startDate.setMonth(today.getMonth() - 6);
21
+ startDate.setHours(0, 0, 0, 0);
22
+ endDate = new Date(today);
23
+ endDate.setHours(23, 59, 59, 999);
24
+ break;
25
+
26
+ case AppConstants.OLDER.toLowerCase():
27
+ startDate = new Date(1970, 0, 1);
28
+ endDate = new Date(today);
29
+ break;
30
+
31
+ default:
32
+ const year = parseInt(filter);
33
+ if (!isNaN(year)) {
34
+ return this.getYearRange(year);
35
+ }
36
+ return null;
37
+ }
38
+
39
+ return { startDate, endDate };
40
+ }
41
+
42
+ static getYearRange(year) {
43
+ const today = new Date();
44
+ const startDate = new Date(year, 0, 1);
45
+
46
+ if (year === today.getFullYear()) {
47
+ const endDate = new Date(today);
48
+ endDate.setHours(23, 59, 59, 999);
49
+ return { startDate, endDate };
50
+ }
51
+
52
+ return {
53
+ startDate,
54
+ endDate: new Date(year, 11, 31, 23, 59, 59, 999)
55
+ };
56
+ }
57
+
58
+ static isValidFilter(filter) {
59
+ if (!filter) return false;
60
+
61
+ const validFilters = [
62
+ AppConstants.LAST_30DAYS.toLowerCase(),
63
+ AppConstants.LAST_6MONTHS.toLowerCase(),
64
+ AppConstants.OLDER.toLowerCase()
65
+ ];
66
+
67
+ if (validFilters.includes(filter.toLowerCase())) {
68
+ return true;
69
+ }
70
+
71
+ const year = parseInt(filter);
72
+ const currentYear = new Date().getFullYear();
73
+ return !isNaN(year) && year <= currentYear && year;
74
+ }
75
+
76
+ static buildWhereCondition(filter, Sequelize) {
77
+ const dateRange = this.getDateRange(filter);
78
+ if (!dateRange) return null;
79
+
80
+ return {
81
+ [Sequelize.Op.gte]: dateRange.startDate,
82
+ [Sequelize.Op.lte]: dateRange.endDate
83
+ };
84
+ }
85
+
86
+ }
87
+ module.exports = OrderTimeFilterUtil;
88
+
@@ -1,65 +1,65 @@
1
- // utils/PdfUtil.js
2
- const puppeteer = require('puppeteer');
3
-
4
- class PdfUtil {
5
- constructor(options = {}) {
6
- this.defaultOptions = {
7
- format: 'A4',
8
- printBackground: true,
9
- margin: {
10
- top: '20px',
11
- right: '20px',
12
- bottom: '20px',
13
- left: '20px'
14
- },
15
- ...options
16
- };
17
- }
18
-
19
- /**
20
- * Generate PDF from HTML content
21
- * @param {string} htmlContent - Complete HTML content to convert to PDF
22
- * @param {object} pdfOptions - Optional PDF generation options (overrides defaults)
23
- * @returns {Buffer} PDF buffer
24
- */
25
- async generatePDFFromHTML(htmlContent, pdfOptions = {}) {
26
- let browser;
27
- try {
28
- // Launch puppeteer
29
- browser = await puppeteer.launch({
30
- executablePath: '/usr/bin/chromium',
31
- headless: true,
32
- args: ['--no-sandbox', '--disable-setuid-sandbox','--disable-dev-shm-usage']
33
- });
34
-
35
- const page = await browser.newPage();
36
-
37
- // Set content and wait for any resources to load
38
- await page.setContent(htmlContent, { waitUntil: 'networkidle0' });
39
-
40
- // Merge default options with provided options
41
- const finalOptions = { ...this.defaultOptions, ...pdfOptions };
42
-
43
- // Generate PDF
44
- const pdfBuffer = await page.pdf(finalOptions);
45
-
46
- return pdfBuffer;
47
-
48
- } catch (error) {
49
- throw error;
50
- } finally {
51
- if (browser) {
52
- await browser.close();
53
- }
54
- }
55
- }
56
-
57
- /**
58
- * Generate PDF with custom page settings
59
- */
60
- async generatePDFWithCustomSettings(htmlContent, settings) {
61
- return this.generatePDFFromHTML(htmlContent, settings);
62
- }
63
- }
64
-
1
+ // utils/PdfUtil.js
2
+ const puppeteer = require('puppeteer');
3
+
4
+ class PdfUtil {
5
+ constructor(options = {}) {
6
+ this.defaultOptions = {
7
+ format: 'A4',
8
+ printBackground: true,
9
+ margin: {
10
+ top: '20px',
11
+ right: '20px',
12
+ bottom: '20px',
13
+ left: '20px'
14
+ },
15
+ ...options
16
+ };
17
+ }
18
+
19
+ /**
20
+ * Generate PDF from HTML content
21
+ * @param {string} htmlContent - Complete HTML content to convert to PDF
22
+ * @param {object} pdfOptions - Optional PDF generation options (overrides defaults)
23
+ * @returns {Buffer} PDF buffer
24
+ */
25
+ async generatePDFFromHTML(htmlContent, pdfOptions = {}) {
26
+ let browser;
27
+ try {
28
+ // Launch puppeteer
29
+ browser = await puppeteer.launch({
30
+ executablePath: '/usr/bin/chromium',
31
+ headless: true,
32
+ args: ['--no-sandbox', '--disable-setuid-sandbox','--disable-dev-shm-usage']
33
+ });
34
+
35
+ const page = await browser.newPage();
36
+
37
+ // Set content and wait for any resources to load
38
+ await page.setContent(htmlContent, { waitUntil: 'networkidle0' });
39
+
40
+ // Merge default options with provided options
41
+ const finalOptions = { ...this.defaultOptions, ...pdfOptions };
42
+
43
+ // Generate PDF
44
+ const pdfBuffer = await page.pdf(finalOptions);
45
+
46
+ return pdfBuffer;
47
+
48
+ } catch (error) {
49
+ throw error;
50
+ } finally {
51
+ if (browser) {
52
+ await browser.close();
53
+ }
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Generate PDF with custom page settings
59
+ */
60
+ async generatePDFWithCustomSettings(htmlContent, settings) {
61
+ return this.generatePDFFromHTML(htmlContent, settings);
62
+ }
63
+ }
64
+
65
65
  module.exports = PdfUtil;