@cesteral/amazon-dsp-mcp 1.0.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/LICENSE.md +201 -0
- package/README.md +59 -0
- package/dist/auth/amazon-dsp-auth-adapter.d.ts +42 -0
- package/dist/auth/amazon-dsp-auth-adapter.d.ts.map +1 -0
- package/dist/auth/amazon-dsp-auth-adapter.js +126 -0
- package/dist/auth/amazon-dsp-auth-adapter.js.map +1 -0
- package/dist/auth/amazon-dsp-auth-strategy.d.ts +14 -0
- package/dist/auth/amazon-dsp-auth-strategy.d.ts.map +1 -0
- package/dist/auth/amazon-dsp-auth-strategy.js +58 -0
- package/dist/auth/amazon-dsp-auth-strategy.js.map +1 -0
- package/dist/auth/index.d.ts +3 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +3 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/config/index.d.ts +116 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +49 -0
- package/dist/config/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +65 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server/prompts/definitions/bulk-operations-workflow.prompt.d.ts +4 -0
- package/dist/mcp-server/prompts/definitions/bulk-operations-workflow.prompt.d.ts.map +1 -0
- package/dist/mcp-server/prompts/definitions/bulk-operations-workflow.prompt.js +127 -0
- package/dist/mcp-server/prompts/definitions/bulk-operations-workflow.prompt.js.map +1 -0
- package/dist/mcp-server/prompts/definitions/campaign-setup-workflow.prompt.d.ts +4 -0
- package/dist/mcp-server/prompts/definitions/campaign-setup-workflow.prompt.d.ts.map +1 -0
- package/dist/mcp-server/prompts/definitions/campaign-setup-workflow.prompt.js +120 -0
- package/dist/mcp-server/prompts/definitions/campaign-setup-workflow.prompt.js.map +1 -0
- package/dist/mcp-server/prompts/definitions/creative-upload-workflow.prompt.d.ts +4 -0
- package/dist/mcp-server/prompts/definitions/creative-upload-workflow.prompt.d.ts.map +1 -0
- package/dist/mcp-server/prompts/definitions/creative-upload-workflow.prompt.js +116 -0
- package/dist/mcp-server/prompts/definitions/creative-upload-workflow.prompt.js.map +1 -0
- package/dist/mcp-server/prompts/definitions/cross-platform-campaign-setup.prompt.d.ts +4 -0
- package/dist/mcp-server/prompts/definitions/cross-platform-campaign-setup.prompt.d.ts.map +1 -0
- package/dist/mcp-server/prompts/definitions/cross-platform-campaign-setup.prompt.js +299 -0
- package/dist/mcp-server/prompts/definitions/cross-platform-campaign-setup.prompt.js.map +1 -0
- package/dist/mcp-server/prompts/definitions/cross-platform-performance.prompt.d.ts +4 -0
- package/dist/mcp-server/prompts/definitions/cross-platform-performance.prompt.d.ts.map +1 -0
- package/dist/mcp-server/prompts/definitions/cross-platform-performance.prompt.js +170 -0
- package/dist/mcp-server/prompts/definitions/cross-platform-performance.prompt.js.map +1 -0
- package/dist/mcp-server/prompts/definitions/entity-duplication-workflow.prompt.d.ts +4 -0
- package/dist/mcp-server/prompts/definitions/entity-duplication-workflow.prompt.d.ts.map +1 -0
- package/dist/mcp-server/prompts/definitions/entity-duplication-workflow.prompt.js +200 -0
- package/dist/mcp-server/prompts/definitions/entity-duplication-workflow.prompt.js.map +1 -0
- package/dist/mcp-server/prompts/definitions/entity-update-workflow.prompt.d.ts +4 -0
- package/dist/mcp-server/prompts/definitions/entity-update-workflow.prompt.d.ts.map +1 -0
- package/dist/mcp-server/prompts/definitions/entity-update-workflow.prompt.js +183 -0
- package/dist/mcp-server/prompts/definitions/entity-update-workflow.prompt.js.map +1 -0
- package/dist/mcp-server/prompts/definitions/reporting-workflow.prompt.d.ts +4 -0
- package/dist/mcp-server/prompts/definitions/reporting-workflow.prompt.d.ts.map +1 -0
- package/dist/mcp-server/prompts/definitions/reporting-workflow.prompt.js +126 -0
- package/dist/mcp-server/prompts/definitions/reporting-workflow.prompt.js.map +1 -0
- package/dist/mcp-server/prompts/definitions/targeting-discovery-workflow.prompt.d.ts +4 -0
- package/dist/mcp-server/prompts/definitions/targeting-discovery-workflow.prompt.d.ts.map +1 -0
- package/dist/mcp-server/prompts/definitions/targeting-discovery-workflow.prompt.js +198 -0
- package/dist/mcp-server/prompts/definitions/targeting-discovery-workflow.prompt.js.map +1 -0
- package/dist/mcp-server/prompts/definitions/tool-schema-exploration.prompt.d.ts +4 -0
- package/dist/mcp-server/prompts/definitions/tool-schema-exploration.prompt.d.ts.map +1 -0
- package/dist/mcp-server/prompts/definitions/tool-schema-exploration.prompt.js +96 -0
- package/dist/mcp-server/prompts/definitions/tool-schema-exploration.prompt.js.map +1 -0
- package/dist/mcp-server/prompts/definitions/troubleshoot-entity.prompt.d.ts +4 -0
- package/dist/mcp-server/prompts/definitions/troubleshoot-entity.prompt.d.ts.map +1 -0
- package/dist/mcp-server/prompts/definitions/troubleshoot-entity.prompt.js +111 -0
- package/dist/mcp-server/prompts/definitions/troubleshoot-entity.prompt.js.map +1 -0
- package/dist/mcp-server/prompts/index.d.ts +9 -0
- package/dist/mcp-server/prompts/index.d.ts.map +1 -0
- package/dist/mcp-server/prompts/index.js +97 -0
- package/dist/mcp-server/prompts/index.js.map +1 -0
- package/dist/mcp-server/resources/definitions/entity-examples.resource.d.ts +4 -0
- package/dist/mcp-server/resources/definitions/entity-examples.resource.d.ts.map +1 -0
- package/dist/mcp-server/resources/definitions/entity-examples.resource.js +121 -0
- package/dist/mcp-server/resources/definitions/entity-examples.resource.js.map +1 -0
- package/dist/mcp-server/resources/definitions/entity-hierarchy.resource.d.ts +3 -0
- package/dist/mcp-server/resources/definitions/entity-hierarchy.resource.d.ts.map +1 -0
- package/dist/mcp-server/resources/definitions/entity-hierarchy.resource.js +58 -0
- package/dist/mcp-server/resources/definitions/entity-hierarchy.resource.js.map +1 -0
- package/dist/mcp-server/resources/definitions/entity-schemas.resource.d.ts +4 -0
- package/dist/mcp-server/resources/definitions/entity-schemas.resource.d.ts.map +1 -0
- package/dist/mcp-server/resources/definitions/entity-schemas.resource.js +51 -0
- package/dist/mcp-server/resources/definitions/entity-schemas.resource.js.map +1 -0
- package/dist/mcp-server/resources/definitions/index.d.ts +7 -0
- package/dist/mcp-server/resources/definitions/index.d.ts.map +1 -0
- package/dist/mcp-server/resources/definitions/index.js +53 -0
- package/dist/mcp-server/resources/definitions/index.js.map +1 -0
- package/dist/mcp-server/resources/definitions/reporting-reference.resource.d.ts +3 -0
- package/dist/mcp-server/resources/definitions/reporting-reference.resource.d.ts.map +1 -0
- package/dist/mcp-server/resources/definitions/reporting-reference.resource.js +50 -0
- package/dist/mcp-server/resources/definitions/reporting-reference.resource.js.map +1 -0
- package/dist/mcp-server/resources/index.d.ts +3 -0
- package/dist/mcp-server/resources/index.d.ts.map +1 -0
- package/dist/mcp-server/resources/index.js +2 -0
- package/dist/mcp-server/resources/index.js.map +1 -0
- package/dist/mcp-server/resources/types.d.ts +8 -0
- package/dist/mcp-server/resources/types.d.ts.map +1 -0
- package/dist/mcp-server/resources/types.js +2 -0
- package/dist/mcp-server/resources/types.js.map +1 -0
- package/dist/mcp-server/server.d.ts +5 -0
- package/dist/mcp-server/server.d.ts.map +1 -0
- package/dist/mcp-server/server.js +137 -0
- package/dist/mcp-server/server.js.map +1 -0
- package/dist/mcp-server/tools/definitions/adjust-bids.tool.d.ts +215 -0
- package/dist/mcp-server/tools/definitions/adjust-bids.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/adjust-bids.tool.js +147 -0
- package/dist/mcp-server/tools/definitions/adjust-bids.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/bulk-create-entities.tool.d.ts +152 -0
- package/dist/mcp-server/tools/definitions/bulk-create-entities.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/bulk-create-entities.tool.js +111 -0
- package/dist/mcp-server/tools/definitions/bulk-create-entities.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/bulk-update-entities.tool.d.ts +193 -0
- package/dist/mcp-server/tools/definitions/bulk-update-entities.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/bulk-update-entities.tool.js +127 -0
- package/dist/mcp-server/tools/definitions/bulk-update-entities.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/bulk-update-status.tool.d.ts +153 -0
- package/dist/mcp-server/tools/definitions/bulk-update-status.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/bulk-update-status.tool.js +136 -0
- package/dist/mcp-server/tools/definitions/bulk-update-status.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/check-report-status.tool.d.ts +112 -0
- package/dist/mcp-server/tools/definitions/check-report-status.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/check-report-status.tool.js +87 -0
- package/dist/mcp-server/tools/definitions/check-report-status.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/create-entity.tool.d.ts +111 -0
- package/dist/mcp-server/tools/definitions/create-entity.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/create-entity.tool.js +96 -0
- package/dist/mcp-server/tools/definitions/create-entity.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/delete-entity.tool.d.ts +152 -0
- package/dist/mcp-server/tools/definitions/delete-entity.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/delete-entity.tool.js +142 -0
- package/dist/mcp-server/tools/definitions/delete-entity.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/download-report.tool.d.ts +297 -0
- package/dist/mcp-server/tools/definitions/download-report.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/download-report.tool.js +107 -0
- package/dist/mcp-server/tools/definitions/download-report.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/duplicate-entity.tool.d.ts +105 -0
- package/dist/mcp-server/tools/definitions/duplicate-entity.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/duplicate-entity.tool.js +85 -0
- package/dist/mcp-server/tools/definitions/duplicate-entity.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-ad-preview.tool.d.ts +75 -0
- package/dist/mcp-server/tools/definitions/get-ad-preview.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-ad-preview.tool.js +63 -0
- package/dist/mcp-server/tools/definitions/get-ad-preview.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-audience-estimate.tool.d.ts +85 -0
- package/dist/mcp-server/tools/definitions/get-audience-estimate.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-audience-estimate.tool.js +91 -0
- package/dist/mcp-server/tools/definitions/get-audience-estimate.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-entity.tool.d.ts +76 -0
- package/dist/mcp-server/tools/definitions/get-entity.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-entity.tool.js +71 -0
- package/dist/mcp-server/tools/definitions/get-entity.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-report-breakdowns.tool.d.ts +289 -0
- package/dist/mcp-server/tools/definitions/get-report-breakdowns.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-report-breakdowns.tool.js +181 -0
- package/dist/mcp-server/tools/definitions/get-report-breakdowns.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-report.tool.d.ts +271 -0
- package/dist/mcp-server/tools/definitions/get-report.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-report.tool.js +174 -0
- package/dist/mcp-server/tools/definitions/get-report.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-targeting-options.tool.d.ts +75 -0
- package/dist/mcp-server/tools/definitions/get-targeting-options.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-targeting-options.tool.js +75 -0
- package/dist/mcp-server/tools/definitions/get-targeting-options.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/index.d.ts +21 -0
- package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/index.js +63 -0
- package/dist/mcp-server/tools/definitions/index.js.map +1 -0
- package/dist/mcp-server/tools/definitions/list-advertisers.tool.d.ts +54 -0
- package/dist/mcp-server/tools/definitions/list-advertisers.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/list-advertisers.tool.js +58 -0
- package/dist/mcp-server/tools/definitions/list-advertisers.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/list-entities.tool.d.ts +171 -0
- package/dist/mcp-server/tools/definitions/list-entities.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/list-entities.tool.js +112 -0
- package/dist/mcp-server/tools/definitions/list-entities.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/search-targeting.tool.d.ts +89 -0
- package/dist/mcp-server/tools/definitions/search-targeting.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/search-targeting.tool.js +93 -0
- package/dist/mcp-server/tools/definitions/search-targeting.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/submit-report.tool.d.ts +134 -0
- package/dist/mcp-server/tools/definitions/submit-report.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/submit-report.tool.js +119 -0
- package/dist/mcp-server/tools/definitions/submit-report.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/update-entity.tool.d.ts +114 -0
- package/dist/mcp-server/tools/definitions/update-entity.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/update-entity.tool.js +89 -0
- package/dist/mcp-server/tools/definitions/update-entity.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/validate-entity.tool.d.ts +169 -0
- package/dist/mcp-server/tools/definitions/validate-entity.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/validate-entity.tool.js +104 -0
- package/dist/mcp-server/tools/definitions/validate-entity.tool.js.map +1 -0
- package/dist/mcp-server/tools/index.d.ts +2 -0
- package/dist/mcp-server/tools/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/index.js +2 -0
- package/dist/mcp-server/tools/index.js.map +1 -0
- package/dist/mcp-server/tools/utils/entity-mapping.d.ts +24 -0
- package/dist/mcp-server/tools/utils/entity-mapping.d.ts.map +1 -0
- package/dist/mcp-server/tools/utils/entity-mapping.js +42 -0
- package/dist/mcp-server/tools/utils/entity-mapping.js.map +1 -0
- package/dist/mcp-server/tools/utils/resolve-session.d.ts +4 -0
- package/dist/mcp-server/tools/utils/resolve-session.d.ts.map +1 -0
- package/dist/mcp-server/tools/utils/resolve-session.js +6 -0
- package/dist/mcp-server/tools/utils/resolve-session.js.map +1 -0
- package/dist/mcp-server/transports/streamable-http-transport.d.ts +57 -0
- package/dist/mcp-server/transports/streamable-http-transport.d.ts.map +1 -0
- package/dist/mcp-server/transports/streamable-http-transport.js +105 -0
- package/dist/mcp-server/transports/streamable-http-transport.js.map +1 -0
- package/dist/services/amazon-dsp/amazon-dsp-api-contract.d.ts +43 -0
- package/dist/services/amazon-dsp/amazon-dsp-api-contract.d.ts.map +1 -0
- package/dist/services/amazon-dsp/amazon-dsp-api-contract.js +193 -0
- package/dist/services/amazon-dsp/amazon-dsp-api-contract.js.map +1 -0
- package/dist/services/amazon-dsp/amazon-dsp-http-client.d.ts +15 -0
- package/dist/services/amazon-dsp/amazon-dsp-http-client.d.ts.map +1 -0
- package/dist/services/amazon-dsp/amazon-dsp-http-client.js +138 -0
- package/dist/services/amazon-dsp/amazon-dsp-http-client.js.map +1 -0
- package/dist/services/amazon-dsp/amazon-dsp-reporting-service.d.ts +63 -0
- package/dist/services/amazon-dsp/amazon-dsp-reporting-service.d.ts.map +1 -0
- package/dist/services/amazon-dsp/amazon-dsp-reporting-service.js +134 -0
- package/dist/services/amazon-dsp/amazon-dsp-reporting-service.js.map +1 -0
- package/dist/services/amazon-dsp/amazon-dsp-service.d.ts +85 -0
- package/dist/services/amazon-dsp/amazon-dsp-service.d.ts.map +1 -0
- package/dist/services/amazon-dsp/amazon-dsp-service.js +182 -0
- package/dist/services/amazon-dsp/amazon-dsp-service.js.map +1 -0
- package/dist/services/amazon-dsp/types.d.ts +142 -0
- package/dist/services/amazon-dsp/types.d.ts.map +1 -0
- package/dist/services/amazon-dsp/types.js +24 -0
- package/dist/services/amazon-dsp/types.js.map +1 -0
- package/dist/services/session-services.d.ts +20 -0
- package/dist/services/session-services.d.ts.map +1 -0
- package/dist/services/session-services.js +23 -0
- package/dist/services/session-services.js.map +1 -0
- package/dist/types-global/mcp.d.ts +2 -0
- package/dist/types-global/mcp.d.ts.map +1 -0
- package/dist/types-global/mcp.js +2 -0
- package/dist/types-global/mcp.js.map +1 -0
- package/dist/utils/errors/index.d.ts +2 -0
- package/dist/utils/errors/index.d.ts.map +1 -0
- package/dist/utils/errors/index.js +2 -0
- package/dist/utils/errors/index.js.map +1 -0
- package/dist/utils/platform.d.ts +3 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +5 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/utils/security/rate-limiter.d.ts +3 -0
- package/dist/utils/security/rate-limiter.d.ts.map +1 -0
- package/dist/utils/security/rate-limiter.js +5 -0
- package/dist/utils/security/rate-limiter.js.map +1 -0
- package/dist/utils/telemetry/index.d.ts +2 -0
- package/dist/utils/telemetry/index.d.ts.map +1 -0
- package/dist/utils/telemetry/index.js +2 -0
- package/dist/utils/telemetry/index.js.map +1 -0
- package/dist/utils/telemetry/tracing.d.ts +3 -0
- package/dist/utils/telemetry/tracing.d.ts.map +1 -0
- package/dist/utils/telemetry/tracing.js +4 -0
- package/dist/utils/telemetry/tracing.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { McpError, JsonRpcErrorCode } from "@cesteral/shared";
|
|
2
|
+
export const AMAZON_DSP_ENTITY_ALIASES = {
|
|
3
|
+
campaign: "order",
|
|
4
|
+
adGroup: "lineItem",
|
|
5
|
+
};
|
|
6
|
+
export const AMAZON_DSP_ENTITY_CONTRACT = {
|
|
7
|
+
order: {
|
|
8
|
+
canonicalType: "order",
|
|
9
|
+
aliases: ["campaign"],
|
|
10
|
+
listPath: "/dsp/orders",
|
|
11
|
+
getPath: "/dsp/orders/{entityId}",
|
|
12
|
+
createPath: "/dsp/orders",
|
|
13
|
+
updatePath: "/dsp/orders/{entityId}",
|
|
14
|
+
createMediaType: "application/vnd.dsporders.v2.2+json",
|
|
15
|
+
updateMediaType: "application/vnd.dsporders.v2.2+json",
|
|
16
|
+
idField: "orderId",
|
|
17
|
+
responseKey: "orders",
|
|
18
|
+
listFilterParam: "advertiserId",
|
|
19
|
+
displayName: "Campaign / Order",
|
|
20
|
+
requiredOnCreate: [
|
|
21
|
+
{ field: "name", expectedType: "string" },
|
|
22
|
+
{ field: "advertiserId", expectedType: "string" },
|
|
23
|
+
{ field: "startDateTime", expectedType: "string", hint: "ISO 8601 date-time string" },
|
|
24
|
+
{ field: "endDateTime", expectedType: "string", hint: "ISO 8601 date-time string" },
|
|
25
|
+
],
|
|
26
|
+
readOnlyFields: ["orderId", "creationDate", "lastUpdatedDate", "createdTime", "modifiedTime"],
|
|
27
|
+
notes: [
|
|
28
|
+
"Campaign management is backed by the order object in Amazon DSP.",
|
|
29
|
+
"Amazon released Performance+ support via the optional automatedAdGroupCreation field on the order object.",
|
|
30
|
+
"Budget and pacing fields vary by campaign type; keep payloads aligned with the specific campaign subtype in the Amazon reference.",
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
lineItem: {
|
|
34
|
+
canonicalType: "lineItem",
|
|
35
|
+
aliases: ["adGroup"],
|
|
36
|
+
listPath: "/dsp/lineItems",
|
|
37
|
+
getPath: "/dsp/lineItems/{entityId}",
|
|
38
|
+
createPath: "/dsp/lineItems",
|
|
39
|
+
updatePath: "/dsp/lineItems/{entityId}",
|
|
40
|
+
createMediaType: "application/vnd.dsplineitems.v3.1+json",
|
|
41
|
+
updateMediaType: "application/vnd.dsplineitems.v3.1+json",
|
|
42
|
+
idField: "lineItemId",
|
|
43
|
+
responseKey: "lineItems",
|
|
44
|
+
listFilterParam: "orderId",
|
|
45
|
+
displayName: "Ad Group / Line Item",
|
|
46
|
+
requiredOnCreate: [
|
|
47
|
+
{ field: "name", expectedType: "string" },
|
|
48
|
+
{ field: "orderId", expectedType: "string", hint: "Parent campaign / order ID" },
|
|
49
|
+
{ field: "advertiserId", expectedType: "string" },
|
|
50
|
+
{
|
|
51
|
+
field: "budget",
|
|
52
|
+
expectedType: "object",
|
|
53
|
+
hint: '{ budgetType: "DAILY" | "LIFETIME", budget: number }',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
readOnlyFields: [
|
|
57
|
+
"lineItemId",
|
|
58
|
+
"creationDate",
|
|
59
|
+
"lastUpdatedDate",
|
|
60
|
+
"createdTime",
|
|
61
|
+
"modifiedTime",
|
|
62
|
+
],
|
|
63
|
+
notes: [
|
|
64
|
+
"Ad group management is backed by the line item object in Amazon DSP.",
|
|
65
|
+
"Targeting and optimization options vary by media type and tactic.",
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
creative: {
|
|
69
|
+
canonicalType: "creative",
|
|
70
|
+
aliases: [],
|
|
71
|
+
listPath: "/dsp/creatives",
|
|
72
|
+
getPath: "/dsp/creatives/{entityId}",
|
|
73
|
+
createPath: "/dsp/creatives",
|
|
74
|
+
updatePath: "/dsp/creatives/{entityId}",
|
|
75
|
+
idField: "creativeId",
|
|
76
|
+
responseKey: "creatives",
|
|
77
|
+
listFilterParam: "advertiserId",
|
|
78
|
+
displayName: "Creative",
|
|
79
|
+
requiredOnCreate: [
|
|
80
|
+
{ field: "name", expectedType: "string" },
|
|
81
|
+
{ field: "advertiserId", expectedType: "string" },
|
|
82
|
+
{
|
|
83
|
+
field: "creativeType",
|
|
84
|
+
expectedType: "string",
|
|
85
|
+
hint: "Creative subtype accepted by Amazon DSP",
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
readOnlyFields: [
|
|
89
|
+
"creativeId",
|
|
90
|
+
"creationDate",
|
|
91
|
+
"lastUpdatedDate",
|
|
92
|
+
"createdTime",
|
|
93
|
+
"modifiedTime",
|
|
94
|
+
],
|
|
95
|
+
notes: [
|
|
96
|
+
"Creative creation depends on the underlying format and may require additional assets or subtype-specific fields.",
|
|
97
|
+
"Creative association to line items is modeled separately from creative asset creation.",
|
|
98
|
+
"Amazon DSP has no plain POST /dsp/creatives endpoint — writes are subtype-routed (/dsp/creatives/image, /video, /thirdParty, /rec) with their own vendor media types. The createPath/updatePath above are for read-side aggregation only; create/update via this service will not work until subtype routing is added.",
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
target: {
|
|
102
|
+
canonicalType: "target",
|
|
103
|
+
aliases: [],
|
|
104
|
+
listPath: "/dsp/targets",
|
|
105
|
+
getPath: "/dsp/targets/{entityId}",
|
|
106
|
+
createPath: "/dsp/targets",
|
|
107
|
+
updatePath: "/dsp/targets/{entityId}",
|
|
108
|
+
idField: "targetId",
|
|
109
|
+
responseKey: "targets",
|
|
110
|
+
listFilterParam: "lineItemId",
|
|
111
|
+
displayName: "Target",
|
|
112
|
+
requiredOnCreate: [
|
|
113
|
+
{ field: "lineItemId", expectedType: "string", hint: "Parent ad group / line item ID" },
|
|
114
|
+
],
|
|
115
|
+
readOnlyFields: ["targetId", "creationDate", "lastUpdatedDate", "createdTime", "modifiedTime"],
|
|
116
|
+
notes: [
|
|
117
|
+
"The exact request shape depends on the targeting tactic and media type.",
|
|
118
|
+
"Use Amazon’s current targeting docs to choose the correct expression structure and targeting subtype fields.",
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
creativeAssociation: {
|
|
122
|
+
canonicalType: "creativeAssociation",
|
|
123
|
+
aliases: [],
|
|
124
|
+
listPath: "/dsp/creativeAssociations",
|
|
125
|
+
getPath: "/dsp/creativeAssociations/{entityId}",
|
|
126
|
+
createPath: "/dsp/creativeAssociations",
|
|
127
|
+
updatePath: "/dsp/creativeAssociations/{entityId}",
|
|
128
|
+
idField: "creativeAssociationId",
|
|
129
|
+
responseKey: "creativeAssociations",
|
|
130
|
+
listFilterParam: "lineItemId",
|
|
131
|
+
displayName: "Creative Association",
|
|
132
|
+
requiredOnCreate: [
|
|
133
|
+
{ field: "lineItemId", expectedType: "string", hint: "Parent ad group / line item ID" },
|
|
134
|
+
{ field: "creativeId", expectedType: "string", hint: "Creative asset to associate" },
|
|
135
|
+
],
|
|
136
|
+
readOnlyFields: [
|
|
137
|
+
"creativeAssociationId",
|
|
138
|
+
"creationDate",
|
|
139
|
+
"lastUpdatedDate",
|
|
140
|
+
"createdTime",
|
|
141
|
+
"modifiedTime",
|
|
142
|
+
],
|
|
143
|
+
notes: [
|
|
144
|
+
"Creative associations link existing creative assets to delivery entities.",
|
|
145
|
+
"Amazon’s public launch notes mention creative association batch-read support; callers should prefer Amazon’s latest contract for high-volume association workflows.",
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
export const AMAZON_DSP_CANONICAL_ENTITY_TYPES = Object.keys(AMAZON_DSP_ENTITY_CONTRACT);
|
|
150
|
+
export const AMAZON_DSP_PUBLIC_ENTITY_TYPES = [
|
|
151
|
+
...AMAZON_DSP_CANONICAL_ENTITY_TYPES,
|
|
152
|
+
"campaign",
|
|
153
|
+
"adGroup",
|
|
154
|
+
];
|
|
155
|
+
export const AMAZON_DSP_REPORTING_CONTRACT = {
|
|
156
|
+
submitPathTemplate: "/dsp/reports",
|
|
157
|
+
statusPathTemplate: "/dsp/reports/{reportId}",
|
|
158
|
+
statuses: ["IN_PROGRESS", "SUCCESS", "FAILURE"],
|
|
159
|
+
defaultTimeUnit: "DAILY",
|
|
160
|
+
reportTypes: [
|
|
161
|
+
"CAMPAIGN",
|
|
162
|
+
"INVENTORY",
|
|
163
|
+
"AUDIENCE",
|
|
164
|
+
"PRODUCTS",
|
|
165
|
+
"TECHNOLOGY",
|
|
166
|
+
"GEOGRAPHY",
|
|
167
|
+
"CONVERSION_SOURCE",
|
|
168
|
+
],
|
|
169
|
+
dimensionsByType: {
|
|
170
|
+
CAMPAIGN: ["ORDER", "LINE_ITEM", "CREATIVE"],
|
|
171
|
+
},
|
|
172
|
+
knownMetrics: ["impressions", "totalCost", "viewableImpressions", "viewabilityRate"],
|
|
173
|
+
notes: [
|
|
174
|
+
"POST /dsp/reports body shape: { startDate (YYYYMMDD), endDate (YYYYMMDD), type (one of reportTypes), dimensions?: string[], metrics?: string (comma-separated), timeUnit?: 'DAILY' }.",
|
|
175
|
+
"Returns 202 with { reportId, type, format, status:'IN_PROGRESS', location:'', expiration } — poll GET /dsp/reports/{reportId} until status === 'SUCCESS' (returns presigned S3 download `location`) or 'FAILURE'.",
|
|
176
|
+
"Plain application/json Content-Type works — no vendor media type required (unlike entity writes).",
|
|
177
|
+
"Endpoint is NOT account-scoped — `accountId` is not part of the URL path. The Amazon-Advertising-API-Scope header still identifies the profile.",
|
|
178
|
+
],
|
|
179
|
+
};
|
|
180
|
+
export function normalizeAmazonDspEntityType(entityType) {
|
|
181
|
+
if (entityType in AMAZON_DSP_ENTITY_CONTRACT) {
|
|
182
|
+
return entityType;
|
|
183
|
+
}
|
|
184
|
+
const aliased = AMAZON_DSP_ENTITY_ALIASES[entityType];
|
|
185
|
+
if (aliased) {
|
|
186
|
+
return aliased;
|
|
187
|
+
}
|
|
188
|
+
throw new McpError(JsonRpcErrorCode.InvalidParams, `Unknown Amazon DSP entity type: ${entityType}`);
|
|
189
|
+
}
|
|
190
|
+
export function getAmazonDspEntityContract(entityType) {
|
|
191
|
+
return AMAZON_DSP_ENTITY_CONTRACT[normalizeAmazonDspEntityType(entityType)];
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=amazon-dsp-api-contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amazon-dsp-api-contract.js","sourceRoot":"","sources":["../../../src/services/amazon-dsp/amazon-dsp-api-contract.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AA4C9D,MAAM,CAAC,MAAM,yBAAyB,GAAiD;IACrF,QAAQ,EAAE,OAAO;IACjB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,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,kBAAkB,EAAE,cAAc;IAClC,kBAAkB,EAAE,yBAAyB;IAE7C,QAAQ,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE,SAAS,CAAU;IACxD,eAAe,EAAE,OAAgB;IAEjC,WAAW,EAAE;QACX,UAAU;QACV,WAAW;QACX,UAAU;QACV,UAAU;QACV,YAAY;QACZ,WAAW;QACX,mBAAmB;KACX;IAEV,gBAAgB,EAAE;QAChB,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAU;KACtD;IAMD,YAAY,EAAE,CAAC,aAAa,EAAE,WAAW,EAAE,qBAAqB,EAAE,iBAAiB,CAAC;IACpF,KAAK,EAAE;QACL,uLAAuL;QACvL,mNAAmN;QACnN,mGAAmG;QACnG,iJAAiJ;KAClJ;CACO,CAAC;AAEX,MAAM,UAAU,4BAA4B,CAC1C,UAA8C;IAE9C,IAAI,UAAU,IAAI,0BAA0B,EAAE,CAAC;QAC7C,OAAO,UAA0C,CAAC;IACpD,CAAC;IAED,MAAM,OAAO,GAAG,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACtD,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,IAAI,QAAQ,CAChB,gBAAgB,CAAC,aAAa,EAC9B,mCAAmC,UAAU,EAAE,CAChD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,UAA8C;IAE9C,OAAO,0BAA0B,CAAC,4BAA4B,CAAC,UAAU,CAAC,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AmazonDspAuthAdapter } from "../../auth/amazon-dsp-auth-adapter.js";
|
|
2
|
+
import type { RequestContext } from "@cesteral/shared";
|
|
3
|
+
export declare class AmazonDspHttpClient {
|
|
4
|
+
private readonly authAdapter;
|
|
5
|
+
private readonly profileId;
|
|
6
|
+
private readonly baseUrl;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
constructor(authAdapter: AmazonDspAuthAdapter, profileId: string, baseUrl: string, logger: import("pino").Logger);
|
|
9
|
+
get(path: string, params?: Record<string, string>, context?: RequestContext, accept?: string): Promise<unknown>;
|
|
10
|
+
post(path: string, data?: Record<string, unknown>, context?: RequestContext, accept?: string, contentType?: string): Promise<unknown>;
|
|
11
|
+
put(path: string, data?: Record<string, unknown>, context?: RequestContext, contentType?: string): Promise<unknown>;
|
|
12
|
+
private buildUrl;
|
|
13
|
+
private executeRequest;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=amazon-dsp-http-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amazon-dsp-http-client.d.ts","sourceRoot":"","sources":["../../../src/services/amazon-dsp/amazon-dsp-http-client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAElF,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,kBAAkB,CAAC;AAsDpE,qBAAa,mBAAmB;IAE5B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAHN,WAAW,EAAE,oBAAoB,EACjC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,OAAO,MAAM,EAAE,MAAM;IAO1C,GAAG,CACP,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,OAAO,CAAC,EAAE,cAAc,EACxB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC;IAsBb,IAAI,CACR,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,CAAC,EAAE,cAAc,EACxB,MAAM,CAAC,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,OAAO,CAAC;IAwBb,GAAG,CACP,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,CAAC,EAAE,cAAc,EACxB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,OAAO,CAAC;IAiBnB,OAAO,CAAC,QAAQ;YAYF,cAAc;CAqC7B"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { fetchWithTimeout, executeWithRetry } from "@cesteral/shared";
|
|
2
|
+
import { withAmazonDspApiSpan } from "../../utils/platform.js";
|
|
3
|
+
const AMAZON_DSP_RETRY_CONFIG = {
|
|
4
|
+
maxRetries: 2,
|
|
5
|
+
initialBackoffMs: 2_000,
|
|
6
|
+
maxBackoffMs: 30_000,
|
|
7
|
+
timeoutMs: 30_000,
|
|
8
|
+
platformName: "AmazonDsp",
|
|
9
|
+
tokenExpiryHint: "Amazon DSP token expired. Regenerate via Login with Amazon.",
|
|
10
|
+
};
|
|
11
|
+
function isAmazonDspRetryable(status, _errorBody) {
|
|
12
|
+
return status >= 500;
|
|
13
|
+
}
|
|
14
|
+
function buildAmazonDspNextAction(status, _errorBody, defaultHint) {
|
|
15
|
+
if (status === 401) {
|
|
16
|
+
return "Renew the Amazon DSP access token via Login with Amazon (LWA) using the configured refresh token, then update AMAZON_DSP_ACCESS_TOKEN.";
|
|
17
|
+
}
|
|
18
|
+
if (status === 403) {
|
|
19
|
+
return "Verify the Amazon-Advertising-API-Scope (profileId) and ClientId headers correspond to a profile the user has access to. Use amazon_dsp_list_accounts to discover valid profileIds.";
|
|
20
|
+
}
|
|
21
|
+
if (status === 404) {
|
|
22
|
+
return "Verify the order/lineItem/creative ID with amazon_dsp_list_entities and the accountId with amazon_dsp_list_accounts.";
|
|
23
|
+
}
|
|
24
|
+
if (status === 429) {
|
|
25
|
+
return "Amazon DSP per-LwA-app quota tripped. Amazon does not send Retry-After; wait at least 5 minutes before retrying, and reduce request rate. /dsp/orders, /dsp/lineItems, /dsp/creatives have particularly tight rolling-window limits.";
|
|
26
|
+
}
|
|
27
|
+
return defaultHint;
|
|
28
|
+
}
|
|
29
|
+
export class AmazonDspHttpClient {
|
|
30
|
+
authAdapter;
|
|
31
|
+
profileId;
|
|
32
|
+
baseUrl;
|
|
33
|
+
logger;
|
|
34
|
+
constructor(authAdapter, profileId, baseUrl, logger) {
|
|
35
|
+
this.authAdapter = authAdapter;
|
|
36
|
+
this.profileId = profileId;
|
|
37
|
+
this.baseUrl = baseUrl;
|
|
38
|
+
this.logger = logger;
|
|
39
|
+
}
|
|
40
|
+
async get(path, params, context, accept) {
|
|
41
|
+
const url = this.buildUrl(path, params);
|
|
42
|
+
const headers = accept ? { Accept: accept } : undefined;
|
|
43
|
+
return this.executeRequest(url, context, { method: "GET", headers });
|
|
44
|
+
}
|
|
45
|
+
async post(path, data, context, accept, contentType) {
|
|
46
|
+
const url = this.buildUrl(path);
|
|
47
|
+
const body = JSON.stringify(data ?? {});
|
|
48
|
+
const headers = {
|
|
49
|
+
"Content-Type": contentType ?? "application/json",
|
|
50
|
+
};
|
|
51
|
+
if (accept) {
|
|
52
|
+
headers.Accept = accept;
|
|
53
|
+
}
|
|
54
|
+
else if (contentType) {
|
|
55
|
+
headers.Accept = contentType;
|
|
56
|
+
}
|
|
57
|
+
return this.executeRequest(url, context, {
|
|
58
|
+
method: "POST",
|
|
59
|
+
headers,
|
|
60
|
+
body,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
async put(path, data, context, contentType) {
|
|
64
|
+
const url = this.buildUrl(path);
|
|
65
|
+
const body = JSON.stringify(data ?? {});
|
|
66
|
+
const headers = {
|
|
67
|
+
"Content-Type": contentType ?? "application/json",
|
|
68
|
+
};
|
|
69
|
+
if (contentType) {
|
|
70
|
+
headers.Accept = contentType;
|
|
71
|
+
}
|
|
72
|
+
return this.executeRequest(url, context, {
|
|
73
|
+
method: "PUT",
|
|
74
|
+
headers,
|
|
75
|
+
body,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
buildUrl(path, params) {
|
|
79
|
+
const url = new URL(`${this.baseUrl}${path}`);
|
|
80
|
+
if (params) {
|
|
81
|
+
for (const [key, value] of Object.entries(params)) {
|
|
82
|
+
if (value !== undefined && value !== null) {
|
|
83
|
+
url.searchParams.set(key, value);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return url.toString();
|
|
88
|
+
}
|
|
89
|
+
async executeRequest(url, context, options) {
|
|
90
|
+
const method = options?.method || "GET";
|
|
91
|
+
return withAmazonDspApiSpan(`api.${method}`, url, async (span) => {
|
|
92
|
+
span.setAttribute("http.request.method", method);
|
|
93
|
+
span.setAttribute("http.url", url);
|
|
94
|
+
return executeWithRetry(AMAZON_DSP_RETRY_CONFIG, {
|
|
95
|
+
url,
|
|
96
|
+
fetchOptions: options,
|
|
97
|
+
context,
|
|
98
|
+
logger: this.logger,
|
|
99
|
+
fetchFn: fetchWithTimeout,
|
|
100
|
+
getHeaders: async () => {
|
|
101
|
+
const accessToken = await this.authAdapter.getAccessToken();
|
|
102
|
+
const headers = {
|
|
103
|
+
...normalizeHeaders(options?.headers),
|
|
104
|
+
Authorization: `Bearer ${accessToken}`,
|
|
105
|
+
"Amazon-Advertising-API-Scope": this.profileId,
|
|
106
|
+
};
|
|
107
|
+
if (options?.body && !headers["Content-Type"]) {
|
|
108
|
+
headers["Content-Type"] = "application/json";
|
|
109
|
+
}
|
|
110
|
+
const clientId = this.authAdapter.clientId;
|
|
111
|
+
if (clientId) {
|
|
112
|
+
headers["Amazon-Advertising-API-ClientId"] = clientId;
|
|
113
|
+
}
|
|
114
|
+
return headers;
|
|
115
|
+
},
|
|
116
|
+
buildNextAction: buildAmazonDspNextAction,
|
|
117
|
+
isRetryable: isAmazonDspRetryable,
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function normalizeHeaders(headers) {
|
|
123
|
+
if (!headers) {
|
|
124
|
+
return {};
|
|
125
|
+
}
|
|
126
|
+
if (headers instanceof Headers) {
|
|
127
|
+
return Object.fromEntries(headers.entries());
|
|
128
|
+
}
|
|
129
|
+
if (Array.isArray(headers)) {
|
|
130
|
+
return Object.fromEntries(headers);
|
|
131
|
+
}
|
|
132
|
+
const normalized = {};
|
|
133
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
134
|
+
normalized[key] = Array.isArray(value) ? value.join(", ") : String(value);
|
|
135
|
+
}
|
|
136
|
+
return normalized;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=amazon-dsp-http-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amazon-dsp-http-client.js","sourceRoot":"","sources":["../../../src/services/amazon-dsp/amazon-dsp-http-client.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAO/D,MAAM,uBAAuB,GAAgB;IAC3C,UAAU,EAAE,CAAC;IACb,gBAAgB,EAAE,KAAK;IACvB,YAAY,EAAE,MAAM;IACpB,SAAS,EAAE,MAAM;IACjB,YAAY,EAAE,WAAW;IACzB,eAAe,EAAE,6DAA6D;CAC/E,CAAC;AAEF,SAAS,oBAAoB,CAAC,MAAc,EAAE,UAAkB;IAC9D,OAAO,MAAM,IAAI,GAAG,CAAC;AACvB,CAAC;AAED,SAAS,wBAAwB,CAC/B,MAAc,EACd,UAAkB,EAClB,WAA+B;IAE/B,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACnB,OAAO,wIAAwI,CAAC;IAClJ,CAAC;IACD,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACnB,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,CAAC;IACL,CAAC;CACF;AAED,SAAS,gBAAgB,CAAC,OAAgC;IACxD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,OAAO,YAAY,OAAO,EAAE,CAAC;QAC/B,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,UAAU,GAA2B,EAAE,CAAC;IAC9C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { AmazonDspHttpClient } from "./amazon-dsp-http-client.js";
|
|
2
|
+
import type { RateLimiter } from "@cesteral/shared";
|
|
3
|
+
import { type RequestContext } from "@cesteral/shared";
|
|
4
|
+
import type { Logger } from "pino";
|
|
5
|
+
import { AMAZON_DSP_REPORTING_CONTRACT } from "./amazon-dsp-api-contract.js";
|
|
6
|
+
export type ReportTaskStatus = (typeof AMAZON_DSP_REPORTING_CONTRACT.statuses)[number];
|
|
7
|
+
interface ReportTaskCheckData {
|
|
8
|
+
reportId: string;
|
|
9
|
+
status: ReportTaskStatus;
|
|
10
|
+
location?: string;
|
|
11
|
+
type?: string;
|
|
12
|
+
format?: string;
|
|
13
|
+
statusDetails?: string;
|
|
14
|
+
expiration?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface AmazonDspReportConfig {
|
|
17
|
+
startDate: string;
|
|
18
|
+
endDate: string;
|
|
19
|
+
type: string;
|
|
20
|
+
dimensions?: string[];
|
|
21
|
+
metrics?: string[];
|
|
22
|
+
timeUnit?: "DAILY" | "SUMMARY";
|
|
23
|
+
}
|
|
24
|
+
export declare class AmazonDspReportingService {
|
|
25
|
+
private readonly rateLimiter;
|
|
26
|
+
private readonly httpClient;
|
|
27
|
+
private readonly logger;
|
|
28
|
+
private readonly pollIntervalMs;
|
|
29
|
+
private readonly maxPollAttempts;
|
|
30
|
+
constructor(rateLimiter: RateLimiter, httpClient: AmazonDspHttpClient, logger: Logger, pollIntervalMs?: number, maxPollAttempts?: number);
|
|
31
|
+
submitReport(reportConfig: AmazonDspReportConfig, context?: RequestContext): Promise<{
|
|
32
|
+
taskId: string;
|
|
33
|
+
}>;
|
|
34
|
+
pollReport(taskId: string, context?: RequestContext): Promise<ReportTaskCheckData>;
|
|
35
|
+
checkReportStatus(taskId: string, context?: RequestContext): Promise<{
|
|
36
|
+
taskId: string;
|
|
37
|
+
status: ReportTaskStatus;
|
|
38
|
+
downloadUrl?: string;
|
|
39
|
+
}>;
|
|
40
|
+
downloadReport(downloadUrl: string, maxRows?: number, context?: RequestContext, options?: {
|
|
41
|
+
includeRawCsv?: boolean;
|
|
42
|
+
}): Promise<{
|
|
43
|
+
rows: string[][];
|
|
44
|
+
headers: string[];
|
|
45
|
+
totalRows: number;
|
|
46
|
+
rawCsv?: string;
|
|
47
|
+
rawMimeType?: string;
|
|
48
|
+
}>;
|
|
49
|
+
getReport(reportConfig: AmazonDspReportConfig, maxRowsOrContext?: number | RequestContext, context?: RequestContext): Promise<{
|
|
50
|
+
rows: string[][];
|
|
51
|
+
headers: string[];
|
|
52
|
+
totalRows: number;
|
|
53
|
+
taskId: string;
|
|
54
|
+
}>;
|
|
55
|
+
getReportBreakdowns(reportConfig: AmazonDspReportConfig, breakdowns: string[], maxRowsOrContext?: number | RequestContext, context?: RequestContext): Promise<{
|
|
56
|
+
rows: string[][];
|
|
57
|
+
headers: string[];
|
|
58
|
+
totalRows: number;
|
|
59
|
+
taskId: string;
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=amazon-dsp-reporting-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amazon-dsp-reporting-service.d.ts","sourceRoot":"","sources":["../../../src/services/amazon-dsp/amazon-dsp-reporting-service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAaL,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAG7E,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,6BAA6B,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAGvF,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,gBAAgB,CAAC;IAEzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,WAAW,qBAAqB;IAEpC,SAAS,EAAE,MAAM,CAAC;IAElB,OAAO,EAAE,MAAM,CAAC;IAEhB,IAAI,EAAE,MAAM,CAAC;IAEb,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAEtB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB,QAAQ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M,GAAG,cAAwC,EACnE,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IA+BhF,mBAAmB,CACvB,YAAY,EAAE,qBAAqB,EACnC,UAAU,EAAE,MAAM,EAAE,EACpB,gBAAgB,GAAE,MAAM,GAAG,cAAwC,EACnE,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAQvF"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { fetchWithTimeout, McpError, JsonRpcErrorCode, DEFAULT_REPORT_MAX_BACKOFF_MS, DEFAULT_REPORT_POLL_INTERVAL_MS, DEFAULT_REPORT_MAX_POLL_ATTEMPTS, DEFAULT_REPORT_DOWNLOAD_TIMEOUT_MS, DEFAULT_REPORT_MAX_SIZE_BYTES, DEFAULT_REPORT_MAX_ROWS, parseCSV, pollUntilComplete, ReportFailedError, } from "@cesteral/shared";
|
|
2
|
+
import { AMAZON_DSP_REPORTING_CONTRACT } from "./amazon-dsp-api-contract.js";
|
|
3
|
+
function toCompactDate(isoDate) {
|
|
4
|
+
return /^\d{8}$/.test(isoDate) ? isoDate : isoDate.replace(/-/g, "");
|
|
5
|
+
}
|
|
6
|
+
export class AmazonDspReportingService {
|
|
7
|
+
rateLimiter;
|
|
8
|
+
httpClient;
|
|
9
|
+
logger;
|
|
10
|
+
pollIntervalMs;
|
|
11
|
+
maxPollAttempts;
|
|
12
|
+
constructor(rateLimiter, httpClient, logger, pollIntervalMs = DEFAULT_REPORT_POLL_INTERVAL_MS, maxPollAttempts = DEFAULT_REPORT_MAX_POLL_ATTEMPTS) {
|
|
13
|
+
this.rateLimiter = rateLimiter;
|
|
14
|
+
this.httpClient = httpClient;
|
|
15
|
+
this.logger = logger;
|
|
16
|
+
this.pollIntervalMs = pollIntervalMs;
|
|
17
|
+
this.maxPollAttempts = maxPollAttempts;
|
|
18
|
+
}
|
|
19
|
+
async submitReport(reportConfig, context) {
|
|
20
|
+
await this.rateLimiter.consume(`amazon_dsp:reporting`);
|
|
21
|
+
const body = {
|
|
22
|
+
startDate: toCompactDate(reportConfig.startDate),
|
|
23
|
+
endDate: toCompactDate(reportConfig.endDate),
|
|
24
|
+
type: reportConfig.type,
|
|
25
|
+
timeUnit: reportConfig.timeUnit ?? AMAZON_DSP_REPORTING_CONTRACT.defaultTimeUnit,
|
|
26
|
+
};
|
|
27
|
+
if (reportConfig.dimensions && reportConfig.dimensions.length > 0) {
|
|
28
|
+
body.dimensions = reportConfig.dimensions;
|
|
29
|
+
}
|
|
30
|
+
if (reportConfig.metrics && reportConfig.metrics.length > 0) {
|
|
31
|
+
body.metrics = reportConfig.metrics.join(",");
|
|
32
|
+
}
|
|
33
|
+
const result = (await this.httpClient.post(AMAZON_DSP_REPORTING_CONTRACT.submitPathTemplate, body, context));
|
|
34
|
+
return { taskId: result.reportId };
|
|
35
|
+
}
|
|
36
|
+
async pollReport(taskId, context) {
|
|
37
|
+
this.logger.debug({ taskId, maxPollAttempts: this.maxPollAttempts }, "Starting report poll");
|
|
38
|
+
const path = AMAZON_DSP_REPORTING_CONTRACT.statusPathTemplate.replace("{reportId}", encodeURIComponent(taskId));
|
|
39
|
+
try {
|
|
40
|
+
return await pollUntilComplete({
|
|
41
|
+
fetchStatus: async () => {
|
|
42
|
+
await this.rateLimiter.consume(`amazon_dsp:reporting`);
|
|
43
|
+
return (await this.httpClient.get(path, undefined, context));
|
|
44
|
+
},
|
|
45
|
+
isComplete: (r) => r.status === "SUCCESS",
|
|
46
|
+
isFailed: (r) => r.status === "FAILURE",
|
|
47
|
+
initialDelayMs: this.pollIntervalMs,
|
|
48
|
+
maxDelayMs: DEFAULT_REPORT_MAX_BACKOFF_MS,
|
|
49
|
+
maxAttempts: this.maxPollAttempts,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
if (err instanceof ReportFailedError) {
|
|
54
|
+
return err.status;
|
|
55
|
+
}
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async checkReportStatus(taskId, context) {
|
|
60
|
+
await this.rateLimiter.consume(`amazon_dsp:reporting`);
|
|
61
|
+
const path = AMAZON_DSP_REPORTING_CONTRACT.statusPathTemplate.replace("{reportId}", encodeURIComponent(taskId));
|
|
62
|
+
const result = (await this.httpClient.get(path, undefined, context));
|
|
63
|
+
return {
|
|
64
|
+
taskId: result.reportId,
|
|
65
|
+
status: result.status,
|
|
66
|
+
downloadUrl: result.location,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
async downloadReport(downloadUrl, maxRows = DEFAULT_REPORT_MAX_ROWS, context, options = {}) {
|
|
70
|
+
const response = await fetchWithTimeout(downloadUrl, DEFAULT_REPORT_DOWNLOAD_TIMEOUT_MS, context);
|
|
71
|
+
if (!response.ok) {
|
|
72
|
+
throw new McpError(JsonRpcErrorCode.InternalError, `Failed to download Amazon DSP report: ${response.status} ${response.statusText}`);
|
|
73
|
+
}
|
|
74
|
+
const contentLength = response.headers?.get("content-length");
|
|
75
|
+
if (contentLength && parseInt(contentLength, 10) > DEFAULT_REPORT_MAX_SIZE_BYTES) {
|
|
76
|
+
throw new McpError(JsonRpcErrorCode.InternalError, `Amazon DSP report too large (${contentLength} bytes, limit ${DEFAULT_REPORT_MAX_SIZE_BYTES}). Use more restrictive filters or date ranges.`);
|
|
77
|
+
}
|
|
78
|
+
const text = await response.text();
|
|
79
|
+
const contentType = response.headers?.get("content-type") ?? "";
|
|
80
|
+
const looksLikeJson = contentType.includes("application/json") ||
|
|
81
|
+
text.trimStart().startsWith("[") ||
|
|
82
|
+
text.trimStart().startsWith("{");
|
|
83
|
+
const rawExtras = options.includeRawCsv
|
|
84
|
+
? { rawCsv: text, rawMimeType: looksLikeJson ? "application/json" : "text/csv" }
|
|
85
|
+
: {};
|
|
86
|
+
if (looksLikeJson) {
|
|
87
|
+
const parsed = JSON.parse(text);
|
|
88
|
+
const data = Array.isArray(parsed) ? parsed : [parsed];
|
|
89
|
+
if (data.length === 0) {
|
|
90
|
+
return { rows: [], headers: [], totalRows: 0, ...rawExtras };
|
|
91
|
+
}
|
|
92
|
+
const headers = Object.keys(data[0]);
|
|
93
|
+
const totalRows = data.length;
|
|
94
|
+
const limitedData = data.slice(0, maxRows);
|
|
95
|
+
const rows = limitedData.map((row) => headers.map((h) => String(row[h] ?? "")));
|
|
96
|
+
return { rows, headers, totalRows, ...rawExtras };
|
|
97
|
+
}
|
|
98
|
+
if (text.replace(/^\uFEFF/, "").trim() === "") {
|
|
99
|
+
return { rows: [], headers: [], totalRows: 0, ...rawExtras };
|
|
100
|
+
}
|
|
101
|
+
const { headers, rows: recordRows } = parseCSV(text);
|
|
102
|
+
if (headers.length === 0 && recordRows.length === 0) {
|
|
103
|
+
return { rows: [], headers: [], totalRows: 0, ...rawExtras };
|
|
104
|
+
}
|
|
105
|
+
const limited = recordRows.slice(0, maxRows);
|
|
106
|
+
const rows = limited.map((record) => headers.map((h) => record[h] ?? ""));
|
|
107
|
+
return { rows, headers, totalRows: recordRows.length, ...rawExtras };
|
|
108
|
+
}
|
|
109
|
+
async getReport(reportConfig, maxRowsOrContext = DEFAULT_REPORT_MAX_ROWS, context) {
|
|
110
|
+
const maxRows = typeof maxRowsOrContext === "number" ? maxRowsOrContext : DEFAULT_REPORT_MAX_ROWS;
|
|
111
|
+
const requestContext = typeof maxRowsOrContext === "number" ? context : maxRowsOrContext;
|
|
112
|
+
const { taskId } = await this.submitReport(reportConfig, requestContext);
|
|
113
|
+
const taskResult = await this.pollReport(taskId, requestContext);
|
|
114
|
+
if (taskResult.status === "FAILURE") {
|
|
115
|
+
throw new McpError(JsonRpcErrorCode.InternalError, `Amazon DSP report task ${taskId} failed`);
|
|
116
|
+
}
|
|
117
|
+
if (!taskResult.location) {
|
|
118
|
+
throw new McpError(JsonRpcErrorCode.InternalError, `Amazon DSP report task ${taskId} completed but has no download URL`);
|
|
119
|
+
}
|
|
120
|
+
const reportData = await this.downloadReport(taskResult.location, maxRows, requestContext);
|
|
121
|
+
return {
|
|
122
|
+
...reportData,
|
|
123
|
+
taskId,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
async getReportBreakdowns(reportConfig, breakdowns, maxRowsOrContext = DEFAULT_REPORT_MAX_ROWS, context) {
|
|
127
|
+
const configWithBreakdowns = {
|
|
128
|
+
...reportConfig,
|
|
129
|
+
dimensions: [...(reportConfig.dimensions ?? []), ...breakdowns],
|
|
130
|
+
};
|
|
131
|
+
return this.getReport(configWithBreakdowns, maxRowsOrContext, context);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=amazon-dsp-reporting-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amazon-dsp-reporting-service.js","sourceRoot":"","sources":["../../../src/services/amazon-dsp/amazon-dsp-reporting-service.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,gBAAgB,EAChB,6BAA6B,EAC7B,+BAA+B,EAC/B,gCAAgC,EAChC,kCAAkC,EAClC,6BAA6B,EAC7B,uBAAuB,EACvB,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,GAElB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAmC7E,SAAS,aAAa,CAAC,OAAe;IAEpC,OAAO,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,E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