@ngx-pwa/local-storage 17.0.0 → 19.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.
Files changed (43) hide show
  1. package/LICENSE +14 -15
  2. package/fesm2022/ngx-pwa-local-storage.mjs +637 -573
  3. package/fesm2022/ngx-pwa-local-storage.mjs.map +1 -1
  4. package/lib/databases/exceptions.d.ts +2 -2
  5. package/lib/databases/indexeddb-database.d.ts +12 -15
  6. package/lib/databases/localstorage-database.d.ts +2 -2
  7. package/lib/databases/memory-database.d.ts +1 -1
  8. package/lib/providers.d.ts +25 -16
  9. package/lib/storage.module.d.ts +6 -4
  10. package/lib/storages/exceptions.d.ts +1 -1
  11. package/lib/storages/storage-map.service.d.ts +100 -46
  12. package/lib/tokens.d.ts +7 -0
  13. package/lib/validation/json-schema.d.ts +10 -8
  14. package/lib/validation/json-validator.d.ts +9 -9
  15. package/package.json +4 -6
  16. package/public-api.d.ts +2 -2
  17. package/schematics/collection.json +1 -1
  18. package/schematics/migration.json +1 -1
  19. package/schematics/ng-add/index.d.ts +1 -1
  20. package/schematics/ng-add/index.js +7 -8
  21. package/schematics/ng-add/index.js.map +1 -1
  22. package/schematics/ng-update/index.d.ts +1 -1
  23. package/schematics/ng-update/index.js +15 -26
  24. package/schematics/ng-update/index.js.map +1 -1
  25. package/schematics/utility/config.js +24 -33
  26. package/schematics/utility/config.js.map +1 -1
  27. package/schematics/utility/module.d.ts +1 -1
  28. package/schematics/utility/module.js +3 -4
  29. package/schematics/utility/module.js.map +1 -1
  30. package/esm2022/lib/databases/exceptions.mjs +0 -28
  31. package/esm2022/lib/databases/indexeddb-database.mjs +0 -306
  32. package/esm2022/lib/databases/local-database.mjs +0 -68
  33. package/esm2022/lib/databases/localstorage-database.mjs +0 -157
  34. package/esm2022/lib/databases/memory-database.mjs +0 -83
  35. package/esm2022/lib/providers.mjs +0 -57
  36. package/esm2022/lib/storage.module.mjs +0 -32
  37. package/esm2022/lib/storages/exceptions.mjs +0 -15
  38. package/esm2022/lib/storages/storage-map.service.mjs +0 -296
  39. package/esm2022/lib/tokens.mjs +0 -59
  40. package/esm2022/lib/validation/json-schema.mjs +0 -5
  41. package/esm2022/lib/validation/json-validator.mjs +0 -246
  42. package/esm2022/ngx-pwa-local-storage.mjs +0 -5
  43. package/esm2022/public-api.mjs +0 -9
@@ -1,47 +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.**
4
+ *
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.**
6
8
  *
7
9
  * @example
8
- * bootstrapApplication(AppComponent, {
10
+ * export const appConfig: ApplicationConfig = {
9
11
  * providers: [provideLocalStoragePrefix('custom_')]
10
- * });
12
+ * };
11
13
  */
12
14
  export declare function provideLocalStoragePrefix(prefix: string): EnvironmentProviders;
13
15
  /**
14
16
  * Allows to change the name used for `indexedDB` database.
15
- * *Use only* for interoperability with other APIs or to avoid collision for multiple apps on the same subdomain.
16
- * **WARNING: do not change this option in an app already deployed in production, as previously stored data would be lost.**
17
+ *
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.**
17
21
  *
18
22
  * @example
19
- * bootstrapApplication(AppComponent, {
23
+ * export const appConfig: ApplicationConfig = {
20
24
  * providers: [provideIndexedDBDataBaseName('custom')]
21
- * });
25
+ * };
22
26
  */
23
27
  export declare function provideIndexedDBDataBaseName(name: string): EnvironmentProviders;
