@winible/winible-typed 2.52.0 → 2.52.2

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.
@@ -3,13 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ConversionLog = exports.EventSendLog = exports.SendLog = exports.tsSequelize = void 0;
7
- var ts_sequelize_1 = require("./ts-sequelize");
8
- Object.defineProperty(exports, "tsSequelize", { enumerable: true, get: function () { return __importDefault(ts_sequelize_1).default; } });
6
+ exports.tsSequelize = exports.ConversionLog = exports.EventSendLog = exports.SendLog = void 0;
9
7
  var send_log_1 = require("./send-log");
10
8
  Object.defineProperty(exports, "SendLog", { enumerable: true, get: function () { return __importDefault(send_log_1).default; } });
11
9
  var event_send_log_1 = require("./event-send-log");
12
10
  Object.defineProperty(exports, "EventSendLog", { enumerable: true, get: function () { return __importDefault(event_send_log_1).default; } });
13
11
  var conversion_log_1 = require("./conversion-log");
14
12
  Object.defineProperty(exports, "ConversionLog", { enumerable: true, get: function () { return __importDefault(conversion_log_1).default; } });
13
+ var ts_sequelize_1 = require("./ts-sequelize");
14
+ Object.defineProperty(exports, "tsSequelize", { enumerable: true, get: function () { return __importDefault(ts_sequelize_1).default; } });
15
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../event-collector-models/index.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAwD;AAA/C,4HAAA,OAAO,OAAe;AAC/B,uCAAgD;AAAvC,oHAAA,OAAO,OAAW;AAC3B,mDAA2D;AAAlD,+HAAA,OAAO,OAAgB;AAChC,mDAA4D;AAAnD,gIAAA,OAAO,OAAiB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../event-collector-models/index.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAgD;AAAvC,oHAAA,OAAO,OAAW;AAC3B,mDAA2D;AAAlD,+HAAA,OAAO,OAAgB;AAChC,mDAA4D;AAAnD,gIAAA,OAAO,OAAiB;AAEjC,+CAAwD;AAA/C,4HAAA,OAAO,OAAe"}
@@ -5,8 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const sequelize_1 = require("sequelize");
7
7
  const ts_sequelize_1 = __importDefault(require("./ts-sequelize"));
8
- const event_send_log_1 = __importDefault(require("./event-send-log"));
9
- const conversion_log_1 = __importDefault(require("./conversion-log"));
10
8
  class SendLog extends sequelize_1.Model {
11
9
  }
12
10
  SendLog.init({
@@ -63,13 +61,5 @@ SendLog.init({
63
61
  tableName: "send_log",
64
62
  timestamps: false,
65
63
  });
66
- SendLog.hasMany(event_send_log_1.default, {
67
- foreignKey: "send_log_id",
68
- as: "events",
69
- });
70
- SendLog.hasOne(conversion_log_1.default, {
71
- foreignKey: "send_log_id",
72
- as: "conversion",
73
- });
74
64
  exports.default = SendLog;
75
65
  //# sourceMappingURL=send-log.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"send-log.js","sourceRoot":"","sources":["../../event-collector-models/send-log.ts"],"names":[],"mappings":";;;;;AAAA,yCAMmB;AAEnB,kEAAuC;AACvC,sEAA4C;AAC5C,sEAA6C;AAE7C,MAAM,OAAQ,SAAQ,iBAGrB;CAUA;AAED,OAAO,CAAC,IAAI,CACV;IACE,EAAE,EAAE;QACF,IAAI,EAAE,qBAAS,CAAC,IAAI;QACpB,YAAY,EAAE,qBAAS,CAAC,MAAM;QAC9B,UAAU,EAAE,IAAI;QAChB,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE,IAAI;KACZ;IACD,MAAM,EAAE;QACN,IAAI,EAAE,qBAAS,CAAC,MAAM;QACtB,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE,SAAS;KACjB;IACD,UAAU,EAAE;QACV,IAAI,EAAE,qBAAS,CAAC,MAAM;QACtB,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE,aAAa;KACrB;IACD,SAAS,EAAE;QACT,IAAI,EAAE,qBAAS,CAAC,MAAM;QACtB,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE,YAAY;KACpB;IACD,SAAS,EAAE;QACT,IAAI,EAAE,qBAAS,CAAC,MAAM;QACtB,SAAS,EAAE,KAAK;KACjB;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,qBAAS,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC;QAC1C,SAAS,EAAE,KAAK;KACjB;IACD,UAAU,EAAE;QACV,IAAI,EAAE,qBAAS,CAAC,MAAM;QACtB,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE,aAAa;KACrB;IACD,mBAAmB,EAAE;QACnB,IAAI,EAAE,qBAAS,CAAC,IAAI;QACpB,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,qBAAS,CAAC,GAAG;QAC3B,KAAK,EAAE,wBAAwB;KAChC;IACD,SAAS,EAAE;QACT,IAAI,EAAE,qBAAS,CAAC,IAAI;QACpB,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,qBAAS,CAAC,GAAG;QAC3B,KAAK,EAAE,YAAY;QACnB,UAAU,EAAE,IAAI;KACjB;CACF,EACD;IACE,SAAS,EAAT,sBAAS;IACT,SAAS,EAAE,UAAU;IACrB,UAAU,EAAE,KAAK;CAClB,CACF,CAAC;AAEF,OAAO,CAAC,OAAO,CAAC,wBAAY,EAAE;IAC5B,UAAU,EAAE,aAAa;IACzB,EAAE,EAAE,QAAQ;CACb,CAAC,CAAC;AAEH,OAAO,CAAC,MAAM,CAAC,wBAAa,EAAE;IAC5B,UAAU,EAAE,aAAa;IACzB,EAAE,EAAE,YAAY;CACjB,CAAC,CAAC;AAEH,kBAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"send-log.js","sourceRoot":"","sources":["../../event-collector-models/send-log.ts"],"names":[],"mappings":";;;;;AAAA,yCAMmB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sBAAS;IACT,SAAS,EAAE,UAAU;IACrB,UAAU,EAAE,KAAK;CAClB,CACF,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -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,5 @@
1
+ export { default as SendLog } from "./send-log";
2
+ export { default as EventSendLog } from "./event-send-log";
3
+ export { default as ConversionLog } from "./conversion-log";
4
+
5
+ export { default as tsSequelize } from "./ts-sequelize";
@@ -0,0 +1,86 @@
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
+ 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.2",
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",