@winible/winible-typed 2.0.0 → 2.1.0
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/dist/migrations/20230412190423-migrate_purchased_contents.js +10 -0
- package/dist/migrations/20230412190423-migrate_purchased_contents.js.map +1 -0
- package/dist/migrations/20230412202031-migrate_other_fields.js +27 -0
- package/dist/migrations/20230412202031-migrate_other_fields.js.map +1 -0
- package/dist/migrations/20230412213952-deprecate_phone_users_and_phone_owners.js +27 -0
- package/dist/migrations/20230412213952-deprecate_phone_users_and_phone_owners.js.map +1 -0
- package/dist/scripts/deleteMalformedImages.js +2 -2
- package/dist/scripts/deleteMalformedImages.js.map +1 -1
- package/dist/typed-model/content-like.js +27 -15
- package/dist/typed-model/content-like.js.map +1 -1
- package/dist/typed-model/credit-payment.js +35 -371
- package/dist/typed-model/credit-payment.js.map +1 -1
- package/dist/typed-model/index.js +13 -15
- package/dist/typed-model/index.js.map +1 -1
- package/dist/typed-model/league-user.js +3 -3
- package/dist/typed-model/league-user.js.map +1 -1
- package/dist/typed-model/media.js +2 -6
- package/dist/typed-model/media.js.map +1 -1
- package/dist/typed-model/pb-sequelize.js +3 -1
- package/dist/typed-model/pb-sequelize.js.map +1 -1
- package/dist/typed-model/phone-owner.js +3 -3
- package/dist/typed-model/phone-owner.js.map +1 -1
- package/dist/typed-model/post.js +126 -0
- package/dist/typed-model/post.js.map +1 -0
- package/dist/typed-model/posts-on-users.js +92 -0
- package/dist/typed-model/posts-on-users.js.map +1 -0
- package/dist/typed-model/premium-content.js +9 -4
- package/dist/typed-model/premium-content.js.map +1 -1
- package/dist/typed-model/purchased-content.js +13 -13
- package/dist/typed-model/purchased-content.js.map +1 -1
- package/dist/typed-model/recurly-account.js.map +1 -1
- package/dist/typed-model/subscription-plan-on-post.js +55 -0
- package/dist/typed-model/subscription-plan-on-post.js.map +1 -0
- package/dist/typed-model/subscription-plan-on-users.js +111 -0
- package/dist/typed-model/subscription-plan-on-users.js.map +1 -0
- package/dist/typed-model/subscription-plan.js +22 -32
- package/dist/typed-model/subscription-plan.js.map +1 -1
- package/dist/typed-model/subscription.js +32 -40
- package/dist/typed-model/subscription.js.map +1 -1
- package/dist/typed-model/transaction.js +108 -0
- package/dist/typed-model/transaction.js.map +1 -0
- package/dist/typed-model/withdrawal.js +33 -0
- package/dist/typed-model/withdrawal.js.map +1 -0
- package/dist/webhooks/index.js.map +1 -1
- package/dist/webhooks/payment/refund.js +11 -11
- package/dist/webhooks/payment/refund.js.map +1 -1
- package/package.json +1 -1
- package/typed-model/content-like.ts +33 -17
- package/typed-model/index.ts +6 -7
- package/typed-model/league-user.ts +5 -3
- package/typed-model/media.ts +3 -9
- package/typed-model/pb-sequelize.ts +5 -1
- package/typed-model/{premium-content.ts → post.ts} +44 -42
- package/typed-model/{purchased-content.ts → posts-on-users.ts} +46 -25
- package/typed-model/recurly-account.ts +0 -1
- package/typed-model/subscription-plan-on-post.ts +77 -0
- package/typed-model/{subscription.ts → subscription-plan-on-users.ts} +43 -59
- package/typed-model/subscription-plan.ts +29 -46
- package/typed-model/transaction.ts +154 -0
- package/typed-model/user.ts +2 -2
- package/typed-model/{credit-payout.ts → withdrawal.ts} +9 -21
- package/typed-model/credit-payment.ts +0 -681
- package/typed-model/phone-owner.ts +0 -341
- package/typed-model/phone-user.ts +0 -146
@@ -4,33 +4,25 @@ import {
|
|
4
4
|
InferCreationAttributes,
|
5
5
|
CreationOptional,
|
6
6
|
DataTypes,
|
7
|
-
fn,
|
8
|
-
NOW,
|
9
7
|
} from "sequelize";
|
10
8
|
|
11
9
|
import sequelize from "./pb-sequelize";
|
12
|
-
import
|
13
|
-
import
|
10
|
+
import SubscriptionPlan from "./subscription-plan";
|
11
|
+
import User from "./user";
|
14
12
|
|
15
13
|
// order of InferAttributes & InferCreationAttributes is important.
|
16
|
-
class
|
17
|
-
InferAttributes<
|
18
|
-
InferCreationAttributes<
|
14
|
+
class SubscriptionPlanOnUsers extends Model<
|
15
|
+
InferAttributes<SubscriptionPlanOnUsers>,
|
16
|
+
InferCreationAttributes<SubscriptionPlanOnUsers>
|
19
17
|
> {
|
20
18
|
// 'CreationOptional' is a special type that marks the field as optional
|
21
19
|
// when creating an instance of the model (such as using Model.create()).
|
22
20
|
declare id: CreationOptional<string>;
|
23
21
|
declare userId: string;
|
24
22
|
declare subscriptionPlanId: string;
|
25
|
-
|
26
|
-
declare paypalSubscriptionId?: string;
|
27
|
-
declare paypalOrderId?: string;
|
28
|
-
declare paypalBillingToken?: string;
|
29
23
|
declare lastPaymentDate?: Date;
|
30
24
|
declare cancelDate?: Date;
|
31
|
-
declare pkSubscriptionId?: string;
|
32
25
|
declare numberOfPayments?: number;
|
33
|
-
declare subscriptionPromotionId?: string;
|
34
26
|
declare recurlySubscriptionId?: string;
|
35
27
|
declare status?:
|
36
28
|
| "active"
|
@@ -43,17 +35,16 @@ class Subscription extends Model<
|
|
43
35
|
declare createdAt: CreationOptional<Date>;
|
44
36
|
declare updatedAt: CreationOptional<Date>;
|
45
37
|
|
46
|
-
static getById: (id: string) => Promise<
|
47
|
-
static getByUserId: (
|
38
|
+
static getById: (id: string) => Promise<SubscriptionPlanOnUsers | null>;
|
39
|
+
static getByUserId: (
|
40
|
+
userId: string
|
41
|
+
) => Promise<SubscriptionPlanOnUsers | null>;
|
48
42
|
static getBySubscriptionPlanId: (
|
49
43
|
subscriptionPlanId: string
|
50
|
-
) => Promise<
|
51
|
-
static getByPaypalSubscriptionId: (
|
52
|
-
paypalSubscriptionId: string
|
53
|
-
) => Promise<Subscription | null>;
|
44
|
+
) => Promise<SubscriptionPlanOnUsers | null>;
|
54
45
|
}
|
55
46
|
|
56
|
-
|
47
|
+
SubscriptionPlanOnUsers.init(
|
57
48
|
{
|
58
49
|
id: {
|
59
50
|
type: DataTypes.BIGINT,
|
@@ -71,18 +62,6 @@ Subscription.init(
|
|
71
62
|
allowNull: false,
|
72
63
|
field: "subscription_plan_id",
|
73
64
|
},
|
74
|
-
paypalSubscriptionId: {
|
75
|
-
type: DataTypes.STRING,
|
76
|
-
field: "paypal_subscription_id",
|
77
|
-
},
|
78
|
-
paypalOrderId: {
|
79
|
-
type: DataTypes.STRING,
|
80
|
-
field: "paypal_order_id",
|
81
|
-
},
|
82
|
-
paypalBillingToken: {
|
83
|
-
type: DataTypes.STRING,
|
84
|
-
field: "paypal_billing_token",
|
85
|
-
},
|
86
65
|
lastPaymentDate: {
|
87
66
|
type: DataTypes.DATE,
|
88
67
|
field: "last_payment_date",
|
@@ -91,19 +70,11 @@ Subscription.init(
|
|
91
70
|
type: DataTypes.DATE,
|
92
71
|
field: "cancel_date",
|
93
72
|
},
|
94
|
-
pkSubscriptionId: {
|
95
|
-
type: DataTypes.STRING,
|
96
|
-
field: "pk_subscription_id",
|
97
|
-
},
|
98
73
|
numberOfPayments: {
|
99
74
|
type: DataTypes.INTEGER,
|
100
75
|
defaultValue: 0,
|
101
76
|
field: "number_of_payments",
|
102
77
|
},
|
103
|
-
subscriptionPromotionId: {
|
104
|
-
type: DataTypes.BIGINT,
|
105
|
-
field: "subscription_promotion_id",
|
106
|
-
},
|
107
78
|
stale: {
|
108
79
|
type: DataTypes.BOOLEAN,
|
109
80
|
field: "stale",
|
@@ -123,7 +94,7 @@ Subscription.init(
|
|
123
94
|
updatedAt: DataTypes.DATE,
|
124
95
|
},
|
125
96
|
{
|
126
|
-
tableName: "
|
97
|
+
tableName: "subscription_plan_on_users",
|
127
98
|
sequelize,
|
128
99
|
}
|
129
100
|
);
|
@@ -134,41 +105,54 @@ Class functions
|
|
134
105
|
====================================================================
|
135
106
|
*/
|
136
107
|
|
137
|
-
|
138
|
-
return await
|
108
|
+
SubscriptionPlanOnUsers.getById = async (id: string) => {
|
109
|
+
return await SubscriptionPlanOnUsers.findOne({
|
139
110
|
where: {
|
140
111
|
id,
|
141
112
|
},
|
142
113
|
});
|
143
114
|
};
|
144
115
|
|
145
|
-
|
146
|
-
return await
|
116
|
+
SubscriptionPlanOnUsers.getByUserId = async (userId: string) => {
|
117
|
+
return await SubscriptionPlanOnUsers.findOne({
|
147
118
|
where: {
|
148
119
|
userId,
|
149
120
|
},
|
150
121
|
});
|
151
122
|
};
|
152
123
|
|
153
|
-
|
154
|
-
|
124
|
+
SubscriptionPlanOnUsers.getBySubscriptionPlanId = async (
|
125
|
+
subscriptionPlanId: string
|
126
|
+
) => {
|
127
|
+
return await SubscriptionPlanOnUsers.findOne({
|
155
128
|
where: {
|
156
129
|
subscriptionPlanId,
|
157
130
|
},
|
158
131
|
});
|
159
132
|
};
|
160
133
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
134
|
+
User.hasMany(SubscriptionPlanOnUsers, {
|
135
|
+
foreignKey: "userId",
|
136
|
+
sourceKey: "id",
|
137
|
+
onDelete: "NO ACTION",
|
138
|
+
constraints: false,
|
139
|
+
});
|
140
|
+
|
141
|
+
SubscriptionPlanOnUsers.hasOne(User, {
|
142
|
+
foreignKey: "id",
|
143
|
+
sourceKey: "userId",
|
144
|
+
});
|
145
|
+
|
146
|
+
SubscriptionPlan.hasMany(SubscriptionPlanOnUsers, {
|
147
|
+
foreignKey: "subscriptionPlanId",
|
148
|
+
sourceKey: "id",
|
149
|
+
onDelete: "NO ACTION",
|
150
|
+
constraints: false,
|
151
|
+
});
|
170
152
|
|
171
|
-
|
172
|
-
|
153
|
+
SubscriptionPlanOnUsers.hasOne(SubscriptionPlan, {
|
154
|
+
foreignKey: "id",
|
155
|
+
sourceKey: "subscriptionPlanId",
|
156
|
+
});
|
173
157
|
|
174
|
-
export default
|
158
|
+
export default SubscriptionPlanOnUsers;
|
@@ -4,14 +4,12 @@ import {
|
|
4
4
|
InferCreationAttributes,
|
5
5
|
CreationOptional,
|
6
6
|
DataTypes,
|
7
|
-
fn,
|
8
|
-
NOW,
|
9
7
|
NonAttribute,
|
10
8
|
} from "sequelize";
|
11
9
|
|
12
10
|
import sequelize from "./pb-sequelize";
|
13
|
-
import
|
14
|
-
import
|
11
|
+
import User from "./user";
|
12
|
+
import SubscriptionPlanOnUsers from "./subscription-plan-on-users";
|
15
13
|
|
16
14
|
// order of InferAttributes & InferCreationAttributes is important.
|
17
15
|
class SubscriptionPlan extends Model<
|
@@ -21,30 +19,24 @@ class SubscriptionPlan extends Model<
|
|
21
19
|
// 'CreationOptional' is a special type that marks the field as optional
|
22
20
|
// when creating an instance of the model (such as using Model.create()).
|
23
21
|
declare id: CreationOptional<string>;
|
24
|
-
declare
|
22
|
+
declare userId: string;
|
25
23
|
declare planName?: string;
|
26
24
|
declare amountInCents?: number;
|
27
25
|
declare intervalCount?: number;
|
28
26
|
declare intervalUnit: CreationOptional<"months" | "days">;
|
29
|
-
declare paypalPlanId: string;
|
30
|
-
declare paypalProductId: string;
|
31
27
|
declare isArchived?: boolean;
|
32
|
-
declare
|
28
|
+
declare planDescription?: string;
|
33
29
|
declare oneTimePurchase?: boolean;
|
34
30
|
declare accessEndDate?: Date;
|
35
31
|
declare recurlyPlanId?: string;
|
36
32
|
declare order?: number;
|
37
33
|
declare createdAt: CreationOptional<Date>;
|
38
34
|
declare updatedAt: CreationOptional<Date>;
|
35
|
+
|
39
36
|
static getById: (id: string) => Promise<SubscriptionPlan | null>;
|
40
|
-
static
|
41
|
-
static getByPaypalPlanId: (
|
42
|
-
paypalPlanId: string
|
43
|
-
) => Promise<SubscriptionPlan | null>;
|
37
|
+
static getByUserId: (ownerId: string) => Promise<SubscriptionPlan | null>;
|
44
38
|
|
45
|
-
declare subscriptions?: NonAttribute<
|
46
|
-
declare SubscriptionPromotions?: NonAttribute<any[]>;
|
47
|
-
declare SubscriptionBundles?: NonAttribute<any[]>;
|
39
|
+
declare subscriptions?: NonAttribute<SubscriptionPlanOnUsers[]>;
|
48
40
|
}
|
49
41
|
|
50
42
|
SubscriptionPlan.init(
|
@@ -55,10 +47,10 @@ SubscriptionPlan.init(
|
|
55
47
|
allowNull: false,
|
56
48
|
defaultValue: sequelize.fn("next_id"),
|
57
49
|
},
|
58
|
-
|
50
|
+
userId: {
|
59
51
|
type: DataTypes.BIGINT,
|
60
52
|
allowNull: false,
|
61
|
-
field: "
|
53
|
+
field: "user_id",
|
62
54
|
},
|
63
55
|
planName: {
|
64
56
|
type: DataTypes.STRING,
|
@@ -78,22 +70,14 @@ SubscriptionPlan.init(
|
|
78
70
|
field: "interval_unit",
|
79
71
|
defaultValue: "months",
|
80
72
|
},
|
81
|
-
paypalPlanId: {
|
82
|
-
type: DataTypes.STRING,
|
83
|
-
field: "paypal_plan_id",
|
84
|
-
},
|
85
|
-
paypalProductId: {
|
86
|
-
type: DataTypes.STRING,
|
87
|
-
field: "paypal_product_id",
|
88
|
-
},
|
89
73
|
isArchived: {
|
90
74
|
type: DataTypes.BOOLEAN,
|
91
75
|
field: "is_archived",
|
92
76
|
defaultValue: false,
|
93
77
|
},
|
94
|
-
|
95
|
-
type: DataTypes.
|
96
|
-
field: "
|
78
|
+
planDescription: {
|
79
|
+
type: DataTypes.STRING,
|
80
|
+
field: "plan_description",
|
97
81
|
},
|
98
82
|
oneTimePurchase: {
|
99
83
|
type: DataTypes.BOOLEAN,
|
@@ -136,37 +120,36 @@ SubscriptionPlan.getById = async (id: string) => {
|
|
136
120
|
});
|
137
121
|
};
|
138
122
|
|
139
|
-
SubscriptionPlan.
|
140
|
-
return await SubscriptionPlan.findOne({
|
141
|
-
where: {
|
142
|
-
ownerId,
|
143
|
-
},
|
144
|
-
});
|
145
|
-
};
|
146
|
-
|
147
|
-
SubscriptionPlan.getByPaypalPlanId = async (paypalPlanId: string) => {
|
123
|
+
SubscriptionPlan.getByUserId = async (userId: string) => {
|
148
124
|
return await SubscriptionPlan.findOne({
|
149
125
|
where: {
|
150
|
-
|
126
|
+
userId,
|
151
127
|
},
|
152
128
|
});
|
153
129
|
};
|
154
130
|
|
155
|
-
SubscriptionPlan.hasMany(
|
156
|
-
|
157
|
-
|
158
|
-
|
131
|
+
SubscriptionPlan.hasMany(SubscriptionPlanOnUsers, {
|
132
|
+
foreignKey: "subscriptionPlanId",
|
133
|
+
sourceKey: "id",
|
134
|
+
onDelete: "NO ACTION",
|
135
|
+
constraints: false,
|
159
136
|
});
|
160
137
|
|
161
|
-
|
138
|
+
SubscriptionPlanOnUsers.hasOne(SubscriptionPlan, {
|
162
139
|
foreignKey: "id",
|
163
|
-
sourceKey: "
|
140
|
+
sourceKey: "subscriptionPlanId",
|
164
141
|
});
|
165
|
-
|
166
|
-
|
142
|
+
|
143
|
+
User.hasMany(SubscriptionPlan, {
|
144
|
+
foreignKey: "userId",
|
167
145
|
sourceKey: "id",
|
168
146
|
onDelete: "NO ACTION",
|
169
147
|
constraints: false,
|
170
148
|
});
|
171
149
|
|
150
|
+
SubscriptionPlan.hasOne(User, {
|
151
|
+
foreignKey: "id",
|
152
|
+
sourceKey: "userId",
|
153
|
+
});
|
154
|
+
|
172
155
|
export default SubscriptionPlan;
|
@@ -0,0 +1,154 @@
|
|
1
|
+
import {
|
2
|
+
Model,
|
3
|
+
InferAttributes,
|
4
|
+
InferCreationAttributes,
|
5
|
+
CreationOptional,
|
6
|
+
DataTypes,
|
7
|
+
} from "sequelize";
|
8
|
+
|
9
|
+
import sequelize from "./pb-sequelize";
|
10
|
+
import User from "./user";
|
11
|
+
import Notification from "./notification";
|
12
|
+
|
13
|
+
type TransactionType =
|
14
|
+
| "subscription"
|
15
|
+
| "tip"
|
16
|
+
| "text"
|
17
|
+
| "unlock_message"
|
18
|
+
| "content"
|
19
|
+
| "unlock"
|
20
|
+
| "audio"
|
21
|
+
| "referral"
|
22
|
+
| "video";
|
23
|
+
|
24
|
+
// order of InferAttributes & InferCreationAttributes is important.
|
25
|
+
class Transaction extends Model<
|
26
|
+
InferAttributes<Transaction>,
|
27
|
+
InferCreationAttributes<Transaction>
|
28
|
+
> {
|
29
|
+
// 'CreationOptional' is a special type that marks the field as optional
|
30
|
+
// when creating an instance of the model (such as using Model.create()).
|
31
|
+
declare id: CreationOptional<string>;
|
32
|
+
declare payerId?: string;
|
33
|
+
declare recipientId?: string;
|
34
|
+
declare transactionAmountInCents: number;
|
35
|
+
declare transactionType: TransactionType;
|
36
|
+
declare withdrawalId?: string;
|
37
|
+
declare withdrawalDate?: Date;
|
38
|
+
declare metadata?: string;
|
39
|
+
declare earningAmountInCents: number;
|
40
|
+
declare referredTransactionId?: string;
|
41
|
+
declare recurlyInvoiceId?: string;
|
42
|
+
declare createdAt: CreationOptional<Date>;
|
43
|
+
declare updatedAt: CreationOptional<Date>;
|
44
|
+
|
45
|
+
static getById: (id: string) => Promise<Transaction | null>;
|
46
|
+
}
|
47
|
+
|
48
|
+
Transaction.init(
|
49
|
+
{
|
50
|
+
id: {
|
51
|
+
type: DataTypes.BIGINT,
|
52
|
+
primaryKey: true,
|
53
|
+
allowNull: false,
|
54
|
+
defaultValue: sequelize.fn("next_id"),
|
55
|
+
},
|
56
|
+
payerId: {
|
57
|
+
type: DataTypes.BIGINT,
|
58
|
+
field: "payer_id",
|
59
|
+
},
|
60
|
+
recipientId: {
|
61
|
+
type: DataTypes.BIGINT,
|
62
|
+
field: "recipient_id",
|
63
|
+
},
|
64
|
+
transactionAmountInCents: {
|
65
|
+
type: DataTypes.INTEGER,
|
66
|
+
field: "transaction_amount_in_cents",
|
67
|
+
},
|
68
|
+
transactionType: {
|
69
|
+
type: DataTypes.STRING,
|
70
|
+
field: "transaction_type",
|
71
|
+
},
|
72
|
+
withdrawalId: {
|
73
|
+
type: DataTypes.BIGINT,
|
74
|
+
field: "withdrawal_id",
|
75
|
+
},
|
76
|
+
withdrawalDate: {
|
77
|
+
type: DataTypes.DATE,
|
78
|
+
field: "withdrawal_date",
|
79
|
+
},
|
80
|
+
metadata: {
|
81
|
+
type: DataTypes.STRING,
|
82
|
+
field: "metadata",
|
83
|
+
},
|
84
|
+
earningAmountInCents: {
|
85
|
+
type: DataTypes.INTEGER,
|
86
|
+
field: "earning_amount_in_cents",
|
87
|
+
},
|
88
|
+
referredTransactionId: {
|
89
|
+
type: DataTypes.BIGINT,
|
90
|
+
field: "referred_transaction_id",
|
91
|
+
},
|
92
|
+
recurlyInvoiceId: {
|
93
|
+
type: DataTypes.STRING,
|
94
|
+
field: "recurly_invoice_id",
|
95
|
+
},
|
96
|
+
createdAt: DataTypes.DATE,
|
97
|
+
updatedAt: DataTypes.DATE,
|
98
|
+
},
|
99
|
+
{
|
100
|
+
tableName: "credit_payments",
|
101
|
+
sequelize,
|
102
|
+
}
|
103
|
+
);
|
104
|
+
|
105
|
+
const REFERRAL_PERCENTAGE = 0.03;
|
106
|
+
|
107
|
+
/*
|
108
|
+
====================================================================
|
109
|
+
Class functions
|
110
|
+
====================================================================
|
111
|
+
*/
|
112
|
+
|
113
|
+
Transaction.getById = async (id: string) => {
|
114
|
+
return await Transaction.findOne({
|
115
|
+
where: {
|
116
|
+
id,
|
117
|
+
},
|
118
|
+
});
|
119
|
+
};
|
120
|
+
|
121
|
+
User.hasMany(Transaction, {
|
122
|
+
foreignKey: "payerId",
|
123
|
+
onDelete: "NO ACTION",
|
124
|
+
constraints: false,
|
125
|
+
});
|
126
|
+
|
127
|
+
Transaction.hasOne(User, {
|
128
|
+
foreignKey: "id",
|
129
|
+
sourceKey: "payerId",
|
130
|
+
onDelete: "NO ACTION",
|
131
|
+
constraints: false,
|
132
|
+
});
|
133
|
+
|
134
|
+
User.hasMany(Transaction, {
|
135
|
+
foreignKey: "recipientId",
|
136
|
+
onDelete: "NO ACTION",
|
137
|
+
constraints: false,
|
138
|
+
});
|
139
|
+
|
140
|
+
Transaction.hasOne(User, {
|
141
|
+
foreignKey: "id",
|
142
|
+
sourceKey: "recipientId",
|
143
|
+
onDelete: "NO ACTION",
|
144
|
+
constraints: false,
|
145
|
+
});
|
146
|
+
|
147
|
+
Notification.hasOne(Transaction, {
|
148
|
+
foreignKey: "id",
|
149
|
+
sourceKey: "transactionId",
|
150
|
+
constraints: false,
|
151
|
+
onDelete: "NO ACTION",
|
152
|
+
});
|
153
|
+
|
154
|
+
export default Transaction;
|
package/typed-model/user.ts
CHANGED
@@ -28,8 +28,8 @@ class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> {
|
|
28
28
|
declare password?: string;
|
29
29
|
declare username?: string;
|
30
30
|
declare emailVerified?: boolean;
|
31
|
-
declare userStatus?:
|
32
|
-
declare userRole?:
|
31
|
+
declare userStatus?: UserStatus;
|
32
|
+
declare userRole?: UserRole;
|
33
33
|
declare phoneNumber?: string;
|
34
34
|
|
35
35
|
declare bio?: string;
|
@@ -4,27 +4,25 @@ import {
|
|
4
4
|
InferCreationAttributes,
|
5
5
|
CreationOptional,
|
6
6
|
DataTypes,
|
7
|
-
fn,
|
8
7
|
} from "sequelize";
|
9
8
|
|
10
9
|
import sequelize from "./pb-sequelize";
|
11
10
|
|
12
11
|
// order of InferAttributes & InferCreationAttributes is important.
|
13
|
-
class
|
14
|
-
InferAttributes<
|
15
|
-
InferCreationAttributes<
|
12
|
+
class Withdrawal extends Model<
|
13
|
+
InferAttributes<Withdrawal>,
|
14
|
+
InferCreationAttributes<Withdrawal>
|
16
15
|
> {
|
17
16
|
// 'CreationOptional' is a special type that marks the field as optional
|
18
17
|
// when creating an instance of the model (such as using Model.create()).
|
19
18
|
declare id: CreationOptional<string>;
|
20
|
-
declare
|
21
|
-
declare agencyId?: string;
|
19
|
+
declare userId: string;
|
22
20
|
declare amountInCents: number;
|
23
21
|
declare createdAt: CreationOptional<Date>;
|
24
22
|
declare updatedAt: CreationOptional<Date>;
|
25
23
|
}
|
26
24
|
|
27
|
-
|
25
|
+
Withdrawal.init(
|
28
26
|
{
|
29
27
|
id: {
|
30
28
|
type: DataTypes.BIGINT,
|
@@ -32,13 +30,9 @@ CreditPayout.init(
|
|
32
30
|
allowNull: false,
|
33
31
|
defaultValue: sequelize.fn("next_id"),
|
34
32
|
},
|
35
|
-
|
33
|
+
userId: {
|
36
34
|
type: DataTypes.BIGINT,
|
37
|
-
field: "
|
38
|
-
},
|
39
|
-
agencyId: {
|
40
|
-
type: DataTypes.BIGINT,
|
41
|
-
field: "agency_id",
|
35
|
+
field: "user_id",
|
42
36
|
},
|
43
37
|
amountInCents: {
|
44
38
|
type: DataTypes.INTEGER,
|
@@ -48,15 +42,9 @@ CreditPayout.init(
|
|
48
42
|
updatedAt: DataTypes.DATE,
|
49
43
|
},
|
50
44
|
{
|
51
|
-
tableName: "
|
45
|
+
tableName: "withdrawals",
|
52
46
|
sequelize,
|
53
47
|
}
|
54
48
|
);
|
55
49
|
|
56
|
-
|
57
|
-
====================================================================
|
58
|
-
Class functions
|
59
|
-
====================================================================
|
60
|
-
*/
|
61
|
-
|
62
|
-
export default CreditPayout;
|
50
|
+
export default Withdrawal;
|