@unito/integration-cli 0.58.8 → 0.58.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -144,9 +144,9 @@ class Publish extends baseCommand_1.BaseCommand {
144
144
  });
145
145
  }
146
146
  async updateRegistry(integrationConfiguration) {
147
- let existing;
147
+ let integration;
148
148
  try {
149
- existing = await IntegrationsPlatform.getIntegrationByName(integrationConfiguration.name);
149
+ integration = await IntegrationsPlatform.getIntegrationByName(integrationConfiguration.name);
150
150
  }
151
151
  catch (error) {
152
152
  if (error instanceof IntegrationsPlatform.HttpError && error.status === 403) {
@@ -154,7 +154,7 @@ class Publish extends baseCommand_1.BaseCommand {
154
154
  this.exit(-1);
155
155
  }
156
156
  else {
157
- existing = undefined;
157
+ integration = undefined;
158
158
  }
159
159
  }
160
160
  // Create or update the integration.
@@ -163,9 +163,17 @@ class Publish extends baseCommand_1.BaseCommand {
163
163
  authorization.instructionsImage = await this.getInstructionsImage(authorization.name);
164
164
  authorization.instructionsMarkdown = await this.getInstructionsMarkdown(authorization.name);
165
165
  }
166
- if (existing) {
166
+ if (integration) {
167
167
  core_1.ux.action.start('Integration found. Updating', undefined, { stdout: true });
168
- updated = await IntegrationsPlatform.updateIntegration(existing.id, integrationConfiguration);
168
+ if (integration.archivedAt) {
169
+ core_1.ux.action.start(`Integration previously archived on ${integration.archivedAt}. Un-archiving`, undefined, {
170
+ stdout: true,
171
+ });
172
+ }
173
+ updated = await IntegrationsPlatform.updateIntegration(integration.id, {
174
+ ...integrationConfiguration,
175
+ archived: false,
176
+ });
169
177
  }
170
178
  else {
171
179
  core_1.ux.action.start('Integration not found. Creating', undefined, { stdout: true });
@@ -174,7 +182,7 @@ class Publish extends baseCommand_1.BaseCommand {
174
182
  core_1.ux.action.stop();
175
183
  // Summary of the operation.
176
184
  core_1.ux.log('');
177
- core_1.ux.log(`The integration was ${existing ? 'updated' : 'created'} with the following information:`);
185
+ core_1.ux.log(`The integration was ${integration ? 'updated' : 'created'} with the following information:`);
178
186
  core_1.ux.log('');
179
187
  core_1.ux.log((0, json_colorizer_1.default)(this.indent(JSON.stringify(updated, null, 2))));
180
188
  core_1.ux.log('');
@@ -37,5 +37,7 @@ export declare function getIntegrationEvents(integrationId: number, options?: {
37
37
  search?: string;
38
38
  limit?: number;
39
39
  }): Promise<IntegrationEvent[]>;
40
- export declare function updateIntegration(integrationId: number, configuration: Configuration): Promise<Integration>;
40
+ export declare function updateIntegration(integrationId: number, configuration: Configuration & {
41
+ archived?: boolean;
42
+ }): Promise<Integration>;
41
43
  export declare function getCredential(credentialId: number): Promise<Credential>;
@@ -151,6 +151,7 @@ async function updateIntegration(integrationId, configuration) {
151
151
  authorizations: authorizationsToCreate.concat(authorizationsToArchive).concat(authorizationsToUpdate),
152
152
  secrets: configuration.secrets,
153
153
  ui: configuration.ui,
154
+ archived: configuration.archived,
154
155
  });
155
156
  }
156
157
  exports.updateIntegration = updateIntegration;
@@ -153,6 +153,32 @@ describe('integrations platform', function () {
153
153
  webhookAcknowledgeRelativeUrl: undefined,
154
154
  webhookParsingRelativeUrl: undefined,
155
155
  webhookSubscriptionsRelativeUrl: undefined,
156
+ archived: undefined,
157
+ });
158
+ });
159
+ it('updateIntegration - unarchive', async function () {
160
+ sinon.stub(integrations_platform_client_1.default, 'getIntegrationById').resolves({ ...integration });
161
+ const mockUpdateIntegration = sinon.stub(integrations_platform_client_1.default, 'updateIntegration');
162
+ const integrationId = 1;
163
+ const archived = false;
164
+ const configuration = {
165
+ name: 'foo',
166
+ secrets: {
167
+ foo: 'bar',
168
+ },
169
+ };
170
+ await IntegrationsPlatform.updateIntegration(integrationId, { ...configuration, archived });
171
+ strict_1.default.deepEqual(mockUpdateIntegration.getCall(0).args.at(1), {
172
+ ui: undefined,
173
+ authorizations: [],
174
+ baseUrl: undefined,
175
+ credentialAccountRelativeUrl: '/me',
176
+ graphRelativeUrl: '/',
177
+ secrets: configuration.secrets,
178
+ webhookAcknowledgeRelativeUrl: undefined,
179
+ webhookParsingRelativeUrl: undefined,
180
+ webhookSubscriptionsRelativeUrl: undefined,
181
+ archived: false, // what matters
156
182
  });
157
183
  });
158
184
  it('encryptData', async function () {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.58.8",
2
+ "version": "0.58.9",
3
3
  "commands": {
4
4
  "activity": {
5
5
  "id": "activity",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unito/integration-cli",
3
- "version": "0.58.8",
3
+ "version": "0.58.9",
4
4
  "description": "Integration CLI",
5
5
  "bin": {
6
6
  "integration-cli": "./bin/run"