@aidc-toolkit/core 1.0.32-beta → 1.0.33-beta
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 +98 -87
- package/dist/app-data-storage.d.ts +118 -0
- package/dist/app-data-storage.d.ts.map +1 -0
- package/dist/app-data-storage.js +117 -0
- package/dist/app-data-storage.js.map +1 -0
- package/dist/app-data.d.ts +26 -0
- package/dist/app-data.d.ts.map +1 -0
- package/dist/app-data.js +79 -0
- package/dist/app-data.js.map +1 -0
- package/dist/browser-app-data-storage.d.ts +26 -0
- package/dist/browser-app-data-storage.d.ts.map +1 -0
- package/dist/browser-app-data-storage.js +34 -0
- package/dist/browser-app-data-storage.js.map +1 -0
- package/dist/file-app-data-storage.d.ts +26 -0
- package/dist/file-app-data-storage.d.ts.map +1 -0
- package/dist/file-app-data-storage.js +40 -0
- package/dist/file-app-data-storage.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/local-app-data-storage.d.ts +8 -0
- package/dist/local-app-data-storage.d.ts.map +1 -0
- package/dist/local-app-data-storage.js +11 -0
- package/dist/local-app-data-storage.js.map +1 -0
- package/dist/locale/en/locale-resources.d.ts +3 -0
- package/dist/locale/en/locale-resources.d.ts.map +1 -1
- package/dist/locale/en/locale-resources.js +3 -0
- package/dist/locale/en/locale-resources.js.map +1 -1
- package/dist/locale/fr/locale-resources.d.ts +3 -0
- package/dist/locale/fr/locale-resources.d.ts.map +1 -1
- package/dist/locale/fr/locale-resources.js +3 -0
- package/dist/locale/fr/locale-resources.js.map +1 -1
- package/dist/locale/i18n.d.ts +22 -13
- package/dist/locale/i18n.d.ts.map +1 -1
- package/dist/locale/i18n.js +62 -43
- package/dist/locale/i18n.js.map +1 -1
- package/dist/logger.d.ts +4 -2
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +9 -3
- package/dist/logger.js.map +1 -1
- package/dist/remote-app-data-storage.d.ts +18 -0
- package/dist/remote-app-data-storage.d.ts.map +1 -0
- package/dist/remote-app-data-storage.js +37 -0
- package/dist/remote-app-data-storage.js.map +1 -0
- package/dist/type-helper.js.map +1 -1
- package/package.json +9 -7
- package/src/app-data-storage.ts +166 -0
- package/src/app-data.ts +94 -0
- package/src/browser-app-data-storage.ts +37 -0
- package/src/file-app-data-storage.ts +49 -0
- package/src/index.ts +5 -0
- package/src/local-app-data-storage.ts +12 -0
- package/src/locale/en/locale-resources.ts +3 -0
- package/src/locale/fr/locale-resources.ts +3 -0
- package/src/locale/i18n.ts +81 -49
- package/src/logger.ts +10 -3
- package/src/remote-app-data-storage.ts +38 -0
- package/src/type-helper.ts +2 -2
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ReadOnlyAppDataStorage } from "./app-data-storage.js";
|
|
2
|
+
import { i18nextCore } from "./locale/i18n.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Remote application data storage using HTTP. The `store()` and `delete()` methods are not supported.
|
|
6
|
+
*/
|
|
7
|
+
export class RemoteAppDataStorage extends ReadOnlyAppDataStorage<true> {
|
|
8
|
+
/**
|
|
9
|
+
* Constructor.
|
|
10
|
+
*
|
|
11
|
+
* @param baseURL
|
|
12
|
+
* Base URL. The URL must not end with a slash.
|
|
13
|
+
*/
|
|
14
|
+
constructor(baseURL: string) {
|
|
15
|
+
super(true, baseURL);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
protected override async doRead(key: string, asBinary: boolean | undefined): Promise<string | Uint8Array | undefined> {
|
|
22
|
+
return fetch(key).then(async (response) => {
|
|
23
|
+
let result: string | Uint8Array | undefined;
|
|
24
|
+
|
|
25
|
+
if (response.ok) {
|
|
26
|
+
result = asBinary === true ? new Uint8Array(await response.arrayBuffer()) : await response.text();
|
|
27
|
+
} else if (response.status === 404) {
|
|
28
|
+
result = undefined;
|
|
29
|
+
} else {
|
|
30
|
+
throw new RangeError(i18nextCore.t("RemoteAppDataStorage.httpError", {
|
|
31
|
+
status: response.status
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return result;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/type-helper.ts
CHANGED
|
@@ -94,7 +94,7 @@ export function pick<T extends object, K extends keyof T>(o: T, ...keys: K[]): P
|
|
|
94
94
|
*/
|
|
95
95
|
export function exclude<TWide extends TNarrow, TNarrow extends object, K extends keyof TNarrow>(wide: TWide, narrow: TNarrow): Omit<TWide, K> {
|
|
96
96
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Keys are valid.
|
|
97
|
-
return omit(wide, ...
|
|
97
|
+
return omit(wide, ...Object.keys(narrow) as K[]);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
@@ -120,7 +120,7 @@ export function exclude<TWide extends TNarrow, TNarrow extends object, K extends
|
|
|
120
120
|
*/
|
|
121
121
|
export function include<TWide extends TNarrow, TNarrow extends object, K extends keyof TNarrow>(wide: TWide, narrow: TNarrow): Pick<TWide, K> {
|
|
122
122
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Keys are valid.
|
|
123
|
-
return pick(wide, ...
|
|
123
|
+
return pick(wide, ...Object.keys(narrow) as K[]);
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
/**
|