agrs-sequelize-sdk 1.2.78 → 1.2.80

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,123 +1,123 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const TonicRSOCKeywordPerformance = sequelize.define(
3
- "TonicRSOCKeywordPerformance",
4
- {
5
- Date: {
6
- type: DataTypes.DATEONLY,
7
- primaryKey: true,
8
- },
9
- adID: {
10
- type: DataTypes.STRING,
11
- references: {
12
- model: "Ad",
13
- key: "AdID",
14
- },
15
- foreignKey: true,
16
- primaryKey: true,
17
- },
18
- Keyword: {
19
- type: DataTypes.STRING,
20
- allowNull: false,
21
- primaryKey: true,
22
- },
23
- Country: {
24
- type: DataTypes.STRING,
25
- allowNull: false,
26
- primaryKey: true, // ✅ Country is now part of primary key
27
- },
28
- Revenue: {
29
- type: DataTypes.FLOAT,
30
- allowNull: false,
31
- },
32
- Clicks: {
33
- type: DataTypes.INTEGER,
34
- allowNull: false,
35
- },
36
- TemplatedKeyword: {
37
- type: DataTypes.STRING,
38
- allowNull: true,
39
- },
40
- FirstAppearanceDate: {
41
- type: DataTypes.DATEONLY,
42
- allowNull: true,
43
- },
44
- },
45
- {
46
- tableName: "TonicRSOCKeywordPerformance",
47
- indexes: [
48
- {
49
- unique: true,
50
- fields: ["Date", "adID", "Keyword", "Country"],
51
- name: "tonic_primary_idx" // ✅ Custom short name
52
- },
53
- {
54
- fields: ["Date"],
55
- name: "tonic_date_idx"
56
- },
57
- {
58
- fields: ["adID"],
59
- name: "tonic_adid_idx"
60
- },
61
- {
62
- fields: ["Keyword"],
63
- name: "tonic_keyword_idx"
64
- },
65
- {
66
- fields: ["Country"],
67
- name: "tonic_country_idx"
68
- },
69
- {
70
- fields: ["Revenue"],
71
- name: "tonic_revenue_idx"
72
- },
73
- {
74
- fields: ["Clicks"],
75
- name: "tonic_clicks_idx"
76
- },
77
- {
78
- fields: ["Country", "Date"],
79
- name: "tonic_country_date_idx"
80
- },
81
- {
82
- fields: ["Keyword", "Country"],
83
- name: "tonic_keyword_country_idx"
84
- },
85
- {
86
- fields: ["Date", "Revenue"],
87
- name: "tonic_date_revenue_idx"
88
- },
89
- ],
90
- hooks: {
91
- beforeCreate: async (record, options) => {
92
- try {
93
- const existingKeyword = await sequelize.models.TonicRSOCKeywordPerformance.findOne({
94
- where: {
95
- Keyword: sequelize.where(
96
- sequelize.fn("LOWER", sequelize.col("Keyword")),
97
- sequelize.fn("LOWER", record.Keyword)
98
- ),
99
- Country: record.Country,
100
- },
101
- attributes: ["FirstAppearanceDate"],
102
- transaction: options.transaction,
103
- });
104
-
105
- record.FirstAppearanceDate =
106
- existingKeyword?.FirstAppearanceDate || record.Date;
107
- } catch (error) {
108
- console.error("Error in TonicRSOCKeywordPerformance FirstAppearanceDate hook:", error);
109
- throw error;
110
- }
111
- },
112
- },
113
- }
114
- );
115
-
116
- TonicRSOCKeywordPerformance.associate = (models) => {
117
- TonicRSOCKeywordPerformance.belongsTo(models.Ad, {
118
- foreignKey: "adID",
119
- });
120
- };
121
-
122
- return TonicRSOCKeywordPerformance;
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const TonicRSOCKeywordPerformance = sequelize.define(
3
+ "TonicRSOCKeywordPerformance",
4
+ {
5
+ Date: {
6
+ type: DataTypes.DATEONLY,
7
+ primaryKey: true,
8
+ },
9
+ adID: {
10
+ type: DataTypes.STRING,
11
+ references: {
12
+ model: "Ad",
13
+ key: "AdID",
14
+ },
15
+ foreignKey: true,
16
+ primaryKey: true,
17
+ },
18
+ Keyword: {
19
+ type: DataTypes.STRING,
20
+ allowNull: false,
21
+ primaryKey: true,
22
+ },
23
+ Country: {
24
+ type: DataTypes.STRING,
25
+ allowNull: false,
26
+ primaryKey: true, // ✅ Country is now part of primary key
27
+ },
28
+ Revenue: {
29
+ type: DataTypes.FLOAT,
30
+ allowNull: false,
31
+ },
32
+ Clicks: {
33
+ type: DataTypes.INTEGER,
34
+ allowNull: false,
35
+ },
36
+ TemplatedKeyword: {
37
+ type: DataTypes.STRING,
38
+ allowNull: true,
39
+ },
40
+ FirstAppearanceDate: {
41
+ type: DataTypes.DATEONLY,
42
+ allowNull: true,
43
+ },
44
+ },
45
+ {
46
+ tableName: "TonicRSOCKeywordPerformance",
47
+ indexes: [
48
+ {
49
+ unique: true,
50
+ fields: ["Date", "adID", "Keyword", "Country"],
51
+ name: "tonic_primary_idx" // ✅ Custom short name
52
+ },
53
+ {
54
+ fields: ["Date"],
55
+ name: "tonic_date_idx"
56
+ },
57
+ {
58
+ fields: ["adID"],
59
+ name: "tonic_adid_idx"
60
+ },
61
+ {
62
+ fields: ["Keyword"],
63
+ name: "tonic_keyword_idx"
64
+ },
65
+ {
66
+ fields: ["Country"],
67
+ name: "tonic_country_idx"
68
+ },
69
+ {
70
+ fields: ["Revenue"],
71
+ name: "tonic_revenue_idx"
72
+ },
73
+ {
74
+ fields: ["Clicks"],
75
+ name: "tonic_clicks_idx"
76
+ },
77
+ {
78
+ fields: ["Country", "Date"],
79
+ name: "tonic_country_date_idx"
80
+ },
81
+ {
82
+ fields: ["Keyword", "Country"],
83
+ name: "tonic_keyword_country_idx"
84
+ },
85
+ {
86
+ fields: ["Date", "Revenue"],
87
+ name: "tonic_date_revenue_idx"
88
+ },
89
+ ],
90
+ hooks: {
91
+ beforeCreate: async (record, options) => {
92
+ try {
93
+ const existingKeyword = await sequelize.models.TonicRSOCKeywordPerformance.findOne({
94
+ where: {
95
+ Keyword: sequelize.where(
96
+ sequelize.fn("LOWER", sequelize.col("Keyword")),
97
+ sequelize.fn("LOWER", record.Keyword)
98
+ ),
99
+ Country: record.Country,
100
+ },
101
+ attributes: ["FirstAppearanceDate"],
102
+ transaction: options.transaction,
103
+ });
104
+
105
+ record.FirstAppearanceDate =
106
+ existingKeyword?.FirstAppearanceDate || record.Date;
107
+ } catch (error) {
108
+ console.error("Error in TonicRSOCKeywordPerformance FirstAppearanceDate hook:", error);
109
+ throw error;
110
+ }
111
+ },
112
+ },
113
+ }
114
+ );
115
+
116
+ TonicRSOCKeywordPerformance.associate = (models) => {
117
+ TonicRSOCKeywordPerformance.belongsTo(models.Ad, {
118
+ foreignKey: "adID",
119
+ });
120
+ };
121
+
122
+ return TonicRSOCKeywordPerformance;
123
123
  };
