agrs-sequelize-sdk 1.4.19 → 1.4.22
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/migrations/2026-05-18-add-group-id-to-ai-campaign-queue.js +18 -0
- package/migrations/2026-05-18-add-platform-code-to-creation-logs.js +65 -0
- package/migrations/2026-05-18-add-platform-code-to-pixels.js +55 -0
- package/migrations/2026-05-18-add-platform-code-to-rsoc-feed-campaigns.js +55 -0
- package/migrations/2026-05-18-add-platform-date-index-to-adperformance.js +16 -0
- package/migrations/2026-05-18-add-platform-date-index-to-adsetperformance.js +16 -0
- package/migrations/2026-05-18-add-review-status-to-ad.js +36 -0
- package/migrations/2026-05-18-create-canonical-insights.js +84 -0
- package/migrations/2026-05-18-create-snapchat-public-profiles.js +68 -0
- package/migrations/2026-05-18-create-tiktok-identities.js +71 -0
- package/migrations/2026-05-18-create-tiktok-snapchat-campaigns.js +143 -0
- package/migrations/2026-05-18-create-tt-snp-adset-ad-tables.js +309 -0
- package/models/AICampaignQueue.js +9 -0
- package/models/Ad.js +12 -0
- package/models/AdPerformance.js +4 -0
- package/models/AdsetPerformance.js +5 -0
- package/models/CampaignCreationLog.js +12 -0
- package/models/CampaignCreationLogV2.js +8 -0
- package/models/CanonicalInsights.js +68 -0
- package/models/RSOCFeedCampaign.js +6 -0
- package/models/SnapchatAd.js +69 -0
- package/models/SnapchatAdSquad.js +92 -0
- package/models/SnapchatCampaign.js +69 -0
- package/models/SnapchatPublicProfiles.js +47 -0
- package/models/TikTokAd.js +71 -0
- package/models/TikTokAdGroup.js +82 -0
- package/models/TikTokCampaign.js +71 -0
- package/models/TiktokIdentities.js +51 -0
- package/models/Users.js +10 -0
- package/models/pixel.js +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) =>
|
|
2
|
+
sequelize.define(
|
|
3
|
+
"SnapchatCampaign",
|
|
4
|
+
{
|
|
5
|
+
id: {
|
|
6
|
+
type: DataTypes.STRING(36),
|
|
7
|
+
primaryKey: true,
|
|
8
|
+
comment: "Snapchat UUID",
|
|
9
|
+
},
|
|
10
|
+
name: {
|
|
11
|
+
type: DataTypes.STRING(255),
|
|
12
|
+
allowNull: false,
|
|
13
|
+
},
|
|
14
|
+
ad_account_id: {
|
|
15
|
+
type: DataTypes.STRING(36),
|
|
16
|
+
allowNull: false,
|
|
17
|
+
},
|
|
18
|
+
status: {
|
|
19
|
+
type: DataTypes.STRING(50),
|
|
20
|
+
allowNull: false,
|
|
21
|
+
comment: "ACTIVE or PAUSED (Snap native)",
|
|
22
|
+
},
|
|
23
|
+
objective: {
|
|
24
|
+
type: DataTypes.STRING(255),
|
|
25
|
+
allowNull: true,
|
|
26
|
+
},
|
|
27
|
+
daily_budget_micro: {
|
|
28
|
+
type: DataTypes.BIGINT,
|
|
29
|
+
allowNull: true,
|
|
30
|
+
},
|
|
31
|
+
lifetime_spend_cap_micro: {
|
|
32
|
+
type: DataTypes.BIGINT,
|
|
33
|
+
allowNull: true,
|
|
34
|
+
},
|
|
35
|
+
timezone: {
|
|
36
|
+
type: DataTypes.STRING(50),
|
|
37
|
+
allowNull: true,
|
|
38
|
+
},
|
|
39
|
+
start_time: {
|
|
40
|
+
type: DataTypes.DATE,
|
|
41
|
+
allowNull: true,
|
|
42
|
+
},
|
|
43
|
+
end_time: {
|
|
44
|
+
type: DataTypes.DATE,
|
|
45
|
+
allowNull: true,
|
|
46
|
+
},
|
|
47
|
+
created_at: {
|
|
48
|
+
type: DataTypes.DATE,
|
|
49
|
+
allowNull: false,
|
|
50
|
+
},
|
|
51
|
+
updated_at: {
|
|
52
|
+
type: DataTypes.DATE,
|
|
53
|
+
allowNull: true,
|
|
54
|
+
},
|
|
55
|
+
synced_at: {
|
|
56
|
+
type: DataTypes.DATE,
|
|
57
|
+
allowNull: false,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
tableName: "snapchat_campaigns",
|
|
62
|
+
timestamps: false,
|
|
63
|
+
indexes: [
|
|
64
|
+
{ fields: ["ad_account_id"] },
|
|
65
|
+
{ fields: ["created_at"] },
|
|
66
|
+
{ fields: ["status"] },
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const SnapchatPublicProfiles = sequelize.define(
|
|
3
|
+
"SnapchatPublicProfiles",
|
|
4
|
+
{
|
|
5
|
+
id: {
|
|
6
|
+
type: DataTypes.BIGINT,
|
|
7
|
+
primaryKey: true,
|
|
8
|
+
autoIncrement: true,
|
|
9
|
+
},
|
|
10
|
+
public_profile_id: {
|
|
11
|
+
type: DataTypes.STRING(64),
|
|
12
|
+
allowNull: false,
|
|
13
|
+
unique: true,
|
|
14
|
+
comment:
|
|
15
|
+
"Snapchat public_profile_id used as creative owner on ad creation",
|
|
16
|
+
},
|
|
17
|
+
name: {
|
|
18
|
+
type: DataTypes.STRING(255),
|
|
19
|
+
allowNull: true,
|
|
20
|
+
},
|
|
21
|
+
ad_account_id: {
|
|
22
|
+
type: DataTypes.STRING(64),
|
|
23
|
+
allowNull: false,
|
|
24
|
+
comment: "Snapchat ad_account_id this profile belongs to",
|
|
25
|
+
},
|
|
26
|
+
status: {
|
|
27
|
+
type: DataTypes.STRING(16),
|
|
28
|
+
allowNull: false,
|
|
29
|
+
defaultValue: "active",
|
|
30
|
+
comment: "active | disabled",
|
|
31
|
+
},
|
|
32
|
+
tier: {
|
|
33
|
+
type: DataTypes.INTEGER,
|
|
34
|
+
allowNull: false,
|
|
35
|
+
defaultValue: 1,
|
|
36
|
+
comment:
|
|
37
|
+
"Rotation weight. Higher tier => higher probability of being picked.",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
tableName: "snapchat_public_profiles",
|
|
42
|
+
indexes: [{ fields: ["ad_account_id", "status"] }],
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return SnapchatPublicProfiles;
|
|
47
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) =>
|
|
2
|
+
sequelize.define(
|
|
3
|
+
"TikTokAd",
|
|
4
|
+
{
|
|
5
|
+
ad_id: {
|
|
6
|
+
type: DataTypes.BIGINT,
|
|
7
|
+
primaryKey: true,
|
|
8
|
+
},
|
|
9
|
+
ad_name: {
|
|
10
|
+
type: DataTypes.STRING(255),
|
|
11
|
+
allowNull: false,
|
|
12
|
+
},
|
|
13
|
+
adgroup_id: {
|
|
14
|
+
type: DataTypes.BIGINT,
|
|
15
|
+
allowNull: false,
|
|
16
|
+
comment: "TikTok adgroup_id; loose FK to tiktok_adgroups (no DB-level constraint)",
|
|
17
|
+
},
|
|
18
|
+
campaign_id: {
|
|
19
|
+
type: DataTypes.BIGINT,
|
|
20
|
+
allowNull: false,
|
|
21
|
+
},
|
|
22
|
+
ad_account_id: {
|
|
23
|
+
type: DataTypes.STRING(64),
|
|
24
|
+
allowNull: false,
|
|
25
|
+
},
|
|
26
|
+
ad_format: {
|
|
27
|
+
type: DataTypes.STRING(50),
|
|
28
|
+
allowNull: true,
|
|
29
|
+
comment: "SINGLE_VIDEO, SINGLE_IMAGE, etc.",
|
|
30
|
+
},
|
|
31
|
+
identity_id: {
|
|
32
|
+
type: DataTypes.STRING(64),
|
|
33
|
+
allowNull: true,
|
|
34
|
+
comment: "TikTok identity (Page equivalent)",
|
|
35
|
+
},
|
|
36
|
+
landing_page_url: {
|
|
37
|
+
type: DataTypes.TEXT,
|
|
38
|
+
allowNull: true,
|
|
39
|
+
},
|
|
40
|
+
display_name: {
|
|
41
|
+
type: DataTypes.STRING(255),
|
|
42
|
+
allowNull: true,
|
|
43
|
+
},
|
|
44
|
+
operation_status: {
|
|
45
|
+
type: DataTypes.STRING(50),
|
|
46
|
+
allowNull: true,
|
|
47
|
+
comment: "ENABLE or DISABLE (TikTok native)",
|
|
48
|
+
},
|
|
49
|
+
created_at: {
|
|
50
|
+
type: DataTypes.DATE,
|
|
51
|
+
allowNull: false,
|
|
52
|
+
},
|
|
53
|
+
updated_at: {
|
|
54
|
+
type: DataTypes.DATE,
|
|
55
|
+
allowNull: true,
|
|
56
|
+
},
|
|
57
|
+
synced_at: {
|
|
58
|
+
type: DataTypes.DATE,
|
|
59
|
+
allowNull: false,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
tableName: "tiktok_ads",
|
|
64
|
+
timestamps: false,
|
|
65
|
+
indexes: [
|
|
66
|
+
{ fields: ["adgroup_id"] },
|
|
67
|
+
{ fields: ["campaign_id"] },
|
|
68
|
+
{ fields: ["operation_status"] },
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) =>
|
|
2
|
+
sequelize.define(
|
|
3
|
+
"TikTokAdGroup",
|
|
4
|
+
{
|
|
5
|
+
adgroup_id: {
|
|
6
|
+
type: DataTypes.BIGINT,
|
|
7
|
+
primaryKey: true,
|
|
8
|
+
},
|
|
9
|
+
adgroup_name: {
|
|
10
|
+
type: DataTypes.STRING(255),
|
|
11
|
+
allowNull: false,
|
|
12
|
+
},
|
|
13
|
+
campaign_id: {
|
|
14
|
+
type: DataTypes.BIGINT,
|
|
15
|
+
allowNull: false,
|
|
16
|
+
comment: "TikTok campaign_id; loose FK to tiktok_campaigns (no DB-level constraint)",
|
|
17
|
+
},
|
|
18
|
+
ad_account_id: {
|
|
19
|
+
type: DataTypes.STRING(64),
|
|
20
|
+
allowNull: false,
|
|
21
|
+
},
|
|
22
|
+
placement_type: {
|
|
23
|
+
type: DataTypes.STRING(50),
|
|
24
|
+
allowNull: true,
|
|
25
|
+
comment: "PLACEMENT_TYPE_AUTOMATIC / PLACEMENT_TYPE_NORMAL",
|
|
26
|
+
},
|
|
27
|
+
budget_mode: {
|
|
28
|
+
type: DataTypes.STRING(50),
|
|
29
|
+
allowNull: true,
|
|
30
|
+
},
|
|
31
|
+
budget: {
|
|
32
|
+
type: DataTypes.DECIMAL(12, 6),
|
|
33
|
+
allowNull: true,
|
|
34
|
+
},
|
|
35
|
+
bid_type: {
|
|
36
|
+
type: DataTypes.STRING(50),
|
|
37
|
+
allowNull: true,
|
|
38
|
+
},
|
|
39
|
+
bid_price: {
|
|
40
|
+
type: DataTypes.DECIMAL(12, 6),
|
|
41
|
+
allowNull: true,
|
|
42
|
+
},
|
|
43
|
+
optimize_goal: {
|
|
44
|
+
type: DataTypes.STRING(50),
|
|
45
|
+
allowNull: true,
|
|
46
|
+
},
|
|
47
|
+
operation_status: {
|
|
48
|
+
type: DataTypes.STRING(50),
|
|
49
|
+
allowNull: true,
|
|
50
|
+
comment: "ENABLE or DISABLE (TikTok native)",
|
|
51
|
+
},
|
|
52
|
+
schedule_start_time: {
|
|
53
|
+
type: DataTypes.DATE,
|
|
54
|
+
allowNull: true,
|
|
55
|
+
},
|
|
56
|
+
schedule_end_time: {
|
|
57
|
+
type: DataTypes.DATE,
|
|
58
|
+
allowNull: true,
|
|
59
|
+
},
|
|
60
|
+
created_at: {
|
|
61
|
+
type: DataTypes.DATE,
|
|
62
|
+
allowNull: false,
|
|
63
|
+
},
|
|
64
|
+
updated_at: {
|
|
65
|
+
type: DataTypes.DATE,
|
|
66
|
+
allowNull: true,
|
|
67
|
+
},
|
|
68
|
+
synced_at: {
|
|
69
|
+
type: DataTypes.DATE,
|
|
70
|
+
allowNull: false,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
tableName: "tiktok_adgroups",
|
|
75
|
+
timestamps: false,
|
|
76
|
+
indexes: [
|
|
77
|
+
{ fields: ["campaign_id"] },
|
|
78
|
+
{ fields: ["ad_account_id"] },
|
|
79
|
+
{ fields: ["operation_status"] },
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) =>
|
|
2
|
+
sequelize.define(
|
|
3
|
+
"TikTokCampaign",
|
|
4
|
+
{
|
|
5
|
+
campaign_id: {
|
|
6
|
+
type: DataTypes.BIGINT,
|
|
7
|
+
primaryKey: true,
|
|
8
|
+
},
|
|
9
|
+
campaign_name: {
|
|
10
|
+
type: DataTypes.STRING(255),
|
|
11
|
+
allowNull: false,
|
|
12
|
+
},
|
|
13
|
+
ad_account_id: {
|
|
14
|
+
type: DataTypes.STRING(64),
|
|
15
|
+
allowNull: false,
|
|
16
|
+
},
|
|
17
|
+
objective_type: {
|
|
18
|
+
type: DataTypes.STRING(50),
|
|
19
|
+
allowNull: true,
|
|
20
|
+
},
|
|
21
|
+
budget_mode: {
|
|
22
|
+
type: DataTypes.STRING(50),
|
|
23
|
+
allowNull: true,
|
|
24
|
+
comment: "BUDGET_MODE_DAY or BUDGET_MODE_LIFETIME (TikTok native)",
|
|
25
|
+
},
|
|
26
|
+
daily_budget_usd: {
|
|
27
|
+
type: DataTypes.DECIMAL(12, 6),
|
|
28
|
+
allowNull: true,
|
|
29
|
+
comment: "Normalized USD value (TikTok returns native USD float)",
|
|
30
|
+
},
|
|
31
|
+
operation_status: {
|
|
32
|
+
type: DataTypes.STRING(50),
|
|
33
|
+
allowNull: true,
|
|
34
|
+
comment: "ENABLE or DISABLE (TikTok native)",
|
|
35
|
+
},
|
|
36
|
+
special_industries: {
|
|
37
|
+
type: DataTypes.TEXT,
|
|
38
|
+
allowNull: true,
|
|
39
|
+
comment: "JSON-serialized array of special industry tags",
|
|
40
|
+
},
|
|
41
|
+
schedule_start_time: {
|
|
42
|
+
type: DataTypes.DATE,
|
|
43
|
+
allowNull: true,
|
|
44
|
+
},
|
|
45
|
+
schedule_end_time: {
|
|
46
|
+
type: DataTypes.DATE,
|
|
47
|
+
allowNull: true,
|
|
48
|
+
},
|
|
49
|
+
created_at: {
|
|
50
|
+
type: DataTypes.DATE,
|
|
51
|
+
allowNull: false,
|
|
52
|
+
},
|
|
53
|
+
updated_at: {
|
|
54
|
+
type: DataTypes.DATE,
|
|
55
|
+
allowNull: true,
|
|
56
|
+
},
|
|
57
|
+
synced_at: {
|
|
58
|
+
type: DataTypes.DATE,
|
|
59
|
+
allowNull: false,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
tableName: "tiktok_campaigns",
|
|
64
|
+
timestamps: false,
|
|
65
|
+
indexes: [
|
|
66
|
+
{ fields: ["ad_account_id"] },
|
|
67
|
+
{ fields: ["created_at"] },
|
|
68
|
+
{ fields: ["operation_status"] },
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const TiktokIdentities = sequelize.define(
|
|
3
|
+
"TiktokIdentities",
|
|
4
|
+
{
|
|
5
|
+
id: {
|
|
6
|
+
type: DataTypes.BIGINT,
|
|
7
|
+
primaryKey: true,
|
|
8
|
+
autoIncrement: true,
|
|
9
|
+
},
|
|
10
|
+
identity_id: {
|
|
11
|
+
type: DataTypes.STRING(64),
|
|
12
|
+
allowNull: false,
|
|
13
|
+
unique: true,
|
|
14
|
+
comment: "TikTok identity_id (CUSTOMIZED_USER) used as creative owner",
|
|
15
|
+
},
|
|
16
|
+
identity_type: {
|
|
17
|
+
type: DataTypes.STRING(32),
|
|
18
|
+
allowNull: false,
|
|
19
|
+
defaultValue: "CUSTOMIZED_USER",
|
|
20
|
+
},
|
|
21
|
+
name: {
|
|
22
|
+
type: DataTypes.STRING(255),
|
|
23
|
+
allowNull: true,
|
|
24
|
+
},
|
|
25
|
+
ad_account_id: {
|
|
26
|
+
type: DataTypes.STRING(64),
|
|
27
|
+
allowNull: false,
|
|
28
|
+
comment: "TikTok advertiser_id this identity belongs to",
|
|
29
|
+
},
|
|
30
|
+
status: {
|
|
31
|
+
type: DataTypes.STRING(16),
|
|
32
|
+
allowNull: false,
|
|
33
|
+
defaultValue: "active",
|
|
34
|
+
comment: "active | disabled",
|
|
35
|
+
},
|
|
36
|
+
tier: {
|
|
37
|
+
type: DataTypes.INTEGER,
|
|
38
|
+
allowNull: false,
|
|
39
|
+
defaultValue: 1,
|
|
40
|
+
comment:
|
|
41
|
+
"Rotation weight. Higher tier => higher probability of being picked.",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
tableName: "tiktok_identities",
|
|
46
|
+
indexes: [{ fields: ["ad_account_id", "status"] }],
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return TiktokIdentities;
|
|
51
|
+
};
|
package/models/Users.js
CHANGED
|
@@ -112,6 +112,16 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
112
112
|
type: DataTypes.JSONB,
|
|
113
113
|
allowNull: true
|
|
114
114
|
},
|
|
115
|
+
ApiRateLimits: {
|
|
116
|
+
type: DataTypes.JSONB,
|
|
117
|
+
allowNull: true,
|
|
118
|
+
defaultValue: null,
|
|
119
|
+
// Per-user public API rate-limit override. Null = use system defaults
|
|
120
|
+
// (read 120, write 20, ai 3, dryRun 600 — all per minute), defined in
|
|
121
|
+
// server/middleware/publicApiRateLimit.js BUCKETS.
|
|
122
|
+
// Shape when set: { read: 200, write: 50, ai: 5, dryRun: 1000 } — any
|
|
123
|
+
// missing key falls back to the system default for that bucket.
|
|
124
|
+
},
|
|
115
125
|
managed_by: {
|
|
116
126
|
type: DataTypes.UUID, // A UUID to store the ID of the user who manages this user
|
|
117
127
|
allowNull: true,
|
package/models/pixel.js
CHANGED
|
@@ -17,6 +17,12 @@ module.exports = (sequelize) => {
|
|
|
17
17
|
defaultValue: "facebook", // Default to Facebook, but you can adjust as needed
|
|
18
18
|
in: ["Facebook", "Tiktok", "Taboola", "Outbrain", "Yahoo"],
|
|
19
19
|
},
|
|
20
|
+
platform_code: {
|
|
21
|
+
type: DataTypes.ENUM("fb", "tt", "snp"),
|
|
22
|
+
allowNull: false,
|
|
23
|
+
defaultValue: "fb",
|
|
24
|
+
comment: "Canonical ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
|
|
25
|
+
},
|
|
20
26
|
access_token: {
|
|
21
27
|
type: DataTypes.STRING,
|
|
22
28
|
allowNull: false,
|