- Assume there is already enabled integrations and processes useing them.
- Removing these integrations upon import will break things out since the integrationId will be changed
- Keep already existing integrations, get the already existing integrations and merge them with the bundle integrations, either create or update to ensure that no integration ids are missed
- The step knows the integration based on the slug, we need to change the integrations translations so that it maps the old integration id(from the bundle) to the new integration id(on the system)
## Export
- Two process in which they use different CW integrations

- Two enabled CW int, one of them is default

- Export the two integrations like below:

## Import
- ### Import from the UI(marketplace or minibundles)
> Put the UI from the marketplace import in for what Zaher is doing, It could default to default integrations, and then could use what he added to autofill the creation form if they don't exist

### import with useDefault = true (used in the non-UI operations like the provisioning and bundle tests)
**bundleIntegrations:**
```json
[
{
"slug": "connectwise",
"integrationId": "OLD_1",
"name": "Core CW"
},
{
"slug": "connectwise",
"integrationId": "OLD_2",
"name": "Edge CW"
}
]
```
**systemIntegrations**
```json
[
{
"_id" : "SYSTEM_1",
"integrationName" : "connectwise",
"name" : "Connectwise",
"defaultIntegration" : false,
...
},
{
"_id" : "SYSTEM_2",
"integrationName" : "connectwise",
"name" : "Connectwise",
"defaultIntegration" : true,
...
}
]
```
**integrationsTranslations**
```json
[
{
"importKey": "connectwise",
"oldIntegrationId": "OLD_1",
"newIntegrationId": "SYSTEM_1"
},
{
"importKey": "connectwise",
"oldIntegrationId": "OLD_2",
"newIntegrationId": "NEW_2",
"integrationName": "Edge CW"
},
]
```
```javascript
const translateIntegrationOption = (
integrationOptionKey,
outputStep,
intSlug,
intId, <====================
integrationTranslations
) => {
...
const integrationTranslation = integrationTranslations
.find(t => t.importKey === intSlug && t.oldIntegrationId === intId); <=========
outputStep.stepOptions[integrationOptionKey] = integrationTranslation.newIntegrationId; <============
};
```
- ### Import from non-UI(provisioning, bundle tests)
- **Bundle Tests:** utility to create integrations with the needed creds then pass the translations like we do with the UI
```javascript
const initializeTests = async ({
bundleName,
bundlePath,
sortedProcesses,
vaultEntries = [],
}) => {
```
- **Provisioning:** useDefault flag will be present and will be creating dummy integrations to match the number of integrations in the imported bundle, if the imported bundle has a default integration flag then the created/matched integration should be the default one, other wise select the first integration to be the default and then the user can change it to thier needs
