@winible/winible-typed 2.68.0 → 2.69.1
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/event-collector-models/conversion-log.js +1 -1
- package/dist/event-collector-models/conversion-log.js.map +1 -1
- package/dist/typed-model/featured-capper.js +51 -0
- package/dist/typed-model/featured-capper.js.map +1 -0
- package/dist/utils/campaignUtils.js +44 -1
- package/dist/utils/campaignUtils.js.map +1 -1
- package/event-collector-models/conversion-log.ts +1 -1
- package/package.json +1 -1
- package/utils/campaignUtils.ts +136 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"conversion-log.js","sourceRoot":"","sources":["../../event-collector-models/conversion-log.ts"],"names":[],"mappings":";;;;;AAAA,yCAMmB;AAEnB,kEAAuC;AACvC,0DAAiC;AAEjC,MAAM,aAAc,SAAQ,iBAG3B;CAMA;AAED,aAAa,CAAC,IAAI,CAChB;IACE,EAAE,EAAE;QACF,IAAI,EAAE,qBAAS,CAAC,IAAI;QACpB,YAAY,EAAE,qBAAS,CAAC,MAAM;QAC9B,UAAU,EAAE,IAAI;QAChB,KAAK,EAAE,IAAI;KACZ;IACD,SAAS,EAAE;QACT,IAAI,EAAE,qBAAS,CAAC,IAAI;QACpB,SAAS,EAAE,
|
1
|
+
{"version":3,"file":"conversion-log.js","sourceRoot":"","sources":["../../event-collector-models/conversion-log.ts"],"names":[],"mappings":";;;;;AAAA,yCAMmB;AAEnB,kEAAuC;AACvC,0DAAiC;AAEjC,MAAM,aAAc,SAAQ,iBAG3B;CAMA;AAED,aAAa,CAAC,IAAI,CAChB;IACE,EAAE,EAAE;QACF,IAAI,EAAE,qBAAS,CAAC,IAAI;QACpB,YAAY,EAAE,qBAAS,CAAC,MAAM;QAC9B,UAAU,EAAE,IAAI;QAChB,KAAK,EAAE,IAAI;KACZ;IACD,SAAS,EAAE;QACT,IAAI,EAAE,qBAAS,CAAC,IAAI;QACpB,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,aAAa;KACrB;IACD,aAAa,EAAE;QACb,IAAI,EAAE,qBAAS,CAAC,MAAM;QACtB,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE,gBAAgB;KACxB;IACD,gBAAgB,EAAE;QAChB,IAAI,EAAE,qBAAS,CAAC,KAAK;QACrB,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,mBAAmB;KAC3B;IACD,SAAS,EAAE;QACT,IAAI,EAAE,qBAAS,CAAC,IAAI;QACpB,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,qBAAS,CAAC,GAAG;QAC3B,UAAU,EAAE,IAAI;KACjB;CACF,EACD;IACE,SAAS,EAAT,sBAAS;IACT,SAAS,EAAE,gBAAgB;IAC3B,UAAU,EAAE,KAAK;CAClB,CACF,CAAC;AAEF,aAAa,CAAC,SAAS,CAAC,kBAAO,EAAE;IAC/B,UAAU,EAAE,WAAW;IACvB,EAAE,EAAE,SAAS;IACb,SAAS,EAAE,IAAI;CAChB,CAAC,CAAC;AAEH,kBAAe,aAAa,CAAC"}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const sequelize_1 = require("sequelize");
|
7
|
+
const pb_sequelize_1 = __importDefault(require("./pb-sequelize"));
|
8
|
+
const user_1 = __importDefault(require("./user"));
|
9
|
+
// order of InferAttributes & InferCreationAttributes is important.
|
10
|
+
class FeaturedCapper extends sequelize_1.Model {
|
11
|
+
}
|
12
|
+
FeaturedCapper.init({
|
13
|
+
id: {
|
14
|
+
type: sequelize_1.DataTypes.BIGINT,
|
15
|
+
primaryKey: true,
|
16
|
+
allowNull: false,
|
17
|
+
defaultValue: pb_sequelize_1.default.fn("next_id"),
|
18
|
+
},
|
19
|
+
userId: {
|
20
|
+
type: sequelize_1.DataTypes.BIGINT,
|
21
|
+
allowNull: false,
|
22
|
+
field: "user_id",
|
23
|
+
references: {
|
24
|
+
model: user_1.default,
|
25
|
+
},
|
26
|
+
},
|
27
|
+
priority: {
|
28
|
+
type: sequelize_1.DataTypes.SMALLINT,
|
29
|
+
field: "priority",
|
30
|
+
},
|
31
|
+
customLabel: {
|
32
|
+
type: sequelize_1.DataTypes.STRING,
|
33
|
+
field: "custom_label",
|
34
|
+
},
|
35
|
+
createdAt: sequelize_1.DataTypes.DATE,
|
36
|
+
updatedAt: sequelize_1.DataTypes.DATE,
|
37
|
+
}, {
|
38
|
+
tableName: "featured_cappers",
|
39
|
+
sequelize: pb_sequelize_1.default,
|
40
|
+
});
|
41
|
+
user_1.default.hasOne(FeaturedCapper, {
|
42
|
+
foreignKey: "userId",
|
43
|
+
sourceKey: "id",
|
44
|
+
});
|
45
|
+
FeaturedCapper.hasOne(user_1.default, {
|
46
|
+
foreignKey: "id",
|
47
|
+
sourceKey: "userId",
|
48
|
+
onDelete: "NO ACTION",
|
49
|
+
});
|
50
|
+
exports.default = FeaturedCapper;
|
51
|
+
//# sourceMappingURL=featured-capper.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"featured-capper.js","sourceRoot":"","sources":["../../typed-model/featured-capper.ts"],"names":[],"mappings":";;;;;AAAA,yCAMmB;AAEnB,kEAAuC;AACvC,kDAA0B;AAE1B,mEAAmE;AACnE,MAAM,cAAe,SAAQ,iBAG5B;CAUA;AAED,cAAc,CAAC,IAAI,CACjB;IACE,EAAE,EAAE;QACF,IAAI,EAAE,qBAAS,CAAC,MAAM;QACtB,UAAU,EAAE,IAAI;QAChB,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,sBAAS,CAAC,EAAE,CAAC,SAAS,CAAC;KACtC;IACD,MAAM,EAAE;QACN,IAAI,EAAE,qBAAS,CAAC,MAAM;QACtB,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE,SAAS;QAChB,UAAU,EAAE;YACV,KAAK,EAAE,cAAI;SACZ;KACF;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,qBAAS,CAAC,QAAQ;QACxB,KAAK,EAAE,UAAU;KAClB;IACD,WAAW,EAAE;QACX,IAAI,EAAE,qBAAS,CAAC,MAAM;QACtB,KAAK,EAAE,cAAc;KACtB;IAED,SAAS,EAAE,qBAAS,CAAC,IAAI;IACzB,SAAS,EAAE,qBAAS,CAAC,IAAI;CAC1B,EACD;IACE,SAAS,EAAE,kBAAkB;IAC7B,SAAS,EAAT,sBAAS;CACV,CACF,CAAC;AAEF,cAAI,CAAC,MAAM,CAAC,cAAc,EAAE;IAC1B,UAAU,EAAE,QAAQ;IACpB,SAAS,EAAE,IAAI;CAChB,CAAC,CAAC;AAEH,cAAc,CAAC,MAAM,CAAC,cAAI,EAAE;IAC1B,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,QAAQ;IACnB,QAAQ,EAAE,WAAW;CACtB,CAAC,CAAC;AAEH,kBAAe,cAAc,CAAC"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const src_1 = require("../src");
|
3
4
|
const CLIENT_URL = process.env.CLIENT_URL;
|
4
5
|
const VARIABLE_MAP = {
|
5
6
|
FIRST_NAME: "{FIRST_NAME}",
|
@@ -35,6 +36,7 @@ const buildReplacements = (contact, campaignMessage) => {
|
|
35
36
|
}
|
36
37
|
return replacements;
|
37
38
|
};
|
39
|
+
// Deprecated Method
|
38
40
|
const buildSmsQueueInput = (senderId, contact, campaignMessage, scheduleSendTime // Optional: Used for absolute/relative timing
|
39
41
|
) => {
|
40
42
|
const replacements = buildReplacements(contact, campaignMessage);
|
@@ -53,6 +55,7 @@ const buildSmsQueueInput = (senderId, contact, campaignMessage, scheduleSendTime
|
|
53
55
|
configuration: configuration,
|
54
56
|
};
|
55
57
|
};
|
58
|
+
// Deprecated Method
|
56
59
|
const buildEmailQueueInput = (senderId, contact, campaignMessage, scheduleSendTime // Optional: Used for absolute/relative timing
|
57
60
|
) => {
|
58
61
|
const replacements = buildReplacements(contact, campaignMessage);
|
@@ -71,5 +74,45 @@ const buildEmailQueueInput = (senderId, contact, campaignMessage, scheduleSendTi
|
|
71
74
|
configuration: configuration,
|
72
75
|
};
|
73
76
|
};
|
74
|
-
|
77
|
+
const buildSmsSendQueueEntry = ({ phoneNumberAssigned, content, contactPhoneNumber, sendAt, timingType, sendLogId, }) => {
|
78
|
+
return {
|
79
|
+
type: "CAMPAIGN_SMS",
|
80
|
+
payload: {
|
81
|
+
configuration: Object.assign(Object.assign({ phoneNumber: phoneNumberAssigned, body: content, to: contactPhoneNumber }, (sendLogId && { sendLogId })), (timingType !== src_1.MessageTimingType.IMMEDIATE &&
|
82
|
+
sendAt && {
|
83
|
+
sendAt: new Date(sendAt),
|
84
|
+
scheduleType: "fixed",
|
85
|
+
})),
|
86
|
+
},
|
87
|
+
};
|
88
|
+
};
|
89
|
+
const buildEmailSendQueueEntry = ({ templateId, apiKey, from, unixSendAt, contactEmail, sendLogId, subject, content, campaignMessageId, unsubscribeUrl, }) => {
|
90
|
+
const personalizationEntry = Object.assign({ to: [{ email: contactEmail }], dynamic_template_data: {
|
91
|
+
subject: subject,
|
92
|
+
html: content,
|
93
|
+
unsubscribe_url: unsubscribeUrl || "",
|
94
|
+
} }, (sendLogId && {
|
95
|
+
custom_args: {
|
96
|
+
send_log_id: sendLogId,
|
97
|
+
},
|
98
|
+
}));
|
99
|
+
const batchKey = `${campaignMessageId}_${templateId}_${unixSendAt || "immediate"}`;
|
100
|
+
return {
|
101
|
+
type: "CAMPAIGN_EMAIL",
|
102
|
+
payload: {
|
103
|
+
configuration: Object.assign({ batchKey,
|
104
|
+
apiKey,
|
105
|
+
from, personalization: personalizationEntry, templateId }, (unixSendAt && {
|
106
|
+
sendAt: unixSendAt,
|
107
|
+
})),
|
108
|
+
},
|
109
|
+
};
|
110
|
+
};
|
111
|
+
exports.default = {
|
112
|
+
buildReplacements,
|
113
|
+
buildEmailQueueInput,
|
114
|
+
buildSmsQueueInput,
|
115
|
+
buildSmsSendQueueEntry,
|
116
|
+
buildEmailSendQueueEntry,
|
117
|
+
};
|
75
118
|
//# sourceMappingURL=campaignUtils.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"campaignUtils.js","sourceRoot":"","sources":["../../utils/campaignUtils.ts"],"names":[],"mappings":";;
|
1
|
+
{"version":3,"file":"campaignUtils.js","sourceRoot":"","sources":["../../utils/campaignUtils.ts"],"names":[],"mappings":";;AAAA,gCAA2C;AA0B3C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;AAE1C,MAAM,YAAY,GAAG;IACnB,UAAU,EAAE,cAAc;IAC1B,YAAY,EAAE,gBAAgB;IAC9B,SAAS,EAAE,aAAa;IACxB,aAAa,EAAE,iBAAiB;IAChC,gBAAgB,EAAE,oBAAoB;CACvC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,OAAa,EAAE,eAAgC,EAAE,EAAE;IAC5E,IAAI,YAAY,GAA2B,EAAE,CAAC;IAE9C,MAAM,OAAO,GAAG,CAAC,eAAe,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IACxE,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,IAAI,EAAE,CAAC;IAC9C,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,IAAI,EAAE,CAAC;IAChD,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,IAAI,EAAE,CAAC;IAEnD,IACE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,UAAU,CAAC;QACzC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,UAAU,CAAC,EACzC;QACA,YAAY,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;KACjE;IAED,IACE,OAAO,CAAC,QAAQ,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ACV,YAAY,EACZ,SAAS,EACT,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,cAAc,GAYf,EAAuB,EAAE;IACxB,MAAM,oBAAoB,mBACxB,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,EAC7B,qBAAqB,EAAE;YACrB,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,OAAO;YACb,eAAe,EAAE,cAAc,IAAI,EAAE;SACtC,IACE,CAAC,SAAS,IAAI;QACf,WAAW,EAAE;YACX,WAAW,EAAE,SAAS;SACvB;KACF,CAAC,CACH,CAAC;IAEF,MAAM,QAAQ,GAAG,GAAG,iBAAiB,IAAI,UAAU,IACjD,UAAU,IAAI,WAChB,EAAE,CAAC;IAEH,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE;YACP,aAAa,kBACX,QAAQ;gBACR,MAAM;gBACN,IAAI,EACJ,eAAe,EAAE,oBAAoB,EACrC,UAAU,IACP,CAAC,UAAU,IAAI;gBAChB,MAAM,EAAE,UAAU;aACnB,CAAC,CACH;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe;IACb,iBAAiB;IACjB,oBAAoB;IACpB,kBAAkB;IAClB,sBAAsB;IACtB,wBAAwB;CACzB,CAAC"}
|
package/package.json
CHANGED
package/utils/campaignUtils.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { MessageTimingType } from "../src";
|
1
2
|
import { CampaignMessage, User } from "../typed-model";
|
2
3
|
|
3
4
|
type CampaignMessageConfiguration = {
|
@@ -78,6 +79,7 @@ const buildReplacements = (contact: User, campaignMessage: CampaignMessage) => {
|
|
78
79
|
return replacements;
|
79
80
|
};
|
80
81
|
|
82
|
+
// Deprecated Method
|
81
83
|
const buildSmsQueueInput = (
|
82
84
|
senderId: string,
|
83
85
|
contact: User,
|
@@ -103,6 +105,7 @@ const buildSmsQueueInput = (
|
|
103
105
|
};
|
104
106
|
};
|
105
107
|
|
108
|
+
// Deprecated Method
|
106
109
|
const buildEmailQueueInput = (
|
107
110
|
senderId: string,
|
108
111
|
contact: User,
|
@@ -128,4 +131,136 @@ const buildEmailQueueInput = (
|
|
128
131
|
};
|
129
132
|
};
|
130
133
|
|
131
|
-
export
|
134
|
+
export type CampaignEmailMessageConfiguration = {
|
135
|
+
batchKey?: string;
|
136
|
+
apiKey?: string;
|
137
|
+
personalization?: any;
|
138
|
+
from?: {
|
139
|
+
email: string;
|
140
|
+
name: string;
|
141
|
+
};
|
142
|
+
templateId?: string;
|
143
|
+
sendAt?: number;
|
144
|
+
};
|
145
|
+
|
146
|
+
export type CampaignSmsMessageConfiguration = {
|
147
|
+
phoneNumber: string;
|
148
|
+
to: string;
|
149
|
+
body: string;
|
150
|
+
sendAt?: Date;
|
151
|
+
scheduleType?: "fixed";
|
152
|
+
sendLogId?: string;
|
153
|
+
};
|
154
|
+
|
155
|
+
export type EmailSendQueueEntry = {
|
156
|
+
type: string;
|
157
|
+
payload: {
|
158
|
+
configuration: CampaignEmailMessageConfiguration;
|
159
|
+
};
|
160
|
+
};
|
161
|
+
|
162
|
+
export type SmsSendQueueEntry = {
|
163
|
+
type: string;
|
164
|
+
payload: {
|
165
|
+
configuration: CampaignSmsMessageConfiguration;
|
166
|
+
};
|
167
|
+
};
|
168
|
+
|
169
|
+
const buildSmsSendQueueEntry = ({
|
170
|
+
phoneNumberAssigned,
|
171
|
+
content,
|
172
|
+
contactPhoneNumber,
|
173
|
+
sendAt,
|
174
|
+
timingType,
|
175
|
+
sendLogId,
|
176
|
+
}: {
|
177
|
+
phoneNumberAssigned: string;
|
178
|
+
content: string;
|
179
|
+
contactPhoneNumber: string;
|
180
|
+
sendAt?: Date;
|
181
|
+
timingType?: MessageTimingType;
|
182
|
+
sendLogId: string;
|
183
|
+
}): SmsSendQueueEntry => {
|
184
|
+
return {
|
185
|
+
type: "CAMPAIGN_SMS",
|
186
|
+
payload: {
|
187
|
+
configuration: {
|
188
|
+
phoneNumber: phoneNumberAssigned,
|
189
|
+
body: content,
|
190
|
+
to: contactPhoneNumber,
|
191
|
+
...(sendLogId && { sendLogId }),
|
192
|
+
...(timingType !== MessageTimingType.IMMEDIATE &&
|
193
|
+
sendAt && {
|
194
|
+
sendAt: new Date(sendAt),
|
195
|
+
scheduleType: "fixed",
|
196
|
+
}),
|
197
|
+
},
|
198
|
+
},
|
199
|
+
};
|
200
|
+
};
|
201
|
+
|
202
|
+
const buildEmailSendQueueEntry = ({
|
203
|
+
templateId,
|
204
|
+
apiKey,
|
205
|
+
from,
|
206
|
+
unixSendAt,
|
207
|
+
contactEmail,
|
208
|
+
sendLogId,
|
209
|
+
subject,
|
210
|
+
content,
|
211
|
+
campaignMessageId,
|
212
|
+
unsubscribeUrl,
|
213
|
+
}: {
|
214
|
+
templateId: string;
|
215
|
+
apiKey: string;
|
216
|
+
from: { email: string; name: string };
|
217
|
+
unixSendAt?: number;
|
218
|
+
contactEmail: string;
|
219
|
+
sendLogId?: string;
|
220
|
+
subject: string;
|
221
|
+
content: string;
|
222
|
+
campaignMessageId: string;
|
223
|
+
unsubscribeUrl: string;
|
224
|
+
}): EmailSendQueueEntry => {
|
225
|
+
const personalizationEntry = {
|
226
|
+
to: [{ email: contactEmail }],
|
227
|
+
dynamic_template_data: {
|
228
|
+
subject: subject,
|
229
|
+
html: content,
|
230
|
+
unsubscribe_url: unsubscribeUrl || "",
|
231
|
+
},
|
232
|
+
...(sendLogId && {
|
233
|
+
custom_args: {
|
234
|
+
send_log_id: sendLogId,
|
235
|
+
},
|
236
|
+
}),
|
237
|
+
};
|
238
|
+
|
239
|
+
const batchKey = `${campaignMessageId}_${templateId}_${
|
240
|
+
unixSendAt || "immediate"
|
241
|
+
}`;
|
242
|
+
|
243
|
+
return {
|
244
|
+
type: "CAMPAIGN_EMAIL",
|
245
|
+
payload: {
|
246
|
+
configuration: {
|
247
|
+
batchKey,
|
248
|
+
apiKey,
|
249
|
+
from,
|
250
|
+
personalization: personalizationEntry,
|
251
|
+
templateId,
|
252
|
+
...(unixSendAt && {
|
253
|
+
sendAt: unixSendAt,
|
254
|
+
}),
|
255
|
+
},
|
256
|
+
},
|
257
|
+
};
|
258
|
+
};
|
259
|
+
|
260
|
+
export default {
|
261
|
+
buildReplacements,
|
262
|
+
buildEmailQueueInput,
|
263
|
+
buildSmsQueueInput,
|
264
|
+
buildSmsSendQueueEntry,
|
265
|
+
buildEmailSendQueueEntry,
|
266
|
+
};
|