@b2y/ecommerce-common 1.2.1 → 1.2.3

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.
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ </content>
9
+ <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ </component>
12
+ </module>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/ecommerce-common.iml" filepath="$PROJECT_DIR$/.idea/ecommerce-common.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -10,6 +10,7 @@ const AppConstants = {
10
10
  CUSTOMER_PORTAL_DOMAIN: 'CustomerPortalDomain',
11
11
  ADMIN_PORTAL_DOMAIN: 'AdminPortalDomain',
12
12
  CREATED_BY:'0000d6ab-8064-4786-a906-f458567224b8',
13
- BOOLEAN:'boolean'
13
+ BOOLEAN:'boolean',
14
+ OBJECT: 'object'
14
15
  }
15
16
  module.exports = AppConstants;
@@ -3,6 +3,9 @@ const StatusMessageConstants = {
3
3
  FAILURE: 'FAILURE',
4
4
  INVALID_REQUEST: 'Invalid request parameters',
5
5
  SERVER_ERROR: 'Internal server error',
6
+ INVALID_JSON_FORMAT: 'Invalid JSON format in request body',
7
+ INVALID_SORT_ORDER: 'SortOrder must be integer',
8
+ FILE_NOT_FOUND: 'File not found',
6
9
  // Tenant
7
10
  TENANT_NOT_FOUND: 'Tenant not found',
8
11
  TENANT_ID_REQUIRED_FIELD: 'TenantID is required for updating the tenant',
@@ -22,10 +25,15 @@ const StatusMessageConstants = {
22
25
  INVALID_START_END_DATE: 'End date can not be before start date',
23
26
  SUBSCRIPTION_PLAN_NOT_FOUND: "Subscription plan not found",
24
27
  INVALID_BOOLEAN_TYPE: "{field} must be boolean value",
25
-
26
28
  //TenantSettings
27
- TENANT_SETTINGS_NOT_FOUND: "Tenant settings not foundd",
28
-
29
+ TENANT_SETTINGS_NOT_FOUND: 'Tenant settings not found',
30
+ TENANT_SETTINGS_IMAGE_UPLOAD_FAILED: 'Failed to upload company logo',
31
+ TENANT_SETTINGS_REQUIRED_FIELD: 'TenantID is required for tenant settings updation',
32
+ TENANT_SETTINGS_UPDATED_SUCCESS: 'Tenant settings updated successfully',
33
+ TENANT_SETTINGS_ALREADY_EXISTS: 'Tenant settings already exist for this tenant',
34
+ INVALID_REQUEST: 'Invalid request',
35
+ TENANT_SETTINGS_UPDATE_ERROR: 'Failed to update tenant settings',
36
+ TENANT_SETTINGS_SINGLE_LOGO_ALLOWED: "Only one logo is allowed per tenant.",
29
37
  //Location
30
38
  STATE_CODE_COUNTRY_CODE_REQUIRE: "State code and country code are required to fetch cities",
31
39
  CITIES_NOT_FOUND: "No cities found for given state code",
@@ -1,7 +1,6 @@
1
1
  const StatusMessage = require('../constants/StatusMessageConstants');
2
2
  const AppUtil = require('../utility/AppUtil');
3
- const LocationUtility = require('../utility/LocationUtility');
4
- const EntityTypeEnum = require('../enum/EntityTypeEnum');
3
+
5
4
  // getAllSubscriptionPlans
6
5
  const getAllSubscriptionPlans = (
7
6
  SubscriptionPlan,
@@ -56,129 +55,5 @@ const getAllSubscriptionPlans = (
56
55
  };
57
56
  };
58
57
 
59
- const getTenantSubscription = (
60
- Tenant,
61
- TenantSubscription,
62
- SubscriptionPlan,
63
- TenantSettings,
64
- Document,
65
- getPublicUrl,
66
- logger,
67
- ) => {
68
- return async (req, res) => {
69
- try {
70
- const { id } = req.params;
71
-
72
- const tenant = await Tenant.findOne({
73
- where: { TenantID: id },
74
- include: [
75
- {
76
- model: TenantSettings,
77
- as: 'TenantSettings',
78
- attributes: ['TenantSettingID']
79
- },
80
- {
81
- model: TenantSubscription,
82
- as: "CurrentSubscription",
83
- attributes: [
84
- "TenantSubscriptionID",
85
- "Status",
86
- "StartDate",
87
- "EndDate",
88
- "GraceEndDate",
89
- "TrialEndDate",
90
- "IsTrial",
91
- "AutoRenew",
92
- ],
93
- include: [
94
- {
95
- model: SubscriptionPlan,
96
- as: "SubscriptionPlan",
97
- attributes: ["SubscriptionPlanID", "PlanName", "PlanCode"],
98
- },
99
- ],
100
- },
101
- ],
102
- });
103
-
104
- if (!tenant) {
105
- return AppUtil.generateResponse(
106
- 404,
107
- StatusMessage.FAILURE,
108
- StatusMessage.TENANT_NOT_FOUND,
109
- null,
110
- res,
111
- );
112
- }
113
- const documents = await Document.findAll({
114
- where: {
115
- EntityType: EntityTypeEnum.TENANT_SETTINGS,
116
- EntityID: tenant.TenantSettings.TenantSettingID
117
- },
118
- order: [["SortOrder", "ASC"]]
119
- });
120
-
121
- const logo = await Promise.all(
122
- documents.map(async (doc) => ({
123
- documentId: doc.DocumentID,
124
- sortOrder: doc.SortOrder,
125
- documentUrl: await getPublicUrl(doc, logger)
126
- }))
127
- );
128
- const { countryName, stateName } =
129
- await LocationUtility.resolveCountryAndState(
130
- tenant.CountryCode,
131
- tenant.StateCode,
132
- logger,
133
- );
134
-
135
- const formattedTenant = {
136
- TenantID: tenant.TenantID,
137
- CompanyName: tenant.CompanyName,
138
- CompanyCode: tenant.CompanyCode,
139
- Email: tenant.Email,
140
- CountryCallingCode: tenant.CountryCallingCode,
141
- PhoneNumber: tenant.PhoneNumber,
142
- GSTNo: tenant.GSTNo,
143
- CustomerPortalDomain: tenant.CustomerPortalDomain,
144
- AdminPortalDomain: tenant.AdminPortalDomain,
145
- AddressLine: tenant.AddressLine,
146
- CityName: tenant.CityName,
147
- StateCode: tenant.StateCode,
148
- StateName: stateName,
149
- CountryCode: tenant.CountryCode,
150
- CountryName: countryName,
151
- Zipcode: tenant.Zipcode,
152
- TenantLogo: logo,
153
- SubscriptionPlanID: tenant.CurrentSubscription?.SubscriptionPlan?.SubscriptionPlanID,
154
- PlanName: tenant.CurrentSubscription?.SubscriptionPlan?.PlanName,
155
- TenantSubscriptionStatus: tenant.CurrentSubscription?.Status,
156
- StartDate: tenant.CurrentSubscription?.StartDate,
157
- EndDate: tenant.CurrentSubscription?.EndDate,
158
- GraceEndDate: tenant.CurrentSubscription?.GraceEndDate,
159
- TrialEndDate: tenant.CurrentSubscription?.TrialEndDate,
160
- IsTrial: tenant.CurrentSubscription?.IsTrial,
161
- AutoRenew: tenant.CurrentSubscription?.AutoRenew,
162
- };
163
-
164
- return AppUtil.generateResponse(
165
- 200,
166
- StatusMessage.SUCCESS,
167
- null,
168
- formattedTenant,
169
- res,
170
- );
171
- } catch (error) {
172
- logger.error("Error fetching tenant:", error);
173
- return AppUtil.generateResponse(
174
- 500,
175
- StatusMessage.FAILURE,
176
- StatusMessage.SERVER_ERROR,
177
- null,
178
- res,
179
- );
180
- }
181
- };
182
- };
183
58
 
184
- module.exports = {getAllSubscriptionPlans, getTenantSubscription}
59
+ module.exports = {getAllSubscriptionPlans}
@@ -3,7 +3,7 @@ const StatusMessage = require('../constants/StatusMessageConstants');
3
3
  const AppUtil = require('../utility/AppUtil');
4
4
  const SubscriptionStatusEnum = require('../enum/SubscriptionStatusEnum');
5
5
  const AppConstants = require('../constants/AppConstants');
6
-
6
+ const EntityTypeEnum = require('../enum/EntityTypeEnum');
7
7
  const updateTenant = (
8
8
  Tenant,
9
9
  TenantSubscription,
@@ -348,5 +348,148 @@ const updateTenant = (
348
348
  };
349
349
  };
350
350
 
351
- module.exports = { updateTenant };
351
+ const getTenantById = (
352
+ Tenant,
353
+ TenantSubscription,
354
+ SubscriptionPlan,
355
+ TenantSettings,
356
+ Document,
357
+ getPublicUrl,
358
+ logger,
359
+ ) => {
360
+ return async (req, res) => {
361
+ try {
362
+ const { id } = req.params;
363
+
364
+ const tenant = await Tenant.findOne({
365
+ where: { TenantID: id },
366
+ attributes: [
367
+ 'TenantID',
368
+ 'CompanyName',
369
+ 'CompanyCode',
370
+ 'Email',
371
+ 'CountryCallingCode',
372
+ 'PhoneNumber',
373
+ 'GSTNo',
374
+ 'CustomerPortalDomain',
375
+ 'AdminPortalDomain',
376
+ 'AddressLine',
377
+ 'CityName',
378
+ 'StateCode',
379
+ 'CountryCode',
380
+ 'Zipcode',
381
+ ],
382
+ include: [
383
+ {
384
+ model: TenantSettings,
385
+ as: 'TenantSettings',
386
+ attributes: ['TenantSettingID']
387
+ },
388
+ {
389
+ model: TenantSubscription,
390
+ as: "CurrentSubscription",
391
+ attributes: [
392
+ "TenantSubscriptionID",
393
+ "Status",
394
+ "StartDate",
395
+ "EndDate",
396
+ "GraceEndDate",
397
+ "TrialEndDate",
398
+ "IsTrial",
399
+ "AutoRenew",
400
+ ],
401
+ include: [
402
+ {
403
+ model: SubscriptionPlan,
404
+ as: "SubscriptionPlan",
405
+ attributes: ["SubscriptionPlanID", "PlanName", "PlanCode"],
406
+ },
407
+ ],
408
+ },
409
+ ],
410
+ });
411
+
412
+ if (!tenant) {
413
+ return AppUtil.generateResponse(
414
+ 404,
415
+ StatusMessage.FAILURE,
416
+ StatusMessage.TENANT_NOT_FOUND,
417
+ null,
418
+ res,
419
+ );
420
+ }
421
+ let logo = null;;
422
+ if(tenant.TenantSettings) {
423
+ const document = await Document.findOne({
424
+ where: {
425
+ EntityType: EntityTypeEnum.TENANT_SETTINGS,
426
+ EntityID: tenant.TenantSettings.TenantSettingID,
427
+ },
428
+ order: [["SortOrder", "ASC"]],
429
+ });
430
+ if (document) {
431
+ logo = {
432
+ documentId: document.DocumentID,
433
+ sortOrder: document.SortOrder,
434
+ documentUrl: await getPublicUrl(document, logger),
435
+ };
436
+ }
437
+ }
438
+ const { countryName, stateName } =
439
+ await LocationUtility.resolveCountryAndState(
440
+ tenant.CountryCode,
441
+ tenant.StateCode,
442
+ logger,
443
+ );
444
+
445
+ const formattedTenant = {
446
+ TenantID: tenant.TenantID,
447
+ CompanyName: tenant.CompanyName,
448
+ CompanyCode: tenant.CompanyCode,
449
+ Email: tenant.Email,
450
+ CountryCallingCode: tenant.CountryCallingCode,
451
+ PhoneNumber: tenant.PhoneNumber,
452
+ GSTNo: tenant.GSTNo,
453
+ CustomerPortalDomain: tenant.CustomerPortalDomain,
454
+ AdminPortalDomain: tenant.AdminPortalDomain,
455
+ AddressLine: tenant.AddressLine,
456
+ CityName: tenant.CityName,
457
+ StateCode: tenant.StateCode,
458
+ StateName: stateName,
459
+ CountryCode: tenant.CountryCode,
460
+ CountryName: countryName,
461
+ Zipcode: tenant.Zipcode,
462
+ TenantLogo: logo,
463
+ SubscriptionPlanID: tenant.CurrentSubscription?.SubscriptionPlan?.SubscriptionPlanID,
464
+ PlanName: tenant.CurrentSubscription?.SubscriptionPlan?.PlanName,
465
+ TenantSubscriptionStatus: tenant.CurrentSubscription?.Status,
466
+ StartDate: tenant.CurrentSubscription?.StartDate,
467
+ EndDate: tenant.CurrentSubscription?.EndDate,
468
+ GraceEndDate: tenant.CurrentSubscription?.GraceEndDate,
469
+ TrialEndDate: tenant.CurrentSubscription?.TrialEndDate,
470
+ IsTrial: tenant.CurrentSubscription?.IsTrial,
471
+ AutoRenew: tenant.CurrentSubscription?.AutoRenew,
472
+ };
473
+
474
+ return AppUtil.generateResponse(
475
+ 200,
476
+ StatusMessage.SUCCESS,
477
+ null,
478
+ formattedTenant,
479
+ res,
480
+ );
481
+ } catch (error) {
482
+ logger.error("Error fetching tenant:", error);
483
+ return AppUtil.generateResponse(
484
+ 500,
485
+ StatusMessage.FAILURE,
486
+ StatusMessage.SERVER_ERROR,
487
+ null,
488
+ res,
489
+ );
490
+ }
491
+ };
492
+ };
493
+
494
+ module.exports = { updateTenant, getTenantById };
352
495
 
@@ -1,6 +1,35 @@
1
1
  const EntityTypeEnum = require('../enum/EntityTypeEnum');
2
2
  const StatusMessage = require('../constants/StatusMessageConstants');
3
3
  const AppUtil = require('../utility/AppUtil');
4
+ const AppConstants = require('../constants/AppConstants')
5
+
6
+ const tenantSettingsDocumentValidation = async (
7
+ file,
8
+ documentMetadata,
9
+ FileUploadUtil,
10
+ FILE_PATHS,
11
+ logger
12
+ ) => {
13
+ if (documentMetadata !== undefined) {
14
+ if (
15
+ typeof documentMetadata !== AppConstants.OBJECT ||
16
+ Array.isArray(documentMetadata)
17
+ ) {
18
+ logger.warn(
19
+ "Validation Failed: documentMetadata must be a single object for this operation.",
20
+ );
21
+ throw new Error(StatusMessage.TENANT_SETTINGS_SINGLE_LOGO_ALLOWED);
22
+ }
23
+ logger.info("Uploading new files to storage before transaction");
24
+ const uploadResult = await FileUploadUtil.uploadFilesToStorage(
25
+ documentMetadata,
26
+ file,
27
+ FILE_PATHS.IMAGE_DIR,
28
+ );
29
+ return uploadResult
30
+ }
31
+ return [];
32
+ };
4
33
 
5
34
  const getTenantSettingsById = (TenantSettings, Document, getPublicUrl, logger) => {
6
35
  return async (req, res) => {
@@ -23,22 +52,21 @@ return async (req, res) => {
23
52
  res
24
53
  );
25
54
  }
26
-
27
- const documents = await Document.findAll({
55
+ let logo = null;
56
+ const document = await Document.findOne({
28
57
  where: {
29
58
  EntityType: EntityTypeEnum.TENANT_SETTINGS,
30
59
  EntityID: settings.TenantSettingID
31
60
  },
32
61
  order: [["SortOrder", "ASC"]]
33
62
  });
34
-
35
- const logo = await Promise.all(
36
- documents.map(async (doc) => ({
37
- documentId: doc.DocumentID,
38
- sortOrder: doc.SortOrder,
39
- documentUrl: await getPublicUrl(doc, logger)
40
- }))
41
- );
63
+ if(document) {
64
+ logo = {
65
+ documentId: document.DocumentID,
66
+ sortOrder: document.SortOrder,
67
+ documentUrl: await getPublicUrl(document, logger)
68
+ }
69
+ }
42
70
  const formattedSettings = {
43
71
  TenantSettingID: settings.TenantSettingID,
44
72
  TenantID: settings.TenantID,
@@ -66,5 +94,144 @@ return async (req, res) => {
66
94
  }
67
95
  }}
68
96
 
69
- module.exports = {getTenantSettingsById};
97
+ const updateTenantSettings = (TenantSettings, multer, upload, FileUploadUtil, FILE_PATHS, UpdatedBy, sequelize, logger) => {
98
+ return async (req, res) => {
99
+ upload(req, res, async (err) => {
100
+ if (err instanceof multer.MulterError || err) {
101
+ logger.error('Upload Error:', err);
102
+ return AppUtil.generateResponse(
103
+ 400,
104
+ StatusMessage.FAILURE,
105
+ StatusMessage.TENANT_SETTINGS_IMAGE_UPLOAD_FAILED,
106
+ null,
107
+ res
108
+ );
109
+ }
110
+
111
+ let transaction;
112
+ let uploadedFilePath = [];
113
+ try {
114
+ let data;
115
+ try {
116
+ data = req.body.data ? JSON.parse(req.body.data) : req.body;
117
+ } catch (error) {
118
+ logger.error('Invalid JSON in request body', error);
119
+ return AppUtil.generateResponse(
120
+ 400,
121
+ StatusMessage.FAILURE,
122
+ StatusMessage.INVALID_JSON_FORMAT,
123
+ null,
124
+ res
125
+ );
126
+ }
127
+
128
+ const {
129
+ TenantSettingID,
130
+ TenantID,
131
+ ThemeColour,
132
+ documentMetadata
133
+ } = data;
134
+
135
+ // Validation
136
+ if (!TenantSettingID && !TenantID) {
137
+ logger.warn('TenantSettingID or TenantID is required for update.');
138
+ return AppUtil.generateResponse(
139
+ 400,
140
+ StatusMessage.FAILURE,
141
+ StatusMessage.TENANT_SETTINGS_REQUIRED_FIELD,
142
+ null,
143
+ res
144
+ );
145
+ }
146
+
147
+ // Find existing settings
148
+ const whereClause = TenantSettingID ? { TenantSettingID } : { TenantID };
149
+ const existingSettings = await TenantSettings.findOne({ where: whereClause });
150
+
151
+ if (!existingSettings) {
152
+ logger.warn('Tenant settings not found for update', whereClause);
153
+ return AppUtil.generateResponse(
154
+ 404,
155
+ StatusMessage.FAILURE,
156
+ StatusMessage.TENANT_SETTINGS_NOT_FOUND,
157
+ null,
158
+ res
159
+ );
160
+ }
161
+
162
+ // Upload new file to storage before starting transaction
163
+ const uploadResult = await tenantSettingsDocumentValidation(req.files, documentMetadata, FileUploadUtil, FILE_PATHS, logger)
164
+ if(uploadResult.length > 0) {
165
+ uploadedFilePath = uploadResult.map(result => result.path)
166
+ }
167
+
168
+ // Start database transaction
169
+ transaction = await sequelize.transaction();
170
+
171
+ // Update tenant settings
172
+ const updatePayload = {};
173
+ if (ThemeColour !== undefined) updatePayload.ThemeColour = ThemeColour;
174
+ updatePayload.UpdatedBy = UpdatedBy;
175
+ updatePayload.UpdatedAt = new Date();
176
+
177
+ await existingSettings.update(updatePayload, { transaction });
178
+
179
+ // Save/Update documents (handles both create and replace logic)
180
+ if (uploadResult.length > 0) {
181
+ logger.info('Saving document records for TenantSettingID:', existingSettings.TenantSettingID);
182
+
183
+ await FileUploadUtil.saveDocumentRecords(
184
+ uploadResult,
185
+ EntityTypeEnum.TENANT_SETTINGS,
186
+ existingSettings.TenantSettingID,
187
+ existingSettings.TenantID,
188
+ UpdatedBy,
189
+ transaction
190
+ );
191
+ }
192
+
193
+ await transaction.commit();
194
+ logger.info('Tenant settings updated successfully');
195
+
196
+ return AppUtil.generateResponse(
197
+ 200,
198
+ StatusMessage.SUCCESS,
199
+ StatusMessage.TENANT_SETTINGS_UPDATED_SUCCESS,
200
+ null,
201
+ res
202
+ );
203
+
204
+ } catch (error) {
205
+ if (transaction) await transaction.rollback();
206
+
207
+ // Cleanup newly uploaded files if transaction failed
208
+ if (uploadedFilePath.length > 0) {
209
+ logger.info('Cleaning up uploaded files due to error');
210
+ await FileUploadUtil.cleanupFiles(uploadedFilePath);
211
+ }
212
+ const errorMessages = [
213
+ StatusMessage.INVALID_SORT_ORDER,
214
+ StatusMessage.FILE_NOT_FOUND,
215
+ StatusMessage.INVALID_FILE_UPLOAD_INPUT,
216
+ StatusMessage.TENANT_SETTINGS_SINGLE_LOGO_ALLOWED,
217
+ ];
218
+ // Error handling
219
+ if (errorMessages.includes(error.message)) {
220
+ return AppUtil.generateResponse(400, StatusMessage.FAILURE, error.message, null, res);
221
+ }
222
+ if (error.name === 'SequelizeUniqueConstraintError') {
223
+ return AppUtil.generateResponse(400, StatusMessage.FAILURE, StatusMessage.TENANT_SETTINGS_ALREADY_EXISTS, null, res);
224
+ } else if (error.name === 'SequelizeValidationError') {
225
+ const details = error.errors.map((e) => e.message);
226
+ logger.warn(`Validation Error detected: ${details.join('; ')}`);
227
+ return AppUtil.generateResponse(400, StatusMessage.FAILURE, StatusMessage.INVALID_REQUEST, null, res);
228
+ } else {
229
+ logger.error("Error in updateTenantSettings:", error);
230
+ return AppUtil.generateResponse(500, StatusMessage.FAILURE, StatusMessage.TENANT_SETTINGS_UPDATE_ERROR, null, res);
231
+ }
232
+ }
233
+ });
234
+ };
235
+ }
236
+ module.exports = {getTenantSettingsById, updateTenantSettings, tenantSettingsDocumentValidation};
70
237
 
@@ -193,10 +193,6 @@ const initializeModels = (sequelize) => {
193
193
  as: "Customer",
194
194
  });
195
195
 
196
- Order.belongsTo(Address, {
197
- foreignKey: "AddressID",
198
- as: "Address",
199
- });
200
196
 
201
197
  Order.hasMany(OrderItem, {
202
198
  foreignKey: "OrderID",
package/index.js CHANGED
@@ -5,7 +5,8 @@ const SubscriptionAbstractController = require('./controller/SubscriptionAbstrac
5
5
  const TenantAbstractController = require('./controller/TenantAbstractController');
6
6
  const TenantSettingsAbstractController = require('./controller/TenantSettingsAbstractController');
7
7
  const LocationController = require('./controller/LocationController');
8
- const PermissionAbstractController = require('./controller/PermissionAbstractController');
8
+ const CommonAppConstants = require('./constants/AppConstants');
9
+ const CommonStatusMessage = require('./constants/StatusMessageConstants');
9
10
  const enums = {};
10
11
  const enumDir = path.join(__dirname, 'enum');
11
12
  fs.readdirSync(enumDir).forEach((file) => {
@@ -23,4 +24,4 @@ fs.readdirSync(utilDir).forEach((file) => {
23
24
  }
24
25
  })
25
26
 
26
- module.exports = {initializeModels, enums, utils, SubscriptionAbstractController, TenantAbstractController, TenantSettingsAbstractController, LocationController, PermissionAbstractController};
27
+ module.exports = {initializeModels, enums, utils, CommonAppConstants, CommonStatusMessage, SubscriptionAbstractController, TenantAbstractController, TenantSettingsAbstractController, LocationController};
package/model/Order.js CHANGED
@@ -37,16 +37,6 @@ module.exports = (sequelize) => {
37
37
  type: DataTypes.DATE,
38
38
  allowNull: false
39
39
  },
40
- AddressID: {
41
- type: DataTypes.UUID,
42
- allowNull: false,
43
- references: {
44
- model: 'Address',
45
- key: 'AddressID'
46
- },
47
- onDelete: 'RESTRICT',
48
- onUpdate: 'CASCADE'
49
- },
50
40
  TotalAmount: {
51
41
  type: DataTypes.DECIMAL(10, 2),
52
42
  allowNull: false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b2y/ecommerce-common",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "E-commerce common library",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,6 +21,7 @@
21
21
  "homepage": "https://github.com/yuvakrishna29/ecommerce-common#readme",
22
22
  "peerDependencies": {
23
23
  "@countrystatecity/countries": "^1.0.4",
24
+ "@b2y/document-module": "^1.0.4",
24
25
  "exceljs": "^4.4.0",
25
26
  "luxon": "^3.7.2",
26
27
  "puppeteer": "^24.35.0",
@@ -1,35 +0,0 @@
1
- const AppUtil = require('../utility/AppUtil');
2
- const StatusMessage = require('../constants/StatusMessageConstants');
3
-
4
- getAllPermissions = (Permission, logger) => {
5
- return async (req, res) => {
6
- const { pageNumber, pageSize } = req.query;
7
- try {
8
- const { limit, offset } = AppUtil.getPagination(pageNumber, pageSize);
9
-
10
- const { rows, count } = await Permission.findAndCountAll({
11
- attributes: ["PermissionID", "Module", "Name", "IsChecked"],
12
- limit,
13
- offset,
14
- });
15
- return AppUtil.generateResponse(
16
- 200,
17
- StatusMessage.SUCCESS,
18
- null,
19
- { rows, count, pageNumber, limit },
20
- res,
21
- );
22
- } catch (error) {
23
- logger.error("Error fetching permissions:", error);
24
- return AppUtil.generateResponse(
25
- 500,
26
- StatusMessage.FAILURE,
27
- StatusMessage.SERVER_ERROR,
28
- null,
29
- res,
30
- );
31
- }
32
- };
33
- };
34
-
35
- module.exports = {getAllPermissions}