@winible/winible-typed 2.90.1 → 2.91.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/package.json +1 -1
- package/typed-model/banner-creative.ts +200 -0
- package/typed-model/index.ts +1 -0
package/package.json
CHANGED
@@ -0,0 +1,200 @@
|
|
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 AffiliateLinks from "./affiliate-link";
|
12
|
+
|
13
|
+
type MediaType = "image" | "video";
|
14
|
+
type BannerStatus = "draft" | "approved" | "paused" | "expired";
|
15
|
+
|
16
|
+
// order of InferAttributes & InferCreationAttributes is important.
|
17
|
+
class BannerCreative extends Model<
|
18
|
+
InferAttributes<BannerCreative>,
|
19
|
+
InferCreationAttributes<BannerCreative>
|
20
|
+
> {
|
21
|
+
// 'CreationOptional' is a special type that marks the field as optional
|
22
|
+
// when creating an instance of the model (such as using Model.create()).
|
23
|
+
declare id: CreationOptional<string>;
|
24
|
+
declare affiliateLinkId: string;
|
25
|
+
declare mediaType: MediaType;
|
26
|
+
declare assetUrls: string[]; // JSONB array field
|
27
|
+
declare videoUrl?: string;
|
28
|
+
declare videoNaturalMs?: number;
|
29
|
+
declare imageDurationMs?: number;
|
30
|
+
declare headline?: string;
|
31
|
+
declare ctaText?: string;
|
32
|
+
declare clickUrl?: string;
|
33
|
+
declare ctaBackgroundCss?: string;
|
34
|
+
declare altText?: string;
|
35
|
+
declare locale?: string;
|
36
|
+
declare status: BannerStatus;
|
37
|
+
declare startAt: Date;
|
38
|
+
declare endAt: Date;
|
39
|
+
declare version: number;
|
40
|
+
declare createdBy: string;
|
41
|
+
declare createdAt: CreationOptional<Date>;
|
42
|
+
declare updatedAt: CreationOptional<Date>;
|
43
|
+
declare notes?: string;
|
44
|
+
|
45
|
+
static getById: (id: string) => Promise<BannerCreative | null>;
|
46
|
+
}
|
47
|
+
|
48
|
+
BannerCreative.init(
|
49
|
+
{
|
50
|
+
id: {
|
51
|
+
type: DataTypes.BIGINT,
|
52
|
+
primaryKey: true,
|
53
|
+
allowNull: false,
|
54
|
+
defaultValue: sequelize.fn("next_id"),
|
55
|
+
},
|
56
|
+
affiliateLinkId: {
|
57
|
+
type: DataTypes.BIGINT,
|
58
|
+
allowNull: false,
|
59
|
+
references: {
|
60
|
+
model: AffiliateLinks,
|
61
|
+
key: "id",
|
62
|
+
},
|
63
|
+
field: "affiliate_link_id",
|
64
|
+
},
|
65
|
+
mediaType: {
|
66
|
+
type: DataTypes.ENUM("image", "video"),
|
67
|
+
allowNull: false,
|
68
|
+
field: "media_type",
|
69
|
+
},
|
70
|
+
assetUrls: {
|
71
|
+
type: DataTypes.JSONB,
|
72
|
+
allowNull: false,
|
73
|
+
field: "asset_urls",
|
74
|
+
},
|
75
|
+
videoUrl: {
|
76
|
+
type: DataTypes.TEXT,
|
77
|
+
allowNull: true,
|
78
|
+
field: "video_url",
|
79
|
+
},
|
80
|
+
videoNaturalMs: {
|
81
|
+
type: DataTypes.INTEGER,
|
82
|
+
allowNull: true,
|
83
|
+
field: "video_natural_ms",
|
84
|
+
},
|
85
|
+
imageDurationMs: {
|
86
|
+
type: DataTypes.INTEGER,
|
87
|
+
allowNull: true,
|
88
|
+
field: "image_duration_ms",
|
89
|
+
},
|
90
|
+
headline: {
|
91
|
+
type: DataTypes.TEXT,
|
92
|
+
allowNull: true,
|
93
|
+
field: "headline",
|
94
|
+
},
|
95
|
+
ctaText: {
|
96
|
+
type: DataTypes.TEXT,
|
97
|
+
allowNull: true,
|
98
|
+
field: "cta_text",
|
99
|
+
},
|
100
|
+
clickUrl: {
|
101
|
+
type: DataTypes.TEXT,
|
102
|
+
allowNull: true,
|
103
|
+
field: "click_url",
|
104
|
+
},
|
105
|
+
ctaBackgroundCss: {
|
106
|
+
type: DataTypes.TEXT,
|
107
|
+
allowNull: true,
|
108
|
+
field: "cta_background_css",
|
109
|
+
},
|
110
|
+
altText: {
|
111
|
+
type: DataTypes.TEXT,
|
112
|
+
allowNull: true,
|
113
|
+
field: "alt_text",
|
114
|
+
},
|
115
|
+
locale: {
|
116
|
+
type: DataTypes.TEXT,
|
117
|
+
allowNull: true,
|
118
|
+
field: "locale",
|
119
|
+
},
|
120
|
+
status: {
|
121
|
+
type: DataTypes.ENUM("draft", "approved", "paused", "expired"),
|
122
|
+
allowNull: false,
|
123
|
+
field: "status",
|
124
|
+
},
|
125
|
+
startAt: {
|
126
|
+
type: DataTypes.DATE,
|
127
|
+
allowNull: false,
|
128
|
+
field: "start_at",
|
129
|
+
},
|
130
|
+
endAt: {
|
131
|
+
type: DataTypes.DATE,
|
132
|
+
allowNull: false,
|
133
|
+
field: "end_at",
|
134
|
+
},
|
135
|
+
version: {
|
136
|
+
type: DataTypes.INTEGER,
|
137
|
+
allowNull: false,
|
138
|
+
defaultValue: 1,
|
139
|
+
field: "version",
|
140
|
+
},
|
141
|
+
createdBy: {
|
142
|
+
type: DataTypes.BIGINT,
|
143
|
+
allowNull: false,
|
144
|
+
references: {
|
145
|
+
model: User,
|
146
|
+
key: "id",
|
147
|
+
},
|
148
|
+
field: "created_by",
|
149
|
+
},
|
150
|
+
createdAt: DataTypes.DATE,
|
151
|
+
updatedAt: DataTypes.DATE,
|
152
|
+
notes: {
|
153
|
+
type: DataTypes.TEXT,
|
154
|
+
allowNull: true,
|
155
|
+
field: "notes",
|
156
|
+
},
|
157
|
+
},
|
158
|
+
{
|
159
|
+
tableName: "banner_creatives",
|
160
|
+
sequelize,
|
161
|
+
}
|
162
|
+
);
|
163
|
+
|
164
|
+
/*
|
165
|
+
====================================================================
|
166
|
+
Class functions
|
167
|
+
====================================================================
|
168
|
+
*/
|
169
|
+
|
170
|
+
BannerCreative.getById = async (id: string) => {
|
171
|
+
return await BannerCreative.findOne({
|
172
|
+
where: {
|
173
|
+
id,
|
174
|
+
},
|
175
|
+
});
|
176
|
+
};
|
177
|
+
|
178
|
+
// Relationships
|
179
|
+
AffiliateLinks.hasMany(BannerCreative, {
|
180
|
+
foreignKey: "affiliateLinkId",
|
181
|
+
onDelete: "NO ACTION",
|
182
|
+
constraints: false,
|
183
|
+
});
|
184
|
+
|
185
|
+
BannerCreative.belongsTo(AffiliateLinks, {
|
186
|
+
foreignKey: "affiliateLinkId",
|
187
|
+
});
|
188
|
+
|
189
|
+
User.hasMany(BannerCreative, {
|
190
|
+
foreignKey: "createdBy",
|
191
|
+
onDelete: "NO ACTION",
|
192
|
+
constraints: false,
|
193
|
+
});
|
194
|
+
|
195
|
+
BannerCreative.belongsTo(User, {
|
196
|
+
as: "creator",
|
197
|
+
foreignKey: "createdBy",
|
198
|
+
});
|
199
|
+
|
200
|
+
export default BannerCreative;
|
package/typed-model/index.ts
CHANGED
@@ -83,5 +83,6 @@ export { default as ParlaysOnBets } from "./parlays-on-bets";
|
|
83
83
|
export { default as DefaultCompliancePolicy } from "./default-compliance-policy";
|
84
84
|
export { default as Dispute } from "./dispute";
|
85
85
|
export { default as SportsbookOnMarket } from "./sportsbook-on-market";
|
86
|
+
export { default as BannerCreative } from "./banner-creative";
|
86
87
|
|
87
88
|
export { default as pbSequelize } from "./pb-sequelize";
|