@chainpatrol/cli 0.24.0 → 0.27.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/CHANGELOG.md +41 -0
- package/dist/{breakdown-XA6UUD3T.js → breakdown-5DJMXRK4.js} +2 -2
- package/dist/{check-NQZPNAUF.js → check-5P3EXVSN.js} +1 -2
- package/dist/chunk-MM5OAY2U.js +317 -0
- package/dist/chunk-OFUIYMPD.js +64 -0
- package/dist/{chunk-DVNTYW7L.js → chunk-PEX2A3IL.js} +1 -1
- package/dist/cli.js +38 -38
- package/dist/{configs-update-VDZVBTIF.js → configs-update-TAYT4JTU.js} +1 -2
- package/dist/{create-DGCWT2YJ.js → create-UXRULUR7.js} +1 -2
- package/dist/{drift-YZHCIQ5O.js → drift-TCZELVHO.js} +1 -2
- package/dist/{found-6JAOLM6M.js → found-NCP6H2SD.js} +2 -2
- package/dist/{get-RC75EJFC.js → get-2PCG3CQN.js} +24 -8
- package/dist/{healthcheck-7YWSOY6Y.js → healthcheck-5YEZCTXC.js} +1 -2
- package/dist/{list-IDR7WH5J.js → list-23C72EH4.js} +3 -3
- package/dist/{list-4HX2R7HU.js → list-2RHEVI2T.js} +1 -2
- package/dist/list-FZD2FGJA.js +83 -0
- package/dist/{list-4KIZLIVN.js → list-GEJQ6N2Y.js} +1 -2
- package/dist/{list-SRVNEUHC.js → list-JG2R7EHK.js} +24 -12
- package/dist/{list-WQFDRXHD.js → list-MPSB2DYU.js} +1 -2
- package/dist/{list-EJDWUF6W.js → list-QJYRXPXM.js} +1 -2
- package/dist/{list-UDT5MDQZ.js → list-QLMFMYU6.js} +1 -2
- package/dist/{list-YNQ6VSYV.js → list-SCA73PLA.js} +1 -2
- package/dist/{list-ZBC53OYA.js → list-TA4HYD66.js} +1 -2
- package/dist/{list-735RYNAF.js → list-TULFPPG3.js} +1 -2
- package/dist/{list-Q3MMBL4Y.js → list-W6JZUNS2.js} +1 -2
- package/dist/{list-json-7FDHNRYP.js → list-json-NJ5IFRDE.js} +1 -2
- package/dist/{login-AMEXCOGT.js → login-2NRI3ECY.js} +2 -2
- package/dist/{login-json-MPLXCSP4.js → login-json-HOCNSQQ7.js} +2 -2
- package/dist/{login-plain-NIJDS3D2.js → login-plain-6ZJF5KA7.js} +2 -2
- package/dist/{organization-NEZA6JX2.js → organization-N6RMWKJM.js} +2 -2
- package/dist/{run-CCVJIK7L.js → run-KOZXEYTL.js} +1 -2
- package/dist/{run-5QV3YD7V.js → run-SE2SUE64.js} +1 -2
- package/dist/{run-JLTNFOJK.js → run-TUADYLU7.js} +3 -3
- package/dist/{search-JXJLBV43.js → search-5DOXBWPB.js} +1 -2
- package/dist/{search-ZXTJPVM6.js → search-Y37B2JVP.js} +1 -2
- package/dist/{setup-skill-CSKNZVG2.js → setup-skill-RRTDEOR4.js} +1 -1
- package/dist/{snapshot-NYOLPGRW.js → snapshot-RFGSAHO7.js} +1 -2
- package/dist/{summary-FE6ROSOO.js → summary-XCN3DRYP.js} +2 -2
- package/dist/{validate-RPQEEQ36.js → validate-OYTNB2ZM.js} +1 -2
- package/dist/{whoami-ZIWZCBGI.js → whoami-5WCW3FOZ.js} +1 -2
- package/package.json +2 -1
- package/dist/chunk-4RKRCENC.js +0 -1964
- package/dist/chunk-GOQL7UCG.js +0 -422
- package/dist/list-ZARZ72DG.js +0 -64
- package/dist/{chunk-PZV55KAR.js → chunk-GGBG2R63.js} +3 -3
package/dist/chunk-GOQL7UCG.js
DELETED
|
@@ -1,422 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getValidCredentials
|
|
3
|
-
} from "./chunk-EGWK6SRQ.js";
|
|
4
|
-
import {
|
|
5
|
-
DateTime
|
|
6
|
-
} from "./chunk-TFCNKBRC.js";
|
|
7
|
-
import {
|
|
8
|
-
getConfig
|
|
9
|
-
} from "./chunk-U73SABXK.js";
|
|
10
|
-
|
|
11
|
-
// src/lib/api-client.ts
|
|
12
|
-
function parseIsoDate(value) {
|
|
13
|
-
if (!value) return void 0;
|
|
14
|
-
const dt = DateTime.fromISO(value, { zone: "utc" });
|
|
15
|
-
if (!dt.isValid) {
|
|
16
|
-
throw new Error(`Invalid ISO date: '${value}'. Use YYYY-MM-DD or full ISO 8601.`);
|
|
17
|
-
}
|
|
18
|
-
return dt.toJSDate();
|
|
19
|
-
}
|
|
20
|
-
function parseIsoDateString(value) {
|
|
21
|
-
return parseIsoDate(value)?.toISOString();
|
|
22
|
-
}
|
|
23
|
-
var REPORT_REVIEW_DECISIONS = ["APPROVE", "REJECT", "SKIP", "ESCALATE"];
|
|
24
|
-
var REPORT_STATUSES = ["TODO", "IN_PROGRESS", "CLOSED"];
|
|
25
|
-
var DETECTION_CONFIDENCE_LEVELS = ["none", "low", "medium", "high"];
|
|
26
|
-
var DETECTION_REPORTED_FILTERS = ["reported", "not_reported"];
|
|
27
|
-
var LIVENESS_FILTER_VALUES = ["ALIVE", "DEAD", "UNKNOWN"];
|
|
28
|
-
var WATCHLIST_FILTER_VALUES = ["ENABLED", "DISABLED"];
|
|
29
|
-
var TAKEDOWN_STATUSES = [
|
|
30
|
-
"TODO",
|
|
31
|
-
"IN_PROGRESS",
|
|
32
|
-
"COMPLETED",
|
|
33
|
-
"CANCELLED",
|
|
34
|
-
"PENDING_RETRACTION",
|
|
35
|
-
"RETRACTION_SENT",
|
|
36
|
-
"RETRACTED",
|
|
37
|
-
"PENDING_INPUT"
|
|
38
|
-
];
|
|
39
|
-
var LIVENESS_STATUSES = ["UNKNOWN", "ALIVE", "DEAD"];
|
|
40
|
-
var TAKEDOWN_SORT_KEYS = [
|
|
41
|
-
"updatedAt",
|
|
42
|
-
"createdAt",
|
|
43
|
-
"takedownStatus",
|
|
44
|
-
"takedownUpdatedAt",
|
|
45
|
-
"assigneeId",
|
|
46
|
-
"brandId"
|
|
47
|
-
];
|
|
48
|
-
var ORGANIZATION_METRICS_INCLUDE_FIELDS = [
|
|
49
|
-
"reports",
|
|
50
|
-
"newThreats",
|
|
51
|
-
"threatsWatchlisted",
|
|
52
|
-
"takedownsFiled",
|
|
53
|
-
"takedownsCompleted",
|
|
54
|
-
"domainThreats",
|
|
55
|
-
"twitterThreats",
|
|
56
|
-
"telegramThreats",
|
|
57
|
-
"otherThreats",
|
|
58
|
-
"blockedByType",
|
|
59
|
-
"blockedByDay"
|
|
60
|
-
];
|
|
61
|
-
var REQUEST_TIMEOUT_MS = 3e4;
|
|
62
|
-
function defaultGetCredential() {
|
|
63
|
-
const envKey = process.env.CHAINPATROL_API_KEY;
|
|
64
|
-
if (envKey && envKey.trim().length > 0) {
|
|
65
|
-
return { kind: "api-key", value: envKey.trim() };
|
|
66
|
-
}
|
|
67
|
-
return { kind: "bearer", value: getValidCredentials().accessToken };
|
|
68
|
-
}
|
|
69
|
-
function createApiClient(options) {
|
|
70
|
-
const config = getConfig();
|
|
71
|
-
const apiUrl = options?.apiUrl ?? config.apiUrl;
|
|
72
|
-
const getCredential = options?.getCredential ?? (options?.getToken ? () => ({ kind: "bearer", value: options.getToken() }) : defaultGetCredential);
|
|
73
|
-
function buildAuthHeaders() {
|
|
74
|
-
const credential = getCredential();
|
|
75
|
-
const headers = {};
|
|
76
|
-
if (credential.kind === "api-key") {
|
|
77
|
-
headers["x-api-key"] = credential.value;
|
|
78
|
-
} else {
|
|
79
|
-
headers["Authorization"] = `Bearer ${credential.value}`;
|
|
80
|
-
}
|
|
81
|
-
return headers;
|
|
82
|
-
}
|
|
83
|
-
async function requestGet(path, query) {
|
|
84
|
-
const headers = buildAuthHeaders();
|
|
85
|
-
const search = new URLSearchParams();
|
|
86
|
-
for (const [key, value] of Object.entries(query)) {
|
|
87
|
-
if (value === void 0) continue;
|
|
88
|
-
if (Array.isArray(value)) {
|
|
89
|
-
for (const item of value) {
|
|
90
|
-
if (item !== void 0 && item !== "") {
|
|
91
|
-
search.append(key, item);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
if (value !== "") {
|
|
97
|
-
search.set(key, value);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
const queryString = search.toString();
|
|
101
|
-
const url = `${apiUrl}/api/v2${path}${queryString ? `?${queryString}` : ""}`;
|
|
102
|
-
let res;
|
|
103
|
-
try {
|
|
104
|
-
res = await fetch(url, {
|
|
105
|
-
method: "GET",
|
|
106
|
-
headers,
|
|
107
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
108
|
-
});
|
|
109
|
-
} catch (err) {
|
|
110
|
-
if (err instanceof DOMException && err.name === "TimeoutError") {
|
|
111
|
-
throw new Error(
|
|
112
|
-
"Request timed out. Check your network connection and try again."
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
if (err instanceof TypeError && err.code === "ECONNREFUSED") {
|
|
116
|
-
throw new Error(`Cannot connect to ${apiUrl}. Is the server running?`);
|
|
117
|
-
}
|
|
118
|
-
throw new Error("Network error. Check your internet connection and try again.");
|
|
119
|
-
}
|
|
120
|
-
return handleResponse(res);
|
|
121
|
-
}
|
|
122
|
-
async function request(path, body) {
|
|
123
|
-
const headers = buildAuthHeaders();
|
|
124
|
-
headers["Content-Type"] = "application/json";
|
|
125
|
-
let res;
|
|
126
|
-
try {
|
|
127
|
-
res = await fetch(`${apiUrl}/api/v2${path}`, {
|
|
128
|
-
method: "POST",
|
|
129
|
-
headers,
|
|
130
|
-
body: JSON.stringify(body),
|
|
131
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
132
|
-
});
|
|
133
|
-
} catch (err) {
|
|
134
|
-
if (err instanceof DOMException && err.name === "TimeoutError") {
|
|
135
|
-
throw new Error(
|
|
136
|
-
"Request timed out. Check your network connection and try again."
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
if (err instanceof TypeError && err.code === "ECONNREFUSED") {
|
|
140
|
-
throw new Error(`Cannot connect to ${apiUrl}. Is the server running?`);
|
|
141
|
-
}
|
|
142
|
-
throw new Error("Network error. Check your internet connection and try again.");
|
|
143
|
-
}
|
|
144
|
-
return handleResponse(res);
|
|
145
|
-
}
|
|
146
|
-
async function handleResponse(res) {
|
|
147
|
-
if (!res.ok) {
|
|
148
|
-
let errorMessageFromResponse = null;
|
|
149
|
-
try {
|
|
150
|
-
const errorBody = await res.json();
|
|
151
|
-
errorMessageFromResponse = errorBody.message ?? null;
|
|
152
|
-
} catch {
|
|
153
|
-
}
|
|
154
|
-
if (res.status === 401) {
|
|
155
|
-
throw new Error(
|
|
156
|
-
errorMessageFromResponse ?? "Authentication failed. Run `chainpatrol login` to re-authenticate."
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
if (res.status === 403) {
|
|
160
|
-
throw new Error(
|
|
161
|
-
errorMessageFromResponse ?? "You don't have permission to access this resource. Check your --org slug and permissions."
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
if (res.status === 404) {
|
|
165
|
-
throw new Error(
|
|
166
|
-
errorMessageFromResponse ?? "Organization not found. Check your --org slug."
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
if (res.status === 422) {
|
|
170
|
-
throw new Error(errorMessageFromResponse ?? "Request validation failed.");
|
|
171
|
-
}
|
|
172
|
-
if (res.status >= 500) {
|
|
173
|
-
throw new Error(
|
|
174
|
-
"ChainPatrol API is temporarily unavailable. Please try again later."
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
throw new Error(
|
|
178
|
-
errorMessageFromResponse ?? `Request failed (${res.status}). Run with --json for details.`
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
return await res.json();
|
|
182
|
-
}
|
|
183
|
-
return {
|
|
184
|
-
assetCheck(input) {
|
|
185
|
-
return request("/asset/check", input);
|
|
186
|
-
},
|
|
187
|
-
assetSearch(input) {
|
|
188
|
-
return request("/asset/search", input);
|
|
189
|
-
},
|
|
190
|
-
listDetectionConfigs(slug) {
|
|
191
|
-
return request("/detection/configs/list", { slug });
|
|
192
|
-
},
|
|
193
|
-
updateDetectionConfig(input) {
|
|
194
|
-
return request("/detection/configs/update", input);
|
|
195
|
-
},
|
|
196
|
-
runDetectionConfigs(input) {
|
|
197
|
-
return request("/detection/configs/run", input);
|
|
198
|
-
},
|
|
199
|
-
validateDetectionConfigs(input) {
|
|
200
|
-
return request("/detection/configs/validate", input);
|
|
201
|
-
},
|
|
202
|
-
getDetectionDrift(input) {
|
|
203
|
-
return request("/detection/drift", {
|
|
204
|
-
...input,
|
|
205
|
-
startDate: parseIsoDate(input.startDate),
|
|
206
|
-
endDate: parseIsoDate(input.endDate)
|
|
207
|
-
});
|
|
208
|
-
},
|
|
209
|
-
getOperationsQueuesSnapshot(input) {
|
|
210
|
-
return request(
|
|
211
|
-
"/operations/queues/snapshot",
|
|
212
|
-
input
|
|
213
|
-
);
|
|
214
|
-
},
|
|
215
|
-
getMetricsSummary(input) {
|
|
216
|
-
return request("/metrics/summary", {
|
|
217
|
-
...input,
|
|
218
|
-
startDate: parseIsoDate(input.startDate),
|
|
219
|
-
endDate: parseIsoDate(input.endDate)
|
|
220
|
-
});
|
|
221
|
-
},
|
|
222
|
-
getMetricsFound(input) {
|
|
223
|
-
return request("/metrics/found", {
|
|
224
|
-
...input,
|
|
225
|
-
startDate: parseIsoDate(input.startDate),
|
|
226
|
-
endDate: parseIsoDate(input.endDate)
|
|
227
|
-
});
|
|
228
|
-
},
|
|
229
|
-
getMetricsBreakdown(input) {
|
|
230
|
-
return request("/metrics/breakdown", {
|
|
231
|
-
...input,
|
|
232
|
-
startDate: parseIsoDate(input.startDate),
|
|
233
|
-
endDate: parseIsoDate(input.endDate)
|
|
234
|
-
});
|
|
235
|
-
},
|
|
236
|
-
createReport(input) {
|
|
237
|
-
return request("/report/create", input);
|
|
238
|
-
},
|
|
239
|
-
listOrganizationReports(input) {
|
|
240
|
-
return request("/public/getOrganizationReports", {
|
|
241
|
-
slug: input.slug,
|
|
242
|
-
limit: input.limit ?? 10,
|
|
243
|
-
cursor: input.cursor,
|
|
244
|
-
status: input.status,
|
|
245
|
-
searchQuery: input.searchQuery,
|
|
246
|
-
reporterQuery: input.reporterQuery,
|
|
247
|
-
reportedByCustomer: input.reportedByCustomer,
|
|
248
|
-
excludeAutomation: input.excludeAutomation,
|
|
249
|
-
onlyRejected: input.onlyRejected,
|
|
250
|
-
reviewStatuses: input.reviewStatuses?.length ? input.reviewStatuses : void 0,
|
|
251
|
-
assetTypes: input.assetTypes?.length ? input.assetTypes : void 0,
|
|
252
|
-
brandIds: input.brandIds?.length ? input.brandIds : void 0,
|
|
253
|
-
countryCodes: input.countryCodes?.length ? input.countryCodes : void 0,
|
|
254
|
-
reviewedByUserId: input.reviewedByUserId,
|
|
255
|
-
startDate: parseIsoDateString(input.startDate),
|
|
256
|
-
endDate: parseIsoDateString(input.endDate),
|
|
257
|
-
updatedAtStartDate: parseIsoDateString(input.updatedAtStartDate),
|
|
258
|
-
updatedAtEndDate: parseIsoDateString(input.updatedAtEndDate)
|
|
259
|
-
});
|
|
260
|
-
},
|
|
261
|
-
listTakedowns(input) {
|
|
262
|
-
return request("/takedowns/list", {
|
|
263
|
-
organizationSlug: input.organizationSlug,
|
|
264
|
-
query: input.query,
|
|
265
|
-
startDate: parseIsoDateString(input.startDate),
|
|
266
|
-
endDate: parseIsoDateString(input.endDate),
|
|
267
|
-
assetType: input.assetType,
|
|
268
|
-
takedownStatus: input.takedownStatus,
|
|
269
|
-
livenessStatus: input.livenessStatus,
|
|
270
|
-
brandIds: input.brandIds?.length ? input.brandIds : void 0,
|
|
271
|
-
assigneeIds: input.assigneeIds?.length ? input.assigneeIds : void 0,
|
|
272
|
-
startedAtStartDate: parseIsoDateString(input.startedAtStartDate),
|
|
273
|
-
startedAtEndDate: parseIsoDateString(input.startedAtEndDate),
|
|
274
|
-
hideAutomatedTakedowns: input.hideAutomatedTakedowns,
|
|
275
|
-
hideAutomatedLivenessChecks: input.hideAutomatedLivenessChecks,
|
|
276
|
-
sorting: input.sorting,
|
|
277
|
-
per_page: input.perPage,
|
|
278
|
-
next_page: input.nextPage
|
|
279
|
-
});
|
|
280
|
-
},
|
|
281
|
-
getOrganizationMetrics(input) {
|
|
282
|
-
return requestGet("/organization/metrics", {
|
|
283
|
-
organizationSlug: input.organizationSlug,
|
|
284
|
-
slugs: input.slugs,
|
|
285
|
-
allMyOrgs: input.allMyOrgs ? "true" : void 0,
|
|
286
|
-
subscriptionStatus: input.subscriptionStatus,
|
|
287
|
-
services: input.services ? JSON.stringify(input.services) : void 0,
|
|
288
|
-
brandSlug: input.brandSlug,
|
|
289
|
-
startDate: parseIsoDateString(input.startDate),
|
|
290
|
-
endDate: parseIsoDateString(input.endDate),
|
|
291
|
-
include: input.include
|
|
292
|
-
});
|
|
293
|
-
},
|
|
294
|
-
listHealthchecks() {
|
|
295
|
-
return request("/healthchecks/list", {});
|
|
296
|
-
},
|
|
297
|
-
runHealthcheck(endpoint, input) {
|
|
298
|
-
return request(endpoint, input);
|
|
299
|
-
},
|
|
300
|
-
getUserOrgs(input) {
|
|
301
|
-
return request("/user/orgs", input);
|
|
302
|
-
},
|
|
303
|
-
getUserOrg(input) {
|
|
304
|
-
return requestGet(
|
|
305
|
-
`/user/orgs/${encodeURIComponent(input.slug)}`,
|
|
306
|
-
{}
|
|
307
|
-
);
|
|
308
|
-
},
|
|
309
|
-
listAssets(input) {
|
|
310
|
-
return request("/asset/list", {
|
|
311
|
-
type: input.type,
|
|
312
|
-
status: input.status,
|
|
313
|
-
startDate: parseIsoDateString(input.startDate),
|
|
314
|
-
endDate: parseIsoDateString(input.endDate),
|
|
315
|
-
per_page: input.perPage,
|
|
316
|
-
next_page: input.nextPage
|
|
317
|
-
});
|
|
318
|
-
},
|
|
319
|
-
listThreats(input) {
|
|
320
|
-
return request("/threats/list", {
|
|
321
|
-
query: input.query,
|
|
322
|
-
startDate: parseIsoDateString(input.startDate),
|
|
323
|
-
endDate: parseIsoDateString(input.endDate),
|
|
324
|
-
assetType: input.assetType,
|
|
325
|
-
sorting: input.sorting,
|
|
326
|
-
per_page: input.perPage,
|
|
327
|
-
next_page: input.nextPage
|
|
328
|
-
});
|
|
329
|
-
},
|
|
330
|
-
listDetections(input) {
|
|
331
|
-
const filters = [];
|
|
332
|
-
if (input.sources?.length) {
|
|
333
|
-
filters.push({ property: "source", operator: "in", value: input.sources });
|
|
334
|
-
}
|
|
335
|
-
if (input.confidence?.length) {
|
|
336
|
-
filters.push({ property: "confidence", operator: "in", value: input.confidence });
|
|
337
|
-
}
|
|
338
|
-
if (input.assetStatus?.length) {
|
|
339
|
-
filters.push({
|
|
340
|
-
property: "assetStatus",
|
|
341
|
-
operator: "in",
|
|
342
|
-
value: input.assetStatus
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
if (input.assetType?.length) {
|
|
346
|
-
filters.push({ property: "assetType", operator: "in", value: input.assetType });
|
|
347
|
-
}
|
|
348
|
-
if (input.brandIds?.length) {
|
|
349
|
-
filters.push({ property: "brand", operator: "in", value: input.brandIds });
|
|
350
|
-
}
|
|
351
|
-
if (input.liveness?.length) {
|
|
352
|
-
filters.push({ property: "liveness", operator: "in", value: input.liveness });
|
|
353
|
-
}
|
|
354
|
-
if (input.watchlist?.length) {
|
|
355
|
-
filters.push({ property: "watchlist", operator: "in", value: input.watchlist });
|
|
356
|
-
}
|
|
357
|
-
if (input.reported?.length) {
|
|
358
|
-
filters.push({ property: "reported", operator: "in", value: input.reported });
|
|
359
|
-
}
|
|
360
|
-
if (input.countryCodes?.length) {
|
|
361
|
-
filters.push({
|
|
362
|
-
property: "countryCode",
|
|
363
|
-
operator: "in",
|
|
364
|
-
value: input.countryCodes
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
if (input.onlyDeleted) {
|
|
368
|
-
filters.push({ property: "deleted", operator: "in", value: ["deleted"] });
|
|
369
|
-
}
|
|
370
|
-
return request("/detection/list", {
|
|
371
|
-
slug: input.slug,
|
|
372
|
-
cursor: input.cursor,
|
|
373
|
-
limit: input.limit,
|
|
374
|
-
query: input.query,
|
|
375
|
-
startDate: parseIsoDate(input.startDate),
|
|
376
|
-
endDate: parseIsoDate(input.endDate),
|
|
377
|
-
filters: filters.length > 0 ? filters : void 0
|
|
378
|
-
});
|
|
379
|
-
},
|
|
380
|
-
searchReports(input) {
|
|
381
|
-
return request("/reports/search", input);
|
|
382
|
-
},
|
|
383
|
-
listOrganizationAssets(input) {
|
|
384
|
-
return requestGet("/organization/assets", {
|
|
385
|
-
type: input.type,
|
|
386
|
-
groupId: input.groupId !== void 0 ? String(input.groupId) : void 0,
|
|
387
|
-
query: input.query,
|
|
388
|
-
per_page: input.perPage !== void 0 ? String(input.perPage) : void 0,
|
|
389
|
-
next_page: input.nextPage
|
|
390
|
-
});
|
|
391
|
-
},
|
|
392
|
-
listOrganizationAssetGroups() {
|
|
393
|
-
return requestGet(
|
|
394
|
-
"/organization/asset-groups",
|
|
395
|
-
{}
|
|
396
|
-
);
|
|
397
|
-
},
|
|
398
|
-
listOrganizationBrands() {
|
|
399
|
-
return requestGet("/organization/brands", {});
|
|
400
|
-
},
|
|
401
|
-
getCurrentUser() {
|
|
402
|
-
return request("/user/me", {});
|
|
403
|
-
},
|
|
404
|
-
validateApiKey() {
|
|
405
|
-
return requestGet("/validate", {});
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
export {
|
|
411
|
-
REPORT_REVIEW_DECISIONS,
|
|
412
|
-
REPORT_STATUSES,
|
|
413
|
-
DETECTION_CONFIDENCE_LEVELS,
|
|
414
|
-
DETECTION_REPORTED_FILTERS,
|
|
415
|
-
LIVENESS_FILTER_VALUES,
|
|
416
|
-
WATCHLIST_FILTER_VALUES,
|
|
417
|
-
TAKEDOWN_STATUSES,
|
|
418
|
-
LIVENESS_STATUSES,
|
|
419
|
-
TAKEDOWN_SORT_KEYS,
|
|
420
|
-
ORGANIZATION_METRICS_INCLUDE_FIELDS,
|
|
421
|
-
createApiClient
|
|
422
|
-
};
|
package/dist/list-ZARZ72DG.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
printOutput,
|
|
3
|
-
toCsvRows
|
|
4
|
-
} from "./chunk-VFT3TD3E.js";
|
|
5
|
-
import {
|
|
6
|
-
createApiClient
|
|
7
|
-
} from "./chunk-GOQL7UCG.js";
|
|
8
|
-
import "./chunk-EGWK6SRQ.js";
|
|
9
|
-
import "./chunk-TFCNKBRC.js";
|
|
10
|
-
import "./chunk-U73SABXK.js";
|
|
11
|
-
|
|
12
|
-
// src/commands/brands/list.ts
|
|
13
|
-
function toRow(brand) {
|
|
14
|
-
return {
|
|
15
|
-
id: brand.id,
|
|
16
|
-
slug: brand.slug,
|
|
17
|
-
name: brand.name,
|
|
18
|
-
type: brand.type,
|
|
19
|
-
description: brand.description ?? "",
|
|
20
|
-
brandGroupId: brand.brandGroupId,
|
|
21
|
-
createdAt: brand.createdAt
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
async function runBrandsList(options) {
|
|
25
|
-
const outputFormat = options.outputFormat ?? (options.json ? "json" : "human");
|
|
26
|
-
const client = options.apiClient ?? createApiClient();
|
|
27
|
-
const result = await client.listOrganizationBrands();
|
|
28
|
-
const brands = options.type ? result.brands.filter((brand) => brand.type === options.type) : result.brands;
|
|
29
|
-
const rows = brands.map(toRow);
|
|
30
|
-
printOutput({
|
|
31
|
-
outputFormat,
|
|
32
|
-
json: options.type ? { ...result, brands } : result,
|
|
33
|
-
markdown: [
|
|
34
|
-
"# Organization brands",
|
|
35
|
-
"",
|
|
36
|
-
`- Returned: ${brands.length}${options.type ? ` (filtered to type=${options.type})` : ""}`,
|
|
37
|
-
"",
|
|
38
|
-
...rows.map(
|
|
39
|
-
(row) => `- #${row.id} ${row.name} (slug=${row.slug}, type=${row.type}${row.brandGroupId !== null ? `, groupId=${row.brandGroupId}` : ""})`
|
|
40
|
-
)
|
|
41
|
-
].join("\n"),
|
|
42
|
-
csv: toCsvRows(rows),
|
|
43
|
-
human: () => {
|
|
44
|
-
if (brands.length === 0) {
|
|
45
|
-
console.log(
|
|
46
|
-
options.type ? `No brands of type ${options.type} found.` : "No brands found."
|
|
47
|
-
);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
console.log(
|
|
51
|
-
`Organization brands \u2014 returned ${brands.length}${options.type ? ` (type=${options.type})` : ""}`
|
|
52
|
-
);
|
|
53
|
-
for (const row of rows) {
|
|
54
|
-
const group = row.brandGroupId !== null ? ` groupId=${row.brandGroupId}` : "";
|
|
55
|
-
console.log(
|
|
56
|
-
`#${row.id} ${row.name} (slug=${row.slug}, type=${row.type}${group})`
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
export {
|
|
63
|
-
runBrandsList
|
|
64
|
-
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DateTime
|
|
3
|
+
} from "./chunk-TFCNKBRC.js";
|
|
1
4
|
import {
|
|
2
5
|
fetchUserEmail,
|
|
3
6
|
getCredentials,
|
|
@@ -7,9 +10,6 @@ import {
|
|
|
7
10
|
requestDeviceCode,
|
|
8
11
|
storeCredentials
|
|
9
12
|
} from "./chunk-EGWK6SRQ.js";
|
|
10
|
-
import {
|
|
11
|
-
DateTime
|
|
12
|
-
} from "./chunk-TFCNKBRC.js";
|
|
13
13
|
|
|
14
14
|
// src/lib/login-flow.ts
|
|
15
15
|
async function runLoginFlow(emit) {
|