agrs-sequelize-sdk 1.1.94 → 1.1.97
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/models/Ad.js +9 -73
- package/models/AdSet.js +0 -144
- package/models/RSOCFeedCampaign.js +10 -1
- package/package.json +1 -1
- package/agrs-sequelize/LICENSE +0 -21
- package/agrs-sequelize/README.md +0 -179
- package/agrs-sequelize/index.js +0 -169
- package/agrs-sequelize/jq.exe +0 -0
- package/agrs-sequelize/models/ActivityHistory.js +0 -73
- package/agrs-sequelize/models/Ad.js +0 -209
- package/agrs-sequelize/models/AdAccount.js +0 -91
- package/agrs-sequelize/models/AdAccountValues.js +0 -26
- package/agrs-sequelize/models/AdHistory.js +0 -30
- package/agrs-sequelize/models/AdPerformance.js +0 -84
- package/agrs-sequelize/models/AdPerformanceHourly.js +0 -66
- package/agrs-sequelize/models/AdSet.js +0 -140
- package/agrs-sequelize/models/AdSetHistory.js +0 -30
- package/agrs-sequelize/models/AdsetPerformance.js +0 -116
- package/agrs-sequelize/models/Article.js +0 -156
- package/agrs-sequelize/models/Buyers.js +0 -26
- package/agrs-sequelize/models/Campaign.js +0 -136
- package/agrs-sequelize/models/CampaignCreationLog.js +0 -86
- package/agrs-sequelize/models/CampaignHistory.js +0 -33
- package/agrs-sequelize/models/Channel.js +0 -55
- package/agrs-sequelize/models/CodefuelCampaign.js +0 -159
- package/agrs-sequelize/models/CodefuelCampaignKWHistory.js +0 -41
- package/agrs-sequelize/models/CodefuelKeywords.js +0 -35
- package/agrs-sequelize/models/CurrencyRate.js +0 -27
- package/agrs-sequelize/models/Domain.js +0 -26
- package/agrs-sequelize/models/ExplorAdsChannel.js +0 -62
- package/agrs-sequelize/models/Feed.js +0 -34
- package/agrs-sequelize/models/Files.js +0 -73
- package/agrs-sequelize/models/Folders.js +0 -133
- package/agrs-sequelize/models/KeywordPerformance.js +0 -99
- package/agrs-sequelize/models/KeywordRotationState.js +0 -51
- package/agrs-sequelize/models/Pages.js +0 -74
- package/agrs-sequelize/models/PipelineExecution.js +0 -46
- package/agrs-sequelize/models/RSOCFeedCampaign.js +0 -302
- package/agrs-sequelize/models/RsocKeywordPerformance.js +0 -111
- package/agrs-sequelize/models/Rule.js +0 -39
- package/agrs-sequelize/models/RulesValues.js +0 -56
- package/agrs-sequelize/models/SupportedLocale.js +0 -24
- package/agrs-sequelize/models/TonicCampaign.js +0 -97
- package/agrs-sequelize/models/Users.js +0 -111
- package/agrs-sequelize/models/Vertical.js +0 -26
- package/agrs-sequelize/models/newFiles.js +0 -68
- package/agrs-sequelize/models/pixel.js +0 -33
- package/agrs-sequelize/models/pixels.js +0 -33
- package/agrs-sequelize/package-lock.json +0 -405
- package/agrs-sequelize/package.json +0 -19
- package/agrs-sequelize/run.ps1 +0 -98
- package/agrs-sequelize/run.sh +0 -214
package/models/Ad.js
CHANGED
|
@@ -21,10 +21,6 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
21
21
|
creativeId: {
|
|
22
22
|
type: DataTypes.STRING,
|
|
23
23
|
allowNull: true,
|
|
24
|
-
// references: {
|
|
25
|
-
// model: "AdCreatives", // Assuming you have an AdCreative model
|
|
26
|
-
// key: "id",
|
|
27
|
-
// },
|
|
28
24
|
},
|
|
29
25
|
pixelId: {
|
|
30
26
|
type: DataTypes.STRING,
|
|
@@ -44,27 +40,27 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
44
40
|
defaultValue: "SINGLE",
|
|
45
41
|
},
|
|
46
42
|
imageHashes: {
|
|
47
|
-
type: DataTypes.ARRAY(DataTypes.STRING),
|
|
43
|
+
type: DataTypes.ARRAY(DataTypes.STRING),
|
|
48
44
|
allowNull: true,
|
|
49
45
|
},
|
|
50
46
|
videoIds: {
|
|
51
|
-
type: DataTypes.ARRAY(DataTypes.STRING),
|
|
47
|
+
type: DataTypes.ARRAY(DataTypes.STRING),
|
|
52
48
|
allowNull: true,
|
|
53
49
|
},
|
|
54
50
|
messages: {
|
|
55
|
-
type: DataTypes.ARRAY(DataTypes.TEXT),
|
|
51
|
+
type: DataTypes.ARRAY(DataTypes.TEXT),
|
|
56
52
|
allowNull: true,
|
|
57
53
|
},
|
|
58
54
|
headlines: {
|
|
59
|
-
type: DataTypes.ARRAY(DataTypes.TEXT),
|
|
55
|
+
type: DataTypes.ARRAY(DataTypes.TEXT),
|
|
60
56
|
allowNull: true,
|
|
61
57
|
},
|
|
62
58
|
websiteUrl: {
|
|
63
|
-
type: DataTypes.TEXT,
|
|
59
|
+
type: DataTypes.TEXT,
|
|
64
60
|
allowNull: true,
|
|
65
61
|
},
|
|
66
62
|
pageId: {
|
|
67
|
-
type: DataTypes.STRING(256),
|
|
63
|
+
type: DataTypes.STRING(256),
|
|
68
64
|
allowNull: true,
|
|
69
65
|
},
|
|
70
66
|
actionTypes: {
|
|
@@ -98,17 +94,14 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
98
94
|
type: DataTypes.STRING,
|
|
99
95
|
allowNull: true,
|
|
100
96
|
},
|
|
101
|
-
// add effective_status field
|
|
102
97
|
effectiveStatus: {
|
|
103
98
|
type: DataTypes.STRING,
|
|
104
99
|
allowNull: true,
|
|
105
100
|
},
|
|
106
|
-
// add issues_info field
|
|
107
101
|
issuesInfo: {
|
|
108
102
|
type: DataTypes.JSONB,
|
|
109
103
|
allowNull: true,
|
|
110
104
|
},
|
|
111
|
-
// add ad_review_feedback
|
|
112
105
|
adReviewFeedback: {
|
|
113
106
|
type: DataTypes.JSONB,
|
|
114
107
|
allowNull: true,
|
|
@@ -122,44 +115,27 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
122
115
|
tableName: "Ad",
|
|
123
116
|
indexes: [
|
|
124
117
|
{
|
|
125
|
-
fields: ["AdSetID"],
|
|
118
|
+
fields: ["AdSetID"],
|
|
126
119
|
},
|
|
127
120
|
],
|
|
128
121
|
}
|
|
129
122
|
);
|
|
130
123
|
|
|
131
|
-
// Ad.associate = (models) => {
|
|
132
|
-
// Ad.belongsTo(models.AdSet, { foreignKey: "AdSetID" });
|
|
133
|
-
|
|
134
|
-
// // Association with CodefuelCampaign using AGRS_CID
|
|
135
|
-
// Ad.belongsTo(models.CodefuelCampaign, {
|
|
136
|
-
// foreignKey: "AGRS_CID",
|
|
137
|
-
// targetKey: "AGRSCID",
|
|
138
|
-
// as: "CodefuelCampaign",
|
|
139
|
-
// constraints: false, // Disable FK constraint at the DB level
|
|
140
|
-
// });
|
|
141
|
-
|
|
142
|
-
// Ad.hasMany(models.AdPerformance, {
|
|
143
|
-
// foreignKey: "AdID",
|
|
144
|
-
// });
|
|
145
|
-
// };
|
|
146
|
-
|
|
147
124
|
Ad.associate = (models) => {
|
|
148
125
|
Ad.belongsTo(models.AdSet, { foreignKey: "AdSetID" });
|
|
149
126
|
|
|
150
|
-
// Add dynamic relations to either CodefuelCampaign or RSOCFeedCampaign
|
|
151
127
|
Ad.belongsTo(models.CodefuelCampaign, {
|
|
152
128
|
foreignKey: "AGRS_CID",
|
|
153
129
|
targetKey: "AGRSCID",
|
|
154
130
|
as: "CodefuelCampaign",
|
|
155
|
-
constraints: false,
|
|
131
|
+
constraints: false,
|
|
156
132
|
});
|
|
157
133
|
|
|
158
134
|
Ad.belongsTo(models.RSOCFeedCampaign, {
|
|
159
135
|
foreignKey: "AGRS_CID",
|
|
160
136
|
targetKey: "AGRS_CID",
|
|
161
137
|
as: "RSOCFeedCampaign",
|
|
162
|
-
constraints: false,
|
|
138
|
+
constraints: false,
|
|
163
139
|
});
|
|
164
140
|
|
|
165
141
|
Ad.hasMany(models.AdPerformance, {
|
|
@@ -167,46 +143,6 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
167
143
|
});
|
|
168
144
|
};
|
|
169
145
|
|
|
170
|
-
// // Method to dynamically fetch related campaign
|
|
171
|
-
// Ad.prototype.getRelatedCampaign = async function () {
|
|
172
|
-
// if (!this.AGRS_CID) return null;
|
|
173
|
-
|
|
174
|
-
// const codefuelCampaign = await sequelize.models.CodefuelCampaign.findOne({
|
|
175
|
-
// where: { AGRSCID: this.AGRS_CID },
|
|
176
|
-
// });
|
|
177
|
-
|
|
178
|
-
// if (codefuelCampaign) {
|
|
179
|
-
// return {
|
|
180
|
-
// type: "CodefuelCampaign",
|
|
181
|
-
// data: codefuelCampaign,
|
|
182
|
-
// };
|
|
183
|
-
// }
|
|
184
|
-
|
|
185
|
-
// const tonicCampaign = await sequelize.models.TonicCampaign.findOne({
|
|
186
|
-
// where: { AGRSCID: this.AGRS_CID },
|
|
187
|
-
// });
|
|
188
|
-
|
|
189
|
-
// if (tonicCampaign) {
|
|
190
|
-
// return {
|
|
191
|
-
// type: "TonicCampaign",
|
|
192
|
-
// data: tonicCampaign,
|
|
193
|
-
// };
|
|
194
|
-
// }
|
|
195
|
-
|
|
196
|
-
// // do the same with RSOCFeedCampaign
|
|
197
|
-
// const rsocFeedCampaign = await sequelize.models.RSOCFeedCampaign.findOne({
|
|
198
|
-
// where: { AGRS_CID: this.AGRS_CID },
|
|
199
|
-
// });
|
|
200
|
-
|
|
201
|
-
// if (rsocFeedCampaign) {
|
|
202
|
-
// return {
|
|
203
|
-
// type: "RSOCFeedCampaign",
|
|
204
|
-
// data: rsocFeedCampaign,
|
|
205
|
-
// };
|
|
206
|
-
// }
|
|
207
|
-
// return null;
|
|
208
|
-
// };
|
|
209
|
-
|
|
210
146
|
Ad.prototype.getRelatedCampaign = async function () {
|
|
211
147
|
if (!this.AGRS_CID) return null;
|
|
212
148
|
|
package/models/AdSet.js
CHANGED
|
@@ -1,147 +1,3 @@
|
|
|
1
|
-
// module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
// const AdSet = sequelize.define(
|
|
3
|
-
// "AdSet",
|
|
4
|
-
// {
|
|
5
|
-
// AdSetID: {
|
|
6
|
-
// type: DataTypes.STRING,
|
|
7
|
-
// primaryKey: true,
|
|
8
|
-
// },
|
|
9
|
-
// AdSetName: {
|
|
10
|
-
// type: DataTypes.STRING,
|
|
11
|
-
// allowNull: true,
|
|
12
|
-
// },
|
|
13
|
-
// Status: {
|
|
14
|
-
// type: DataTypes.STRING,
|
|
15
|
-
// allowNull: true,
|
|
16
|
-
// },
|
|
17
|
-
// daily_budget: {
|
|
18
|
-
// type: DataTypes.INTEGER,
|
|
19
|
-
// allowNull: true,
|
|
20
|
-
// },
|
|
21
|
-
// start_time: {
|
|
22
|
-
// type: DataTypes.DATE,
|
|
23
|
-
// allowNull: true,
|
|
24
|
-
// },
|
|
25
|
-
// end_time: {
|
|
26
|
-
// type: DataTypes.DATE,
|
|
27
|
-
// allowNull: true,
|
|
28
|
-
// },
|
|
29
|
-
// targeting: {
|
|
30
|
-
// type: DataTypes.JSONB,
|
|
31
|
-
// allowNull: true,
|
|
32
|
-
// },
|
|
33
|
-
// promotedObject: {
|
|
34
|
-
// type: DataTypes.JSONB, // Storing promoted object as a JSON object
|
|
35
|
-
// allowNull: true,
|
|
36
|
-
// },
|
|
37
|
-
// BillingEvent: {
|
|
38
|
-
// type: DataTypes.STRING,
|
|
39
|
-
// allowNull: false,
|
|
40
|
-
// defaultValue: "impressions", // Default value for BillingEvent
|
|
41
|
-
// },
|
|
42
|
-
// OptimizationGoal: {
|
|
43
|
-
// type: DataTypes.STRING,
|
|
44
|
-
// allowNull: false,
|
|
45
|
-
// defaultValue: "offsite_conversions", // Default value for OptimizationGoal
|
|
46
|
-
// },
|
|
47
|
-
// Draft: {
|
|
48
|
-
// type: DataTypes.BOOLEAN,
|
|
49
|
-
// allowNull: true,
|
|
50
|
-
// defaultValue: false,
|
|
51
|
-
// },
|
|
52
|
-
// UserCreated: {
|
|
53
|
-
// type: DataTypes.STRING,
|
|
54
|
-
// allowNull: true,
|
|
55
|
-
// },
|
|
56
|
-
// publish: {
|
|
57
|
-
// type: DataTypes.BOOLEAN,
|
|
58
|
-
// allowNull: true,
|
|
59
|
-
// defaultValue: true,
|
|
60
|
-
// },
|
|
61
|
-
// CampaignID: {
|
|
62
|
-
// type: DataTypes.STRING,
|
|
63
|
-
// allowNull: false,
|
|
64
|
-
// references: {
|
|
65
|
-
// model: "Campaign",
|
|
66
|
-
// key: "CampaignID",
|
|
67
|
-
// },
|
|
68
|
-
// },
|
|
69
|
-
// effectiveStatus: {
|
|
70
|
-
// type: DataTypes.STRING,
|
|
71
|
-
// allowNull: true,
|
|
72
|
-
// },
|
|
73
|
-
// // add issues_info field
|
|
74
|
-
// issuesInfo: {
|
|
75
|
-
// type: DataTypes.JSONB,
|
|
76
|
-
// allowNull: true,
|
|
77
|
-
// },
|
|
78
|
-
// bid_strategy: {
|
|
79
|
-
// type: DataTypes.STRING,
|
|
80
|
-
// allowNull: true,
|
|
81
|
-
// },
|
|
82
|
-
// // bid amount
|
|
83
|
-
// bid_amount: {
|
|
84
|
-
// type: DataTypes.INTEGER,
|
|
85
|
-
// allowNull: true,
|
|
86
|
-
// },
|
|
87
|
-
// waiting: {
|
|
88
|
-
// type: DataTypes.BOOLEAN,
|
|
89
|
-
// defaultValue: false,
|
|
90
|
-
// },
|
|
91
|
-
// },
|
|
92
|
-
// {
|
|
93
|
-
// tableName: "AdSet",
|
|
94
|
-
// indexes: [
|
|
95
|
-
// {
|
|
96
|
-
// fields: ["CampaignID"], // Index on CampaignID for faster join
|
|
97
|
-
// },
|
|
98
|
-
// ],
|
|
99
|
-
// }
|
|
100
|
-
// );
|
|
101
|
-
|
|
102
|
-
// AdSet.associate = (models) => {
|
|
103
|
-
// AdSet.belongsTo(models.Campaign, { foreignKey: "CampaignID" });
|
|
104
|
-
// AdSet.hasMany(models.Ad, { foreignKey: "AdSetID" });
|
|
105
|
-
// };
|
|
106
|
-
|
|
107
|
-
// AdSet.addHook("beforeUpdate", async (adSet, options) => {
|
|
108
|
-
// if (adSet.changed("publish")) {
|
|
109
|
-
// if (adSet.previous("publish") === true && adSet.publish === false) {
|
|
110
|
-
// // Save current state to AdSetHistory
|
|
111
|
-
// await sequelize.models.AdSetHistory.create({
|
|
112
|
-
// AdSetID: adSet.AdSetID,
|
|
113
|
-
// DataSnapshot: adSet._previousDataValues, // Save the full AdSet data as JSON
|
|
114
|
-
// });
|
|
115
|
-
// } else if (
|
|
116
|
-
// adSet.previous("publish") === false &&
|
|
117
|
-
// adSet.publish === true
|
|
118
|
-
// ) {
|
|
119
|
-
// // Delete the latest history entry
|
|
120
|
-
// const latestHistory = await sequelize.models.AdSetHistory.findOne({
|
|
121
|
-
// where: { AdSetID: adSet.AdSetID },
|
|
122
|
-
// order: [["timestamp", "DESC"]], // Get the latest history entry
|
|
123
|
-
// });
|
|
124
|
-
|
|
125
|
-
// if (latestHistory) {
|
|
126
|
-
// await latestHistory.destroy();
|
|
127
|
-
// }
|
|
128
|
-
// }
|
|
129
|
-
// }
|
|
130
|
-
// });
|
|
131
|
-
|
|
132
|
-
// AdSet.addHook("afterCreate", async (adSet, options) => {
|
|
133
|
-
// if (adSet.publish === false) {
|
|
134
|
-
// // If publish is false on creation, save a snapshot to AdSetHistory
|
|
135
|
-
// await sequelize.models.AdSetHistory.create({
|
|
136
|
-
// AdSetID: adSet.AdSetID,
|
|
137
|
-
// DataSnapshot: adSet.toJSON(), // Save the full AdSet data as JSON
|
|
138
|
-
// });
|
|
139
|
-
// }
|
|
140
|
-
// });
|
|
141
|
-
|
|
142
|
-
// return AdSet;
|
|
143
|
-
// };
|
|
144
|
-
|
|
145
1
|
module.exports = (sequelize, DataTypes) => {
|
|
146
2
|
const AdSet = sequelize.define(
|
|
147
3
|
"AdSet",
|
|
@@ -158,6 +158,15 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
158
158
|
constraints: false,
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
+
|
|
162
|
+
if (models.Ad) {
|
|
163
|
+
RSOCFeedCampaign.hasMany(models.Ad, {
|
|
164
|
+
foreignKey: "AGRS_CID",
|
|
165
|
+
sourceKey: "AGRS_CID",
|
|
166
|
+
as: "Ads",
|
|
167
|
+
constraints: false,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
161
170
|
};
|
|
162
171
|
|
|
163
172
|
// BeforeCreate hook: Update Channel status and connectedCampaigns
|
|
@@ -281,7 +290,7 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
281
290
|
}
|
|
282
291
|
} else {
|
|
283
292
|
console.warn(
|
|
284
|
-
`
|
|
293
|
+
`Channel not found for channelId: ${newChannelId}, styleId: ${newStyleId}`
|
|
285
294
|
);
|
|
286
295
|
}
|
|
287
296
|
} catch (error) {
|
package/package.json
CHANGED
package/agrs-sequelize/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Agressive Scale LTD
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/agrs-sequelize/README.md
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
# agrs-sequelize SDK
|
|
2
|
-
|
|
3
|
-
The `agrs-sequelize` SDK provides a structured way to manage your database models using Sequelize ORM. It allows you to easily add, update, and manage models, with support for publishing updates to NPM and pushing changes to GitHub.
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [Prerequisites](#prerequisites)
|
|
8
|
-
- [Installation](#installation)
|
|
9
|
-
- [Usage](#usage)
|
|
10
|
-
- [Adding or Modifying Models](#adding-or-modifying-models)
|
|
11
|
-
- [Model Loading](#model-loading)
|
|
12
|
-
- [Publishing Changes](#publishing-changes)
|
|
13
|
-
- [Using PowerShell (Windows)](#using-powershell-windows)
|
|
14
|
-
- [Using Bash (Linux/macOS)](#using-bash-linuxmacos)
|
|
15
|
-
- [Script Details](#script-details)
|
|
16
|
-
- [run.ps1 (PowerShell Script for Windows)](#runps1-powershell-script-for-windows)
|
|
17
|
-
- [run.sh (Bash Script for Linux/macOS)](#runsh-bash-script-for-linuxmacos)
|
|
18
|
-
- [Example Model File](#example-model-file)
|
|
19
|
-
- [Versioning](#versioning)
|
|
20
|
-
- [Troubleshooting](#troubleshooting)
|
|
21
|
-
- [License](#license)
|
|
22
|
-
|
|
23
|
-
## Prerequisites
|
|
24
|
-
|
|
25
|
-
Ensure the following dependencies are installed on your system:
|
|
26
|
-
|
|
27
|
-
- **Node.js**: [Download Node.js](https://nodejs.org/)
|
|
28
|
-
- **Sequelize**: Used for database interaction.
|
|
29
|
-
- **Git**: Required for version control and publishing changes to GitHub.
|
|
30
|
-
- **npm**: For managing and publishing packages.
|
|
31
|
-
- **PowerShell** (Windows) or **Bash** (Linux/macOS): For running automation scripts.
|
|
32
|
-
|
|
33
|
-
## Installation
|
|
34
|
-
|
|
35
|
-
1. **Clone the Repository:**
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
git clone https://github.com/your-repo/agrs-sequelize.git
|
|
39
|
-
cd agrs-sequelize
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
2. **Install Dependencies:**
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
npm install
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
# Usage
|
|
50
|
-
|
|
51
|
-
## Adding or Modifying Models
|
|
52
|
-
To add or modify models in the agrs-sequelize SDK:
|
|
53
|
-
|
|
54
|
-
1. **Create or Edit a Model:**
|
|
55
|
-
|
|
56
|
-
- Add a new model file inside the models directory or edit an existing one.
|
|
57
|
-
- Each model file should export a function that initializes the model with Sequelize.
|
|
58
|
-
|
|
59
|
-
```javascript
|
|
60
|
-
// models/YourModel.js
|
|
61
|
-
module.exports = (sequelize, DataTypes) => {
|
|
62
|
-
const YourModel = sequelize.define('YourModel', {
|
|
63
|
-
fieldName: {
|
|
64
|
-
type: DataTypes.STRING,
|
|
65
|
-
allowNull: false,
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
// Define associations (optional)
|
|
70
|
-
YourModel.associate = (models) => {
|
|
71
|
-
YourModel.hasMany(models.OtherModel);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
return YourModel;
|
|
75
|
-
};
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
2. **Define Associations (if required):**
|
|
79
|
-
|
|
80
|
-
Use the associate method to define relationships with other models.
|
|
81
|
-
Associations like hasMany, belongsTo, etc., are supported.
|
|
82
|
-
### Model Loading
|
|
83
|
-
Models are automatically loaded when initializing Sequelize.
|
|
84
|
-
The index.js file ensures all models in the models directory are properly loaded and associated.
|
|
85
|
-
|
|
86
|
-
## Publishing Changes
|
|
87
|
-
After modifying or adding models, publish the changes to NPM and GitHub.
|
|
88
|
-
|
|
89
|
-
### Using PowerShell (Windows)
|
|
90
|
-
Open PowerShell as Administrator.
|
|
91
|
-
|
|
92
|
-
Run the Script:
|
|
93
|
-
|
|
94
|
-
```powershell
|
|
95
|
-
./run.ps1
|
|
96
|
-
```
|
|
97
|
-
The script will:
|
|
98
|
-
|
|
99
|
-
- Check for jq installation.
|
|
100
|
-
- Bump the version in package.json.
|
|
101
|
-
- Publish to NPM.
|
|
102
|
-
- Commit and push changes to GitHub.
|
|
103
|
-
|
|
104
|
-
### Using Bash (Linux/macOS)
|
|
105
|
-
Open a Bash Terminal.
|
|
106
|
-
|
|
107
|
-
Run the Script:
|
|
108
|
-
|
|
109
|
-
```bash
|
|
110
|
-
./run.sh
|
|
111
|
-
```
|
|
112
|
-
The script performs the same tasks as the PowerShell script, tailored for Bash environments.
|
|
113
|
-
|
|
114
|
-
## Script Details
|
|
115
|
-
### run.ps1 (PowerShell Script for Windows)
|
|
116
|
-
Automates the publishing process:
|
|
117
|
-
|
|
118
|
-
- Ensures jq is installed.
|
|
119
|
-
- Increments the version in package.json.
|
|
120
|
-
- Publishes the package to NPM.
|
|
121
|
-
- Commits and pushes changes to GitHub.
|
|
122
|
-
|
|
123
|
-
### run.sh (Bash Script for Linux/macOS)
|
|
124
|
-
Provides similar functionality:
|
|
125
|
-
|
|
126
|
-
- Checks for jq installation.
|
|
127
|
-
- Bumps the package version.
|
|
128
|
-
= Publishes to NPM.
|
|
129
|
-
= Commits and pushes to GitHub.
|
|
130
|
-
|
|
131
|
-
## Example Model File
|
|
132
|
-
```javascript
|
|
133
|
-
Copy code
|
|
134
|
-
// models/YourModel.js
|
|
135
|
-
module.exports = (sequelize, DataTypes) => {
|
|
136
|
-
const YourModel = sequelize.define('YourModel', {
|
|
137
|
-
name: {
|
|
138
|
-
type: DataTypes.STRING,
|
|
139
|
-
allowNull: false,
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
// Define associations (optional)
|
|
144
|
-
YourModel.associate = (models) => {
|
|
145
|
-
YourModel.hasMany(models.OtherModel);
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
return YourModel;
|
|
149
|
-
};
|
|
150
|
-
```
|
|
151
|
-
In this example:
|
|
152
|
-
|
|
153
|
-
YourModel has a name field.
|
|
154
|
-
It has a hasMany association with OtherModel.
|
|
155
|
-
## Versioning
|
|
156
|
-
Versioning is handled automatically:
|
|
157
|
-
|
|
158
|
-
- The scripts increment the version in package.json.
|
|
159
|
-
- Follows semantic versioning (major, minor, patch).
|
|
160
|
-
- Updated versions are published to NPM and committed to the repository.
|
|
161
|
-
|
|
162
|
-
## Troubleshooting
|
|
163
|
-
- ### Permission Issues:
|
|
164
|
-
|
|
165
|
-
- Linux/macOS: Ensure scripts have execute permissions (chmod +x run.sh).
|
|
166
|
-
- ### NPM Login Errors:
|
|
167
|
-
|
|
168
|
-
- The script will prompt for NPM login if not already logged in.
|
|
169
|
-
- Verify NPM account credentials.
|
|
170
|
-
|
|
171
|
-
- ### Missing Dependencies:
|
|
172
|
-
|
|
173
|
-
- The script checks for jq and installs it if missing.
|
|
174
|
-
## License
|
|
175
|
-
This project is licensed under the MIT License. See the LICENSE file for details.
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|