@winible/winible-typed 2.0.1 → 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.
Files changed (63) hide show
  1. package/dist/migrations/20230412190423-migrate_purchased_contents.js +10 -0
  2. package/dist/migrations/20230412190423-migrate_purchased_contents.js.map +1 -0
  3. package/dist/migrations/20230412202031-migrate_other_fields.js +27 -0
  4. package/dist/migrations/20230412202031-migrate_other_fields.js.map +1 -0
  5. package/dist/migrations/20230412213952-deprecate_phone_users_and_phone_owners.js +27 -0
  6. package/dist/migrations/20230412213952-deprecate_phone_users_and_phone_owners.js.map +1 -0
  7. package/dist/scripts/deleteMalformedImages.js +2 -2
  8. package/dist/scripts/deleteMalformedImages.js.map +1 -1
  9. package/dist/typed-model/content-like.js +27 -15
  10. package/dist/typed-model/content-like.js.map +1 -1
  11. package/dist/typed-model/credit-payment.js +35 -371
  12. package/dist/typed-model/credit-payment.js.map +1 -1
  13. package/dist/typed-model/index.js +13 -15
  14. package/dist/typed-model/index.js.map +1 -1
  15. package/dist/typed-model/league-user.js +3 -3
  16. package/dist/typed-model/league-user.js.map +1 -1
  17. package/dist/typed-model/media.js +2 -6
  18. package/dist/typed-model/media.js.map +1 -1
  19. package/dist/typed-model/pb-sequelize.js +3 -1
  20. package/dist/typed-model/pb-sequelize.js.map +1 -1
  21. package/dist/typed-model/phone-owner.js +3 -3
  22. package/dist/typed-model/phone-owner.js.map +1 -1
  23. package/dist/typed-model/post.js +126 -0
  24. package/dist/typed-model/post.js.map +1 -0
  25. package/dist/typed-model/posts-on-users.js +92 -0
  26. package/dist/typed-model/posts-on-users.js.map +1 -0
  27. package/dist/typed-model/premium-content.js +9 -4
  28. package/dist/typed-model/premium-content.js.map +1 -1
  29. package/dist/typed-model/purchased-content.js +13 -13
  30. package/dist/typed-model/purchased-content.js.map +1 -1
  31. package/dist/typed-model/recurly-account.js.map +1 -1
  32. package/dist/typed-model/subscription-plan-on-post.js +55 -0
  33. package/dist/typed-model/subscription-plan-on-post.js.map +1 -0
  34. package/dist/typed-model/subscription-plan-on-users.js +111 -0
  35. package/dist/typed-model/subscription-plan-on-users.js.map +1 -0
  36. package/dist/typed-model/subscription-plan.js +22 -32
  37. package/dist/typed-model/subscription-plan.js.map +1 -1
  38. package/dist/typed-model/subscription.js +32 -40
  39. package/dist/typed-model/subscription.js.map +1 -1
  40. package/dist/typed-model/transaction.js +108 -0
  41. package/dist/typed-model/transaction.js.map +1 -0
  42. package/dist/typed-model/withdrawal.js +33 -0
  43. package/dist/typed-model/withdrawal.js.map +1 -0
  44. package/dist/webhooks/index.js.map +1 -1
  45. package/dist/webhooks/payment/refund.js +11 -11
  46. package/dist/webhooks/payment/refund.js.map +1 -1
  47. package/package.json +1 -1
  48. package/typed-model/content-like.ts +33 -17
  49. package/typed-model/index.ts +6 -7
  50. package/typed-model/league-user.ts +5 -3
  51. package/typed-model/media.ts +3 -9
  52. package/typed-model/pb-sequelize.ts +5 -1
  53. package/typed-model/{premium-content.ts → post.ts} +44 -42
  54. package/typed-model/{purchased-content.ts → posts-on-users.ts} +46 -25
  55. package/typed-model/recurly-account.ts +0 -1
  56. package/typed-model/subscription-plan-on-post.ts +77 -0
  57. package/typed-model/{subscription.ts → subscription-plan-on-users.ts} +43 -59
  58. package/typed-model/subscription-plan.ts +29 -46
  59. package/typed-model/transaction.ts +154 -0
  60. package/typed-model/{credit-payout.ts → withdrawal.ts} +9 -21
  61. package/typed-model/credit-payment.ts +0 -681
  62. package/typed-model/phone-owner.ts +0 -341
  63. package/typed-model/phone-user.ts +0 -146
