equalweb-sdk 1.0.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/README.md +227 -0
- package/dist/index.d.mts +381 -0
- package/dist/index.d.ts +381 -0
- package/dist/index.js +568 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +532 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +52 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
interface EqualWebConfig {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
timeout?: number;
|
|
5
|
+
}
|
|
6
|
+
type DocumentStatus = "done" | "pending" | "processing" | string;
|
|
7
|
+
type AuditType = "audit" | "check";
|
|
8
|
+
type ReportType = "audited" | "original" | "both";
|
|
9
|
+
type DownloadFileType = "pdf" | "xlsx";
|
|
10
|
+
interface BalanceResponse {
|
|
11
|
+
results: number;
|
|
12
|
+
}
|
|
13
|
+
interface Document {
|
|
14
|
+
numberOfPages: number;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
group: number | null;
|
|
17
|
+
archived: boolean;
|
|
18
|
+
reportID: string;
|
|
19
|
+
status: DocumentStatus;
|
|
20
|
+
}
|
|
21
|
+
interface GetDocumentsParams {
|
|
22
|
+
groupID?: string;
|
|
23
|
+
archived?: boolean;
|
|
24
|
+
type?: string;
|
|
25
|
+
}
|
|
26
|
+
interface DocumentStatusResponse {
|
|
27
|
+
status: DocumentStatus;
|
|
28
|
+
}
|
|
29
|
+
interface UploadResponse {
|
|
30
|
+
id: string;
|
|
31
|
+
createdAt: string;
|
|
32
|
+
numberOfPages: number;
|
|
33
|
+
}
|
|
34
|
+
interface DeleteDocumentsParams {
|
|
35
|
+
files: string[];
|
|
36
|
+
}
|
|
37
|
+
interface DeleteDocumentsResponse {
|
|
38
|
+
results: Record<string, boolean | {
|
|
39
|
+
error: string;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
interface ArchiveDocumentsParams {
|
|
43
|
+
files: string[];
|
|
44
|
+
archive?: boolean;
|
|
45
|
+
}
|
|
46
|
+
interface ArchiveDocumentsResponse {
|
|
47
|
+
results: "ok";
|
|
48
|
+
}
|
|
49
|
+
interface DocumentGroup {
|
|
50
|
+
id: number;
|
|
51
|
+
name: string;
|
|
52
|
+
createdAt: string;
|
|
53
|
+
}
|
|
54
|
+
interface GroupDocumentsParams {
|
|
55
|
+
files: string[];
|
|
56
|
+
newGroup?: string;
|
|
57
|
+
selectedGroup?: string;
|
|
58
|
+
}
|
|
59
|
+
interface GroupDocumentsResponse {
|
|
60
|
+
results: "ok";
|
|
61
|
+
}
|
|
62
|
+
interface RenameGroupParams {
|
|
63
|
+
groupID: string;
|
|
64
|
+
groupName: string;
|
|
65
|
+
}
|
|
66
|
+
interface RenameGroupResponse {
|
|
67
|
+
results: "ok";
|
|
68
|
+
}
|
|
69
|
+
interface AuditDocumentsParams {
|
|
70
|
+
files: string[];
|
|
71
|
+
type?: AuditType;
|
|
72
|
+
}
|
|
73
|
+
interface AuditDocumentsResponse {
|
|
74
|
+
results: "ok";
|
|
75
|
+
}
|
|
76
|
+
interface ReportRule {
|
|
77
|
+
Rule: string;
|
|
78
|
+
Status: "Passed" | "Failed" | "Needs manual check" | string;
|
|
79
|
+
Description: string;
|
|
80
|
+
}
|
|
81
|
+
interface ReportSummary {
|
|
82
|
+
"Passed"?: number;
|
|
83
|
+
"Failed"?: number;
|
|
84
|
+
"Needs manual check"?: number;
|
|
85
|
+
Description?: string;
|
|
86
|
+
}
|
|
87
|
+
interface DetailedReport {
|
|
88
|
+
Document?: ReportRule[];
|
|
89
|
+
"Page Content"?: ReportRule[];
|
|
90
|
+
Forms?: ReportRule[];
|
|
91
|
+
"Alternate Text"?: ReportRule[];
|
|
92
|
+
Tables?: ReportRule[];
|
|
93
|
+
Lists?: ReportRule[];
|
|
94
|
+
Headings?: ReportRule[];
|
|
95
|
+
}
|
|
96
|
+
interface ReportCustomData {
|
|
97
|
+
fileName?: string;
|
|
98
|
+
fileSize?: number;
|
|
99
|
+
numberOfPages?: number;
|
|
100
|
+
tags?: Record<string, number>;
|
|
101
|
+
[key: string]: unknown;
|
|
102
|
+
}
|
|
103
|
+
interface AuditedReport {
|
|
104
|
+
Summary?: ReportSummary;
|
|
105
|
+
"Detailed Report"?: DetailedReport;
|
|
106
|
+
customData?: ReportCustomData;
|
|
107
|
+
}
|
|
108
|
+
interface OriginalReport {
|
|
109
|
+
Summary?: ReportSummary;
|
|
110
|
+
"Detailed Report"?: DetailedReport;
|
|
111
|
+
customData?: ReportCustomData;
|
|
112
|
+
}
|
|
113
|
+
interface GetReportParams {
|
|
114
|
+
type?: ReportType;
|
|
115
|
+
}
|
|
116
|
+
interface ReportResponse {
|
|
117
|
+
original?: OriginalReport;
|
|
118
|
+
audited?: AuditedReport;
|
|
119
|
+
}
|
|
120
|
+
interface DownloadFileParams {
|
|
121
|
+
original?: boolean;
|
|
122
|
+
type?: DownloadFileType;
|
|
123
|
+
}
|
|
124
|
+
interface DownloadZippedParams {
|
|
125
|
+
files: string[];
|
|
126
|
+
}
|
|
127
|
+
interface EqualWebErrorResponse {
|
|
128
|
+
error?: string;
|
|
129
|
+
message?: string;
|
|
130
|
+
statusCode?: number;
|
|
131
|
+
}
|
|
132
|
+
declare class EqualWebError extends Error {
|
|
133
|
+
readonly statusCode: number;
|
|
134
|
+
readonly response?: EqualWebErrorResponse;
|
|
135
|
+
constructor(message: string, statusCode: number, response?: EqualWebErrorResponse);
|
|
136
|
+
}
|
|
137
|
+
declare class RateLimitError extends EqualWebError {
|
|
138
|
+
readonly retryAfter?: number;
|
|
139
|
+
constructor(message: string, retryAfter?: number);
|
|
140
|
+
}
|
|
141
|
+
declare class AuthenticationError extends EqualWebError {
|
|
142
|
+
constructor(message?: string);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
interface RequestOptions {
|
|
146
|
+
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
147
|
+
path: string;
|
|
148
|
+
query?: Record<string, string | boolean | undefined>;
|
|
149
|
+
body?: unknown;
|
|
150
|
+
isFormData?: boolean;
|
|
151
|
+
responseType?: "json" | "blob";
|
|
152
|
+
}
|
|
153
|
+
declare class HttpClient {
|
|
154
|
+
private readonly apiKey;
|
|
155
|
+
private readonly baseUrl;
|
|
156
|
+
private readonly timeout;
|
|
157
|
+
constructor(config: EqualWebConfig);
|
|
158
|
+
request<T>(options: RequestOptions): Promise<T>;
|
|
159
|
+
private handleErrorResponse;
|
|
160
|
+
get<T>(path: string, query?: Record<string, string | boolean | undefined>): Promise<T>;
|
|
161
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
162
|
+
put<T>(path: string, body?: unknown, isFormData?: boolean): Promise<T>;
|
|
163
|
+
delete<T>(path: string, body?: unknown): Promise<T>;
|
|
164
|
+
getBlob(path: string, query?: Record<string, string | boolean | undefined>): Promise<Blob>;
|
|
165
|
+
postBlob(path: string, body?: unknown): Promise<Blob>;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
declare class InfoApi {
|
|
169
|
+
private readonly client;
|
|
170
|
+
constructor(client: HttpClient);
|
|
171
|
+
/**
|
|
172
|
+
* Get the current credit balance for your account
|
|
173
|
+
* @returns The current credit balance
|
|
174
|
+
*/
|
|
175
|
+
getBalance(): Promise<number>;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
declare class DocumentsApi {
|
|
179
|
+
private readonly client;
|
|
180
|
+
constructor(client: HttpClient);
|
|
181
|
+
/**
|
|
182
|
+
* Get all documents
|
|
183
|
+
* @param params - Optional filters for groupID, archived status, and document type
|
|
184
|
+
* @returns Array of documents
|
|
185
|
+
*/
|
|
186
|
+
getAll(params?: GetDocumentsParams): Promise<Document[]>;
|
|
187
|
+
/**
|
|
188
|
+
* Get the status of a specific document
|
|
189
|
+
* @param reportID - The report ID of the document
|
|
190
|
+
* @returns The document status
|
|
191
|
+
*/
|
|
192
|
+
getStatus(reportID: string): Promise<string>;
|
|
193
|
+
/**
|
|
194
|
+
* Upload a document for processing
|
|
195
|
+
* Supported formats: PDF, XLSX, DOCX, PPTX
|
|
196
|
+
* @param file - The file to upload (File, Blob, ArrayBuffer, or Uint8Array)
|
|
197
|
+
* @param filename - Optional filename (required if file is an ArrayBuffer or Uint8Array)
|
|
198
|
+
* @returns Upload response with document ID and metadata
|
|
199
|
+
*/
|
|
200
|
+
upload(file: File | Blob | ArrayBuffer | Uint8Array, filename?: string): Promise<UploadResponse>;
|
|
201
|
+
/**
|
|
202
|
+
* Delete multiple documents
|
|
203
|
+
* @param files - Array of document IDs to delete
|
|
204
|
+
* @returns Results indicating success/failure for each document
|
|
205
|
+
*/
|
|
206
|
+
delete(files: string[]): Promise<DeleteDocumentsResponse>;
|
|
207
|
+
/**
|
|
208
|
+
* Archive documents
|
|
209
|
+
* @param files - Array of document IDs to archive
|
|
210
|
+
* @returns Result of the operation
|
|
211
|
+
*/
|
|
212
|
+
archive(files: string[]): Promise<ArchiveDocumentsResponse>;
|
|
213
|
+
/**
|
|
214
|
+
* Restore archived documents
|
|
215
|
+
* @param files - Array of document IDs to restore
|
|
216
|
+
* @returns Result of the operation
|
|
217
|
+
*/
|
|
218
|
+
restore(files: string[]): Promise<ArchiveDocumentsResponse>;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
declare class GroupsApi {
|
|
222
|
+
private readonly client;
|
|
223
|
+
constructor(client: HttpClient);
|
|
224
|
+
/**
|
|
225
|
+
* Get all document groups
|
|
226
|
+
* @returns Array of document groups
|
|
227
|
+
*/
|
|
228
|
+
getAll(): Promise<DocumentGroup[]>;
|
|
229
|
+
/**
|
|
230
|
+
* Add documents to a new group
|
|
231
|
+
* @param files - Array of document IDs to group
|
|
232
|
+
* @param groupName - Name of the new group to create
|
|
233
|
+
* @returns Result of the operation
|
|
234
|
+
*/
|
|
235
|
+
createGroup(files: string[], groupName: string): Promise<GroupDocumentsResponse>;
|
|
236
|
+
/**
|
|
237
|
+
* Add documents to an existing group
|
|
238
|
+
* @param files - Array of document IDs to group
|
|
239
|
+
* @param groupID - ID of the existing group
|
|
240
|
+
* @returns Result of the operation
|
|
241
|
+
*/
|
|
242
|
+
addToGroup(files: string[], groupID: string): Promise<GroupDocumentsResponse>;
|
|
243
|
+
/**
|
|
244
|
+
* Rename a document group
|
|
245
|
+
* @param groupID - ID of the group to rename
|
|
246
|
+
* @param groupName - New name for the group
|
|
247
|
+
* @returns Result of the operation
|
|
248
|
+
*/
|
|
249
|
+
rename(groupID: string, groupName: string): Promise<RenameGroupResponse>;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
declare class AuditApi {
|
|
253
|
+
private readonly client;
|
|
254
|
+
constructor(client: HttpClient);
|
|
255
|
+
/**
|
|
256
|
+
* Start a full audit on documents
|
|
257
|
+
* This performs accessibility remediation and generates detailed reports
|
|
258
|
+
* @param files - Array of document IDs to audit
|
|
259
|
+
* @returns Result of the operation (202 Accepted - processing is async)
|
|
260
|
+
*/
|
|
261
|
+
audit(files: string[]): Promise<AuditDocumentsResponse>;
|
|
262
|
+
/**
|
|
263
|
+
* Perform a quick check on documents without full remediation
|
|
264
|
+
* @param files - Array of document IDs to check
|
|
265
|
+
* @returns Result of the operation (202 Accepted - processing is async)
|
|
266
|
+
*/
|
|
267
|
+
check(files: string[]): Promise<AuditDocumentsResponse>;
|
|
268
|
+
/**
|
|
269
|
+
* Start an audit with custom type
|
|
270
|
+
* @param files - Array of document IDs to process
|
|
271
|
+
* @param type - Type of audit: "audit" for full audit, "check" for quick check
|
|
272
|
+
* @returns Result of the operation (202 Accepted - processing is async)
|
|
273
|
+
*/
|
|
274
|
+
process(files: string[], type: AuditType): Promise<AuditDocumentsResponse>;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
declare class ReportsApi {
|
|
278
|
+
private readonly client;
|
|
279
|
+
constructor(client: HttpClient);
|
|
280
|
+
/**
|
|
281
|
+
* Get the JSON report for a document
|
|
282
|
+
* @param reportID - The report ID
|
|
283
|
+
* @param type - Which report to retrieve: "audited", "original", or "both"
|
|
284
|
+
* @returns The report data
|
|
285
|
+
*/
|
|
286
|
+
get(reportID: string, type?: ReportType): Promise<ReportResponse>;
|
|
287
|
+
/**
|
|
288
|
+
* Get the audited report for a document
|
|
289
|
+
* @param reportID - The report ID
|
|
290
|
+
* @returns The audited report data
|
|
291
|
+
*/
|
|
292
|
+
getAudited(reportID: string): Promise<ReportResponse>;
|
|
293
|
+
/**
|
|
294
|
+
* Get the original report for a document
|
|
295
|
+
* @param reportID - The report ID
|
|
296
|
+
* @returns The original report data
|
|
297
|
+
*/
|
|
298
|
+
getOriginal(reportID: string): Promise<ReportResponse>;
|
|
299
|
+
/**
|
|
300
|
+
* Get both audited and original reports for a document
|
|
301
|
+
* @param reportID - The report ID
|
|
302
|
+
* @returns Both report data
|
|
303
|
+
*/
|
|
304
|
+
getBoth(reportID: string): Promise<ReportResponse>;
|
|
305
|
+
/**
|
|
306
|
+
* Get the URL to view the report in a browser
|
|
307
|
+
* Note: This URL does not require authentication
|
|
308
|
+
* @param reportID - The report ID
|
|
309
|
+
* @returns The browser-viewable URL
|
|
310
|
+
*/
|
|
311
|
+
getBrowserUrl(reportID: string): string;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
declare class DownloadsApi {
|
|
315
|
+
private readonly client;
|
|
316
|
+
constructor(client: HttpClient);
|
|
317
|
+
/**
|
|
318
|
+
* Download a single document file
|
|
319
|
+
* @param reportID - The report ID of the document
|
|
320
|
+
* @param options - Download options (original file, file type)
|
|
321
|
+
* @returns The file as a Blob
|
|
322
|
+
*/
|
|
323
|
+
file(reportID: string, options?: DownloadFileParams): Promise<Blob>;
|
|
324
|
+
/**
|
|
325
|
+
* Download the audited/processed version of a document
|
|
326
|
+
* @param reportID - The report ID of the document
|
|
327
|
+
* @param type - File type to download (pdf or xlsx)
|
|
328
|
+
* @returns The processed file as a Blob
|
|
329
|
+
*/
|
|
330
|
+
audited(reportID: string, type?: DownloadFileType): Promise<Blob>;
|
|
331
|
+
/**
|
|
332
|
+
* Download the original version of a document
|
|
333
|
+
* @param reportID - The report ID of the document
|
|
334
|
+
* @param type - File type to download (pdf or xlsx)
|
|
335
|
+
* @returns The original file as a Blob
|
|
336
|
+
*/
|
|
337
|
+
original(reportID: string, type?: DownloadFileType): Promise<Blob>;
|
|
338
|
+
/**
|
|
339
|
+
* Download multiple documents as a ZIP file
|
|
340
|
+
* @param files - Array of document IDs to include in the ZIP
|
|
341
|
+
* @returns The ZIP file as a Blob
|
|
342
|
+
*/
|
|
343
|
+
zipped(files: string[]): Promise<Blob>;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
declare class EqualWeb {
|
|
347
|
+
private readonly client;
|
|
348
|
+
readonly info: InfoApi;
|
|
349
|
+
readonly documents: DocumentsApi;
|
|
350
|
+
readonly groups: GroupsApi;
|
|
351
|
+
readonly audit: AuditApi;
|
|
352
|
+
readonly reports: ReportsApi;
|
|
353
|
+
readonly downloads: DownloadsApi;
|
|
354
|
+
/**
|
|
355
|
+
* Create a new EqualWeb API client
|
|
356
|
+
* @param config - Configuration object with API key and optional settings
|
|
357
|
+
* @example
|
|
358
|
+
* ```typescript
|
|
359
|
+
* const client = new EqualWeb({ apiKey: 'your-api-key' });
|
|
360
|
+
*
|
|
361
|
+
* // Get credit balance
|
|
362
|
+
* const balance = await client.info.getBalance();
|
|
363
|
+
*
|
|
364
|
+
* // Upload a document
|
|
365
|
+
* const file = new File([...], 'document.pdf');
|
|
366
|
+
* const upload = await client.documents.upload(file);
|
|
367
|
+
*
|
|
368
|
+
* // Start an audit
|
|
369
|
+
* await client.audit.audit([upload.id]);
|
|
370
|
+
*
|
|
371
|
+
* // Check status
|
|
372
|
+
* const status = await client.documents.getStatus(upload.id);
|
|
373
|
+
*
|
|
374
|
+
* // Download the audited file
|
|
375
|
+
* const blob = await client.downloads.audited(upload.id);
|
|
376
|
+
* ```
|
|
377
|
+
*/
|
|
378
|
+
constructor(config: EqualWebConfig);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export { type ArchiveDocumentsParams, type ArchiveDocumentsResponse, AuditApi, type AuditDocumentsParams, type AuditDocumentsResponse, type AuditType, type AuditedReport, AuthenticationError, type BalanceResponse, type DeleteDocumentsParams, type DeleteDocumentsResponse, type DetailedReport, type Document, type DocumentGroup, type DocumentStatus, type DocumentStatusResponse, DocumentsApi, type DownloadFileParams, type DownloadFileType, type DownloadZippedParams, DownloadsApi, EqualWeb, type EqualWebConfig, EqualWebError, type EqualWebErrorResponse, type GetDocumentsParams, type GetReportParams, type GroupDocumentsParams, type GroupDocumentsResponse, GroupsApi, InfoApi, type OriginalReport, RateLimitError, type RenameGroupParams, type RenameGroupResponse, type ReportCustomData, type ReportResponse, type ReportRule, type ReportSummary, type ReportType, ReportsApi, type UploadResponse };
|