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