@automate.ax/integration-contracts 0.141.0 → 0.143.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.
@@ -0,0 +1,96 @@
1
+ import { GOOGLE_ADS_CHANGE_EVENT_PAYLOAD_SCHEMA, GOOGLE_ADS_CHANGE_TRIGGER_CONFIG_SCHEMA, } from "./schemas.js";
2
+ const changeContract = {
3
+ configSchema: GOOGLE_ADS_CHANGE_TRIGGER_CONFIG_SCHEMA,
4
+ eventSchema: GOOGLE_ADS_CHANGE_EVENT_PAYLOAD_SCHEMA,
5
+ };
6
+ export const googleAdsTriggerContracts = {
7
+ "googleAds.adGroup.created": changeContract,
8
+ "googleAds.adGroup.removed": changeContract,
9
+ "googleAds.adGroup.updated": changeContract,
10
+ "googleAds.adGroupAd.created": changeContract,
11
+ "googleAds.adGroupAd.removed": changeContract,
12
+ "googleAds.adGroupAd.updated": changeContract,
13
+ "googleAds.adGroupAsset.created": changeContract,
14
+ "googleAds.adGroupAsset.removed": changeContract,
15
+ "googleAds.adGroupAsset.updated": changeContract,
16
+ "googleAds.asset.created": changeContract,
17
+ "googleAds.asset.removed": changeContract,
18
+ "googleAds.asset.updated": changeContract,
19
+ "googleAds.campaign.created": changeContract,
20
+ "googleAds.campaign.removed": changeContract,
21
+ "googleAds.campaign.updated": changeContract,
22
+ "googleAds.campaignAsset.created": changeContract,
23
+ "googleAds.campaignAsset.removed": changeContract,
24
+ "googleAds.campaignAsset.updated": changeContract,
25
+ "googleAds.campaignBudget.created": changeContract,
26
+ "googleAds.campaignBudget.removed": changeContract,
27
+ "googleAds.campaignBudget.updated": changeContract,
28
+ "googleAds.change": changeContract,
29
+ };
30
+ /**
31
+ * Returns the broad and optional semantic event types for one change.
32
+ *
33
+ * @param event - Normalized Google Ads change event.
34
+ */
35
+ export function getGoogleAdsChangeEventTypes(event) {
36
+ const semanticType = getSemanticEventType(event.event.changeResourceType, event.event.resourceChangeOperation);
37
+ return semanticType
38
+ ? ["googleAds.change", semanticType]
39
+ : ["googleAds.change"];
40
+ }
41
+ /**
42
+ * Maps provider resource and operation enums to public event types.
43
+ *
44
+ * @param resource - Provider change resource enum.
45
+ * @param operation - Provider mutation operation.
46
+ */
47
+ function getSemanticEventType(resource, operation) {
48
+ if (operation === "UNSPECIFIED" || operation === "UNKNOWN")
49
+ return undefined;
50
+ switch (resource) {
51
+ case "AD_GROUP":
52
+ return {
53
+ CREATE: "googleAds.adGroup.created",
54
+ REMOVE: "googleAds.adGroup.removed",
55
+ UPDATE: "googleAds.adGroup.updated",
56
+ }[operation];
57
+ case "AD_GROUP_AD":
58
+ return {
59
+ CREATE: "googleAds.adGroupAd.created",
60
+ REMOVE: "googleAds.adGroupAd.removed",
61
+ UPDATE: "googleAds.adGroupAd.updated",
62
+ }[operation];
63
+ case "AD_GROUP_ASSET":
64
+ return {
65
+ CREATE: "googleAds.adGroupAsset.created",
66
+ REMOVE: "googleAds.adGroupAsset.removed",
67
+ UPDATE: "googleAds.adGroupAsset.updated",
68
+ }[operation];
69
+ case "ASSET":
70
+ return {
71
+ CREATE: "googleAds.asset.created",
72
+ REMOVE: "googleAds.asset.removed",
73
+ UPDATE: "googleAds.asset.updated",
74
+ }[operation];
75
+ case "CAMPAIGN":
76
+ return {
77
+ CREATE: "googleAds.campaign.created",
78
+ REMOVE: "googleAds.campaign.removed",
79
+ UPDATE: "googleAds.campaign.updated",
80
+ }[operation];
81
+ case "CAMPAIGN_ASSET":
82
+ return {
83
+ CREATE: "googleAds.campaignAsset.created",
84
+ REMOVE: "googleAds.campaignAsset.removed",
85
+ UPDATE: "googleAds.campaignAsset.updated",
86
+ }[operation];
87
+ case "CAMPAIGN_BUDGET":
88
+ return {
89
+ CREATE: "googleAds.campaignBudget.created",
90
+ REMOVE: "googleAds.campaignBudget.removed",
91
+ UPDATE: "googleAds.campaignBudget.updated",
92
+ }[operation];
93
+ default:
94
+ return undefined;
95
+ }
96
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./api.js";
2
+ export * from "./events.js";
3
+ export * from "./schemas.js";
@@ -0,0 +1,3 @@
1
+ export * from "./api.js";
2
+ export * from "./events.js";
3
+ export * from "./schemas.js";