@winible/winible-typed 2.52.0 → 2.52.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.
@@ -0,0 +1,65 @@
1
+ import {
2
+ Model,
3
+ DataTypes,
4
+ InferAttributes,
5
+ InferCreationAttributes,
6
+ CreationOptional,
7
+ } from "sequelize";
8
+
9
+ import sequelize from "./ts-sequelize";
10
+ import SendLog from "./send-log";
11
+
12
+ class ConversionLog extends Model<
13
+ InferAttributes<ConversionLog>,
14
+ InferCreationAttributes<ConversionLog>
15
+ > {
16
+ declare id: CreationOptional<string>;
17
+ declare sendLogId: string;
18
+ declare amount: number;
19
+ declare currency: CreationOptional<string>;
20
+ declare createdAt: CreationOptional<Date>;
21
+ }
22
+
23
+ ConversionLog.init(
24
+ {
25
+ id: {
26
+ type: DataTypes.UUID,
27
+ defaultValue: DataTypes.UUIDV4,
28
+ primaryKey: true,
29
+ field: "id",
30
+ },
31
+ sendLogId: {
32
+ type: DataTypes.UUID,
33
+ allowNull: false,
34
+ field: "send_log_id",
35
+ },
36
+ amount: {
37
+ type: DataTypes.DECIMAL(12, 2),
38
+ allowNull: false,
39
+ },
40
+ currency: {
41
+ type: DataTypes.STRING,
42
+ allowNull: false,
43
+ defaultValue: "USD",
44
+ },
45
+ createdAt: {
46
+ type: DataTypes.DATE,
47
+ allowNull: false,
48
+ defaultValue: DataTypes.NOW,
49
+ primaryKey: true,
50
+ },
51
+ },
52
+ {
53
+ sequelize,
54
+ tableName: "conversion_log",
55
+ timestamps: false,
56
+ }
57
+ );
58
+
59
+ ConversionLog.belongsTo(SendLog, {
60
+ foreignKey: "sendLogId",
61
+ as: "sendLog",
62
+ targetKey: "id",
63
+ });
64
+
65
+ export default ConversionLog;
@@ -0,0 +1,71 @@
1
+ import {
2
+ Model,
3
+ DataTypes,
4
+ InferAttributes,
5
+ InferCreationAttributes,
6
+ CreationOptional,
7
+ } from "sequelize";
8
+
9
+ import sequelize from "./ts-sequelize";
10
+ import SendLog from "./send-log";
11
+
12
+ class EventSendLog extends Model<
13
+ InferAttributes<EventSendLog>,
14
+ InferCreationAttributes<EventSendLog>
15
+ > {
16
+ declare id: CreationOptional<string>;
17
+ declare sendLogId: string;
18
+ declare eventType: string;
19
+ declare timestamp: CreationOptional<Date>;
20
+ declare metadata: object;
21
+ declare webhookSource: string;
22
+ }
23
+
24
+ EventSendLog.init(
25
+ {
26
+ id: {
27
+ type: DataTypes.UUID,
28
+ defaultValue: DataTypes.UUIDV4,
29
+ primaryKey: true,
30
+ field: "id",
31
+ },
32
+ sendLogId: {
33
+ type: DataTypes.UUID,
34
+ allowNull: false,
35
+ field: "send_log_id",
36
+ },
37
+ eventType: {
38
+ type: DataTypes.STRING,
39
+ allowNull: false,
40
+ field: "event_type",
41
+ },
42
+ timestamp: {
43
+ type: DataTypes.DATE,
44
+ allowNull: false,
45
+ defaultValue: DataTypes.NOW,
46
+ primaryKey: true,
47
+ },
48
+ metadata: {
49
+ type: DataTypes.JSONB,
50
+ allowNull: false,
51
+ },
52
+ webhookSource: {
53
+ type: DataTypes.STRING,
54
+ allowNull: false,
55
+ field: "webhook_source",
56
+ },
57
+ },
58
+ {
59
+ sequelize,
60
+ tableName: "event_send_log",
61
+ timestamps: false,
62
+ }
63
+ );
64
+
65
+ EventSendLog.belongsTo(SendLog, {
66
+ foreignKey: "sendLogId",
67
+ as: "sendLog",
68
+ targetKey: "id",
69
+ });
70
+
71
+ export default EventSendLog;
@@ -0,0 +1,4 @@
1
+ export { default as tsSequelize } from "./ts-sequelize";
2
+ export { default as SendLog } from "./send-log";
3
+ export { default as EventSendLog } from "./event-send-log";
4
+ export { default as ConversionLog } from "./conversion-log";
@@ -0,0 +1,96 @@
1
+ import {
2
+ Model,
3
+ DataTypes,
4
+ InferAttributes,
5
+ InferCreationAttributes,
6
+ CreationOptional,
7
+ } from "sequelize";
8
+
9
+ import sequelize from "./ts-sequelize";
10
+ import EventSendLog from "./event-send-log";
11
+ import ConversionLog from "./conversion-log";
12
+
13
+ class SendLog extends Model<
14
+ InferAttributes<SendLog>,
15
+ InferCreationAttributes<SendLog>
16
+ > {
17
+ declare id: CreationOptional<string>;
18
+ declare userId: string;
19
+ declare campaignId: string;
20
+ declare messageId: string;
21
+ declare recipient: string;
22
+ declare provider: "sendgrid" | "twilio";
23
+ declare lastStatus: string;
24
+ declare lastStatusUpdatedAt: CreationOptional<Date>;
25
+ declare createdAt: CreationOptional<Date>;
26
+ }
27
+
28
+ SendLog.init(
29
+ {
30
+ id: {
31
+ type: DataTypes.UUID,
32
+ defaultValue: DataTypes.UUIDV4,
33
+ primaryKey: true,
34
+ allowNull: false,
35
+ field: "id",
36
+ },
37
+ userId: {
38
+ type: DataTypes.STRING,
39
+ allowNull: false,
40
+ field: "user_id",
41
+ },
42
+ campaignId: {
43
+ type: DataTypes.STRING,
44
+ allowNull: false,
45
+ field: "campaign_id",
46
+ },
47
+ messageId: {
48
+ type: DataTypes.STRING,
49
+ allowNull: false,
50
+ field: "message_id",
51
+ },
52
+ recipient: {
53
+ type: DataTypes.STRING,
54
+ allowNull: false,
55
+ },
56
+ provider: {
57
+ type: DataTypes.ENUM("sendgrid", "twilio"),
58
+ allowNull: false,
59
+ },
60
+ lastStatus: {
61
+ type: DataTypes.STRING,
62
+ allowNull: false,
63
+ field: "last_status",
64
+ },
65
+ lastStatusUpdatedAt: {
66
+ type: DataTypes.DATE,
67
+ allowNull: false,
68
+ defaultValue: DataTypes.NOW,
69
+ field: "last_status_updated_at",
70
+ },
71
+ createdAt: {
72
+ type: DataTypes.DATE,
73
+ allowNull: false,
74
+ defaultValue: DataTypes.NOW,
75
+ field: "created_at",
76
+ primaryKey: true,
77
+ },
78
+ },
79
+ {
80
+ sequelize,
81
+ tableName: "send_log",
82
+ timestamps: false,
83
+ }
84
+ );
85
+
86
+ SendLog.hasMany(EventSendLog, {
87
+ foreignKey: "send_log_id",
88
+ as: "events",
89
+ });
90
+
91
+ SendLog.hasOne(ConversionLog, {
92
+ foreignKey: "send_log_id",
93
+ as: "conversion",
94
+ });
95
+
96
+ export default SendLog;
@@ -0,0 +1,49 @@
1
+ import * as pg from "pg";
2
+ import { Sequelize } from "sequelize";
3
+
4
+ let sequelize: Sequelize;
5
+
6
+ sequelize = new Sequelize({
7
+ dialect: "postgres",
8
+ dialectModule: pg,
9
+ host:
10
+ process.env.TS_DB_HOST ||
11
+ (() => {
12
+ throw new Error("TS_DB_HOST is required");
13
+ })(),
14
+ port: parseInt(
15
+ process.env.TS_DB_PORT ||
16
+ (() => {
17
+ throw new Error("TS_DB_PORT is required");
18
+ })()
19
+ ),
20
+ database:
21
+ process.env.TS_DB_NAME ||
22
+ (() => {
23
+ throw new Error("TS_DB_NAME is required");
24
+ })(),
25
+ username:
26
+ process.env.TS_DB_USER ||
27
+ (() => {
28
+ throw new Error("TS_DB_USER is required");
29
+ })(),
30
+ password:
31
+ process.env.TS_DB_PASSWORD ||
32
+ (() => {
33
+ throw new Error("TS_DB_PASSWORD is required");
34
+ })(),
35
+ logging: false,
36
+ });
37
+
38
+ (async () => {
39
+ try {
40
+ await sequelize.authenticate();
41
+ console.log(
42
+ "Timescale database connection has been established successfully."
43
+ );
44
+ } catch (error) {
45
+ console.error("Unable to connect to the Timescale database:", error);
46
+ }
47
+ })();
48
+
49
+ export default sequelize;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@winible/winible-typed",
3
- "version": "2.52.0",
3
+ "version": "2.52.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -70,6 +70,7 @@
70
70
  },
71
71
  "files": [
72
72
  "typed-model/**/*",
73
+ "event-collector-models/**/*",
73
74
  "support/**/*",
74
75
  "src/**/*",
75
76
  "index.ts",