@adcp/client 4.0.2 → 4.1.0
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/dist/lib/adapters/content-standards-adapter.d.ts.map +1 -1
- package/dist/lib/adapters/content-standards-adapter.js +2 -0
- package/dist/lib/adapters/content-standards-adapter.js.map +1 -1
- package/dist/lib/core/AgentClient.d.ts.map +1 -1
- package/dist/lib/core/SingleAgentClient.d.ts +0 -7
- package/dist/lib/core/SingleAgentClient.d.ts.map +1 -1
- package/dist/lib/core/SingleAgentClient.js +3 -45
- package/dist/lib/core/SingleAgentClient.js.map +1 -1
- package/dist/lib/index.d.ts +6 -2
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +12 -4
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/types/adcp.d.ts +2 -5
- package/dist/lib/types/adcp.d.ts.map +1 -1
- package/dist/lib/types/compat.d.ts +3 -0
- package/dist/lib/types/compat.d.ts.map +1 -1
- package/dist/lib/types/compat.js.map +1 -1
- package/dist/lib/types/core.generated.d.ts +616 -233
- package/dist/lib/types/core.generated.d.ts.map +1 -1
- package/dist/lib/types/core.generated.js +1 -1
- package/dist/lib/types/error-codes.d.ts +32 -0
- package/dist/lib/types/error-codes.d.ts.map +1 -0
- package/dist/lib/types/error-codes.js +114 -0
- package/dist/lib/types/error-codes.js.map +1 -0
- package/dist/lib/types/index.d.ts +1 -1
- package/dist/lib/types/index.d.ts.map +1 -1
- package/dist/lib/types/index.js.map +1 -1
- package/dist/lib/types/schemas.generated.d.ts +26250 -12235
- package/dist/lib/types/schemas.generated.d.ts.map +1 -1
- package/dist/lib/types/schemas.generated.js +459 -418
- package/dist/lib/types/schemas.generated.js.map +1 -1
- package/dist/lib/types/tools.generated.d.ts +993 -1012
- package/dist/lib/types/tools.generated.d.ts.map +1 -1
- package/dist/lib/utils/creative-adapter.d.ts +1 -1
- package/dist/lib/utils/creative-adapter.js +2 -2
- package/dist/lib/utils/creative-adapter.js.map +1 -1
- package/dist/lib/utils/deprecation.d.ts +11 -0
- package/dist/lib/utils/deprecation.d.ts.map +1 -0
- package/dist/lib/utils/deprecation.js +23 -0
- package/dist/lib/utils/deprecation.js.map +1 -0
- package/dist/lib/utils/request-normalizer.d.ts +23 -0
- package/dist/lib/utils/request-normalizer.d.ts.map +1 -0
- package/dist/lib/utils/request-normalizer.js +119 -0
- package/dist/lib/utils/request-normalizer.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Deprecation warning utility for backward-compat shims.
|
|
4
|
+
*
|
|
5
|
+
* Each key is warned once per process lifetime to avoid log spam.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.warnOnce = warnOnce;
|
|
9
|
+
exports.resetWarnings = resetWarnings;
|
|
10
|
+
const warned = new Set();
|
|
11
|
+
function warnOnce(key, message) {
|
|
12
|
+
if (!warned.has(key)) {
|
|
13
|
+
warned.add(key);
|
|
14
|
+
console.warn(`[@adcp/client] DEPRECATED: ${message}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Reset all deprecation warnings. Only useful in tests.
|
|
19
|
+
*/
|
|
20
|
+
function resetWarnings() {
|
|
21
|
+
warned.clear();
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=deprecation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deprecation.js","sourceRoot":"","sources":["../../../src/lib/utils/deprecation.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAIH,4BAKC;AAKD,sCAEC;AAdD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;AAEjC,SAAgB,QAAQ,CAAC,GAAW,EAAE,OAAe;IACnD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO,CAAC,IAAI,CAAC,8BAA8B,OAAO,EAAE,CAAC,CAAC;IACxD,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa;IAC3B,MAAM,CAAC,KAAK,EAAE,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request parameter normalization for backward compatibility.
|
|
3
|
+
*
|
|
4
|
+
* Converts deprecated field names and shapes so callers written against
|
|
5
|
+
* earlier schema versions keep working. Each conversion emits a one-time
|
|
6
|
+
* deprecation warning via warnOnce().
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Normalize a single package's params for backward compatibility.
|
|
10
|
+
*
|
|
11
|
+
* Handles:
|
|
12
|
+
* - optimization_goal (scalar) → optimization_goals (array)
|
|
13
|
+
* - catalog (scalar object) → catalogs (array)
|
|
14
|
+
*/
|
|
15
|
+
export declare function normalizePackageParams(pkg: any): any;
|
|
16
|
+
/**
|
|
17
|
+
* Normalize request params for backward compatibility.
|
|
18
|
+
*
|
|
19
|
+
* Infers missing fields that can be derived from deprecated params so callers
|
|
20
|
+
* written against older schema versions keep working.
|
|
21
|
+
*/
|
|
22
|
+
export declare function normalizeRequestParams(taskType: string, params: any): any;
|
|
23
|
+
//# sourceMappingURL=request-normalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-normalizer.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/request-normalizer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAuBpD;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,GAAG,CAqFzE"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Request parameter normalization for backward compatibility.
|
|
4
|
+
*
|
|
5
|
+
* Converts deprecated field names and shapes so callers written against
|
|
6
|
+
* earlier schema versions keep working. Each conversion emits a one-time
|
|
7
|
+
* deprecation warning via warnOnce().
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.normalizePackageParams = normalizePackageParams;
|
|
11
|
+
exports.normalizeRequestParams = normalizeRequestParams;
|
|
12
|
+
const compat_1 = require("../types/compat");
|
|
13
|
+
const deprecation_1 = require("./deprecation");
|
|
14
|
+
/**
|
|
15
|
+
* Normalize a single package's params for backward compatibility.
|
|
16
|
+
*
|
|
17
|
+
* Handles:
|
|
18
|
+
* - optimization_goal (scalar) → optimization_goals (array)
|
|
19
|
+
* - catalog (scalar object) → catalogs (array)
|
|
20
|
+
*/
|
|
21
|
+
function normalizePackageParams(pkg) {
|
|
22
|
+
if (!pkg || typeof pkg !== 'object')
|
|
23
|
+
return pkg;
|
|
24
|
+
const normalized = { ...pkg };
|
|
25
|
+
// optimization_goal (scalar) → optimization_goals (array)
|
|
26
|
+
if (normalized.optimization_goal && !normalized.optimization_goals?.length) {
|
|
27
|
+
(0, deprecation_1.warnOnce)('optimization_goal', 'PackageRequest.optimization_goal is deprecated. Use optimization_goals (array) instead.');
|
|
28
|
+
normalized.optimization_goals = [normalized.optimization_goal];
|
|
29
|
+
}
|
|
30
|
+
delete normalized.optimization_goal;
|
|
31
|
+
// catalog (scalar) → catalogs (array)
|
|
32
|
+
if (normalized.catalog && !normalized.catalogs?.length) {
|
|
33
|
+
(0, deprecation_1.warnOnce)('catalog', 'PackageRequest.catalog is deprecated. Use catalogs (array) instead.');
|
|
34
|
+
normalized.catalogs = [normalized.catalog];
|
|
35
|
+
}
|
|
36
|
+
delete normalized.catalog;
|
|
37
|
+
return normalized;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Normalize request params for backward compatibility.
|
|
41
|
+
*
|
|
42
|
+
* Infers missing fields that can be derived from deprecated params so callers
|
|
43
|
+
* written against older schema versions keep working.
|
|
44
|
+
*/
|
|
45
|
+
function normalizeRequestParams(taskType, params) {
|
|
46
|
+
if (!params) {
|
|
47
|
+
return params;
|
|
48
|
+
}
|
|
49
|
+
let normalized = { ...params };
|
|
50
|
+
// ── Universal shims (all tools) ──
|
|
51
|
+
// Always delete deprecated fields, even when the new field already exists,
|
|
52
|
+
// to prevent Zod strict validation failures on unknown keys.
|
|
53
|
+
// account_id (bare string) → account: { account_id }
|
|
54
|
+
if (typeof normalized.account_id === 'string' && !normalized.account) {
|
|
55
|
+
(0, deprecation_1.warnOnce)('account_id', 'account_id is deprecated. Use account: { account_id } instead.');
|
|
56
|
+
normalized.account = { account_id: normalized.account_id };
|
|
57
|
+
}
|
|
58
|
+
delete normalized.account_id;
|
|
59
|
+
// campaign_ref → buyer_campaign_ref
|
|
60
|
+
if (normalized.campaign_ref && !normalized.buyer_campaign_ref) {
|
|
61
|
+
(0, deprecation_1.warnOnce)('campaign_ref', 'campaign_ref is deprecated. Use buyer_campaign_ref instead.');
|
|
62
|
+
normalized.buyer_campaign_ref = normalized.campaign_ref;
|
|
63
|
+
}
|
|
64
|
+
delete normalized.campaign_ref;
|
|
65
|
+
// ── brand_manifest → brand (get_products, create_media_buy) ──
|
|
66
|
+
// update_media_buy has no brand field in either v2 or v3 — excluded deliberately.
|
|
67
|
+
// brand takes precedence if both are supplied.
|
|
68
|
+
if (taskType === 'get_products' || taskType === 'create_media_buy') {
|
|
69
|
+
if (normalized.brand_manifest && !normalized.brand) {
|
|
70
|
+
const brand = (0, compat_1.brandManifestToBrandReference)(normalized.brand_manifest);
|
|
71
|
+
if (brand) {
|
|
72
|
+
normalized.brand = brand;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
delete normalized.brand_manifest;
|
|
76
|
+
}
|
|
77
|
+
// ── Package normalization (create_media_buy, update_media_buy) ──
|
|
78
|
+
if ((taskType === 'create_media_buy' || taskType === 'update_media_buy') && Array.isArray(normalized.packages)) {
|
|
79
|
+
normalized.packages = normalized.packages.map(normalizePackageParams);
|
|
80
|
+
}
|
|
81
|
+
// ── activate_signal: deployments → destinations ──
|
|
82
|
+
if (taskType === 'activate_signal') {
|
|
83
|
+
if (normalized.deployments && !normalized.destinations) {
|
|
84
|
+
(0, deprecation_1.warnOnce)('deployments', 'deployments is deprecated. Use destinations instead.');
|
|
85
|
+
normalized.destinations = normalized.deployments;
|
|
86
|
+
}
|
|
87
|
+
delete normalized.deployments;
|
|
88
|
+
}
|
|
89
|
+
// ── get_signals: deliver_to → destinations ──
|
|
90
|
+
if (taskType === 'get_signals') {
|
|
91
|
+
if (normalized.deliver_to && !normalized.destinations) {
|
|
92
|
+
(0, deprecation_1.warnOnce)('deliver_to', 'deliver_to is deprecated. Use destinations and countries instead.');
|
|
93
|
+
normalized.destinations = normalized.deliver_to;
|
|
94
|
+
}
|
|
95
|
+
delete normalized.deliver_to;
|
|
96
|
+
}
|
|
97
|
+
// ── get_products-specific normalization ──
|
|
98
|
+
if (taskType === 'get_products') {
|
|
99
|
+
// Infer buying_mode from brief presence if not supplied
|
|
100
|
+
if (!normalized.buying_mode) {
|
|
101
|
+
normalized.buying_mode = normalized.brief ? 'brief' : 'wholesale';
|
|
102
|
+
}
|
|
103
|
+
// Strip removed v2 fields that would fail strict validation
|
|
104
|
+
for (const removed of ['feedback', 'product_ids', 'proposal_id']) {
|
|
105
|
+
if (removed in normalized) {
|
|
106
|
+
(0, deprecation_1.warnOnce)(`get_products.${removed}`, `GetProductsRequest.${removed} has been removed in v3.`);
|
|
107
|
+
delete normalized[removed];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Convert legacy product_selectors (v3 beta / v2 era) → catalog so strict validation passes.
|
|
111
|
+
// catalog takes precedence if both are supplied.
|
|
112
|
+
if (normalized.product_selectors && !normalized.catalog) {
|
|
113
|
+
normalized.catalog = (0, compat_1.promotedProductsToCatalog)(normalized.product_selectors);
|
|
114
|
+
}
|
|
115
|
+
delete normalized.product_selectors;
|
|
116
|
+
}
|
|
117
|
+
return normalized;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=request-normalizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-normalizer.js","sourceRoot":"","sources":["../../../src/lib/utils/request-normalizer.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAYH,wDAuBC;AAQD,wDAqFC;AA9HD,4CAA2F;AAC3F,+CAAyC;AAEzC;;;;;;GAMG;AACH,SAAgB,sBAAsB,CAAC,GAAQ;IAC7C,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC;IAEhD,MAAM,UAAU,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;IAE9B,0DAA0D;IAC1D,IAAI,UAAU,CAAC,iBAAiB,IAAI,CAAC,UAAU,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC;QAC3E,IAAA,sBAAQ,EACN,mBAAmB,EACnB,yFAAyF,CAC1F,CAAC;QACF,UAAU,CAAC,kBAAkB,GAAG,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,UAAU,CAAC,iBAAiB,CAAC;IAEpC,sCAAsC;IACtC,IAAI,UAAU,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QACvD,IAAA,sBAAQ,EAAC,SAAS,EAAE,qEAAqE,CAAC,CAAC;QAC3F,UAAU,CAAC,QAAQ,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,UAAU,CAAC,OAAO,CAAC;IAE1B,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,QAAgB,EAAE,MAAW;IAClE,IAAI,CAAC,MAAM,EAAE,CAAC;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