ojamoto_models 1.0.0 → 1.0.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.
@@ -1,81 +1,85 @@
1
- "use strict";
2
-
3
- const { Model, DataTypes } = require("sequelize");
4
- const {
5
- WALLET_TRANSACTION_TYPE,
6
- WALLET_TRANSACTION_STATUS,
7
- } = require("../services/constants");
8
-
9
- module.exports = (sequelize) => {
10
- class WalletTransaction extends Model {
11
- static associate(models) {
12
- WalletTransaction.belongsTo(models.Wallet, {
13
- foreignKey: "wallet_id",
14
- as: "wallet",
15
- });
16
-
17
- WalletTransaction.belongsTo(models.User, {
18
- foreignKey: "user_id",
19
- as: "user",
20
- });
21
- }
22
- }
23
-
24
- WalletTransaction.init(
25
- {
26
- wallet_transaction_id: {
27
- type: DataTypes.INTEGER,
28
- primaryKey: true,
29
- autoIncrement: true,
30
- },
31
- wallet_id: {
32
- type: DataTypes.INTEGER,
33
- allowNull: false,
34
- references: { model: "wallets", key: "wallet_id" },
35
- onDelete: "CASCADE",
36
- },
37
- user_id: {
38
- type: DataTypes.INTEGER,
39
- allowNull: false,
40
- references: { model: "users", key: "user_id" },
41
- onDelete: "CASCADE",
42
- comment: "Denormalized for quick queries",
43
- },
44
- type: {
45
- type: DataTypes.ENUM(...Object.values(WALLET_TRANSACTION_TYPE)),
46
- allowNull: false,
47
- },
48
- amount: {
49
- type: DataTypes.DECIMAL(15, 2),
50
- allowNull: false,
51
- },
52
- currency: {
53
- type: DataTypes.STRING(3),
54
- allowNull: false,
55
- defaultValue: "NGN",
56
- },
57
- reference: {
58
- type: DataTypes.STRING(100),
59
- allowNull: false,
60
- unique: true,
61
- comment: "Flutterwave ref or internal reference",
62
- },
63
- status: {
64
- type: DataTypes.ENUM(...Object.values(WALLET_TRANSACTION_STATUS)),
65
- allowNull: false,
66
- defaultValue: WALLET_TRANSACTION_STATUS.PENDING,
67
- },
68
- },
69
- {
70
- sequelize,
71
- modelName: "WalletTransaction",
72
- tableName: "wallet_transactions",
73
- timestamps: true,
74
- createdAt: "created_at",
75
- updatedAt: false,
76
- },
77
- );
78
-
79
- WalletTransaction.removeAttribute("id");
80
- return WalletTransaction;
81
- };
1
+ "use strict";
2
+
3
+ const { Model, DataTypes } = require("sequelize");
4
+ const {
5
+ WALLET_TRANSACTION_TYPE,
6
+ WALLET_TRANSACTION_STATUS,
7
+ } = require("../services/constants");
8
+
9
+ module.exports = (sequelize) => {
10
+ class WalletTransaction extends Model {
11
+ static associate(models) {
12
+ WalletTransaction.belongsTo(models.Wallet, {
13
+ foreignKey: "wallet_id",
14
+ as: "wallet",
15
+ });
16
+
17
+ WalletTransaction.belongsTo(models.User, {
18
+ foreignKey: "user_id",
19
+ as: "user",
20
+ });
21
+ }
22
+ }
23
+
24
+ WalletTransaction.init(
25
+ {
26
+ wallet_transaction_id: {
27
+ type: DataTypes.INTEGER,
28
+ primaryKey: true,
29
+ autoIncrement: true,
30
+ },
31
+ wallet_id: {
32
+ type: DataTypes.INTEGER,
33
+ allowNull: false,
34
+ references: { model: "wallets", key: "wallet_id" },
35
+ onDelete: "CASCADE",
36
+ },
37
+ user_id: {
38
+ type: DataTypes.INTEGER,
39
+ allowNull: false,
40
+ references: { model: "users", key: "user_id" },
41
+ onDelete: "CASCADE",
42
+ comment: "Denormalized for quick queries",
43
+ },
44
+ provider_reference_id: {
45
+ type: DataTypes.STRING(100),
46
+ allowNull: true,
47
+ },
48
+ type: {
49
+ type: DataTypes.ENUM(...Object.values(WALLET_TRANSACTION_TYPE)),
50
+ allowNull: false,
51
+ },
52
+ amount: {
53
+ type: DataTypes.DECIMAL(15, 2),
54
+ allowNull: false,
55
+ },
56
+ currency: {
57
+ type: DataTypes.STRING(3),
58
+ allowNull: false,
59
+ defaultValue: "NGN",
60
+ },
61
+ reference: {
62
+ type: DataTypes.STRING(100),
63
+ allowNull: false,
64
+ unique: true,
65
+ comment: "Flutterwave ref or internal reference",
66
+ },
67
+ status: {
68
+ type: DataTypes.ENUM(...Object.values(WALLET_TRANSACTION_STATUS)),
69
+ allowNull: false,
70
+ defaultValue: WALLET_TRANSACTION_STATUS.PENDING,
71
+ },
72
+ },
73
+ {
74
+ sequelize,
75
+ modelName: "WalletTransaction",
76
+ tableName: "wallet_transactions",
77
+ timestamps: true,
78
+ createdAt: "created_at",
79
+ updatedAt: false,
80
+ },
81
+ );
82
+
83
+ WalletTransaction.removeAttribute("id");
84
+ return WalletTransaction;
85
+ };
@@ -1,52 +1,52 @@
1
- "use strict";
2
-
3
- const { Model, DataTypes } = require("sequelize");
4
- const { WEBHOOK_STATUS } = require("../services/constants");
5
-
6
- module.exports = (sequelize) => {
7
- class WebhookLog extends Model {
8
- static associate(models) {
9
- // No associations — standalone security log
10
- }
11
- }
12
-
13
- WebhookLog.init(
14
- {
15
- webhook_log_id: {
16
- type: DataTypes.INTEGER,
17
- primaryKey: true,
18
- autoIncrement: true,
19
- },
20
- source: {
21
- type: DataTypes.STRING(100),
22
- allowNull: false,
23
- comment: "flutterwave | twilio | onesignal",
24
- },
25
- event_type: {
26
- type: DataTypes.STRING(100),
27
- allowNull: true,
28
- comment: "e.g. charge.completed | delivery.update",
29
- },
30
- payload_json: {
31
- type: DataTypes.JSON,
32
- allowNull: false,
33
- comment: "Raw webhook body",
34
- },
35
- status: {
36
- type: DataTypes.ENUM(...Object.values(WEBHOOK_STATUS)),
37
- allowNull: false,
38
- },
39
- },
40
- {
41
- sequelize,
42
- modelName: "WebhookLog",
43
- tableName: "webhook_logs",
44
- timestamps: true,
45
- createdAt: "created_at",
46
- updatedAt: false,
47
- },
48
- );
49
-
50
- WebhookLog.removeAttribute("id");
51
- return WebhookLog;
52
- };
1
+ "use strict";
2
+
3
+ const { Model, DataTypes } = require("sequelize");
4
+ const { WEBHOOK_STATUS } = require("../services/constants");
5
+
6
+ module.exports = (sequelize) => {
7
+ class WebhookLog extends Model {
8
+ static associate(models) {
9
+ // No associations — standalone security log
10
+ }
11
+ }
12
+
13
+ WebhookLog.init(
14
+ {
15
+ webhook_log_id: {
16
+ type: DataTypes.INTEGER,
17
+ primaryKey: true,
18
+ autoIncrement: true,
19
+ },
20
+ source: {
21
+ type: DataTypes.STRING(100),
22
+ allowNull: false,
23
+ comment: "flutterwave | twilio | onesignal",
24
+ },
25
+ event_type: {
26
+ type: DataTypes.STRING(100),
27
+ allowNull: true,
28
+ comment: "e.g. charge.completed | delivery.update",
29
+ },
30
+ payload_json: {
31
+ type: DataTypes.JSON,
32
+ allowNull: false,
33
+ comment: "Raw webhook body",
34
+ },
35
+ status: {
36
+ type: DataTypes.ENUM(...Object.values(WEBHOOK_STATUS)),
37
+ allowNull: false,
38
+ },
39
+ },
40
+ {
41
+ sequelize,
42
+ modelName: "WebhookLog",
43
+ tableName: "webhook_logs",
44
+ timestamps: true,
45
+ createdAt: "created_at",
46
+ updatedAt: false,
47
+ },
48
+ );
49
+
50
+ WebhookLog.removeAttribute("id");
51
+ return WebhookLog;
52
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ojamoto_models",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "migrate:up": "npx sequelize-cli db:migrate",