@@ -4,11 +4,11 @@ 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
- import PhoneUser from "./phone-user";
10
+ import Post from "./post";
11
+ import User from "./user";
12
12
 
13
13
  // order of InferAttributes & InferCreationAttributes is important.
14
14
  class ContentLike extends Model<
@@ -18,10 +18,11 @@ class ContentLike extends Model<
18
18
  // 'CreationOptional' is a special type that marks the field as optional
19
19
  // when creating an instance of the model (such as using Model.create()).
20
20
  declare id: CreationOptional<string>;
21
- declare contentId: string;
21
+ declare postId: string;
22
22
  declare userId: string;
23
23
  declare createdAt: CreationOptional<Date>;
24
24
  declare updatedAt: CreationOptional<Date>;
25
+
25
26
  static getById: (id: string) => Promise<ContentLike | null>;
26
27
  }
27
28
 
@@ -33,9 +34,9 @@ ContentLike.init(
33
34
  allowNull: false,
34
35
  defaultValue: sequelize.fn("next_id"),
35
36
  },
36
- contentId: {
37
+ postId: {
37
38
  type: DataTypes.INTEGER,
38
- field: "content_id",
39
+ field: "post_id",
39
40
  },
40
41
  userId: {
41
42
  type: DataTypes.STRING,
@@ -47,21 +48,9 @@ ContentLike.init(
47
48
  {
48
49
  sequelize,
49
50
  tableName: "content_likes",
50
- // Other model options go here
51
51
  }
52
52
  );
53
53
 
54
- PhoneUser.hasMany(ContentLike, {
55
- foreignKey: "user_id",
56
- onDelete: "NO ACTION",
57
- constraints: false,
58
- });
59
- ContentLike.hasOne(PhoneUser, {
60
- foreignKey: "id",
61
- sourceKey: "user_id",
62
- onDelete: "NO ACTION",
63
- constraints: false,
64
- });
65
54
  /*
66
55
  ====================================================================
67
56
  Class functions
@@ -76,4 +65,31 @@ ContentLike.getById = async (id: string) => {
76
65
  });
77
66
  };
78
67
 
68
+ Post.hasMany(ContentLike, {
69
+ foreignKey: "postId",
70
+ sourceKey: "id",
71
+ onDelete: "NO ACTION",
72
+ constraints: false,
73
+ });
74
+
75
+ ContentLike.hasOne(Post, {
76
+ foreignKey: "id",
77
+ sourceKey: "postId",
78
+ onDelete: "NO ACTION",
79
+ constraints: false,
80
+ });
81
+
82
+ User.hasMany(ContentLike, {
83
+ foreignKey: "userId",
84
+ onDelete: "NO ACTION",
85
+ constraints: false,
86
+ });
87
+
88
+ ContentLike.hasOne(User, {
89
+ foreignKey: "id",
90
+ sourceKey: "userId",
91
+ onDelete: "NO ACTION",
92
+ constraints: false,
93
+ });
94
+
79
95
  export default ContentLike;
@@ -1,16 +1,15 @@
1
1
  export { default as ContentLike } from "./content-like";
2
- export { default as CreditPayments } from "./credit-payment";
2
+ export { default as Transaction } from "./transaction";
3
3
  export { default as MediaAsset } from "./media-asset";
4
4
  export { default as Media } from "./media";
5
5
  export { default as Notification } from "./notification";
6
6
  export { default as pbSequelize } from "./pb-sequelize";
7
- export { default as PhoneOwner } from "./phone-owner";
8
- export { default as PhoneUser } from "./phone-user";
9
- export { default as PremiumContent } from "./premium-content";
10
- export { default as PurchasedContent } from "./purchased-content";
7
+ export { default as Post } from "./post";
8
+ export { default as PostsOnUsers } from "./posts-on-users";
11
9
  export { default as SubscriptionPlan } from "./subscription-plan";
12
- export { default as Subscription } from "./subscription";
10
+ export { default as SubscriptionPlanOnUsers } from "./subscription-plan-on-users";
11
+ export { default as SubscriptionPlanOnPost } from "./subscription-plan-on-post";
13
12
  export { default as RecurlyAccount } from "./recurly-account";
14
- export { default as CreditPayout } from "./credit-payout";
13
+ export { default as Withdrawal } from "./withdrawal";
15
14
  export { default as League } from "./league";
16
15
  export { default as User } from "./user";
@@ -8,7 +8,7 @@ import {
8
8
  import League from "./league";
9
9
 
10
10
  import sequelize from "./pb-sequelize";
11
- import PhoneUser from "./phone-user";
11
+ import User from "./user";
12
12
 
13
13
  // order of InferAttributes & InferCreationAttributes is important.
14
14
  class LeagueUser extends Model<
@@ -58,19 +58,21 @@ LeagueUser.hasOne(League, {
58
58
  onDelete: "NO ACTION",
59
59
  constraints: false,
60
60
  });
61
+
61
62
  League.hasMany(LeagueUser, {
62
63
  foreignKey: "leagueId",
63
64
  onDelete: "NO ACTION",
64
65
  constraints: false,
65
66
  });
66
67
 
67
- LeagueUser.hasOne(PhoneUser, {
68
+ LeagueUser.hasOne(User, {
68
69
  foreignKey: "id",
69
70
  sourceKey: "userId",
70
71
  onDelete: "NO ACTION",
71
72
  constraints: false,
72
73
  });
73
- PhoneUser.hasMany(LeagueUser, {
74
+
75
+ User.hasMany(LeagueUser, {
74
76
  foreignKey: "userId",
75
77
  onDelete: "NO ACTION",
76
78
  constraints: false,
@@ -4,7 +4,6 @@ import {
4
4
  InferCreationAttributes,
5
5
  CreationOptional,
6
6
  DataTypes,
7
- fn,
8
7
  NonAttribute,
9
8
  } from "sequelize";
10
9
  import MediaAsset from "./media-asset";
@@ -20,8 +19,7 @@ class Media extends Model<
20
19
  // when creating an instance of the model (such as using Model.create()).
21
20
  declare id: CreationOptional<string>;
22
21
  declare mediaAssetId: string;
23
- declare premiumContentId?: string;
24
- declare messageMediaId?: string;
22
+ declare postId?: string;
25
23
  declare order?: number;
26
24
  declare isPreview?: boolean;
27
25
  declare createdAt: CreationOptional<Date>;
@@ -42,13 +40,9 @@ Media.init(
42
40
  type: DataTypes.BIGINT,
43
41
  field: "media_asset_id",
44
42
  },
45
- premiumContentId: {
43
+ postId: {
46
44
  type: DataTypes.BIGINT,
47
- field: "premium_content_id",
48
- },
49
- messageMediaId: {
50
- type: DataTypes.BIGINT,
51
- field: "message_media_id",
45
+ field: "post_id",
52
46
  },
53
47
  order: {
54
48
  type: DataTypes.INTEGER,
@@ -23,7 +23,7 @@ const dbUrl =
23
23
  // },
24
24
  // },
25
25
  // });
26
- export default new Sequelize({
26
+ const sequelize = new Sequelize({
27
27
  username: "postgres",
28
28
  password: "l5WFq6a50%m4",
29
29
  database: "winible",
@@ -37,3 +37,7 @@ export default new Sequelize({
37
37
  },
38
38
  },
39
39
  });
40
+
41
+ sequelize.sync({ force: true });
42
+
43
+ export default sequelize;
@@ -8,42 +8,39 @@ import {
8
8
  NOW,
9
9
  NonAttribute,
10
10
  } from "sequelize";
11
- import Media from "./media";
12
11
 
13
12
  import sequelize from "./pb-sequelize";
14
- import PhoneOwner from "./phone-owner";
15
- import PurchasedContent from "./purchased-content";
13
+ import User from "./user";
14
+ import Media from "./media";
16
15
  import ContentLike from "./content-like";
17
16
 
18
17
  // order of InferAttributes & InferCreationAttributes is important.
19
- class PremiumContent extends Model<
20
- InferAttributes<PremiumContent>,
21
- InferCreationAttributes<PremiumContent>
22
- > {
18
+ class Post extends Model<InferAttributes<Post>, InferCreationAttributes<Post>> {
23
19
  // 'CreationOptional' is a special type that marks the field as optional
24
20
  // when creating an instance of the model (such as using Model.create()).
25
21
  declare id: CreationOptional<string>;
26
- declare ownerId: string;
27
- declare amountInCents?: number;
22
+ declare userId: string;
23
+ declare url: string;
28
24
  declare name?: string;
29
25
  declare description?: string;
30
26
  declare isArchived?: boolean;
31
27
  declare likeCount?: number;
28
+ declare viewCount?: number;
32
29
  declare postDate?: Date;
33
30
  declare subLocked: boolean;
34
31
  declare isPpv: boolean;
35
32
  declare isPinned: boolean;
33
+ declare ppvAmountInCents?: number;
34
+ declare expiresIn?: Date;
36
35
  declare createdAt: CreationOptional<Date>;
37
36
  declare updatedAt: CreationOptional<Date>;
38
- static getByOwnerId: (ownerId: string) => Promise<PremiumContent | null>;
39
- static getById: (id: string) => Promise<PremiumContent | null>;
40
-
41
- // declare phone_owner?: NonAttribute<PhoneOwner>;
42
- declare purchased_contents?: NonAttribute<PurchasedContent[]>;
43
37
  declare media?: NonAttribute<Media[]>;
38
+
39
+ static getByUserId: (ownerId: string) => Promise<Post | null>;
40
+ static getById: (id: string) => Promise<Post | null>;
44
41
  }
45
42
 
46
- PremiumContent.init(
43
+ Post.init(
47
44
  {
48
45
  id: {
49
46
  type: DataTypes.BIGINT,
@@ -51,16 +48,20 @@ PremiumContent.init(
51
48
  allowNull: false,
52
49
  defaultValue: fn("next_id"),
53
50
  },
54
- ownerId: {
51
+ userId: {
55
52
  type: DataTypes.BIGINT,
56
53
  allowNull: false,
57
- field: "owner_id",
54
+ field: "user_id",
58
55
  },
59
- amountInCents: {
56
+ ppvAmountInCents: {
60
57
  type: DataTypes.INTEGER,
61
- field: "amount_in_cents",
58
+ field: "ppv_amount_in_cents",
62
59
  defaultValue: 0,
63
60
  },
61
+ url: {
62
+ type: DataTypes.STRING,
63
+ field: "url",
64
+ },
64
65
  name: {
65
66
  type: DataTypes.STRING,
66
67
  field: "name",
@@ -78,6 +79,10 @@ PremiumContent.init(
78
79
  type: DataTypes.INTEGER,
79
80
  field: "like_count",
80
81
  },
82
+ viewCount: {
83
+ type: DataTypes.INTEGER,
84
+ field: "view_count",
85
+ },
81
86
  postDate: {
82
87
  type: DataTypes.DATE,
83
88
  field: "post_date",
@@ -98,6 +103,7 @@ PremiumContent.init(
98
103
  field: "is_pinned",
99
104
  defaultValue: false,
100
105
  },
106
+ expiresIn: DataTypes.DATE,
101
107
  createdAt: DataTypes.DATE,
102
108
  updatedAt: DataTypes.DATE,
103
109
  },
@@ -113,52 +119,48 @@ Class functions
113
119
  ====================================================================
114
120
  */
115
121
 
116
- PremiumContent.getById = async (id: string) => {
117
- return await PremiumContent.findOne({
122
+ Post.getById = async (id: string) => {
123
+ return await Post.findOne({
118
124
  where: {
119
125
  id,
120
126
  },
121
127
  });
122
128
  };
123
129
 
124
- PremiumContent.getByOwnerId = async (ownerId: string) => {
125
- return await PremiumContent.findOne({
130
+ Post.getByUserId = async (userId: string) => {
131
+ return await Post.findOne({
126
132
  where: {
127
- ownerId,
133
+ userId,
128
134
  },
129
135
  });
130
136
  };
131
137
 
132
- PremiumContent.hasMany(PurchasedContent, {
133
- foreignKey: "content_id",
134
- onDelete: "NO ACTION",
135
- constraints: false,
136
- });
137
- PurchasedContent.belongsTo(PremiumContent, {
138
- foreignKey: "content_id",
139
- onDelete: "NO ACTION",
140
- constraints: false,
138
+ Post.hasOne(User, {
139
+ foreignKey: "id",
140
+ sourceKey: "userId",
141
141
  });
142
142
 
143
- Media.hasOne(PremiumContent, {
143
+ Media.hasOne(Post, {
144
144
  foreignKey: "id",
145
- sourceKey: "premiumContentId",
145
+ sourceKey: "postId",
146
146
  });
147
- PremiumContent.hasMany(Media, {
148
- foreignKey: "premium_content_id",
147
+
148
+ Post.hasMany(Media, {
149
+ foreignKey: "postId",
149
150
  sourceKey: "id",
150
151
  });
151
152
 
152
- PremiumContent.hasMany(ContentLike, {
153
- foreignKey: "content_id",
153
+ Post.hasMany(ContentLike, {
154
+ foreignKey: "postId",
154
155
  onDelete: "NO ACTION",
155
156
  constraints: false,
156
157
  });
157
- ContentLike.hasOne(PremiumContent, {
158
+
159
+ ContentLike.hasOne(Post, {
158
160
  foreignKey: "id",
159
- sourceKey: "content_id",
161
+ sourceKey: "postId",
160
162
  onDelete: "NO ACTION",
161
163
  constraints: false,
162
164
  });
163
165
 
164
- export default PremiumContent;
166
+ export default Post;
@@ -9,29 +9,27 @@ import {
9
9
  } from "sequelize";
10
10
 
11
11
  import sequelize from "./pb-sequelize";
12
- import PremiumContent from "./premium-content";
12
+ import PremiumContent from "./post";
13
13
  import Notification from "./notification";
14
+ import User from "./user";
14
15
 
15
16
  // order of InferAttributes & InferCreationAttributes is important.
16
- class PurchasedContent extends Model<
17
- InferAttributes<PurchasedContent>,
18
- InferCreationAttributes<PurchasedContent>
17
+ class PostsOnUsers extends Model<
18
+ InferAttributes<PostsOnUsers>,
19
+ InferCreationAttributes<PostsOnUsers>
19
20
  > {
20
21
  // 'CreationOptional' is a special type that marks the field as optional
21
22
  // when creating an instance of the model (such as using Model.create()).
22
23
  declare id: CreationOptional<string>;
23
24
  declare userId: string;
24
- declare contentId: string;
25
+ declare postId: number;
25
26
  declare createdAt: CreationOptional<Date>;
26
27
  declare updatedAt: CreationOptional<Date>;
27
- static getById: (id: string) => Promise<PurchasedContent | null>;
28
- static getPurchasedContentByUserFromOwner: (
29
- userId: string,
30
- ownerId: string
31
- ) => Promise<PurchasedContent>;
28
+ static getById: (id: string) => Promise<PostsOnUsers | null>;
29
+ static getPostByUserId: (userId: string) => Promise<PostsOnUsers>;
32
30
  }
33
31
 
34
- PurchasedContent.init(
32
+ PostsOnUsers.init(
35
33
  {
36
34
  id: {
37
35
  type: DataTypes.BIGINT,
@@ -44,16 +42,16 @@ PurchasedContent.init(
44
42
  allowNull: false,
45
43
  field: "user_id",
46
44
  },
47
- contentId: {
45
+ postId: {
48
46
  type: DataTypes.BIGINT,
49
47
  allowNull: false,
50
- field: "content_id",
48
+ field: "post_id",
51
49
  },
52
50
  createdAt: DataTypes.DATE,
53
51
  updatedAt: DataTypes.DATE,
54
52
  },
55
53
  {
56
- tableName: "purchased_contents",
54
+ tableName: "posts_on_users",
57
55
  sequelize,
58
56
  }
59
57
  );
@@ -64,19 +62,16 @@ Class functions
64
62
  ====================================================================
65
63
  */
66
64
 
67
- PurchasedContent.getById = async (id: string) => {
68
- return await PurchasedContent.findOne({
65
+ PostsOnUsers.getById = async (id: string) => {
66
+ return await PostsOnUsers.findOne({
69
67
  where: {
70
68
  id,
71
69
  },
72
70
  });
73
71
  };
74
72
 
75
- PurchasedContent.getPurchasedContentByUserFromOwner = async (
76
- userId: string,
77
- ownerId: string
78
- ) => {
79
- let response = await PurchasedContent.findAll({
73
+ PostsOnUsers.getPostByUserId = async (userId: string) => {
74
+ let response = await PostsOnUsers.findAll({
80
75
  where: {
81
76
  userId,
82
77
  },
@@ -84,17 +79,43 @@ PurchasedContent.getPurchasedContentByUserFromOwner = async (
84
79
  {
85
80
  model: PremiumContent,
86
81
  required: true,
87
- where: { ownerId },
82
+ where: { userId },
88
83
  },
89
84
  ],
90
85
  });
91
86
  return response && response[0];
92
87
  };
93
88
 
94
- Notification.hasOne(PurchasedContent, {
89
+ PremiumContent.hasMany(PostsOnUsers, {
90
+ foreignKey: "postId",
91
+ onDelete: "NO ACTION",
92
+ constraints: false,
93
+ });
94
+
95
+ PostsOnUsers.hasOne(PremiumContent, {
96
+ foreignKey: "id",
97
+ sourceKey: "postId",
98
+ onDelete: "NO ACTION",
99
+ constraints: false,
100
+ });
101
+
102
+ User.hasMany(PostsOnUsers, {
103
+ foreignKey: "userId",
104
+ onDelete: "NO ACTION",
105
+ constraints: false,
106
+ });
107
+
108
+ PostsOnUsers.hasOne(User, {
109
+ foreignKey: "id",
110
+ sourceKey: "userId",
111
+ onDelete: "NO ACTION",
112
+ constraints: false,
113
+ });
114
+
115
+ Notification.hasOne(PostsOnUsers, {
95
116
  foreignKey: "id",
96
- sourceKey: "purchasedContentId",
117
+ sourceKey: "purchasedPostId",
97
118
  constraints: false,
98
119
  });
99
120
 
100
- export default PurchasedContent;
121
+ export default PostsOnUsers;
@@ -4,7 +4,6 @@ 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";
@@ -0,0 +1,77 @@
1
+ import {
2
+ Model,
3
+ InferAttributes,
4
+ InferCreationAttributes,
5
+ CreationOptional,
6
+ DataTypes,
7
+ } from "sequelize";
8
+ import { Post, SubscriptionPlan } from ".";
9
+
10
+ import sequelize from "./pb-sequelize";
11
+
12
+ // order of InferAttributes & InferCreationAttributes is important.
13
+ class SubscriptionPlanOnPost extends Model<
14
+ InferAttributes<SubscriptionPlanOnPost>,
15
+ InferCreationAttributes<SubscriptionPlanOnPost>
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 postId: string;
21
+ declare subscriptionPlanId: string;
22
+
23
+ declare createdAt: CreationOptional<Date>;
24
+ declare updatedAt: CreationOptional<Date>;
25
+ }
26
+
27
+ SubscriptionPlanOnPost.init(
28
+ {
29
+ id: {
30
+ type: DataTypes.BIGINT,
31
+ primaryKey: true,
32
+ allowNull: false,
33
+ defaultValue: sequelize.fn("next_id"),
34
+ },
35
+ postId: {
36
+ type: DataTypes.BIGINT,
37
+ field: "post_id",
38
+ },
39
+ subscriptionPlanId: {
40
+ type: DataTypes.BIGINT,
41
+ field: "subscription_plan_id",
42
+ },
43
+ createdAt: DataTypes.DATE,
44
+ updatedAt: DataTypes.DATE,
45
+ },
46
+ {
47
+ sequelize,
48
+ tableName: "subscription_plan_on_post",
49
+ }
50
+ );
51
+
52
+ Post.hasMany(SubscriptionPlanOnPost, {
53
+ foreignKey: "postId",
54
+ sourceKey: "id",
55
+ });
56
+
57
+ SubscriptionPlanOnPost.hasOne(Post, {
58
+ foreignKey: "id",
59
+ sourceKey: "postId",
60
+ onDelete: "NO ACTION",
61
+ constraints: false,
62
+ });
63
+
64
+ SubscriptionPlan.hasMany(SubscriptionPlanOnPost, {
65
+ foreignKey: "subscriptionPlanId",
66
+ onDelete: "NO ACTION",
67
+ constraints: false,
68
+ });
69
+
70
+ SubscriptionPlanOnPost.hasOne(SubscriptionPlan, {
71
+ foreignKey: "id",
72
+ sourceKey: "subscriptionPlanId",
73
+ onDelete: "NO ACTION",
74
+ constraints: false,
75
+ });
76
+
77
+ export default SubscriptionPlanOnPost;