24
28
  /**
25
29
  * Allows to change the database version used for `indexedDB` database.
26
30
  * Must be an unsigned **integer**.
31
+ *
27
32
  * **Use with caution as the creation of the store depends on the version.**
28
- * *Use only* for interoperability with other APIs or to avoid collision for multiple apps on the same subdomain.
29
- * **WARNING: do not change this option in an app already deployed in production, as previously stored data would be lost.**
33
+ *
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.**
30
37
  *
31
38
  * @example
32
- * bootstrapApplication(AppComponent, {
39
+ * export const appConfig: ApplicationConfig = {
33
40
  * providers: [provideIndexedDBDataBaseVersion(2)]
34
- * });
41
+ * };
35
42
  */
36
43
  export declare function provideIndexedDBDataBaseVersion(version: number): EnvironmentProviders;
37
44
  /**
38
45
  * Allows to change the name used for `indexedDB` object store.
46
+ *
39
47
  * *Use only* for interoperability with other APIs.
40
- * **WARNING: do not change this option in an app already deployed in production, as previously stored data would be lost.**
48
+ *
49
+ * **WARNING: do not change this option in an application already deployed in production, as previously stored data would be lost.**
41
50
  *
42
51
  * @example
43
- * bootstrapApplication(AppComponent, {
52
+ * export const appConfig: ApplicationConfig = {
44
53
  * providers: [provideIndexedDBStoreName('custom')]
45
- * });
54
+ * };
46
55
  */
47
56
  export declare function provideIndexedDBStoreName(name: string): EnvironmentProviders;
@@ -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 raised when a value is not valid against the JSON schema
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, OperatorFunction, ReplaySubject } from "rxjs";
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
- protected database: LocalDatabase;
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, jsonValidator?: JSONValidator);
11
+ constructor(database: LocalDatabase);
17
12
  /**
18
- * **Number of items** in storage, wrapped in an `Observable`.
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. *Only useful for interoperability.*
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
- * (Firefox private mode and Safari cross-origin iframes),
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
- * Info about `indexedDB` database. *Only useful for interoperability.*
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
- * Info about `localStorage` fallback storage. *Only useful for interoperability.*
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
- * The signature has many overloads due to validation, **please refer to the documentation.**
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 `Observable`
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
- * Set an item in storage.
119
- * Note that setting `null` or `undefined` will remove the item to avoid some browsers issues.
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 `Observable` to wait the end of the operation
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 `Observable` to wait the end of the operation
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
- * @returns A RxJS `Observable` to wait the end of the operation
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. Note **this is an *iterating* `Observable`**:
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 `Observable` can emit several values and so will invoke the `next` callback several times.
151
- * @returns A list of the keys wrapped in a RxJS `Observable`
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
- * @returns A RxJS `Observable` telling if the key exists
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
- * **Note only changes done via this lib will be watched**, external changes in storage can't be detected.
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 `Observable` giving the current value
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
- * Notify when a value changes
189
- * @param key The item's key
190
- * @param data The new value
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
- protected catchIDBBroken<T>(operationCallback: () => Observable<T>): OperatorFunction<T, T>;
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;
@@ -224,35 +224,37 @@ export interface JSONSchemaObject {
224
224
  }
225
225
  /**
226
226
  * Subset of the JSON Schema standard.
227
+ *
227
228
  * Types are enforced to validate everything: each value **must** have a `type`.
229
+ *
228
230
  * @see {@link https://github.com/cyrilletuzi/angular-async-local-storage/blob/main/docs/VALIDATION.md}
229
231
  *
230
232
  * @example
231
- * const schema: JSONSchema = { type: 'string' };
233
+ * const schema = { type: 'string' } satisfies JSONSchema;
232
234
  *
233
235
  * @example
234
- * const schema: JSONSchema = { type: 'number' };
236
+ * const schema = { type: 'number' } satisfies JSONSchema;
235
237
  *
236
238
  * @example
237
- * const schema: JSONSchema = { type: 'integer' };
239
+ * const schema = { type: 'integer' } satisfies JSONSchema;
238
240
  *
239
241
  * @example
240
- * const schema: JSONSchema = { type: 'boolean' };
242
+ * const schema = { type: 'boolean' } satisfies JSONSchema;
241
243
  *
242
244
  * @example
243
- * const schema: JSONSchema = {
245
+ * const schema = {
244
246
  * type: 'array',
245
247
  * items: { type: 'string' },
246
- * };
248
+ * } satisfies JSONSchema;
247
249
  *
248
250
  * @example
249
- * const schema: JSONSchema = {
251
+ * const schema = {
250
252
  * type: 'object',
251
253
  * properties: {
252
254
  * firstName: { type: 'string' },
253
255
  * lastName: { type: 'string' },
254
256
  * },
255
257
  * required: ['firstName'],
256
- * };
258
+ * } satisfies JSONSchema;
257
259
  */