@@ -1,26 +1,26 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const Vertical = sequelize.define(
3
- "Vertical",
4
- {
5
- id: {
6
- type: DataTypes.UUID,
7
- defaultValue: DataTypes.UUIDV4,
8
- primaryKey: true,
9
- },
10
- name: {
11
- type: DataTypes.STRING,
12
- allowNull: false,
13
- },
14
- code: {
15
- type: DataTypes.STRING,
16
- allowNull: false,
17
- unique: true,
18
- },
19
- },
20
- {
21
- tableName: "Vertical",
22
- }
23
- );
24
-
25
- return Vertical;
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const Vertical = sequelize.define(
3
+ "Vertical",
4
+ {
5
+ id: {
6
+ type: DataTypes.UUID,
7
+ defaultValue: DataTypes.UUIDV4,
8
+ primaryKey: true,
9
+ },
10
+ name: {
11
+ type: DataTypes.STRING,
12
+ allowNull: false,
13
+ },
14
+ code: {
15
+ type: DataTypes.STRING,
16
+ allowNull: false,
17
+ unique: true,
18
+ },
19
+ },
20
+ {
21
+ tableName: "Vertical",
22
+ }
23
+ );
24
+
25
+ return Vertical;
26
26
  };
@@ -1,110 +1,110 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const NewFiles = sequelize.define("NewFiles", {
3
- id: {
4
- type: DataTypes.STRING,
5
- primaryKey: true,
6
- },
7
- accounts: {
8
- type: DataTypes.JSONB(),
9
- allowNull: true,
10
- },
11
- name: {
12
- type: DataTypes.STRING,
13
- allowNull: false,
14
- },
15
- // need to add a field of the name in the gcp bucket
16
- gcpFileName: {
17
- type: DataTypes.STRING,
18
- allowNull: true,
19
- },
20
- type: {
21
- type: DataTypes.STRING, // Can be "image" or "video"
22
- allowNull: false,
23
- },
24
- URL: {
25
- type: DataTypes.STRING, // URL for the file
26
- allowNull: false,
27
- },
28
- FileType: {
29
- type: DataTypes.STRING,
30
- allowNull: true,
31
- defaultValue: "image",
32
- },
33
- Size: {
34
- type: DataTypes.STRING,
35
- allowNull: true,
36
- },
37
- Language: {
38
- type: DataTypes.STRING,
39
- allowNull: true,
40
- },
41
- Vertical: {
42
- type: DataTypes.STRING,
43
- allowNull: true,
44
- },
45
- // want to add length ( duration of the video) if the file is a video.
46
- // maybe call it duration
47
- Duration: {
48
- type: DataTypes.STRING,
49
- allowNull: true,
50
- },
51
- // Thumbnail URL
52
- Thumbnail: {
53
- type: DataTypes.TEXT,
54
- allowNull: true,
55
- },
56
- Thumbnai2: {
57
- type: DataTypes.TEXT,
58
- allowNull: true,
59
- },
60
- // ImageHash
61
- ImageHash: {
62
- type: DataTypes.STRING,
63
- allowNull: true,
64
- },
65
- isGenerated: {
66
- type: DataTypes.BOOLEAN,
67
- allowNull: true,
68
- defaultValue: false,
69
- },
70
- isUploading: {
71
- type: DataTypes.BOOLEAN,
72
- allowNull: true,
73
- defaultValue: false,
74
- },
75
- freeText: {
76
- type: DataTypes.STRING,
77
- allowNull: true,
78
- },
79
- style: {
80
- type: DataTypes.STRING,
81
- allowNull: true,
82
- },
83
- ratio: {
84
- type: DataTypes.STRING,
85
- allowNull: true,
86
- },
87
- notes: {
88
- type: DataTypes.STRING(1000),
89
- allowNull: true,
90
- },
91
- headline: {
92
- type: DataTypes.STRING(1000),
93
- allowNull: true,
94
- },
95
- subtext: {
96
- type: DataTypes.STRING(1000),
97
- allowNull: true,
98
- },
99
- cta: {
100
- type: DataTypes.STRING(1000),
101
- allowNull: true,
102
- },
103
- script: {
104
- type: DataTypes.STRING(1000),
105
- allowNull: true,
106
- },
107
- });
108
-
109
- return NewFiles;
110
- };
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const NewFiles = sequelize.define("NewFiles", {
3
+ id: {
4
+ type: DataTypes.STRING,
5
+ primaryKey: true,
6
+ },
7
+ accounts: {
8
+ type: DataTypes.JSONB(),
9
+ allowNull: true,
10
+ },
11
+ name: {
12
+ type: DataTypes.STRING,
13
+ allowNull: false,
14
+ },
15
+ // need to add a field of the name in the gcp bucket
16
+ gcpFileName: {
17
+ type: DataTypes.STRING,
18
+ allowNull: true,
19
+ },
20
+ type: {
21
+ type: DataTypes.STRING, // Can be "image" or "video"
22
+ allowNull: false,
23
+ },
24
+ URL: {
25
+ type: DataTypes.STRING, // URL for the file
26
+ allowNull: false,
27
+ },
28
+ FileType: {
29
+ type: DataTypes.STRING,
30
+ allowNull: true,
31
+ defaultValue: "image",
32
+ },
33
+ Size: {
34
+ type: DataTypes.STRING,
35
+ allowNull: true,
36
+ },
37
+ Language: {
38
+ type: DataTypes.STRING,
39
+ allowNull: true,
40
+ },
41
+ Vertical: {
42
+ type: DataTypes.STRING,
43
+ allowNull: true,
44
+ },
45
+ // want to add length ( duration of the video) if the file is a video.
46
+ // maybe call it duration
47
+ Duration: {
48
+ type: DataTypes.STRING,
49
+ allowNull: true,
50
+ },
51
+ // Thumbnail URL
52
+ Thumbnail: {
53
+ type: DataTypes.TEXT,
54
+ allowNull: true,
55
+ },
56
+ Thumbnai2: {
57
+ type: DataTypes.TEXT,
58
+ allowNull: true,
59
+ },
60
+ // ImageHash
61
+ ImageHash: {
62
+ type: DataTypes.STRING,
63
+ allowNull: true,
64
+ },
65
+ isGenerated: {
66
+ type: DataTypes.BOOLEAN,
67
+ allowNull: true,
68
+ defaultValue: false,
69
+ },
70
+ isUploading: {
71
+ type: DataTypes.BOOLEAN,
72
+ allowNull: true,
73
+ defaultValue: false,
74
+ },
75
+ freeText: {
76
+ type: DataTypes.STRING,
77
+ allowNull: true,
78
+ },
79
+ style: {
80
+ type: DataTypes.STRING,
81
+ allowNull: true,
82
+ },
83
+ ratio: {
84
+ type: DataTypes.STRING,
85
+ allowNull: true,
86
+ },
87
+ notes: {
88
+ type: DataTypes.STRING(1000),
89
+ allowNull: true,
90
+ },
91
+ headline: {
92
+ type: DataTypes.STRING(1000),
93
+ allowNull: true,
94
+ },
95
+ subtext: {
96
+ type: DataTypes.STRING(1000),
97
+ allowNull: true,
98
+ },
99
+ cta: {
100
+ type: DataTypes.STRING(1000),
101
+ allowNull: true,
102
+ },
103
+ script: {
104
+ type: DataTypes.STRING(1000),
105
+ allowNull: true,
106
+ },
107
+ });
108
+
109
+ return NewFiles;
110
+ };
package/package.json CHANGED
@@ -1,19 +1,21 @@
1
- {
2
- "name": "agrs-sequelize-sdk",
3
- "version": "1.2.78",
4
- "main": "index.js",
5
- "scripts": {
6
- "start": "node index.js",
7
- "sync": "node services/sequelizeService.js",
8
- "test": "echo \"Error: no test specified\" && exit 1"
9
- },
10
- "keywords": [],
11
- "author": "",
12
- "license": "ISC",
13
- "description": "",
14
- "dependencies": {
15
- "pg": "^8.13.0",
16
- "pg-hstore": "^2.3.4",
17
- "sequelize": "^6.37.4"
18
- }
19
- }
1
+ {
2
+ "name": "agrs-sequelize-sdk",
3
+ "version": "1.2.80",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "start": "node index.js",
7
+ "sync": "node services/sequelizeService.js",
8
+ "test": "echo \"Error: no test specified\" \u0026\u0026 exit 1"
9
+ },
10
+ "keywords": [
11
+
12
+ ],
13
+ "author": "",
14
+ "license": "ISC",
15
+ "description": "",
16
+ "dependencies": {
17
+ "pg": "^8.13.0",
18
+ "pg-hstore": "^2.3.4",
19
+ "sequelize": "^6.37.4"
20
+ }
21
+ }