@segment/action-destinations 3.317.0 → 3.318.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.
Files changed (92) hide show
  1. package/dist/destinations/campaign-manager-360/common-fields.d.ts +3 -0
  2. package/dist/destinations/campaign-manager-360/common-fields.js +306 -0
  3. package/dist/destinations/campaign-manager-360/common-fields.js.map +1 -0
  4. package/dist/destinations/campaign-manager-360/conversionAdjustmentUpload/generated-types.d.ts +45 -0
  5. package/dist/destinations/campaign-manager-360/conversionAdjustmentUpload/generated-types.js +3 -0
  6. package/dist/destinations/campaign-manager-360/conversionAdjustmentUpload/generated-types.js.map +1 -0
  7. package/dist/destinations/campaign-manager-360/conversionAdjustmentUpload/index.d.ts +5 -0
  8. package/dist/destinations/campaign-manager-360/conversionAdjustmentUpload/index.js +86 -0
  9. package/dist/destinations/campaign-manager-360/conversionAdjustmentUpload/index.js.map +1 -0
  10. package/dist/destinations/campaign-manager-360/conversionUpload/generated-types.d.ts +50 -0
  11. package/dist/destinations/campaign-manager-360/conversionUpload/generated-types.js +3 -0
  12. package/dist/destinations/campaign-manager-360/conversionUpload/generated-types.js.map +1 -0
  13. package/dist/destinations/campaign-manager-360/conversionUpload/index.d.ts +5 -0
  14. package/dist/destinations/campaign-manager-360/conversionUpload/index.js +131 -0
  15. package/dist/destinations/campaign-manager-360/conversionUpload/index.js.map +1 -0
  16. package/dist/destinations/campaign-manager-360/generated-types.d.ts +5 -0
  17. package/dist/destinations/campaign-manager-360/generated-types.js +3 -0
  18. package/dist/destinations/campaign-manager-360/generated-types.js.map +1 -0
  19. package/dist/destinations/campaign-manager-360/index.d.ts +4 -0
  20. package/dist/destinations/campaign-manager-360/index.js +63 -0
  21. package/dist/destinations/campaign-manager-360/index.js.map +1 -0
  22. package/dist/destinations/campaign-manager-360/types.d.ts +116 -0
  23. package/dist/destinations/campaign-manager-360/types.js +23 -0
  24. package/dist/destinations/campaign-manager-360/types.js.map +1 -0
  25. package/dist/destinations/campaign-manager-360/utils.d.ts +21 -0
  26. package/dist/destinations/campaign-manager-360/utils.js +175 -0
  27. package/dist/destinations/campaign-manager-360/utils.js.map +1 -0
  28. package/dist/destinations/hubspot/upsertObject/dynamic-fields.js +8 -0
  29. package/dist/destinations/hubspot/upsertObject/dynamic-fields.js.map +1 -1
  30. package/dist/destinations/index.js +1 -0
  31. package/dist/destinations/index.js.map +1 -1
  32. package/dist/destinations/reddit-conversions-api/customEvent/generated-types.d.ts +2 -2
  33. package/dist/destinations/reddit-conversions-api/fields.js +10 -2
  34. package/dist/destinations/reddit-conversions-api/fields.js.map +1 -1
  35. package/dist/destinations/reddit-conversions-api/standardEvent/generated-types.d.ts +2 -2
  36. package/dist/destinations/reddit-conversions-api/utils.js +10 -2
  37. package/dist/destinations/reddit-conversions-api/utils.js.map +1 -1
  38. package/dist/destinations/s3/client.d.ts +15 -0
  39. package/dist/destinations/s3/client.js +105 -0
  40. package/dist/destinations/s3/client.js.map +1 -0
  41. package/dist/destinations/s3/fields.d.ts +3 -0
  42. package/dist/destinations/s3/fields.js +222 -0
  43. package/dist/destinations/s3/fields.js.map +1 -0
  44. package/dist/destinations/s3/functions.d.ts +9 -0
  45. package/dist/destinations/s3/functions.js +66 -0
  46. package/dist/destinations/s3/functions.js.map +1 -0
  47. package/dist/destinations/s3/generated-types.d.ts +6 -0
  48. package/dist/destinations/s3/generated-types.js +3 -0
  49. package/dist/destinations/s3/generated-types.js.map +1 -0
  50. package/dist/destinations/s3/index.d.ts +4 -0
  51. package/dist/destinations/s3/index.js +46 -0
  52. package/dist/destinations/s3/index.js.map +1 -0
  53. package/dist/destinations/s3/syncToS3/generated-types.d.ts +38 -0
  54. package/dist/destinations/s3/syncToS3/generated-types.js +3 -0
  55. package/dist/destinations/s3/syncToS3/generated-types.js.map +1 -0
  56. package/dist/destinations/s3/syncToS3/index.d.ts +5 -0
  57. package/dist/destinations/s3/syncToS3/index.js +22 -0
  58. package/dist/destinations/s3/syncToS3/index.js.map +1 -0
  59. package/dist/destinations/s3/types.d.ts +16 -0
  60. package/dist/destinations/s3/types.js +3 -0
  61. package/dist/destinations/s3/types.js.map +1 -0
  62. package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/functions.d.ts +3 -0
  63. package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/functions.js +80 -0
  64. package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/functions.js.map +1 -0
  65. package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/generated-types.d.ts +12 -0
  66. package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/generated-types.js +3 -0
  67. package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/generated-types.js.map +1 -0
  68. package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/index.d.ts +5 -0
  69. package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/index.js +100 -0
  70. package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/index.js.map +1 -0
  71. package/dist/destinations/stackadapt-audiences/forwardProfile/functions.d.ts +3 -0
  72. package/dist/destinations/stackadapt-audiences/forwardProfile/functions.js +121 -0
  73. package/dist/destinations/stackadapt-audiences/forwardProfile/functions.js.map +1 -0
  74. package/dist/destinations/stackadapt-audiences/forwardProfile/generated-types.d.ts +19 -0
  75. package/dist/destinations/stackadapt-audiences/forwardProfile/generated-types.js +3 -0
  76. package/dist/destinations/stackadapt-audiences/forwardProfile/generated-types.js.map +1 -0
  77. package/dist/destinations/stackadapt-audiences/forwardProfile/index.d.ts +5 -0
  78. package/dist/destinations/stackadapt-audiences/forwardProfile/index.js +186 -0
  79. package/dist/destinations/stackadapt-audiences/forwardProfile/index.js.map +1 -0
  80. package/dist/destinations/stackadapt-audiences/functions.d.ts +6 -0
  81. package/dist/destinations/stackadapt-audiences/functions.js +54 -0
  82. package/dist/destinations/stackadapt-audiences/functions.js.map +1 -0
  83. package/dist/destinations/stackadapt-audiences/generated-types.d.ts +3 -0
  84. package/dist/destinations/stackadapt-audiences/generated-types.js +3 -0
  85. package/dist/destinations/stackadapt-audiences/generated-types.js.map +1 -0
  86. package/dist/destinations/stackadapt-audiences/index.d.ts +4 -0
  87. package/dist/destinations/stackadapt-audiences/index.js +64 -0
  88. package/dist/destinations/stackadapt-audiences/index.js.map +1 -0
  89. package/dist/destinations/stackadapt-audiences/types.d.ts +15 -0
  90. package/dist/destinations/stackadapt-audiences/types.js +3 -0
  91. package/dist/destinations/stackadapt-audiences/types.js.map +1 -0
  92. package/package.json +2 -2
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const functions_1 = require("./functions");
4
+ const functions_2 = require("../functions");
5
+ const action = {
6
+ title: 'Forward Profile',
7
+ description: 'Forward new or updated user profile to StackAdapt',
8
+ defaultSubscription: 'type = "identify" or type = "alias" or type = "track"',
9
+ fields: {
10
+ traits: {
11
+ label: 'User Properties',
12
+ type: 'object',
13
+ description: 'The properties of the user.',
14
+ defaultObjectUI: 'keyvalue',
15
+ additionalProperties: true,
16
+ required: false,
17
+ properties: {
18
+ email: {
19
+ label: 'Email',
20
+ type: 'string',
21
+ description: 'The email address of the user.'
22
+ },
23
+ firstName: {
24
+ label: 'First Name',
25
+ type: 'string',
26
+ description: "The user's first name."
27
+ },
28
+ lastName: {
29
+ label: 'Last Name',
30
+ type: 'string',
31
+ description: "The user's last name."
32
+ },
33
+ phone: {
34
+ label: 'Phone',
35
+ type: 'string',
36
+ description: 'The phone number of the user.'
37
+ },
38
+ city: {
39
+ label: 'City',
40
+ type: 'string',
41
+ description: 'The city of the user.'
42
+ },
43
+ country: {
44
+ label: 'Country',
45
+ type: 'string',
46
+ description: 'The country of the user.'
47
+ },
48
+ state: {
49
+ label: 'State',
50
+ type: 'string',
51
+ description: 'The state of the user.'
52
+ },
53
+ postalCode: {
54
+ label: 'Postal Code',
55
+ type: 'string',
56
+ description: 'The postal code of the user.'
57
+ },
58
+ birthday: {
59
+ label: 'Birthday',
60
+ type: 'string',
61
+ description: 'The birthday of the user.'
62
+ }
63
+ },
64
+ default: {
65
+ email: {
66
+ '@if': {
67
+ exists: { '@path': '$.traits.email' },
68
+ then: { '@path': '$.traits.email' },
69
+ else: { '@path': '$.context.traits.email' }
70
+ }
71
+ },
72
+ firstName: {
73
+ '@if': {
74
+ exists: { '@path': '$.traits.first_name' },
75
+ then: { '@path': '$.traits.first_name' },
76
+ else: { '@path': '$.context.traits.first_name' }
77
+ }
78
+ },
79
+ lastName: {
80
+ '@if': {
81
+ exists: { '@path': '$.traits.last_name' },
82
+ then: { '@path': '$.traits.last_name' },
83
+ else: { '@path': '$.context.traits.last_name' }
84
+ }
85
+ },
86
+ phone: {
87
+ '@if': {
88
+ exists: { '@path': '$.traits.phone' },
89
+ then: { '@path': '$.traits.phone' },
90
+ else: { '@path': '$.context.traits.phone' }
91
+ }
92
+ },
93
+ city: {
94
+ '@if': {
95
+ exists: { '@path': '$.traits.address.city' },
96
+ then: { '@path': '$.traits.address.city' },
97
+ else: { '@path': '$.context.traits.address.city' }
98
+ }
99
+ },
100
+ country: {
101
+ '@if': {
102
+ exists: { '@path': '$.traits.address.country' },
103
+ then: { '@path': '$.traits.address.country' },
104
+ else: { '@path': '$.context.traits.address.country' }
105
+ }
106
+ },
107
+ state: {
108
+ '@if': {
109
+ exists: { '@path': '$.traits.address.state' },
110
+ then: { '@path': '$.traits.address.state' },
111
+ else: { '@path': '$.context.traits.address.state' }
112
+ }
113
+ },
114
+ postalCode: {
115
+ '@if': {
116
+ exists: { '@path': '$.traits.address.postalCode' },
117
+ then: { '@path': '$.traits.address.postalCode' },
118
+ else: { '@path': '$.context.traits.address.postalCode' }
119
+ }
120
+ },
121
+ birthday: {
122
+ '@if': {
123
+ exists: { '@path': '$.traits.birthday' },
124
+ then: { '@path': '$.traits.birthday' },
125
+ else: { '@path': '$.context.traits.birthday' }
126
+ }
127
+ }
128
+ }
129
+ },
130
+ user_id: {
131
+ label: 'Segment User ID',
132
+ description: 'The ID of the user in Segment',
133
+ type: 'string',
134
+ default: {
135
+ '@if': {
136
+ exists: { '@path': '$.userId' },
137
+ then: { '@path': '$.userId' },
138
+ else: { '@path': '$.anonymousId' }
139
+ }
140
+ }
141
+ },
142
+ previous_id: {
143
+ label: 'Previous ID',
144
+ type: 'string',
145
+ description: "The user's previous ID, for alias events",
146
+ default: {
147
+ '@path': '$.previousId'
148
+ }
149
+ },
150
+ event_type: {
151
+ label: 'Event Type',
152
+ description: 'The Segment event type (identify, alias, etc.)',
153
+ type: 'string',
154
+ default: {
155
+ '@path': '$.type'
156
+ }
157
+ },
158
+ enable_batching: {
159
+ type: 'boolean',
160
+ label: 'Batch Profiles',
161
+ unsafe_hidden: true,
162
+ description: 'When enabled, Segment will batch profiles together and send them to StackAdapt in a single request.',
163
+ required: true,
164
+ default: true
165
+ },
166
+ advertiser_id: {
167
+ label: 'Advertiser',
168
+ description: 'The StackAdapt advertiser to add the profile to.',
169
+ type: 'string',
170
+ disabledInputMethods: ['literal', 'variable', 'function', 'freeform', 'enrichment'],
171
+ required: true,
172
+ dynamic: true
173
+ }
174
+ },
175
+ dynamicFields: {
176
+ advertiser_id: functions_2.advertiserIdFieldImplementation
177
+ },
178
+ perform: async (request, { payload }) => {
179
+ return await functions_1.performForwardProfiles(request, [payload]);
180
+ },
181
+ performBatch: async (request, { payload }) => {
182
+ return await functions_1.performForwardProfiles(request, payload);
183
+ }
184
+ };
185
+ exports.default = action;
186
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/stackadapt-audiences/forwardProfile/index.ts"],"names":[],"mappings":";;AAGA,2CAAoD;AACpD,4CAA8D;AAE9D,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,iBAAiB;IACxB,WAAW,EAAE,mDAAmD;IAChE,mBAAmB,EAAE,uDAAuD;IAC5E,MAAM,EAAE;QACN,MAAM,EAAE;YACN,KAAK,EAAE,iBAAiB;YACxB,IAAI,EAAE,QAAQ;Y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AAK,EAAE,YAAY;YACnB,WAAW,EAAE,kDAAkD;YAC/D,IAAI,EAAE,QAAQ;YACd,oBAAoB,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC;YACnF,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,IAAI;SACd;KACF;IACD,aAAa,EAAE;QACb,aAAa,EAAE,2CAA+B;KAC/C;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACtC,OAAO,MAAM,kCAAsB,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IACzD,CAAC;IACD,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAC3C,OAAO,MAAM,kCAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACvD,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createRequestClient, DynamicFieldResponse } from '@segment/actions-core';
2
+ export declare const EXTERNAL_PROVIDER = "segmentio";
3
+ export declare const GQL_ENDPOINT = "https://api.stackadapt.com/graphql";
4
+ export declare function advertiserIdFieldImplementation(request: ReturnType<typeof createRequestClient>): Promise<DynamicFieldResponse>;
5
+ export declare function sha256hash(data: string): string;
6
+ export declare function stringifyJsonWithEscapedQuotes(value: unknown): string;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stringifyJsonWithEscapedQuotes = exports.sha256hash = exports.advertiserIdFieldImplementation = exports.GQL_ENDPOINT = exports.EXTERNAL_PROVIDER = void 0;
4
+ const crypto_1 = require("crypto");
5
+ exports.EXTERNAL_PROVIDER = 'segmentio';
6
+ exports.GQL_ENDPOINT = 'https://api.stackadapt.com/graphql';
7
+ async function advertiserIdFieldImplementation(request) {
8
+ try {
9
+ const query = `query {
10
+ tokenInfo {
11
+ scopesByAdvertiser {
12
+ nodes {
13
+ advertiser {
14
+ id
15
+ name
16
+ }
17
+ scopes
18
+ }
19
+ }
20
+ }
21
+ }`;
22
+ const response = await request(exports.GQL_ENDPOINT, {
23
+ body: JSON.stringify({ query })
24
+ });
25
+ const scopesByAdvertiser = response.data.data.tokenInfo.scopesByAdvertiser;
26
+ const choices = scopesByAdvertiser.nodes
27
+ .filter((advertiserEntry) => advertiserEntry.scopes.includes('WRITE'))
28
+ .map((advertiserEntry) => ({ value: advertiserEntry.advertiser.id, label: advertiserEntry.advertiser.name }))
29
+ .sort((a, b) => a.label.localeCompare(b.label));
30
+ return { choices };
31
+ }
32
+ catch (error) {
33
+ return {
34
+ choices: [],
35
+ nextPage: '',
36
+ error: {
37
+ message: error.message ?? 'Unknown error',
38
+ code: error.status?.toString() ?? 'Unknown error'
39
+ }
40
+ };
41
+ }
42
+ }
43
+ exports.advertiserIdFieldImplementation = advertiserIdFieldImplementation;
44
+ function sha256hash(data) {
45
+ const hash = crypto_1.createHash('sha256');
46
+ hash.update(data);
47
+ return hash.digest('hex');
48
+ }
49
+ exports.sha256hash = sha256hash;
50
+ function stringifyJsonWithEscapedQuotes(value) {
51
+ return JSON.stringify(value).replace(/"/g, '\\"');
52
+ }
53
+ exports.stringifyJsonWithEscapedQuotes = stringifyJsonWithEscapedQuotes;
54
+ //# sourceMappingURL=functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/destinations/stackadapt-audiences/functions.ts"],"names":[],"mappings":";;;AACA,mCAAmC;AAwBtB,QAAA,iBAAiB,GAAG,WAAW,CAAA;AAC/B,QAAA,YAAY,GAAG,oCAAoC,CAAA;AAEzD,KAAK,UAAU,+BAA+B,CACnD,OAA+C;IAE/C,IAAI;QACF,MAAM,KAAK,GAAG;;;;;;;;;;;;QAYV,CAAA;QACJ,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAoB,oBAAY,EAAE;YAC9D,IAAI,EAAE,IA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,EAAE,KAAK,CAAC,CAAA;AACnD,CAAC;AAFD,wEAEC"}
@@ -0,0 +1,3 @@
1
+ export interface Settings {
2
+ apiKey: string;
3
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/destinations/stackadapt-audiences/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { DestinationDefinition } from '@segment/actions-core';
2
+ import type { Settings } from './generated-types';
3
+ declare const destination: DestinationDefinition<Settings>;
4
+ export default destination;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const forwardProfile_1 = __importDefault(require("./forwardProfile"));
7
+ const forwardAudienceEvent_1 = __importDefault(require("./forwardAudienceEvent"));
8
+ const functions_1 = require("./functions");
9
+ const destination = {
10
+ name: 'StackAdapt Audiences',
11
+ slug: 'actions-stackadapt-audiences',
12
+ mode: 'cloud',
13
+ authentication: {
14
+ scheme: 'custom',
15
+ fields: {
16
+ apiKey: {
17
+ label: 'GraphQL Token',
18
+ description: 'Your StackAdapt GQL API Token',
19
+ type: 'string',
20
+ required: true
21
+ }
22
+ },
23
+ testAuthentication: async (request) => {
24
+ const scopeQuery = `query {
25
+ tokenInfo {
26
+ scopesByAdvertiser {
27
+ nodes {
28
+ advertiser {
29
+ name
30
+ }
31
+ scopes
32
+ }
33
+ }
34
+ }
35
+ }`;
36
+ const res = await request(functions_1.GQL_ENDPOINT, {
37
+ body: JSON.stringify({ query: scopeQuery }),
38
+ throwHttpErrors: false
39
+ });
40
+ if (res.status !== 200) {
41
+ throw new Error(res.status + res.statusText);
42
+ }
43
+ const canWrite = (await res.json()).data?.tokenInfo?.scopesByAdvertiser?.nodes?.some((node) => node.scopes.includes('WRITE'));
44
+ if (!canWrite) {
45
+ throw new Error('Please verify your GQL Token or contact support');
46
+ }
47
+ }
48
+ },
49
+ extendRequest: ({ settings }) => {
50
+ return {
51
+ method: 'POST',
52
+ headers: {
53
+ 'Content-Type': 'application/json',
54
+ Authorization: `Bearer ${settings.apiKey}`
55
+ }
56
+ };
57
+ },
58
+ actions: {
59
+ forwardProfile: forwardProfile_1.default,
60
+ forwardAudienceEvent: forwardAudienceEvent_1.default
61
+ }
62
+ };
63
+ exports.default = destination;
64
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/stackadapt-audiences/index.ts"],"names":[],"mappings":";;;;;AAGA,sEAA6C;AAC7C,kFAAyD;AAEzD,2CAA0C;AAE1C,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,sBAAsB;IAC5B,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,MAAM,EAAE;gBACN,KAAK,EAAE,eAAe;gBACtB,WAAW,EAAE,+BAA+B;gBAC5C,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;aACf;SACF;QACD,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACpC,MAAM,UAAU,GAAG;;;;;;;;;;;QAWjB,CAAA;YAEF,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,wBAAY,EAAE;gBACtC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;gBAC3C,eAAe,EAAE,KAAK;aACvB,CAAC,CAAA;YACF,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE;gBACtB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,UAAU,CAAC,CAAA;aAC7C;YACD,MAAM,QAAQ,GACZ,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAClB,CAAC,IAAI,EAAE,SAAS,EAAE,kBAAkB,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,IAA0B,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAA;YACjH,IAAI,CAAC,QAAQ,EAAE;gBACb,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;aACnE;QACH,CAAC;KACF;IACD,aAAa,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC9B,OAAO;YACL,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,UAAU,QAAQ,CAAC,MAAM,EAAE;aAC3C;SACF,CAAA;IACH,CAAC;IACD,OAAO,EAAE;QACP,cAAc,EAAd,wBAAc;QACd,oBAAoB,EAApB,8BAAoB;KACrB;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
@@ -0,0 +1,15 @@
1
+ export interface AdvertiserScopesResponse {
2
+ data: {
3
+ tokenInfo: {
4
+ scopesByAdvertiser: {
5
+ nodes: {
6
+ advertiser: {
7
+ id: string;
8
+ name: string;
9
+ };
10
+ scopes: string[];
11
+ }[];
12
+ };
13
+ };
14
+ };
15
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/destinations/stackadapt-audiences/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@segment/action-destinations",
3
3
  "description": "Destination Actions engine and definitions.",
4
- "version": "3.317.0",
4
+ "version": "3.318.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/segmentio/action-destinations",
@@ -87,5 +87,5 @@
87
87
  "__tests__/__helpers__/"
88
88
  ]
89
89
  },
90
- "gitHead": "571be201590bb64c4187bea54c292f021455f8c0"
90
+ "gitHead": "f9a777beb461f6de2d3ead3d188be206d727317c"
91
91
  }