@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.
Files changed (59) hide show
  1. package/README.md +98 -87
  2. package/dist/app-data-storage.d.ts +118 -0
  3. package/dist/app-data-storage.d.ts.map +1 -0
  4. package/dist/app-data-storage.js +117 -0
  5. package/dist/app-data-storage.js.map +1 -0
  6. package/dist/app-data.d.ts +26 -0
  7. package/dist/app-data.d.ts.map +1 -0
  8. package/dist/app-data.js +79 -0
  9. package/dist/app-data.js.map +1 -0
  10. package/dist/browser-app-data-storage.d.ts +26 -0
  11. package/dist/browser-app-data-storage.d.ts.map +1 -0
  12. package/dist/browser-app-data-storage.js +34 -0
  13. package/dist/browser-app-data-storage.js.map +1 -0
  14. package/dist/file-app-data-storage.d.ts +26 -0
  15. package/dist/file-app-data-storage.d.ts.map +1 -0
  16. package/dist/file-app-data-storage.js +40 -0
  17. package/dist/file-app-data-storage.js.map +1 -0
  18. package/dist/index.d.ts +4 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +4 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/local-app-data-storage.d.ts +8 -0
  23. package/dist/local-app-data-storage.d.ts.map +1 -0
  24. package/dist/local-app-data-storage.js +11 -0
  25. package/dist/local-app-data-storage.js.map +1 -0
  26. package/dist/locale/en/locale-resources.d.ts +3 -0
  27. package/dist/locale/en/locale-resources.d.ts.map +1 -1
  28. package/dist/locale/en/locale-resources.js +3 -0
  29. package/dist/locale/en/locale-resources.js.map +1 -1
  30. package/dist/locale/fr/locale-resources.d.ts +3 -0
  31. package/dist/locale/fr/locale-resources.d.ts.map +1 -1
  32. package/dist/locale/fr/locale-resources.js +3 -0
  33. package/dist/locale/fr/locale-resources.js.map +1 -1
  34. package/dist/locale/i18n.d.ts +22 -13
  35. package/dist/locale/i18n.d.ts.map +1 -1
  36. package/dist/locale/i18n.js +62 -43
  37. package/dist/locale/i18n.js.map +1 -1
  38. package/dist/logger.d.ts +4 -2
  39. package/dist/logger.d.ts.map +1 -1
  40. package/dist/logger.js +9 -3
  41. package/dist/logger.js.map +1 -1
  42. package/dist/remote-app-data-storage.d.ts +18 -0
  43. package/dist/remote-app-data-storage.d.ts.map +1 -0
  44. package/dist/remote-app-data-storage.js +37 -0
  45. package/dist/remote-app-data-storage.js.map +1 -0
  46. package/dist/type-helper.js.map +1 -1
  47. package/package.json +9 -7
  48. package/src/app-data-storage.ts +166 -0
  49. package/src/app-data.ts +94 -0
  50. package/src/browser-app-data-storage.ts +37 -0
  51. package/src/file-app-data-storage.ts +49 -0
  52. package/src/index.ts +5 -0
  53. package/src/local-app-data-storage.ts +12 -0
  54. package/src/locale/en/locale-resources.ts +3 -0
  55. package/src/locale/fr/locale-resources.ts +3 -0
  56. package/src/locale/i18n.ts +81 -49
  57. package/src/logger.ts +10 -3
  58. package/src/remote-app-data-storage.ts +38 -0
  59. 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
+ }
@@ -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, ...(Object.keys(narrow) as K[]));
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, ...(Object.keys(narrow) as K[]));
123
+ return pick(wide, ...Object.keys(narrow) as K[]);
124
124
  }
125
125
 
126
126
  /**