@b2y/ecommerce-common 1.0.7 → 1.0.8

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 (77) hide show
  1. package/README.md +4 -4
  2. package/constants/AppConstants.js +3 -3
  3. package/constants/ReportConstants.js +14 -14
  4. package/constants/StatusMessageConstants.js +17 -17
  5. package/dbconnection/Connect.js +420 -384
  6. package/enum/AccessModeEnum.js +7 -0
  7. package/enum/AddressTypeEnum.js +6 -6
  8. package/enum/BillingCycleEnum.js +6 -0
  9. package/enum/BooleanEnum.js +4 -4
  10. package/enum/EntityTypeEnum.js +11 -11
  11. package/enum/FeatureTypeEnum.js +7 -0
  12. package/enum/GenderEnum.js +7 -7
  13. package/enum/NotificationStatusEnum.js +5 -5
  14. package/enum/NotificationTypeEnum.js +9 -9
  15. package/enum/OrderStatusEnum.js +7 -7
  16. package/enum/PaymentMethodEnum.js +6 -6
  17. package/enum/PaymentStatusEnum.js +6 -6
  18. package/enum/PaymentTypeEnum.js +6 -6
  19. package/enum/PlatformEnum.js +4 -4
  20. package/enum/RegistrationStatusEnum.js +5 -5
  21. package/enum/SortByEnum.js +7 -7
  22. package/enum/SubscriptionStatusEnum.js +8 -0
  23. package/index.js +22 -22
  24. package/model/Address.js +95 -95
  25. package/model/AttributeType.js +50 -50
  26. package/model/AttributeValue.js +64 -64
  27. package/model/Banner.js +78 -78
  28. package/model/Brand.js +76 -76
  29. package/model/Cart.js +76 -76
  30. package/model/Category.js +72 -72
  31. package/model/CategoryAttributeType.js +62 -62
  32. package/model/Colour.js +52 -52
  33. package/model/Customer.js +94 -94
  34. package/model/DeviceToken.js +51 -51
  35. package/model/Document.js +70 -70
  36. package/model/DynamicUIComponent.js +52 -52
  37. package/model/Feedback.js +79 -79
  38. package/model/Inventory.js +83 -83
  39. package/model/NotificationHistory.js +67 -67
  40. package/model/Order.js +94 -94
  41. package/model/OrderItem.js +98 -98
  42. package/model/OrderItemHistory.js +69 -69
  43. package/model/OrderStatus.js +48 -48
  44. package/model/Payment.js +101 -101
  45. package/model/PaymentMethod.js +36 -36
  46. package/model/PaymentStatus.js +36 -36
  47. package/model/PaymentType.js +36 -36
  48. package/model/Permission.js +55 -55
  49. package/model/Product.js +82 -82
  50. package/model/ProductGroup.js +48 -48
  51. package/model/ProductSpecification.js +65 -65
  52. package/model/ProductVariant.js +75 -75
  53. package/model/ProductVariantAttribute.js +58 -58
  54. package/model/Role.js +61 -61
  55. package/model/RolePermissionMapping.js +63 -63
  56. package/model/SpecificationType.js +41 -41
  57. package/model/Store.js +99 -99
  58. package/model/StoreUserMapping.js +44 -44
  59. package/model/SubscriptionFeature.js +50 -0
  60. package/model/SubscriptionPlan.js +62 -0
  61. package/model/SubscriptionPlanFeature.js +49 -0
  62. package/model/Tenant.js +91 -91
  63. package/model/TenantSettings.js +47 -47
  64. package/model/TenantSubscription.js +68 -0
  65. package/model/User.js +132 -132
  66. package/model/WishList.js +62 -62
  67. package/package.json +29 -29
  68. package/utility/AppUtil.js +65 -65
  69. package/utility/DateUtil.js +55 -55
  70. package/utility/ExcelUtil.js +125 -125
  71. package/utility/LocationUtility.js +130 -130
  72. package/utility/OrderTimeFilterUtil.js +87 -87
  73. package/utility/PdfUtil.js +63 -63
  74. package/utility/QueryUtil.js +261 -261
  75. package/utility/Razorpay.js +65 -65
  76. package/utility/ResolveAccessMode.js +25 -0
  77. package/utility/VariantPriceUtil.js +54 -54
