Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/1842 resolve automationid in event #1845

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions @types/lib/metadataTypes/Event.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion @types/lib/metadataTypes/Event.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions @types/lib/metadataTypes/definitions/Event.definition.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions lib/metadataTypes/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,23 @@ class Event extends MetadataType {
break;
}
}

// automation
if (metadata.r__automation_key) {
metadata.automationId = cache.searchForField(
'automation',
metadata.r__automation_key,
'key',
'id'
);
if (metadata.arguments) {
metadata.arguments.automationId = metadata.automationId;
}
delete metadata.arguments.automationId;
}
// dataExteension
// is resolved in createOrUpdate

await this.preDeployTasks_SalesforceEntryEvents(
metadata.type,
metadata.configurationArguments
Expand Down Expand Up @@ -453,6 +470,29 @@ class Event extends MetadataType {
);
}

// automation
try {
if (
metadata?.automationId &&
metadata?.automationId !== '00000000-0000-0000-0000-000000000000'
) {
metadata.r__automation_key = cache.searchForField(
'automation',
metadata.automationId,
'id',
'key'
);
delete metadata.automationId;
delete metadata.arguments?.automationId;
}
} catch (ex) {
Util.logger.verbose(
` - ${this.definition.type} ${metadata[this.definition.nameField]} (${
metadata[this.definition.keyField]
}): ${ex.message}.`
);
}
// dataExtension
try {
metadata.r__dataExtension_key = cache.searchForField(
'dataExtension',
Expand Down
10 changes: 8 additions & 2 deletions lib/metadataTypes/definitions/Event.definition.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default {
bodyIteratorField: 'items',
dependencies: ['dataExtension', 'user'],
dependencyGraph: { dataExtension: ['r__dataExtension_key'] },
dependencies: ['automation', 'dataExtension', 'user'],
dependencyGraph: { automation: ['r__automation_key'], dataExtension: ['r__dataExtension_key'] },
hasExtended: false,
idField: 'id',
keyIsFixed: false,
Expand Down Expand Up @@ -970,5 +970,11 @@ export default {
retrieving: true,
template: true,
},
r__automation_key: {
isCreateable: false,
isUpdateable: false,
retrieving: true,
template: true,
},
},
};
20 changes: 10 additions & 10 deletions test/general.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ describe('GENERAL', () => {
// download first before we test buildTemplate
await handler.retrieve('testInstance/testBU', ['automation', 'query']);

const expectedApiCallsRetrieve = 28;
const expectedApiCallsRetrieve = 30;
assert.equal(
testUtils.getAPIHistoryLength(),
expectedApiCallsRetrieve,
Expand Down Expand Up @@ -813,7 +813,7 @@ describe('GENERAL', () => {
});

it('buildTemplate + buildDefinition for multiple types with keys and --retrieve', async () => {
const expectedApiCallsRetrieve = 29;
const expectedApiCallsRetrieve = 30;

// preparation
const argvMetadata = [
Expand Down Expand Up @@ -918,7 +918,7 @@ describe('GENERAL', () => {
// download first before we test buildTemplate
await handler.retrieve('testInstance/testBU');

const expectedApiCallsRetrieve = 87;
const expectedApiCallsRetrieve = 89;
assert.equal(
testUtils.getAPIHistoryLength(),
expectedApiCallsRetrieve,
Expand Down Expand Up @@ -1046,7 +1046,7 @@ describe('GENERAL', () => {
});

it('buildTemplate + buildDefinition for multiple types with keys and --dependencies and --retrieve', async () => {
const expectedApiCallsRetrieve = 91;
const expectedApiCallsRetrieve = 93;

// preparation
const argvMetadata = [
Expand Down Expand Up @@ -1171,7 +1171,7 @@ describe('GENERAL', () => {
// download first before we test buildTemplate
await handler.retrieve('testInstance/testBU', ['automation', 'query']);

const expectedApiCallsRetrieve = 28;
const expectedApiCallsRetrieve = 30;
assert.equal(
testUtils.getAPIHistoryLength(),
expectedApiCallsRetrieve,
Expand Down Expand Up @@ -1363,7 +1363,7 @@ describe('GENERAL', () => {
// download first before we test buildTemplate
await handler.retrieve('testInstance/testBU', ['automation', 'query']);

const expectedApiCallsRetrieve = 28;
const expectedApiCallsRetrieve = 30;
assert.equal(
testUtils.getAPIHistoryLength(),
expectedApiCallsRetrieve,
Expand Down Expand Up @@ -1454,7 +1454,7 @@ describe('GENERAL', () => {
// download everything before we test buildTemplate
await handler.retrieve('testInstance/testBU');

const expectedApiCallsRetrieve = 87;
const expectedApiCallsRetrieve = 89;
assert.equal(
testUtils.getAPIHistoryLength(),
expectedApiCallsRetrieve,
Expand Down Expand Up @@ -1564,7 +1564,7 @@ describe('GENERAL', () => {
});

it('build multiple type with keys and --dependencies and --retrieve', async () => {
const expectedApiCallsRetrieve = 91;
const expectedApiCallsRetrieve = 93;

// preparation
const argvMetadata = [
Expand Down Expand Up @@ -1671,7 +1671,7 @@ describe('GENERAL', () => {
// download first before we test buildTemplate
await handler.retrieve('testInstance/testBU', ['automation', 'query']);

const expectedApiCallsRetrieve = 28;
const expectedApiCallsRetrieve = 30;
assert.equal(
testUtils.getAPIHistoryLength(),
expectedApiCallsRetrieve,
Expand Down Expand Up @@ -1849,7 +1849,7 @@ describe('GENERAL', () => {
// download first before we test buildTemplate
await handler.retrieve('testInstance/testBU');

const expectedApiCallsRetrieve = 87;
const expectedApiCallsRetrieve = 89;
assert.equal(
testUtils.getAPIHistoryLength(),
expectedApiCallsRetrieve,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"id": "8f82c2a7-0bae-45a9-bdee-e631ab25c0d5",
"name": "testExisting_automation_event",
"description": "",
"key": "testExisting_automation_event",
"typeId": 1,
"type": "scheduled",
"statusId": 6,
"status": "Scheduled",
"categoryId": 290937,
"lastRunTime": "2024-11-08T03:15:20.27",
"lastRunInstanceId": "b2bc1d03-04ba-4a01-9e33-0c246f07dd36",
"schedule": {
"id": "064cf4ba-a5d0-420a-8a4f-26055a3550ba",
"typeId": 2,
"startDate": "2024-11-07T12:15:00",
"endDate": "2079-06-06T00:00:00",
"scheduledTime": "2024-11-08T11:15:00",
"rangeTypeId": 1,
"occurrences": 478403,
"pattern": "<Pattern><PatternType>0</PatternType><HourInterval>1</HourInterval></Pattern>",
"icalRecur": "FREQ=HOURLY;UNTIL=20790606T080000;INTERVAL=1",
"timezoneName": "W. Europe Standard Time",
"scheduleStatus": "active",
"timezoneId": 5
},
"steps": [
{
"id": "83755b3f-5012-49b4-8112-0291c879b9d5",
"name": "",
"description": "",
"step": 1,
"activities": [
{
"id": "39d74fe0-ced2-4e91-b23e-11218adc304c",
"name": "testExisting_event_automation",
"activityObjectId": "161b64a1-1867-4272-8c5c-4d7abe880702",
"objectTypeId": 952,
"displayOrder": 1
}
]
}
]
}
42 changes: 42 additions & 0 deletions test/resources/9999999/event/get-automation-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"type": "AutomationAudience",
"name": "testExisting_event_automation",
"description": "",
"createdDate": "2024-11-07T04:58:46.51",
"createdBy": "Jörn Berkefeld",
"modifiedDate": "2024-11-07T04:58:46.51",
"modifiedBy": "Jörn Berkefeld",
"eventDefinitionKey": "testExisting_event_automation",
"sourceApplicationExtensionId": "97e942ee-6914-4d3d-9e52-37ecb71f79ed",
"filterDefinitionId": "00000000-0000-0000-0000-000000000000",
"filterDefinitionTemplate": "",
"iconUrl": "/images/icon-data-extension.svg",
"arguments": {
"serializedObjectType": 9,
"useHighWatermark": true,
"resetHighWatermark": false,
"criteria": ""
},
"configurationArguments": {},
"metaData": {
"criteriaDescription": "",
"scheduleFlowMode": "automation"
},
"schedule": {
"startDateTime": "2024-11-07T12:15:00",
"endDateTime": "2079-06-06T00:00:00",
"timeZone": "W. Europe Standard Time",
"occurrences": 478403,
"endType": "EndDate",
"frequency": "Hourly",
"recurrencePattern": "Interval",
"interval": 1
},
"interactionCount": 1,
"isVisibleInPicker": false,
"category": "Audience",
"publishedInteractionCount": 1,
"disableDEDataLogging": false,
"r__automation_key": "testExisting_automation_event",
"r__dataExtension_key": "testExisting_dataExtension"
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,61 @@
{
"count": 4,
"count": 5,
"page": 1,
"pageSize": 50,
"links": {},
"items": [
{
"id": "161b64a1-1867-4272-8c5c-4d7abe880702",
"type": "AutomationAudience",
"name": "testExisting_event_automation",
"description": "",
"createdDate": "2024-11-07T04:58:46.51",
"createdBy": 700301950,
"modifiedDate": "2024-11-07T04:58:46.51",
"modifiedBy": 700301950,
"mode": "Production",
"eventDefinitionKey": "testExisting_event_automation",
"dataExtensionId": "21711373-72c1-ec11-b83b-48df37d1deb7",
"dataExtensionName": "testExisting_automation_event",
"sourceApplicationExtensionId": "97e942ee-6914-4d3d-9e52-37ecb71f79ed",
"filterDefinitionId": "00000000-0000-0000-0000-000000000000",
"filterDefinitionTemplate": "",
"iconUrl": "/images/icon-data-extension.svg",
"arguments": {
"serializedObjectType": 9,
"useHighWatermark": true,
"resetHighWatermark": false,
"automationId": "8f82c2a7-0bae-45a9-bdee-e631ab25c0d5",
"eventDefinitionId": "161b64a1-1867-4272-8c5c-4d7abe880702",
"eventDefinitionKey": "testExisting_event_automation",
"dataExtensionId": "21711373-72c1-ec11-b83b-48df37d1deb7",
"criteria": ""
},
"configurationArguments": {
"unconfigured": false
},
"metaData": {
"criteriaDescription": "",
"scheduleFlowMode": "automation"
},
"schedule": {
"startDateTime": "2024-11-07T12:15:00",
"endDateTime": "2079-06-06T00:00:00",
"timeZone": "W. Europe Standard Time",
"occurrences": 478403,
"endType": "EndDate",
"frequency": "Hourly",
"recurrencePattern": "Interval",
"interval": 1
},
"interactionCount": 1,
"isVisibleInPicker": false,
"isPlatformObject": false,
"category": "Audience",
"publishedInteractionCount": 1,
"automationId": "8f82c2a7-0bae-45a9-bdee-e631ab25c0d5",
"disableDEDataLogging": false
},
{
"id": "33b4dbc5-4b58-4a54-ab57-24388f1eefe4",
"type": "APIEvent",
Expand Down Expand Up @@ -79,7 +131,7 @@
"isPlatformObject": false,
"category": "Audience",
"publishedInteractionCount": 0,
"automationId": "0fc8f605-bca8-4f24-8b46-b43e06bf271c",
"automationId": "00000000-0000-0000-0000-000000000000",
"disableDEDataLogging": false
},
{
Expand Down Expand Up @@ -118,7 +170,7 @@
"isPlatformObject": false,
"category": "Audience",
"publishedInteractionCount": 0,
"automationId": "a3c606a8-19d7-4866-8804-5f43dc4502ea",
"automationId": "00000000-0000-0000-0000-000000000000",
"disableDEDataLogging": false
},
{
Expand Down
Loading
Loading