@unito/integration-cli 0.58.7 → 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.
- package/dist/src/commands/publish.js +14 -6
- package/dist/src/resources/oauth2.js +2 -1
- package/dist/src/services/integrationsPlatform.d.ts +3 -1
- package/dist/src/services/integrationsPlatform.js +1 -0
- package/dist/test/services/integrationsPlatform.test.js +26 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
|
@@ -144,9 +144,9 @@ class Publish extends baseCommand_1.BaseCommand {
|
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
async updateRegistry(integrationConfiguration) {
|
|
147
|
-
let
|
|
147
|
+
let integration;
|
|
148
148
|
try {
|
|
149
|
-
|
|
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
|
-
|
|
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 (
|
|
166
|
+
if (integration) {
|
|
167
167
|
core_1.ux.action.start('Integration found. Updating', undefined, { stdout: true });
|
|
168
|
-
|
|
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 ${
|
|
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('');
|
|
@@ -10,7 +10,8 @@ async function performOAuth2Flow(applicationCredentials, environment = globalCon
|
|
|
10
10
|
const serverUrl = await oauthHelper.startServer();
|
|
11
11
|
const healthCheck = await fetch(`${serverUrl}/health`);
|
|
12
12
|
if (healthCheck.status !== 200) {
|
|
13
|
-
|
|
13
|
+
const error = await healthCheck.text();
|
|
14
|
+
throw new Error(`OAuthServer did not start correctly.\n HealthCheck status: ${healthCheck.status}\n Response: ${error}`);
|
|
14
15
|
}
|
|
15
16
|
await oauthHelper.authorize();
|
|
16
17
|
const oauth2Response = await oauthHelper.callbackIsDone();
|
|
@@ -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
|
|
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 () {
|
package/oclif.manifest.json
CHANGED