@ngx-pwa/local-storage 16.3.0 → 18.0.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/LICENSE +14 -15
- package/esm2022/lib/databases/exceptions.mjs +3 -3
- package/esm2022/lib/databases/indexeddb-database.mjs +16 -15
- package/esm2022/lib/databases/local-database.mjs +9 -11
- package/esm2022/lib/databases/localstorage-database.mjs +13 -13
- package/esm2022/lib/databases/memory-database.mjs +7 -7
- package/esm2022/lib/providers.mjs +21 -36
- package/esm2022/lib/storage.module.mjs +10 -9
- package/esm2022/lib/storages/exceptions.mjs +2 -2
- package/esm2022/lib/storages/storage-map.service.mjs +124 -77
- package/esm2022/lib/tokens.mjs +1 -1
- package/esm2022/lib/validation/json-schema.mjs +1 -1
- package/esm2022/lib/validation/json-validator.mjs +14 -18
- package/esm2022/ngx-pwa-local-storage.mjs +1 -1
- package/esm2022/public-api.mjs +1 -4
- package/fesm2022/ngx-pwa-local-storage.mjs +586 -635
- package/fesm2022/ngx-pwa-local-storage.mjs.map +1 -1
- package/lib/databases/exceptions.d.ts +2 -2
- package/lib/databases/indexeddb-database.d.ts +13 -16
- package/lib/databases/local-database.d.ts +1 -2
- package/lib/databases/localstorage-database.d.ts +3 -3
- package/lib/databases/memory-database.d.ts +2 -2
- package/lib/providers.d.ts +21 -36
- package/lib/storage.module.d.ts +6 -4
- package/lib/storages/exceptions.d.ts +1 -1
- package/lib/storages/storage-map.service.d.ts +100 -46
- package/lib/tokens.d.ts +7 -0
- package/lib/validation/json-schema.d.ts +11 -18
- package/lib/validation/json-validator.d.ts +9 -10
- package/package.json +4 -4
- package/public-api.d.ts +2 -5
- package/schematics/collection.json +1 -1
- package/schematics/migration.json +1 -1
- package/schematics/ng-add/index.d.ts +1 -1
- package/schematics/ng-add/index.js +4 -10
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-update/index.d.ts +1 -1
- package/schematics/ng-update/index.js +1 -2
- package/schematics/ng-update/index.js.map +1 -1
- package/schematics/utility/config.js +2 -1
- package/schematics/utility/config.js.map +1 -1
- package/schematics/utility/module.d.ts +1 -1
- package/schematics/utility/module.js +1 -1
- package/schematics/utility/module.js.map +1 -1
- package/esm2022/lib/storages/local-storage.service.mjs +0 -85
- package/lib/storages/local-storage.service.d.ts +0 -99
package/lib/providers.d.ts
CHANGED
|
@@ -1,71 +1,56 @@
|
|
|
1
|
-
import { EnvironmentProviders } from "@angular/core";
|
|
1
|
+
import { type EnvironmentProviders } from "@angular/core";
|
|
2
2
|
/**
|
|
3
3
|
* Allows to add a prefix before `localStorage` keys.
|
|
4
|
-
* *Use only* for interoperability with other APIs or to avoid collision for multiple apps on the same subdomain.
|
|
5
|
-
* **WARNING: do not change this option in an app already deployed in production, as previously stored data would be lost.**
|
|
6
4
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* });
|
|
5
|
+
* *Use only* for interoperability with other APIs or to avoid collision for multiple applications on the same subdomain.
|
|
6
|
+
*
|
|
7
|
+
* **WARNING: do not change this option in an application already deployed in production, as previously stored data would be lost.**
|
|
11
8
|
*
|
|
12
9
|
* @example
|
|
13
|
-
*
|
|
10
|
+
* export const appConfig: ApplicationConfig = {
|
|
14
11
|
* providers: [provideLocalStoragePrefix('custom_')]
|
|
15
|
-
* }
|
|
16
|
-
* export class AppModule
|
|
12
|
+
* };
|
|
17
13
|
*/
|
|
18
14
|
export declare function provideLocalStoragePrefix(prefix: string): EnvironmentProviders;
|
|
19
15
|
/**
|
|
20
16
|
* Allows to change the name used for `indexedDB` database.
|
|
21
|
-
* *Use only* for interoperability with other APIs or to avoid collision for multiple apps on the same subdomain.
|
|
22
|
-
* **WARNING: do not change this option in an app already deployed in production, as previously stored data would be lost.**
|
|
23
17
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* });
|
|
18
|
+
* *Use only* for interoperability with other APIs or to avoid collision for multiple applications on the same subdomain.
|
|
19
|
+
*
|
|
20
|
+
* **WARNING: do not change this option in an application already deployed in production, as previously stored data would be lost.**
|
|
28
21
|
*
|
|
29
22
|
* @example
|
|
30
|
-
*
|
|
23
|
+
* export const appConfig: ApplicationConfig = {
|
|
31
24
|
* providers: [provideIndexedDBDataBaseName('custom')]
|
|
32
|
-
* }
|
|
33
|
-
* export class AppModule
|
|
25
|
+
* };
|
|
34
26
|
*/
|
|
35
27
|
export declare function provideIndexedDBDataBaseName(name: string): EnvironmentProviders;
|
|
36
28
|
/**
|
|
37
29
|
* Allows to change the database version used for `indexedDB` database.
|
|
38
30
|
* Must be an unsigned **integer**.
|
|
31
|
+
*
|
|
39
32
|
* **Use with caution as the creation of the store depends on the version.**
|
|
40
|
-
* *Use only* for interoperability with other APIs or to avoid collision for multiple apps on the same subdomain.
|
|
41
|
-
* **WARNING: do not change this option in an app already deployed in production, as previously stored data would be lost.**
|
|
42
33
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* });
|
|
34
|
+
* *Use only* for interoperability with other APIs or to avoid collision for multiple applications on the same subdomain.
|
|
35
|
+
*
|
|
36
|
+
* **WARNING: do not change this option in an applicattion already deployed in production, as previously stored data would be lost.**
|
|
47
37
|
*
|
|
48
38
|
* @example
|
|
49
|
-
*
|
|
39
|
+
* export const appConfig: ApplicationConfig = {
|
|
50
40
|
* providers: [provideIndexedDBDataBaseVersion(2)]
|
|
51
|
-
* }
|
|
52
|
-
* export class AppModule
|
|
41
|
+
* };
|
|
53
42
|
*/
|
|
54
43
|
export declare function provideIndexedDBDataBaseVersion(version: number): EnvironmentProviders;
|
|
55
44
|
/**
|
|
56
45
|
* Allows to change the name used for `indexedDB` object store.
|
|
46
|
+
*
|
|
57
47
|
* *Use only* for interoperability with other APIs.
|
|
58
|
-
* **WARNING: do not change this option in an app already deployed in production, as previously stored data would be lost.**
|
|
59
48
|
*
|
|
60
|
-
*
|
|
61
|
-
* bootstrapApplication(AppComponent, {
|
|
62
|
-
* providers: [provideIndexedDBStoreName('custom')]
|
|
63
|
-
* });
|
|
49
|
+
* **WARNING: do not change this option in an application already deployed in production, as previously stored data would be lost.**
|
|
64
50
|
*
|
|
65
51
|
* @example
|
|
66
|
-
*
|
|
52
|
+
* export const appConfig: ApplicationConfig = {
|
|
67
53
|
* providers: [provideIndexedDBStoreName('custom')]
|
|
68
|
-
* }
|
|
69
|
-
* export class AppModule
|
|
54
|
+
* };
|
|
70
55
|
*/
|
|
71
56
|
export declare function provideIndexedDBStoreName(name: string): EnvironmentProviders;
|
package/lib/storage.module.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { ModuleWithProviders } from "@angular/core";
|
|
2
|
-
import { StorageConfig } from "./tokens";
|
|
1
|
+
import { type ModuleWithProviders } from "@angular/core";
|
|
2
|
+
import { type StorageConfig } from "./tokens";
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
4
|
/**
|
|
5
|
-
* This module is only here for backward compatibility, do not add it by yourself
|
|
5
|
+
* This module is only here for backward compatibility, **do not add it by yourself**
|
|
6
|
+
*
|
|
7
|
+
* @ignore
|
|
6
8
|
*/
|
|
7
9
|
export declare class StorageModule {
|
|
8
10
|
/**
|
|
9
11
|
* Only useful to provide options, otherwise it does nothing.
|
|
10
|
-
* **Must be used at initialization, ie. in `AppModule`, and must not be loaded again in another module.**
|
|
11
12
|
*
|
|
13
|
+
* **Must be used at initialization, ie. in `AppModule`, and must not be loaded again in another module.**
|
|
12
14
|
*/
|
|
13
15
|
static forRoot(config: StorageConfig): ModuleWithProviders<StorageModule>;
|
|
14
16
|
static ɵfac: i0.ɵɵFactoryDeclaration<StorageModule, never>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare const VALIDATION_ERROR = "Data stored is not valid against the provided JSON schema.\nCheck your JSON schema, otherwise it means data has been corrupted.";
|
|
5
5
|
/**
|
|
6
|
-
* Exception
|
|
6
|
+
* Exception throwned when a value is not valid against the JSON schema
|
|
7
7
|
*/
|
|
8
8
|
export declare class ValidationError extends Error {
|
|
9
9
|
message: string;
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { Observable
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
2
|
import { LocalDatabase } from "../databases/local-database";
|
|
3
|
-
import { JSONSchema, JSONSchemaArrayOf, JSONSchemaBoolean, JSONSchemaInteger, JSONSchemaNumber, JSONSchemaString } from "../validation/json-schema";
|
|
4
|
-
import { JSONValidator } from "../validation/json-validator";
|
|
3
|
+
import type { JSONSchema, JSONSchemaArrayOf, JSONSchemaBoolean, JSONSchemaInteger, JSONSchemaNumber, JSONSchemaString } from "../validation/json-schema";
|
|
5
4
|
import * as i0 from "@angular/core";
|
|
6
5
|
export declare class StorageMap {
|
|
7
|
-
|
|
8
|
-
protected readonly jsonValidator: JSONValidator;
|
|
9
|
-
protected readonly notifiers: Map<string, ReplaySubject<unknown>>;
|
|
6
|
+
#private;
|
|
10
7
|
/**
|
|
11
8
|
* Constructor params are provided by Angular (but can also be passed manually in tests)
|
|
12
9
|
* @param database Storage to use
|
|
13
|
-
* @param jsonValidator Validator service
|
|
14
|
-
* @param LSPrefix Prefix for `localStorage` keys to avoid collision for multiple apps on the same subdomain or for interoperability
|
|
15
10
|
*/
|
|
16
|
-
constructor(database: LocalDatabase
|
|
11
|
+
constructor(database: LocalDatabase);
|
|
17
12
|
/**
|
|
18
|
-
* **Number of items** in storage, wrapped in an
|
|
13
|
+
* **Number of items** in storage, wrapped in an Observable.
|
|
14
|
+
*
|
|
15
|
+
* Note you do *not* need to unsubscribe (it is a self-completing Observable).
|
|
19
16
|
*
|
|
20
17
|
* @example
|
|
21
18
|
* this.storageMap.size.subscribe((size) => {
|
|
@@ -24,9 +21,12 @@ export declare class StorageMap {
|
|
|
24
21
|
*/
|
|
25
22
|
get size(): Observable<number>;
|
|
26
23
|
/**
|
|
27
|
-
* Tells you which storage engine is used.
|
|
24
|
+
* Tells you which storage engine is used.
|
|
25
|
+
*
|
|
26
|
+
* *Only useful for interoperability.*
|
|
27
|
+
*
|
|
28
28
|
* Note that due to some browsers issues in some special contexts
|
|
29
|
-
* (
|
|
29
|
+
* (like Safari cross-origin iframes),
|
|
30
30
|
* **this information may be wrong at initialization,**
|
|
31
31
|
* as the storage could fallback from `indexedDB` to `localStorage`
|
|
32
32
|
* only after a first read or write operation.
|
|
@@ -39,10 +39,12 @@ export declare class StorageMap {
|
|
|
39
39
|
*/
|
|
40
40
|
get backingEngine(): "indexedDB" | "localStorage" | "memory" | "unknown";
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* Information about `indexedDB` database.
|
|
43
|
+
*
|
|
44
|
+
* *Only useful for interoperability.*
|
|
45
|
+
*
|
|
43
46
|
* @returns `indexedDB` database name, store name and database version.
|
|
44
|
-
* **Values will be empty if the storage is not `indexedDB
|
|
45
|
-
* **so it should be used after an engine check**.
|
|
47
|
+
* **Values will be empty if the storage is not `indexedDB`, so it should be used after an engine check**.
|
|
46
48
|
*
|
|
47
49
|
* @see {@link https://github.com/cyrilletuzi/angular-async-local-storage/blob/main/docs/INTEROPERABILITY.md}
|
|
48
50
|
*
|
|
@@ -57,10 +59,12 @@ export declare class StorageMap {
|
|
|
57
59
|
version: number;
|
|
58
60
|
};
|
|
59
61
|
/**
|
|
60
|
-
*
|
|
62
|
+
* Information about `localStorage` fallback storage.
|
|
63
|
+
*
|
|
64
|
+
* *Only useful for interoperability.*
|
|
65
|
+
*
|
|
61
66
|
* @returns `localStorage` prefix.
|
|
62
|
-
* **Values will be empty if the storage is not `localStorage
|
|
63
|
-
* **so it should be used after an engine check**.
|
|
67
|
+
* **Values will be empty if the storage is not `localStorage`, so it should be used after an engine check**.
|
|
64
68
|
*
|
|
65
69
|
* @see {@link https://github.com/cyrilletuzi/angular-async-local-storage/blob/main/docs/INTEROPERABILITY.md}
|
|
66
70
|
*
|
|
@@ -74,11 +78,18 @@ export declare class StorageMap {
|
|
|
74
78
|
};
|
|
75
79
|
/**
|
|
76
80
|
* Get an item value in storage.
|
|
77
|
-
*
|
|
81
|
+
*
|
|
82
|
+
* Note that:
|
|
83
|
+
* * not finding an item is not an error, it succeeds but returns `undefined`,
|
|
84
|
+
* * you do *not* need to unsubscribe (it is a self-completing Observable),
|
|
85
|
+
* * you will only get *one* value: the Observable is here for asynchrony but is *not* meant to emit again when the stored data is changed. If you need to watch the value, see the `watch` method.
|
|
86
|
+
*
|
|
87
|
+
* Do not forget it is client-side storage: **always check the data**, as it could have been forged.
|
|
78
88
|
* @see {@link https://github.com/cyrilletuzi/angular-async-local-storage/blob/main/docs/VALIDATION.md}
|
|
89
|
+
*
|
|
79
90
|
* @param key The item's key
|
|
80
|
-
* @param schema Optional JSON schema to validate the data
|
|
81
|
-
* @returns The item's value if the key exists, `undefined` otherwise, wrapped in a RxJS
|
|
91
|
+
* @param schema Optional but recommended JSON schema to validate the data
|
|
92
|
+
* @returns The item's value if the key exists, `undefined` otherwise, wrapped in a RxJS Observable
|
|
82
93
|
*
|
|
83
94
|
* @example
|
|
84
95
|
* this.storageMap.get('key', { type: 'string' }).subscribe((result) => {
|
|
@@ -97,8 +108,8 @@ export declare class StorageMap {
|
|
|
97
108
|
* firstName: { type: 'string' },
|
|
98
109
|
* lastName: { type: 'string' },
|
|
99
110
|
* },
|
|
100
|
-
* required: ['firstName']
|
|
101
|
-
* };
|
|
111
|
+
* required: ['firstName'],
|
|
112
|
+
* } satisfies JSONSchema;
|
|
102
113
|
*
|
|
103
114
|
* this.storageMap.get<User>('user', schema).subscribe((user) => {
|
|
104
115
|
* if (user) {
|
|
@@ -115,40 +126,61 @@ export declare class StorageMap {
|
|
|
115
126
|
get<T extends readonly boolean[] = boolean[]>(key: string, schema: JSONSchemaArrayOf<JSONSchemaBoolean>): Observable<T | undefined>;
|
|
116
127
|
get<T>(key: string, schema: JSONSchema): Observable<T | undefined>;
|
|
117
128
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
129
|
+
* Store an item in storage.
|
|
130
|
+
*
|
|
131
|
+
* Note that:
|
|
132
|
+
* * you *do* need to subscribe, even if you do not have something specific to do after writing in storage, otherwise nothing happens (because it is how RxJS Observables work),
|
|
133
|
+
* * but you do *not* need to unsubscribe (it is a self-completing Observable),
|
|
134
|
+
* * setting `null` or `undefined` will remove the item to avoid some browsers issues,
|
|
135
|
+
* * you should stick to serializable JSON data, meaning primitive types, arrays and literal objects. Date, Map, Set, Blob and other special structures can cause issues in some scenarios.
|
|
136
|
+
* @see {@link https://github.com/cyrilletuzi/angular-async-local-storage/blob/main/docs/SERIALIZATION.md}
|
|
137
|
+
*
|
|
120
138
|
* @param key The item's key
|
|
121
139
|
* @param data The item's value
|
|
122
140
|
* @param schema Optional JSON schema to validate the data
|
|
123
|
-
* @returns A RxJS
|
|
141
|
+
* @returns A RxJS Observable to wait the end of the operation
|
|
124
142
|
*
|
|
125
143
|
* @example
|
|
126
144
|
* this.storageMap.set('key', 'value').subscribe(() => {});
|
|
127
145
|
*/
|
|
128
146
|
set(key: string, data: unknown, schema?: JSONSchema): Observable<undefined>;
|
|
129
147
|
/**
|
|
130
|
-
* Delete an item in storage
|
|
148
|
+
* Delete an item in storage.
|
|
149
|
+
*
|
|
150
|
+
* Note that:
|
|
151
|
+
* * you *do* need to subscribe, even if you do not have something specific to do after deleting, otherwise nothing happens (because it is how RxJS Observables work),
|
|
152
|
+
* * but you do *not* need to unsubscribe (it is a self-completing Observable).
|
|
153
|
+
*
|
|
131
154
|
* @param key The item's key
|
|
132
|
-
* @returns A RxJS
|
|
155
|
+
* @returns A RxJS Observable to wait the end of the operation
|
|
133
156
|
*
|
|
134
157
|
* @example
|
|
135
158
|
* this.storageMap.delete('key').subscribe(() => {});
|
|
136
159
|
*/
|
|
137
160
|
delete(key: string): Observable<undefined>;
|
|
138
161
|
/**
|
|
139
|
-
* Delete all items in storage
|
|
140
|
-
*
|
|
162
|
+
* Delete all items in storage.
|
|
163
|
+
*
|
|
164
|
+
* Note that:
|
|
165
|
+
* * you *do* need to subscribe, even if you do not have something specific to do after clearing, otherwise nothing happens (because it is how RxJS Observables work),
|
|
166
|
+
* * but you do *not* need to unsubscribe (it is a self-completing Observable).
|
|
167
|
+
*
|
|
168
|
+
* @returns A RxJS Observable to wait the end of the operation
|
|
141
169
|
*
|
|
142
170
|
* @example
|
|
143
171
|
* this.storageMap.clear().subscribe(() => {});
|
|
144
172
|
*/
|
|
145
173
|
clear(): Observable<undefined>;
|
|
146
174
|
/**
|
|
147
|
-
* Get all keys stored in storage.
|
|
175
|
+
* Get all keys stored in storage.
|
|
176
|
+
*
|
|
177
|
+
* Note **this is an *iterating* Observable**:
|
|
148
178
|
* * if there is no key, the `next` callback will not be invoked,
|
|
149
179
|
* * if you need to wait the whole operation to end, be sure to act in the `complete` callback,
|
|
150
|
-
* as this
|
|
151
|
-
*
|
|
180
|
+
* as this Observable can emit several values and so will invoke the `next` callback several times,
|
|
181
|
+
* * you do *not* need to unsubscribe (it is a self-completing Observable).
|
|
182
|
+
*
|
|
183
|
+
* @returns A list of the keys wrapped in a RxJS Observable
|
|
152
184
|
*
|
|
153
185
|
* @example
|
|
154
186
|
* this.storageMap.keys().subscribe({
|
|
@@ -158,8 +190,11 @@ export declare class StorageMap {
|
|
|
158
190
|
*/
|
|
159
191
|
keys(): Observable<string>;
|
|
160
192
|
/**
|
|
161
|
-
* Tells if a key exists in storage
|
|
162
|
-
*
|
|
193
|
+
* Tells if a key exists in storage.
|
|
194
|
+
*
|
|
195
|
+
* Note you do *not* need to unsubscribe (it is a self-completing Observable).
|
|
196
|
+
*
|
|
197
|
+
* @returns A RxJS Observable telling if the key exists
|
|
163
198
|
*
|
|
164
199
|
* @example
|
|
165
200
|
* this.storageMap.has('key').subscribe((hasKey) => {
|
|
@@ -169,12 +204,35 @@ export declare class StorageMap {
|
|
|
169
204
|
has(key: string): Observable<boolean>;
|
|
170
205
|
/**
|
|
171
206
|
* Watch an item value in storage.
|
|
172
|
-
*
|
|
207
|
+
*
|
|
208
|
+
* Note that:
|
|
209
|
+
* * it is an infinite Observable, do not forget to unsubscribe,
|
|
210
|
+
* * only changes done via this library will be watched, external changes in storage cannot be detected.
|
|
211
|
+
*
|
|
173
212
|
* The signature has many overloads due to validation, **please refer to the documentation.**
|
|
174
213
|
* @see https://github.com/cyrilletuzi/angular-async-local-storage/blob/main/docs/VALIDATION.md
|
|
214
|
+
*
|
|
175
215
|
* @param key The item's key to watch
|
|
176
216
|
* @param schema Optional JSON schema to validate the initial value
|
|
177
|
-
* @returns An infinite
|
|
217
|
+
* @returns An infinite Observable giving the current value
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* Component()
|
|
221
|
+
* export class MyComponent implements OnInit, OnDestroy {
|
|
222
|
+
*
|
|
223
|
+
* private storageSubscription?: Subscription;
|
|
224
|
+
*
|
|
225
|
+
* ngOnInit(): void {
|
|
226
|
+
* this.storageSubscription = this.storageMap.watch('key', { type: 'string' }).subscribe((result) => {
|
|
227
|
+
* result; // string or undefined
|
|
228
|
+
* });
|
|
229
|
+
* }
|
|
230
|
+
*
|
|
231
|
+
* ngOnDestroy(): void {
|
|
232
|
+
* this.storageSubscription?.unsubscribe();
|
|
233
|
+
* }
|
|
234
|
+
*
|
|
235
|
+
* }
|
|
178
236
|
*/
|
|
179
237
|
watch(key: string): Observable<unknown>;
|
|
180
238
|
watch<T extends string = string>(key: string, schema: JSONSchemaString): Observable<T | undefined>;
|
|
@@ -185,16 +243,12 @@ export declare class StorageMap {
|
|
|
185
243
|
watch<T extends readonly boolean[] = boolean[]>(key: string, schema: JSONSchemaArrayOf<JSONSchemaBoolean>): Observable<T | undefined>;
|
|
186
244
|
watch<T>(key: string, schema: JSONSchema): Observable<T | undefined>;
|
|
187
245
|
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
* @
|
|
191
|
-
|
|
192
|
-
protected notify(key: string, value: unknown): void;
|
|
193
|
-
/**
|
|
194
|
-
* RxJS operator to catch if `indexedDB` is broken
|
|
195
|
-
* @param operationCallback Callback with the operation to redo
|
|
246
|
+
* THIS METHOD IS FOR INTERNAL PURPOSE ONLY AND MUST NOT BE USED,
|
|
247
|
+
* IT CAN BE REMOVED AT ANY TIME AND MESSING WITH IT CAN CAUSE ISSUES
|
|
248
|
+
* @private
|
|
249
|
+
* @ignore
|
|
196
250
|
*/
|
|
197
|
-
|
|
251
|
+
private ɵinternalGetDatabase;
|
|
198
252
|
static ɵfac: i0.ɵɵFactoryDeclaration<StorageMap, never>;
|
|
199
253
|
static ɵprov: i0.ɵɵInjectableDeclaration<StorageMap>;
|
|
200
254
|
}
|
package/lib/tokens.d.ts
CHANGED
|
@@ -41,6 +41,11 @@ export declare const DEFAULT_IDB_NO_WRAP = true;
|
|
|
41
41
|
* **DO NOT CHANGE THIS BEHAVIOR ONCE IN PRODUCTION**, as it would break with existing data.
|
|
42
42
|
*/
|
|
43
43
|
export declare const IDB_NO_WRAP: InjectionToken<boolean>;
|
|
44
|
+
/**
|
|
45
|
+
* This interface is only here for backward compatibility, **do not add it by yourself**
|
|
46
|
+
*
|
|
47
|
+
* @ignore
|
|
48
|
+
*/
|
|
44
49
|
export interface StorageConfig {
|
|
45
50
|
/**
|
|
46
51
|
* @deprecated Use `provideLocalStoragePrefix()` method instead
|
|
@@ -61,7 +66,9 @@ export interface StorageConfig {
|
|
|
61
66
|
/**
|
|
62
67
|
* Allows interoperability with native `indexedDB` and other storage libs,
|
|
63
68
|
* by changing how values are stored in `indexedDB` database.
|
|
69
|
+
*
|
|
64
70
|
* Defaults to `true`. Change to `false` for backward compatiblity in existing applications.
|
|
71
|
+
*
|
|
65
72
|
* **DO NOT CHANGE THIS BEHAVIOR ONCE IN PRODUCTION**, as it would break with existing data.
|
|
66
73
|
*/
|
|
67
74
|
IDBNoWrap?: boolean;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* JSON Schema to describe a boolean value.
|
|
3
|
-
* @deprecated Will be removed in v17, use the generic `JSONSchema`
|
|
4
3
|
*/
|
|
5
4
|
export interface JSONSchemaBoolean {
|
|
6
5
|
/**
|
|
@@ -14,7 +13,6 @@ export interface JSONSchemaBoolean {
|
|
|
14
13
|
}
|
|
15
14
|
/**
|
|
16
15
|
* JSON Schema to describe a number value.
|
|
17
|
-
* @deprecated Will be removed in v17, use the generic `JSONSchema`
|
|
18
16
|
*/
|
|
19
17
|
export interface JSONSchemaNumber {
|
|
20
18
|
/**
|
|
@@ -53,7 +51,6 @@ export interface JSONSchemaNumber {
|
|
|
53
51
|
}
|
|
54
52
|
/**
|
|
55
53
|
* JSON Schema to describe an integer value.
|
|
56
|
-
* @deprecated Will be removed in v17, use the generic `JSONSchema`
|
|
57
54
|
*/
|
|
58
55
|
export interface JSONSchemaInteger {
|
|
59
56
|
/**
|
|
@@ -92,7 +89,6 @@ export interface JSONSchemaInteger {
|
|
|
92
89
|
}
|
|
93
90
|
/**
|
|
94
91
|
* JSON Schema to describe a string value.
|
|
95
|
-
* @deprecated Will be removed in v17, use the generic `JSONSchema`
|
|
96
92
|
*/
|
|
97
93
|
export interface JSONSchemaString {
|
|
98
94
|
/**
|
|
@@ -125,7 +121,6 @@ export interface JSONSchemaString {
|
|
|
125
121
|
}
|
|
126
122
|
/**
|
|
127
123
|
* JSON schema to describe an array of values.
|
|
128
|
-
* @deprecated Will be removed in v17, use the generic `JSONSchema`
|
|
129
124
|
*/
|
|
130
125
|
export interface JSONSchemaArray {
|
|
131
126
|
/**
|
|
@@ -157,7 +152,6 @@ export interface JSONSchemaArray {
|
|
|
157
152
|
* - array of numbers: `JSONSchemaArrayOf<JSONSchemaNumber>`,
|
|
158
153
|
* - array of integers: `JSONSchemaArrayOf<JSONSchemaInteger>`,
|
|
159
154
|
* - array of strings: `JSONSchemaArrayOf<JSONSchemaString>`.
|
|
160
|
-
* @deprecated Will be removed in v17, use the generic `JSONSchema`
|
|
161
155
|
*/
|
|
162
156
|
export interface JSONSchemaArrayOf<T extends JSONSchemaBoolean | JSONSchemaNumber | JSONSchemaInteger | JSONSchemaString> {
|
|
163
157
|
/**
|
|
@@ -212,7 +206,6 @@ export interface JSONSchemaTuple {
|
|
|
212
206
|
}
|
|
213
207
|
/**
|
|
214
208
|
* JSON schema to describe an object.
|
|
215
|
-
* @deprecated Will be removed in v17, use the generic `JSONSchema`
|
|
216
209
|
*/
|
|
217
210
|
export interface JSONSchemaObject {
|
|
218
211
|
/**
|
|
@@ -222,9 +215,7 @@ export interface JSONSchemaObject {
|
|
|
222
215
|
/**
|
|
223
216
|
* List of properties of the object and their associated JSON schemas.
|
|
224
217
|
*/
|
|
225
|
-
properties:
|
|
226
|
-
[k: string]: JSONSchema;
|
|
227
|
-
};
|
|
218
|
+
properties: Record<string, JSONSchema>;
|
|
228
219
|
/**
|
|
229
220
|
* Array of names of the required properties for an object.
|
|
230
221
|
* Properties set as required should be present in `properties` too.
|
|
@@ -233,35 +224,37 @@ export interface JSONSchemaObject {
|
|
|
233
224
|
}
|
|
234
225
|
/**
|
|
235
226
|
* Subset of the JSON Schema standard.
|
|
227
|
+
*
|
|
236
228
|
* Types are enforced to validate everything: each value **must** have a `type`.
|
|
229
|
+
*
|
|
237
230
|
* @see {@link https://github.com/cyrilletuzi/angular-async-local-storage/blob/main/docs/VALIDATION.md}
|
|
238
231
|
*
|
|
239
232
|
* @example
|
|
240
|
-
* const schema
|
|
233
|
+
* const schema = { type: 'string' } satisfies JSONSchema;
|
|
241
234
|
*
|
|
242
235
|
* @example
|
|
243
|
-
* const schema
|
|
236
|
+
* const schema = { type: 'number' } satisfies JSONSchema;
|
|
244
237
|
*
|
|
245
238
|
* @example
|
|
246
|
-
* const schema
|
|
239
|
+
* const schema = { type: 'integer' } satisfies JSONSchema;
|
|
247
240
|
*
|
|
248
241
|
* @example
|
|
249
|
-
* const schema
|
|
242
|
+
* const schema = { type: 'boolean' } satisfies JSONSchema;
|
|
250
243
|
*
|
|
251
244
|
* @example
|
|
252
|
-
* const schema
|
|
245
|
+
* const schema = {
|
|
253
246
|
* type: 'array',
|
|
254
247
|
* items: { type: 'string' },
|
|
255
|
-
* };
|
|
248
|
+
* } satisfies JSONSchema;
|
|
256
249
|
*
|
|
257
250
|
* @example
|
|
258
|
-
* const schema
|
|
251
|
+
* const schema = {
|
|
259
252
|
* type: 'object',
|
|
260
253
|
* properties: {
|
|
261
254
|
* firstName: { type: 'string' },
|
|
262
255
|
* lastName: { type: 'string' },
|
|
263
256
|
* },
|
|
264
257
|
* required: ['firstName'],
|
|
265
|
-
* };
|
|
258
|
+
* } satisfies JSONSchema;
|
|
266
259
|
*/
|
|
267
260
|
export type JSONSchema = JSONSchemaString | JSONSchemaNumber | JSONSchemaInteger | JSONSchemaBoolean | JSONSchemaArray | JSONSchemaTuple | JSONSchemaObject;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { JSONSchema
|
|
1
|
+
import type { JSONSchema } from "./json-schema";
|
|
2
2
|
import * as i0 from "@angular/core";
|
|
3
|
-
/** @deprecated Will be removed in v17 */
|
|
4
3
|
export declare class JSONValidator {
|
|
5
4
|
/**
|
|
6
5
|
* Validate a JSON data against a Jsubset of the JSON Schema standard.
|
|
@@ -17,56 +16,56 @@ export declare class JSONValidator {
|
|
|
17
16
|
* @param schema Schema describing the string
|
|
18
17
|
* @returns If data is valid: `true`, if it is invalid: `false`
|
|
19
18
|
*/
|
|
20
|
-
|
|
19
|
+
private validateString;
|
|
21
20
|
/**
|
|
22
21
|
* Validate a number or an integer
|
|
23
22
|
* @param data Data to validate
|
|
24
23
|
* @param schema Schema describing the number or integer
|
|
25
24
|
* @returns If data is valid: `true`, if it is invalid: `false`
|
|
26
25
|
*/
|
|
27
|
-
|
|
26
|
+
private validateNumber;
|
|
28
27
|
/**
|
|
29
28
|
* Validate a boolean
|
|
30
29
|
* @param data Data to validate
|
|
31
30
|
* @param schema Schema describing the boolean
|
|
32
31
|
* @returns If data is valid: `true`, if it is invalid: `false`
|
|
33
32
|
*/
|
|
34
|
-
|
|
33
|
+
private validateBoolean;
|
|
35
34
|
/**
|
|
36
35
|
* Validate an array
|
|
37
36
|
* @param data Data to validate
|
|
38
37
|
* @param schema Schema describing the array
|
|
39
38
|
* @returns If data is valid: `true`, if it is invalid: `false`
|
|
40
39
|
*/
|
|
41
|
-
|
|
40
|
+
private validateArray;
|
|
42
41
|
/**
|
|
43
42
|
* Validate a tuple (array with fixed length and multiple types)
|
|
44
43
|
* @param data Data to validate
|
|
45
44
|
* @param schemas Schemas describing the tuple
|
|
46
45
|
* @returns If data is valid: `true`, if it is invalid: `false`
|
|
47
46
|
*/
|
|
48
|
-
|
|
47
|
+
private validateTuple;
|
|
49
48
|
/**
|
|
50
49
|
* Validate an object
|
|
51
50
|
* @param data Data to validate
|
|
52
51
|
* @param schema JSON schema describing the object
|
|
53
52
|
* @returns If data is valid: `true`, if it is invalid: `false`
|
|
54
53
|
*/
|
|
55
|
-
|
|
54
|
+
private validateObject;
|
|
56
55
|
/**
|
|
57
56
|
* Validate a constant
|
|
58
57
|
* @param data Data ta validate
|
|
59
58
|
* @param schema JSON schema describing the constant
|
|
60
59
|
* @returns If data is valid: `true`, if it is invalid: `false`
|
|
61
60
|
*/
|
|
62
|
-
|
|
61
|
+
private validateConst;
|
|
63
62
|
/**
|
|
64
63
|
* Validate an enum
|
|
65
64
|
* @param data Data ta validate
|
|
66
65
|
* @param schema JSON schema describing the enum
|
|
67
66
|
* @returns If data is valid: `true`, if it is invalid: `false`
|
|
68
67
|
*/
|
|
69
|
-
|
|
68
|
+
private validateEnum;
|
|
70
69
|
static ɵfac: i0.ɵɵFactoryDeclaration<JSONValidator, never>;
|
|
71
70
|
static ɵprov: i0.ɵɵInjectableDeclaration<JSONValidator>;
|
|
72
71
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngx-pwa/local-storage",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.0.0",
|
|
4
4
|
"funding": {
|
|
5
5
|
"type": "github",
|
|
6
6
|
"url": "https://github.com/sponsors/cyrilletuzi"
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"tslib": "^2.5.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@angular/common": "^
|
|
24
|
-
"@angular/core": "^
|
|
25
|
-
"rxjs": "^7.
|
|
23
|
+
"@angular/common": "^18.0.0",
|
|
24
|
+
"@angular/core": "^18.0.0",
|
|
25
|
+
"rxjs": "^7.6.0"
|
|
26
26
|
},
|
|
27
27
|
"schematics": "./schematics/collection.json",
|
|
28
28
|
"ng-update": {
|
package/public-api.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
export { SERIALIZATION_ERROR, SerializationError } from "./lib/databases/exceptions";
|
|
2
|
-
export { LocalDatabase } from "./lib/databases/local-database";
|
|
3
2
|
export { provideIndexedDBDataBaseName, provideIndexedDBDataBaseVersion, provideIndexedDBStoreName, provideLocalStoragePrefix } from "./lib/providers";
|
|
4
3
|
export { StorageModule } from "./lib/storage.module";
|
|
5
4
|
export { VALIDATION_ERROR, ValidationError } from "./lib/storages/exceptions";
|
|
6
|
-
export { LocalStorage } from "./lib/storages/local-storage.service";
|
|
7
5
|
export { StorageMap } from "./lib/storages/storage-map.service";
|
|
8
|
-
export { StorageConfig } from "./lib/tokens";
|
|
9
|
-
export { JSONSchema
|
|
10
|
-
export { JSONValidator } from "./lib/validation/json-validator";
|
|
6
|
+
export type { StorageConfig } from "./lib/tokens";
|
|
7
|
+
export type { JSONSchema } from "./lib/validation/json-schema";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "../../node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
3
3
|
"schematics": {
|
|
4
4
|
"ng-add": {
|
|
5
5
|
"description": "Add @ngx-pwa/local-storage library to the project.",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Rule } from "@angular-devkit/schematics";
|
|
1
|
+
import { type Rule } from "@angular-devkit/schematics";
|
|
2
2
|
export default function (): Rule;
|