@giftwizard/db-models
Advanced tools
Comparing version 10.2.1 to 11.0.0
@@ -9,11 +9,5 @@ module.exports = { | ||
logger: 'readonly', | ||
db_models: 'writable', | ||
'jest/globals': true, | ||
}, | ||
plugins: [ | ||
'jest', | ||
], | ||
extends: [ | ||
'airbnb-base', | ||
'plugin:jest/recommended', | ||
], | ||
@@ -32,2 +26,2 @@ parserOptions: { | ||
root: true, | ||
}; | ||
}; |
@@ -14,3 +14,3 @@ const _ = require('lodash'); | ||
primaryKey: true, | ||
autoIncrement: true | ||
autoIncrement: true, | ||
}, | ||
@@ -20,13 +20,13 @@ gift_card_id: { | ||
type: DataTypes.UUID, | ||
defaultValue: () => uuid() | ||
defaultValue: () => uuid(), | ||
}, | ||
shop_url: { | ||
type: DataTypes.TEXT | ||
type: DataTypes.TEXT, | ||
}, | ||
cart_id: { | ||
type: DataTypes.TEXT, | ||
allowNull: true | ||
allowNull: true, | ||
}, | ||
shopify_gift_card_id: { | ||
type: DataTypes.TEXT | ||
type: DataTypes.TEXT, | ||
}, | ||
@@ -36,11 +36,11 @@ created_at: { | ||
allowNull: false, | ||
defaultValue: DataTypes.NOW | ||
defaultValue: DataTypes.NOW, | ||
}, | ||
code: { | ||
type: DataTypes.TEXT, | ||
allowNull: true | ||
allowNull: true, | ||
}, | ||
initial_value: { | ||
type: DataTypes.FLOAT, | ||
allowNull: true | ||
allowNull: true, | ||
}, | ||
@@ -50,7 +50,7 @@ balance: { | ||
allowNull: true, | ||
defaultValue: '0' | ||
defaultValue: '0', | ||
}, | ||
gift_card_type: { | ||
type: DataTypes.ENUM('regular', 'coupon'), | ||
allowNull: true | ||
allowNull: true, | ||
}, | ||
@@ -68,79 +68,76 @@ collections: { | ||
const collectionsArray = collectionsValue.split(','); | ||
return collectionsArray.map(collectionId => { | ||
return parseInt(collectionId); | ||
}); | ||
} else { | ||
return []; | ||
return collectionsArray.map(collectionId => parseInt(collectionId)); | ||
} | ||
} | ||
return []; | ||
}, | ||
}, | ||
gift_card_source: { | ||
type: DataTypes.TEXT | ||
type: DataTypes.TEXT, | ||
}, | ||
notified: { | ||
type: DataTypes.INTEGER | ||
type: DataTypes.INTEGER, | ||
}, | ||
expires_on: { | ||
type: DataTypes.DATE, | ||
allowNull: true | ||
allowNull: true, | ||
}, | ||
disabled_at: { | ||
type: DataTypes.DATE, | ||
allowNull: true | ||
allowNull: true, | ||
}, | ||
campaign_id: { | ||
type: DataTypes.TEXT, | ||
allowNull: true | ||
allowNull: true, | ||
}, | ||
platform: { | ||
type: DataTypes.TEXT | ||
type: DataTypes.TEXT, | ||
}, | ||
customer_email: { | ||
type: DataTypes.TEXT, | ||
allowNull: true | ||
allowNull: true, | ||
}, | ||
customer_name: { | ||
type: DataTypes.TEXT, | ||
allowNull: true | ||
allowNull: true, | ||
}, | ||
order_id: { | ||
type: DataTypes.TEXT, | ||
allowNull: true | ||
allowNull: true, | ||
}, | ||
note: { | ||
type: DataTypes.TEXT, | ||
allowNull: true | ||
allowNull: true, | ||
}, | ||
fulfilled_at: { | ||
type: DataTypes.DATE, | ||
allowNull: true | ||
allowNull: true, | ||
}, | ||
reason: { | ||
type: DataTypes.TEXT, | ||
allowNull: true | ||
allowNull: true, | ||
}, | ||
customer_id: { | ||
type: DataTypes.INTEGER(10).UNSIGNED, | ||
allowNull: true | ||
allowNull: true, | ||
}, | ||
api_client_id: { | ||
type: DataTypes.INTEGER(10).UNSIGNED, | ||
allowNull: true | ||
allowNull: true, | ||
}, | ||
workflow_id: { | ||
type: DataTypes.INTEGER(10).UNSIGNED, | ||
allowNull: true | ||
allowNull: true, | ||
}, | ||
reminders_count: { | ||
type: DataTypes.INTEGER(11).UNSIGNED, | ||
allowNull: true | ||
allowNull: true, | ||
}, | ||
last_reminder_triggered_at: { | ||
type: DataTypes.DATE, | ||
allowNull: true | ||
allowNull: true, | ||
}, | ||
order_risk_level: { | ||
type: DataTypes.INTEGER(11).UNSIGNED, | ||
allowNull: true | ||
} | ||
allowNull: true, | ||
}, | ||
}, | ||
@@ -154,12 +151,12 @@ { | ||
updatedAt: 'updated_at', | ||
deletedAt: 'deleted_at' | ||
} | ||
deletedAt: 'deleted_at', | ||
}, | ||
); | ||
GiftCard.getMatchingPhysicalGiftCardInBrand = async function(last_chars, brand, shop_url) { | ||
GiftCard.getMatchingPhysicalGiftCardInBrand = async function (last_chars, brand, shop_url) { | ||
return this.findOne({ | ||
where: { | ||
code: { | ||
[Op.like]: `%${last_chars}` | ||
} | ||
[Op.like]: `%${last_chars}`, | ||
}, | ||
}, | ||
@@ -175,16 +172,16 @@ include: [ | ||
shop_url: { | ||
[Op.ne]: shop_url | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
[Op.ne]: shop_url, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
}); | ||
}; | ||
GiftCard.getMatchingGiftCardsInBrand = async function(code, brand, shop_url) { | ||
GiftCard.getMatchingGiftCardsInBrand = async function (code, brand, shop_url) { | ||
return this.findAll({ | ||
where: { | ||
code | ||
code, | ||
}, | ||
@@ -200,13 +197,14 @@ include: [ | ||
shop_url: { | ||
[Op.ne]: shop_url | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
[Op.ne]: shop_url, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
}); | ||
}; | ||
GiftCard.associate = models => { | ||
GiftCard.associate = (models) => { | ||
GiftCard.hasOne(models.MapRiseToScpCodes); | ||
GiftCard.hasOne(models.LoyaltyCard); | ||
@@ -213,0 +211,0 @@ |
{ | ||
"name": "@giftwizard/db-models", | ||
"version": "10.2.1", | ||
"version": "11.0.0", | ||
"description": "Rise.ai package for 'sequelize' models used by several projects.", | ||
@@ -31,6 +31,6 @@ "main": "index.js", | ||
"devDependencies": { | ||
"eslint": "^7.11.0", | ||
"eslint-config-airbnb": "^17.1.1", | ||
"eslint-config-airbnb-base": "^14.2.1", | ||
"eslint-config-prettier": "^4.1.0", | ||
"eslint-plugin-import": "^2.23.3", | ||
"eslint-plugin-import": "^2.18.2", | ||
"eslint-plugin-jsx-a11y": "^6.2.3", | ||
@@ -40,2 +40,2 @@ "eslint-plugin-prettier": "^3.1.1", | ||
} | ||
} | ||
} |
88919
3329