package/model/User.js CHANGED
@@ -1,132 +1,132 @@
1
- const { DataTypes } = require('sequelize');
2
- const GenderEnum = require('../enum/GenderEnum')
3
- module.exports = (sequelize) => {
4
- return sequelize.define('User', {
5
- UserID: {
6
- type: DataTypes.UUID,
7
- primaryKey: true,
8
- allowNull: false,
9
- defaultValue: DataTypes.UUIDV4
10
- },
11
- TenantID: {
12
- type: DataTypes.UUID,
13
- allowNull: false,
14
- references: {
15
- model: 'Tenant',
16
- key: 'TenantID'
17
- },
18
- onDelete: 'CASCADE',
19
- onUpdate: 'CASCADE'
20
- },
21
- FirstName: {
22
- type: DataTypes.STRING(255),
23
- allowNull: false
24
- },
25
- LastName: {
26
- type: DataTypes.STRING(255),
27
- allowNull: false
28
- },
29
- EmployeeID: {
30
- type: DataTypes.STRING(50),
31
- allowNull: false,
32
- unique: true
33
- },
34
- Email: {
35
- type: DataTypes.STRING(100),
36
- allowNull: false,
37
- },
38
- Password: {
39
- type: DataTypes.STRING(255),
40
- allowNull: false
41
- },
42
- CountryCallingCode: {
43
- type: DataTypes.STRING(5),
44
- allowNull: false
45
- },
46
- PhoneNumber: {
47
- type: DataTypes.STRING(20),
48
- allowNull: false,
49
- },
50
- Gender: {
51
- type: DataTypes.ENUM(...Object.values(GenderEnum)),
52
- allowNull: true
53
- },
54
- RoleID: {
55
- type: DataTypes.UUID,
56
- allowNull: false,
57
- references: {
58
- model: 'Role',
59
- key: 'RoleID'
60
- },
61
- onDelete: 'RESTRICT',
62
- onUpdate: 'CASCADE'
63
- },
64
- AddressLine: {
65
- type: DataTypes.STRING(500),
66
- allowNull: false
67
- },
68
- CityName: {
69
- type: DataTypes.STRING(100),
70
- allowNull: false,
71
- },
72
- StateCode: {
73
- type:DataTypes.STRING(3),
74
- allowNull:false
75
- },
76
- CountryCode:{
77
- type:DataTypes.CHAR(2),
78
- allowNull:false
79
- },
80
- Zipcode: {
81
- type: DataTypes.STRING(20),
82
- allowNull: false
83
- },
84
- OTP: {
85
- type: DataTypes.STRING(10),
86
- allowNull: true
87
- },
88
- OtpExpiry: {
89
- type: DataTypes.DATE,
90
- allowNull: true
91
- },
92
- IsActive: {
93
- type: DataTypes.BOOLEAN,
94
- defaultValue: true
95
- },
96
- CreatedBy: {
97
- type: DataTypes.UUID,
98
- allowNull: false
99
- },
100
- CreatedAt: {
101
- type: DataTypes.DATE,
102
- defaultValue: DataTypes.NOW,
103
- allowNull: false
104
- },
105
- UpdatedBy: {
106
- type: DataTypes.UUID,
107
- allowNull: false
108
- },
109
- UpdatedAt: {
110
- type: DataTypes.DATE,
111
- defaultValue: DataTypes.NOW,
112
- allowNull: false
113
- }
114
- }, {
115
- tableName: 'User',
116
- timestamps: false,
117
- indexes: [
118
- {
119
- name: "UQ_User_Tenant_Email",
120
- unique: true,
121
- fields: ["TenantID", "Email"],
122
- },
123
- {
124
- name: "UQ_User_Tenant_Phone",
125
- unique: true,
126
- fields: ["TenantID", "CountryCallingCode", "PhoneNumber"],
127
- },
128
- ],
129
- });
130
- };
131
-
132
-
1
+ const { DataTypes } = require('sequelize');
2
+ const GenderEnum = require('../enum/GenderEnum')
3
+ module.exports = (sequelize) => {
4
+ return sequelize.define('User', {
5
+ UserID: {
6
+ type: DataTypes.UUID,
7
+ primaryKey: true,
8
+ allowNull: false,
9
+ defaultValue: DataTypes.UUIDV4
10
+ },
11
+ TenantID: {
12
+ type: DataTypes.UUID,
13
+ allowNull: false,
14
+ references: {
15
+ model: 'Tenant',
16
+ key: 'TenantID'
17
+ },
18
+ onDelete: 'CASCADE',
19
+ onUpdate: 'CASCADE'
20
+ },
21
+ FirstName: {
22
+ type: DataTypes.STRING(255),
23
+ allowNull: false
24
+ },
25
+ LastName: {
26
+ type: DataTypes.STRING(255),
27
+ allowNull: false
28
+ },
29
+ EmployeeID: {
30
+ type: DataTypes.STRING(50),
31
+ allowNull: false,
32
+ unique: true
33
+ },
34
+ Email: {
35
+ type: DataTypes.STRING(100),
36
+ allowNull: false,
37
+ },
38
+ Password: {
39
+ type: DataTypes.STRING(255),
40
+ allowNull: false
41
+ },
42
+ CountryCallingCode: {
43
+ type: DataTypes.STRING(5),
44
+ allowNull: false
45
+ },
46
+ PhoneNumber: {
47
+ type: DataTypes.STRING(20),
48
+ allowNull: false,
49
+ },
50
+ Gender: {
51
+ type: DataTypes.ENUM(...Object.values(GenderEnum)),
52
+ allowNull: true
53
+ },
54
+ RoleID: {
55
+ type: DataTypes.UUID,
56
+ allowNull: false,
57
+ references: {
58
+ model: 'Role',
59
+ key: 'RoleID'
60
+ },
61
+ onDelete: 'RESTRICT',
62
+ onUpdate: 'CASCADE'
63
+ },
64
+ AddressLine: {
65
+ type: DataTypes.STRING(500),
66
+ allowNull: false
67
+ },
68
+ CityName: {
69
+ type: DataTypes.STRING(100),
70
+ allowNull: false,
71
+ },
72
+ StateCode: {
73
+ type:DataTypes.STRING(3),
74
+ allowNull:false
75
+ },
76
+ CountryCode:{
77
+ type:DataTypes.CHAR(2),
78
+ allowNull:false
79
+ },
80
+ Zipcode: {
81
+ type: DataTypes.STRING(20),
82
+ allowNull: false
83
+ },
84
+ OTP: {
85
+ type: DataTypes.STRING(10),
86
+ allowNull: true
87
+ },
88
+ OtpExpiry: {
89
+ type: DataTypes.DATE,
90
+ allowNull: true
91
+ },
92
+ IsActive: {
93
+ type: DataTypes.BOOLEAN,
94
+ defaultValue: true
95
+ },
96
+ CreatedBy: {
97
+ type: DataTypes.UUID,
98
+ allowNull: false
99
+ },
100
+ CreatedAt: {
101
+ type: DataTypes.DATE,
102
+ defaultValue: DataTypes.NOW,
103
+ allowNull: false
104
+ },
105
+ UpdatedBy: {
106
+ type: DataTypes.UUID,
107
+ allowNull: false
108
+ },
109
+ UpdatedAt: {
110
+ type: DataTypes.DATE,
111
+ defaultValue: DataTypes.NOW,
112
+ allowNull: false
113
+ }
114
+ }, {
115
+ tableName: 'User',
116
+ timestamps: false,
117
+ indexes: [
118
+ {
119
+ name: "UQ_User_Tenant_Email",
120
+ unique: true,
121
+ fields: ["TenantID", "Email"],
122
+ },
123
+ {
124
+ name: "UQ_User_Tenant_Phone",
125
+ unique: true,
126
+ fields: ["TenantID", "CountryCallingCode", "PhoneNumber"],
127
+ },
128
+ ],
129
+ });
130
+ };
131
+
132
+
package/model/WishList.js CHANGED
@@ -1,63 +1,63 @@
1
- const { DataTypes } = require('sequelize');
2
-
3
- module.exports = (sequelize) => {
4
- return sequelize.define('WishList', {
5
- WishListID: {
6
- type: DataTypes.UUID,
7
- primaryKey: true,
8
- allowNull: false,
9
- defaultValue: DataTypes.UUIDV4
10
- },
11
- TenantID: {
12
- type: DataTypes.UUID,
13
- allowNull: false,
14
- references: {
15
- model: 'Tenant',
16
- key: 'TenantID'
17
- },
18
- onDelete: 'CASCADE',
19
- onUpdate: 'CASCADE'
20
- },
21
- ProductVariantID: {
22
- type: DataTypes.UUID,
23
- allowNull: false,
24
- references: {
25
- model: 'ProductVariant',
26
- key: 'ProductVariantID'
27
- },
28
- onDelete: 'RESTRICT',
29
- onUpdate: 'CASCADE'
30
- },
31
- CustomerID: {
32
- type: DataTypes.UUID,
33
- allowNull: false,
34
- references: {
35
- model: 'Customer',
36
- key: 'CustomerID'
37
- },
38
- onDelete: 'RESTRICT',
39
- onUpdate: 'CASCADE'
40
- },
41
- CreatedBy: {
42
- type: DataTypes.UUID,
43
- allowNull: false
44
- },
45
- CreatedAt: {
46
- type: DataTypes.DATE,
47
- allowNull: false,
48
- defaultValue: DataTypes.NOW
49
- },
50
- UpdatedBy: {
51
- type: DataTypes.UUID,
52
- allowNull: false
53
- },
54
- UpdatedAt: {
55
- type: DataTypes.DATE,
56
- allowNull: false,
57
- defaultValue: DataTypes.NOW
58
- }
59
- }, {
60
- tableName: 'WishList',
61
- timestamps: false
62
- });
1
+ const { DataTypes } = require('sequelize');
2
+
3
+ module.exports = (sequelize) => {
4
+ return sequelize.define('WishList', {
5
+ WishListID: {
6
+ type: DataTypes.UUID,
7
+ primaryKey: true,
8
+ allowNull: false,
9
+ defaultValue: DataTypes.UUIDV4
10
+ },
11
+ TenantID: {
12
+ type: DataTypes.UUID,
13
+ allowNull: false,
14
+ references: {
15
+ model: 'Tenant',
16
+ key: 'TenantID'
17
+ },
18
+ onDelete: 'CASCADE',
19
+ onUpdate: 'CASCADE'
20
+ },
21
+ ProductVariantID: {
22
+ type: DataTypes.UUID,
23
+ allowNull: false,
24
+ references: {
25
+ model: 'ProductVariant',
26
+ key: 'ProductVariantID'
27
+ },
28
+ onDelete: 'RESTRICT',
29
+ onUpdate: 'CASCADE'
30
+ },
31
+ CustomerID: {
32
+ type: DataTypes.UUID,
33
+ allowNull: false,
34
+ references: {
35
+ model: 'Customer',
36
+ key: 'CustomerID'
37
+ },
38
+ onDelete: 'RESTRICT',
39
+ onUpdate: 'CASCADE'
40
+ },
41
+ CreatedBy: {
42
+ type: DataTypes.UUID,
43
+ allowNull: false
44
+ },
45
+ CreatedAt: {
46
+ type: DataTypes.DATE,
47
+ allowNull: false,
48
+ defaultValue: DataTypes.NOW
49
+ },
50
+ UpdatedBy: {
51
+ type: DataTypes.UUID,
52
+ allowNull: false
53
+ },
54
+ UpdatedAt: {
55
+ type: DataTypes.DATE,
56
+ allowNull: false,
57
+ defaultValue: DataTypes.NOW
58
+ }
59
+ }, {
60
+ tableName: 'WishList',
61
+ timestamps: false
62
+ });
63
63
  };
package/package.json CHANGED
@@ -1,29 +1,29 @@
1
- {
2
- "name": "@b2y/ecommerce-common",
3
- "version": "1.0.7",
4
- "description": "E-commerce common library",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/yuvakrishna29/ecommerce-common.git"
12
- },
13
- "publishConfig": {
14
- "access": "public"
15
- },
16
- "author": "Shikha",
17
- "license": "ISC",
18
- "bugs": {
19
- "url": "https://github.com/yuvakrishna29/ecommerce-common/issues"
20
- },
21
- "homepage": "https://github.com/yuvakrishna29/ecommerce-common#readme",
22
- "peerDependencies": {
23
- "@countrystatecity/countries": "^1.0.4",
24
- "exceljs": "^4.4.0",
25
- "luxon": "^3.7.2",
26
- "puppeteer": "^24.35.0",
27
- "sequelize": "^6.37.5"
28
- }
29
- }
1
+ {
2
+ "name": "@b2y/ecommerce-common",
3
+ "version": "1.0.8",
4
+ "description": "E-commerce common library",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/yuvakrishna29/ecommerce-common.git"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "author": "Shikha",
17
+ "license": "ISC",
18
+ "bugs": {
19
+ "url": "https://github.com/yuvakrishna29/ecommerce-common/issues"
20
+ },
21
+ "homepage": "https://github.com/yuvakrishna29/ecommerce-common#readme",
22
+ "peerDependencies": {
23
+ "@countrystatecity/countries": "^1.0.4",
24
+ "exceljs": "^4.4.0",
25
+ "luxon": "^3.7.2",
26
+ "puppeteer": "^24.35.0",
27
+ "sequelize": "^6.37.5"
28
+ }
29
+ }
@@ -1,66 +1,66 @@
1
- const BooleanEnum = require('../enum/BooleanEnum');
2
- const AppUtil = {
3
- generateResponse: function (statusCode, status, message, payload, res, customCode = null) {
4
- let response = {
5
- status,
6
- };
7
- if (
8
- payload &&
9
- (Array.isArray(payload) || Object.keys(payload).length > 0)
10
- ) {
11
- if (payload.rows && typeof payload.count !== "undefined") {
12
- const { rows, count, pageNumber, limit } = payload;
13
- const currentPage = Number(pageNumber) || 1;
14
- const pageSize = Number(limit) || count;
15
- const totalPages = Math.ceil(count / pageSize);
16
- response.data = rows;
17
- response.pagination = {
18
- totalRecords: count,
19
- totalPages,
20
- currentPage,
21
- pageSize,
22
- hasNext: currentPage < totalPages,
23
- hasPrev: currentPage > 1,
24
- };
25
- } else {
26
- // Non-paginated response
27
- response.data = payload;
28
- }
29
- }
30
- if (message) {
31
- // No data => return message (POST/PUT/DELETE-like APIs)
32
- response.message = message || "";
33
- }
34
- // if custome code also need to send in reponse body
35
- if (customCode) {
36
- response.customCode = customCode;
37
- }
38
- res.status(statusCode).send(response);
39
- },
40
- parseIsActive: function (isActive) {
41
- if (isActive === true || isActive === "true") return BooleanEnum.TRUE;
42
- if (isActive === false || isActive === "false") return BooleanEnum.FALSE;
43
- return undefined;
44
- },
45
- getPagination: function (page, size) {
46
- if (!size || !page) return {};
47
- const limit = +size;
48
- const offset = (page - 1) * limit;
49
- return { limit, offset };
50
- },
51
- trimDecimal: function (decimal) {
52
- const value = parseFloat(decimal);
53
- return Math.round(value)
54
- },
55
- isValidEmail: function (email) {
56
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
57
- return emailRegex.test(email.trim());
58
- },
59
- isValidPhone: function (phoneNumber) {
60
- const phoneRegex = /^\d{10,20}$/;
61
- return phoneRegex.test(phoneNumber);
62
- }
63
- };
64
-
65
-
1
+ const BooleanEnum = require('../enum/BooleanEnum');
2
+ const AppUtil = {
3
+ generateResponse: function (statusCode, status, message, payload, res, customCode = null) {
4
+ let response = {
5
+ status,
6
+ };
7
+ if (
8
+ payload &&
9
+ (Array.isArray(payload) || Object.keys(payload).length > 0)
10
+ ) {
11
+ if (payload.rows && typeof payload.count !== "undefined") {
12
+ const { rows, count, pageNumber, limit } = payload;
13
+ const currentPage = Number(pageNumber) || 1;
14
+ const pageSize = Number(limit) || count;
15
+ const totalPages = Math.ceil(count / pageSize);
16
+ response.data = rows;
17
+ response.pagination = {
18
+ totalRecords: count,
19
+ totalPages,
20
+ currentPage,
21
+ pageSize,
22
+ hasNext: currentPage < totalPages,
23
+ hasPrev: currentPage > 1,
24
+ };
25
+ } else {
26
+ // Non-paginated response
27
+ response.data = payload;
28
+ }
29
+ }
30
+ if (message) {
31
+ // No data => return message (POST/PUT/DELETE-like APIs)
32
+ response.message = message || "";
33
+ }
34
+ // if custome code also need to send in reponse body
35
+ if (customCode) {
36
+ response.customCode = customCode;
37
+ }
38
+ res.status(statusCode).send(response);
39
+ },
40
+ parseIsActive: function (isActive) {
41
+ if (isActive === true || isActive === "true") return BooleanEnum.TRUE;
42
+ if (isActive === false || isActive === "false") return BooleanEnum.FALSE;
43
+ return undefined;
44
+ },
45
+ getPagination: function (page, size) {
46
+ if (!size || !page) return {};
47
+ const limit = +size;
48
+ const offset = (page - 1) * limit;
49
+ return { limit, offset };
50
+ },
51
+ trimDecimal: function (decimal) {
52
+ const value = parseFloat(decimal);
53
+ return Math.round(value)
54
+ },
55
+ isValidEmail: function (email) {
56
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
57
+ return emailRegex.test(email.trim());
58
+ },
59
+ isValidPhone: function (phoneNumber) {
60
+ const phoneRegex = /^\d{10,20}$/;
61
+ return phoneRegex.test(phoneNumber);
62
+ }
63
+ };
64
+
65
+
66
66
  module.exports = AppUtil;