@docbox-nz/hapi-gateway 0.2.0 → 0.3.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.
Files changed (48) hide show
  1. package/.github/workflows/build.yml +30 -0
  2. package/.github/workflows/release.yml +37 -0
  3. package/.oxfmtrc.json +8 -0
  4. package/.oxlintrc.json +11 -0
  5. package/.zed/settings.json +10 -0
  6. package/README.md +32 -38
  7. package/cspell.json +1 -4
  8. package/dist/index.node.cjs +15031 -21882
  9. package/dist/index.node.cjs.map +1 -1
  10. package/dist/index.node.esm.js +15024 -21880
  11. package/dist/index.node.esm.js.map +1 -1
  12. package/package.json +44 -55
  13. package/rolldown.config.js +19 -0
  14. package/src/index.ts +257 -257
  15. package/tsconfig.json +15 -15
  16. package/.eslintignore +0 -6
  17. package/.eslintrc +0 -131
  18. package/.prettierignore +0 -11
  19. package/.prettierrc +0 -6
  20. package/dist/api/adminService.d.ts +0 -16
  21. package/dist/api/boxService.d.ts +0 -43
  22. package/dist/api/client.d.ts +0 -45
  23. package/dist/api/docboxFile.d.ts +0 -15
  24. package/dist/api/fileService.d.ts +0 -251
  25. package/dist/api/folderService.d.ts +0 -45
  26. package/dist/api/linkService.d.ts +0 -115
  27. package/dist/api/taskService.d.ts +0 -23
  28. package/dist/api/utils.d.ts +0 -1
  29. package/dist/error.d.ts +0 -11
  30. package/dist/index.browser.cjs +0 -988
  31. package/dist/index.browser.cjs.map +0 -1
  32. package/dist/index.browser.esm.js +0 -984
  33. package/dist/index.browser.esm.js.map +0 -1
  34. package/dist/index.browser.js +0 -4390
  35. package/dist/index.browser.js.map +0 -1
  36. package/dist/index.d.ts +0 -4
  37. package/dist/index.node.js +0 -20809
  38. package/dist/index.node.js.map +0 -1
  39. package/dist/options.d.ts +0 -85
  40. package/dist/types/box.d.ts +0 -59
  41. package/dist/types/file.d.ts +0 -371
  42. package/dist/types/folder.d.ts +0 -153
  43. package/dist/types/index.d.ts +0 -22
  44. package/dist/types/link.d.ts +0 -136
  45. package/dist/types/search.d.ts +0 -177
  46. package/dist/types/shared.d.ts +0 -94
  47. package/dist/types/user.d.ts +0 -20
  48. package/rollup.config.js +0 -36
