@o3r/store-sync 14.1.0-prerelease.4 → 14.1.0-prerelease.6
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/package.json +6 -6
- package/index.d.ts +0 -188
- package/index.d.ts.map +0 -1
- package/schematics/ng-add/index.js.map +0 -1
- package/schematics/ng-add/schema.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/store-sync",
|
|
3
|
-
"version": "14.1.0-prerelease.
|
|
3
|
+
"version": "14.1.0-prerelease.6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"otter-module"
|
|
14
14
|
],
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"@ama-sdk/core": "~14.1.0-prerelease.
|
|
16
|
+
"@ama-sdk/core": "~14.1.0-prerelease.6",
|
|
17
17
|
"@angular-devkit/core": "^21.0.0",
|
|
18
18
|
"@angular-devkit/schematics": "^21.0.0",
|
|
19
19
|
"@ngrx/entity": "^21.0.0",
|
|
20
20
|
"@ngrx/store": "^21.0.0",
|
|
21
|
-
"@o3r/core": "~14.1.0-prerelease.
|
|
22
|
-
"@o3r/logger": "~14.1.0-prerelease.
|
|
23
|
-
"@o3r/schematics": "~14.1.0-prerelease.
|
|
21
|
+
"@o3r/core": "~14.1.0-prerelease.6",
|
|
22
|
+
"@o3r/logger": "~14.1.0-prerelease.6",
|
|
23
|
+
"@o3r/schematics": "~14.1.0-prerelease.6",
|
|
24
24
|
"@schematics/angular": "^21.0.0",
|
|
25
25
|
"fast-deep-equal": "^3.1.3",
|
|
26
26
|
"rxjs": "^7.8.1",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@o3r/schematics": "~14.1.0-prerelease.
|
|
47
|
+
"@o3r/schematics": "~14.1.0-prerelease.6",
|
|
48
48
|
"tslib": "^2.6.2"
|
|
49
49
|
},
|
|
50
50
|
"schematics": "./collection.json",
|
package/index.d.ts
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { Logger, Serializer } from '@o3r/core';
|
|
2
|
-
import * as _ngrx_store from '@ngrx/store';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Options to provide to the synchronous store synchronization mechanism
|
|
6
|
-
*/
|
|
7
|
-
interface SyncStorageSyncOptions {
|
|
8
|
-
/** Callback to define the serialization strategy of the store */
|
|
9
|
-
serialize?: (state: any) => any;
|
|
10
|
-
/** Callback to define the deserialization strategy of the store */
|
|
11
|
-
deserialize?: (state: any) => any;
|
|
12
|
-
/** Callback to define the reviving strategy of the store */
|
|
13
|
-
reviver?: (key: string, value: any) => any;
|
|
14
|
-
/** replacer callback function provided to the parser */
|
|
15
|
-
replacer?: ((key: string, value: any) => any) | string[];
|
|
16
|
-
/** Filter to apply to the store fields */
|
|
17
|
-
filter?: string[];
|
|
18
|
-
/** Spacing for serializer */
|
|
19
|
-
space?: string | number;
|
|
20
|
-
/** Defines whether the store is loaded as forFeature */
|
|
21
|
-
syncForFeature?: boolean;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Interface of the configurations for a store
|
|
25
|
-
*/
|
|
26
|
-
interface StorageKeyConfiguration {
|
|
27
|
-
[key: string]: string[] | number[] | StorageKeyConfiguration[] | SyncStorageSyncOptions | ((key: string, value: any) => any);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Definition of a store to to synchronize
|
|
31
|
-
*/
|
|
32
|
-
type StorageKeys = (StorageKeyConfiguration | SyncStorageSyncOptions | string)[];
|
|
33
|
-
/**
|
|
34
|
-
* Configuration to define the way the stores should be synchronize to the storage
|
|
35
|
-
*/
|
|
36
|
-
interface SyncStorageConfig {
|
|
37
|
-
/** Map of the store to synchronize */
|
|
38
|
-
keys: StorageKeys;
|
|
39
|
-
/** Should the stores be initially rehydrated */
|
|
40
|
-
rehydrate?: boolean;
|
|
41
|
-
/** Storage reference */
|
|
42
|
-
storage?: Storage;
|
|
43
|
-
/** Should be removed from storage if undefined */
|
|
44
|
-
removeOnUndefined?: boolean;
|
|
45
|
-
/** Should apply restore date to the restored stores */
|
|
46
|
-
restoreDates?: boolean;
|
|
47
|
-
/** Callback to define the serialization strategy for the store keys */
|
|
48
|
-
storageKeySerializer?: (key: string) => string;
|
|
49
|
-
/** Callback to define the condition to the synchronization */
|
|
50
|
-
syncCondition?: (state: any) => any;
|
|
51
|
-
/** Callback to define the condition to the key synchronization */
|
|
52
|
-
syncKeyCondition?: (key: string, state: any) => boolean;
|
|
53
|
-
/** check the availability of the storage */
|
|
54
|
-
checkStorageAvailability?: boolean;
|
|
55
|
-
/** Merge reducer to use to deserialize the store */
|
|
56
|
-
mergeReducer?: (state: any, rehydratedState: any, action: any) => any;
|
|
57
|
-
/** Logger to report messages */
|
|
58
|
-
logger?: Logger;
|
|
59
|
-
/** Post process after sync storage execution */
|
|
60
|
-
postProcess?: (state: any) => void;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Reviver the date from a JSON field if the string is matching iso format. Return the same value otherwise
|
|
65
|
-
* @param _key JSON item key name
|
|
66
|
-
* @param value JSON item value
|
|
67
|
-
*/
|
|
68
|
-
declare const dateReviver: (_key: string, value: any) => any;
|
|
69
|
-
/**
|
|
70
|
-
* Rehydrate the state of the whole application store
|
|
71
|
-
* @param keys Keys of the store to rehydrate
|
|
72
|
-
* @param storage storage when getting the data from
|
|
73
|
-
* @param storageKeySerializer storage key transform function
|
|
74
|
-
* @param restoreDates determine if the date need to be restored
|
|
75
|
-
* @param logger
|
|
76
|
-
*/
|
|
77
|
-
declare const rehydrateApplicationState: (keys: StorageKeys, storage: Storage | undefined, storageKeySerializer: (key: string) => string, restoreDates: boolean, logger?: Logger) => any;
|
|
78
|
-
/**
|
|
79
|
-
* Update the state of the store after reviving from storage
|
|
80
|
-
* Note: this function is mainly use for internal process of store synchronization
|
|
81
|
-
* @param state store state
|
|
82
|
-
* @param keys key of the store
|
|
83
|
-
* @param storage storage to use for the synchronization
|
|
84
|
-
* @param storageKeySerializer callback to serialize the store key
|
|
85
|
-
* @param removeOnUndefined Define if the store should be clean in the storage if undefined
|
|
86
|
-
* @param syncCondition callback to define if the synchronization should be process
|
|
87
|
-
* @param logger Logger to report messages
|
|
88
|
-
*/
|
|
89
|
-
declare const syncStateUpdate: (state: any, keys: StorageKeys, storage: Storage | undefined, storageKeySerializer: (key: string | number) => string, removeOnUndefined?: boolean, syncCondition?: (state: any) => any, logger?: Logger) => void;
|
|
90
|
-
/**
|
|
91
|
-
* Local and Session storage synchronization helper
|
|
92
|
-
* @param config
|
|
93
|
-
*/
|
|
94
|
-
declare const syncStorage: (config: SyncStorageConfig) => (reducer: any) => (state: any, action: any) => any;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Format of a key in `StoreSyncConfig`
|
|
98
|
-
*/
|
|
99
|
-
interface StoreSyncSerializers {
|
|
100
|
-
[storeName: string]: Serializer<any>;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* An interface defining the configuration attributes to bootstrap `storeSyncMetaReducer`
|
|
104
|
-
*/
|
|
105
|
-
interface StoreSyncConfig {
|
|
106
|
-
/** State keys to sync with storage */
|
|
107
|
-
keys: StoreSyncSerializers[];
|
|
108
|
-
/** Pull initial state from storage on startup */
|
|
109
|
-
rehydrate?: boolean;
|
|
110
|
-
/** Specify an object that conforms to the Storage interface to use, this will default to localStorage */
|
|
111
|
-
storage?: Storage;
|
|
112
|
-
/** When set, sync to storage will only occur when this function returns a true boolean */
|
|
113
|
-
syncCondition?: (state: any) => any;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Typings for async storage
|
|
117
|
-
*/
|
|
118
|
-
type AsyncStorage = Omit<Storage, 'getItem'> & {
|
|
119
|
-
getItem(key: string): Promise<string | null>;
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* Options for async storage sync
|
|
123
|
-
*/
|
|
124
|
-
interface AsyncStorageSyncOptions extends Omit<SyncStorageConfig, 'storage'> {
|
|
125
|
-
storage?: AsyncStorage;
|
|
126
|
-
}
|
|
127
|
-
/** Options for storage sync method */
|
|
128
|
-
type StorageSyncOptions = SyncStorageConfig | AsyncStorageSyncOptions;
|
|
129
|
-
/**
|
|
130
|
-
* Options that can be set on the Storage sync constructor
|
|
131
|
-
* postProcess and syncKeyCondition will be handled by the StorageSync class if smart sync is activated
|
|
132
|
-
*/
|
|
133
|
-
type StorageSyncConstructorOptions = Omit<StorageSyncOptions, 'postProcess' | 'syncKeyCondition'>;
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Storage synchronizer
|
|
137
|
-
*/
|
|
138
|
-
declare class StorageSync {
|
|
139
|
-
private readonly alreadyHydratedStoreSlices;
|
|
140
|
-
private hasHydrated;
|
|
141
|
-
private readonly storeImage;
|
|
142
|
-
options: StorageSyncOptions;
|
|
143
|
-
constructor(options?: StorageSyncConstructorOptions, extraOptions?: {
|
|
144
|
-
disableSmartSync: boolean;
|
|
145
|
-
});
|
|
146
|
-
/**
|
|
147
|
-
* Handle state manipulation in case of store storage sync
|
|
148
|
-
* Merge strategy is a full merge at init; When a new `store slice` is registered, its initial state is merged with its corresponding storage content
|
|
149
|
-
* Pass it as mergeReducer callback when calling localStorageSync function from 'ngrx-store-localstorage', in the app
|
|
150
|
-
* @param state actual state
|
|
151
|
-
* @param rehydratedState state from storage
|
|
152
|
-
* @param action Triggered action
|
|
153
|
-
*/
|
|
154
|
-
readonly mergeReducer: (state: any, rehydratedState: any, action: any) => any;
|
|
155
|
-
/**
|
|
156
|
-
* Returns a meta reducer that handles storage sync
|
|
157
|
-
*/
|
|
158
|
-
localStorageSync: () => (reducer: any) => (state: any, action: any) => any;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Defines if an object is a Serializer
|
|
163
|
-
* @param obj Object to test
|
|
164
|
-
* @returns True if the object is a Serializer
|
|
165
|
-
*/
|
|
166
|
-
declare const isSerializer: (obj: any) => obj is Serializer<any>;
|
|
167
|
-
/**
|
|
168
|
-
* Label of the action to rehydrate the store
|
|
169
|
-
*/
|
|
170
|
-
declare const REHYDRATE_ACTION_LABEL = "[storeSync] rehydrate";
|
|
171
|
-
/**
|
|
172
|
-
* Action to rehydrate the store
|
|
173
|
-
*/
|
|
174
|
-
declare const rehydrateAction: _ngrx_store.ActionCreator<"[storeSync] rehydrate", (props: {
|
|
175
|
-
payload: Record<string, any>;
|
|
176
|
-
}) => {
|
|
177
|
-
payload: Record<string, any>;
|
|
178
|
-
} & _ngrx_store.Action<"[storeSync] rehydrate">>;
|
|
179
|
-
/**
|
|
180
|
-
* Defines if the storage is a non-async storage
|
|
181
|
-
* @param options The storage config
|
|
182
|
-
* @returns in case the storage used is a non-async storage
|
|
183
|
-
*/
|
|
184
|
-
declare const isLocalStorageConfig: (options: StorageSyncOptions) => options is SyncStorageConfig;
|
|
185
|
-
|
|
186
|
-
export { REHYDRATE_ACTION_LABEL, StorageSync, dateReviver, isLocalStorageConfig, isSerializer, rehydrateAction, rehydrateApplicationState, syncStateUpdate, syncStorage };
|
|
187
|
-
export type { AsyncStorage, AsyncStorageSyncOptions, StorageKeyConfiguration, StorageKeys, StorageSyncConstructorOptions, StorageSyncOptions, StoreSyncConfig, StoreSyncSerializers, SyncStorageConfig, SyncStorageSyncOptions };
|
|
188
|
-
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sources":["../src/sync-storage/interfaces.ts","../src/sync-storage/storage-sync.ts","../src/core/interfaces.ts","../src/core/storage-sync.ts","../src/core/storage-sync-helpers.ts"],"sourcesContent":[null,null,null,null,null],"names":[],"mappings":";;;AAIA;;AAEG;;;;;;;AAOD;;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AAM;CACP,CAAC;AAEF;;GAEG;AACH,MAAM,wBAAwB,GAAa,EAC1C,CAAC;AAEF,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;AAE5E;;;GAGG;AACH,SAAS,OAAO,CAAC,OAA8B;IAC7C,OAAO,IAAA,kBAAK,EAAC;QACX,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE,CAAC,CAAC,CAAC,IAAA,2BAAc,GAAE;QAC9C,IAAA,kCAAqB,EAAC,OAAO,EAAE,eAAe,EAAE,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,CAAC;KACrG,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,MAAM,KAAK,GAAG,CAAC,OAA8B,EAAE,EAAE,CAAC,IAAA,iCAAoB,EAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;AAAnF,QAAA,KAAK,SAA8E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../schematics/ng-add/schema.ts"],"names":[],"mappings":""}
|