@b2y/ecommerce-common 1.4.2 → 1.4.4
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.
- package/constants/AuditConstants.js +16 -0
- package/index.js +2 -1
- package/package.json +1 -1
- package/utility/ThemeColourUtil.js +26 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const AuditConstants = {
|
|
2
|
+
EVENT_TYPE: {
|
|
3
|
+
CREATE: 'CREATE',
|
|
4
|
+
UPDATE: 'UPDATE',
|
|
5
|
+
DELETE: 'DELETE',
|
|
6
|
+
},
|
|
7
|
+
ENTITY_NAME: {
|
|
8
|
+
TENANT: 'Tenant',
|
|
9
|
+
TENANT_SETTINGS: 'TenantSettings',
|
|
10
|
+
TENANT_SUBSCRIPTION: 'TenantSubscription',
|
|
11
|
+
MULTI_TENANT_USER: 'MultiTenantUser',
|
|
12
|
+
SUBSCRIPTION_PLAN: 'SubscriptionPlan',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = AuditConstants;
|
package/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const TenantSettingsAbstractController = require('./controller/TenantSettingsAbs
|
|
|
7
7
|
const LocationController = require('./controller/LocationController');
|
|
8
8
|
const CommonAppConstants = require('./constants/AppConstants');
|
|
9
9
|
const CommonStatusMessage = require('./constants/StatusMessageConstants');
|
|
10
|
+
const AuditConstants = require('./constants/AuditConstants');
|
|
10
11
|
const QueryBuilder = require('./scripts/QueryBuilder');
|
|
11
12
|
const enums = {};
|
|
12
13
|
const enumDir = path.join(__dirname, 'enum');
|
|
@@ -25,4 +26,4 @@ fs.readdirSync(utilDir).forEach((file) => {
|
|
|
25
26
|
}
|
|
26
27
|
})
|
|
27
28
|
|
|
28
|
-
module.exports = {initializeModels, enums, utils, CommonAppConstants, CommonStatusMessage, SubscriptionAbstractController, TenantAbstractController, TenantSettingsAbstractController, LocationController, QueryBuilder};
|
|
29
|
+
module.exports = {initializeModels, enums, utils, CommonAppConstants, CommonStatusMessage, AuditConstants, SubscriptionAbstractController, TenantAbstractController, TenantSettingsAbstractController, LocationController, QueryBuilder};
|
package/package.json
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Brand colour used for {{themeColour}} in transactional email templates
|
|
2
|
+
// (the header band / accent colour) whenever a tenant hasn't set their own
|
|
3
|
+
// TenantSettings.ThemeColour yet.
|
|
4
|
+
const DEFAULT_THEME_COLOUR = '#FFFFFF';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the brand colour to use for a tenant's transactional emails.
|
|
8
|
+
*
|
|
9
|
+
* TenantSettings is passed in (not required here) because each service owns
|
|
10
|
+
* its own Sequelize connection/model instance - same dependency-injection
|
|
11
|
+
* convention as TenantSettingsAbstractController.
|
|
12
|
+
*
|
|
13
|
+
* @param {object} TenantSettings the caller's own TenantSettings Sequelize model
|
|
14
|
+
* @param {string} [tenantId] tenant to look up (omit for a platform/admin-only send - resolves straight to the default)
|
|
15
|
+
* @param {string} [override] explicit colour that skips the TenantSettings lookup entirely
|
|
16
|
+
* @returns {Promise<string>} override, else the tenant's TenantSettings.ThemeColour, else DEFAULT_THEME_COLOUR
|
|
17
|
+
*/
|
|
18
|
+
const resolveThemeColour = async (TenantSettings, tenantId, override) => {
|
|
19
|
+
if (override) return override;
|
|
20
|
+
if (!tenantId) return DEFAULT_THEME_COLOUR;
|
|
21
|
+
|
|
22
|
+
const settings = await TenantSettings.findOne({ where: { TenantID: tenantId } }).catch(() => null);
|
|
23
|
+
return settings?.ThemeColour || DEFAULT_THEME_COLOUR;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
module.exports = { DEFAULT_THEME_COLOUR, resolveThemeColour };
|