agrs-sequelize-sdk 1.3.29 → 1.3.34

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.
@@ -200,6 +200,12 @@ module.exports = (sequelize, DataTypes) => {
200
200
  sourceKey: "requestId",
201
201
  as: "logs",
202
202
  });
203
+ // ✅ NEW: One request can have many generated files
204
+ AIGenerationRequest.hasMany(models.NewFiles, {
205
+ foreignKey: "generationRequestId",
206
+ sourceKey: "requestId",
207
+ as: "generatedFiles",
208
+ });
203
209
  };
204
210
 
205
211
  return AIGenerationRequest;
@@ -132,6 +132,11 @@ module.exports = (sequelize, DataTypes) => {
132
132
  allowNull: true,
133
133
  comment: "black, blue, green, white",
134
134
  },
135
+ ads_category: {
136
+ type: DataTypes.STRING(10),
137
+ allowNull: true,
138
+ comment: "l (Low), m (Medium), h (High)",
139
+ },
135
140
  ad_title: {
136
141
  type: DataTypes.STRING(500),
137
142
  allowNull: true,
package/models/Users.js CHANGED
@@ -1,124 +1,124 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const Users = sequelize.define(
3
- "Users",
4
- {
5
- id: {
6
- type: DataTypes.UUID, // Use UUID for the primary key
7
- defaultValue: DataTypes.UUIDV4, // Automatically generate a UUID
8
- primaryKey: true, // Set as primary key
9
- },
10
- Username: {
11
- type: DataTypes.STRING,
12
- allowNull: false,
13
- unique: true,
14
- },
15
- Image: {
16
- type: DataTypes.STRING,
17
- allowNull: true,
18
- },
19
- Email: {
20
- type: DataTypes.STRING,
21
- allowNull: true,
22
- unique: true,
23
- },
24
- // add name field
25
- Name: {
26
- type: DataTypes.STRING,
27
- allowNull: false,
28
- },
29
- Password: {
30
- type: DataTypes.STRING(1024), // Store hash with max length 256
31
- allowNull: false,
32
- },
33
- Roles: {
34
- type: DataTypes.ARRAY(DataTypes.STRING), // Array of roles
35
- allowNull: true,
36
- defaultValue: [],
37
- },
38
- Features: {
39
- type: DataTypes.ARRAY(DataTypes.STRING), // Array of features
40
- allowNull: true,
41
- defaultValue: [],
42
- },
43
- Accounts: {
44
- type: DataTypes.ARRAY(DataTypes.STRING), // Array of account IDs
45
- allowNull: true,
46
- defaultValue: [],
47
- },
48
- MediaBuyers: {
49
- type: DataTypes.ARRAY(DataTypes.STRING), // Array of account IDs
50
- allowNull: true,
51
- defaultValue: [],
52
- },
53
- Pages: {
54
- type: DataTypes.ARRAY(DataTypes.STRING), // Array of account IDs
55
- allowNull: true,
56
- defaultValue: [],
57
- },
58
- FeedProvider: {
59
- type: DataTypes.ARRAY(DataTypes.STRING), // Array of static feed names (predicto, mine, etc.)
60
- allowNull: true,
61
- defaultValue: [],
62
- },
63
- DynamicFeedIds: {
64
- type: DataTypes.ARRAY(DataTypes.UUID), // Array of UUIDs referencing dynamic_feeds.id
65
- allowNull: true,
66
- defaultValue: [],
67
- },
68
- Organization: {
69
- type: DataTypes.ARRAY(DataTypes.STRING), // Array of organization IDs
70
- allowNull: true,
71
- defaultValue: [],
72
- },
73
- Tier2Accounts: {
74
- type: DataTypes.ARRAY(DataTypes.STRING), // Array of Tier2 Ad Account Facebook IDs
75
- allowNull: true,
76
- defaultValue: [],
77
- },
78
- LastEntrance: {
79
- type: DataTypes.DATE, // Array of organization IDs
80
- allowNull: true,
81
- defaultValue: [],
82
- },
83
- Status: {
84
- type: DataTypes.STRING, // Array of organization IDs
85
- allowNull: true,
86
- },
87
- access_all_files: {
88
- type: DataTypes.BOOLEAN,
89
- allowNull: true,
90
- },
91
- managed_by: {
92
- type: DataTypes.UUID, // A UUID to store the ID of the user who manages this user
93
- allowNull: true,
94
- references: {
95
- model: "Users",
96
- key: "id",
97
- },
98
- },
99
- },
100
- {
101
- tableName: "Users",
102
- }
103
- );
104
-
105
- // Define associations for managed_by relationship
106
- Users.associate = (models) => {
107
- // A user can manage many users
108
- Users.hasMany(models.Users, {
109
- foreignKey: "managed_by",
110
- as: "managedUsers",
111
- });
112
-
113
- // A user can only be managed by one user
114
- Users.belongsTo(models.Users, {
115
- foreignKey: "managed_by",
116
- as: "manager",
117
- });
118
-
119
- // A user can have many presets
120
- Users.hasMany(models.Presets, { foreignKey: "userId", as: "presets" });
121
- };
122
-
123
- return Users;
124
- };
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const Users = sequelize.define(
3
+ "Users",
4
+ {
5
+ id: {
6
+ type: DataTypes.UUID, // Use UUID for the primary key
7
+ defaultValue: DataTypes.UUIDV4, // Automatically generate a UUID
8
+ primaryKey: true, // Set as primary key
9
+ },
10
+ Username: {
11
+ type: DataTypes.STRING,
12
+ allowNull: false,
13
+ unique: true,
14
+ },
15
+ Image: {
16
+ type: DataTypes.STRING,
17
+ allowNull: true,
18
+ },
19
+ Email: {
20
+ type: DataTypes.STRING,
21
+ allowNull: true,
22
+ unique: true,
23
+ },
24
+ // add name field
25
+ Name: {
26
+ type: DataTypes.STRING,
27
+ allowNull: false,
28
+ },
29
+ Password: {
30
+ type: DataTypes.STRING(1024), // Store hash with max length 256
31
+ allowNull: false,
32
+ },
33
+ Roles: {
34
+ type: DataTypes.ARRAY(DataTypes.STRING), // Array of roles
35
+ allowNull: true,
36
+ defaultValue: [],
37
+ },
38
+ Features: {
39
+ type: DataTypes.ARRAY(DataTypes.STRING), // Array of features
40
+ allowNull: true,
41
+ defaultValue: [],
42
+ },
43
+ Accounts: {
44
+ type: DataTypes.ARRAY(DataTypes.STRING), // Array of account IDs
45
+ allowNull: true,
46
+ defaultValue: [],
47
+ },
48
+ MediaBuyers: {
49
+ type: DataTypes.ARRAY(DataTypes.STRING), // Array of account IDs
50
+ allowNull: true,
51
+ defaultValue: [],
52
+ },
53
+ Pages: {
54
+ type: DataTypes.ARRAY(DataTypes.STRING), // Array of account IDs
55
+ allowNull: true,
56
+ defaultValue: [],
57
+ },
58
+ FeedProvider: {
59
+ type: DataTypes.ARRAY(DataTypes.STRING), // Array of static feed names (predicto, mine, etc.)
60
+ allowNull: true,
61
+ defaultValue: [],
62
+ },
63
+ DynamicFeedIds: {
64
+ type: DataTypes.ARRAY(DataTypes.UUID), // Array of UUIDs referencing dynamic_feeds.id
65
+ allowNull: true,
66
+ defaultValue: [],
67
+ },
68
+ Organization: {
69
+ type: DataTypes.ARRAY(DataTypes.STRING), // Array of organization IDs
70
+ allowNull: true,
71
+ defaultValue: [],
72
+ },
73
+ Tier2Accounts: {
74
+ type: DataTypes.ARRAY(DataTypes.STRING), // Array of Tier2 Ad Account Facebook IDs
75
+ allowNull: true,
76
+ defaultValue: [],
77
+ },
78
+ LastEntrance: {
79
+ type: DataTypes.DATE, // Array of organization IDs
80
+ allowNull: true,
81
+ defaultValue: [],
82
+ },
83
+ Status: {
84
+ type: DataTypes.STRING, // Array of organization IDs
85
+ allowNull: true,
86
+ },
87
+ access_all_files: {
88
+ type: DataTypes.BOOLEAN,
89
+ allowNull: true,
90
+ },
91
+ managed_by: {
92
+ type: DataTypes.UUID, // A UUID to store the ID of the user who manages this user
93
+ allowNull: true,
94
+ references: {
95
+ model: "Users",
96
+ key: "id",
97
+ },
98
+ },
99
+ },
100
+ {
101
+ tableName: "Users",
102
+ }
103
+ );
104
+
105
+ // Define associations for managed_by relationship
106
+ Users.associate = (models) => {
107
+ // A user can manage many users
108
+ Users.hasMany(models.Users, {
109
+ foreignKey: "managed_by",
110
+ as: "managedUsers",
111
+ });
112
+
113
+ // A user can only be managed by one user
114
+ Users.belongsTo(models.Users, {
115
+ foreignKey: "managed_by",
116
+ as: "manager",
117
+ });
118
+
119
+ // A user can have many presets
120
+ Users.hasMany(models.Presets, { foreignKey: "userId", as: "presets" });
121
+ };
122
+
123
+ return Users;
124
+ };
@@ -109,7 +109,29 @@ module.exports = (sequelize, DataTypes) => {
109
109
  allowNull: true,
110
110
  comment: 'Text extracted from image/video using Gemini Vision API',
111
111
  },
112
+ // AI Generation Settings - stores all generation parameters for AI-generated files
113
+ generationSettings: {
114
+ type: DataTypes.JSONB,
115
+ allowNull: true,
116
+ comment: 'Generation settings from AdvancedCreativeGenerator (style, colors, layout, etc.)',
117
+ },
118
+ // AI Generation Request ID - link to AIGenerationRequest table
119
+ generationRequestId: {
120
+ type: DataTypes.STRING,
121
+ allowNull: true,
122
+ comment: 'Request ID from AIGenerationRequest table if this file was AI-generated',
123
+ },
112
124
  });
113
125
 
126
+ // ✅ Associations
127
+ NewFiles.associate = function (models) {
128
+ // File belongs to a generation request
129
+ NewFiles.belongsTo(models.AIGenerationRequest, {
130
+ foreignKey: "generationRequestId",
131
+ targetKey: "requestId",
132
+ as: "generationRequest",
133
+ });
134
+ };
135
+
114
136
  return NewFiles;
115
137
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agrs-sequelize-sdk",
3
- "version": "1.3.29",
3
+ "version": "1.3.34",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "start": "node index.js",