-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into fix.snowpipe-streaming-users
- Loading branch information
Showing
117 changed files
with
7,375 additions
and
3,861 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const SUPPORTED_EVENT_TYPE = 'record'; | ||
export const ACTION_TYPES = ['insert', 'delete']; | ||
export const BASE_ENDPOINT = 'https://api.linkedin.com/rest'; | ||
export const USER_ENDPOINT = '/dmpSegments/audienceId/users'; | ||
export const COMPANY_ENDPOINT = '/dmpSegments/audienceId/companies'; | ||
export const FIELD_MAP = { | ||
sha256Email: 'SHA256_EMAIL', | ||
sha512Email: 'SHA512_EMAIL', | ||
googleAid: 'GOOGLE_AID', | ||
}; |
89 changes: 89 additions & 0 deletions
89
src/cdk/v2/destinations/linkedin_audience/procWorkflow.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
bindings: | ||
- path: ./config | ||
exportAll: true | ||
- path: ./utils | ||
exportAll: true | ||
- name: defaultRequestConfig | ||
path: ../../../../v0/util | ||
|
||
steps: | ||
- name: validateInput | ||
description: Validate input, if all the required fields are available or not. | ||
template: | | ||
const config = .connection.config.destination; | ||
const secret = .metadata.secret; | ||
let messageType = .message.type; | ||
$.assertConfig(config.audienceId, "Audience Id is not present. Aborting"); | ||
$.assertConfig(secret.accessToken, "Access Token is not present. Aborting"); | ||
$.assertConfig(config.audienceType, "audienceType is not present. Aborting"); | ||
$.assert(messageType, "Message Type is not present. Aborting message."); | ||
$.assert(messageType.toLowerCase() === $.SUPPORTED_EVENT_TYPE, `Event type ${.message.type.toLowerCase()} is not supported. Aborting message.`); | ||
$.assert(.message.fields, "`fields` is not present. Aborting message."); | ||
$.assert(.message.identifiers, "`identifiers` is not present inside properties. Aborting message."); | ||
$.assert($.containsAll([.message.action], $.ACTION_TYPES), "Unsupported action type. Aborting message.") | ||
- name: getConfigs | ||
description: This step fetches the configs from different places and combines them. | ||
template: | | ||
const config = .connection.config.destination; | ||
{ | ||
audienceType: config.audienceType, | ||
audienceId: config.audienceId, | ||
accessToken: .metadata.secret.accessToken, | ||
isHashRequired: config.isHashRequired, | ||
} | ||
- name: prepareUserTypeBasePayload | ||
condition: $.outputs.getConfigs.audienceType === 'user' | ||
steps: | ||
- name: prepareUserIds | ||
description: Prepare user ids for user audience type | ||
template: | | ||
const identifiers = $.outputs.getConfigs.isHashRequired === true ? | ||
$.hashIdentifiers(.message.identifiers) : | ||
.message.identifiers; | ||
$.prepareUserIds(identifiers) | ||
- name: preparePayload | ||
description: Prepare base payload for user audiences | ||
template: | | ||
const payload = { | ||
'elements': [ | ||
{ | ||
'action': $.generateActionType(.message.action), | ||
'userIds': $.outputs.prepareUserTypeBasePayload.prepareUserIds, | ||
....message.fields | ||
} | ||
] | ||
} | ||
payload; | ||
- name: prepareCompanyTypeBasePayload | ||
description: Prepare base payload for company audiences | ||
condition: $.outputs.getConfigs.audienceType === 'company' | ||
template: | | ||
const payload = { | ||
'elements': [ | ||
{ | ||
'action': $.generateActionType(.message.action), | ||
....message.identifiers, | ||
....message.fields | ||
} | ||
] | ||
} | ||
payload; | ||
- name: buildResponseForProcessTransformation | ||
description: build response depending upon batch size | ||
template: | | ||
const response = $.defaultRequestConfig(); | ||
response.body.JSON = {...$.outputs.prepareUserTypeBasePayload, ...$.outputs.prepareCompanyTypeBasePayload}; | ||
response.endpoint = $.generateEndpoint($.outputs.getConfigs.audienceType, $.outputs.getConfigs.audienceId); | ||
response.headers = { | ||
"Authorization": "Bearer " + $.outputs.getConfigs.accessToken, | ||
"Content-Type": "application/json", | ||
"X-RestLi-Method": "BATCH_CREATE", | ||
"X-Restli-Protocol-Version": "2.0.0", | ||
"LinkedIn-Version": "202409" | ||
}; | ||
response; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
bindings: | ||
- path: ./utils | ||
- name: handleRtTfSingleEventError | ||
path: ../../../../v0/util/index | ||
|
||
steps: | ||
- name: validateInput | ||
template: | | ||
$.assert(Array.isArray(^) && ^.length > 0, "Invalid event array") | ||
- name: transform | ||
externalWorkflow: | ||
path: ./procWorkflow.yaml | ||
bindings: | ||
- name: batchMode | ||
value: true | ||
loopOverInput: true | ||
|
||
- name: successfulEvents | ||
template: | | ||
$.outputs.transform#idx.output.({ | ||
"message": .[], | ||
"destination": ^ [idx].destination, | ||
"metadata": ^ [idx].metadata | ||
})[] | ||
- name: failedEvents | ||
template: | | ||
$.outputs.transform#idx.error.( | ||
$.handleRtTfSingleEventError(^[idx], .originalError ?? ., {}) | ||
)[] | ||
- name: batchSuccessfulEvents | ||
description: Batches the successfulEvents | ||
template: | | ||
$.batchResponseBuilder($.outputs.successfulEvents); | ||
- name: finalPayload | ||
template: | | ||
[...$.outputs.batchSuccessfulEvents, ...$.outputs.failedEvents] |
Oops, something went wrong.