258
260
  export type JSONSchema = JSONSchemaString | JSONSchemaNumber | JSONSchemaInteger | JSONSchemaBoolean | JSONSchemaArray | JSONSchemaTuple | JSONSchemaObject;
@@ -1,4 +1,4 @@
1
- import { JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaInteger, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, JSONSchemaTuple } from "./json-schema";
1
+ import type { JSONSchema } from "./json-schema";
2
2
  import * as i0 from "@angular/core";
3
3
  export declare class JSONValidator {
4
4
  /**
@@ -16,56 +16,56 @@ export declare class JSONValidator {
16
16
  * @param schema Schema describing the string
17
17
  * @returns If data is valid: `true`, if it is invalid: `false`
18
18
  */
19
- protected validateString(data: unknown, schema: JSONSchemaString): boolean;
19
+ private validateString;
20
20
  /**
21
21
  * Validate a number or an integer
22
22
  * @param data Data to validate
23
23
  * @param schema Schema describing the number or integer
24
24
  * @returns If data is valid: `true`, if it is invalid: `false`
25
25
  */
26
- protected validateNumber(data: unknown, schema: JSONSchemaNumber | JSONSchemaInteger): boolean;
26
+ private validateNumber;
27
27
  /**
28
28
  * Validate a boolean
29
29
  * @param data Data to validate
30
30
  * @param schema Schema describing the boolean
31
31
  * @returns If data is valid: `true`, if it is invalid: `false`
32
32
  */
33
- protected validateBoolean(data: unknown, schema: JSONSchemaBoolean): boolean;
33
+ private validateBoolean;
34
34
  /**
35
35
  * Validate an array
36
36
  * @param data Data to validate
37
37
  * @param schema Schema describing the array
38
38
  * @returns If data is valid: `true`, if it is invalid: `false`
39
39
  */
40
- protected validateArray(data: unknown, schema: JSONSchemaArray | JSONSchemaTuple): boolean;
40
+ private validateArray;
41
41
  /**
42
42
  * Validate a tuple (array with fixed length and multiple types)
43
43
  * @param data Data to validate
44
44
  * @param schemas Schemas describing the tuple
45
45
  * @returns If data is valid: `true`, if it is invalid: `false`
46
46
  */
47
- protected validateTuple(data: unknown[], schemas: JSONSchema[] | undefined): boolean;
47
+ private validateTuple;
48
48
  /**
49
49
  * Validate an object
50
50
  * @param data Data to validate
51
51
  * @param schema JSON schema describing the object
52
52
  * @returns If data is valid: `true`, if it is invalid: `false`
53
53
  */
54
- protected validateObject(data: unknown, schema: JSONSchemaObject): boolean;
54
+ private validateObject;
55
55
  /**
56
56
  * Validate a constant
57
57
  * @param data Data ta validate
58
58
  * @param schema JSON schema describing the constant
59
59
  * @returns If data is valid: `true`, if it is invalid: `false`
60
60
  */
61
- protected validateConst(data: unknown, schema: JSONSchemaBoolean | JSONSchemaInteger | JSONSchemaNumber | JSONSchemaString): boolean;
61
+ private validateConst;
62
62
  /**
63
63
  * Validate an enum
64
64
  * @param data Data ta validate
65
65
  * @param schema JSON schema describing the enum
66
66
  * @returns If data is valid: `true`, if it is invalid: `false`
67
67
  */
68
- protected validateEnum(data: unknown, schema: JSONSchemaInteger | JSONSchemaNumber | JSONSchemaString): boolean;
68
+ private validateEnum;
69
69
  static ɵfac: i0.ɵɵFactoryDeclaration<JSONValidator, never>;
70
70
  static ɵprov: i0.ɵɵInjectableDeclaration<JSONValidator>;
71
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngx-pwa/local-storage",
3
- "version": "17.0.0",
3
+ "version": "19.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": "^17.0.0",
24
- "@angular/core": "^17.0.0",
25
- "rxjs": "^7.4.0"
23
+ "@angular/common": "^19.0.0",
24
+ "@angular/core": "^19.0.0",
25
+ "rxjs": "^7.6.0"
26
26
  },
