@b2y/ecommerce-common 1.1.9 → 1.2.0

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.
@@ -1,7 +1,7 @@
1
1
  const StatusMessage = require('../constants/StatusMessageConstants');
2
2
  const AppUtil = require('../utility/AppUtil');
3
3
  const LocationUtility = require('../utility/LocationUtility');
4
-
4
+ const EntityTypeEnum = require('../enum/EntityTypeEnum');
5
5
  // getAllSubscriptionPlans
6
6
  const getAllSubscriptionPlans = (
7
7
  SubscriptionPlan,
@@ -60,6 +60,9 @@ const getTenantSubscription = (
60
60
  Tenant,
61
61
  TenantSubscription,
62
62
  SubscriptionPlan,
63
+ TenantSettings,
64
+ Document,
65
+ getPublicUrl,
63
66
  logger,
64
67
  ) => {
65
68
  return async (req, res) => {
@@ -69,6 +72,11 @@ const getTenantSubscription = (
69
72
  const tenant = await Tenant.findOne({
70
73
  where: { TenantID: id },
71
74
  include: [
75
+ {
76
+ model: TenantSettings,
77
+ as: 'TenantSettings',
78
+ attributes: ['TenantSettingID']
79
+ },
72
80
  {
73
81
  model: TenantSubscription,
74
82
  as: "CurrentSubscription",
@@ -102,7 +110,21 @@ const getTenantSubscription = (
102
110
  res,
103
111
  );
104
112
  }
105
-
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
+ );
106
128
  const { countryName, stateName } =
107
129
  await LocationUtility.resolveCountryAndState(
108
130
  tenant.CountryCode,
@@ -127,6 +149,7 @@ const getTenantSubscription = (
127
149
  CountryCode: tenant.CountryCode,
128
150
  CountryName: countryName,
129
151
  Zipcode: tenant.Zipcode,
152
+ TenantLogo: logo,
130
153
  SubscriptionPlanID: tenant.CurrentSubscription?.SubscriptionPlan?.SubscriptionPlanID,
131
154
  PlanName: tenant.CurrentSubscription?.SubscriptionPlan?.PlanName,
132
155
  TenantSubscriptionStatus: tenant.CurrentSubscription?.Status,
@@ -427,6 +427,16 @@ const initializeModels = (sequelize) => {
427
427
  foreignKey: 'ProductImportID',
428
428
  as: 'ProductImport'
429
429
  })
430
+
431
+ //Tenant Settings
432
+ Tenant.hasOne(TenantSettings, {
433
+ foreignKey: 'TenantID',
434
+ as: 'TenantSettings'
435
+ });
436
+ TenantSettings.belongsTo(Tenant, {
437
+ foreignKey: 'TenantID',
438
+ as: 'Tenant'
439
+ });
430
440
  return { ...models };
431
441
  };
432
442
  module.exports = initializeModels;
@@ -10,6 +10,10 @@ module.exports = (sequelize) => {
10
10
  allowNull: false,
11
11
  defaultValue: DataTypes.UUIDV4,
12
12
  },
13
+ Module: {
14
+ type: DataTypes.STRING(255),
15
+ allowNull: false
16
+ },
13
17
  FeatureName: {
14
18
  type: DataTypes.STRING(100),
15
19
  allowNull: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b2y/ecommerce-common",
3
- "version": "1.1.9",
3
+ "version": "1.2.0",
4
4
  "description": "E-commerce common library",
5
5
  "main": "index.js",
6
6
  "scripts": {