@winible/winible-typed 1.0.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/README.md +32 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations/20220601151258-custom_name_describing_your_migration.js +19 -0
- package/dist/migrations/20220601151258-custom_name_describing_your_migration.js.map +1 -0
- package/dist/migrations/20220605225655-create-dashboard-user-permissions.js +27 -0
- package/dist/migrations/20220605225655-create-dashboard-user-permissions.js.map +1 -0
- package/dist/migrations/20220606001300-update-dashboard-user-permissions.js +14 -0
- package/dist/migrations/20220606001300-update-dashboard-user-permissions.js.map +1 -0
- package/dist/migrations/20220607091109-add-read-date-for-message.js +19 -0
- package/dist/migrations/20220607091109-add-read-date-for-message.js.map +1 -0
- package/dist/migrations/20220616225456-add-delete-columns.js +21 -0
- package/dist/migrations/20220616225456-add-delete-columns.js.map +1 -0
- package/dist/migrations/20220709202211-disable-feed.js +24 -0
- package/dist/migrations/20220709202211-disable-feed.js.map +1 -0
- package/dist/migrations/20220723215213-limit-promotion-claims.js +18 -0
- package/dist/migrations/20220723215213-limit-promotion-claims.js.map +1 -0
- package/dist/migrations/20220723220233-num_claims.js +12 -0
- package/dist/migrations/20220723220233-num_claims.js.map +1 -0
- package/dist/migrations/20220723221907-default_false_promos.js +17 -0
- package/dist/migrations/20220723221907-default_false_promos.js.map +1 -0
- package/dist/migrations/20220724172559-default_zero_claims.js +13 -0
- package/dist/migrations/20220724172559-default_zero_claims.js.map +1 -0
- package/dist/migrations/20220724201419-pinned_post.js +13 -0
- package/dist/migrations/20220724201419-pinned_post.js.map +1 -0
- package/dist/migrations/20220729164625-unsend_mass.js +12 -0
- package/dist/migrations/20220729164625-unsend_mass.js.map +1 -0
- package/dist/migrations/20220823033002-interval-unit.js +14 -0
- package/dist/migrations/20220823033002-interval-unit.js.map +1 -0
- package/dist/migrations/20220830193530-processorId.js +15 -0
- package/dist/migrations/20220830193530-processorId.js.map +1 -0
- package/dist/migrations/20220907121932-add-processor-to-sub.js +15 -0
- package/dist/migrations/20220907121932-add-processor-to-sub.js.map +1 -0
- package/dist/migrations/20220907212232-add-trans-id.js +12 -0
- package/dist/migrations/20220907212232-add-trans-id.js.map +1 -0
- package/dist/migrations/20220907220423-big-int-trans.js +12 -0
- package/dist/migrations/20220907220423-big-int-trans.js.map +1 -0
- package/dist/migrations/20220909161902-add-stale.js +13 -0
- package/dist/migrations/20220909161902-add-stale.js.map +1 -0
- package/dist/migrations/20220922000225-verified-spender.js +13 -0
- package/dist/migrations/20220922000225-verified-spender.js.map +1 -0
- package/dist/migrations/20220922212108-verified-spender-2.js +16 -0
- package/dist/migrations/20220922212108-verified-spender-2.js.map +1 -0
- package/dist/migrations/20221013223648-product-subscription-list.js +12 -0
- package/dist/migrations/20221013223648-product-subscription-list.js.map +1 -0
- package/dist/migrations/20221014001037-product-subscription-list.js +75 -0
- package/dist/migrations/20221014001037-product-subscription-list.js.map +1 -0
- package/dist/migrations/20221026055245-update-type.js +15 -0
- package/dist/migrations/20221026055245-update-type.js.map +1 -0
- package/dist/scripts/authorizeTransfer.js +188 -0
- package/dist/scripts/authorizeTransfer.js.map +1 -0
- package/dist/scripts/createDashboardLink.js +30 -0
- package/dist/scripts/createDashboardLink.js.map +1 -0
- package/dist/scripts/deleteMalformedImages.js +84 -0
- package/dist/scripts/deleteMalformedImages.js.map +1 -0
- package/dist/scripts/importMixpanelEvents.js +44 -0
- package/dist/scripts/importMixpanelEvents.js.map +1 -0
- package/dist/scripts/payoutSubscriptions.js +185 -0
- package/dist/scripts/payoutSubscriptions.js.map +1 -0
- package/dist/scripts/removeUnreferenceSubs.js +39 -0
- package/dist/scripts/removeUnreferenceSubs.js.map +1 -0
- package/dist/scripts/test.js +33 -0
- package/dist/scripts/test.js.map +1 -0
- package/dist/server/index.js +30 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/middlewares/slack-auth.js +40 -0
- package/dist/server/middlewares/slack-auth.js.map +1 -0
- package/dist/server/v1/bypassCreator.js +81 -0
- package/dist/server/v1/bypassCreator.js.map +1 -0
- package/dist/server/v1/cancelSubscription.js +35 -0
- package/dist/server/v1/cancelSubscription.js.map +1 -0
- package/dist/server/v1/changeName.js +41 -0
- package/dist/server/v1/changeName.js.map +1 -0
- package/dist/server/v1/checkAuthSub.js +58 -0
- package/dist/server/v1/checkAuthSub.js.map +1 -0
- package/dist/server/v1/dashboardLink.js +30 -0
- package/dist/server/v1/dashboardLink.js.map +1 -0
- package/dist/server/v1/getSuspendedSubs.js +76 -0
- package/dist/server/v1/getSuspendedSubs.js.map +1 -0
- package/dist/server/v1/index.js +28 -0
- package/dist/server/v1/index.js.map +1 -0
- package/dist/server/v1/manualCreateSub.js +159 -0
- package/dist/server/v1/manualCreateSub.js.map +1 -0
- package/dist/server/v1/refund.js +78 -0
- package/dist/server/v1/refund.js.map +1 -0
- package/dist/server/v1/retrySubscription.js +81 -0
- package/dist/server/v1/retrySubscription.js.map +1 -0
- package/dist/server/v1/searchUser.js +169 -0
- package/dist/server/v1/searchUser.js.map +1 -0
- package/dist/server/v1/slack.js +14 -0
- package/dist/server/v1/slack.js.map +1 -0
- package/dist/src/index.js +24 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/pk-client.js +1103 -0
- package/dist/src/pk-client.js.map +1 -0
- package/dist/src/pk-sub.js +310 -0
- package/dist/src/pk-sub.js.map +1 -0
- package/dist/src/slack-client.js +48 -0
- package/dist/src/slack-client.js.map +1 -0
- package/dist/src/types.js +3 -0
- package/dist/src/types.js.map +1 -0
- package/dist/support/index.js +19 -0
- package/dist/support/index.js.map +1 -0
- package/dist/support/metrics.js +21 -0
- package/dist/support/metrics.js.map +1 -0
- package/dist/support/mixpanel.js +7 -0
- package/dist/support/mixpanel.js.map +1 -0
- package/dist/support/slack-client.js +51 -0
- package/dist/support/slack-client.js.map +1 -0
- package/dist/support/uploadcare.js +140 -0
- package/dist/support/uploadcare.js.map +1 -0
- package/dist/support/utils.js +69 -0
- package/dist/support/utils.js.map +1 -0
- package/dist/typed-model/asset-category.js +38 -0
- package/dist/typed-model/asset-category.js.map +1 -0
- package/dist/typed-model/asset-constent-person.js +56 -0
- package/dist/typed-model/asset-constent-person.js.map +1 -0
- package/dist/typed-model/blocked-ip.js +34 -0
- package/dist/typed-model/blocked-ip.js.map +1 -0
- package/dist/typed-model/category-tag.js +46 -0
- package/dist/typed-model/category-tag.js.map +1 -0
- package/dist/typed-model/consent-person.js +55 -0
- package/dist/typed-model/consent-person.js.map +1 -0
- package/dist/typed-model/content-category-tag.js +58 -0
- package/dist/typed-model/content-category-tag.js.map +1 -0
- package/dist/typed-model/content-like.js +58 -0
- package/dist/typed-model/content-like.js.map +1 -0
- package/dist/typed-model/credit-payment.js +389 -0
- package/dist/typed-model/credit-payment.js.map +1 -0
- package/dist/typed-model/credit-payout.js +42 -0
- package/dist/typed-model/credit-payout.js.map +1 -0
- package/dist/typed-model/credit-purchase.js +46 -0
- package/dist/typed-model/credit-purchase.js.map +1 -0
- package/dist/typed-model/customer-profile.js +51 -0
- package/dist/typed-model/customer-profile.js.map +1 -0
- package/dist/typed-model/dashboard-user-permissions.js +34 -0
- package/dist/typed-model/dashboard-user-permissions.js.map +1 -0
- package/dist/typed-model/dashboard-user.js +109 -0
- package/dist/typed-model/dashboard-user.js.map +1 -0
- package/dist/typed-model/fan-list.js +46 -0
- package/dist/typed-model/fan-list.js.map +1 -0
- package/dist/typed-model/fraud.js +41 -0
- package/dist/typed-model/fraud.js.map +1 -0
- package/dist/typed-model/index.js +101 -0
- package/dist/typed-model/index.js.map +1 -0
- package/dist/typed-model/list-member.js +47 -0
- package/dist/typed-model/list-member.js.map +1 -0
- package/dist/typed-model/mass-message.js +43 -0
- package/dist/typed-model/mass-message.js.map +1 -0
- package/dist/typed-model/media-asset.js +73 -0
- package/dist/typed-model/media-asset.js.map +1 -0
- package/dist/typed-model/media-category.js +49 -0
- package/dist/typed-model/media-category.js.map +1 -0
- package/dist/typed-model/media.js +59 -0
- package/dist/typed-model/media.js.map +1 -0
- package/dist/typed-model/message-media.js +53 -0
- package/dist/typed-model/message-media.js.map +1 -0
- package/dist/typed-model/message.js +191 -0
- package/dist/typed-model/message.js.map +1 -0
- package/dist/typed-model/notification.js +84 -0
- package/dist/typed-model/notification.js.map +1 -0
- package/dist/typed-model/pb-sequelize.js +25 -0
- package/dist/typed-model/pb-sequelize.js.map +1 -0
- package/dist/typed-model/phone-chat-participation.js +127 -0
- package/dist/typed-model/phone-chat-participation.js.map +1 -0
- package/dist/typed-model/phone-chat.js +118 -0
- package/dist/typed-model/phone-chat.js.map +1 -0
- package/dist/typed-model/phone-owner.js +266 -0
- package/dist/typed-model/phone-owner.js.map +1 -0
- package/dist/typed-model/phone-user.js +109 -0
- package/dist/typed-model/phone-user.js.map +1 -0
- package/dist/typed-model/premium-content.js +123 -0
- package/dist/typed-model/premium-content.js.map +1 -0
- package/dist/typed-model/purchased-content.js +69 -0
- package/dist/typed-model/purchased-content.js.map +1 -0
- package/dist/typed-model/short-url.js +88 -0
- package/dist/typed-model/short-url.js.map +1 -0
- package/dist/typed-model/subscription-bundle.js +53 -0
- package/dist/typed-model/subscription-bundle.js.map +1 -0
- package/dist/typed-model/subscription-category-tags.js +58 -0
- package/dist/typed-model/subscription-category-tags.js.map +1 -0
- package/dist/typed-model/subscription-plan.js +126 -0
- package/dist/typed-model/subscription-plan.js.map +1 -0
- package/dist/typed-model/subscription-promotion.js +93 -0
- package/dist/typed-model/subscription-promotion.js.map +1 -0
- package/dist/typed-model/subscription.js +123 -0
- package/dist/typed-model/subscription.js.map +1 -0
- package/dist/typed-model/twilio-phone.js +92 -0
- package/dist/typed-model/twilio-phone.js.map +1 -0
- package/dist/typed-model/user-follow.js +103 -0
- package/dist/typed-model/user-follow.js.map +1 -0
- package/dist/typed-model/verification-code.js +52 -0
- package/dist/typed-model/verification-code.js.map +1 -0
- package/index.ts +3 -0
- package/package.json +72 -0
- package/src/index.ts +2 -0
- package/src/pk-client.ts +1650 -0
- package/src/pk-sub.ts +455 -0
- package/src/types.ts +40 -0
- package/support/index.ts +2 -0
- package/support/slack-client.ts +43 -0
- package/support/uploadcare.ts +191 -0
- package/support/utils.ts +72 -0
- package/typed-model/asset-category.ts +57 -0
- package/typed-model/asset-constent-person.ts +82 -0
- package/typed-model/blocked-ip.ts +52 -0
- package/typed-model/category-tag.ts +66 -0
- package/typed-model/consent-person.ts +78 -0
- package/typed-model/content-category-tag.ts +79 -0
- package/typed-model/content-like.ts +79 -0
- package/typed-model/credit-payment.ts +678 -0
- package/typed-model/credit-payout.ts +62 -0
- package/typed-model/credit-purchase.ts +67 -0
- package/typed-model/customer-profile.ts +70 -0
- package/typed-model/dashboard-user-permissions.ts +51 -0
- package/typed-model/dashboard-user.ts +146 -0
- package/typed-model/fan-list.ts +68 -0
- package/typed-model/fraud.ts +62 -0
- package/typed-model/index.ts +58 -0
- package/typed-model/list-member.ts +67 -0
- package/typed-model/mass-message.ts +64 -0
- package/typed-model/media-asset.ts +99 -0
- package/typed-model/media-category.ts +70 -0
- package/typed-model/media.ts +85 -0
- package/typed-model/message-media.ts +74 -0
- package/typed-model/message.ts +258 -0
- package/typed-model/notification.ts +130 -0
- package/typed-model/pb-sequelize.ts +25 -0
- package/typed-model/phone-chat-participation.ts +166 -0
- package/typed-model/phone-chat.ts +185 -0
- package/typed-model/phone-owner.ts +341 -0
- package/typed-model/phone-user.ts +146 -0
- package/typed-model/premium-content.ts +164 -0
- package/typed-model/purchased-content.ts +100 -0
- package/typed-model/short-url.ts +120 -0
- package/typed-model/subscription-bundle.ts +75 -0
- package/typed-model/subscription-category-tags.ts +79 -0
- package/typed-model/subscription-plan.ts +171 -0
- package/typed-model/subscription-promotion.ts +125 -0
- package/typed-model/subscription.ts +170 -0
- package/typed-model/twilio-phone.ts +149 -0
- package/typed-model/user-follow.ts +141 -0
- package/typed-model/verification-code.ts +74 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
import {
|
2
|
+
Model,
|
3
|
+
InferAttributes,
|
4
|
+
InferCreationAttributes,
|
5
|
+
CreationOptional,
|
6
|
+
DataTypes,
|
7
|
+
fn,
|
8
|
+
} from "sequelize";
|
9
|
+
|
10
|
+
import sequelize from "./pb-sequelize";
|
11
|
+
|
12
|
+
// order of InferAttributes & InferCreationAttributes is important.
|
13
|
+
class CreditPayout extends Model<
|
14
|
+
InferAttributes<CreditPayout>,
|
15
|
+
InferCreationAttributes<CreditPayout>
|
16
|
+
> {
|
17
|
+
// 'CreationOptional' is a special type that marks the field as optional
|
18
|
+
// when creating an instance of the model (such as using Model.create()).
|
19
|
+
declare id: CreationOptional<string>;
|
20
|
+
declare ownerId: string;
|
21
|
+
declare agencyId?: string;
|
22
|
+
declare amountInCents: number;
|
23
|
+
declare createdAt: CreationOptional<Date>;
|
24
|
+
declare updatedAt: CreationOptional<Date>;
|
25
|
+
}
|
26
|
+
|
27
|
+
CreditPayout.init(
|
28
|
+
{
|
29
|
+
id: {
|
30
|
+
type: DataTypes.BIGINT,
|
31
|
+
primaryKey: true,
|
32
|
+
allowNull: false,
|
33
|
+
defaultValue: sequelize.fn("next_id"),
|
34
|
+
},
|
35
|
+
ownerId: {
|
36
|
+
type: DataTypes.BIGINT,
|
37
|
+
field: "owner_id",
|
38
|
+
},
|
39
|
+
agencyId: {
|
40
|
+
type: DataTypes.BIGINT,
|
41
|
+
field: "agency_id",
|
42
|
+
},
|
43
|
+
amountInCents: {
|
44
|
+
type: DataTypes.INTEGER,
|
45
|
+
field: "amount_in_cents",
|
46
|
+
},
|
47
|
+
createdAt: DataTypes.DATE,
|
48
|
+
updatedAt: DataTypes.DATE,
|
49
|
+
},
|
50
|
+
{
|
51
|
+
tableName: "credit_payouts",
|
52
|
+
sequelize,
|
53
|
+
}
|
54
|
+
);
|
55
|
+
|
56
|
+
/*
|
57
|
+
====================================================================
|
58
|
+
Class functions
|
59
|
+
====================================================================
|
60
|
+
*/
|
61
|
+
|
62
|
+
export default CreditPayout;
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import {
|
2
|
+
Model,
|
3
|
+
InferAttributes,
|
4
|
+
InferCreationAttributes,
|
5
|
+
CreationOptional,
|
6
|
+
DataTypes,
|
7
|
+
fn,
|
8
|
+
} from "sequelize";
|
9
|
+
|
10
|
+
import sequelize from "./pb-sequelize";
|
11
|
+
|
12
|
+
// order of InferAttributes & InferCreationAttributes is important.
|
13
|
+
class CreditPurchase extends Model<
|
14
|
+
InferAttributes<CreditPurchase>,
|
15
|
+
InferCreationAttributes<CreditPurchase>
|
16
|
+
> {
|
17
|
+
// 'CreationOptional' is a special type that marks the field as optional
|
18
|
+
// when creating an instance of the model (such as using Model.create()).
|
19
|
+
declare id: CreationOptional<string>;
|
20
|
+
declare userId: string;
|
21
|
+
declare creditAmountInCents: number;
|
22
|
+
declare createdAt: CreationOptional<Date>;
|
23
|
+
declare updatedAt: CreationOptional<Date>;
|
24
|
+
static getById: (id: string) => Promise<CreditPurchase | null>;
|
25
|
+
}
|
26
|
+
|
27
|
+
CreditPurchase.init(
|
28
|
+
{
|
29
|
+
id: {
|
30
|
+
type: DataTypes.BIGINT,
|
31
|
+
primaryKey: true,
|
32
|
+
allowNull: false,
|
33
|
+
defaultValue: sequelize.fn("next_id"),
|
34
|
+
},
|
35
|
+
userId: {
|
36
|
+
type: DataTypes.BIGINT,
|
37
|
+
allowNull: false,
|
38
|
+
field: "user_id",
|
39
|
+
},
|
40
|
+
creditAmountInCents: {
|
41
|
+
type: DataTypes.INTEGER,
|
42
|
+
field: "credit_amount_in_cents",
|
43
|
+
},
|
44
|
+
createdAt: DataTypes.DATE,
|
45
|
+
updatedAt: DataTypes.DATE,
|
46
|
+
},
|
47
|
+
{
|
48
|
+
tableName: "credit_purchases",
|
49
|
+
sequelize,
|
50
|
+
}
|
51
|
+
);
|
52
|
+
|
53
|
+
/*
|
54
|
+
====================================================================
|
55
|
+
Class functions
|
56
|
+
====================================================================
|
57
|
+
*/
|
58
|
+
|
59
|
+
CreditPurchase.getById = async (id: string) => {
|
60
|
+
return await CreditPurchase.findOne({
|
61
|
+
where: {
|
62
|
+
id,
|
63
|
+
},
|
64
|
+
});
|
65
|
+
};
|
66
|
+
|
67
|
+
export default CreditPurchase;
|
@@ -0,0 +1,70 @@
|
|
1
|
+
import {
|
2
|
+
Model,
|
3
|
+
InferAttributes,
|
4
|
+
InferCreationAttributes,
|
5
|
+
CreationOptional,
|
6
|
+
DataTypes,
|
7
|
+
fn,
|
8
|
+
} from "sequelize";
|
9
|
+
|
10
|
+
import sequelize from "./pb-sequelize";
|
11
|
+
|
12
|
+
export enum ProcessorId {
|
13
|
+
HUMBOLDT = "humboldt",
|
14
|
+
KAJA = "kaja",
|
15
|
+
KAJACOACHING = "kajacoaching",
|
16
|
+
}
|
17
|
+
|
18
|
+
// order of InferAttributes & InferCreationAttributes is important.
|
19
|
+
class PKCustomerProfile extends Model<
|
20
|
+
InferAttributes<PKCustomerProfile>,
|
21
|
+
InferCreationAttributes<PKCustomerProfile>
|
22
|
+
> {
|
23
|
+
// 'CreationOptional' is a special type that marks the field as optional
|
24
|
+
// when creating an instance of the model (such as using Model.create()).
|
25
|
+
declare id: CreationOptional<string>;
|
26
|
+
declare userId: string;
|
27
|
+
declare customerProfileId: string;
|
28
|
+
declare defaultPaymentProfileId?: string;
|
29
|
+
declare processorId: ProcessorId;
|
30
|
+
declare createdAt: CreationOptional<Date>;
|
31
|
+
declare updatedAt: CreationOptional<Date>;
|
32
|
+
}
|
33
|
+
|
34
|
+
PKCustomerProfile.init(
|
35
|
+
{
|
36
|
+
id: {
|
37
|
+
type: DataTypes.BIGINT,
|
38
|
+
primaryKey: true,
|
39
|
+
allowNull: false,
|
40
|
+
defaultValue: sequelize.fn("next_id"),
|
41
|
+
},
|
42
|
+
userId: {
|
43
|
+
type: DataTypes.BIGINT,
|
44
|
+
allowNull: false,
|
45
|
+
field: "user_id",
|
46
|
+
},
|
47
|
+
customerProfileId: {
|
48
|
+
type: DataTypes.STRING,
|
49
|
+
field: "pk_customer_profile_id",
|
50
|
+
},
|
51
|
+
processorId: {
|
52
|
+
type: DataTypes.STRING,
|
53
|
+
field: "processor_id",
|
54
|
+
allowNull: false,
|
55
|
+
defaultValue: ProcessorId.HUMBOLDT,
|
56
|
+
},
|
57
|
+
defaultPaymentProfileId: {
|
58
|
+
type: DataTypes.STRING,
|
59
|
+
field: "pk_default_payment_profile_id",
|
60
|
+
},
|
61
|
+
createdAt: DataTypes.DATE,
|
62
|
+
updatedAt: DataTypes.DATE,
|
63
|
+
},
|
64
|
+
{
|
65
|
+
tableName: "pk_customer_profiles",
|
66
|
+
sequelize,
|
67
|
+
}
|
68
|
+
);
|
69
|
+
|
70
|
+
export default PKCustomerProfile;
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import {
|
2
|
+
Model,
|
3
|
+
InferAttributes,
|
4
|
+
InferCreationAttributes,
|
5
|
+
CreationOptional,
|
6
|
+
DataTypes,
|
7
|
+
fn,
|
8
|
+
} from "sequelize";
|
9
|
+
|
10
|
+
import sequelize from "./pb-sequelize";
|
11
|
+
|
12
|
+
// order of InferAttributes & InferCreationAttributes is important.
|
13
|
+
class DashboardUserPermissions extends Model<
|
14
|
+
InferAttributes<DashboardUserPermissions>,
|
15
|
+
InferCreationAttributes<DashboardUserPermissions>
|
16
|
+
> {
|
17
|
+
// 'CreationOptional' is a special type that marks the field as optional
|
18
|
+
// when creating an instance of the model (such as using Model.create()).
|
19
|
+
declare id: CreationOptional<string>;
|
20
|
+
declare dashboardUserId: string;
|
21
|
+
declare role: "admin" | "message-only";
|
22
|
+
declare createdAt: CreationOptional<Date>;
|
23
|
+
declare updatedAt: CreationOptional<Date>;
|
24
|
+
}
|
25
|
+
|
26
|
+
DashboardUserPermissions.init(
|
27
|
+
{
|
28
|
+
id: {
|
29
|
+
type: DataTypes.BIGINT,
|
30
|
+
primaryKey: true,
|
31
|
+
allowNull: false,
|
32
|
+
defaultValue: fn("next_id"),
|
33
|
+
},
|
34
|
+
dashboardUserId: {
|
35
|
+
type: new DataTypes.BIGINT(),
|
36
|
+
allowNull: false,
|
37
|
+
unique: true,
|
38
|
+
},
|
39
|
+
role: {
|
40
|
+
type: new DataTypes.STRING(30),
|
41
|
+
allowNull: false,
|
42
|
+
},
|
43
|
+
createdAt: DataTypes.DATE,
|
44
|
+
updatedAt: DataTypes.DATE,
|
45
|
+
},
|
46
|
+
{
|
47
|
+
sequelize,
|
48
|
+
tableName: "dashboard_user_permissions",
|
49
|
+
}
|
50
|
+
);
|
51
|
+
export default DashboardUserPermissions;
|
@@ -0,0 +1,146 @@
|
|
1
|
+
import {
|
2
|
+
Model,
|
3
|
+
InferAttributes,
|
4
|
+
InferCreationAttributes,
|
5
|
+
CreationOptional,
|
6
|
+
DataTypes,
|
7
|
+
fn,
|
8
|
+
} from "sequelize";
|
9
|
+
|
10
|
+
import PhoneUser from "./phone-user";
|
11
|
+
import PhoneOwner from "./phone-owner";
|
12
|
+
|
13
|
+
import sequelize from "./pb-sequelize";
|
14
|
+
|
15
|
+
// order of InferAttributes & InferCreationAttributes is important.
|
16
|
+
class DashboardUser extends Model<
|
17
|
+
InferAttributes<DashboardUser>,
|
18
|
+
InferCreationAttributes<DashboardUser>
|
19
|
+
> {
|
20
|
+
// 'CreationOptional' is a special type that marks the field as optional
|
21
|
+
// when creating an instance of the model (such as using Model.create()).
|
22
|
+
declare id: CreationOptional<string>;
|
23
|
+
declare ownerId?: string;
|
24
|
+
declare userId?: string;
|
25
|
+
declare email?: string;
|
26
|
+
declare password?: string;
|
27
|
+
declare referringOwnerId?: string;
|
28
|
+
declare name?: string;
|
29
|
+
declare username?: string;
|
30
|
+
declare masspayUserToken?: string;
|
31
|
+
declare deleted?: boolean;
|
32
|
+
declare emailVerified?: boolean;
|
33
|
+
|
34
|
+
declare createdAt?: Date;
|
35
|
+
declare updatedAt?: Date;
|
36
|
+
static getById: (id: string) => Promise<DashboardUser | null>;
|
37
|
+
static getByEmail: (email: string) => Promise<DashboardUser | null>;
|
38
|
+
static getAllByOwnerId: (ownerId: string) => Promise<DashboardUser[]>;
|
39
|
+
}
|
40
|
+
|
41
|
+
DashboardUser.init(
|
42
|
+
{
|
43
|
+
id: {
|
44
|
+
type: DataTypes.BIGINT,
|
45
|
+
primaryKey: true,
|
46
|
+
allowNull: false,
|
47
|
+
defaultValue: fn("next_id"),
|
48
|
+
},
|
49
|
+
ownerId: {
|
50
|
+
type: DataTypes.BIGINT,
|
51
|
+
field: "phone_owner_id",
|
52
|
+
},
|
53
|
+
userId: {
|
54
|
+
type: DataTypes.BIGINT,
|
55
|
+
field: "user_id",
|
56
|
+
},
|
57
|
+
email: {
|
58
|
+
type: DataTypes.STRING,
|
59
|
+
field: "email",
|
60
|
+
unique: true,
|
61
|
+
},
|
62
|
+
password: {
|
63
|
+
type: DataTypes.STRING,
|
64
|
+
field: "password",
|
65
|
+
},
|
66
|
+
referringOwnerId: {
|
67
|
+
type: DataTypes.BIGINT,
|
68
|
+
field: "referring_owner_id",
|
69
|
+
},
|
70
|
+
name: {
|
71
|
+
type: DataTypes.STRING,
|
72
|
+
field: "name",
|
73
|
+
},
|
74
|
+
username: {
|
75
|
+
type: DataTypes.STRING,
|
76
|
+
field: "username",
|
77
|
+
// unique: true,
|
78
|
+
},
|
79
|
+
masspayUserToken: {
|
80
|
+
type: DataTypes.STRING,
|
81
|
+
field: "masspay_user_token",
|
82
|
+
unique: true,
|
83
|
+
},
|
84
|
+
deleted: {
|
85
|
+
type: DataTypes.BOOLEAN,
|
86
|
+
field: "deleted",
|
87
|
+
defaultValue: false,
|
88
|
+
},
|
89
|
+
emailVerified: {
|
90
|
+
type: DataTypes.BOOLEAN,
|
91
|
+
field: "email_verified",
|
92
|
+
defaultValue: false,
|
93
|
+
},
|
94
|
+
},
|
95
|
+
{
|
96
|
+
tableName: "dashboard_users",
|
97
|
+
sequelize,
|
98
|
+
defaultScope: {
|
99
|
+
attributes: { exclude: ["password"] },
|
100
|
+
},
|
101
|
+
}
|
102
|
+
);
|
103
|
+
|
104
|
+
/*
|
105
|
+
====================================================================
|
106
|
+
Class functions
|
107
|
+
====================================================================
|
108
|
+
*/
|
109
|
+
|
110
|
+
DashboardUser.getById = async (id: string) => {
|
111
|
+
return await DashboardUser.findOne({
|
112
|
+
where: {
|
113
|
+
id,
|
114
|
+
},
|
115
|
+
});
|
116
|
+
};
|
117
|
+
|
118
|
+
DashboardUser.getByEmail = async (email: string) => {
|
119
|
+
return await DashboardUser.findOne({
|
120
|
+
where: {
|
121
|
+
email,
|
122
|
+
},
|
123
|
+
});
|
124
|
+
};
|
125
|
+
|
126
|
+
DashboardUser.getAllByOwnerId = async (ownerId: string) => {
|
127
|
+
return await DashboardUser.findAll({
|
128
|
+
where: {
|
129
|
+
ownerId,
|
130
|
+
},
|
131
|
+
});
|
132
|
+
};
|
133
|
+
|
134
|
+
DashboardUser.hasOne(PhoneOwner, {
|
135
|
+
foreignKey: "id",
|
136
|
+
sourceKey: "ownerId",
|
137
|
+
constraints: false,
|
138
|
+
});
|
139
|
+
|
140
|
+
DashboardUser.hasOne(PhoneUser, {
|
141
|
+
foreignKey: "id",
|
142
|
+
sourceKey: "userId",
|
143
|
+
constraints: false,
|
144
|
+
});
|
145
|
+
|
146
|
+
export default DashboardUser;
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import {
|
2
|
+
Model,
|
3
|
+
InferAttributes,
|
4
|
+
InferCreationAttributes,
|
5
|
+
CreationOptional,
|
6
|
+
DataTypes,
|
7
|
+
fn,
|
8
|
+
} from "sequelize";
|
9
|
+
import ListMember from "./list-member";
|
10
|
+
|
11
|
+
import sequelize from "./pb-sequelize";
|
12
|
+
import PhoneOwner from "./phone-owner";
|
13
|
+
|
14
|
+
// order of InferAttributes & InferCreationAttributes is important.
|
15
|
+
class FanList extends Model<
|
16
|
+
InferAttributes<FanList>,
|
17
|
+
InferCreationAttributes<FanList>
|
18
|
+
> {
|
19
|
+
// 'CreationOptional' is a special type that marks the field as optional
|
20
|
+
// when creating an instance of the model (such as using Model.create()).
|
21
|
+
declare id: CreationOptional<string>;
|
22
|
+
declare name: string;
|
23
|
+
declare ownerId: string;
|
24
|
+
declare isArchived?: boolean;
|
25
|
+
declare createdAt: CreationOptional<Date>;
|
26
|
+
declare updatedAt: CreationOptional<Date>;
|
27
|
+
}
|
28
|
+
|
29
|
+
FanList.init(
|
30
|
+
{
|
31
|
+
id: {
|
32
|
+
type: DataTypes.BIGINT,
|
33
|
+
primaryKey: true,
|
34
|
+
allowNull: false,
|
35
|
+
defaultValue: sequelize.fn("next_id"),
|
36
|
+
},
|
37
|
+
ownerId: {
|
38
|
+
type: DataTypes.BIGINT,
|
39
|
+
field: "owner_id",
|
40
|
+
},
|
41
|
+
name: {
|
42
|
+
type: DataTypes.STRING,
|
43
|
+
field: "name",
|
44
|
+
},
|
45
|
+
isArchived: {
|
46
|
+
type: DataTypes.BOOLEAN,
|
47
|
+
field: "is_archived",
|
48
|
+
defaultValue: false,
|
49
|
+
},
|
50
|
+
createdAt: DataTypes.DATE,
|
51
|
+
updatedAt: DataTypes.DATE,
|
52
|
+
},
|
53
|
+
{ tableName: "fan_lists", sequelize }
|
54
|
+
);
|
55
|
+
|
56
|
+
/*
|
57
|
+
====================================================================
|
58
|
+
Class functions
|
59
|
+
====================================================================
|
60
|
+
*/
|
61
|
+
|
62
|
+
FanList.hasMany(ListMember, { foreignKey: "fan_list_id" });
|
63
|
+
ListMember.hasOne(FanList, { foreignKey: "id", sourceKey: "fanListId" });
|
64
|
+
|
65
|
+
FanList.hasOne(PhoneOwner, { foreignKey: "id", sourceKey: "ownerId" });
|
66
|
+
PhoneOwner.hasMany(FanList, { foreignKey: "owner_id" });
|
67
|
+
|
68
|
+
export default FanList;
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import {
|
2
|
+
Model,
|
3
|
+
InferAttributes,
|
4
|
+
InferCreationAttributes,
|
5
|
+
CreationOptional,
|
6
|
+
DataTypes,
|
7
|
+
fn,
|
8
|
+
} from "sequelize";
|
9
|
+
|
10
|
+
import sequelize from "./pb-sequelize";
|
11
|
+
import PhoneOwner from "./phone-owner";
|
12
|
+
import PhoneUser from "./phone-user";
|
13
|
+
|
14
|
+
// order of InferAttributes & InferCreationAttributes is important.
|
15
|
+
class Fraud extends Model<
|
16
|
+
InferAttributes<Fraud>,
|
17
|
+
InferCreationAttributes<Fraud>
|
18
|
+
> {
|
19
|
+
// 'CreationOptional' is a special type that marks the field as optional
|
20
|
+
// when creating an instance of the model (such as using Model.create()).
|
21
|
+
declare id: CreationOptional<string>;
|
22
|
+
declare userId: string;
|
23
|
+
declare ownerId: string;
|
24
|
+
declare createdAt: CreationOptional<Date>;
|
25
|
+
declare updatedAt: CreationOptional<Date>;
|
26
|
+
}
|
27
|
+
|
28
|
+
Fraud.init(
|
29
|
+
{
|
30
|
+
id: {
|
31
|
+
type: DataTypes.BIGINT,
|
32
|
+
primaryKey: true,
|
33
|
+
allowNull: false,
|
34
|
+
defaultValue: sequelize.fn("next_id"),
|
35
|
+
},
|
36
|
+
ownerId: {
|
37
|
+
type: DataTypes.BIGINT,
|
38
|
+
field: "owner_id",
|
39
|
+
},
|
40
|
+
userId: {
|
41
|
+
type: DataTypes.BIGINT,
|
42
|
+
field: "user_id",
|
43
|
+
},
|
44
|
+
createdAt: DataTypes.DATE,
|
45
|
+
updatedAt: DataTypes.DATE,
|
46
|
+
},
|
47
|
+
{ tableName: "frauds", sequelize }
|
48
|
+
);
|
49
|
+
|
50
|
+
/*
|
51
|
+
====================================================================
|
52
|
+
Class functions
|
53
|
+
====================================================================
|
54
|
+
*/
|
55
|
+
|
56
|
+
Fraud.hasOne(PhoneUser, { foreignKey: "id", sourceKey: "userId" });
|
57
|
+
PhoneUser.hasOne(Fraud, { foreignKey: "user_id" });
|
58
|
+
|
59
|
+
Fraud.hasOne(PhoneOwner, { foreignKey: "id", sourceKey: "ownerId" });
|
60
|
+
PhoneOwner.hasOne(Fraud, { foreignKey: "owner_id" });
|
61
|
+
|
62
|
+
export default Fraud;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
// let models = {
|
2
|
+
// DashboardUserPermissions: require("./dashboard-user-permissions"),
|
3
|
+
// PhoneUser: require("./phone-user"),
|
4
|
+
// PhoneOwner: require("./phone-owner"),
|
5
|
+
// DashboardUser: require("./dashboard-user"),
|
6
|
+
// };
|
7
|
+
|
8
|
+
// export sequelize from "./pb-sequelize";
|
9
|
+
|
10
|
+
// const sync = async () => {
|
11
|
+
// console.log("Syncing type models...");
|
12
|
+
// await sequelize.sync({ alter: true });
|
13
|
+
// console.log("Sync done");
|
14
|
+
// };
|
15
|
+
|
16
|
+
// if (process.env.SYNC_TABLES) {
|
17
|
+
// sync();
|
18
|
+
// }
|
19
|
+
|
20
|
+
export { default as AssetCategory } from "./asset-category";
|
21
|
+
export { default as AssetConsentPerson } from "./asset-constent-person";
|
22
|
+
export { default as PhoneChat } from "./phone-chat";
|
23
|
+
export { default as PhoneChatParticipant } from "./phone-chat-participation";
|
24
|
+
export { default as ConsentPerson } from "./consent-person";
|
25
|
+
export { default as ContentLike } from "./content-like";
|
26
|
+
export { default as CreditPayments } from "./credit-payment";
|
27
|
+
export { default as CreditPurchase } from "./credit-purchase";
|
28
|
+
export { default as BlockedIP } from "./blocked-ip";
|
29
|
+
export { default as CustomerProfile, ProcessorId } from "./customer-profile";
|
30
|
+
export { default as DashboardUserPermissions } from "./dashboard-user-permissions";
|
31
|
+
export { default as DashboardUser } from "./dashboard-user";
|
32
|
+
export { default as FanList } from "./fan-list";
|
33
|
+
export { default as Fraud } from "./fraud";
|
34
|
+
export { default as ListMember } from "./list-member";
|
35
|
+
export { default as MassMessage } from "./mass-message";
|
36
|
+
export { default as MediaAsset } from "./media-asset";
|
37
|
+
export { default as MediaCategory } from "./media-category";
|
38
|
+
export { default as Media } from "./media";
|
39
|
+
export { default as MessageMedia } from "./message-media";
|
40
|
+
export { default as Message } from "./message";
|
41
|
+
export { default as Notification } from "./notification";
|
42
|
+
export { default as pbSequelize } from "./pb-sequelize";
|
43
|
+
export { default as PhoneOwner } from "./phone-owner";
|
44
|
+
export { default as PhoneUser } from "./phone-user";
|
45
|
+
export { default as PremiumContent } from "./premium-content";
|
46
|
+
export { default as PurchasedContent } from "./purchased-content";
|
47
|
+
export { default as SubscriptionBundle } from "./subscription-bundle";
|
48
|
+
export { default as SubscriptionPlan } from "./subscription-plan";
|
49
|
+
export { default as SubscriptionPromotion } from "./subscription-promotion";
|
50
|
+
export { default as Subscription } from "./subscription";
|
51
|
+
export { default as UserFollow } from "./user-follow";
|
52
|
+
export { default as TwilioPhone } from "./twilio-phone";
|
53
|
+
export { default as ShortUrl } from "./short-url";
|
54
|
+
export { default as CreditPayout } from "./credit-payout";
|
55
|
+
export { default as VerificationCode } from "./verification-code";
|
56
|
+
export { default as CategoryTag } from "./category-tag";
|
57
|
+
export { default as SubscriptionCategoryTag } from "./subscription-category-tags";
|
58
|
+
export { default as ContentCategoryTag } from "./content-category-tag";
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import {
|
2
|
+
Model,
|
3
|
+
InferAttributes,
|
4
|
+
InferCreationAttributes,
|
5
|
+
CreationOptional,
|
6
|
+
DataTypes,
|
7
|
+
fn,
|
8
|
+
} from "sequelize";
|
9
|
+
|
10
|
+
import sequelize from "./pb-sequelize";
|
11
|
+
import PhoneUser from "./phone-user";
|
12
|
+
|
13
|
+
// order of InferAttributes & InferCreationAttributes is important.
|
14
|
+
class ListMember extends Model<
|
15
|
+
InferAttributes<ListMember>,
|
16
|
+
InferCreationAttributes<ListMember>
|
17
|
+
> {
|
18
|
+
// 'CreationOptional' is a special type that marks the field as optional
|
19
|
+
// when creating an instance of the model (such as using Model.create()).
|
20
|
+
declare id: CreationOptional<string>;
|
21
|
+
declare userId: string;
|
22
|
+
declare fanListId: string;
|
23
|
+
declare createdAt: CreationOptional<Date>;
|
24
|
+
declare updatedAt: CreationOptional<Date>;
|
25
|
+
}
|
26
|
+
|
27
|
+
ListMember.init(
|
28
|
+
{
|
29
|
+
id: {
|
30
|
+
type: DataTypes.BIGINT,
|
31
|
+
primaryKey: true,
|
32
|
+
allowNull: false,
|
33
|
+
defaultValue: sequelize.fn("next_id"),
|
34
|
+
},
|
35
|
+
userId: {
|
36
|
+
type: DataTypes.BIGINT,
|
37
|
+
field: "user_id",
|
38
|
+
},
|
39
|
+
fanListId: {
|
40
|
+
type: DataTypes.BIGINT,
|
41
|
+
field: "fan_list_id",
|
42
|
+
},
|
43
|
+
createdAt: DataTypes.DATE,
|
44
|
+
updatedAt: DataTypes.DATE,
|
45
|
+
},
|
46
|
+
{ tableName: "list_members", sequelize }
|
47
|
+
);
|
48
|
+
|
49
|
+
/*
|
50
|
+
====================================================================
|
51
|
+
Class functions
|
52
|
+
====================================================================
|
53
|
+
*/
|
54
|
+
|
55
|
+
ListMember.hasOne(PhoneUser, {
|
56
|
+
foreignKey: "id",
|
57
|
+
sourceKey: "userId",
|
58
|
+
onDelete: "NO ACTION",
|
59
|
+
constraints: false,
|
60
|
+
});
|
61
|
+
PhoneUser.hasMany(ListMember, {
|
62
|
+
foreignKey: "userId",
|
63
|
+
onDelete: "NO ACTION",
|
64
|
+
constraints: false,
|
65
|
+
});
|
66
|
+
|
67
|
+
export default ListMember;
|