agrs-sequelize-sdk 1.4.31 → 1.4.32
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/TiktokIdentities.js +8 -9
- package/models/Users.js +10 -0
- package/package.json +1 -1
- package/models/MineWebhookEvent.js +0 -53
|
@@ -11,8 +11,7 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
11
11
|
type: DataTypes.STRING(64),
|
|
12
12
|
allowNull: false,
|
|
13
13
|
unique: true,
|
|
14
|
-
comment:
|
|
15
|
-
"TikTok identity_id (creative owner). ONE row per identity — mirrors FB Pages.code.",
|
|
14
|
+
comment: "TikTok identity_id (CUSTOMIZED_USER) used as creative owner",
|
|
16
15
|
},
|
|
17
16
|
identity_type: {
|
|
18
17
|
type: DataTypes.STRING(32),
|
|
@@ -23,21 +22,21 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
23
22
|
type: DataTypes.STRING(255),
|
|
24
23
|
allowNull: true,
|
|
25
24
|
},
|
|
26
|
-
// Identities are scoped by business_center_id (mirrors FB Pages, tagged by
|
|
27
|
-
// BM with no ad-account binding) and selected at creation time (UI lets the
|
|
28
|
-
// user pick; the AI/feed flow random-picks via the resolver, which queries
|
|
29
|
-
// by the advertiser's BC and IGNORES ad_account_id). ad_account_id is kept
|
|
30
|
-
// NOT NULL (no schema mutation) and holds a representative advertiser.
|
|
31
25
|
ad_account_id: {
|
|
32
26
|
type: DataTypes.STRING(64),
|
|
33
27
|
allowNull: false,
|
|
34
|
-
comment:
|
|
28
|
+
comment:
|
|
29
|
+
"Representative TikTok advertiser_id (legacy). Selection is by " +
|
|
30
|
+
"business_center_id; the resolver ignores this. Kept NOT NULL so the " +
|
|
31
|
+
"column add stays additive.",
|
|
35
32
|
},
|
|
36
33
|
business_center_id: {
|
|
37
34
|
type: DataTypes.STRING(64),
|
|
38
35
|
allowNull: true,
|
|
39
36
|
comment:
|
|
40
|
-
"
|
|
37
|
+
"Business Center this identity is authorized to. Mirrors FB Pages " +
|
|
38
|
+
"(tagged by BM, no ad-account binding). The asset resolver scopes " +
|
|
39
|
+
"identity selection by this, NOT by ad_account_id.",
|
|
41
40
|
},
|
|
42
41
|
status: {
|
|
43
42
|
type: DataTypes.STRING(16),
|
package/models/Users.js
CHANGED
|
@@ -40,6 +40,16 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
40
40
|
allowNull: true,
|
|
41
41
|
defaultValue: [],
|
|
42
42
|
},
|
|
43
|
+
// Public API token scope preference. Admin sets it on the User
|
|
44
|
+
// Management screen (Features → API & Docs → Read / Read & Write).
|
|
45
|
+
// The token-issue route reads this when a user mints/regenerates so
|
|
46
|
+
// the new token gets the admin-granted scope, without polluting the
|
|
47
|
+
// Features array.
|
|
48
|
+
api_scope: {
|
|
49
|
+
type: DataTypes.STRING,
|
|
50
|
+
allowNull: false,
|
|
51
|
+
defaultValue: "read",
|
|
52
|
+
},
|
|
43
53
|
Accounts: {
|
|
44
54
|
type: DataTypes.ARRAY(DataTypes.STRING), // Array of account IDs
|
|
45
55
|
allowNull: true,
|
package/package.json
CHANGED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
/**
|
|
3
|
-
* Durable audit log of every inbound Mine webhook call (article-ready / policy-decision).
|
|
4
|
-
* Purpose: observability, security audit (signature failures), idempotency, replay/reconcile.
|
|
5
|
-
* Correlation is by string ids (provider_id / adset_id / ad_id) — no FK, to stay decoupled
|
|
6
|
-
* from the article/ad lifecycle and tolerate webhooks that arrive before the local row exists.
|
|
7
|
-
*/
|
|
8
|
-
const MineWebhookEvent = sequelize.define(
|
|
9
|
-
"MineWebhookEvent",
|
|
10
|
-
{
|
|
11
|
-
id: {
|
|
12
|
-
type: DataTypes.INTEGER,
|
|
13
|
-
primaryKey: true,
|
|
14
|
-
autoIncrement: true,
|
|
15
|
-
},
|
|
16
|
-
event_id: { type: DataTypes.STRING, allowNull: true }, // Mine's unique id (idempotency)
|
|
17
|
-
event_type: { type: DataTypes.STRING, allowNull: false }, // 'article-ready' | 'policy-decision'
|
|
18
|
-
endpoint: { type: DataTypes.STRING, allowNull: true },
|
|
19
|
-
source_ip: { type: DataTypes.STRING, allowNull: true },
|
|
20
|
-
|
|
21
|
-
signature_valid: { type: DataTypes.BOOLEAN, allowNull: true },
|
|
22
|
-
http_status: { type: DataTypes.INTEGER, allowNull: true },
|
|
23
|
-
|
|
24
|
-
payload: { type: DataTypes.JSONB, allowNull: true },
|
|
25
|
-
|
|
26
|
-
provider_id: { type: DataTypes.STRING, allowNull: true },
|
|
27
|
-
adset_id: { type: DataTypes.STRING, allowNull: true },
|
|
28
|
-
ad_id: { type: DataTypes.STRING, allowNull: true },
|
|
29
|
-
matched_agrsaid: { type: DataTypes.STRING, allowNull: true },
|
|
30
|
-
|
|
31
|
-
// received | processed | skipped | duplicate | rejected_signature | rejected_validation | failed
|
|
32
|
-
outcome: { type: DataTypes.STRING, allowNull: false, defaultValue: "received" },
|
|
33
|
-
outcome_reason: { type: DataTypes.TEXT, allowNull: true },
|
|
34
|
-
|
|
35
|
-
received_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW },
|
|
36
|
-
processed_at: { type: DataTypes.DATE, allowNull: true },
|
|
37
|
-
duration_ms: { type: DataTypes.INTEGER, allowNull: true },
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
tableName: "mine_webhook_events",
|
|
41
|
-
indexes: [
|
|
42
|
-
{ fields: ["event_id"] },
|
|
43
|
-
{ fields: ["event_type"] },
|
|
44
|
-
{ fields: ["outcome"] },
|
|
45
|
-
{ fields: ["provider_id"] },
|
|
46
|
-
{ fields: ["adset_id"] },
|
|
47
|
-
{ fields: [{ name: "received_at", order: "DESC" }] },
|
|
48
|
-
],
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
return MineWebhookEvent;
|
|
53
|
-
};
|