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 isExitCodeException(err) {
|
27 | return err && typeof err.exitCode === 'number' && err.exitCode >= 0 && err.exitCode <= 255;
|
28 | }
|
29 | exports.isExitCodeException = isExitCodeException;
|
30 | function isSuperAgentError(err) {
|
31 | return err && err.response && typeof err.response === 'object';
|
32 | }
|
33 | exports.isSuperAgentError = isSuperAgentError;
|
34 | function isAPIResponseSuccess(res) {
|
35 | return res && (typeof res.data === 'object' || typeof res.data === 'string');
|
36 | }
|
37 | exports.isAPIResponseSuccess = isAPIResponseSuccess;
|
38 | function isAPIResponseError(res) {
|
39 | return res && typeof res.error === 'object';
|
40 | }
|
41 | exports.isAPIResponseError = isAPIResponseError;
|
42 | function isOrg(org) {
|
43 | return org && typeof org.name === 'string';
|
44 | }
|
45 | exports.isOrg = isOrg;
|
46 | function isGithubRepo(repo) {
|
47 | return repo
|
48 | && typeof repo.full_name === 'string'
|
49 | && typeof repo.id === 'number';
|
50 | }
|
51 | exports.isGithubRepo = isGithubRepo;
|
52 | function isGithubBranch(branch) {
|
53 | return branch && typeof branch.name === 'string';
|
54 | }
|
55 | exports.isGithubBranch = isGithubBranch;
|
56 | function isGithubRepoListResponse(res) {
|
57 | if (!isAPIResponseSuccess(res) || !Array.isArray(res.data)) {
|
58 | return false;
|
59 | }
|
60 | if (res.data.length === 0) {
|
61 | return true;
|
62 | }
|
63 | return isGithubRepo(res.data[0]);
|
64 | }
|
65 | exports.isGithubRepoListResponse = isGithubRepoListResponse;
|
66 | function isGithubBranchListResponse(res) {
|
67 | if (!isAPIResponseSuccess(res) || !Array.isArray(res.data)) {
|
68 | return false;
|
69 | }
|
70 | if (res.data.length === 0) {
|
71 | return true;
|
72 | }
|
73 | return isGithubBranch(res.data[0]);
|
74 | }
|
75 | exports.isGithubBranchListResponse = isGithubBranchListResponse;
|
76 | function isAppAssociation(association) {
|
77 | return (association &&
|
78 | typeof association.repository === 'object' &&
|
79 | typeof association.repository.html_url === 'string' &&
|
80 | (isGithubRepoAssociation(association.repository) ||
|
81 | isBitbucketCloudRepoAssociation(association.repository) ||
|
82 | isBitbucketServerRepoAssociation(association.repository)));
|
83 | }
|
84 | exports.isAppAssociation = isAppAssociation;
|
85 | function isAppAssociationResponse(res) {
|
86 | return isAPIResponseSuccess(res)
|
87 | && typeof res.data === 'object'
|
88 | && isAppAssociation(res.data);
|
89 | }
|
90 | exports.isAppAssociationResponse = isAppAssociationResponse;
|
91 | function isGithubRepoAssociation(association) {
|
92 | return association
|
93 | && association.type === 'github'
|
94 | && typeof association.id === 'number';
|
95 | }
|
96 | exports.isGithubRepoAssociation = isGithubRepoAssociation;
|
97 | function isBitbucketCloudRepoAssociation(association) {
|
98 | return association
|
99 | && association.type === 'bitbucket_cloud'
|
100 | && typeof association.id === 'string';
|
101 | }
|
102 | exports.isBitbucketCloudRepoAssociation = isBitbucketCloudRepoAssociation;
|
103 | function isBitbucketServerRepoAssociation(association) {
|
104 | return association
|
105 | && association.type === 'bitbucket_server'
|
106 | && typeof association.id === 'number';
|
107 | }
|
108 | exports.isBitbucketServerRepoAssociation = isBitbucketServerRepoAssociation;
|
109 | function isApp(app) {
|
110 | return app
|
111 | && typeof app === 'object'
|
112 | && typeof app.id === 'string'
|
113 | && typeof app.name === 'string'
|
114 | && typeof app.slug === 'string'
|
115 | && (!app.org || isOrg(app.org))
|
116 | && (!app.association || isAppAssociation(app.association));
|
117 | }
|
118 | exports.isApp = isApp;
|
119 | function isAppResponse(res) {
|
120 | return isAPIResponseSuccess(res)
|
121 | && typeof res.data === 'object'
|
122 | && isApp(res.data);
|
123 | }
|
124 | exports.isAppResponse = isAppResponse;
|
125 | function isAppsResponse(res) {
|
126 | if (!isAPIResponseSuccess(res) || !Array.isArray(res.data)) {
|
127 | return false;
|
128 | }
|
129 | if (res.data.length === 0) {
|
130 | return true;
|
131 | }
|
132 | return isApp(res.data[0]);
|
133 | }
|
134 | exports.isAppsResponse = isAppsResponse;
|
135 | function isOAuthLogin(login) {
|
136 | return login && typeof login.redirect_url === 'string';
|
137 | }
|
138 | exports.isOAuthLogin = isOAuthLogin;
|
139 | function isOAuthLoginResponse(res) {
|
140 | return isAPIResponseSuccess(res) && isOAuthLogin(res.data);
|
141 | }
|
142 | exports.isOAuthLoginResponse = isOAuthLoginResponse;
|
143 | function isSnapshot(snapshot) {
|
144 | return snapshot
|
145 | && typeof snapshot.id === 'string'
|
146 | && typeof snapshot.sha === 'string'
|
147 | && typeof snapshot.ref === 'string'
|
148 | && typeof snapshot.state === 'string'
|
149 | && typeof snapshot.created === 'string'
|
150 | && typeof snapshot.note === 'string';
|
151 | }
|
152 | exports.isSnapshot = isSnapshot;
|
153 | function isSnapshotResponse(res) {
|
154 | return isAPIResponseSuccess(res) && isSnapshot(res.data);
|
155 | }
|
156 | exports.isSnapshotResponse = isSnapshotResponse;
|
157 | function isSnapshotListResponse(res) {
|
158 | if (!isAPIResponseSuccess(res) || !Array.isArray(res.data)) {
|
159 | return false;
|
160 | }
|
161 | if (res.data.length === 0) {
|
162 | return true;
|
163 | }
|
164 | return isSnapshot(res.data[0]);
|
165 | }
|
166 | exports.isSnapshotListResponse = isSnapshotListResponse;
|
167 | function isLogin(login) {
|
168 | return login
|
169 | && isUser(login.user)
|
170 | && typeof login.token === 'string';
|
171 | }
|
172 | exports.isLogin = isLogin;
|
173 | function isLoginResponse(res) {
|
174 | return isAPIResponseSuccess(res) && isLogin(res.data);
|
175 | }
|
176 | exports.isLoginResponse = isLoginResponse;
|
177 | function isAuthConnection(connection) {
|
178 | return connection && typeof connection.uuid === 'string';
|
179 | }
|
180 | exports.isAuthConnection = isAuthConnection;
|
181 | function isAuthConnectionResponse(res) {
|
182 | return isAPIResponseSuccess(res) && isAuthConnection(res.data);
|
183 | }
|
184 | exports.isAuthConnectionResponse = isAuthConnectionResponse;
|
185 | function isUser(user) {
|
186 | return user
|
187 | && typeof user.id === 'number'
|
188 | && typeof user.email === 'string';
|
189 | }
|
190 | exports.isUser = isUser;
|
191 | function isUserResponse(res) {
|
192 | return isAPIResponseSuccess(res) && isUser(res.data);
|
193 | }
|
194 | exports.isUserResponse = isUserResponse;
|
195 | function isSSHKey(key) {
|
196 | return key
|
197 | && typeof key.id === 'string'
|
198 | && typeof key.pubkey === 'string'
|
199 | && typeof key.fingerprint === 'string'
|
200 | && typeof key.annotation === 'string'
|
201 | && typeof key.name === 'string'
|
202 | && typeof key.created === 'string'
|
203 | && typeof key.updated === 'string';
|
204 | }
|
205 | exports.isSSHKey = isSSHKey;
|
206 | function isSSHKeyListResponse(res) {
|
207 | if (!isAPIResponseSuccess(res) || !Array.isArray(res.data)) {
|
208 | return false;
|
209 | }
|
210 | if (res.data.length === 0) {
|
211 | return true;
|
212 | }
|
213 | return isSSHKey(res.data[0]);
|
214 | }
|
215 | exports.isSSHKeyListResponse = isSSHKeyListResponse;
|
216 | function isSSHKeyResponse(res) {
|
217 | return isAPIResponseSuccess(res) && isSSHKey(res.data);
|
218 | }
|
219 | exports.isSSHKeyResponse = isSSHKeyResponse;
|
220 | function isSecurityProfile(obj) {
|
221 | return obj
|
222 | && typeof obj.name === 'string'
|
223 | && typeof obj.tag === 'string'
|
224 | && typeof obj.type === 'string'
|
225 | && typeof obj.created === 'string'
|
226 | && typeof obj.credentials === 'object';
|
227 | }
|
228 | exports.isSecurityProfile = isSecurityProfile;
|
229 | function isSecurityProfileResponse(r) {
|
230 | const res = r;
|
231 | return isAPIResponseSuccess(res) && isSecurityProfile(res.data);
|
232 | }
|
233 | exports.isSecurityProfileResponse = isSecurityProfileResponse;
|
234 | function isTreatableAilment(ailment) {
|
235 | return ailment && ailment.treatable && typeof ailment.getTreatmentSteps === 'function';
|
236 | }
|
237 | exports.isTreatableAilment = isTreatableAilment;
|
238 | function isIntegrationName(name) {
|
239 | return exports.INTEGRATION_NAMES.includes(name);
|
240 | }
|
241 | exports.isIntegrationName = isIntegrationName;
|
242 | function isProjectConfig(configFile) {
|
243 | return configFile
|
244 | && typeof configFile.name === 'string'
|
245 | && typeof configFile.projects === 'undefined';
|
246 | }
|
247 | exports.isProjectConfig = isProjectConfig;
|
248 | function isMultiProjectConfig(configFile) {
|
249 | return configFile
|
250 | && typeof configFile.name === 'undefined'
|
251 | && typeof configFile.projects === 'object';
|
252 | }
|
253 | exports.isMultiProjectConfig = isMultiProjectConfig;
|