@or-sdk/files 3.10.0 → 3.11.0-beta.4013.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/dist/types/Files.d.ts +147 -2
- package/dist/types/Files.d.ts.map +1 -1
- package/dist/types/types/ttl.d.ts +10 -0
- package/dist/types/types/ttl.d.ts.map +1 -1
- package/dist/types/types/upload-files.d.ts +55 -3
- package/dist/types/types/upload-files.d.ts.map +1 -1
- package/dist/types/types.d.ts +38 -1
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +3 -4
- package/src/types/upload-files.ts +1 -5
- package/src/types.ts +3 -1
package/dist/types/Files.d.ts
CHANGED
|
@@ -1,39 +1,184 @@
|
|
|
1
1
|
import { Base } from '@or-sdk/base';
|
|
2
2
|
import type { FileItem, FileItemSelect, FilesConfigWithDiscovery, FilesConfigWithExplicitUrls, RequestOptions, DateTime, UploadFileOptions, UploadFileProps, UploadFilePropsLegacy, UploadSystemFileParams, UploadSystemFileParamsLegacy, UploadUrlProps, UploadUrlPropsLegacy, UploadUrlResponse } from './types';
|
|
3
3
|
export declare class Files extends Base {
|
|
4
|
+
/** Service-Discovery API allows to fetch URLs for required services automatically on bootstrap */
|
|
4
5
|
constructor(params: FilesConfigWithDiscovery);
|
|
6
|
+
/** Providing URLs for APIs explicitly allows to reduce initial delay by avoiding extra calls to discovery service */
|
|
5
7
|
constructor(params: FilesConfigWithExplicitUrls);
|
|
8
|
+
/**
|
|
9
|
+
* Get one file full data
|
|
10
|
+
* @param isPublic does this file public or private
|
|
11
|
+
* @param prefix the file path, example: /data/images/second.png
|
|
12
|
+
* @param attributes select specific props from FileItem. Example: 'key, isBoolean, size'
|
|
13
|
+
* @returns object with: file, headData and url for downloading
|
|
14
|
+
*/
|
|
6
15
|
getFile(prefix: string, isPublic: boolean, attributes?: string): Promise<FileItem>;
|
|
16
|
+
/**
|
|
17
|
+
* Get one folder full data
|
|
18
|
+
* @param key the file path, example: /data/images/second.png
|
|
19
|
+
* @returns Folder record
|
|
20
|
+
*/
|
|
7
21
|
getFolder(key: string, options?: RequestOptions): Promise<FileItem>;
|
|
22
|
+
/**
|
|
23
|
+
* Get folder size
|
|
24
|
+
* @param key the name of folder
|
|
25
|
+
* @returns total folder size in bytes
|
|
26
|
+
*/
|
|
8
27
|
getFolderSize(key: string, options?: RequestOptions): Promise<number>;
|
|
28
|
+
/**
|
|
29
|
+
* Get list of public/private FileItems from api
|
|
30
|
+
* @param treePrefix the folder path where GET FileItems, for Root use ''
|
|
31
|
+
* @param isPublic does this file public or private, undefined for both types
|
|
32
|
+
* @returns list of FileItem records
|
|
33
|
+
*/
|
|
9
34
|
getItemsList(treePrefix: string, isPublic?: boolean): Promise<FileItem[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Get list of public/private FileItems from api
|
|
37
|
+
* @param treePrefix the folder path where GET FileItems, for Root use ''
|
|
38
|
+
* @param isPublic does this file public or private, undefined for both types
|
|
39
|
+
* @param attributes select specific props from FileItem. Example: 'key, isBoolean, size'
|
|
40
|
+
* @returns list of FileItemSelect
|
|
41
|
+
*/
|
|
10
42
|
getItemsList(treePrefix: string, isPublic?: boolean, attributes?: string): Promise<FileItemSelect[]>;
|
|
11
43
|
getFoldersList(treePrefix: string, options?: RequestOptions): Promise<FileItem[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Se list of public/private FileItems from api with specific prefix
|
|
46
|
+
* @param term the folder/file path where search will be done
|
|
47
|
+
* @param isPublic does this file public or private, undefined for both types
|
|
48
|
+
* @returns list of FileItems
|
|
49
|
+
*/
|
|
12
50
|
search(term: string, isPublic?: boolean): Promise<FileItem[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Create ROOT folder
|
|
53
|
+
*/
|
|
13
54
|
createRootFolder(options?: RequestOptions): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Create new folder
|
|
57
|
+
* @param folderName should have folder path + folder name, example: /main/New folder
|
|
58
|
+
*/
|
|
14
59
|
createFolder(folderName: string, options?: RequestOptions): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Rename exist file
|
|
62
|
+
* @param key old file name
|
|
63
|
+
* @param newKey new file name
|
|
64
|
+
* @param isPublic does this file public or private
|
|
65
|
+
* @param abortSignal signal to cancel file renaming
|
|
66
|
+
*/
|
|
15
67
|
renameFile(key: string, newKey: string, isPublic: boolean, abortSignal?: AbortSignal): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Duplicate file
|
|
70
|
+
* @param key target file name
|
|
71
|
+
* @param newKey new file name
|
|
72
|
+
* @param isPublic does this file public or private
|
|
73
|
+
*/
|
|
16
74
|
duplicateFile(key: string, newKey: string, isPublic: boolean): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Change file privacy
|
|
77
|
+
* @param key file name
|
|
78
|
+
* @param newPrivacy new file privacy
|
|
79
|
+
* @param isPublic does this file public or private
|
|
80
|
+
*/
|
|
17
81
|
changePrivacy(key: string, newPrivacy: 'private' | 'public', isPublic: boolean): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Delete file
|
|
84
|
+
* @param key file name
|
|
85
|
+
* @param isPublic does this file public or private
|
|
86
|
+
* @param abortSignal signal to cancel file renaming
|
|
87
|
+
*/
|
|
18
88
|
deleteFile(key: string, isPublic: boolean, abortSignal?: AbortSignal): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Delete folder
|
|
91
|
+
* @param key folder name
|
|
92
|
+
*/
|
|
19
93
|
deleteFolder(key: string, options?: RequestOptions): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Get a link to download file, example: for preview
|
|
96
|
+
* @param key folder name
|
|
97
|
+
* @param isPublic does this file public or private
|
|
98
|
+
* @param expireMs how long PRIVATE file link will be accessible in milliseconds
|
|
99
|
+
* @param checkFileExist check that file exists in database
|
|
100
|
+
* @returns file url
|
|
101
|
+
*/
|
|
20
102
|
getDownloadUrl(key: string, isPublic: boolean, expireMs?: number, checkFileExist?: boolean): Promise<string>;
|
|
21
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Get a link for uploading specific file, JUST FOR INNER USE
|
|
105
|
+
* @returns URL for uploading a file with additional header Fields
|
|
106
|
+
*/
|
|
107
|
+
getUploadUrlV2(
|
|
108
|
+
/** Details of the file to be uploaded */
|
|
109
|
+
{ fileName, prefix, contentType, isPublic, expiresAt, ...data }: UploadUrlProps,
|
|
110
|
+
/** Additional request options */
|
|
111
|
+
options?: RequestOptions): Promise<UploadUrlResponse>;
|
|
112
|
+
/**
|
|
113
|
+
* Upload the file to File service
|
|
114
|
+
*
|
|
115
|
+
* @returns URL of the uploaded file into Files
|
|
116
|
+
*/
|
|
22
117
|
uploadFileV2({ fileName, prefix, fileContent, contentType, expiresAt, isPublic, rewriteMode, maxFileSize, knownLength, cacheControl, waitTillFileAddedInDb, onUploadProgress, }: UploadFileProps, { signal, waitForDatabaseUpdateTimeout, waitForDatabaseUpdatePollInterval, }?: UploadFileOptions): Promise<string>;
|
|
118
|
+
/**
|
|
119
|
+
* Upload system file to S3 bucket, will not affect total size for user storage
|
|
120
|
+
*/
|
|
23
121
|
uploadSystemFileV3({ fileName, prefix, fileContent, contentType, cacheControl, expiresAt, knownLength, onUploadProgress, }: UploadSystemFileParams, options?: RequestOptions): Promise<string>;
|
|
122
|
+
/**
|
|
123
|
+
* Delete system file
|
|
124
|
+
* @param path file path
|
|
125
|
+
*/
|
|
24
126
|
deleteSystemFile(path: string, options?: RequestOptions): Promise<void>;
|
|
127
|
+
/** Get signed URL params for uploading of system file */
|
|
25
128
|
private getSystemFileUploadUrl;
|
|
129
|
+
/**
|
|
130
|
+
* Set ttl for a specific file or folder
|
|
131
|
+
* @param key file or folder path
|
|
132
|
+
* @param isPublic `false` for folders, `true` or `false` for files
|
|
133
|
+
* @param expiresAt when file should expire and be deleted
|
|
134
|
+
*/
|
|
26
135
|
addTtl(key: string, isPublic: boolean, expiresAt: DateTime): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* Update ttl for a specific file or folder
|
|
138
|
+
* @param key file or folder path
|
|
139
|
+
* @param isPublic false for folders, true or false for files
|
|
140
|
+
* @param newExpiresAt when file should expire and be deleted
|
|
141
|
+
*/
|
|
27
142
|
updateTtl(key: string, isPublic: boolean, newExpiresAt: DateTime): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Delete ttl for a specific file or folder
|
|
145
|
+
* @param key file or folder path
|
|
146
|
+
* @param isPublic false for folders, true or false for files
|
|
147
|
+
*/
|
|
28
148
|
deleteTtl(key: string, isPublic: boolean): Promise<void>;
|
|
29
149
|
private uploadToSignedUrl;
|
|
30
150
|
private formDataFactory;
|
|
31
151
|
private getFormDataHeaders;
|
|
32
152
|
private normalizeFileModel;
|
|
33
153
|
private normalizeDate;
|
|
154
|
+
/**
|
|
155
|
+
* Upload the file to File service
|
|
156
|
+
*
|
|
157
|
+
* @returns URL of the uploaded file into Files
|
|
158
|
+
* @deprecated Use {@link uploadFileV2} instead
|
|
159
|
+
*/
|
|
34
160
|
uploadFile({ name, prefix, fileModel, type, isPublic, rewriteMode, maxFileSize, knownLength, cacheControl, ttl, waitTillFileAddedInDb, abortSignal, progress, }: UploadFilePropsLegacy, signal?: AbortSignal): Promise<string>;
|
|
35
|
-
|
|
161
|
+
/**
|
|
162
|
+
* Get a link for uploading specific file, JUST FOR INNER USE
|
|
163
|
+
* @returns uploading Url with different header Fields
|
|
164
|
+
* @deprecated Use {@link getUploadUrlV2} instead
|
|
165
|
+
*/
|
|
166
|
+
getUploadUrl(
|
|
167
|
+
/** Details of the file to be uploaded */
|
|
168
|
+
params: UploadUrlPropsLegacy, isPublic?: boolean, ttl?: number, abortSignal?: AbortSignal): Promise<UploadUrlResponse>;
|
|
169
|
+
/**
|
|
170
|
+
* Upload system file to S3 bucket, will not affect total size for user storage
|
|
171
|
+
* @param prefix prefix inside the system folder
|
|
172
|
+
* @param file file for uploading
|
|
173
|
+
* @param cacheControl cache settings
|
|
174
|
+
* @param abortSignal signal to cancel uploading
|
|
175
|
+
* @deprecated use {@link uploadSystemFileV3} instead
|
|
176
|
+
*/
|
|
36
177
|
uploadSystemFile(prefix: string, file: File, cacheControl?: string, abortSignal?: AbortSignal): Promise<string>;
|
|
178
|
+
/**
|
|
179
|
+
* Upload system file to S3 bucket, will not affect total size for user storage
|
|
180
|
+
* @deprecated Use {@link uploadSystemFileV3} instead
|
|
181
|
+
*/
|
|
37
182
|
uploadSystemFileV2({ fileName, prefix, file, contentType, cacheControl, ttl, knownLength, abortSignal, }: UploadSystemFileParamsLegacy): Promise<string>;
|
|
38
183
|
}
|
|
39
184
|
//# sourceMappingURL=Files.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Files.d.ts","sourceRoot":"","sources":["../../src/Files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAMpC,OAAO,KAAK,EAEV,QAAQ,EACR,cAAc,EAEd,wBAAwB,EACxB,2BAA2B,EAK3B,cAAc,EAEd,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,4BAA4B,EAE5B,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAKjB,qBAAa,KAAM,SAAQ,IAAI;
|
|
1
|
+
{"version":3,"file":"Files.d.ts","sourceRoot":"","sources":["../../src/Files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAMpC,OAAO,KAAK,EAEV,QAAQ,EACR,cAAc,EAEd,wBAAwB,EACxB,2BAA2B,EAK3B,cAAc,EAEd,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,4BAA4B,EAE5B,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAKjB,qBAAa,KAAM,SAAQ,IAAI;IAC7B,kGAAkG;gBACtF,MAAM,EAAE,wBAA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C,EAAE,WAAW,GACxB,OAAO,CAAC,iBAAiB,CAAC;IAa7B;;;;;;;OAOG;IACU,gBAAgB,CAC3B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,YAAY,SAAiB,EAC7B,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,MAAM,CAAC;IAalB;;;OAGG;IACU,kBAAkB,CAAC,EAC9B,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,WAAW,EACX,YAA6B,EAC7B,GAAG,EACH,WAAW,EACX,WAAW,GACZ,EAAE,4BAA4B,GAAG,OAAO,CAAC,MAAM,CAAC;CAclD"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* - `Date` valid date instance
|
|
3
|
+
* - `number` amount of milliseconds since midnight Jan 1 1970 UTC (aka UNIX timestamp in milliseconds)
|
|
4
|
+
* - `string` valid Date string that represents datetime
|
|
5
|
+
* */
|
|
1
6
|
export type DateTime = Date | number | string;
|
|
2
7
|
export type NormalizeDateOptions = {
|
|
8
|
+
/** Message of the error to throw if input is invalid date */
|
|
3
9
|
errorMessage?: string;
|
|
10
|
+
/**
|
|
11
|
+
* If `true` check that date is in the future, otherwise do not check
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
4
14
|
validateFutureDate?: boolean;
|
|
5
15
|
};
|
|
6
16
|
//# sourceMappingURL=ttl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ttl.d.ts","sourceRoot":"","sources":["../../../src/types/ttl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ttl.d.ts","sourceRoot":"","sources":["../../../src/types/ttl.ts"],"names":[],"mappings":"AAAA;;;;KAIK;AACL,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;AAE9C,MAAM,MAAM,oBAAoB,GAAG;IACjC,6DAA6D;IAC7D,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAA"}
|
|
@@ -1,18 +1,52 @@
|
|
|
1
|
+
import type { RequestOptions } from '@or-sdk/base';
|
|
1
2
|
import type { AxiosProgressEvent } from 'axios';
|
|
2
3
|
import type { ReadStream } from 'node:fs';
|
|
3
4
|
import type { DateTime } from './ttl';
|
|
4
5
|
export type { AxiosProgressEvent };
|
|
5
|
-
export type RequestOptions = {
|
|
6
|
-
signal?: AbortSignal;
|
|
7
|
-
};
|
|
8
6
|
export type UploadBaseParams = {
|
|
7
|
+
/**
|
|
8
|
+
* Name of the file
|
|
9
|
+
* @example 'my_file.json'
|
|
10
|
+
*/
|
|
9
11
|
fileName: string;
|
|
12
|
+
/**
|
|
13
|
+
* File path prefix
|
|
14
|
+
* @example If fine name is 'my_file.json' and prefix is 'path/to/file/' the result file path is:
|
|
15
|
+
* 'path/to/file/my_file.json'
|
|
16
|
+
*
|
|
17
|
+
* @example If fine name is 'my_file.json' and prefix is 'name_prefix_' the result file path is:
|
|
18
|
+
* 'name_prefix_my_file.json'
|
|
19
|
+
*/
|
|
10
20
|
prefix?: string;
|
|
21
|
+
/**
|
|
22
|
+
* [MIME type](https://www.iana.org/assignments/media-types/media-types.xhtml)
|
|
23
|
+
* of the file.
|
|
24
|
+
* @default 'binary/octet-stream'
|
|
25
|
+
* @example 'application/json'
|
|
26
|
+
*/
|
|
11
27
|
contentType?: string;
|
|
28
|
+
/** Max size of the file in bytes */
|
|
12
29
|
maxFileSize?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Custom cache control setting for a file
|
|
32
|
+
*
|
|
33
|
+
* Examples:
|
|
34
|
+
* - `max-age=<seconds>`
|
|
35
|
+
* Specifies the maximum time (in seconds) a resource is considered fresh.
|
|
36
|
+
* For example, max-age=86400 means the resource is cached for 1 day.
|
|
37
|
+
* - `no-cache`
|
|
38
|
+
* Force to validate with the origin server before serving a cached copy.
|
|
39
|
+
* Useful for content that changes frequently.
|
|
40
|
+
*/
|
|
13
41
|
cacheControl?: string;
|
|
14
42
|
rewriteMode?: 'rewrite' | 'prevent-rewrite';
|
|
43
|
+
/** Datetime when file should expire and be deleted */
|
|
15
44
|
expiresAt?: DateTime;
|
|
45
|
+
/**
|
|
46
|
+
* If `true` after upload file would be publicly available by it's URL.
|
|
47
|
+
* If `false` access to file is possible only via temporary signed URL to a file.
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
16
50
|
isPublic?: boolean;
|
|
17
51
|
};
|
|
18
52
|
export type UploadUrlProps = UploadBaseParams;
|
|
@@ -25,8 +59,11 @@ export type GetUploadUrlDataPayload = Omit<UploadUrlProps, 'expiresAt' | 'fileNa
|
|
|
25
59
|
ttl?: string;
|
|
26
60
|
};
|
|
27
61
|
export type UploadUrlResponse = {
|
|
62
|
+
/** URL for uploading of the file */
|
|
28
63
|
url: string;
|
|
64
|
+
/** URL for downloading the file once it will be uploaded */
|
|
29
65
|
downloadUrl: string;
|
|
66
|
+
/** Additional FormData fields and headers for uploading the file */
|
|
30
67
|
fields: UploadFields;
|
|
31
68
|
};
|
|
32
69
|
export type UploadFields = {
|
|
@@ -40,17 +77,32 @@ export type UploadFields = {
|
|
|
40
77
|
'X-Amz-Security-Token': string;
|
|
41
78
|
'cache-control'?: string;
|
|
42
79
|
};
|
|
80
|
+
/** Buffer and ReadStream only supported in Node.js */
|
|
43
81
|
export type FileModel = File | Blob | Buffer | ReadStream;
|
|
82
|
+
/** Allows to use a string or Uint8Array<ArrayBuffer> as a file value */
|
|
44
83
|
export type ExtendedFileModel = FileModel | string | Uint8Array;
|
|
45
84
|
export type UploadFileBaseParams = UploadBaseParams & {
|
|
85
|
+
/** File contents */
|
|
46
86
|
fileContent: ExtendedFileModel;
|
|
87
|
+
/** Callback function to be called with upload progress events */
|
|
47
88
|
onUploadProgress?: (event: ProgressEvent | AxiosProgressEvent) => void;
|
|
89
|
+
/** Size of the file in bytes. Helpful when file is an instance of ReadStream in Node.js */
|
|
48
90
|
knownLength?: number;
|
|
91
|
+
/** If `true` method will wait after file upload until file system will update to include file */
|
|
49
92
|
waitTillFileAddedInDb?: boolean;
|
|
50
93
|
};
|
|
51
94
|
export type UploadFileProps = UploadFileBaseParams;
|
|
95
|
+
/** Optional config for uploading files */
|
|
52
96
|
export type UploadFileOptions = RequestOptions & {
|
|
97
|
+
/**
|
|
98
|
+
* Maximum wait time for update of the data base in milliseconds.
|
|
99
|
+
* @default 60_000
|
|
100
|
+
*/
|
|
53
101
|
waitForDatabaseUpdateTimeout?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Interval between checking if database was updated in milliseconds.
|
|
104
|
+
* @default 2_000
|
|
105
|
+
*/
|
|
54
106
|
waitForDatabaseUpdatePollInterval?: number;
|
|
55
107
|
};
|
|
56
108
|
export type UploadToSignedUrlParameters = Pick<UploadFileProps, 'fileName' | 'fileContent' | 'contentType' | 'cacheControl' | 'knownLength' | 'onUploadProgress'> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-files.d.ts","sourceRoot":"","sources":["../../../src/types/upload-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAEnC,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"upload-files.d.ts","sourceRoot":"","sources":["../../../src/types/upload-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,YAA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IACF,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,iBAAiB,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,GAAG,kBAAkB,KAAK,IAAI,CAAC;IAC/D,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,CAAA"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,20 +1,57 @@
|
|
|
1
|
-
import type { Token } from '@or-sdk/base';
|
|
1
|
+
import type { Token, RequestOptions } from '@or-sdk/base';
|
|
2
|
+
export type { RequestOptions };
|
|
2
3
|
export type * from './types/system-files';
|
|
3
4
|
export type * from './types/upload-files';
|
|
4
5
|
export type * from './types/ttl';
|
|
5
6
|
export type { Token };
|
|
6
7
|
export type FilesConfigBase = {
|
|
8
|
+
/**
|
|
9
|
+
* token
|
|
10
|
+
*/
|
|
7
11
|
token: Token;
|
|
12
|
+
/**
|
|
13
|
+
* Account ID for cross-account requests (super admin only)
|
|
14
|
+
*/
|
|
8
15
|
accountId?: string;
|
|
9
16
|
};
|
|
10
17
|
export type FilesConfigWithDiscovery = FilesConfigBase & {
|
|
18
|
+
/**
|
|
19
|
+
* URL of OneReach service discovery API.
|
|
20
|
+
*
|
|
21
|
+
* Allows to fetch URLs of needed API's instead of defining them in the constructor.
|
|
22
|
+
*
|
|
23
|
+
* @example 'https://discovery.<env>.api.onereach.ai'
|
|
24
|
+
*/
|
|
11
25
|
discoveryUrl: string;
|
|
26
|
+
/**
|
|
27
|
+
* Direct service url, can be used to avoid discovery api call
|
|
28
|
+
*
|
|
29
|
+
* Not needed if {@link FilesConfig.discoveryUrl} is defined.
|
|
30
|
+
*
|
|
31
|
+
* @example 'https://files-api.svc.<env>.api.onereach.ai'
|
|
32
|
+
*/
|
|
12
33
|
filesApiUrl?: never;
|
|
34
|
+
/** @deprecated Use {@link FilesConfig.filesApiUrl} instead */
|
|
13
35
|
serviceUrl?: never;
|
|
14
36
|
};
|
|
15
37
|
export type FilesConfigWithExplicitUrls = FilesConfigBase & {
|
|
38
|
+
/**
|
|
39
|
+
* Direct service url, can be used to avoid discovery api call
|
|
40
|
+
*
|
|
41
|
+
* Not needed if {@link FilesConfig.discoveryUrl} is defined.
|
|
42
|
+
*
|
|
43
|
+
* @example 'https://files-api.svc.<env>.api.onereach.ai'
|
|
44
|
+
*/
|
|
16
45
|
filesApiUrl: string;
|
|
46
|
+
/** @deprecated Use {@link FilesConfig.filesApiUrl} instead */
|
|
17
47
|
serviceUrl?: string;
|
|
48
|
+
/**
|
|
49
|
+
* URL of OneReach service discovery API.
|
|
50
|
+
*
|
|
51
|
+
* Not needed if {@link FilesConfig.filesApiUrl} is defined.
|
|
52
|
+
*
|
|
53
|
+
* @example 'https://discovery.<env>.api.onereach.ai'
|
|
54
|
+
*/
|
|
18
55
|
discoveryUrl?: never;
|
|
19
56
|
};
|
|
20
57
|
export type FilesConfig = FilesConfigWithDiscovery | FilesConfigWithExplicitUrls;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE1D,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,aAAa,CAAC;AAEjC,YAAY,EAAE,KAAK,EAAE,CAAC;AAEtB,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;IAEb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB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;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAC3B,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@or-sdk/files",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.0-beta.4013.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dev": "pnpm build:watch:esm"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@or-sdk/base": "^0.
|
|
24
|
+
"@or-sdk/base": "^0.44.0-beta.4013.0",
|
|
25
25
|
"form-data": "4.0.4",
|
|
26
26
|
"typescript-memoize": "^1.1.1"
|
|
27
27
|
},
|
|
@@ -31,6 +31,5 @@
|
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
|
-
}
|
|
35
|
-
"gitHead": "480349cb6b36e66aea6b9b63b93ed61c95497f94"
|
|
34
|
+
}
|
|
36
35
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RequestOptions } from '@or-sdk/base';
|
|
1
2
|
import type { AxiosProgressEvent } from 'axios';
|
|
2
3
|
import type { ReadStream } from 'node:fs';
|
|
3
4
|
|
|
@@ -5,11 +6,6 @@ import type { DateTime } from './ttl';
|
|
|
5
6
|
|
|
6
7
|
export type { AxiosProgressEvent };
|
|
7
8
|
|
|
8
|
-
export type RequestOptions = {
|
|
9
|
-
/** Signal from AbortController to abort active request */
|
|
10
|
-
signal?: AbortSignal;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
9
|
export type UploadBaseParams = {
|
|
14
10
|
/**
|
|
15
11
|
* Name of the file
|