@b2y/ecommerce-common 1.4.0 → 1.4.2

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.
@@ -11,23 +11,39 @@ const tenantSettingsDocumentValidation = async (
11
11
  logger
12
12
  ) => {
13
13
  if (documentMetadata !== undefined) {
14
- if (
15
- typeof documentMetadata !== AppConstants.OBJECT ||
16
- Array.isArray(documentMetadata)
17
- ) {
14
+
15
+ // Accept both object and single-element array
16
+ if (Array.isArray(documentMetadata)) {
17
+ if (documentMetadata.length !== 1) {
18
+ logger.warn(
19
+ "Validation Failed: Only one logo is allowed."
20
+ );
21
+ throw new Error(StatusMessage.TENANT_SETTINGS_SINGLE_LOGO_ALLOWED);
22
+ }
23
+
24
+ // Convert array -> object
25
+ documentMetadata = documentMetadata[0];
26
+ }
27
+
28
+ // Validate the final value
29
+ if (typeof documentMetadata !== AppConstants.OBJECT) {
18
30
  logger.warn(
19
- "Validation Failed: documentMetadata must be a single object for this operation.",
31
+ "Validation Failed: documentMetadata must be a single object."
20
32
  );
21
33
  throw new Error(StatusMessage.TENANT_SETTINGS_SINGLE_LOGO_ALLOWED);
22
34
  }
35
+
23
36
  logger.info("Uploading new files to storage before transaction");
37
+
24
38
  const uploadResult = await FileUploadUtil.uploadFilesToStorage(
25
39
  documentMetadata,
26
40
  file,
27
41
  FILE_PATHS.IMAGE_DIR,
28
42
  );
29
- return uploadResult
43
+
44
+ return uploadResult;
30
45
  }
46
+
31
47
  return [];
32
48
  };
33
49
 
package/model/Customer.js CHANGED
@@ -38,6 +38,10 @@ module.exports = (sequelize) => {
38
38
  type: DataTypes.STRING(5),
39
39
  allowNull: false
40
40
  },
41
+ CountryCode: {
42
+ type: DataTypes.CHAR(4),
43
+ allowNull: true
44
+ },
41
45
  PhoneNumber: {
42
46
  type: DataTypes.STRING(20),
43
47
  allowNull: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b2y/ecommerce-common",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "E-commerce common library",
5
5
  "main": "index.js",
6
6
  "scripts": {