@unito/integration-cli 0.55.1
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/LICENSE +3 -0
- package/README.md +32 -0
- package/bin/run +11 -0
- package/bin/run.cmd +3 -0
- package/dist/.eslintrc.d.ts +10 -0
- package/dist/.eslintrc.js +20 -0
- package/dist/integrationGenerator/errors.d.ts +2 -0
- package/dist/integrationGenerator/errors.js +6 -0
- package/dist/integrationGenerator/index.d.ts +2 -0
- package/dist/integrationGenerator/index.js +5 -0
- package/dist/integrationGenerator/integrationBoilerplate/.dockerignore +3 -0
- package/dist/integrationGenerator/integrationBoilerplate/.eslintrc.js +74 -0
- package/dist/integrationGenerator/integrationBoilerplate/.nvmrc +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/.prettierignore +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/.prettierrc +7 -0
- package/dist/integrationGenerator/integrationBoilerplate/.unito.json +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/Dockerfile +38 -0
- package/dist/integrationGenerator/integrationBoilerplate/README.md +21 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.dockerignore +3 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.eslintrc.js +74 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.nvmrc +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.prettierignore +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.prettierrc +7 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.unito.json +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/Dockerfile +38 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/README.md +21 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/package.json +43 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/index.ts +94 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/logger.ts +55 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/middlewares/additionalLoggingContext.ts +22 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/middlewares/correlationId.ts +13 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/middlewares/credentials.ts +38 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/request.ts +59 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/routes/index.ts +11 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/routes/me.ts +15 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/routes/root.ts +12 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/tsconfig.json +37 -0
- package/dist/integrationGenerator/integrationBoilerplate/package.json +43 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/index.ts +90 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/logger.ts +37 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/middlewares/correlationId.ts +18 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/middlewares/credentials.ts +38 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/request.ts +59 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/routes/index.ts +11 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/routes/me.ts +15 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/routes/root.ts +12 -0
- package/dist/integrationGenerator/integrationBoilerplate/tsconfig.json +37 -0
- package/dist/integrationGenerator/src/index.d.ts +1 -0
- package/dist/integrationGenerator/src/index.js +5 -0
- package/dist/integrationGenerator/src/resources/index.d.ts +1 -0
- package/dist/integrationGenerator/src/resources/index.js +5 -0
- package/dist/integrationGenerator/src/resources/integration.d.ts +9 -0
- package/dist/integrationGenerator/src/resources/integration.js +60 -0
- package/dist/integrationGenerator/test/resources/integration.test.d.ts +1 -0
- package/dist/integrationGenerator/test/resources/integration.test.js +51 -0
- package/dist/schemas/authorization.json +204 -0
- package/dist/schemas/automation.json +81 -0
- package/dist/schemas/configuration.json +89 -0
- package/dist/scripts/generateTypes.d.ts +8 -0
- package/dist/scripts/generateTypes.js +44 -0
- package/dist/src/baseCommand.d.ts +14 -0
- package/dist/src/baseCommand.js +39 -0
- package/dist/src/commands/activity.d.ts +12 -0
- package/dist/src/commands/activity.js +75 -0
- package/dist/src/commands/dev.d.ts +15 -0
- package/dist/src/commands/dev.js +123 -0
- package/dist/src/commands/encrypt.d.ts +11 -0
- package/dist/src/commands/encrypt.js +50 -0
- package/dist/src/commands/init.d.ts +10 -0
- package/dist/src/commands/init.js +51 -0
- package/dist/src/commands/invite.d.ts +11 -0
- package/dist/src/commands/invite.js +71 -0
- package/dist/src/commands/login.d.ts +11 -0
- package/dist/src/commands/login.js +76 -0
- package/dist/src/commands/oauth2.d.ts +10 -0
- package/dist/src/commands/oauth2.js +99 -0
- package/dist/src/commands/publish.d.ts +28 -0
- package/dist/src/commands/publish.js +302 -0
- package/dist/src/commands/test.d.ts +9 -0
- package/dist/src/commands/test.js +165 -0
- package/dist/src/commands/upgrade.d.ts +7 -0
- package/dist/src/commands/upgrade.js +88 -0
- package/dist/src/configurationTypes.d.ts +209 -0
- package/dist/src/configurationTypes.js +49 -0
- package/dist/src/errors.d.ts +38 -0
- package/dist/src/errors.js +159 -0
- package/dist/src/hooks/init/displayLogo.d.ts +3 -0
- package/dist/src/hooks/init/displayLogo.js +37 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +5 -0
- package/dist/src/oauth2Helper/oauth2Helper.d.ts +63 -0
- package/dist/src/oauth2Helper/oauth2Helper.js +235 -0
- package/dist/src/oauth2Helper/types.d.ts +22 -0
- package/dist/src/oauth2Helper/types.js +2 -0
- package/dist/src/resources/configuration.d.ts +30 -0
- package/dist/src/resources/configuration.js +191 -0
- package/dist/src/resources/decryption.d.ts +5 -0
- package/dist/src/resources/decryption.js +62 -0
- package/dist/src/resources/fileSystem.d.ts +2 -0
- package/dist/src/resources/fileSystem.js +22 -0
- package/dist/src/resources/globalConfiguration.d.ts +13 -0
- package/dist/src/resources/globalConfiguration.js +44 -0
- package/dist/src/resources/integrations.d.ts +2 -0
- package/dist/src/resources/integrations.js +17 -0
- package/dist/src/resources/integrationsPlatform.d.ts +2 -0
- package/dist/src/resources/integrationsPlatform.js +33 -0
- package/dist/src/services/integrationsPlatform.d.ts +36 -0
- package/dist/src/services/integrationsPlatform.js +162 -0
- package/dist/src/services/oauth2Helper.d.ts +3 -0
- package/dist/src/services/oauth2Helper.js +34 -0
- package/dist/test/commands/activity.test.d.ts +1 -0
- package/dist/test/commands/activity.test.js +62 -0
- package/dist/test/commands/dev.test.d.ts +1 -0
- package/dist/test/commands/dev.test.js +139 -0
- package/dist/test/commands/encrypt.test.d.ts +1 -0
- package/dist/test/commands/encrypt.test.js +73 -0
- package/dist/test/commands/init.test.d.ts +1 -0
- package/dist/test/commands/init.test.js +45 -0
- package/dist/test/commands/invite.test.d.ts +1 -0
- package/dist/test/commands/invite.test.js +56 -0
- package/dist/test/commands/login.test.d.ts +1 -0
- package/dist/test/commands/login.test.js +90 -0
- package/dist/test/commands/oauth2.test.d.ts +1 -0
- package/dist/test/commands/oauth2.test.js +104 -0
- package/dist/test/commands/publish.test.d.ts +1 -0
- package/dist/test/commands/publish.test.js +429 -0
- package/dist/test/commands/test.test.d.ts +1 -0
- package/dist/test/commands/test.test.js +171 -0
- package/dist/test/commands/upgrade.test.d.ts +1 -0
- package/dist/test/commands/upgrade.test.js +47 -0
- package/dist/test/errors.test.d.ts +1 -0
- package/dist/test/errors.test.js +96 -0
- package/dist/test/helpers/init.d.ts +1 -0
- package/dist/test/helpers/init.js +6 -0
- package/dist/test/mocha.hooks.d.ts +2 -0
- package/dist/test/mocha.hooks.js +37 -0
- package/dist/test/oauth2Helper/oauth2Helper.test.d.ts +1 -0
- package/dist/test/oauth2Helper/oauth2Helper.test.js +150 -0
- package/dist/test/resources/configuration.test.d.ts +1 -0
- package/dist/test/resources/configuration.test.js +586 -0
- package/dist/test/resources/decryption.test.d.ts +1 -0
- package/dist/test/resources/decryption.test.js +68 -0
- package/dist/test/resources/globalConfiguration.test.d.ts +1 -0
- package/dist/test/resources/globalConfiguration.test.js +32 -0
- package/dist/test/services/integrationsPlatform.test.d.ts +1 -0
- package/dist/test/services/integrationsPlatform.test.js +168 -0
- package/dist/test/services/oauth2Helper.test.d.ts +1 -0
- package/dist/test/services/oauth2Helper.test.js +85 -0
- package/oclif.manifest.json +423 -0
- package/package.json +98 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
3
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
4
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The configuration of an integration
|
|
8
|
+
*/
|
|
9
|
+
export interface Configuration {
|
|
10
|
+
/**
|
|
11
|
+
* The name of the integration
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
/**
|
|
15
|
+
* The base URL where the integration is located
|
|
16
|
+
*/
|
|
17
|
+
baseUrl?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The relative URL (to the baseUrl) where the graph of items of the integration is located
|
|
20
|
+
*/
|
|
21
|
+
graphRelativeUrl?: string;
|
|
22
|
+
/**
|
|
23
|
+
* The relative URL (to the baseUrl) to fetch the current integration's authenticated user
|
|
24
|
+
*/
|
|
25
|
+
credentialAccountRelativeUrl?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The relative URL (to the baseUrl) to parse a webhook payload
|
|
28
|
+
*/
|
|
29
|
+
webhookParsingRelativeUrl?: string | null;
|
|
30
|
+
/**
|
|
31
|
+
* The relative URL (to the baseUrl) to operate on webhook subscriptions
|
|
32
|
+
*/
|
|
33
|
+
webhookSubscriptionsRelativeUrl?: string | null;
|
|
34
|
+
/**
|
|
35
|
+
* The relative URL (to the baseUrl) to acknowledge webhook sender
|
|
36
|
+
*/
|
|
37
|
+
webhookAcknowledgeRelativeUrl?: string | null;
|
|
38
|
+
/**
|
|
39
|
+
* The UI-related information of the integration
|
|
40
|
+
*/
|
|
41
|
+
ui?: {
|
|
42
|
+
/**
|
|
43
|
+
* The name of the integration, as it should be displayed in a UI
|
|
44
|
+
*/
|
|
45
|
+
displayName?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Base64-encoded SVG of the logo of the integration
|
|
48
|
+
*/
|
|
49
|
+
logo?: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* The authorizations of the integration
|
|
53
|
+
*/
|
|
54
|
+
authorizations?: Authorization[];
|
|
55
|
+
/**
|
|
56
|
+
* The test accounts of the integration
|
|
57
|
+
*/
|
|
58
|
+
testAccounts?: {
|
|
59
|
+
/**
|
|
60
|
+
* Test account for local development
|
|
61
|
+
*/
|
|
62
|
+
development?: {
|
|
63
|
+
[k: string]: unknown;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Test account for compliance tests
|
|
67
|
+
*/
|
|
68
|
+
compliance?: {
|
|
69
|
+
[k: string]: unknown;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* The secrets of the integration
|
|
74
|
+
*/
|
|
75
|
+
secrets?: {
|
|
76
|
+
[k: string]: string;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* An authorization is a way to obtain and generate credentials for an integration
|
|
81
|
+
*/
|
|
82
|
+
export interface Authorization {
|
|
83
|
+
name: string;
|
|
84
|
+
/**
|
|
85
|
+
* Whether the authorization is used locally for development purposes only
|
|
86
|
+
*/
|
|
87
|
+
development?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* The Base64-encoded data URL of an <img> src content or null. For example: 'data:image/png;base64,<base64>'
|
|
90
|
+
*/
|
|
91
|
+
instructionsImage?: null | string;
|
|
92
|
+
/**
|
|
93
|
+
* A string representing a markdown document or null
|
|
94
|
+
*/
|
|
95
|
+
instructionsMarkdown?: null | string;
|
|
96
|
+
method: Method;
|
|
97
|
+
oauth2?: Oauth2;
|
|
98
|
+
/**
|
|
99
|
+
* Variables to obtain credentials from an end-user
|
|
100
|
+
*/
|
|
101
|
+
variables?: {
|
|
102
|
+
/**
|
|
103
|
+
* This interface was referenced by `undefined`'s JSON-Schema definition
|
|
104
|
+
* via the `patternProperty` "^(?!refreshToken$)(?!accessToken$)(?!scope$)(?!expiresIn$)(?!tokenType$)(?!oauth2ExtraParameters$).*$".
|
|
105
|
+
*/
|
|
106
|
+
[k: string]: {
|
|
107
|
+
type: Type;
|
|
108
|
+
format?: Format;
|
|
109
|
+
/**
|
|
110
|
+
* The JSON Schema regular expression template for the string value. Only the values that match this template will be accepted. The regular expression syntax used is from JavaScript (more specifically, ECMA 262)
|
|
111
|
+
*/
|
|
112
|
+
pattern?: string;
|
|
113
|
+
label?: string;
|
|
114
|
+
required?: boolean;
|
|
115
|
+
defaultValue?: string | number | boolean;
|
|
116
|
+
placeholder?: string;
|
|
117
|
+
help?: string;
|
|
118
|
+
documentationUrl?: string;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Parameters to obtain OAuth 2 credentials from an end-user
|
|
124
|
+
*/
|
|
125
|
+
export interface Oauth2 {
|
|
126
|
+
/**
|
|
127
|
+
* The Client Secret obtained from the provider.
|
|
128
|
+
*/
|
|
129
|
+
clientSecret?: string;
|
|
130
|
+
/**
|
|
131
|
+
* The Client Id obtained from the provider.
|
|
132
|
+
*/
|
|
133
|
+
clientId?: string;
|
|
134
|
+
/**
|
|
135
|
+
* The URL to grant or deny access to the user account.
|
|
136
|
+
*/
|
|
137
|
+
authorizationUrl?: string;
|
|
138
|
+
/**
|
|
139
|
+
* The URL to obtain or refresh an access token.
|
|
140
|
+
*/
|
|
141
|
+
tokenUrl: string;
|
|
142
|
+
grantType?: GrantType;
|
|
143
|
+
scopes: {
|
|
144
|
+
/**
|
|
145
|
+
* The name of the scope
|
|
146
|
+
*/
|
|
147
|
+
name: string;
|
|
148
|
+
/**
|
|
149
|
+
* Message to the end-user to explain the usage of the scope by Unito
|
|
150
|
+
*/
|
|
151
|
+
help?: string;
|
|
152
|
+
}[];
|
|
153
|
+
tokenRequestParameters?: AuthorizationRequestParameters;
|
|
154
|
+
refreshRequestParameters?: AuthorizationRequestParameters;
|
|
155
|
+
requestContentType?: RequestContentType;
|
|
156
|
+
responseContentType?: RequestContentType;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The extra information used to communicate with the provider
|
|
160
|
+
*/
|
|
161
|
+
export interface AuthorizationRequestParameters {
|
|
162
|
+
/**
|
|
163
|
+
* Extra information to include in the HTTP request headers
|
|
164
|
+
*/
|
|
165
|
+
header?: {
|
|
166
|
+
[k: string]: string | number | boolean;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Extra information to include in the HTTP request body
|
|
170
|
+
*/
|
|
171
|
+
body?: {
|
|
172
|
+
[k: string]: string | number | boolean;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The method of authorization
|
|
177
|
+
*/
|
|
178
|
+
export declare enum Method {
|
|
179
|
+
CUSTOM = "custom",
|
|
180
|
+
OAUTH2 = "oauth2"
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The type of grant of the OAuth 2 authorization
|
|
184
|
+
*/
|
|
185
|
+
export declare enum GrantType {
|
|
186
|
+
AUTHORIZATION_CODE = "authorization_code",
|
|
187
|
+
PASSWORD = "password"
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The content type of exchanged information with the provider
|
|
191
|
+
*/
|
|
192
|
+
export declare enum RequestContentType {
|
|
193
|
+
URL_ENCODED = "application/x-www-form-urlencoded",
|
|
194
|
+
JSON = "application/json"
|
|
195
|
+
}
|
|
196
|
+
export declare enum Type {
|
|
197
|
+
BOOLEAN = "boolean",
|
|
198
|
+
NUMBER = "number",
|
|
199
|
+
PASSWORD = "password",
|
|
200
|
+
STRING = "string",
|
|
201
|
+
TEXT = "text"
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The JSON Schema format that the value of the variable must comply to
|
|
205
|
+
*/
|
|
206
|
+
export declare enum Format {
|
|
207
|
+
EMAIL = "email",
|
|
208
|
+
URI = "uri"
|
|
209
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
5
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
6
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.Format = exports.Type = exports.RequestContentType = exports.GrantType = exports.Method = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* The method of authorization
|
|
12
|
+
*/
|
|
13
|
+
var Method;
|
|
14
|
+
(function (Method) {
|
|
15
|
+
Method["CUSTOM"] = "custom";
|
|
16
|
+
Method["OAUTH2"] = "oauth2";
|
|
17
|
+
})(Method || (exports.Method = Method = {}));
|
|
18
|
+
/**
|
|
19
|
+
* The type of grant of the OAuth 2 authorization
|
|
20
|
+
*/
|
|
21
|
+
var GrantType;
|
|
22
|
+
(function (GrantType) {
|
|
23
|
+
GrantType["AUTHORIZATION_CODE"] = "authorization_code";
|
|
24
|
+
GrantType["PASSWORD"] = "password";
|
|
25
|
+
})(GrantType || (exports.GrantType = GrantType = {}));
|
|
26
|
+
/**
|
|
27
|
+
* The content type of exchanged information with the provider
|
|
28
|
+
*/
|
|
29
|
+
var RequestContentType;
|
|
30
|
+
(function (RequestContentType) {
|
|
31
|
+
RequestContentType["URL_ENCODED"] = "application/x-www-form-urlencoded";
|
|
32
|
+
RequestContentType["JSON"] = "application/json";
|
|
33
|
+
})(RequestContentType || (exports.RequestContentType = RequestContentType = {}));
|
|
34
|
+
var Type;
|
|
35
|
+
(function (Type) {
|
|
36
|
+
Type["BOOLEAN"] = "boolean";
|
|
37
|
+
Type["NUMBER"] = "number";
|
|
38
|
+
Type["PASSWORD"] = "password";
|
|
39
|
+
Type["STRING"] = "string";
|
|
40
|
+
Type["TEXT"] = "text";
|
|
41
|
+
})(Type || (exports.Type = Type = {}));
|
|
42
|
+
/**
|
|
43
|
+
* The JSON Schema format that the value of the variable must comply to
|
|
44
|
+
*/
|
|
45
|
+
var Format;
|
|
46
|
+
(function (Format) {
|
|
47
|
+
Format["EMAIL"] = "email";
|
|
48
|
+
Format["URI"] = "uri";
|
|
49
|
+
})(Format || (exports.Format = Format = {}));
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare class NoIntegrationFoundError extends Error {
|
|
2
|
+
}
|
|
3
|
+
export declare class NoConfigurationFileError extends Error {
|
|
4
|
+
}
|
|
5
|
+
export declare class ConfigurationMalformed extends Error {
|
|
6
|
+
}
|
|
7
|
+
export declare class MissingEnvironmentVariableError extends Error {
|
|
8
|
+
}
|
|
9
|
+
export declare class NoRefreshTokenError extends Error {
|
|
10
|
+
}
|
|
11
|
+
export declare class FailedToRetrieveAccessTokenError extends Error {
|
|
12
|
+
}
|
|
13
|
+
export declare class InvalidRequestContentTypeError extends Error {
|
|
14
|
+
}
|
|
15
|
+
export declare class MissingCredentialsError extends Error {
|
|
16
|
+
}
|
|
17
|
+
export declare class FileSizeExceeded extends Error {
|
|
18
|
+
}
|
|
19
|
+
export declare class MissingApiKey extends Error {
|
|
20
|
+
}
|
|
21
|
+
export declare class AuthenticationFailed extends Error {
|
|
22
|
+
}
|
|
23
|
+
export declare class DecryptionAuthenticationError extends Error {
|
|
24
|
+
encryptedEntityName: string;
|
|
25
|
+
constructor(entityName: string);
|
|
26
|
+
}
|
|
27
|
+
export declare class EntryDecryptionError extends Error {
|
|
28
|
+
key: string;
|
|
29
|
+
value: string;
|
|
30
|
+
environment: string;
|
|
31
|
+
constructor(key: string, value: string, targetEnvironment: string);
|
|
32
|
+
}
|
|
33
|
+
export declare class ConfigurationInvalid extends Error {
|
|
34
|
+
details: unknown;
|
|
35
|
+
prettyDetails: string;
|
|
36
|
+
constructor(message: string, details: unknown, prettyDetails: string);
|
|
37
|
+
}
|
|
38
|
+
export declare function handleError(error: Error): boolean;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleError = exports.ConfigurationInvalid = exports.EntryDecryptionError = exports.DecryptionAuthenticationError = exports.AuthenticationFailed = exports.MissingApiKey = exports.FileSizeExceeded = exports.MissingCredentialsError = exports.InvalidRequestContentTypeError = exports.FailedToRetrieveAccessTokenError = exports.NoRefreshTokenError = exports.MissingEnvironmentVariableError = exports.ConfigurationMalformed = exports.NoConfigurationFileError = exports.NoIntegrationFoundError = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
+
const json_colorizer_1 = tslib_1.__importDefault(require("json-colorizer"));
|
|
9
|
+
const configuration_1 = require("./resources/configuration");
|
|
10
|
+
const integrationsPlatform_1 = require("./services/integrationsPlatform");
|
|
11
|
+
class NoIntegrationFoundError extends Error {
|
|
12
|
+
}
|
|
13
|
+
exports.NoIntegrationFoundError = NoIntegrationFoundError;
|
|
14
|
+
class NoConfigurationFileError extends Error {
|
|
15
|
+
}
|
|
16
|
+
exports.NoConfigurationFileError = NoConfigurationFileError;
|
|
17
|
+
class ConfigurationMalformed extends Error {
|
|
18
|
+
}
|
|
19
|
+
exports.ConfigurationMalformed = ConfigurationMalformed;
|
|
20
|
+
class MissingEnvironmentVariableError extends Error {
|
|
21
|
+
}
|
|
22
|
+
exports.MissingEnvironmentVariableError = MissingEnvironmentVariableError;
|
|
23
|
+
class NoRefreshTokenError extends Error {
|
|
24
|
+
}
|
|
25
|
+
exports.NoRefreshTokenError = NoRefreshTokenError;
|
|
26
|
+
class FailedToRetrieveAccessTokenError extends Error {
|
|
27
|
+
}
|
|
28
|
+
exports.FailedToRetrieveAccessTokenError = FailedToRetrieveAccessTokenError;
|
|
29
|
+
class InvalidRequestContentTypeError extends Error {
|
|
30
|
+
}
|
|
31
|
+
exports.InvalidRequestContentTypeError = InvalidRequestContentTypeError;
|
|
32
|
+
class MissingCredentialsError extends Error {
|
|
33
|
+
}
|
|
34
|
+
exports.MissingCredentialsError = MissingCredentialsError;
|
|
35
|
+
class FileSizeExceeded extends Error {
|
|
36
|
+
}
|
|
37
|
+
exports.FileSizeExceeded = FileSizeExceeded;
|
|
38
|
+
class MissingApiKey extends Error {
|
|
39
|
+
}
|
|
40
|
+
exports.MissingApiKey = MissingApiKey;
|
|
41
|
+
class AuthenticationFailed extends Error {
|
|
42
|
+
}
|
|
43
|
+
exports.AuthenticationFailed = AuthenticationFailed;
|
|
44
|
+
class DecryptionAuthenticationError extends Error {
|
|
45
|
+
encryptedEntityName;
|
|
46
|
+
constructor(entityName) {
|
|
47
|
+
super();
|
|
48
|
+
this.encryptedEntityName = entityName;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.DecryptionAuthenticationError = DecryptionAuthenticationError;
|
|
52
|
+
class EntryDecryptionError extends Error {
|
|
53
|
+
key;
|
|
54
|
+
value;
|
|
55
|
+
environment;
|
|
56
|
+
constructor(key, value, targetEnvironment) {
|
|
57
|
+
super();
|
|
58
|
+
this.key = key;
|
|
59
|
+
this.value = value;
|
|
60
|
+
this.environment = targetEnvironment;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.EntryDecryptionError = EntryDecryptionError;
|
|
64
|
+
class ConfigurationInvalid extends Error {
|
|
65
|
+
details;
|
|
66
|
+
prettyDetails;
|
|
67
|
+
constructor(message, details, prettyDetails) {
|
|
68
|
+
super(message);
|
|
69
|
+
this.details = details;
|
|
70
|
+
this.prettyDetails = prettyDetails;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.ConfigurationInvalid = ConfigurationInvalid;
|
|
74
|
+
function handleError(error) {
|
|
75
|
+
/* istanbul ignore if */
|
|
76
|
+
if (core_1.ux.action.running) {
|
|
77
|
+
core_1.ux.action.stop(chalk_1.default.redBright('failed'));
|
|
78
|
+
}
|
|
79
|
+
let handled = false;
|
|
80
|
+
if (error instanceof NoIntegrationFoundError) {
|
|
81
|
+
core_1.ux.log(chalk_1.default.redBright('Your directory does not seem to contain an integration :('));
|
|
82
|
+
core_1.ux.log(`Make sure you are in the right directory and that you have a ${chalk_1.default.yellowBright(configuration_1.DEFAULT_CONFIGURATION_NAME)} file.`);
|
|
83
|
+
handled = true;
|
|
84
|
+
}
|
|
85
|
+
else if (error instanceof NoConfigurationFileError) {
|
|
86
|
+
core_1.ux.log(chalk_1.default.redBright('This command requires a configuration file for your integration :('));
|
|
87
|
+
core_1.ux.log(`This file should be located at ${chalk_1.default.yellowBright(path_1.default.relative(process.cwd(), (0, configuration_1.getConfigurationPath)()))}.`);
|
|
88
|
+
handled = true;
|
|
89
|
+
}
|
|
90
|
+
else if (error instanceof MissingEnvironmentVariableError) {
|
|
91
|
+
core_1.ux.log(chalk_1.default.redBright('This command requires a variable which is missing from your environment :('));
|
|
92
|
+
core_1.ux.log(`Make sure the environment variable ${chalk_1.default.yellowBright(error.message)} is defined.`);
|
|
93
|
+
handled = true;
|
|
94
|
+
}
|
|
95
|
+
else if (error instanceof ConfigurationMalformed) {
|
|
96
|
+
core_1.ux.log(chalk_1.default.redBright(`Your ${chalk_1.default.yellowBright(configuration_1.DEFAULT_CONFIGURATION_NAME)} was found but its not a valid JSON file!`));
|
|
97
|
+
handled = true;
|
|
98
|
+
}
|
|
99
|
+
else if (error instanceof ConfigurationInvalid) {
|
|
100
|
+
core_1.ux.log(chalk_1.default.redBright(`Your ${chalk_1.default.yellowBright(configuration_1.DEFAULT_CONFIGURATION_NAME)} is invalid!`));
|
|
101
|
+
core_1.ux.log();
|
|
102
|
+
core_1.ux.log(error.prettyDetails);
|
|
103
|
+
handled = true;
|
|
104
|
+
}
|
|
105
|
+
else if (error instanceof NoRefreshTokenError) {
|
|
106
|
+
core_1.ux.log(chalk_1.default.redBright('No refresh token found in your configuration file'));
|
|
107
|
+
handled = true;
|
|
108
|
+
}
|
|
109
|
+
else if (error instanceof FailedToRetrieveAccessTokenError) {
|
|
110
|
+
core_1.ux.log(chalk_1.default.redBright('Failed to retrieve access token'));
|
|
111
|
+
core_1.ux.log();
|
|
112
|
+
core_1.ux.log(error.message);
|
|
113
|
+
handled = true;
|
|
114
|
+
}
|
|
115
|
+
else if (error instanceof InvalidRequestContentTypeError) {
|
|
116
|
+
core_1.ux.log(chalk_1.default.redBright('Invalid request content type'));
|
|
117
|
+
handled = true;
|
|
118
|
+
core_1.ux.log();
|
|
119
|
+
core_1.ux.log(error.message);
|
|
120
|
+
}
|
|
121
|
+
else if (error instanceof integrationsPlatform_1.HttpError) {
|
|
122
|
+
handled = true;
|
|
123
|
+
core_1.ux.log();
|
|
124
|
+
core_1.ux.log((0, json_colorizer_1.default)(JSON.stringify(error.data, null, 2)));
|
|
125
|
+
}
|
|
126
|
+
else if (error instanceof MissingCredentialsError) {
|
|
127
|
+
core_1.ux.log();
|
|
128
|
+
core_1.ux.log(chalk_1.default.redBright('The credentials are missing from your configuration file'));
|
|
129
|
+
handled = true;
|
|
130
|
+
}
|
|
131
|
+
else if (error instanceof MissingApiKey) {
|
|
132
|
+
core_1.ux.log();
|
|
133
|
+
core_1.ux.log(chalk_1.default.redBright('Your API key is not set!'));
|
|
134
|
+
core_1.ux.log(`Make sure to run the ${chalk_1.default.yellowBright('login')} command first`);
|
|
135
|
+
handled = true;
|
|
136
|
+
}
|
|
137
|
+
else if (error instanceof AuthenticationFailed) {
|
|
138
|
+
core_1.ux.log();
|
|
139
|
+
core_1.ux.log(chalk_1.default.redBright('This command requires that you are logged to Unito!'));
|
|
140
|
+
core_1.ux.log(`Make sure to run the ${chalk_1.default.yellowBright('login')} command first`);
|
|
141
|
+
handled = true;
|
|
142
|
+
}
|
|
143
|
+
else if (error instanceof DecryptionAuthenticationError) {
|
|
144
|
+
core_1.ux.log();
|
|
145
|
+
core_1.ux.log(chalk_1.default.yellowBright(`Your configuration contains encrypted ${error.encryptedEntityName}.`));
|
|
146
|
+
core_1.ux.log('To use them locally, you must be authenticated to Unito.');
|
|
147
|
+
handled = true;
|
|
148
|
+
}
|
|
149
|
+
else if (error instanceof EntryDecryptionError) {
|
|
150
|
+
core_1.ux.log();
|
|
151
|
+
core_1.ux.log(chalk_1.default.yellowBright(`Error decrypting entry:`));
|
|
152
|
+
core_1.ux.log(chalk_1.default.redBright(`${error.key}: ${error.value}`));
|
|
153
|
+
core_1.ux.log();
|
|
154
|
+
core_1.ux.log(`Make sure they were encrypted by the same environement (Currently targeting: ${error.environment}).`);
|
|
155
|
+
handled = true;
|
|
156
|
+
}
|
|
157
|
+
return handled;
|
|
158
|
+
}
|
|
159
|
+
exports.handleError = handleError;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const gradient = tslib_1.__importStar(require("gradient-string"));
|
|
6
|
+
const displayLogo = async function () {
|
|
7
|
+
const gradients = [
|
|
8
|
+
gradient.atlas,
|
|
9
|
+
gradient.mind,
|
|
10
|
+
gradient.morning,
|
|
11
|
+
gradient.passion,
|
|
12
|
+
gradient.fruit,
|
|
13
|
+
gradient.instagram,
|
|
14
|
+
gradient.retro,
|
|
15
|
+
gradient.teen,
|
|
16
|
+
gradient.pastel,
|
|
17
|
+
gradient.rainbow,
|
|
18
|
+
gradient.cristal,
|
|
19
|
+
];
|
|
20
|
+
const selectedGradient = gradients[Math.floor(Math.random() * gradients.length)];
|
|
21
|
+
const UNITOCLI_LOGO = selectedGradient.multiline([
|
|
22
|
+
'+------------------------------------+',
|
|
23
|
+
'| |',
|
|
24
|
+
'| / / / /___ (_) /_____ |',
|
|
25
|
+
'| / / / / __ \\/ / __/ __ \\ |',
|
|
26
|
+
'| / /_/ / / / / / /_/ /_/ / |',
|
|
27
|
+
'| \\____/_/_/_/_/\\__/\\____/ |',
|
|
28
|
+
'| / ____/ / / _/ |',
|
|
29
|
+
'| / / / / / / |',
|
|
30
|
+
'| / /___/ /____/ / |',
|
|
31
|
+
'| \\____/_____/___/ |',
|
|
32
|
+
'| |',
|
|
33
|
+
'+------------------------------------+',
|
|
34
|
+
].join('\n'));
|
|
35
|
+
core_1.ux.log(UNITOCLI_LOGO);
|
|
36
|
+
};
|
|
37
|
+
exports.default = displayLogo;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { run } from '@oclif/core';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as openUrl from 'openurl';
|
|
2
|
+
import { Oauth2Response, Oauth2Payload } from './types';
|
|
3
|
+
export declare const open: typeof openUrl;
|
|
4
|
+
declare class OAuth2Helper {
|
|
5
|
+
private server;
|
|
6
|
+
private clientId;
|
|
7
|
+
private clientSecret;
|
|
8
|
+
private providerAuthorizationUrl;
|
|
9
|
+
private tokenUrl;
|
|
10
|
+
private scopes;
|
|
11
|
+
private grantType;
|
|
12
|
+
private requestContentType;
|
|
13
|
+
private responseContentType;
|
|
14
|
+
private refreshToken?;
|
|
15
|
+
private code;
|
|
16
|
+
private serverUrl;
|
|
17
|
+
private tokenRequestParameters;
|
|
18
|
+
private refreshRequestParameters;
|
|
19
|
+
/**
|
|
20
|
+
* Constructs an instance of OAuthHelper.
|
|
21
|
+
* @param clientId The client ID for your OAuth application.
|
|
22
|
+
* @param clientSecret The client secret for your OAuth application.
|
|
23
|
+
* @param authorizationUrl The URL for the authorization endpoint of the provider.
|
|
24
|
+
* @param scopes The scopes required for the OAuth authorization.
|
|
25
|
+
* @param providerTokenUrl The URL for the token endpoint of the provider.
|
|
26
|
+
*/
|
|
27
|
+
constructor(authorizationInfo: Oauth2Payload);
|
|
28
|
+
/**
|
|
29
|
+
* Handles the authorization request and redirects the user to the provider's authorization page.
|
|
30
|
+
* @param req The express Request object.
|
|
31
|
+
* @param res The express Response object.
|
|
32
|
+
*/
|
|
33
|
+
private handleAuthorize;
|
|
34
|
+
/**
|
|
35
|
+
* Handles the callback request from the provider and stores the authorization code.
|
|
36
|
+
* @param req The express Request object.
|
|
37
|
+
* @param res The express Response object.
|
|
38
|
+
*/
|
|
39
|
+
private handleCallback;
|
|
40
|
+
private encodeBody;
|
|
41
|
+
/**
|
|
42
|
+
* Handles the token request to exchange the authorization code for an access token.
|
|
43
|
+
* @param req The express Request object.
|
|
44
|
+
* @param res The express Response object.
|
|
45
|
+
*/
|
|
46
|
+
private handleToken;
|
|
47
|
+
updateToken(): Promise<Oauth2Response>;
|
|
48
|
+
/**
|
|
49
|
+
* Starts the Express server for handling OAuth callbacks.
|
|
50
|
+
* @returns The URL of the server.
|
|
51
|
+
*/
|
|
52
|
+
startServer(): string;
|
|
53
|
+
/**
|
|
54
|
+
* Stops the Express server.
|
|
55
|
+
*/
|
|
56
|
+
stopServer(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Waits for the authorization code to be set.
|
|
59
|
+
* @returns A promise that resolves when the code is set.
|
|
60
|
+
*/
|
|
61
|
+
callbackIsDone(): Promise<boolean>;
|
|
62
|
+
}
|
|
63
|
+
export default OAuth2Helper;
|