27
27
  "schematics": "./schematics/collection.json",
28
28
  "ng-update": {
@@ -37,8 +37,6 @@
37
37
  },
38
38
  ".": {
39
39
  "types": "./index.d.ts",
40
- "esm2022": "./esm2022/ngx-pwa-local-storage.mjs",
41
- "esm": "./esm2022/ngx-pwa-local-storage.mjs",
42
40
  "default": "./fesm2022/ngx-pwa-local-storage.mjs"
43
41
  }
44
42
  }
package/public-api.d.ts CHANGED
@@ -3,5 +3,5 @@ export { provideIndexedDBDataBaseName, provideIndexedDBDataBaseVersion, provideI
3
3
  export { StorageModule } from "./lib/storage.module";
4
4
  export { VALIDATION_ERROR, ValidationError } from "./lib/storages/exceptions";
5
5
  export { StorageMap } from "./lib/storages/storage-map.service";
6
- export { StorageConfig } from "./lib/tokens";
7
- export { JSONSchema } from "./lib/validation/json-schema";
6
+ export type { StorageConfig } from "./lib/tokens";
7
+ export type { JSONSchema } from "./lib/validation/json-schema";
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "../../../../node_modules/@angular-devkit/schematics/collection-schema.json",
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,5 +1,5 @@
1
1
  {
2
- "$schema": "../../../../node_modules/@angular-devkit/schematics/collection-schema.json",
2
+ "$schema": "../../node_modules/@angular-devkit/schematics/collection-schema.json",
3
3
  "schematics": {
4
4
  "migration-v8": {
5
5
  "version": "8",
@@ -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;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
3
4
  const schematics_1 = require("@angular-devkit/schematics");
4
5
  const tasks_1 = require("@angular-devkit/schematics/tasks");
5
6
  const config_1 = require("../utility/config");
@@ -7,18 +8,17 @@ function default_1() {
7
8
  return (host, context) => {
8
9
  /* Get config */
9
10
  const angularMajorVersion = (0, config_1.getDependencyMajorVersion)("@angular/core", host);
10
- if (!angularMajorVersion) {
11
+ if (angularMajorVersion === undefined) {
11
12
  context.logger.warn(`Not able to detect @angular/core version. Be aware that Angular versions <= 14 are no longer supported.`);
12
13
  }
13
- if (angularMajorVersion && (angularMajorVersion <= 14)) {
14
- throw new schematics_1.SchematicsException("Angular versions <= 14 are no longer supported.");
14
+ if (angularMajorVersion !== undefined && (angularMajorVersion <= 16)) {
15
+ throw new schematics_1.SchematicsException("Angular versions <= 16 are no longer supported.");
15
16
  }
16
17
  const rxjsMajorVersion = (0, config_1.getDependencyMajorVersion)("rxjs", host);
17
- if (!rxjsMajorVersion) {
18
- // eslint-disable-next-line max-len
19
- context.logger.warn(`Not able to detect rxjs version. Be aware that rxjs version >= 7.4 is recommended for Angular 14 and required for Angular >= 15.`);
18
+ if (rxjsMajorVersion === undefined) {
19
+ context.logger.warn(`Not able to detect rxjs version. Be aware that rxjs version >= 7.4 is required, rxjs 6 is not supported.`);
20
20
  }
21
- if (rxjsMajorVersion && (rxjsMajorVersion < 7)) {
21
+ if (rxjsMajorVersion !== undefined && (rxjsMajorVersion < 7)) {
22
22
  throw new schematics_1.SchematicsException("rxjs >= 7.4 is required for this lib, rxjs 6 is not supported.");
23
23
  }
24
24
  /* Task to run `npm install` (or user package manager) */
@@ -26,5 +26,4 @@ function default_1() {
26
26
  return (0, schematics_1.chain)([]);
27
27
  };
28
28
  }
29
- exports.default = default_1;
30
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../projects/ngx-pwa/local-storage/schematics/ng-add/index.ts"],"names":[],"mappings":";;AAAA,2DAAsG;AACtG,4DAA0E;AAC1E,8CAA8D;AAE9D;IACE,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAE/C,gBAAgB;QAChB,MAAM,mBAAmB,GAAG,IAAA,kCAAyB,EAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QAE7E,IAAI,CAAC,mBAAmB,EAAE;YACxB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,yGAAyG,CAAC,CAAC;SAChI;QAED,IAAI,mBAAmB,IAAI,CAAC,mBAAmB,IAAI,EAAE,CAAC,EAAE;YACtD,MAAM,IAAI,gCAAmB,CAAC,iDAAiD,CAAC,CAAC;SAClF;QAED,MAAM,gBAAgB,GAAG,IAAA,kCAAyB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAEjE,IAAI,CAAC,gBAAgB,EAAE;YACrB,mCAAmC;YACnC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,kIAAkI,CAAC,CAAC;SACzJ;QAED,IAAI,gBAAgB,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC,EAAE;YAC9C,MAAM,IAAI,gCAAmB,CAAC,gEAAgE,CAAC,CAAC;SACjG;QAED,yDAAyD;QACzD,OAAO,CAAC,OAAO,CAAC,IAAI,8BAAsB,EAAE,CAAC,CAAC;QAE9C,OAAO,IAAA,kBAAK,EAAC,EAAE,CAAC,CAAC;IAEnB,CAAC,CAAC;AACJ,CAAC;AA/BD,4BA+BC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lib/schematics/ng-add/index.ts"],"names":[],"mappings":";;AAIA,4BA8BC;AAlCD,2DAAgH;AAChH,4DAA0E;AAC1E,8CAA8D;AAE9D;IACE,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAE/C,gBAAgB;QAChB,MAAM,mBAAmB,GAAG,IAAA,kCAAyB,EAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QAE7E,IAAI,mBAAmB,KAAK,SAAS,EAAE,CAAC;YACtC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,yGAAyG,CAAC,CAAC;QACjI,CAAC;QAED,IAAI,mBAAmB,KAAK,SAAS,IAAI,CAAC,mBAAmB,IAAI,EAAE,CAAC,EAAE,CAAC;YACrE,MAAM,IAAI,gCAAmB,CAAC,iDAAiD,CAAC,CAAC;QACnF,CAAC;QAED,MAAM,gBAAgB,GAAG,IAAA,kCAAyB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAEjE,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACnC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,0GAA0G,CAAC,CAAC;QAClI,CAAC;QAED,IAAI,gBAAgB,KAAK,SAAS,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC;YAC7D,MAAM,IAAI,gCAAmB,CAAC,gEAAgE,CAAC,CAAC;QAClG,CAAC;QAED,yDAAyD;QACzD,OAAO,CAAC,OAAO,CAAC,IAAI,8BAAsB,EAAE,CAAC,CAAC;QAE9C,OAAO,IAAA,kBAAK,EAAC,EAAE,CAAC,CAAC;IAEnB,CAAC,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Rule } from "@angular-devkit/schematics";
1
+ import { type Rule } from "@angular-devkit/schematics";
2
2
  export declare function updateToV8(): Rule;
3
3
  export declare function updateToV9(): Rule;
4
4
  export declare function updateToV13(): Rule;