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

[BREAKING CHANGE] #777: rename type eventDefinition to event #794

Merged
merged 1 commit into from
Mar 10, 2023
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
98 changes: 49 additions & 49 deletions docs/dist/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ as this is a configuration in the EID</p>
<dt><a href="#EmailSendDefinition">EmailSendDefinition</a> ⇐ <code><a href="#MetadataType">MetadataType</a></code></dt>
<dd><p>MessageSendActivity MetadataType</p>
</dd>
<dt><a href="#EventDefinition">EventDefinition</a> ⇐ <code><a href="#MetadataType">MetadataType</a></code></dt>
<dd><p>EventDefinition MetadataType</p>
<dt><a href="#Event">Event</a> ⇐ <code><a href="#MetadataType">MetadataType</a></code></dt>
<dd><p>Event MetadataType</p>
</dd>
<dt><a href="#FtpLocation">FtpLocation</a> ⇐ <code><a href="#MetadataType">MetadataType</a></code></dt>
<dd><p>ImportFile MetadataType</p>
Expand Down Expand Up @@ -2326,34 +2326,34 @@ parses retrieved Metadata before saving
| --- | --- | --- |
| metadata | <code>TYPE.MetadataTypeItem</code> | a single query activity definition |

<a name="EventDefinition"></a>
<a name="Event"></a>

## EventDefinition ⇐ [<code>MetadataType</code>](#MetadataType)
EventDefinition MetadataType
## Event ⇐ [<code>MetadataType</code>](#MetadataType)
Event MetadataType

