@winible/winible-typed 2.20.5 → 2.20.6

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 +1 @@
1
- {"version":3,"file":"notification.js","sourceRoot":"","sources":["../../typed-model/notification.ts"],"names":[],"mappings":";;;;;AAAA,yCAOmB;AAEnB,kEAAuC;AACvC,kEAAyC;AACzC,kDAA0B;AAe1B,mEAAmE;AACnE,MAAM,YAAa,SAAQ,iBAG1B;CAgBA;AAED,YAAY,CAAC,IAAI,CACf;IACE,EAAE,EAAE;QACF,IAAI,EAAE,qBAAS,CAAC,MAAM;QACtB,YAAY,EAAE,IAAA,cAAE,EAAC,SAAS,CAAC;QAC3B,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,IAAI;KACjB;IACD,WAAW,EAAE;QACX,IAAI,EAAE,qBAAS,CAAC,MAAM;QACtB,KAAK,EAAE,cAAc;QACrB,SAAS,EAAE,KAAK;KACjB;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,qBAAS,CAAC,MAAM;QACtB,KAAK,EAAE,WAAW;QAClB,SAAS,EAAE,KAAK;KACjB;IACD,MAAM,EAAE;QACN,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,qBAAS,CAAC,OAAO;QACvB,YAAY,EAAE,KAAK;KACpB;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM;QACb,IAAI,EAAE,qBAAS,CAAC,MAAM;KACvB;IACD,aAAa,EAAE;QACb,KAAK,EAAE,gBAAgB;QACvB,IAAI,EAAE,qBAAS,CAAC,MAAM;KACvB;IACD,eAAe,EAAE;QACf,KAAK,EAAE,mBAAmB;QAC1B,IAAI,EAAE,qBAAS,CAAC,MAAM;KACvB;IACD,UAAU,EAAE;QACV,KAAK,EAAE,cAAc;QACrB,IAAI,EAAE,qBAAS,CAAC,MAAM;KACvB;IACD,kBAAkB,EAAE;QAClB,KAAK,EAAE,sBAAsB;QAC7B,IAAI,EAAE,qBAAS,CAAC,MAAM;KACvB;IACD,2BAA2B,EAAE;QAC3B,KAAK,EAAE,gCAAgC;QACvC,IAAI,EAAE,qBAAS,CAAC,MAAM;KACvB;IACD,SAAS,EAAE,qBAAS,CAAC,IAAI;IACzB,SAAS,EAAE,qBAAS,CAAC,IAAI;IACzB,MAAM,EAAE;QACN,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,qBAAS,CAAC,MAAM;KACvB;CACF,EACD;IACE,SAAS,EAAE,eAAe;IAC1B,SAAS,EAAT,sBAAS;CACV,CACF,CAAC;AAEF;;;;EAIE;AAEF,YAAY,CAAC,MAAM,CAAC,cAAI,EAAE;IACxB,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,aAAa;IACxB,WAAW,EAAE,KAAK;CACnB,CAAC,CAAC;AAEH,YAAY,CAAC,MAAM,CAAC,sBAAW,EAAE;IAC/B,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,YAAY;IACvB,WAAW,EAAE,KAAK;CACnB,CAAC,CAAC;AAEH,kBAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"notification.js","sourceRoot":"","sources":["../../typed-model/notification.ts"],"names":[],"mappings":";;;;;AAAA,yCAOmB;AAEnB,kEAAuC;AACvC,kEAAyC;AACzC,kDAA0B;AAU1B,mEAAmE;AACnE,MAAM,YAAa,SAAQ,iBAG1B;CAgBA;AAED,YAAY,CAAC,IAAI,CACf;IACE,EAAE,EAAE;QACF,IAAI,EAAE,qBAAS,CAAC,MAAM;QACtB,YAAY,EAAE,IAAA,cAAE,EAAC,SAAS,CAAC;QAC3B,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,IAAI;KACjB;IACD,WAAW,EAAE;QACX,IAAI,EAAE,qBAAS,CAAC,MAAM;QACtB,KAAK,EAAE,cAAc;QACrB,SAAS,EAAE,KAAK;KACjB;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,qBAAS,CAAC,MAAM;QACtB,KAAK,EAAE,WAAW;QAClB,SAAS,EAAE,KAAK;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ible-typed",
3
- "version": "2.20.5",
3
+ "version": "2.20.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",
package/src/types.ts CHANGED
@@ -80,3 +80,8 @@ export enum SubscriptionPlanType {
80
80
  RECURRING = "RECURRING",
81
81
  FIXED = "FIXED",
82
82
  }
83
+
84
+ export enum ShouldRemoveSubscriberStatus {
85
+ TRUE = "TRUE",
86
+ FALSE = "FALSE",
87
+ }
@@ -0,0 +1,85 @@
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 TelegramIntegration from "./telegram-integration";
12
+
13
+ // order of InferAttributes & InferCreationAttributes is important.
14
+ class SubscriberTelegramIntegration extends Model<
15
+ InferAttributes<SubscriberTelegramIntegration>,
16
+ InferCreationAttributes<SubscriberTelegramIntegration>
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 userId: string;
21
+ declare telegramIntegrationId: string;
22
+ declare telegramUserId: string;
23
+
24
+ declare createdAt: CreationOptional<Date>;
25
+ declare updatedAt: CreationOptional<Date>;
26
+ }
27
+
28
+ SubscriberTelegramIntegration.init(
29
+ {
30
+ userId: {
31
+ type: DataTypes.BIGINT,
32
+ allowNull: false,
33
+ field: "user_id",
34
+ references: {
35
+ model: User,
36
+ },
37
+ },
38
+ telegramIntegrationId: {
39
+ type: DataTypes.BIGINT,
40
+ allowNull: false,
41
+ field: "telegram_integration_id",
42
+ references: {
43
+ model: TelegramIntegration,
44
+ },
45
+ },
46
+ telegramUserId: {
47
+ type: DataTypes.STRING,
48
+ allowNull: false,
49
+ field: "telegram_user_id",
50
+ },
51
+
52
+ createdAt: DataTypes.DATE,
53
+ updatedAt: DataTypes.DATE,
54
+ },
55
+ {
56
+ tableName: "subscriber_telegram_integrations",
57
+ sequelize,
58
+ }
59
+ );
60
+
61
+ TelegramIntegration.hasMany(SubscriberTelegramIntegration, {
62
+ foreignKey: "telegramIntegrationId",
63
+ sourceKey: "id",
64
+ onDelete: "NO ACTION",
65
+ constraints: false,
66
+ });
67
+
68
+ SubscriberTelegramIntegration.hasOne(TelegramIntegration, {
69
+ foreignKey: "id",
70
+ sourceKey: "telegramIntegrationId",
71
+ });
72
+
73
+ User.hasMany(SubscriberTelegramIntegration, {
74
+ foreignKey: "userId",
75
+ sourceKey: "id",
76
+ onDelete: "NO ACTION",
77
+ constraints: false,
78
+ });
79
+
80
+ SubscriberTelegramIntegration.hasOne(User, {
81
+ foreignKey: "id",
82
+ sourceKey: "userId",
83
+ });
84
+
85
+ export default SubscriberTelegramIntegration;
@@ -0,0 +1,118 @@
1
+ import {
2
+ Model,
3
+ InferAttributes,
4
+ InferCreationAttributes,
5
+ CreationOptional,
6
+ DataTypes,
7
+ } from "sequelize";
8
+
9
+ import sequelize from "./pb-sequelize";
10
+ import SubscriptionPlan from "./subscription-plan";
11
+ import FreeSubscriptionPlan from "./free-subscription-plan";
12
+ import { ShouldRemoveSubscriberStatus } from "../src/types";
13
+
14
+ // order of InferAttributes & InferCreationAttributes is important.
15
+ class TelegramIntegration extends Model<
16
+ InferAttributes<TelegramIntegration>,
17
+ InferCreationAttributes<TelegramIntegration>
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 planId: string;
23
+ declare freePlanId: string;
24
+ declare chatId: string;
25
+ declare chatTitle: string;
26
+ declare metadata: string;
27
+ declare archived: boolean;
28
+ declare shouldRemoveSubscriber: ShouldRemoveSubscriberStatus;
29
+
30
+ declare createdAt: CreationOptional<Date>;
31
+ declare updatedAt: CreationOptional<Date>;
32
+ }
33
+
34
+ TelegramIntegration.init(
35
+ {
36
+ id: {
37
+ type: DataTypes.BIGINT,
38
+ primaryKey: true,
39
+ allowNull: false,
40
+ defaultValue: sequelize.fn("next_id"),
41
+ },
42
+ planId: {
43
+ type: DataTypes.BIGINT,
44
+ allowNull: true,
45
+ field: "plan_id",
46
+ references: {
47
+ model: SubscriptionPlan,
48
+ },
49
+ },
50
+ freePlanId: {
51
+ type: DataTypes.BIGINT,
52
+ allowNull: true,
53
+ field: "free_plan_id",
54
+ references: {
55
+ model: FreeSubscriptionPlan,
56
+ },
57
+ },
58
+ chatId: {
59
+ type: DataTypes.STRING,
60
+ allowNull: true,
61
+ field: "chat_id",
62
+ },
63
+ chatTitle: {
64
+ type: DataTypes.STRING,
65
+ allowNull: true,
66
+ field: "chat_title",
67
+ },
68
+ metadata: {
69
+ type: DataTypes.JSON,
70
+ allowNull: true,
71
+ field: "metadata",
72
+ },
73
+ archived: {
74
+ type: DataTypes.BOOLEAN,
75
+ allowNull: false,
76
+ defaultValue: false,
77
+ field: "archived",
78
+ },
79
+ shouldRemoveSubscriber: {
80
+ type: DataTypes.ENUM(...Object.values(ShouldRemoveSubscriberStatus)),
81
+ allowNull: false,
82
+ defaultValue: ShouldRemoveSubscriberStatus.TRUE,
83
+ field: "should_remove_subscriber",
84
+ },
85
+ createdAt: DataTypes.DATE,
86
+ updatedAt: DataTypes.DATE,
87
+ },
88
+ {
89
+ tableName: "telegram_integrations",
90
+ sequelize,
91
+ }
92
+ );
93
+
94
+ SubscriptionPlan.hasMany(TelegramIntegration, {
95
+ foreignKey: "planId",
96
+ sourceKey: "id",
97
+ onDelete: "NO ACTION",
98
+ constraints: false,
99
+ });
100
+
101
+ TelegramIntegration.hasOne(SubscriptionPlan, {
102
+ foreignKey: "id",
103
+ sourceKey: "planId",
104
+ });
105
+
106
+ FreeSubscriptionPlan.hasMany(TelegramIntegration, {
107
+ foreignKey: "freePlanId",
108
+ sourceKey: "id",
109
+ onDelete: "NO ACTION",
110
+ constraints: false,
111
+ });
112
+
113
+ TelegramIntegration.hasOne(FreeSubscriptionPlan, {
114
+ foreignKey: "id",
115
+ sourceKey: "freePlanId",
116
+ });
117
+
118
+ export default TelegramIntegration;