@lark-apaas/dataloom 0.1.1-alpha.0 → 0.1.1-alpha.2
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 +812 -1
- package/lib/DataloomClient.d.ts +8 -9
- package/lib/DataloomClient.d.ts.map +1 -1
- package/lib/DataloomClient.js +12 -7
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/service/services/DataloomServiceBase.d.ts.map +1 -1
- package/lib/service/services/DataloomServiceBase.js +1 -1
- package/lib/service/services/session-service/index.d.ts.map +1 -1
- package/lib/service/services/session-service/index.js +26 -0
- package/lib/service/utils/logger.d.ts +2 -2
- package/lib/service/utils/logger.d.ts.map +1 -1
- package/lib/service/utils/types.d.ts +2 -2
- package/lib/service/utils/types.d.ts.map +1 -1
- package/lib/storage/StorageClient.d.ts +9 -2
- package/lib/storage/StorageClient.d.ts.map +1 -1
- package/lib/storage/StorageClient.js +12 -3
- package/lib/storage/libs/errors.d.ts +9 -3
- package/lib/storage/libs/errors.d.ts.map +1 -1
- package/lib/storage/libs/errors.js +3 -3
- package/lib/storage/libs/fetch.d.ts +6 -6
- package/lib/storage/libs/fetch.d.ts.map +1 -1
- package/lib/storage/libs/fetch.js +21 -2
- package/lib/storage/libs/helpers.d.ts +4 -4
- package/lib/storage/libs/helpers.d.ts.map +1 -1
- package/lib/storage/libs/helpers.js +27 -14
- package/lib/storage/libs/index.d.ts +0 -1
- package/lib/storage/libs/index.d.ts.map +1 -1
- package/lib/storage/libs/index.js +0 -1
- package/lib/storage/libs/types.d.ts +6 -5
- package/lib/storage/libs/types.d.ts.map +1 -1
- package/lib/storage/packages/StorageFileApi.d.ts +1 -1
- package/lib/storage/packages/StorageFileApi.d.ts.map +1 -1
- package/lib/storage/packages/StorageFileApi.js +6 -1
- package/lib/storage/utils/logger.d.ts +2 -2
- package/lib/storage/utils/logger.d.ts.map +1 -1
- package/lib/utils/fetch.d.ts +2 -3
- package/lib/utils/fetch.d.ts.map +1 -1
- package/lib/utils/fetch.js +4 -4
- package/lib/utils/helpers.d.ts +2 -2
- package/lib/utils/slardar.d.ts +2 -0
- package/lib/utils/slardar.d.ts.map +1 -0
- package/lib/utils/slardar.js +15 -0
- package/lib/utils/types.d.ts +4 -3
- package/lib/utils/types.d.ts.map +1 -1
- package/package.json +4 -1
- package/lib/storage/packages/StorageBucketApi.d.ts +0 -121
- package/lib/storage/packages/StorageBucketApi.d.ts.map +0 -1
- package/lib/storage/packages/StorageBucketApi.js +0 -135
package/lib/DataloomClient.d.ts
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
import RateLimiter from './RateLimiter';
|
|
2
2
|
import DataloomService from './service';
|
|
3
3
|
import { StorageClient } from './storage';
|
|
4
|
-
import type {
|
|
4
|
+
import type { DataloomClientOptions, Fetch } from './utils/types';
|
|
5
|
+
import type { OnRequestErrorType } from './service/utils/types';
|
|
5
6
|
/**
|
|
6
7
|
* Dataloom Client.
|
|
7
8
|
*
|
|
8
9
|
* An isomorphic Javascript client for interacting with Dataloom service and storage.
|
|
9
10
|
*/
|
|
10
11
|
export default class DataloomClient {
|
|
11
|
-
protected
|
|
12
|
-
protected
|
|
13
|
-
protected workspaceId: string;
|
|
12
|
+
protected dataloomUrl: string;
|
|
13
|
+
protected dataloomKey: string;
|
|
14
14
|
service: DataloomService;
|
|
15
15
|
storage: StorageClient;
|
|
16
16
|
protected storageUrl: string;
|
|
17
17
|
protected fetch?: Fetch;
|
|
18
18
|
protected rateLimiter?: RateLimiter;
|
|
19
|
-
protected onRequestError: (error:
|
|
19
|
+
protected onRequestError: (error: OnRequestErrorType) => void;
|
|
20
20
|
protected headers: Record<string, string>;
|
|
21
21
|
/**
|
|
22
22
|
* Create a new client for use in the browser.
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
25
|
-
* @param workspaceId The unique workspace id which is supplied when you create a new workspace.
|
|
23
|
+
* @param dataloomUrl The unique Dataloom URL which is supplied when you create a new project.
|
|
24
|
+
* @param dataloomKey The unique Dataloom Key which is supplied when you create a new project.
|
|
26
25
|
* @param options.global.fetch A custom fetch implementation.
|
|
27
26
|
* @param options.global.headers Any additional headers to send with each network request.
|
|
28
27
|
*/
|
|
29
|
-
constructor(
|
|
28
|
+
constructor(dataloomUrl: string, dataloomKey: string, options?: DataloomClientOptions);
|
|
30
29
|
}
|
|
31
30
|
//# sourceMappingURL=DataloomClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataloomClient.d.ts","sourceRoot":"","sources":["../src/DataloomClient.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,eAAe,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"DataloomClient.d.ts","sourceRoot":"","sources":["../src/DataloomClient.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,eAAe,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAK1C,OAAO,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,cAAc;IAmB/B,SAAS,CAAC,WAAW,EAAE,MAAM;IAC7B,SAAS,CAAC,WAAW,EAAE,MAAM;IAnB/B,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,EAAE,aAAa,CAAC;IAEvB,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACxB,SAAS,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACpC,SAAS,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAE9D,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE1C;;;;;;OAMG;gBAES,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EAC7B,OAAO,CAAC,EAAE,qBAAqB;CA0DlC"}
|
package/lib/DataloomClient.js
CHANGED
|
@@ -4,23 +4,28 @@ import { StorageClient } from "./storage/index.js";
|
|
|
4
4
|
import { DEFAULT_GLOBAL_OPTIONS } from "./utils/constants.js";
|
|
5
5
|
import { fetchWithAuth } from "./utils/fetch.js";
|
|
6
6
|
import { applySettingDefaults, stripTrailingSlash } from "./utils/helpers.js";
|
|
7
|
+
import { reportDataloomException } from "./utils/slardar.js";
|
|
7
8
|
class DataloomClient {
|
|
8
|
-
constructor(
|
|
9
|
-
this.
|
|
10
|
-
this.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.storageUrl = `${_supabaseUrl}/storage`;
|
|
9
|
+
constructor(dataloomUrl, dataloomKey, options){
|
|
10
|
+
this.dataloomUrl = dataloomUrl;
|
|
11
|
+
this.dataloomKey = dataloomKey;
|
|
12
|
+
const normalizedDataloomUrl = stripTrailingSlash(dataloomUrl);
|
|
13
|
+
this.storageUrl = `${normalizedDataloomUrl}/storage`;
|
|
14
14
|
const DEFAULTS = {
|
|
15
15
|
global: DEFAULT_GLOBAL_OPTIONS
|
|
16
16
|
};
|
|
17
17
|
const settings = applySettingDefaults(options ?? {}, DEFAULTS);
|
|
18
18
|
this.headers = settings.global.headers ?? {};
|
|
19
19
|
this.onRequestError = (error)=>{
|
|
20
|
+
reportDataloomException(error, {
|
|
21
|
+
module: 'client',
|
|
22
|
+
phase: 'request',
|
|
23
|
+
appId: settings.global.appId
|
|
24
|
+
});
|
|
20
25
|
if (settings.global.onError) settings.global.onError(error, this);
|
|
21
26
|
};
|
|
22
27
|
if (settings.global.requestRateLimit && settings.global.requestRateLimit > 0) this.rateLimiter = new RateLimiter(settings.global.requestRateLimit);
|
|
23
|
-
this.fetch = fetchWithAuth(
|
|
28
|
+
this.fetch = fetchWithAuth(dataloomKey, this.rateLimiter, settings.global.fetch);
|
|
24
29
|
this.service = new service({
|
|
25
30
|
headers: this.headers,
|
|
26
31
|
fetch: this.fetch,
|
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import DataloomClient from './DataloomClient';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DataloomClientOptions } from './utils/types';
|
|
3
3
|
export { default as DataloomClient } from './DataloomClient';
|
|
4
|
-
export type {
|
|
4
|
+
export type { DataloomClientOptions } from './utils/types';
|
|
5
5
|
/**
|
|
6
6
|
* Creates a new Dataloom Client.
|
|
7
7
|
*/
|
|
8
|
-
export declare const createClient: (dataloomUrl: string, dataloomKey: string,
|
|
8
|
+
export declare const createClient: (dataloomUrl: string, dataloomKey: string, options?: DataloomClientOptions) => DataloomClient;
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,YAAY,GACvB,aAAa,MAAM,EACnB,aAAa,MAAM,EACnB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,YAAY,GACvB,aAAa,MAAM,EACnB,aAAa,MAAM,EACnB,UAAU,qBAAqB,KAC9B,cAEF,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import DataloomClient from "./DataloomClient.js";
|
|
2
|
-
const createClient = (dataloomUrl, dataloomKey,
|
|
2
|
+
const createClient = (dataloomUrl, dataloomKey, options)=>new DataloomClient(dataloomUrl, dataloomKey, options);
|
|
3
3
|
export { DataloomClient, createClient };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataloomServiceBase.d.ts","sourceRoot":"","sources":["../../../src/service/services/DataloomServiceBase.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,mBAAmB;IAC/C,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC7C,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;IACvB,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,WAAW,EAAE,WAAW,CAAC;IACnC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI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1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/service/services/session-service/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/service/services/session-service/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,mBAAmB,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAGV,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAcjB,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,mBAAmB;IACpD,WAAW,cAA8B;IAElD;;OAEG;IACH,eAAe,CACb,OAAO,CAAC,EAAE,wBAAwB,GACjC,uBAAuB,CAAC,SAAS,CAAC;IAsCrC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC;IAyBvD;;OAEG;IACH,mBAAmB,IAAI,MAAM;IAkB7B;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,CAAC;IAuDvE;;OAEG;IACH,qBAAqB,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE;;;;;;;;;;;;;;;;CA+BrD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isBrowser } from "../../utils/helpers.js";
|
|
2
2
|
import { ServiceName } from "../../utils/types.js";
|
|
3
|
+
import { reportDataloomException } from "../../../utils/slardar.js";
|
|
3
4
|
import DataloomServiceBase from "../DataloomServiceBase.js";
|
|
4
5
|
const browserEnvError = {
|
|
5
6
|
data: null,
|
|
@@ -15,6 +16,11 @@ const browserEnvError = {
|
|
|
15
16
|
class SessionService extends DataloomServiceBase {
|
|
16
17
|
redirectToLogin(options) {
|
|
17
18
|
if (!isBrowser()) {
|
|
19
|
+
reportDataloomException(browserEnvError.error, {
|
|
20
|
+
module: 'session-service',
|
|
21
|
+
method: 'redirectToLogin',
|
|
22
|
+
type: 'runtime'
|
|
23
|
+
});
|
|
18
24
|
console.log('[Dataloom][SessionService.RedirectToLogin] dataloom.service.session.redirectToLogin can only be invoked in browser environment.');
|
|
19
25
|
return browserEnvError;
|
|
20
26
|
}
|
|
@@ -34,6 +40,11 @@ class SessionService extends DataloomServiceBase {
|
|
|
34
40
|
}
|
|
35
41
|
async signOut() {
|
|
36
42
|
if (!isBrowser()) {
|
|
43
|
+
reportDataloomException(browserEnvError.error, {
|
|
44
|
+
module: 'session-service',
|
|
45
|
+
method: 'signOut',
|
|
46
|
+
type: 'runtime'
|
|
47
|
+
});
|
|
37
48
|
console.log('[Dataloom][SessionService.SignOut] dataloom.service.session.signOut can only be invoked in browser environment.');
|
|
38
49
|
return browserEnvError;
|
|
39
50
|
}
|
|
@@ -48,6 +59,11 @@ class SessionService extends DataloomServiceBase {
|
|
|
48
59
|
}
|
|
49
60
|
getUrlWithBizSource() {
|
|
50
61
|
if (!isBrowser()) {
|
|
62
|
+
reportDataloomException(browserEnvError.error, {
|
|
63
|
+
module: 'session-service',
|
|
64
|
+
method: 'getUrlWithBizSource',
|
|
65
|
+
type: 'runtime'
|
|
66
|
+
});
|
|
51
67
|
console.log('[Dataloom][SessionService.GetUrlWithBizSource] dataloom.service.session.getUrlWithBizSource can only be invoked in browser environment.');
|
|
52
68
|
return '';
|
|
53
69
|
}
|
|
@@ -57,6 +73,11 @@ class SessionService extends DataloomServiceBase {
|
|
|
57
73
|
}
|
|
58
74
|
async getUserInfo() {
|
|
59
75
|
if (!isBrowser()) {
|
|
76
|
+
reportDataloomException(browserEnvError.error, {
|
|
77
|
+
module: 'session-service',
|
|
78
|
+
method: 'getUserInfo',
|
|
79
|
+
type: 'runtime'
|
|
80
|
+
});
|
|
60
81
|
console.log('[Dataloom][SessionService.GetUserInfo] dataloom.service.session.getUserInfo can only be invoked in browser environment.');
|
|
61
82
|
return Promise.resolve(browserEnvError);
|
|
62
83
|
}
|
|
@@ -89,6 +110,11 @@ class SessionService extends DataloomServiceBase {
|
|
|
89
110
|
}
|
|
90
111
|
navigateToUserProfile(options) {
|
|
91
112
|
if (!isBrowser()) {
|
|
113
|
+
reportDataloomException(browserEnvError.error, {
|
|
114
|
+
module: 'session-service',
|
|
115
|
+
method: 'navigateToUserProfile',
|
|
116
|
+
type: 'runtime'
|
|
117
|
+
});
|
|
92
118
|
console.log('[Dataloom][SessionService.NavigateToUserProfile] dataloom.service.session.navigateToUserProfile can only be invoked in browser environment.');
|
|
93
119
|
return browserEnvError;
|
|
94
120
|
}
|
|
@@ -7,8 +7,8 @@ type LogParams = {
|
|
|
7
7
|
};
|
|
8
8
|
export declare const logRequest: (params: LogParams, psmName?: string) => void;
|
|
9
9
|
export declare const logResponse: (traceId: number, response: {
|
|
10
|
-
data:
|
|
11
|
-
error:
|
|
10
|
+
data: unknown;
|
|
11
|
+
error: unknown;
|
|
12
12
|
status: number;
|
|
13
13
|
}, psmName?: string) => void;
|
|
14
14
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/service/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,KAAK,SAAS,GAAG;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,QAAQ,SAAS,EAAE,UAAS,MAAkB,SAwBxE,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/service/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,KAAK,SAAS,GAAG;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,QAAQ,SAAS,EAAE,UAAS,MAAkB,SAwBxE,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,SAAS,MAAM,EACf,UAAU;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC3D,UAAS,MAAkB,SA0B5B,CAAC"}
|
|
@@ -3,11 +3,11 @@ export declare enum ServiceName {
|
|
|
3
3
|
UserService = "user-service",
|
|
4
4
|
SessionService = "session-service"
|
|
5
5
|
}
|
|
6
|
-
export type Fetch =
|
|
6
|
+
export type Fetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
7
7
|
export type FetchMethod = 'GET' | 'HEAD' | 'POST' | 'PATCH' | 'DELETE';
|
|
8
8
|
export type FetchOptions = {
|
|
9
9
|
method: FetchMethod;
|
|
10
|
-
body?:
|
|
10
|
+
body?: unknown;
|
|
11
11
|
};
|
|
12
12
|
export interface ExtraInfo {
|
|
13
13
|
psmName?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/service/utils/types.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,OAAO,YAAY;IACnB,WAAW,iBAAiB;IAC5B,cAAc,oBAAoB;CACnC;AAED,MAAM,MAAM,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot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WAAW,sBAAsB,CAAC,CAAC,CAAE,SAAQ,mBAAmB;IACpE,KAAK,EAAE,IAAI,CAAC;IACZ,IAAI,EAAE,CAAC,CAAC;CACT;AACD,MAAM,WAAW,sBAAuB,SAAQ,mBAAmB;IACjE,KAAK,EAAE,oBAAoB,CAAC;IAC5B,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,MAAM,uBAAuB,CAAC,CAAC,IACjC,sBAAsB,CAAC,CAAC,CAAC,GACzB,sBAAsB,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Fetch } from './libs/fetch';
|
|
2
2
|
import type { OnRequestErrorType } from './libs/types';
|
|
3
|
-
import StorageBucketApi from './packages/StorageBucketApi';
|
|
4
3
|
import StorageFileApi from './packages/StorageFileApi';
|
|
5
4
|
export interface StorageClientOptions {
|
|
6
5
|
useNewHostname?: boolean;
|
|
@@ -8,7 +7,15 @@ export interface StorageClientOptions {
|
|
|
8
7
|
appId?: string;
|
|
9
8
|
onRequestError: (error: OnRequestErrorType) => void;
|
|
10
9
|
}
|
|
11
|
-
export declare class StorageClient
|
|
10
|
+
export declare class StorageClient {
|
|
11
|
+
protected url: string;
|
|
12
|
+
protected headers: {
|
|
13
|
+
[key: string]: string;
|
|
14
|
+
};
|
|
15
|
+
protected appId?: string;
|
|
16
|
+
protected fetch: Fetch;
|
|
17
|
+
protected loggerEnabled?: boolean;
|
|
18
|
+
protected onRequestError?: (error: OnRequestErrorType) => void;
|
|
12
19
|
constructor(url: string, headers?: {
|
|
13
20
|
[key: string]: string;
|
|
14
21
|
}, fetch?: Fetch, opts?: StorageClientOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageClient.d.ts","sourceRoot":"","sources":["../../src/storage/StorageClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"StorageClient.d.ts","sourceRoot":"","sources":["../../src/storage/StorageClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,cAAc,MAAM,2BAA2B,CAAC;AAEvD,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACrD;AAED,qBAAa,aAAa;IACxB,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC7C,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;IACvB,SAAS,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IAClC,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;gBAG7D,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAO,EACvC,KAAK,CAAC,EAAE,KAAK,EACb,IAAI,CAAC,EAAE,oBAAoB;IAa7B;;;;OAIG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc;CAWjC"}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DEFAULT_HEADERS } from "./libs/constants.js";
|
|
2
|
+
import { resolveFetch } from "./libs/helpers.js";
|
|
2
3
|
import StorageFileApi from "./packages/StorageFileApi.js";
|
|
3
|
-
class StorageClient
|
|
4
|
+
class StorageClient {
|
|
4
5
|
constructor(url, headers = {}, fetch, opts){
|
|
5
|
-
|
|
6
|
+
this.url = url;
|
|
7
|
+
this.headers = {
|
|
8
|
+
...DEFAULT_HEADERS,
|
|
9
|
+
...headers
|
|
10
|
+
};
|
|
11
|
+
this.fetch = resolveFetch(fetch);
|
|
12
|
+
this.onRequestError = opts?.onRequestError;
|
|
13
|
+
this.appId = opts?.appId;
|
|
14
|
+
if (opts?.enableLogger) this.loggerEnabled = true;
|
|
6
15
|
}
|
|
7
16
|
from(id) {
|
|
8
17
|
return new StorageFileApi(this.url, this.headers, id, this.appId, this.fetch, this.loggerEnabled, this.onRequestError);
|
|
@@ -18,7 +18,13 @@ export declare class StorageUnknownError extends StorageError {
|
|
|
18
18
|
originalError: unknown;
|
|
19
19
|
constructor(message: string, originalError: unknown);
|
|
20
20
|
}
|
|
21
|
-
export declare const isServerCustomError: (res:
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
export declare const isServerCustomError: (res: {
|
|
22
|
+
headers?: Headers;
|
|
23
|
+
error_msg?: unknown;
|
|
24
|
+
} | null | undefined, noResolveJson?: boolean) => unknown;
|
|
25
|
+
export declare const isSdkRateLimited: (res: {
|
|
26
|
+
status?: unknown;
|
|
27
|
+
statusText?: unknown;
|
|
28
|
+
} | null | undefined) => boolean;
|
|
29
|
+
export declare const isCustomError: (res: unknown) => {};
|
|
24
30
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/storage/libs/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;IACrC,SAAS,CAAC,gBAAgB,UAAQ;gBAEtB,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAIpE;AAED,qBAAa,eAAgB,SAAQ,YAAY;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAO/D,MAAM;;;;;;CAQP;AAED,qBAAa,mBAAoB,SAAQ,YAAY;IACnD,aAAa,EAAE,OAAO,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO;CAKpD;AAED,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/storage/libs/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;IACrC,SAAS,CAAC,gBAAgB,UAAQ;gBAEtB,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAIpE;AAED,qBAAa,eAAgB,SAAQ,YAAY;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAO/D,MAAM;;;;;;CAQP;AAED,qBAAa,mBAAoB,SAAQ,YAAY;IACnD,aAAa,EAAE,OAAO,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO;CAKpD;AAED,eAAO,MAAM,mBAAmB,GAC9B,KAAK;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,EAClE,gBAAgB,OAAO,YAOxB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,KAAK;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,YAGnE,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,KAAK,OAAO,OAOzC,CAAC"}
|
|
@@ -31,9 +31,9 @@ class StorageUnknownError extends StorageError {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
const isServerCustomError = (res, noResolveJson)=>{
|
|
34
|
-
if (noResolveJson &&
|
|
35
|
-
return res
|
|
34
|
+
if (noResolveJson && res?.headers?.get('server') !== 'TosServer') return true;
|
|
35
|
+
return res?.error_msg;
|
|
36
36
|
};
|
|
37
|
-
const isSdkRateLimited = (res)=>
|
|
37
|
+
const isSdkRateLimited = (res)=>res?.status === 429 && res?.statusText === 'Too Many Requests';
|
|
38
38
|
const isCustomError = (res)=>isServerCustomError(res) || isSdkRateLimited(res);
|
|
39
39
|
export { StorageApiError, StorageError, StorageUnknownError, isCustomError, isSdkRateLimited, isServerCustomError, isStorageError };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FetchParameters, OnRequestErrorType } from './types';
|
|
2
|
-
export type Fetch =
|
|
2
|
+
export type Fetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
3
3
|
export interface FetchOptions {
|
|
4
4
|
headers?: {
|
|
5
5
|
[key: string]: string;
|
|
@@ -16,9 +16,9 @@ export interface ExtraInfo {
|
|
|
16
16
|
psmName?: string;
|
|
17
17
|
}
|
|
18
18
|
export type RequestMethodType = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD';
|
|
19
|
-
export declare function get(fetcher: Fetch, url: string, options?: FetchOptions, parameters?: FetchParameters, extras?: ExtraInfo): Promise<
|
|
20
|
-
export declare function post(fetcher: Fetch, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters, extras?: ExtraInfo): Promise<
|
|
21
|
-
export declare function put(fetcher: Fetch, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters, extras?: ExtraInfo): Promise<
|
|
22
|
-
export declare function head(fetcher: Fetch, url: string, options?: FetchOptions, parameters?: FetchParameters, extras?: ExtraInfo): Promise<
|
|
23
|
-
export declare function remove(fetcher: Fetch, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters, extras?: ExtraInfo): Promise<
|
|
19
|
+
export declare function get(fetcher: Fetch, url: string, options?: FetchOptions, parameters?: FetchParameters, extras?: ExtraInfo): Promise<unknown>;
|
|
20
|
+
export declare function post(fetcher: Fetch, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters, extras?: ExtraInfo): Promise<unknown>;
|
|
21
|
+
export declare function put(fetcher: Fetch, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters, extras?: ExtraInfo): Promise<unknown>;
|
|
22
|
+
export declare function head(fetcher: Fetch, url: string, options?: FetchOptions, parameters?: FetchParameters, extras?: ExtraInfo): Promise<unknown>;
|
|
23
|
+
export declare function remove(fetcher: Fetch, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters, extras?: ExtraInfo): Promise<unknown>;
|
|
24
24
|
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/storage/libs/fetch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/storage/libs/fetch.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEnE,MAAM,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAExF,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE;QACR,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;IACF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACtD;AAED,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,OAAO,CAAC,E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|
2
2
|
import { traceIdGenerator } from "../utils/trace-id.js";
|
|
3
|
+
import { reportDataloomException } from "../../utils/slardar.js";
|
|
3
4
|
import { StorageApiError, StorageUnknownError, isSdkRateLimited, isServerCustomError } from "./errors.js";
|
|
4
5
|
import { isPlainObject, resolveResponse } from "./helpers.js";
|
|
5
|
-
const _getErrorMessage = (err)=>
|
|
6
|
+
const _getErrorMessage = (err)=>{
|
|
7
|
+
if ('object' == typeof err && null !== err) {
|
|
8
|
+
const candidate = err;
|
|
9
|
+
return String(candidate.msg ?? candidate.message ?? candidate.error_description ?? candidate.error ?? JSON.stringify(err));
|
|
10
|
+
}
|
|
11
|
+
return String(err);
|
|
12
|
+
};
|
|
6
13
|
const handleError = async (error, reject, options)=>{
|
|
7
14
|
const Res = await resolveResponse();
|
|
8
15
|
if (isSdkRateLimited(error)) {
|
|
@@ -32,9 +39,21 @@ const handleError = async (error, reject, options)=>{
|
|
|
32
39
|
});
|
|
33
40
|
reject(new StorageApiError(_getErrorMessage(err), status, statusCode));
|
|
34
41
|
}).catch((err)=>{
|
|
42
|
+
reportDataloomException(err, {
|
|
43
|
+
module: 'storage-fetch',
|
|
44
|
+
phase: 'response-json-parse',
|
|
45
|
+
type: 'unknown'
|
|
46
|
+
});
|
|
35
47
|
reject(new StorageUnknownError(_getErrorMessage(err), err));
|
|
36
48
|
});
|
|
37
|
-
else
|
|
49
|
+
else {
|
|
50
|
+
reportDataloomException(error, {
|
|
51
|
+
module: 'storage-fetch',
|
|
52
|
+
phase: 'request',
|
|
53
|
+
type: 'unknown'
|
|
54
|
+
});
|
|
55
|
+
reject(new StorageUnknownError(_getErrorMessage(error), error));
|
|
56
|
+
}
|
|
38
57
|
};
|
|
39
58
|
const _getRequestParams = (method, options, parameters, body)=>{
|
|
40
59
|
const params = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { FileBody } from './types';
|
|
2
|
-
type Fetch =
|
|
1
|
+
import type { FileBody, FileObject } from './types';
|
|
2
|
+
type Fetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
3
3
|
export declare const resolveFetch: (customFetch?: Fetch) => Fetch;
|
|
4
4
|
export declare const resolveResponse: () => Promise<typeof Response>;
|
|
5
|
-
export declare const recursiveToCamel: (item: Record<string,
|
|
5
|
+
export declare const recursiveToCamel: (item: Record<string, unknown>) => unknown;
|
|
6
6
|
/**
|
|
7
7
|
* Determine if input is a plain object
|
|
8
8
|
* An object is plain if it's created by either {}, new Object(), or Object.create(null)
|
|
@@ -11,7 +11,7 @@ export declare const recursiveToCamel: (item: Record<string, any>) => unknown;
|
|
|
11
11
|
export declare const isPlainObject: (value: object) => boolean;
|
|
12
12
|
export declare const getUpdateFileSize: (file: FileBody) => string;
|
|
13
13
|
export declare const toValidExpiresIn: (expiresIn: number) => number;
|
|
14
|
-
export declare const transformFilePayload: (file:
|
|
14
|
+
export declare const transformFilePayload: (file: Record<string, unknown> | null | undefined) => FileObject;
|
|
15
15
|
export declare const sanitizeFileName: (fileName: string) => string;
|
|
16
16
|
export declare const checkIsVolcEngineUrl: (url: string) => boolean;
|
|
17
17
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/storage/libs/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/storage/libs/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAIpD,KAAK,KAAK,GAAG,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEjF,eAAO,MAAM,YAAY,GAAI,cAAc,KAAK,KAAG,KAQlD,CAAC;AAEF,eAAO,MAAM,eAAe,QAAa,OAAO,CAAC,OAAO,QAAQ,CAE/D,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,OAmBhE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,KAAG,OAa7C,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,MAAM,QAAQ,KAAG,MAqBlD,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,WAAW,MAAM,WAQjD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,KAC9C,UA8BH,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,WAMhD,CAAC;AAKF,eAAO,MAAM,oBAAoB,GAAI,KAAK,MAAM,YAE/C,CAAC"}
|
|
@@ -2,7 +2,7 @@ const THIRTY_DAYS_IN_SECONDS = 2592000;
|
|
|
2
2
|
const resolveFetch = (customFetch)=>{
|
|
3
3
|
let _fetch;
|
|
4
4
|
_fetch = customFetch ? customFetch : fetch;
|
|
5
|
-
return (
|
|
5
|
+
return (input, init)=>_fetch(input, init);
|
|
6
6
|
};
|
|
7
7
|
const resolveResponse = async ()=>Response;
|
|
8
8
|
const recursiveToCamel = (item)=>{
|
|
@@ -11,7 +11,7 @@ const recursiveToCamel = (item)=>{
|
|
|
11
11
|
const result = {};
|
|
12
12
|
Object.entries(item).forEach(([key, value])=>{
|
|
13
13
|
const newKey = key.replace(/([-_][a-z])/gi, (c)=>c.toUpperCase().replace(/[-_]/g, ''));
|
|
14
|
-
result[newKey] = recursiveToCamel(value);
|
|
14
|
+
result[newKey] = 'object' == typeof value && null !== value ? recursiveToCamel(value) : value;
|
|
15
15
|
});
|
|
16
16
|
return result;
|
|
17
17
|
};
|
|
@@ -34,20 +34,33 @@ const toValidExpiresIn = (expiresIn)=>{
|
|
|
34
34
|
if (expiresIn > THIRTY_DAYS_IN_SECONDS) return THIRTY_DAYS_IN_SECONDS;
|
|
35
35
|
return expiresIn;
|
|
36
36
|
};
|
|
37
|
-
const transformFilePayload = (file)=>
|
|
38
|
-
|
|
37
|
+
const transformFilePayload = (file)=>{
|
|
38
|
+
const safeFile = file ?? {};
|
|
39
|
+
const buckets = safeFile.buckets;
|
|
40
|
+
return {
|
|
41
|
+
name: safeFile.name ?? '',
|
|
42
|
+
bucket_id: safeFile.bucket_id ?? '',
|
|
43
|
+
owner: safeFile.owner ?? '',
|
|
44
|
+
id: safeFile.id ?? '',
|
|
45
|
+
updated_at: safeFile.updated_at ?? '',
|
|
46
|
+
created_at: safeFile.created_at ?? '',
|
|
47
|
+
created_by: safeFile.created_by ?? '',
|
|
48
|
+
updated_by: safeFile.updated_by ?? '',
|
|
49
|
+
last_accessed_at: safeFile.last_accessed_at,
|
|
50
|
+
metadata: safeFile.metadata ?? {},
|
|
39
51
|
buckets: {
|
|
40
|
-
allowed_mime_types:
|
|
41
|
-
created_at:
|
|
42
|
-
file_size_limit:
|
|
43
|
-
id:
|
|
44
|
-
name:
|
|
45
|
-
public:
|
|
46
|
-
updated_at:
|
|
47
|
-
updated_by:
|
|
48
|
-
owner:
|
|
52
|
+
allowed_mime_types: buckets?.allowed_mime_types ?? [],
|
|
53
|
+
created_at: buckets?.created_at ?? '',
|
|
54
|
+
file_size_limit: buckets?.file_size_limit ?? 0,
|
|
55
|
+
id: buckets?.id ?? '',
|
|
56
|
+
name: buckets?.name ?? '',
|
|
57
|
+
public: buckets?.public ?? false,
|
|
58
|
+
updated_at: buckets?.updated_at ?? '',
|
|
59
|
+
updated_by: buckets?.updated_by ?? '',
|
|
60
|
+
owner: buckets?.created_by ?? ''
|
|
49
61
|
}
|
|
50
|
-
}
|
|
62
|
+
};
|
|
63
|
+
};
|
|
51
64
|
const sanitizeFileName = (fileName)=>{
|
|
52
65
|
const illegalChars = /[\x00-\x1F\x7F:"\\/*?<>|,;]/g;
|
|
53
66
|
return encodeURIComponent(fileName.replace(illegalChars, '')) || 'download_file';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/libs/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/libs/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
|
|
@@ -14,6 +14,7 @@ export interface Bucket {
|
|
|
14
14
|
type?: BucketType;
|
|
15
15
|
name: string;
|
|
16
16
|
owner: string;
|
|
17
|
+
updated_by?: string;
|
|
17
18
|
file_size_limit?: number;
|
|
18
19
|
allowed_mime_types?: string[];
|
|
19
20
|
created_at: string;
|
|
@@ -43,7 +44,7 @@ export interface FileObject {
|
|
|
43
44
|
created_by: string;
|
|
44
45
|
updated_by: string;
|
|
45
46
|
last_accessed_at?: string;
|
|
46
|
-
metadata: Record<string,
|
|
47
|
+
metadata: Record<string, unknown>;
|
|
47
48
|
buckets: Bucket;
|
|
48
49
|
}
|
|
49
50
|
export interface FileObjectV2 {
|
|
@@ -59,7 +60,7 @@ export interface FileObjectV2 {
|
|
|
59
60
|
content_type?: string;
|
|
60
61
|
etag?: string;
|
|
61
62
|
last_modified?: string;
|
|
62
|
-
metadata?: Record<string,
|
|
63
|
+
metadata?: Record<string, unknown>;
|
|
63
64
|
}
|
|
64
65
|
export interface SortBy {
|
|
65
66
|
column?: string;
|
|
@@ -67,7 +68,7 @@ export interface SortBy {
|
|
|
67
68
|
}
|
|
68
69
|
export interface FileOptions {
|
|
69
70
|
/**
|
|
70
|
-
* The number of seconds the asset is cached in the browser and in the
|
|
71
|
+
* The number of seconds the asset is cached in the browser and in the Dataloom CDN. This is set in the `Cache-Control: max-age=<seconds>` header. Defaults to 3600 seconds.
|
|
71
72
|
*/
|
|
72
73
|
cacheControl?: string | number;
|
|
73
74
|
/**
|
|
@@ -85,7 +86,7 @@ export interface FileOptions {
|
|
|
85
86
|
/**
|
|
86
87
|
* The metadata option is an object that allows you to store additional information about the file. This information can be used to filter and search for files. The metadata object can contain any key-value pairs you want to store.
|
|
87
88
|
*/
|
|
88
|
-
metadata?: Record<string,
|
|
89
|
+
metadata?: Record<string, unknown>;
|
|
89
90
|
/**
|
|
90
91
|
* Optionally add extra headers
|
|
91
92
|
*/
|
|
@@ -97,7 +98,7 @@ export interface FileOptionsV2 {
|
|
|
97
98
|
*/
|
|
98
99
|
filePath?: string;
|
|
99
100
|
/**
|
|
100
|
-
* The number of seconds the asset is cached in the browser and in the
|
|
101
|
+
* The number of seconds the asset is cached in the browser and in the Dataloom CDN. This is set in the `Cache-Control: max-age=<seconds>` header.
|
|
101
102
|
*/
|
|
102
103
|
cacheControl?: string | number;
|
|
103
104
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/storage/libs/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,GAAG;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,WAAW,CAAC;AAElD,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,UAAU,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,IAC7B,CAAC,SAAS,GAAG,MAAM,EAAE,IAAI,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,GAC1C,GAAG,SAAS,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE,GAClD,CAAC,CAAC;AAER,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KACvB,CAAC,IAAI,MAAM,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,QAAQ,GAChB,WAAW,GACX,eAAe,GACf,IAAI,GACJ,IAAI,GACJ,QAAQ,GACR,cAAc,CAAC,UAAU,CAAC,GAC1B,eAAe,GACf,MAAM,CAAC"}
|
|
@@ -171,7 +171,7 @@ export default class StorageFileApi {
|
|
|
171
171
|
error: StorageError;
|
|
172
172
|
}>;
|
|
173
173
|
generateDownloadUrlFromFilePath(filePath: string): string;
|
|
174
|
-
protected encodeMetadata(metadata: Record<string,
|
|
174
|
+
protected encodeMetadata(metadata: Record<string, unknown>): string;
|
|
175
175
|
toBase64(data: string): string;
|
|
176
176
|
private _getFinalPath;
|
|
177
177
|
private _removeEmptyFolders;
|