1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.INTEGRATION_NAMES = ['capacitor', 'cordova', 'enterprise'];
|
4 | function isCommand(cmd) {
|
5 | return cmd && typeof cmd.run === 'function';
|
6 | }
|
7 | exports.isCommand = isCommand;
|
8 | function isCommandPreRun(cmd) {
|
9 | return cmd && typeof cmd.preRun === 'function';
|
10 | }
|
11 | exports.isCommandPreRun = isCommandPreRun;
|
12 | function isStarterManifest(obj) {
|
13 | return obj &&
|
14 | typeof obj.name === 'string' &&
|
15 | typeof obj.baseref === 'string';
|
16 | }
|
17 | exports.isStarterManifest = isStarterManifest;
|
18 | function isCordovaPackageJson(obj) {
|
19 | return obj &&
|
20 | typeof obj.name === 'string' &&
|
21 | typeof obj.cordova === 'object' &&
|
22 | Array.isArray(obj.cordova.platforms) &&
|
23 | typeof obj.cordova.plugins === 'object';
|
24 | }
|
25 | exports.isCordovaPackageJson = isCordovaPackageJson;
|
26 | function isLegacyAndroidBuildOutputFile(obj) {
|
27 | if (!Array.isArray(obj)) {
|
28 | return false;
|
29 | }
|
30 | if (obj.length === 0) {
|
31 | return true;
|
32 | }
|
33 | return obj[0]
|
34 | && typeof obj[0].path === 'string'
|
35 | && typeof obj[0].outputType === 'object'
|
36 | && typeof obj[0].outputType.type === 'string';
|
37 | }
|
38 | exports.isLegacyAndroidBuildOutputFile = isLegacyAndroidBuildOutputFile;
|
39 | function isAndroidBuildOutputFile(obj) {
|
40 | return obj &&
|
41 | typeof obj.artifactType === 'object' &&
|
42 | typeof obj.artifactType.type === 'string' &&
|
43 | Array.isArray(obj.elements);
|
44 | }
|
45 | exports.isAndroidBuildOutputFile = isAndroidBuildOutputFile;
|
46 | function isExitCodeException(err) {
|
47 | return err && typeof err.exitCode === 'number' && err.exitCode >= 0 && err.exitCode <= 255;
|
48 | }
|
49 | exports.isExitCodeException = isExitCodeException;
|
50 | function isSuperAgentError(err) {
|
51 | return err && err.response && typeof err.response === 'object';
|
52 | }
|
53 | exports.isSuperAgentError = isSuperAgentError;
|
54 | function isAPIResponseSuccess(res) {
|
55 | return res && (typeof res.data === 'object' || typeof res.data === 'string');
|
56 | }
|
57 | exports.isAPIResponseSuccess = isAPIResponseSuccess;
|
58 | function isAPIResponseError(res) {
|
59 | return res && typeof res.error === 'object';
|
60 | }
|
61 | exports.isAPIResponseError = isAPIResponseError;
|
62 | function isOrg(org) {
|
63 | return org && typeof org.name === 'string';
|
64 | }
|
65 | exports.isOrg = isOrg;
|
66 | function isGithubRepo(repo) {
|
67 | return repo
|
68 | && typeof repo.full_name === 'string'
|
69 | && typeof repo.id === 'number';
|
70 | }
|
71 | exports.isGithubRepo = isGithubRepo;
|
72 | function isGithubBranch(branch) {
|
73 | return branch && typeof branch.name === 'string';
|
74 | }
|
75 | exports.isGithubBranch = isGithubBranch;
|
76 | function isGithubRepoListResponse(res) {
|
77 | if (!isAPIResponseSuccess(res) || !Array.isArray(res.data)) {
|
78 | return false;
|
79 | }
|
80 | if (res.data.length === 0) {
|
81 | return true;
|
82 | }
|
83 | return isGithubRepo(res.data[0]);
|
84 | }
|
85 | exports.isGithubRepoListResponse = isGithubRepoListResponse;
|
86 | function isGithubBranchListResponse(res) {
|
87 | if (!isAPIResponseSuccess(res) || !Array.isArray(res.data)) {
|
88 | return false;
|
89 | }
|
90 | if (res.data.length === 0) {
|
91 | return true;
|
92 | }
|
93 | return isGithubBranch(res.data[0]);
|
94 | }
|
95 | exports.isGithubBranchListResponse = isGithubBranchListResponse;
|
96 | function isAppAssociation(association) {
|
97 | return (association &&
|
98 | typeof association.repository === 'object' &&
|
99 | typeof association.repository.html_url === 'string' &&
|
100 | (isGithubRepoAssociation(association.repository) ||
|
101 | isBitbucketCloudRepoAssociation(association.repository) ||
|
102 | isBitbucketServerRepoAssociation(association.repository)));
|
103 | }
|
104 | exports.isAppAssociation = isAppAssociation;
|
105 | function isAppAssociationResponse(res) {
|
106 | return isAPIResponseSuccess(res)
|
107 | && typeof res.data === 'object'
|
108 | && isAppAssociation(res.data);
|
109 | }
|
110 | exports.isAppAssociationResponse = isAppAssociationResponse;
|
111 | function isGithubRepoAssociation(association) {
|
112 | return association
|
113 | && association.type === 'github'
|
114 | && typeof association.id === 'number';
|
115 | }
|
116 | exports.isGithubRepoAssociation = isGithubRepoAssociation;
|
117 | function isBitbucketCloudRepoAssociation(association) {
|
118 | return association
|
119 | && association.type === 'bitbucket_cloud'
|
120 | && typeof association.id === 'string';
|
121 | }
|
122 | exports.isBitbucketCloudRepoAssociation = isBitbucketCloudRepoAssociation;
|
123 | function isBitbucketServerRepoAssociation(association) {
|
124 | return association
|
125 | && association.type === 'bitbucket_server'
|
126 | && typeof association.id === 'number';
|
127 | }
|
128 | exports.isBitbucketServerRepoAssociation = isBitbucketServerRepoAssociation;
|
129 | function isApp(app) {
|
130 | return app
|
131 | && typeof app === 'object'
|
132 | && typeof app.id === 'string'
|
133 | && typeof app.name === 'string'
|
134 | && typeof app.slug === 'string'
|
135 | && (!app.org || isOrg(app.org))
|
136 | && (!app.association || isAppAssociation(app.association));
|
137 | }
|
138 | exports.isApp = isApp;
|
139 | function isAppResponse(res) {
|
140 | return isAPIResponseSuccess(res)
|
141 | && typeof res.data === 'object'
|
142 | && isApp(res.data);
|
143 | }
|
144 | exports.isAppResponse = isAppResponse;
|
145 | function isAppsResponse(res) {
|
146 | if (!isAPIResponseSuccess(res) || !Array.isArray(res.data)) {
|
147 | return false;
|
148 | }
|
149 | if (res.data.length === 0) {
|
150 | return true;
|
151 | }
|
152 | return isApp(res.data[0]);
|
153 | }
|
154 | exports.isAppsResponse = isAppsResponse;
|
155 | function isOAuthLogin(login) {
|
156 | return login && typeof login.redirect_url === 'string';
|
157 | }
|
158 | exports.isOAuthLogin = isOAuthLogin;
|
159 | function isOAuthLoginResponse(res) {
|
160 | return isAPIResponseSuccess(res) && isOAuthLogin(res.data);
|
161 | }
|
162 | exports.isOAuthLoginResponse = isOAuthLoginResponse;
|
163 | function isOpenIDToken(tokenObj) {
|
164 | return tokenObj
|
165 | && typeof tokenObj.access_token === 'string'
|
166 | && typeof tokenObj.expires_in === 'number'
|
167 | && (tokenObj.id_token ? typeof tokenObj.id_token === 'string' : true)
|
168 | && (tokenObj.refresh_token ? typeof tokenObj.refresh_token === 'string' : true)
|
169 | && tokenObj.scope === 'openid profile email offline_access'
|
170 | && tokenObj.token_type === 'Bearer';
|
171 | }
|
172 | exports.isOpenIDToken = isOpenIDToken;
|
173 | function isOpenIDTokenExchangeResponse(res) {
|
174 | return res && typeof res.body === 'object' && isOpenIDToken(res.body);
|
175 | }
|
176 | exports.isOpenIDTokenExchangeResponse = isOpenIDTokenExchangeResponse;
|
177 | function isSnapshot(snapshot) {
|
178 | return snapshot
|
179 | && typeof snapshot.id === 'string'
|
180 | && typeof snapshot.sha === 'string'
|
181 | && typeof snapshot.ref === 'string'
|
182 | && typeof snapshot.state === 'string'
|
183 | && typeof snapshot.created === 'string'
|
184 | && typeof snapshot.note === 'string';
|
185 | }
|
186 | exports.isSnapshot = isSnapshot;
|
187 | function isSnapshotResponse(res) {
|
188 | return isAPIResponseSuccess(res) && isSnapshot(res.data);
|
189 | }
|
190 | exports.isSnapshotResponse = isSnapshotResponse;
|
191 | function isSnapshotListResponse(res) {
|
192 | if (!isAPIResponseSuccess(res) || !Array.isArray(res.data)) {
|
193 | return false;
|
194 | }
|
195 | if (res.data.length === 0) {
|
196 | return true;
|
197 | }
|
198 | return isSnapshot(res.data[0]);
|
199 | }
|
200 | exports.isSnapshotListResponse = isSnapshotListResponse;
|
201 | function isLogin(login) {
|
202 | return login
|
203 | && isUser(login.user)
|
204 | && typeof login.token === 'string';
|
205 | }
|
206 | exports.isLogin = isLogin;
|
207 | function isLoginResponse(res) {
|
208 | return isAPIResponseSuccess(res) && isLogin(res.data);
|
209 | }
|
210 | exports.isLoginResponse = isLoginResponse;
|
211 | function isAuthConnection(connection) {
|
212 | return connection && typeof connection.uuid === 'string';
|
213 | }
|
214 | exports.isAuthConnection = isAuthConnection;
|
215 | function isAuthConnectionResponse(res) {
|
216 | return isAPIResponseSuccess(res) && isAuthConnection(res.data);
|
217 | }
|
218 | exports.isAuthConnectionResponse = isAuthConnectionResponse;
|
219 | function isUser(user) {
|
220 | return user
|
221 | && typeof user.id === 'number'
|
222 | && typeof user.email === 'string';
|
223 | }
|
224 | exports.isUser = isUser;
|
225 | function isUserResponse(res) {
|
226 | return isAPIResponseSuccess(res) && isUser(res.data);
|
227 | }
|
228 | exports.isUserResponse = isUserResponse;
|
229 | function isSSHKey(key) {
|
230 | return key
|
231 | && typeof key.id === 'string'
|
232 | && typeof key.pubkey === 'string'
|
233 | && typeof key.fingerprint === 'string'
|
234 | && typeof key.annotation === 'string'
|
235 | && typeof key.name === 'string'
|
236 | && typeof key.created === 'string'
|
237 | && typeof key.updated === 'string';
|
238 | }
|
239 | exports.isSSHKey = isSSHKey;
|
240 | function isSSHKeyListResponse(res) {
|
241 | if (!isAPIResponseSuccess(res) || !Array.isArray(res.data)) {
|
242 | return false;
|
243 | }
|
244 | if (res.data.length === 0) {
|
245 | return true;
|
246 | }
|
247 | return isSSHKey(res.data[0]);
|
248 | }
|
249 | exports.isSSHKeyListResponse = isSSHKeyListResponse;
|
250 | function isSSHKeyResponse(res) {
|
251 | return isAPIResponseSuccess(res) && isSSHKey(res.data);
|
252 | }
|
253 | exports.isSSHKeyResponse = isSSHKeyResponse;
|
254 | function isSecurityProfile(obj) {
|
255 | return obj
|
256 | && typeof obj.name === 'string'
|
257 | && typeof obj.tag === 'string'
|
258 | && typeof obj.type === 'string'
|
259 | && typeof obj.created === 'string'
|
260 | && typeof obj.credentials === 'object';
|
261 | }
|
262 | exports.isSecurityProfile = isSecurityProfile;
|
263 | function isSecurityProfileResponse(r) {
|
264 | const res = r;
|
265 | return isAPIResponseSuccess(res) && isSecurityProfile(res.data);
|
266 | }
|
267 | exports.isSecurityProfileResponse = isSecurityProfileResponse;
|
268 | function isTreatableAilment(ailment) {
|
269 | return ailment && ailment.treatable && typeof ailment.getTreatmentSteps === 'function';
|
270 | }
|
271 | exports.isTreatableAilment = isTreatableAilment;
|
272 | function isIntegrationName(name) {
|
273 | return exports.INTEGRATION_NAMES.includes(name);
|
274 | }
|
275 | exports.isIntegrationName = isIntegrationName;
|
276 | function isProjectConfig(configFile) {
|
277 | return configFile
|
278 | && typeof configFile.name === 'string'
|
279 | && typeof configFile.projects === 'undefined';
|
280 | }
|
281 | exports.isProjectConfig = isProjectConfig;
|
282 | function isMultiProjectConfig(configFile) {
|
283 | return configFile
|
284 | && typeof configFile.name === 'undefined'
|
285 | && typeof configFile.projects === 'object';
|
286 | }
|
287 | exports.isMultiProjectConfig = isMultiProjectConfig;
|