@unito/integration-cli 0.58.8 → 0.59.0
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/schemas/authorization.json +4 -4
- package/dist/src/commands/publish.js +14 -6
- package/dist/src/configurationTypes.d.ts +3 -2
- package/dist/src/configurationTypes.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
|
@@ -163,15 +163,15 @@
|
|
|
163
163
|
},
|
|
164
164
|
"grantType": {
|
|
165
165
|
"type": "string",
|
|
166
|
-
"description": "The type of grant of the OAuth 2 authorization",
|
|
167
|
-
"enum": ["authorization_code", "password"],
|
|
168
|
-
"tsEnumNames": ["AUTHORIZATION_CODE", "PASSWORD"]
|
|
166
|
+
"description": "The type of grant of the OAuth 2 authorization.",
|
|
167
|
+
"enum": ["authorization_code", "password", "client_credentials"],
|
|
168
|
+
"tsEnumNames": ["AUTHORIZATION_CODE", "PASSWORD", "CLIENT_CREDENTIALS"]
|
|
169
169
|
},
|
|
170
170
|
"scopes": {
|
|
171
171
|
"type": "array",
|
|
172
172
|
"items": {
|
|
173
173
|
"type": "object",
|
|
174
|
-
"description": "The requested scope of access to the user account",
|
|
174
|
+
"description": "The requested scope of access to the user account.",
|
|
175
175
|
"additionalProperties": false,
|
|
176
176
|
"required": ["name"],
|
|
177
177
|
"properties": {
|
|
@@ -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('');
|
|
@@ -180,11 +180,12 @@ export declare enum Method {
|
|
|
180
180
|
OAUTH2 = "oauth2"
|
|
181
181
|
}
|
|
182
182
|
/**
|
|
183
|
-
* The type of grant of the OAuth 2 authorization
|
|
183
|
+
* The type of grant of the OAuth 2 authorization.
|
|
184
184
|
*/
|
|
185
185
|
export declare enum GrantType {
|
|
186
186
|
AUTHORIZATION_CODE = "authorization_code",
|
|
187
|
-
PASSWORD = "password"
|
|
187
|
+
PASSWORD = "password",
|
|
188
|
+
CLIENT_CREDENTIALS = "client_credentials"
|
|
188
189
|
}
|
|
189
190
|
/**
|
|
190
191
|
* The content type of exchanged information with the provider
|
|
@@ -16,12 +16,13 @@ var Method;
|
|
|
16
16
|
Method["OAUTH2"] = "oauth2";
|
|
17
17
|
})(Method || (exports.Method = Method = {}));
|
|
18
18
|
/**
|
|
19
|
-
* The type of grant of the OAuth 2 authorization
|
|
19
|
+
* The type of grant of the OAuth 2 authorization.
|
|
20
20
|
*/
|
|
21
21
|
var GrantType;
|
|
22
22
|
(function (GrantType) {
|
|
23
23
|
GrantType["AUTHORIZATION_CODE"] = "authorization_code";
|
|
24
24
|
GrantType["PASSWORD"] = "password";
|
|
25
|
+
GrantType["CLIENT_CREDENTIALS"] = "client_credentials";
|
|
25
26
|
})(GrantType || (exports.GrantType = GrantType = {}));
|
|
26
27
|
/**
|
|
27
28
|
* The content type of exchanged information with the provider
|
|
@@ -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