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/1940: resolve fileLocation in GCP triggered automations #1946

Merged
merged 2 commits into from
Dec 20, 2024
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
2 changes: 1 addition & 1 deletion @types/lib/metadataTypes/Automation.d.ts.map

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

6 changes: 5 additions & 1 deletion @types/types/mcdev.d.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/types/mcdev.d.d.ts.map

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions lib/metadataTypes/Automation.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,22 @@ class Automation extends MetadataType {
// folder
this.setFolderPath(metadata);
// automations are often skipped due to lack of support.
if (
metadata.type == 'automationtriggered' &&
metadata.automationTrigger?.fileTransferLocationId
) {
try {
metadata.automationTrigger.r__fileLocation_name = cache.searchForField(
'fileLocation',
metadata.automationTrigger.fileTransferLocationId,
'id',
'name'
);
delete metadata.automationTrigger.fileTransferLocationId;
} catch (ex) {
Util.logger.warn(` - automation ${metadata.key}: ${ex.message}`);
}
}
try {
if (metadata.type === 'scheduled' && metadata.schedule?.startDate) {
// Starting Source == 'Schedule'
Expand Down Expand Up @@ -905,6 +921,18 @@ class Automation extends MetadataType {
this.notificationUpdates[metadata.key] = [];
}
}
if (
metadata.type == 'automationtriggered' &&
metadata.automationTrigger?.r__fileLocation_name
) {
metadata.automationTrigger.fileTransferLocationId = cache.searchForField(
'fileLocation',
metadata.automationTrigger.r__fileLocation_name,
'name',
'id'
);
delete metadata.automationTrigger.r__fileLocation_name;
}
if (this.validateDeployMetadata(metadata)) {
// folder
this.setFolderId(metadata);
Expand Down
1 change: 1 addition & 0 deletions lib/metadataTypes/definitions/Automation.definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default {
'dataExtract',
'emailSend',
'fileTransfer',
'fileLocation',
'folder-automations',
'importFile',
'query',
Expand Down
10 changes: 5 additions & 5 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 = 30;
const expectedApiCallsRetrieve = 31;
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 = 30;
const expectedApiCallsRetrieve = 31;

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

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

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

const expectedApiCallsRetrieve = 30;
const expectedApiCallsRetrieve = 31;
assert.equal(
testUtils.getAPIHistoryLength(),
expectedApiCallsRetrieve,
Expand Down
26 changes: 13 additions & 13 deletions test/type.automation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('type: automation', () => {
);
assert.equal(
testUtils.getAPIHistoryLength(),
27,
28,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -144,7 +144,7 @@ describe('type: automation', () => {

assert.equal(
testUtils.getAPIHistoryLength(),
34,
35,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -212,7 +212,7 @@ describe('type: automation', () => {

assert.equal(
testUtils.getAPIHistoryLength(),
42,
43,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -279,7 +279,7 @@ describe('type: automation', () => {

assert.equal(
testUtils.getAPIHistoryLength(),
38,
39,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -318,7 +318,7 @@ describe('type: automation', () => {
// check number of API calls
assert.equal(
testUtils.getAPIHistoryLength(),
24,
25,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -362,7 +362,7 @@ describe('type: automation', () => {
// check number of API calls
assert.equal(
testUtils.getAPIHistoryLength(),
52,
54,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -406,7 +406,7 @@ describe('type: automation', () => {
// check number of API calls
assert.equal(
testUtils.getAPIHistoryLength(),
54,
56,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -450,7 +450,7 @@ describe('type: automation', () => {
// check number of API calls
assert.equal(
testUtils.getAPIHistoryLength(),
55,
57,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -494,7 +494,7 @@ describe('type: automation', () => {
// check number of API calls
assert.equal(
testUtils.getAPIHistoryLength(),
47,
49,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -538,7 +538,7 @@ describe('type: automation', () => {
// check number of API calls
assert.equal(
testUtils.getAPIHistoryLength(),
53,
55,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -582,7 +582,7 @@ describe('type: automation', () => {
// check number of API calls
assert.equal(
testUtils.getAPIHistoryLength(),
55,
57,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -626,7 +626,7 @@ describe('type: automation', () => {
);
assert.equal(
testUtils.getAPIHistoryLength(),
26,
27,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -670,7 +670,7 @@ describe('type: automation', () => {
);
assert.equal(
testUtils.getAPIHistoryLength(),
27,
28,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down
4 changes: 2 additions & 2 deletions test/type.query.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ describe('type: query', () => {
// check number of API calls
assert.equal(
testUtils.getAPIHistoryLength(),
41,
42,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -690,7 +690,7 @@ describe('type: query', () => {
// check number of API calls
assert.equal(
testUtils.getAPIHistoryLength(),
43,
44,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down
3 changes: 2 additions & 1 deletion types/mcdev.d.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
* @property {string} [Name] name (SOAP API)
* @property {any} [notifications] notifications
* @property {string} [description] -
* @property {'scheduled'|'triggered'} [type] Starting Source = Schedule / File Drop
* @property {'scheduled'|'triggered'|'automationtriggered'} [type] Starting Source = Schedule / File Drop
* @property {'Scheduled'|'Running'|'Ready'|'Building'|'PausedSchedule'|'InactiveTrigger'} [status] automation status
* @property {number} [statusId] automation status
* @property {AutomationSchedule} [schedule] only existing if type=scheduled
Expand All @@ -302,6 +302,7 @@
* @property {boolean} fileTrigger.isPublished ?
* @property {boolean} fileTrigger.queueFiles ?
* @property {boolean} fileTrigger.triggerActive -
* @property {object} [automationTrigger] only existing if type=automationtriggered
* @property {object} [startSource] -
* @property {AutomationSchedule} [startSource.schedule] rewritten to AutomationItem.schedule
* @property {object} [startSource.fileDrop] rewritten to AutomationItem.fileTrigger
Expand Down
Loading