**Kind**: global class
**Extends**: [<code>MetadataType</code>](#MetadataType)

* [EventDefinition](#EventDefinition) ⇐ [<code>MetadataType</code>](#MetadataType)
* [.retrieve(retrieveDir, [_], [__], [key])](#EventDefinition.retrieve) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
* [.retrieveForCache()](#EventDefinition.retrieveForCache) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
* [.retrieveAsTemplate(templateDir, name, templateVariables)](#EventDefinition.retrieveAsTemplate) ⇒ <code>Promise.&lt;TYPE.MetadataTypeItemObj&gt;</code>
* [.postRetrieveTasks(eventDef)](#EventDefinition.postRetrieveTasks) ⇒ <code>TYPE.MetadataTypeItem</code>
* [.deleteByKey(key)](#EventDefinition.deleteByKey) ⇒ <code>Promise.&lt;boolean&gt;</code>
* [.deploy(metadata, deployDir, retrieveDir)](#EventDefinition.deploy) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMap&gt;</code>
* [.create(EventDefinition)](#EventDefinition.create) ⇒ <code>Promise</code>
* [.update(metadataEntry)](#EventDefinition.update) ⇒ <code>Promise</code>
* [.preDeployTasks(metadata)](#EventDefinition.preDeployTasks) ⇒ <code>TYPE.MetadataTypeItem</code>
* [.parseMetadata(metadata)](#EventDefinition.parseMetadata) ⇒ <code>TYPE.MetadataTypeItem</code>

<a name="EventDefinition.retrieve"></a>

### EventDefinition.retrieve(retrieveDir, [_], [__], [key]) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
* [Event](#Event) ⇐ [<code>MetadataType</code>](#MetadataType)
* [.retrieve(retrieveDir, [_], [__], [key])](#Event.retrieve) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
* [.retrieveForCache()](#Event.retrieveForCache) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
* [.retrieveAsTemplate(templateDir, name, templateVariables)](#Event.retrieveAsTemplate) ⇒ <code>Promise.&lt;TYPE.MetadataTypeItemObj&gt;</code>
* [.postRetrieveTasks(eventDef)](#Event.postRetrieveTasks) ⇒ <code>TYPE.MetadataTypeItem</code>
* [.deleteByKey(key)](#Event.deleteByKey) ⇒ <code>Promise.&lt;boolean&gt;</code>
* [.deploy(metadata, deployDir, retrieveDir)](#Event.deploy) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMap&gt;</code>
* [.create(metadata)](#Event.create) ⇒ <code>Promise</code>
* [.update(metadataEntry)](#Event.update) ⇒ <code>Promise</code>
* [.preDeployTasks(metadata)](#Event.preDeployTasks) ⇒ <code>TYPE.MetadataTypeItem</code>
* [.parseMetadata(metadata)](#Event.parseMetadata) ⇒ <code>TYPE.MetadataTypeItem</code>

<a name="Event.retrieve"></a>

### Event.retrieve(retrieveDir, [_], [__], [key]) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
Retrieves Metadata of Event Definition.
Endpoint /interaction/v1/EventDefinitions return all Event Definitions with all details.
Currently it is not needed to loop over Imports with endpoint /interaction/v1/EventDefinitions/{id}

**Kind**: static method of [<code>EventDefinition</code>](#EventDefinition)
**Kind**: static method of [<code>Event</code>](#Event)
**Returns**: <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code> - Promise of metadata

| Param | Type | Description |
Expand All @@ -2363,19 +2363,19 @@ Currently it is not needed to loop over Imports with endpoint /interaction/v1/Ev
| [__] | <code>void</code> | unused parameter |
| [key] | <code>string</code> | customer key of single item to retrieve |

<a name="EventDefinition.retrieveForCache"></a>
<a name="Event.retrieveForCache"></a>

### EventDefinition.retrieveForCache() ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
### Event.retrieveForCache() ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
Retrieves event definition metadata for caching

**Kind**: static method of [<code>EventDefinition</code>](#EventDefinition)
**Kind**: static method of [<code>Event</code>](#Event)
**Returns**: <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code> - Promise of metadata
<a name="EventDefinition.retrieveAsTemplate"></a>
<a name="Event.retrieveAsTemplate"></a>

### EventDefinition.retrieveAsTemplate(templateDir, name, templateVariables) ⇒ <code>Promise.&lt;TYPE.MetadataTypeItemObj&gt;</code>
### Event.retrieveAsTemplate(templateDir, name, templateVariables) ⇒ <code>Promise.&lt;TYPE.MetadataTypeItemObj&gt;</code>
Retrieve a specific Event Definition by Name

**Kind**: static method of [<code>EventDefinition</code>](#EventDefinition)
**Kind**: static method of [<code>Event</code>](#Event)
**Returns**: <code>Promise.&lt;TYPE.MetadataTypeItemObj&gt;</code> - Promise of metadata

| Param | Type | Description |
Expand All @@ -2384,36 +2384,36 @@ Retrieve a specific Event Definition by Name
| name | <code>string</code> | name of the metadata file |
| templateVariables | <code>TYPE.TemplateMap</code> | variables to be replaced in the metadata |

<a name="EventDefinition.postRetrieveTasks"></a>
<a name="Event.postRetrieveTasks"></a>

### EventDefinition.postRetrieveTasks(eventDef) ⇒ <code>TYPE.MetadataTypeItem</code>
### Event.postRetrieveTasks(eventDef) ⇒ <code>TYPE.MetadataTypeItem</code>
manages post retrieve steps

**Kind**: static method of [<code>EventDefinition</code>](#EventDefinition)
**Kind**: static method of [<code>Event</code>](#Event)
**Returns**: <code>TYPE.MetadataTypeItem</code> - metadata

| Param | Type | Description |
| --- | --- | --- |
| eventDef | <code>TYPE.MetadataTypeItem</code> | a single item of Event Definition |

<a name="EventDefinition.deleteByKey"></a>
<a name="Event.deleteByKey"></a>

### EventDefinition.deleteByKey(key) ⇒ <code>Promise.&lt;boolean&gt;</code>
### Event.deleteByKey(key) ⇒ <code>Promise.&lt;boolean&gt;</code>
Delete a metadata item from the specified business unit

**Kind**: static method of [<code>EventDefinition</code>](#EventDefinition)
**Kind**: static method of [<code>Event</code>](#Event)
**Returns**: <code>Promise.&lt;boolean&gt;</code> - deletion success status

| Param | Type | Description |
| --- | --- | --- |
| key | <code>string</code> | Identifier of item |

<a name="EventDefinition.deploy"></a>
<a name="Event.deploy"></a>

### EventDefinition.deploy(metadata, deployDir, retrieveDir) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMap&gt;</code>
### Event.deploy(metadata, deployDir, retrieveDir) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMap&gt;</code>
Deploys metadata - merely kept here to be able to print [logBeta](#Util.logBeta) once per deploy

**Kind**: static method of [<code>EventDefinition</code>](#EventDefinition)
**Kind**: static method of [<code>Event</code>](#Event)
**Returns**: <code>Promise.&lt;TYPE.MetadataTypeMap&gt;</code> - Promise of keyField => metadata map

| Param | Type | Description |
Expand All @@ -2422,48 +2422,48 @@ Deploys metadata - merely kept here to be able to print [logBeta](#Util.logBeta)
| deployDir | <code>string</code> | directory where deploy metadata are saved |
| retrieveDir | <code>string</code> | directory where metadata after deploy should be saved |

<a name="EventDefinition.create"></a>
<a name="Event.create"></a>

### EventDefinition.create(EventDefinition) ⇒ <code>Promise</code>
### Event.create(metadata) ⇒ <code>Promise</code>
Creates a single Event Definition

**Kind**: static method of [<code>EventDefinition</code>](#EventDefinition)
**Kind**: static method of [<code>Event</code>](#Event)
**Returns**: <code>Promise</code> - Promise

| Param | Type | Description |
| --- | --- | --- |
| EventDefinition | <code>TYPE.MetadataTypeItem</code> | a single Event Definition |
| metadata | <code>TYPE.MetadataTypeItem</code> | a single Event Definition |

<a name="EventDefinition.update"></a>
<a name="Event.update"></a>

### EventDefinition.update(metadataEntry) ⇒ <code>Promise</code>
### Event.update(metadataEntry) ⇒ <code>Promise</code>
Updates a single Event Definition (using PUT method since PATCH isn't supported)

**Kind**: static method of [<code>EventDefinition</code>](#EventDefinition)
**Kind**: static method of [<code>Event</code>](#Event)
**Returns**: <code>Promise</code> - Promise

| Param | Type | Description |
| --- | --- | --- |
| metadataEntry | <code>TYPE.MetadataTypeItem</code> | a single Event Definition |

<a name="EventDefinition.preDeployTasks"></a>
<a name="Event.preDeployTasks"></a>

### EventDefinition.preDeployTasks(metadata) ⇒ <code>TYPE.MetadataTypeItem</code>
### Event.preDeployTasks(metadata) ⇒ <code>TYPE.MetadataTypeItem</code>
prepares an event definition for deployment

**Kind**: static method of [<code>EventDefinition</code>](#EventDefinition)
**Kind**: static method of [<code>Event</code>](#Event)
**Returns**: <code>TYPE.MetadataTypeItem</code> - parsed version

| Param | Type | Description |
| --- | --- | --- |
| metadata | <code>TYPE.MetadataTypeItem</code> | a single eventDefinition |

<a name="EventDefinition.parseMetadata"></a>
<a name="Event.parseMetadata"></a>

### EventDefinition.parseMetadata(metadata) ⇒ <code>TYPE.MetadataTypeItem</code>
### Event.parseMetadata(metadata) ⇒ <code>TYPE.MetadataTypeItem</code>
parses retrieved Metadata before saving

**Kind**: static method of [<code>EventDefinition</code>](#EventDefinition)
**Kind**: static method of [<code>Event</code>](#Event)
**Returns**: <code>TYPE.MetadataTypeItem</code> - parsed metadata

| Param | Type | Description |
Expand Down
2 changes: 1 addition & 1 deletion lib/MetadataTypeDefinitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const MetadataTypeDefinitions = {
discovery: require('./metadataTypes/definitions/Discovery.definition'),
email: require('./metadataTypes/definitions/Email.definition'),
emailSendDefinition: require('./metadataTypes/definitions/EmailSendDefinition.definition'),
eventDefinition: require('./metadataTypes/definitions/EventDefinition.definition'),
event: require('./metadataTypes/definitions/Event.definition'),
fileLocation: require('./metadataTypes/definitions/FileLocation.definition'),
fileTransfer: require('./metadataTypes/definitions/FileTransfer.definition'),
filter: require('./metadataTypes/definitions/Filter.definition'),
Expand Down
2 changes: 1 addition & 1 deletion lib/MetadataTypeInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const MetadataTypeInfo = {
discovery: require('./metadataTypes/Discovery'),
email: require('./metadataTypes/Email'),
emailSendDefinition: require('./metadataTypes/EmailSendDefinition'),
eventDefinition: require('./metadataTypes/EventDefinition'),
event: require('./metadataTypes/Event'),
fileLocation: require('./metadataTypes/FileLocation'),
fileTransfer: require('./metadataTypes/FileTransfer'),
filter: require('./metadataTypes/Filter'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const File = require('../util/file');
const cache = require('../util/cache');

/**
* EventDefinition MetadataType
* Event MetadataType
*
* @augments MetadataType
*/
class EventDefinition extends MetadataType {
class Event extends MetadataType {
/**
* Retrieves Metadata of Event Definition.
* Endpoint /interaction/v1/EventDefinitions return all Event Definitions with all details.
Expand Down Expand Up @@ -77,7 +77,7 @@ class EventDefinition extends MetadataType {
);
if (!eventDef.dataExtensionId) {
throw new Error(
`EventDefinition.parseMetadata:: ` +
`Event.parseMetadata:: ` +
`No Data Extension found for ` +
`event: ${eventDef.name}. ` +
`This cannot be templated`
Expand All @@ -101,7 +101,7 @@ class EventDefinition extends MetadataType {
);
}
} catch (ex) {
Util.logger.error('EventDefinition.retrieveAsTemplate:: ' + ex);
Util.logger.error('Event.retrieveAsTemplate:: ' + ex);
return null;
}
}
Expand Down Expand Up @@ -147,11 +147,11 @@ class EventDefinition extends MetadataType {
/**
* Creates a single Event Definition
*
* @param {TYPE.MetadataTypeItem} EventDefinition a single Event Definition
* @param {TYPE.MetadataTypeItem} metadata a single Event Definition
* @returns {Promise} Promise
*/
static create(EventDefinition) {
return super.createREST(EventDefinition, '/interaction/v1/EventDefinitions/');
static create(metadata) {
return super.createREST(metadata, '/interaction/v1/EventDefinitions/');
}

/**
Expand Down Expand Up @@ -232,6 +232,6 @@ class EventDefinition extends MetadataType {
}

// Assign definition to static attributes
EventDefinition.definition = require('../MetadataTypeDefinitions').eventDefinition;
Event.definition = require('../MetadataTypeDefinitions').event;

module.exports = EventDefinition;
module.exports = Event;
20 changes: 10 additions & 10 deletions lib/metadataTypes/Interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,22 +299,22 @@ class Interaction extends MetadataType {
case 'Multistep': {
// Multi-Step Journey
// ~~~ TRIGGERS ~~~~
// eventDefinition / definitionType==='Multistep' && channel==='' && triggers[].type === 'EmailAudience'|'APIEvent'
// event / definitionType==='Multistep' && channel==='' && triggers[].type === 'EmailAudience'|'APIEvent'
if (
metadata.triggers?.length > 0 &&
metadata.triggers[0].metaData?.eventDefinitionKey
) {
// trigger found; there can only be one entry in this array
try {
const edId = cache.searchForField(
'eventDefinition',
'event',
metadata.triggers[0].metaData.eventDefinitionKey,
'eventDefinitionKey',
'id'
);
if (metadata.triggers[0].metaData.eventDefinitionId !== edId) {
throw new Error(
`eventDefinitionId not matching Id found on eventDefinition with key in eventDefinitionKey`
`eventDefinitionId not matching Id found on event with key in eventDefinitionKey`
);
}
delete metadata.triggers[0].metaData.eventDefinitionId;
Expand Down Expand Up @@ -379,15 +379,15 @@ class Interaction extends MetadataType {
}): definitionType Quicksend is not fully supported yet.`
);
// ~~~ TRIGGERS ~~~~
// eventDefinition && triggers[].type === 'ContactAudience'
// event && triggers[].type === 'ContactAudience'
if (
metadata.triggers?.length > 0 &&
metadata.triggers[0].metaData?.eventDefinitionKey
) {
// trigger found; there can only be one entry in this array
try {
const edId = cache.searchForField(
'eventDefinition',
'event',
metadata.triggers[0].metaData.eventDefinitionKey,
'eventDefinitionKey',
'id'
Expand All @@ -398,7 +398,7 @@ class Interaction extends MetadataType {
metadata[this.definition.nameField]
} (${
metadata[this.definition.keyField]
}): eventDefinitionId not matching Id found on eventDefinition with key in eventDefinitionKey`
}): eventDefinitionId not matching Id found on event with key in eventDefinitionKey`
);
}
delete metadata.triggers[0].metaData.eventDefinitionId;
Expand Down Expand Up @@ -535,14 +535,14 @@ class Interaction extends MetadataType {
// Multi-Step Journey
// ~~~ TRIGGERS ~~~~

// eventDefinition / definitionType==='Multistep' && channel==='' && triggers[].type === 'EmailAudience'|'APIEvent'
// event / definitionType==='Multistep' && channel==='' && triggers[].type === 'EmailAudience'|'APIEvent'
if (
metadata.triggers?.length > 0 &&
metadata.triggers[0].metaData?.eventDefinitionKey
) {
// trigger found; there can only be one entry in this array
metadata.triggers[0].metaData.eventDefinitionId = cache.searchForField(
'eventDefinition',
'event',
metadata.triggers[0].metaData.eventDefinitionKey,
'eventDefinitionKey',
'id'
Expand Down Expand Up @@ -586,15 +586,15 @@ class Interaction extends MetadataType {
}): definitionType Quicksend is not supported yet and might fail to deploy.`
);
// ~~~ TRIGGERS ~~~~
// eventDefinition && triggers[].type === 'ContactAudience'
// event && triggers[].type === 'ContactAudience'
if (
metadata.triggers?.length > 0 &&
metadata.triggers[0].metaData?.eventDefinitionKey
) {
// trigger found; there can only be one entry in this array
try {
metadata.triggers[0].metaData.eventDefinitionId = cache.searchForField(
'eventDefinition',
'event',
metadata.triggers[0].metaData?.eventDefinitionKey,
'eventDefinitionKey',
'id'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
lastmodDateField: 'modifiedDate',
lastmodNameField: 'modifiedBy',
restPagination: true,
type: 'eventDefinition',
type: 'event',
typeDescription: 'Used in Journeys (Interactions) to define Entry Events.',
typeRetrieveByDefault: true,
typeName: 'Journey: Entry Event Definition',
Expand Down
2 changes: 1 addition & 1 deletion lib/metadataTypes/definitions/Interaction.definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// update: https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/putUpdateInteraction.html
module.exports = {
bodyIteratorField: 'items',
dependencies: ['folder-journey', 'triggeredSendDefinition', 'eventDefinition'], // ! interaction and transactionalEmail both link to each other. caching transactionalEmail here "manually" instead of via dependencies array, assuming that it is quicker than the other way round
dependencies: ['folder-journey', 'triggeredSendDefinition', 'event'], // ! interaction and transactionalEmail both link to each other. caching transactionalEmail here "manually" instead of via dependencies array, assuming that it is quicker than the other way round
folderIdField: 'categoryId',
hasExtended: false,
idField: 'id',
Expand Down