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.
package/models/Escrow.js CHANGED
@@ -1,110 +1,110 @@
1
- "use strict";
2
-
3
- const { Model, DataTypes } = require("sequelize");
4
- const { ESCROW_STATUS } = require("../services/constants");
5
-
6
- module.exports = (sequelize) => {
7
- class Escrow extends Model {
8
- static associate(models) {
9
- Escrow.belongsTo(models.User, {
10
- foreignKey: "buyer_id",
11
- as: "buyer",
12
- });
13
-
14
- Escrow.belongsTo(models.User, {
15
- foreignKey: "seller_id",
16
- as: "seller",
17
- });
18
-
19
- Escrow.belongsTo(models.Product, {
20
- foreignKey: "product_id",
21
- as: "product",
22
- });
23
-
24
- Escrow.hasMany(models.EscrowEvent, {
25
- foreignKey: "escrow_id",
26
- as: "events",
27
- });
28
-
29
- Escrow.hasOne(models.Dispute, {
30
- foreignKey: "escrow_id",
31
- as: "dispute",
32
- });
33
-
34
- Escrow.hasOne(models.Logistics, {
35
- foreignKey: "escrow_id",
36
- as: "logistics",
37
- });
38
-
39
- Escrow.hasOne(models.Rating, {
40
- foreignKey: "escrow_id",
41
- as: "rating",
42
- });
43
- }
44
- }
45
-
46
- Escrow.init(
47
- {
48
- escrow_id: {
49
- type: DataTypes.INTEGER,
50
- primaryKey: true,
51
- autoIncrement: true,
52
- },
53
- buyer_id: {
54
- type: DataTypes.INTEGER,
55
- allowNull: false,
56
- references: { model: "users", key: "user_id" },
57
- onDelete: "RESTRICT",
58
- },
59
- seller_id: {
60
- type: DataTypes.INTEGER,
61
- allowNull: false,
62
- references: { model: "users", key: "user_id" },
63
- onDelete: "RESTRICT",
64
- },
65
- product_id: {
66
- type: DataTypes.INTEGER,
67
- allowNull: false,
68
- references: { model: "products", key: "product_id" },
69
- onDelete: "RESTRICT",
70
- },
71
- amount: {
72
- type: DataTypes.DECIMAL(15, 2),
73
- allowNull: false,
74
- comment: "Agreed transaction value",
75
- },
76
- platform_fee: {
77
- type: DataTypes.DECIMAL(15, 2),
78
- allowNull: false,
79
- defaultValue: 0.0,
80
- comment: "AutoParts NG escrow fee",
81
- },
82
- currency: {
83
- type: DataTypes.STRING(3),
84
- allowNull: false,
85
- defaultValue: "NGN",
86
- },
87
- status: {
88
- type: DataTypes.ENUM(...Object.values(ESCROW_STATUS)),
89
- allowNull: false,
90
- defaultValue: ESCROW_STATUS.PENDING,
91
- },
92
- delivery_deadline: {
93
- type: DataTypes.DATEONLY,
94
- allowNull: true,
95
- comment: "Auto-release trigger date if buyer does not confirm",
96
- },
97
- },
98
- {
99
- sequelize,
100
- modelName: "Escrow",
101
- tableName: "escrows",
102
- timestamps: true,
103
- createdAt: "created_at",
104
- updatedAt: "updated_at",
105
- },
106
- );
107
-
108
- Escrow.removeAttribute("id");
109
- return Escrow;
110
- };
1
+ "use strict";
2
+
3
+ const { Model, DataTypes } = require("sequelize");
4
+ const { ESCROW_STATUS } = require("../services/constants");
5
+
6
+ module.exports = (sequelize) => {
7
+ class Escrow extends Model {
8
+ static associate(models) {
9
+ Escrow.belongsTo(models.User, {
10
+ foreignKey: "buyer_id",
11
+ as: "buyer",
12
+ });
13
+
14
+ Escrow.belongsTo(models.User, {
15
+ foreignKey: "seller_id",
16
+ as: "seller",
17
+ });
18
+
19
+ Escrow.belongsTo(models.Product, {
20
+ foreignKey: "product_id",
21
+ as: "product",
22
+ });
23
+
24
+ Escrow.hasMany(models.EscrowEvent, {
25
+ foreignKey: "escrow_id",
26
+ as: "events",
27
+ });
28
+
29
+ Escrow.hasOne(models.Dispute, {
30
+ foreignKey: "escrow_id",
31
+ as: "dispute",
32
+ });
33
+
34
+ Escrow.hasOne(models.Logistics, {
35
+ foreignKey: "escrow_id",
36
+ as: "logistics",
37
+ });
38
+
39
+ Escrow.hasOne(models.Rating, {
40
+ foreignKey: "escrow_id",
41
+ as: "rating",
42
+ });
43
+ }
44
+ }
45
+
46
+ Escrow.init(
47
+ {
48
+ escrow_id: {
49
+ type: DataTypes.INTEGER,
50
+ primaryKey: true,
51
+ autoIncrement: true,
52
+ },
53
+ buyer_id: {
54
+ type: DataTypes.INTEGER,
55
+ allowNull: false,
56
+ references: { model: "users", key: "user_id" },
57
+ onDelete: "RESTRICT",
58
+ },
59
+ seller_id: {
60
+ type: DataTypes.INTEGER,
61
+ allowNull: false,
62
+ references: { model: "users", key: "user_id" },
63
+ onDelete: "RESTRICT",
64
+ },
65
+ product_id: {
66
+ type: DataTypes.INTEGER,
67
+ allowNull: false,
68
+ references: { model: "products", key: "product_id" },
69
+ onDelete: "RESTRICT",
70
+ },
71
+ amount: {
72
+ type: DataTypes.DECIMAL(15, 2),
73
+ allowNull: false,
74
+ comment: "Agreed transaction value",
75
+ },
76
+ platform_fee: {
77
+ type: DataTypes.DECIMAL(15, 2),
78
+ allowNull: false,
79
+ defaultValue: 0.0,
80
+ comment: "AutoParts NG escrow fee",
81
+ },
82
+ currency: {
83
+ type: DataTypes.STRING(3),
84
+ allowNull: false,
85
+ defaultValue: "NGN",
86
+ },
87
+ status: {
88
+ type: DataTypes.ENUM(...Object.values(ESCROW_STATUS)),
89
+ allowNull: false,
90
+ defaultValue: ESCROW_STATUS.PENDING,
91
+ },
92
+ delivery_deadline: {
93
+ type: DataTypes.DATEONLY,
94
+ allowNull: true,
95
+ comment: "Auto-release trigger date if buyer does not confirm",
96
+ },
97
+ },
98
+ {
99
+ sequelize,
100
+ modelName: "Escrow",
101
+ tableName: "escrows",
102
+ timestamps: true,
103
+ createdAt: "created_at",
104
+ updatedAt: "updated_at",
105
+ },
106
+ );
107
+
108
+ Escrow.removeAttribute("id");
109
+ return Escrow;
110
+ };
@@ -1,63 +1,63 @@
1
- "use strict";
2
-
3
- const { Model, DataTypes } = require("sequelize");
4
-
5
- module.exports = (sequelize) => {
6
- class EscrowEvent extends Model {
7
- static associate(models) {
8
- EscrowEvent.belongsTo(models.Escrow, {
9
- foreignKey: "escrow_id",
10
- as: "escrow",
11
- });
12
-
13
- EscrowEvent.belongsTo(models.User, {
14
- foreignKey: "created_by",
15
- as: "actor",
16
- });
17
- }
18
- }
19
-
20
- EscrowEvent.init(
21
- {
22
- escrow_event_id: {
23
- type: DataTypes.INTEGER,
24
- primaryKey: true,
25
- autoIncrement: true,
26
- },
27
- escrow_id: {
28
- type: DataTypes.INTEGER,
29
- allowNull: false,
30
- references: { model: "escrows", key: "escrow_id" },
31
- onDelete: "CASCADE",
32
- },
33
- event_type: {
34
- type: DataTypes.STRING(100),
35
- allowNull: false,
36
- comment: "FUNDED | ACCEPTED | DELIVERED | RELEASED etc.",
37
- },
38
- description: {
39
- type: DataTypes.TEXT,
40
- allowNull: true,
41
- comment: "Human-readable event detail",
42
- },
43
- created_by: {
44
- type: DataTypes.INTEGER,
45
- allowNull: true,
46
- references: { model: "users", key: "user_id" },
47
- onDelete: "SET NULL",
48
- comment: "User or system actor (null = system)",
49
- },
50
- },
51
- {
52
- sequelize,
53
- modelName: "EscrowEvent",
54
- tableName: "escrow_events",
55
- timestamps: true,
56
- createdAt: "created_at",
57
- updatedAt: false,
58
- },
59
- );
60
-
61
- EscrowEvent.removeAttribute("id");
62
- return EscrowEvent;
63
- };
1
+ "use strict";
2
+
3
+ const { Model, DataTypes } = require("sequelize");
4
+
5
+ module.exports = (sequelize) => {
6
+ class EscrowEvent extends Model {
7
+ static associate(models) {
8
+ EscrowEvent.belongsTo(models.Escrow, {
9
+ foreignKey: "escrow_id",
10
+ as: "escrow",
11
+ });
12
+
13
+ EscrowEvent.belongsTo(models.User, {
14
+ foreignKey: "created_by",
15
+ as: "actor",
16
+ });
17
+ }
18
+ }
19
+
20
+ EscrowEvent.init(
21
+ {
22
+ escrow_event_id: {
23
+ type: DataTypes.INTEGER,
24
+ primaryKey: true,
25
+ autoIncrement: true,
26
+ },
27
+ escrow_id: {
28
+ type: DataTypes.INTEGER,
29
+ allowNull: false,
30
+ references: { model: "escrows", key: "escrow_id" },
31
+ onDelete: "CASCADE",
32
+ },
33
+ event_type: {
34
+ type: DataTypes.STRING(100),
35
+ allowNull: false,
36
+ comment: "FUNDED | ACCEPTED | DELIVERED | RELEASED etc.",
37
+ },
38
+ description: {
39
+ type: DataTypes.TEXT,
40
+ allowNull: true,
41
+ comment: "Human-readable event detail",
42
+ },
43
+ created_by: {
44
+ type: DataTypes.INTEGER,
45
+ allowNull: true,
46
+ references: { model: "users", key: "user_id" },
47
+ onDelete: "SET NULL",
48
+ comment: "User or system actor (null = system)",
49
+ },
50
+ },
51
+ {
52
+ sequelize,
53
+ modelName: "EscrowEvent",
54
+ tableName: "escrow_events",
55
+ timestamps: true,
56
+ createdAt: "created_at",
57
+ updatedAt: false,
58
+ },
59
+ );
60
+
61
+ EscrowEvent.removeAttribute("id");
62
+ return EscrowEvent;
63
+ };
@@ -1,62 +1,62 @@
1
- "use strict";
2
-
3
- const { Model, DataTypes } = require("sequelize");
4
- const { KYC_STATUS, KYC_PROVIDER } = require("../services/constants");
5
-
6
- module.exports = (sequelize) => {
7
- class KycVerification extends Model {
8
- static associate(models) {
9
- KycVerification.belongsTo(models.User, {
10
- foreignKey: "user_id",
11
- as: "user",
12
- });
13
- }
14
- }
15
-
16
- KycVerification.init(
17
- {
18
- kyc_verification_id: {
19
- type: DataTypes.INTEGER,
20
- primaryKey: true,
21
- autoIncrement: true,
22
- },
23
- user_id: {
24
- type: DataTypes.INTEGER,
25
- allowNull: false,
26
- unique: true,
27
- references: { model: "users", key: "user_id" },
28
- onDelete: "CASCADE",
29
- },
30
- nin_data_json: {
31
- type: DataTypes.JSON,
32
- allowNull: true,
33
- comment: "Raw NIN API response from provider",
34
- },
35
- bank_data_json: {
36
- type: DataTypes.JSON,
37
- allowNull: true,
38
- comment: "Resolved account name and bank details",
39
- },
40
- verification_status: {
41
- type: DataTypes.ENUM(...Object.values(KYC_STATUS)),
42
- allowNull: false,
43
- defaultValue: KYC_STATUS.PENDING,
44
- },
45
- provider: {
46
- type: DataTypes.ENUM(...Object.values(KYC_PROVIDER)),
47
- allowNull: true,
48
- },
49
- },
50
- {
51
- sequelize,
52
- modelName: "KycVerification",
53
- tableName: "kyc_verifications",
54
- timestamps: true,
55
- createdAt: "created_at",
56
- updatedAt: false,
57
- },
58
- );
59
-
60
- KycVerification.removeAttribute("id");
61
- return KycVerification;
62
- };
1
+ "use strict";
2
+
3
+ const { Model, DataTypes } = require("sequelize");
4
+ const { KYC_STATUS, KYC_PROVIDER } = require("../services/constants");
5
+
6
+ module.exports = (sequelize) => {
7
+ class KycVerification extends Model {
8
+ static associate(models) {
9
+ KycVerification.belongsTo(models.User, {
10
+ foreignKey: "user_id",
11
+ as: "user",
12
+ });
13
+ }
14
+ }
15
+
16
+ KycVerification.init(
17
+ {
18
+ kyc_verification_id: {
19
+ type: DataTypes.INTEGER,
20
+ primaryKey: true,
21
+ autoIncrement: true,
22
+ },
23
+ user_id: {
24
+ type: DataTypes.INTEGER,
25
+ allowNull: false,
26
+ unique: true,
27
+ references: { model: "users", key: "user_id" },
28
+ onDelete: "CASCADE",
29
+ },
30
+ nin_data_json: {
31
+ type: DataTypes.JSON,
32
+ allowNull: true,
33
+ comment: "Raw NIN API response from provider",
34
+ },
35
+ bank_data_json: {
36
+ type: DataTypes.JSON,
37
+ allowNull: true,
38
+ comment: "Resolved account name and bank details",
39
+ },
40
+ verification_status: {
41
+ type: DataTypes.ENUM(...Object.values(KYC_STATUS)),
42
+ allowNull: false,
43
+ defaultValue: KYC_STATUS.PENDING,
44
+ },
45
+ provider: {
46
+ type: DataTypes.ENUM(...Object.values(KYC_PROVIDER)),
47
+ allowNull: true,
48
+ },
49
+ },
50
+ {
51
+ sequelize,
52
+ modelName: "KycVerification",
53
+ tableName: "kyc_verifications",
54
+ timestamps: true,
55
+ createdAt: "created_at",
56
+ updatedAt: false,
57
+ },
58
+ );
59
+
60
+ KycVerification.removeAttribute("id");
61
+ return KycVerification;
62
+ };
@@ -1,62 +1,62 @@
1
- "use strict";
2
-
3
- const { Model, DataTypes } = require("sequelize");
4
- const { LOGISTICS_STATUS } = require("../services/constants");
5
-
6
- module.exports = (sequelize) => {
7
- class Logistics extends Model {
8
- static associate(models) {
9
- Logistics.belongsTo(models.Escrow, {
10
- foreignKey: "escrow_id",
11
- as: "escrow",
12
- });
13
- }
14
- }
15
-
16
- Logistics.init(
17
- {
18
- logistics_id: {
19
- type: DataTypes.INTEGER,
20
- primaryKey: true,
21
- autoIncrement: true,
22
- },
23
- escrow_id: {
24
- type: DataTypes.INTEGER,
25
- allowNull: false,
26
- unique: true,
27
- references: { model: "escrows", key: "escrow_id" },
28
- onDelete: "RESTRICT",
29
- },
30
- provider: {
31
- type: DataTypes.STRING(100),
32
- allowNull: false,
33
- comment: "GIG | DHL | FedEx",
34
- },
35
- tracking_number: {
36
- type: DataTypes.STRING(100),
37
- allowNull: false,
38
- },
39
- status: {
40
- type: DataTypes.ENUM(...Object.values(LOGISTICS_STATUS)),
41
- allowNull: false,
42
- defaultValue: LOGISTICS_STATUS.SHIPPED,
43
- },
44
- delivery_proof_url: {
45
- type: DataTypes.STRING(500),
46
- allowNull: true,
47
- comment: "AWS S3 URL — photo or waybill",
48
- },
49
- },
50
- {
51
- sequelize,
52
- modelName: "Logistics",
53
- tableName: "logistics",
54
- timestamps: true,
55
- createdAt: "created_at",
56
- updatedAt: "updated_at",
57
- },
58
- );
59
-
60
- Logistics.removeAttribute("id");
61
- return Logistics;
62
- };
1
+ "use strict";
2
+
3
+ const { Model, DataTypes } = require("sequelize");
4
+ const { LOGISTICS_STATUS } = require("../services/constants");
5
+
6
+ module.exports = (sequelize) => {
7
+ class Logistics extends Model {
8
+ static associate(models) {
9
+ Logistics.belongsTo(models.Escrow, {
10
+ foreignKey: "escrow_id",
11
+ as: "escrow",
12
+ });
13
+ }
14
+ }
15
+
16
+ Logistics.init(
17
+ {
18
+ logistics_id: {
19
+ type: DataTypes.INTEGER,
20
+ primaryKey: true,
21
+ autoIncrement: true,
22
+ },
23
+ escrow_id: {
24
+ type: DataTypes.INTEGER,
25
+ allowNull: false,
26
+ unique: true,
27
+ references: { model: "escrows", key: "escrow_id" },
28
+ onDelete: "RESTRICT",
29
+ },
30
+ provider: {
31
+ type: DataTypes.STRING(100),
32
+ allowNull: false,
33
+ comment: "GIG | DHL | FedEx",
34
+ },
35
+ tracking_number: {
36
+ type: DataTypes.STRING(100),
37
+ allowNull: false,
38
+ },
39
+ status: {
40
+ type: DataTypes.ENUM(...Object.values(LOGISTICS_STATUS)),
41
+ allowNull: false,
42
+ defaultValue: LOGISTICS_STATUS.SHIPPED,
43
+ },
44
+ delivery_proof_url: {
45
+ type: DataTypes.STRING(500),
46
+ allowNull: true,
47
+ comment: "AWS S3 URL — photo or waybill",
48
+ },
49
+ },
50
+ {
51
+ sequelize,
52
+ modelName: "Logistics",
53
+ tableName: "logistics",
54
+ timestamps: true,
55
+ createdAt: "created_at",
56
+ updatedAt: "updated_at",
57
+ },
58
+ );
59
+
60
+ Logistics.removeAttribute("id");
61
+ return Logistics;
62
+ };