package/dist/options.d.ts DELETED
@@ -1,85 +0,0 @@
1
- import type { Request, RouteOptions } from '@hapi/hapi';
2
- import type { CreateAxiosDefaults } from 'axios';
3
- export interface DocboxRequestUser {
4
- /** Internal unique user ID for the user (Specific to your app) */
5
- id?: string;
6
- /** Username of the user */
7
- name?: string;
8
- /** Some internal field used to identify the profile image of the user */
9
- imageId?: string;
10
- }
11
- export interface DocboxRequestTenant {
12
- /** ID of the tenant */
13
- id: string;
14
- /** Environment the tenant is within */
15
- env: string;
16
- }
17
- export interface PluginOptions {
18
- /**
19
- * Base URL of the docbox server
20
- */
21
- docboxBaseURL: string;
22
- /**
23
- * Base path to serve docbox endpoints from. Must begin
24
- * with a slash
25
- *
26
- * Docbox endpoints will be added in a nested /box path
27
- *
28
- * @default /
29
- */
30
- basePath?: string;
31
- /**
32
- * Base set of route options applied to any routes created
33
- * by docbox
34
- */
35
- baseRouteOptions?: RouteOptions;
36
- /**
37
- * Base set of route options applied only to forwarding
38
- * routes created by docbox
39
- */
40
- baseForwardRouteOptions?: RouteOptions;
41
- /**
42
- * Additional configuration options for axios
43
- */
44
- axiosConfig?: CreateAxiosDefaults;
45
- /**
46
- * Get a API key for making requests to docbox
47
- *
48
- * @returns The key or a promise to the key
49
- */
50
- getApiKey?: () => (string | null) | Promise<string | null>;
51
- /**
52
- * Write access check, will be invoked to check whether the request
53
- * has authorization to perform a write action against docbox
54
- *
55
- * @param request The HTTP request
56
- * @param scope The requested docbox scope
57
- * @param path The requested path
58
- * @returns Whether the user is allowed to write
59
- */
60
- isAllowedWrite(request: Request, scope: string, path: string): Promise<boolean> | boolean;
61
- /**
62
- * Read access check, will be invoked to check whether the request
63
- * has authorization to perform a read action against docbox
64
- *
65
- * @param request The HTTP request
66
- * @param scope The requested docbox scope
67
- * @param path The requested path
68
- * @returns Whether the user is allowed to write
69
- */
70
- isAllowedRead(request: Request, scope: string, path: string): Promise<boolean> | boolean;
71
- /**
72
- * Extract the user details from the provided request
73
- *
74
- * @param request The HTTP request
75
- * @returns The user details if they were obtainable
76
- */
77
- getRequestUser?: (request: Request) => Promise<DocboxRequestUser | null> | (DocboxRequestUser | null);
78
- /**
79
- * Gets the docbox tenant from the request
80
- *
81
- * @param request The HTTP request
82
- * @returns The current tenant
83
- */
84
- getRequestTenant(request: Request): Promise<DocboxRequestTenant> | DocboxRequestTenant;
85
- }
@@ -1,59 +0,0 @@
1
- import { DocFolder, ResolvedFolder } from './folder';
2
- import { DocumentBoxScope, ISODate } from './shared';
3
- export interface CreateDocumentBox {
4
- /**
5
- * Scope of the document box to create
6
- */
7
- scope: DocumentBoxScope;
8
- }
9
- export interface CreatedDocumentBox {
10
- /**
11
- * The created document box
12
- */
13
- document_box: DocumentBox;
14
- /**
15
- * The root folder of the document box
16
- */
17
- root: DocFolder;
18
- }
19
- export interface DocumentBoxResponse {
20
- /**
21
- * The document box itself
22
- */
23
- document_box: DocumentBox;
24
- /**
25
- * The root folder of the document box
26
- */
27
- root: DocFolder;
28
- /**
29
- * Resolved children of the document box
30
- */
31
- children: ResolvedFolder;
32
- }
33
- /**
34
- * Stats for a document box
35
- */
36
- export interface DocumentBoxStats {
37
- /**
38
- * Total number of files within the document box
39
- */
40
- total_files: number;
41
- /**
42
- * Total number of links within the document box
43
- */
44
- total_links: number;
45
- /**
46
- * Total number of folders within the document box
47
- */
48
- total_folders: number;
49
- }
50
- export interface DocumentBox {
51
- /**
52
- * Scope of the document box
53
- */
54
- scope: DocumentBoxScope;
55
- /**
56
- * Timestamp the document box was created at
57
- */
58
- created_at: ISODate;
59
- }
@@ -1,371 +0,0 @@
1
- import { DocumentBoxScope, EditHistoryMetadataMoveToFolder, EditHistoryMetadataRename, EditHistoryType, FileId, FolderId, GeneratedFileId, ISODate } from './shared';
2
- import { User } from './user';
3
- /**
4
- * Request to create a new presigned file upload
5
- */
6
- export interface PresignedUploadFileRequest {
7
- /**
8
- * Name of the file that will be uploaded
9
- */
10
- name: string;
11
- /**
12
- * ID of the folder to store the uploaded
13
- * file within
14
- */
15
- folder_id: FolderId;
16
- /**
17
- * Size of the file that will be uploaded
18
- *
19
- * This must match the size of the file you
20
- * upload otherwise your request will fail
21
- */
22
- size: number;
23
- /**
24
- * Mime type of the file that will be uploaded
25
- */
26
- mime: string;
27
- /**
28
- * Optional: ID of the parent file to use for the
29
- * file after its been uploaded
30
- */
31
- parent_id?: FileId | null;
32
- /**
33
- * Additional configuration specifying how the file should
34
- * be processed
35
- */
36
- processing_config?: ProcessingConfig | null;
37
- }
38
- /**
39
- * Response for a presigned upload request
40
- */
41
- export interface PresignedUploadResponse {
42
- /**
43
- * ID of the presigned upload task
44
- */
45
- task_id: string;
46
- /**
47
- * HTTP request method to send the upload as
48
- */
49
- method: string;
50
- /**
51
- * URL to send the file upload to
52
- */
53
- uri: string;
54
- /**
55
- * Headers to attach to the presigned upload
56
- */
57
- headers: Record<string, string>;
58
- }
59
- /**
60
- * Additional options that can be specified on a presigned file upload
61
- * request for things like aborting or progress
62
- */
63
- export type PresignedUploadOptions = {
64
- /**
65
- * Abort controller to abort an upload in progress
66
- */
67
- abort?: AbortController;
68
- /**
69
- * Optional: ID of the parent file to use for the
70
- * file after its been uploaded
71
- */
72
- parent_id?: FileId | null;
73
- /**
74
- * Additional configuration specifying how the file should
75
- * be processed
76
- */
77
- processing_config?: ProcessingConfig | null;
78
- /**
79
- * Callback to update the current progress
80
- *
81
- * @param name The name of the current progress state
82
- * @param progress Percent complete if the progress is not indeterminate
83
- */
84
- onProgress?: (name: string, progress?: number) => void;
85
- };
86
- /**
87
- * Types of generated files
88
- */
89
- export declare enum GeneratedFileType {
90
- PDF = "Pdf",
91
- COVER_PAGE = "CoverPage",
92
- SMALL_THUMBNAIL = "SmallThumbnail",
93
- LARGE_THUMBNAIL = "LargeThumbnail",
94
- TEXT_CONTENT = "TextContent",
95
- HTML_CONTENT = "HtmlContent",
96
- METADATA = "Metadata"
97
- }
98
- export interface DocGeneratedFile {
99
- /**
100
- * Unique ID of the generated file
101
- */
102
- id: GeneratedFileId;
103
- /**
104
- * ID of the file this generated file
105
- * belongs to
106
- */
107
- file_id: FileId;
108
- /**
109
- * Mime/Content-Type of the generated file
110
- */
111
- mime: string;
112
- /**
113
- * Type of the generated file
114
- */
115
- type: GeneratedFileType;
116
- /**
117
- * SHA256 hash of the generated file contents
118
- */
119
- hash: string;
120
- /**
121
- * Timestamp the generated file was created at
122
- */
123
- created_at: ISODate;
124
- }
125
- export interface FileResponse {
126
- /**
127
- * The file itself
128
- */
129
- file: DocFile;
130
- /**
131
- * Files generated from processing the file
132
- */
133
- generated: DocGeneratedFile[];
134
- }
135
- export type UploadFileResponse = {
136
- /**
137
- * The file itself
138
- */
139
- file: DocFile;
140
- /**
141
- * Files generated from processing the file
142
- */
143
- generated: DocGeneratedFile[];
144
- /**
145
- * Additional files that were created from processing the
146
- * uploaded file
147
- *
148
- * When email attachment processing is enabled this will
149
- * contain the responses for the extracted attachments
150
- */
151
- additional_files: UploadFileResponse[];
152
- };
153
- /**
154
- * Statuses that a presigned upload task can have
155
- */
156
- export declare enum PresignedUploadStatus {
157
- Pending = "Pending",
158
- Complete = "Complete",
159
- Failed = "Failed"
160
- }
161
- export type PresignedStatusResponse = {
162
- status: PresignedUploadStatus.Pending;
163
- } | ({
164
- status: PresignedUploadStatus.Complete;
165
- } & FileResponse) | {
166
- status: PresignedUploadStatus.Failed;
167
- error: string;
168
- };
169
- export type UploadOptions = {
170
- /**
171
- * Used for legacy API compatibility, specify a fixed file ID
172
- */
173
- fixed_id?: FileId;
174
- /**
175
- * Abort controller to abort an upload in progress
176
- */
177
- abort?: AbortController;
178
- /**
179
- * Callback to update the current progress
180
- *
181
- * @param name The name of the current progress state
182
- * @param progress Percent complete if the progress is not indeterminate
183
- */
184
- onProgress?: (name: string, progress?: number) => void;
185
- };
186
- /**
187
- * File within docbox
188
- */
189
- export interface DocFile {
190
- /**
191
- * Unique ID of the file
192
- */
193
- id: FileId;
194
- /**
195
- * Name of the file
196
- */
197
- name: string;
198
- /**
199
- * Mime/Content-Type of the file i.e application/json
200
- */
201
- mime: string;
202
- /**
203
- * ID of the folder this file is stored within.
204
- */
205
- folder_id: FolderId;
206
- /**
207
- * SHA256 hash of the file contents
208
- */
209
- hash: string;
210
- /**
211
- * Size of the file contents in bytes
212
- */
213
- size: number;
214
- /**
215
- * Whether the file has been detected as encrypted when it
216
- * was processed
217
- */
218
- encrypted: boolean;
219
- /**
220
- * Timestamp of when the file was created
221
- */
222
- created_at: ISODate;
223
- /**
224
- * User who created the file if the user was known
225
- * at the point of creation
226
- */
227
- created_by: User | null;
228
- /**
229
- * Timestamp of when the file was last modified
230
- */
231
- last_modified_at: ISODate | null;
232
- /**
233
- * User who last modified the file if the user was
234
- * known at the point of modification
235
- *
236
- * NOTE: This is the user for the most recent modification, not the
237
- * most recent modification with a user
238
- */
239
- last_modified_by: User | null;
240
- /**
241
- * ID of the parent file, if the file belongs to some other file
242
- * (i.e attachment for an email file)
243
- */
244
- parent_id: FileId | null;
245
- }
246
- /**
247
- * Entry within an edit history for a file
248
- */
249
- export interface DocFileEditHistoryBase {
250
- /**
251
- * ID of the specific entry
252
- */
253
- id: string;
254
- /**
255
- * ID of the file the edit history belongs to
256
- */
257
- file_id: FileId;
258
- /**
259
- * User who performed the edit, if available at the
260
- * time of the edit
261
- */
262
- user: User | null;
263
- /**
264
- * Timestamp the edit was performed at
265
- */
266
- created_at: ISODate;
267
- }
268
- export type DocFileEditHistoryData = {
269
- type: EditHistoryType.MoveToFolder;
270
- metadata: EditHistoryMetadataMoveToFolder;
271
- } | {
272
- type: EditHistoryType.Rename;
273
- metadata: EditHistoryMetadataRename;
274
- };
275
- export type DocFileEditHistory = DocFileEditHistoryBase & DocFileEditHistoryData;
276
- /**
277
- * Request to upload a new file
278
- */
279
- export interface UploadFileRequest {
280
- /**
281
- * Scope to upload the file into
282
- */
283
- scope: DocumentBoxScope;
284
- /**
285
- * Name of the file to upload
286
- */
287
- name: string;
288
- /**
289
- * ID of the folder to store the file within
290
- */
291
- folder_id: FolderId;
292
- /**
293
- * The file itself
294
- */
295
- file: File;
296
- /**
297
- * Optional: Fixed ID to set for the file, this should be used
298
- * if you require the file to have some fixed ID when
299
- * its created
300
- */
301
- fixed_id?: FileId | null;
302
- /**
303
- * Optional: ID of the parent file to associate this file to
304
- */
305
- parent_id?: FileId | null;
306
- /**
307
- * Additional configuration specifying how the file should
308
- * be processed
309
- */
310
- processing_config?: ProcessingConfig | null;
311
- /**
312
- * Abort controller to cancel the file upload
313
- */
314
- abort?: AbortController;
315
- }
316
- /**
317
- * Configuration specifying how the file should
318
- * be processed
319
- */
320
- export interface ProcessingConfig {
321
- /**
322
- * Email specific processing configuration
323
- */
324
- email?: EmailProcessingConfig | null;
325
- [key: string]: unknown | null;
326
- }
327
- /**
328
- * Email specific processing configuration
329
- */
330
- export interface EmailProcessingConfig {
331
- /**
332
- * Skip extracting attachments from emails
333
- */
334
- skip_attachments?: boolean | null;
335
- [key: string]: unknown | null;
336
- }
337
- /**
338
- * Perform partial updates on a specific file, such
339
- * as changing the file name or moving it to another folder
340
- */
341
- export interface UpdateFile {
342
- /**
343
- * Optional new name of the file.
344
- *
345
- * leave undefined or specify null to not update this field
346
- */
347
- name?: string | null;
348
- /**
349
- * Optional new folder to move the file to.
350
- *
351
- * leave undefined or specify null to not update this field
352
- */
353
- folder_id?: FolderId | null;
354
- }
355
- export interface DocboxTask {
356
- id: string;
357
- document_box: DocumentBoxScope;
358
- status: DocboxTaskStatus;
359
- output_data: any | null;
360
- created_at: string;
361
- completed_at: string | null;
362
- }
363
- export declare enum DocboxTaskStatus {
364
- Pending = "Pending",
365
- Completed = "Completed",
366
- Failed = "Failed"
367
- }
368
- export interface UploadTaskResponse {
369
- task_id: string;
370
- created_at: string;
371
- }
@@ -1,153 +0,0 @@
1
- import { DocFile } from './file';
2
- import { DocLink } from './link';
3
- import { ISODate, FolderId, EditHistoryType, EditHistoryMetadataRename, EditHistoryMetadataMoveToFolder } from './shared';
4
- import { User } from './user';
5
- /**
6
- * Folder within docbox
7
- */
8
- export interface DocFolder {
9
- /**
10
- * Unique ID of the folder
11
- */
12
- id: FolderId;
13
- /**
14
- * Name of the folder
15
- */
16
- name: string;
17
- /**
18
- * ID of the folder this folder is contained within. This
19
- * is null if the folder is the root folder of a document
20
- * box
21
- */
22
- folder_id: FolderId | null;
23
- /**
24
- * Timestamp of when the folder was created
25
- */
26
- created_at: ISODate;
27
- /**
28
- * User who created the folder if the user was known
29
- * at the point of creation
30
- */
31
- created_by: User | null;
32
- /**
33
- * Timestamp of when the folder was last modified
34
- */
35
- last_modified_at: ISODate | null;
36
- /**
37
- * User who last modified the folder if the user was
38
- * known at the point of modification
39
- *
40
- * NOTE: This is the user for the most recent modification, not the
41
- * most recent modification with a user
42
- */
43
- last_modified_by: User | null;
44
- }
45
- /**
46
- * Entry within an edit history for a file
47
- */
48
- export interface DocFolderEditHistoryBase {
49
- /**
50
- * ID of the specific entry
51
- */
52
- id: string;
53
- /**
54
- * ID of the folder the edit history belongs to
55
- */
56
- folder_id: FolderId;
57
- /**
58
- * User who performed the edit, if available at the.
59
- * time of the edit
60
- */
61
- user: User | null;
62
- /**
63
- * Timestamp the edit was performed at.
64
- */
65
- created_at: ISODate;
66
- }
67
- export type DocFolderEditHistoryData = {
68
- type: EditHistoryType.MoveToFolder;
69
- metadata: EditHistoryMetadataMoveToFolder;
70
- } | {
71
- type: EditHistoryType.Rename;
72
- metadata: EditHistoryMetadataRename;
73
- };
74
- export type DocFolderEditHistory = DocFolderEditHistoryBase & DocFolderEditHistoryData;
75
- /**
76
- * Create a new folder
77
- */
78
- export interface CreateFolder {
79
- /**
80
- * Name of the folder, must be at minimum 1 character long.
81
- */
82
- name: string;
83
- /**
84
- * ID of the parent folder to create the folder within.
85
- */
86
- folder_id: FolderId;
87
- }
88
- /**
89
- * Perform partial updates on a specific folder, such
90
- * as changing the folder name or moving it to another folder
91
- */
92
- export interface UpdateFolder {
93
- /**
94
- * Optional new name of the folder.
95
- *
96
- * leave undefined or specify null to not update this field
97
- */
98
- name?: string | null;
99
- /**
100
- * Optional new folder to move the folder to.
101
- *
102
- * leave undefined or specify null to not update this field
103
- */
104
- folder_id?: FolderId | null;
105
- }
106
- /**
107
- * Named segment from a folder path
108
- */
109
- export interface FolderPathSegment {
110
- /**
111
- * ID of the folder for this segment
112
- */
113
- id: FolderId;
114
- /**
115
- * Name of the folder for this segment
116
- */
117
- name: string;
118
- }
119
- /**
120
- * Resolved details about a folder such as the path
121
- * to the folder and its children
122
- */
123
- export interface ResolvedFolder {
124
- /**
125
- * Path to get to the folder itself
126
- */
127
- path: FolderPathSegment[];
128
- /**
129
- * Folders contained within the folder
130
- */
131
- folders: DocFolder[];
132
- /**
133
- * Files contained within the folder
134
- */
135
- files: DocFile[];
136
- /**
137
- * Links contained within the folder
138
- */
139
- links: DocLink[];
140
- }
141
- /**
142
- * Response from requesting a folder
143
- */
144
- export interface FolderResponse {
145
- /**
146
- * The folder itself
147
- */
148
- folder: DocFolder;
149
- /**
150
- * The resolved folder details
151
- */
152
- children: ResolvedFolder;
153
- }
@@ -1,22 +0,0 @@
1
- import { DocFile } from './file';
2
- import { DocFolder } from './folder';
3
- import { DocLink } from './link';
4
- export * from './box';
5
- export * from './file';
6
- export * from './folder';
7
- export * from './link';
8
- export * from './search';
9
- export * from './shared';
10
- export * from './user';
11
- export declare enum DocboxItemType {
12
- File = "File",
13
- Folder = "Folder",
14
- Link = "Link"
15
- }
16
- export type DocboxItem = ({
17
- type: DocboxItemType.File;
18
- } & DocFile) | ({
19
- type: DocboxItemType.Folder;
20
- } & DocFolder) | ({
21
- type: DocboxItemType.Link;
22
- } & DocLink);