@cirrobio/sdk 0.4.3 → 0.9.1
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 +7 -0
- package/dist/index.esm.js +759 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +815 -19
- package/dist/index.js.map +1 -0
- package/dist/types/api/config.d.ts +6 -0
- package/dist/{api → types/api}/error-handler.d.ts +0 -4
- package/dist/types/api/error.d.ts +4 -0
- package/dist/types/api.d.ts +2 -0
- package/dist/types/auth/authentication-provider.d.ts +24 -0
- package/dist/types/auth/current-user.d.ts +16 -0
- package/dist/types/auth/static-token-auth.d.ts +11 -0
- package/dist/types/auth.d.ts +3 -0
- package/dist/types/data/data.service.d.ts +44 -0
- package/dist/types/data.d.ts +1 -0
- package/dist/{file → types/file}/calculate-size.d.ts +1 -1
- package/dist/{file → types/file}/file.service.d.ts +9 -6
- package/dist/types/file/manifest-parser.d.ts +14 -0
- package/dist/types/file/models/assets.d.ts +8 -0
- package/dist/{file → types/file/models}/file-object.model.d.ts +1 -1
- package/dist/types/file/models/file.d.ts +14 -0
- package/dist/types/file/models/folder.d.ts +13 -0
- package/dist/{file → types/file}/shared.d.ts +1 -1
- package/dist/types/file/util/get-parent.fn.d.ts +4 -0
- package/dist/{file.d.ts → types/file.d.ts} +5 -2
- package/dist/{index.d.ts → types/index.d.ts} +2 -0
- package/dist/types/util/get-resource-name.d.ts +1 -0
- package/dist/{util.d.ts → types/util.d.ts} +1 -0
- package/package.json +20 -15
- package/dist/api/error-handler.js +0 -37
- package/dist/api.d.ts +0 -1
- package/dist/api.js +0 -6
- package/dist/file/__test__/s3-utils.test.d.ts +0 -1
- package/dist/file/__test__/s3-utils.test.js +0 -16
- package/dist/file/actions/delete.fn.js +0 -15
- package/dist/file/actions/sign-url.fn.js +0 -27
- package/dist/file/actions/upload.fn.js +0 -23
- package/dist/file/calculate-size.js +0 -16
- package/dist/file/extensions.fn.js +0 -77
- package/dist/file/file-object.model.js +0 -8
- package/dist/file/file.service.js +0 -81
- package/dist/file/project-access-context.js +0 -24
- package/dist/file/shared.js +0 -11
- package/dist/file/util/credentials-mutex.so.js +0 -32
- package/dist/file/util/s3-client.js +0 -19
- package/dist/file/util/s3-utils.js +0 -17
- package/dist/file.js +0 -43
- package/dist/formatters/bytes-to-string.js +0 -30
- package/dist/formatters/json-pretty-print.js +0 -12
- package/dist/formatters/normalize-date.js +0 -16
- package/dist/formatters/normalize-string.js +0 -13
- package/dist/formatters/slash.js +0 -19
- package/dist/formatters/to-date-format.js +0 -16
- package/dist/formatters/to-friendly-name.js +0 -17
- package/dist/formatters/to-money.js +0 -16
- package/dist/formatters/to-pascal-case.js +0 -12
- package/dist/formatters/to-title-case.js +0 -14
- package/dist/formatters.js +0 -24
- package/dist/util/download.js +0 -22
- package/dist/util/extract-from-object.js +0 -15
- package/dist/util/handle-promise.js +0 -11
- package/dist/util.js +0 -10
- package/src/api/error-handler.ts +0 -36
- package/src/api.ts +0 -1
- package/src/file/__test__/s3-utils.test.ts +0 -17
- package/src/file/actions/delete.fn.ts +0 -18
- package/src/file/actions/sign-url.fn.ts +0 -36
- package/src/file/actions/upload.fn.ts +0 -30
- package/src/file/calculate-size.ts +0 -14
- package/src/file/extensions.fn.ts +0 -88
- package/src/file/file-object.model.ts +0 -57
- package/src/file/file.service.ts +0 -86
- package/src/file/project-access-context.ts +0 -26
- package/src/file/shared.ts +0 -7
- package/src/file/util/credentials-mutex.so.ts +0 -33
- package/src/file/util/s3-client.ts +0 -17
- package/src/file/util/s3-utils.ts +0 -14
- package/src/file.ts +0 -13
- package/src/formatters/__tests__/formatters.spec.ts +0 -65
- package/src/formatters/bytes-to-string.ts +0 -32
- package/src/formatters/json-pretty-print.ts +0 -8
- package/src/formatters/normalize-date.ts +0 -10
- package/src/formatters/normalize-string.ts +0 -8
- package/src/formatters/slash.ts +0 -15
- package/src/formatters/to-date-format.ts +0 -12
- package/src/formatters/to-friendly-name.ts +0 -14
- package/src/formatters/to-money.ts +0 -13
- package/src/formatters/to-pascal-case.ts +0 -8
- package/src/formatters/to-title-case.ts +0 -9
- package/src/formatters.ts +0 -10
- package/src/index.ts +0 -4
- package/src/util/download.ts +0 -18
- package/src/util/extract-from-object.ts +0 -11
- package/src/util/handle-promise.ts +0 -7
- package/src/util.ts +0 -3
- package/tsconfig.json +0 -21
- /package/dist/{file → types/file}/actions/delete.fn.d.ts +0 -0
- /package/dist/{file → types/file}/actions/sign-url.fn.d.ts +0 -0
- /package/dist/{file → types/file}/actions/upload.fn.d.ts +0 -0
- /package/dist/{file → types/file}/extensions.fn.d.ts +0 -0
- /package/dist/{file → types/file}/project-access-context.d.ts +0 -0
- /package/dist/{file → types/file}/util/credentials-mutex.so.d.ts +0 -0
- /package/dist/{file → types/file}/util/s3-client.d.ts +0 -0
- /package/dist/{file → types/file}/util/s3-utils.d.ts +0 -0
- /package/dist/{formatters → types/formatters}/bytes-to-string.d.ts +0 -0
- /package/dist/{formatters → types/formatters}/json-pretty-print.d.ts +0 -0
- /package/dist/{formatters → types/formatters}/normalize-date.d.ts +0 -0
- /package/dist/{formatters → types/formatters}/normalize-string.d.ts +0 -0
- /package/dist/{formatters → types/formatters}/slash.d.ts +0 -0
- /package/dist/{formatters → types/formatters}/to-date-format.d.ts +0 -0
- /package/dist/{formatters → types/formatters}/to-friendly-name.d.ts +0 -0
- /package/dist/{formatters → types/formatters}/to-money.d.ts +0 -0
- /package/dist/{formatters → types/formatters}/to-pascal-case.d.ts +0 -0
- /package/dist/{formatters → types/formatters}/to-title-case.d.ts +0 -0
- /package/dist/{formatters.d.ts → types/formatters.d.ts} +0 -0
- /package/dist/{util → types/util}/download.d.ts +0 -0
- /package/dist/{util → types/util}/extract-from-object.d.ts +0 -0
- /package/dist/{util → types/util}/handle-promise.d.ts +0 -0
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateTotalSize = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Calculate the total size of all files in a directory.
|
|
6
|
-
* @param files - An array of FileSystemObject representing the files in the directory.
|
|
7
|
-
* @return The total size of all files in bytes.
|
|
8
|
-
*/
|
|
9
|
-
function calculateTotalSize(files) {
|
|
10
|
-
let totalSize = 0;
|
|
11
|
-
for (const file of files) {
|
|
12
|
-
totalSize += file.size;
|
|
13
|
-
}
|
|
14
|
-
return totalSize;
|
|
15
|
-
}
|
|
16
|
-
exports.calculateTotalSize = calculateTotalSize;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.matchesExtension = exports.FILE_EXTENSIONS_TO_OPEN = exports.FILE_OME_EXTENSIONS = exports.FILE_IMAGE_EXTENSIONS = exports.FILE_TXT_EXTENSIONS = exports.FILE_TXT_GENOMICS_EXTENSIONS = exports.FILE_DSV_EXTENSIONS = exports.FILE_PROTEIN_STRUCTURE_EXTENSIONS = exports.FILE_BROWSER_EXTENSIONS = exports.FILE_TRACK_EXTENSIONS = exports.FILE_TRACK_EXTENSIONS_NO_INDEX = exports.FILE_VITESSCE_EXTENSIONS = exports.FILE_TRACK_INDEX_EXTENSIONS = exports.FILE_TRACK_SEG = exports.FILE_TRACK_WIG = exports.FILE_TRACK_VARIANT = exports.FILE_TRACK_ALIGNMENTS = exports.FILE_TRACK_ANNOTATION = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* An array of file extensions that can be rendered in a genome viewer
|
|
6
|
-
*/
|
|
7
|
-
exports.FILE_TRACK_ANNOTATION = ['bed', 'bed.gz', 'gtf', 'gtf.gz'];
|
|
8
|
-
exports.FILE_TRACK_ALIGNMENTS = ['cram', 'cram.gz']; // TODO: put back bam
|
|
9
|
-
exports.FILE_TRACK_VARIANT = ['vcf', 'vcf.gz'];
|
|
10
|
-
exports.FILE_TRACK_WIG = ['wig', 'wig.gz', 'bw', 'bw.gz', 'bigwig', 'bigwig.gz'];
|
|
11
|
-
exports.FILE_TRACK_SEG = ['seg', 'seg.gz'];
|
|
12
|
-
exports.FILE_TRACK_INDEX_EXTENSIONS = ['tbi', 'bai', 'crai', 'csi'];
|
|
13
|
-
exports.FILE_VITESSCE_EXTENSIONS = ['hdf5', 'h5ad', 'loom'];
|
|
14
|
-
exports.FILE_TRACK_EXTENSIONS_NO_INDEX = [
|
|
15
|
-
...exports.FILE_TRACK_ANNOTATION,
|
|
16
|
-
...exports.FILE_TRACK_ALIGNMENTS,
|
|
17
|
-
...exports.FILE_TRACK_VARIANT,
|
|
18
|
-
...exports.FILE_TRACK_WIG,
|
|
19
|
-
...exports.FILE_TRACK_SEG
|
|
20
|
-
];
|
|
21
|
-
exports.FILE_TRACK_EXTENSIONS = [
|
|
22
|
-
...exports.FILE_TRACK_EXTENSIONS_NO_INDEX,
|
|
23
|
-
...exports.FILE_TRACK_INDEX_EXTENSIONS
|
|
24
|
-
];
|
|
25
|
-
exports.FILE_BROWSER_EXTENSIONS = ['html', 'pdf'];
|
|
26
|
-
/**
|
|
27
|
-
* An array of file extensions that are protein structure files.
|
|
28
|
-
*/
|
|
29
|
-
exports.FILE_PROTEIN_STRUCTURE_EXTENSIONS = ['pdb', 'pdb.gz', 'cif', 'cif.gz', 'ent', 'ent.gz', 'mmtf', 'mmtf.gz'];
|
|
30
|
-
/**
|
|
31
|
-
* An array of file extensions that are considered tabular files.
|
|
32
|
-
*/
|
|
33
|
-
exports.FILE_DSV_EXTENSIONS = ['tab', 'csv', 'tsv', 'dsv'];
|
|
34
|
-
/**
|
|
35
|
-
* An array of file extensions that contain genomic sequence content.
|
|
36
|
-
*/
|
|
37
|
-
exports.FILE_TXT_GENOMICS_EXTENSIONS = ['fasta', 'fna', 'fsa', 'fa', 'fastp', 'fastq', 'faa', 'gbk', 'gff', 'vcf', 'seq'];
|
|
38
|
-
/**
|
|
39
|
-
* An array of file extensions that are considered TXT files.
|
|
40
|
-
*/
|
|
41
|
-
exports.FILE_TXT_EXTENSIONS = ['txt', 'log', 'yml', 'cfg', 'config', 'xml', 'yaml', ...exports.FILE_DSV_EXTENSIONS, ...exports.FILE_TXT_GENOMICS_EXTENSIONS];
|
|
42
|
-
/**
|
|
43
|
-
* An array of file extensions that are considered image files.
|
|
44
|
-
*/
|
|
45
|
-
exports.FILE_IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'svg'];
|
|
46
|
-
/**
|
|
47
|
-
* An array of file extensions that are considered OME (Open Microscopy Environment) files.
|
|
48
|
-
*/
|
|
49
|
-
exports.FILE_OME_EXTENSIONS = ['tif', 'ome.tif', 'ome.tiff', 'ome.tif.gz', 'ome.tiff.gz'];
|
|
50
|
-
/**
|
|
51
|
-
* An array of file extensions that can be opened in the browser.
|
|
52
|
-
* Includes common document formats such as HTML, PDF, and JSON, as well as image, DSV, TXT, and OME file formats.
|
|
53
|
-
*/
|
|
54
|
-
exports.FILE_EXTENSIONS_TO_OPEN = ['html', 'pdf', 'json', 'fcs',
|
|
55
|
-
...exports.FILE_IMAGE_EXTENSIONS,
|
|
56
|
-
...exports.FILE_TXT_EXTENSIONS,
|
|
57
|
-
...exports.FILE_TRACK_EXTENSIONS,
|
|
58
|
-
...exports.FILE_PROTEIN_STRUCTURE_EXTENSIONS
|
|
59
|
-
];
|
|
60
|
-
/**
|
|
61
|
-
* Checks if a file has an extension that matches one in the provided list.
|
|
62
|
-
* @param filePath The file to check the extension of.
|
|
63
|
-
* @param extensions A list of file endings to check the file against.
|
|
64
|
-
* @returns True or false if the file has an ending in the extensions list.
|
|
65
|
-
*/
|
|
66
|
-
function matchesExtension(filePath, extensions) {
|
|
67
|
-
filePath = filePath.toLowerCase();
|
|
68
|
-
// Decompress the filePath if it ends with .gz
|
|
69
|
-
if (filePath.endsWith('.gz')) {
|
|
70
|
-
filePath = filePath.slice(0, -3); // remove the .gz extension
|
|
71
|
-
}
|
|
72
|
-
// Now, get the extension of the file
|
|
73
|
-
const fileExtension = filePath.slice(filePath.lastIndexOf('.') + 1);
|
|
74
|
-
// Check if the fileExtension is in the list of extensions
|
|
75
|
-
return extensions.includes(fileExtension);
|
|
76
|
-
}
|
|
77
|
-
exports.matchesExtension = matchesExtension;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileSystemObjectType = void 0;
|
|
4
|
-
var FileSystemObjectType;
|
|
5
|
-
(function (FileSystemObjectType) {
|
|
6
|
-
FileSystemObjectType["FILE"] = "file";
|
|
7
|
-
FileSystemObjectType["FOLDER"] = "folder";
|
|
8
|
-
})(FileSystemObjectType = exports.FileSystemObjectType || (exports.FileSystemObjectType = {}));
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileService = void 0;
|
|
4
|
-
const api_client_1 = require("@cirrobio/api-client");
|
|
5
|
-
const credentials_mutex_so_1 = require("./util/credentials-mutex.so");
|
|
6
|
-
const sign_url_fn_1 = require("./actions/sign-url.fn");
|
|
7
|
-
const shared_1 = require("./shared");
|
|
8
|
-
/**
|
|
9
|
-
* Service for viewing files in Cirro
|
|
10
|
-
* currently this only operates on files within a project
|
|
11
|
-
*/
|
|
12
|
-
class FileService {
|
|
13
|
-
constructor(fileApi) {
|
|
14
|
-
this.fileApi = fileApi;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Get contents of a file
|
|
18
|
-
*/
|
|
19
|
-
async getProjectFile(file) {
|
|
20
|
-
const url = await this.getSignedUrlFromProjectFile(file);
|
|
21
|
-
return fetch(url);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Get a signed URL for a file
|
|
25
|
-
*/
|
|
26
|
-
async getSignedUrlFromProjectFile(file, params) {
|
|
27
|
-
const credentials = await this.getProjectAccessCredentials(file.fileAccessContext);
|
|
28
|
-
const _params = {
|
|
29
|
-
...params,
|
|
30
|
-
filename: file.name,
|
|
31
|
-
url: file.url,
|
|
32
|
-
credentials,
|
|
33
|
-
};
|
|
34
|
-
return (0, sign_url_fn_1.getSignedUrl)(_params);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Get a signed URL for a file given a path
|
|
38
|
-
*/
|
|
39
|
-
async getSignedUrlFromProjectPath(fileAccessContext, path, params) {
|
|
40
|
-
const credentials = await this.getProjectAccessCredentials(fileAccessContext);
|
|
41
|
-
const _params = {
|
|
42
|
-
...params,
|
|
43
|
-
filename: path.split('/').pop(),
|
|
44
|
-
url: `s3://${(0, shared_1.getProjectS3Bucket)(fileAccessContext.project.id)}/${path}`,
|
|
45
|
-
credentials,
|
|
46
|
-
};
|
|
47
|
-
return (0, sign_url_fn_1.getSignedUrl)(_params);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Get credentials for accessing a project file
|
|
51
|
-
*/
|
|
52
|
-
async getProjectAccessCredentials(fileAccessContext) {
|
|
53
|
-
const accessType = fileAccessContext.fileAccessRequest.accessType;
|
|
54
|
-
// Special case for project download, since we can cache the credentials
|
|
55
|
-
if (accessType === api_client_1.ProjectAccessType.ProjectDownload || accessType === api_client_1.ProjectAccessType.SharedDatasetDownload) {
|
|
56
|
-
return this.getProjectReadCredentials(fileAccessContext);
|
|
57
|
-
}
|
|
58
|
-
return this.fileApi.generateProjectFileAccessToken({ projectId: fileAccessContext.project.id, projectFileAccessRequest: fileAccessContext.fileAccessRequest });
|
|
59
|
-
}
|
|
60
|
-
async getProjectReadCredentials(fileAccessContext) {
|
|
61
|
-
const projectId = fileAccessContext.project.id;
|
|
62
|
-
// Append datasetId to cache key for shared dataset downloads since we need to generate a new token for each dataset
|
|
63
|
-
let cacheKey = projectId;
|
|
64
|
-
if (fileAccessContext.fileAccessRequest.accessType === api_client_1.ProjectAccessType.SharedDatasetDownload) {
|
|
65
|
-
cacheKey = `${projectId}-${fileAccessContext.fileAccessRequest.datasetId}`;
|
|
66
|
-
}
|
|
67
|
-
return credentials_mutex_so_1.credentialsMutex.dispatch(async () => {
|
|
68
|
-
const cachedCredentials = credentials_mutex_so_1.credentialsCache.get(cacheKey);
|
|
69
|
-
const expirationTime = cachedCredentials ? cachedCredentials === null || cachedCredentials === void 0 ? void 0 : cachedCredentials.expiration : null;
|
|
70
|
-
const fetchNewCredentials = !expirationTime || expirationTime < new Date();
|
|
71
|
-
if (fetchNewCredentials) {
|
|
72
|
-
const projectFileAccessRequest = fileAccessContext.fileAccessRequest;
|
|
73
|
-
const credentials = await this.fileApi.generateProjectFileAccessToken({ projectId, projectFileAccessRequest });
|
|
74
|
-
credentials_mutex_so_1.credentialsCache.set(cacheKey, credentials);
|
|
75
|
-
return credentials;
|
|
76
|
-
}
|
|
77
|
-
return cachedCredentials;
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.FileService = FileService;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProjectFileAccessContext = void 0;
|
|
4
|
-
const api_client_1 = require("@cirrobio/api-client");
|
|
5
|
-
/**
|
|
6
|
-
* Helper class to encapsulate the file access for a project.
|
|
7
|
-
*/
|
|
8
|
-
class ProjectFileAccessContext {
|
|
9
|
-
constructor(project, dataset, fileAccessRequest) {
|
|
10
|
-
this.project = project;
|
|
11
|
-
this.dataset = dataset;
|
|
12
|
-
this.fileAccessRequest = fileAccessRequest;
|
|
13
|
-
}
|
|
14
|
-
static projectDownload(project) {
|
|
15
|
-
const request = { accessType: api_client_1.ProjectAccessType.ProjectDownload };
|
|
16
|
-
return new ProjectFileAccessContext(project, null, request);
|
|
17
|
-
}
|
|
18
|
-
static datasetDownload(project, dataset) {
|
|
19
|
-
const accessType = dataset.share ? api_client_1.ProjectAccessType.SharedDatasetDownload : api_client_1.ProjectAccessType.ProjectDownload;
|
|
20
|
-
const request = { accessType, datasetId: dataset.id };
|
|
21
|
-
return new ProjectFileAccessContext(project, dataset, request);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.ProjectFileAccessContext = ProjectFileAccessContext;
|
package/dist/file/shared.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProjectS3Bucket = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Get the S3 bucket name for a project.
|
|
6
|
-
* Will be deprecated in the future.
|
|
7
|
-
*/
|
|
8
|
-
function getProjectS3Bucket(projectId) {
|
|
9
|
-
return `project-${projectId}`;
|
|
10
|
-
}
|
|
11
|
-
exports.getProjectS3Bucket = getProjectS3Bucket;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.credentialsCache = exports.credentialsMutex = void 0;
|
|
4
|
-
class Mutex {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.mutex = Promise.resolve();
|
|
7
|
-
}
|
|
8
|
-
lock() {
|
|
9
|
-
let begin = () => { };
|
|
10
|
-
this.mutex = this.mutex.then(() => new Promise(begin));
|
|
11
|
-
return new Promise((res) => {
|
|
12
|
-
begin = res;
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
async dispatch(fn) {
|
|
16
|
-
const unlock = await this.lock();
|
|
17
|
-
try {
|
|
18
|
-
return await Promise.resolve(fn());
|
|
19
|
-
}
|
|
20
|
-
finally {
|
|
21
|
-
unlock();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* A mutex to ensure that only one request for credentials is made at a time.
|
|
27
|
-
*/
|
|
28
|
-
exports.credentialsMutex = new Mutex();
|
|
29
|
-
/**
|
|
30
|
-
* A cache of credentials to avoid making multiple requests for the same credentials.
|
|
31
|
-
*/
|
|
32
|
-
exports.credentialsCache = new Map();
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createS3Client = void 0;
|
|
4
|
-
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
5
|
-
/**
|
|
6
|
-
* Creates an S3 client using the provided credentials.
|
|
7
|
-
*/
|
|
8
|
-
function createS3Client(credentials) {
|
|
9
|
-
return new client_s3_1.S3Client({
|
|
10
|
-
credentials: {
|
|
11
|
-
accessKeyId: credentials.accessKeyId,
|
|
12
|
-
secretAccessKey: credentials.secretAccessKey,
|
|
13
|
-
sessionToken: credentials.sessionToken,
|
|
14
|
-
},
|
|
15
|
-
region: credentials.region,
|
|
16
|
-
useDualstackEndpoint: true,
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
exports.createS3Client = createS3Client;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.s3UriToParams = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Converts an S3 URI to a bucket and key
|
|
6
|
-
*/
|
|
7
|
-
function s3UriToParams(uri) {
|
|
8
|
-
const matches = /^s3:\/\/([^/]+)\/(.+)$/.exec(uri);
|
|
9
|
-
if (!matches) {
|
|
10
|
-
throw new Error(`Received invalid uri: '${uri}'`);
|
|
11
|
-
}
|
|
12
|
-
return {
|
|
13
|
-
Bucket: matches[1],
|
|
14
|
-
Key: matches[2],
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
exports.s3UriToParams = s3UriToParams;
|
package/dist/file.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Upload = exports.calculateTotalSize = exports.getProjectS3Bucket = exports.credentialsMutex = exports.credentialsCache = exports.createS3Client = exports.s3UriToParams = exports.FileSystemObjectType = exports.ProjectFileAccessContext = exports.uploadFile = exports.getSignedUrl = exports.deleteFile = exports.FileService = void 0;
|
|
18
|
-
__exportStar(require("./file/extensions.fn"), exports);
|
|
19
|
-
var file_service_1 = require("./file/file.service");
|
|
20
|
-
Object.defineProperty(exports, "FileService", { enumerable: true, get: function () { return file_service_1.FileService; } });
|
|
21
|
-
var delete_fn_1 = require("./file/actions/delete.fn");
|
|
22
|
-
Object.defineProperty(exports, "deleteFile", { enumerable: true, get: function () { return delete_fn_1.deleteFile; } });
|
|
23
|
-
var sign_url_fn_1 = require("./file/actions/sign-url.fn");
|
|
24
|
-
Object.defineProperty(exports, "getSignedUrl", { enumerable: true, get: function () { return sign_url_fn_1.getSignedUrl; } });
|
|
25
|
-
var upload_fn_1 = require("./file/actions/upload.fn");
|
|
26
|
-
Object.defineProperty(exports, "uploadFile", { enumerable: true, get: function () { return upload_fn_1.uploadFile; } });
|
|
27
|
-
var project_access_context_1 = require("./file/project-access-context");
|
|
28
|
-
Object.defineProperty(exports, "ProjectFileAccessContext", { enumerable: true, get: function () { return project_access_context_1.ProjectFileAccessContext; } });
|
|
29
|
-
var file_object_model_1 = require("./file/file-object.model");
|
|
30
|
-
Object.defineProperty(exports, "FileSystemObjectType", { enumerable: true, get: function () { return file_object_model_1.FileSystemObjectType; } });
|
|
31
|
-
var s3_utils_1 = require("./file/util/s3-utils");
|
|
32
|
-
Object.defineProperty(exports, "s3UriToParams", { enumerable: true, get: function () { return s3_utils_1.s3UriToParams; } });
|
|
33
|
-
var s3_client_1 = require("./file/util/s3-client");
|
|
34
|
-
Object.defineProperty(exports, "createS3Client", { enumerable: true, get: function () { return s3_client_1.createS3Client; } });
|
|
35
|
-
var credentials_mutex_so_1 = require("./file/util/credentials-mutex.so");
|
|
36
|
-
Object.defineProperty(exports, "credentialsCache", { enumerable: true, get: function () { return credentials_mutex_so_1.credentialsCache; } });
|
|
37
|
-
Object.defineProperty(exports, "credentialsMutex", { enumerable: true, get: function () { return credentials_mutex_so_1.credentialsMutex; } });
|
|
38
|
-
var shared_1 = require("./file/shared");
|
|
39
|
-
Object.defineProperty(exports, "getProjectS3Bucket", { enumerable: true, get: function () { return shared_1.getProjectS3Bucket; } });
|
|
40
|
-
var calculate_size_1 = require("./file/calculate-size");
|
|
41
|
-
Object.defineProperty(exports, "calculateTotalSize", { enumerable: true, get: function () { return calculate_size_1.calculateTotalSize; } });
|
|
42
|
-
var lib_storage_1 = require("@aws-sdk/lib-storage");
|
|
43
|
-
Object.defineProperty(exports, "Upload", { enumerable: true, get: function () { return lib_storage_1.Upload; } });
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bytesToString = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Format bytes as human-readable text.
|
|
6
|
-
* @param bytes Number of bytes.
|
|
7
|
-
* @param si True to use metric(SI) units, aka powers of 1000. False to use
|
|
8
|
-
* binary(IEC), aka powers of 1024.
|
|
9
|
-
* @param dp Number of decimal places to display.
|
|
10
|
-
*
|
|
11
|
-
* @return Formatted string.
|
|
12
|
-
*/
|
|
13
|
-
function bytesToString(bytes, si = false, dp = 1) {
|
|
14
|
-
const thresh = si ? 1000 : 1024;
|
|
15
|
-
if (Math.abs(bytes) < thresh) {
|
|
16
|
-
return `${bytes} B`;
|
|
17
|
-
}
|
|
18
|
-
const units = si
|
|
19
|
-
? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
|
20
|
-
: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
|
|
21
|
-
let u = -1;
|
|
22
|
-
const r = 10 ** dp;
|
|
23
|
-
do {
|
|
24
|
-
bytes /= thresh;
|
|
25
|
-
++u;
|
|
26
|
-
} while (Math.round(Math.abs(bytes) * r) / r >= thresh
|
|
27
|
-
&& u < units.length - 1);
|
|
28
|
-
return `${bytes.toFixed(dp)} ${units[u]}`;
|
|
29
|
-
}
|
|
30
|
-
exports.bytesToString = bytesToString;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jsonPrettyPrint = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Pretty prints a JSON object with the specified indentation level.
|
|
6
|
-
* @param obj JSON object to be pretty printed.
|
|
7
|
-
* @param indentLevel Number of spaces to use for indentation.
|
|
8
|
-
*/
|
|
9
|
-
function jsonPrettyPrint(obj, indentLevel = 2) {
|
|
10
|
-
return JSON.stringify(obj, null, indentLevel);
|
|
11
|
-
}
|
|
12
|
-
exports.jsonPrettyPrint = jsonPrettyPrint;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeDate = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Normalizes a date to UTC by adjusting for the timezone offset.
|
|
6
|
-
* Useful when you are working with dates that may not include time information.
|
|
7
|
-
* @param date
|
|
8
|
-
*/
|
|
9
|
-
function normalizeDate(date) {
|
|
10
|
-
if (!date)
|
|
11
|
-
throw new Error("Attempt to normalize undefined");
|
|
12
|
-
if (!(date instanceof Date))
|
|
13
|
-
date = new Date(date);
|
|
14
|
-
return new Date(date.getTime() - date.getTimezoneOffset() * -60000);
|
|
15
|
-
}
|
|
16
|
-
exports.normalizeDate = normalizeDate;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeString = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Normalize a string by trimming it and returning null if it is empty.
|
|
6
|
-
* @param input The string to normalize.
|
|
7
|
-
*/
|
|
8
|
-
function normalizeString(input) {
|
|
9
|
-
if (!(input === null || input === void 0 ? void 0 : input.trim()))
|
|
10
|
-
return null;
|
|
11
|
-
return input.trim();
|
|
12
|
-
}
|
|
13
|
-
exports.normalizeString = normalizeString;
|
package/dist/formatters/slash.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeEndingSlash = exports.removeStartingSlash = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Removes the starting slash from a path.
|
|
6
|
-
* @param path Input path
|
|
7
|
-
*/
|
|
8
|
-
function removeStartingSlash(path) {
|
|
9
|
-
return (path === null || path === void 0 ? void 0 : path.startsWith('/')) ? path.substring(1) : path;
|
|
10
|
-
}
|
|
11
|
-
exports.removeStartingSlash = removeStartingSlash;
|
|
12
|
-
/**
|
|
13
|
-
* Removes the ending slash from a path.
|
|
14
|
-
* @param path Input path
|
|
15
|
-
*/
|
|
16
|
-
function removeEndingSlash(path) {
|
|
17
|
-
return (path === null || path === void 0 ? void 0 : path.endsWith('/')) ? path.slice(0, -1) : path;
|
|
18
|
-
}
|
|
19
|
-
exports.removeEndingSlash = removeEndingSlash;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toDateFormat = void 0;
|
|
4
|
-
const dateFormat = new Intl.DateTimeFormat('en-US', { month: '2-digit', day: '2-digit', year: '2-digit' });
|
|
5
|
-
/**
|
|
6
|
-
* Converts a date string or Date object to MM/DD/YY date string.
|
|
7
|
-
* Ex., "2023-10-01" -> "10/01/23"
|
|
8
|
-
* @param date Input date string or Date object.
|
|
9
|
-
*/
|
|
10
|
-
function toDateFormat(date) {
|
|
11
|
-
if (!date)
|
|
12
|
-
return null;
|
|
13
|
-
const d = (typeof date === 'string') ? new Date(date) : date;
|
|
14
|
-
return dateFormat.format(d);
|
|
15
|
-
}
|
|
16
|
-
exports.toDateFormat = toDateFormat;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toFriendlyName = void 0;
|
|
4
|
-
const to_title_case_1 = require("./to-title-case");
|
|
5
|
-
/**
|
|
6
|
-
* Converts a field name to a more human-readable format.
|
|
7
|
-
* Ex., "helloWorld" -> "Hello World"
|
|
8
|
-
* @param value The value to convert.
|
|
9
|
-
*/
|
|
10
|
-
function toFriendlyName(value) {
|
|
11
|
-
let _value = value.split(/(?=[A-Z])/).join(' ');
|
|
12
|
-
_value = _value.split('_').join(' ');
|
|
13
|
-
_value = _value.split('|').join(' ');
|
|
14
|
-
_value = _value.replace(/ +/g, ' ');
|
|
15
|
-
return (0, to_title_case_1.toTitleCase)(_value);
|
|
16
|
-
}
|
|
17
|
-
exports.toFriendlyName = toFriendlyName;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toMoney = void 0;
|
|
4
|
-
const money = new Intl.NumberFormat('en-US', {
|
|
5
|
-
style: 'currency',
|
|
6
|
-
currency: 'USD',
|
|
7
|
-
});
|
|
8
|
-
/**
|
|
9
|
-
* Converts a number or bigint to a formatted money string.
|
|
10
|
-
* Ex., 1234.56 -> $1,234.56
|
|
11
|
-
* @param value Input number or bigint value.
|
|
12
|
-
*/
|
|
13
|
-
function toMoney(value) {
|
|
14
|
-
return money.format(value);
|
|
15
|
-
}
|
|
16
|
-
exports.toMoney = toMoney;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toPascalCase = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Converts a string to PascalCase.
|
|
6
|
-
* Ex., "hello world" -> "HelloWorld"
|
|
7
|
-
* @param value The string to convert.
|
|
8
|
-
*/
|
|
9
|
-
function toPascalCase(value) {
|
|
10
|
-
return value.replace(/(\w)(\w*)/g, (g0, g1, g2) => g1.toUpperCase() + g2.toLowerCase());
|
|
11
|
-
}
|
|
12
|
-
exports.toPascalCase = toPascalCase;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toTitleCase = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Converts a string to Title case.
|
|
6
|
-
* Ex., "hello world" -> "Hello world"
|
|
7
|
-
* @param value
|
|
8
|
-
*/
|
|
9
|
-
function toTitleCase(value) {
|
|
10
|
-
if (!value)
|
|
11
|
-
return null;
|
|
12
|
-
return value[0].toUpperCase() + value.slice(1).toLowerCase();
|
|
13
|
-
}
|
|
14
|
-
exports.toTitleCase = toTitleCase;
|
package/dist/formatters.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toTitleCase = exports.toPascalCase = exports.toMoney = exports.toFriendlyName = exports.toDateFormat = exports.removeEndingSlash = exports.removeStartingSlash = exports.normalizeString = exports.normalizeDate = exports.bytesToString = exports.jsonPrettyPrint = void 0;
|
|
4
|
-
var json_pretty_print_1 = require("./formatters/json-pretty-print");
|
|
5
|
-
Object.defineProperty(exports, "jsonPrettyPrint", { enumerable: true, get: function () { return json_pretty_print_1.jsonPrettyPrint; } });
|
|
6
|
-
var bytes_to_string_1 = require("./formatters/bytes-to-string");
|
|
7
|
-
Object.defineProperty(exports, "bytesToString", { enumerable: true, get: function () { return bytes_to_string_1.bytesToString; } });
|
|
8
|
-
var normalize_date_1 = require("./formatters/normalize-date");
|
|
9
|
-
Object.defineProperty(exports, "normalizeDate", { enumerable: true, get: function () { return normalize_date_1.normalizeDate; } });
|
|
10
|
-
var normalize_string_1 = require("./formatters/normalize-string");
|
|
11
|
-
Object.defineProperty(exports, "normalizeString", { enumerable: true, get: function () { return normalize_string_1.normalizeString; } });
|
|
12
|
-
var slash_1 = require("./formatters/slash");
|
|
13
|
-
Object.defineProperty(exports, "removeStartingSlash", { enumerable: true, get: function () { return slash_1.removeStartingSlash; } });
|
|
14
|
-
Object.defineProperty(exports, "removeEndingSlash", { enumerable: true, get: function () { return slash_1.removeEndingSlash; } });
|
|
15
|
-
var to_date_format_1 = require("./formatters/to-date-format");
|
|
16
|
-
Object.defineProperty(exports, "toDateFormat", { enumerable: true, get: function () { return to_date_format_1.toDateFormat; } });
|
|
17
|
-
var to_friendly_name_1 = require("./formatters/to-friendly-name");
|
|
18
|
-
Object.defineProperty(exports, "toFriendlyName", { enumerable: true, get: function () { return to_friendly_name_1.toFriendlyName; } });
|
|
19
|
-
var to_money_1 = require("./formatters/to-money");
|
|
20
|
-
Object.defineProperty(exports, "toMoney", { enumerable: true, get: function () { return to_money_1.toMoney; } });
|
|
21
|
-
var to_pascal_case_1 = require("./formatters/to-pascal-case");
|
|
22
|
-
Object.defineProperty(exports, "toPascalCase", { enumerable: true, get: function () { return to_pascal_case_1.toPascalCase; } });
|
|
23
|
-
var to_title_case_1 = require("./formatters/to-title-case");
|
|
24
|
-
Object.defineProperty(exports, "toTitleCase", { enumerable: true, get: function () { return to_title_case_1.toTitleCase; } });
|
package/dist/util/download.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.downloadContent = exports.downloadBlob = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Download a blob as a file with the specified file name.
|
|
6
|
-
*/
|
|
7
|
-
function downloadBlob(blob, fileName) {
|
|
8
|
-
const url = window.URL.createObjectURL(blob);
|
|
9
|
-
const a = document.createElement('a');
|
|
10
|
-
a.href = url;
|
|
11
|
-
a.download = fileName;
|
|
12
|
-
a.click();
|
|
13
|
-
}
|
|
14
|
-
exports.downloadBlob = downloadBlob;
|
|
15
|
-
/**
|
|
16
|
-
* Downloads the specified content as a file with the specified file name and type.
|
|
17
|
-
*/
|
|
18
|
-
function downloadContent(content, fileName, fileType = 'text/plain') {
|
|
19
|
-
const blob = new Blob([content], { type: fileType });
|
|
20
|
-
downloadBlob(blob, fileName);
|
|
21
|
-
}
|
|
22
|
-
exports.downloadContent = downloadContent;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractFromObject = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Extracts a value from an object using the json path notation, i.e. $.test.id
|
|
6
|
-
* @param path JSON path to the value
|
|
7
|
-
* @param obj Object to extract the value from
|
|
8
|
-
*/
|
|
9
|
-
function extractFromObject(path, obj) {
|
|
10
|
-
const pathParts = path.slice(2).split('.');
|
|
11
|
-
return pathParts.reduce(function (o, k) {
|
|
12
|
-
return o && o[k];
|
|
13
|
-
}, obj);
|
|
14
|
-
}
|
|
15
|
-
exports.extractFromObject = extractFromObject;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.handlePromiseError = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Ignores dangling promise rejections.
|
|
6
|
-
* @param err The error to ignore.
|
|
7
|
-
*/
|
|
8
|
-
function handlePromiseError(err) {
|
|
9
|
-
console.warn(err);
|
|
10
|
-
}
|
|
11
|
-
exports.handlePromiseError = handlePromiseError;
|
package/dist/util.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.downloadContent = exports.downloadBlob = exports.handlePromiseError = exports.extractFromObject = void 0;
|
|
4
|
-
var extract_from_object_1 = require("./util/extract-from-object");
|
|
5
|
-
Object.defineProperty(exports, "extractFromObject", { enumerable: true, get: function () { return extract_from_object_1.extractFromObject; } });
|
|
6
|
-
var handle_promise_1 = require("./util/handle-promise");
|
|
7
|
-
Object.defineProperty(exports, "handlePromiseError", { enumerable: true, get: function () { return handle_promise_1.handlePromiseError; } });
|
|
8
|
-
var download_1 = require("./util/download");
|
|
9
|
-
Object.defineProperty(exports, "downloadBlob", { enumerable: true, get: function () { return download_1.downloadBlob; } });
|
|
10
|
-
Object.defineProperty(exports, "downloadContent", { enumerable: true, get: function () { return download_1.downloadContent; } });
|
package/src/api/error-handler.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Middleware, ResponseContext } from "@cirrobio/api-client";
|
|
2
|
-
|
|
3
|
-
export class ApiError extends Error {
|
|
4
|
-
errors: string[];
|
|
5
|
-
|
|
6
|
-
constructor(message: string, errors: string[]) {
|
|
7
|
-
super(message);
|
|
8
|
-
this.errors = errors;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class PortalErrorHandler implements Middleware {
|
|
13
|
-
async post(context: ResponseContext): Promise<Response | void> {
|
|
14
|
-
const { response } = context;
|
|
15
|
-
if (response && (response.status >= 200 && response.status < 300)) {
|
|
16
|
-
return response;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Handle Error
|
|
20
|
-
let errorMessage: string;
|
|
21
|
-
const errors = [];
|
|
22
|
-
try {
|
|
23
|
-
const err = await response.json();
|
|
24
|
-
console.warn(err);
|
|
25
|
-
if ('errorDetail' in err) {
|
|
26
|
-
errorMessage = err.errorDetail;
|
|
27
|
-
errors.push(err.errors.map((e: any) => e.message));
|
|
28
|
-
} else {
|
|
29
|
-
errorMessage = err.message;
|
|
30
|
-
}
|
|
31
|
-
} catch (ignore) {
|
|
32
|
-
errorMessage = "Unknown Error";
|
|
33
|
-
}
|
|
34
|
-
throw new ApiError(errorMessage, errors);
|
|
35
|
-
}
|
|
36
|
-
}
|
package/src/api.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { PortalErrorHandler, ApiError } from './api/error-handler';
|