effector-storage 6.0.0 → 6.0.1

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 (55) hide show
  1. package/README.md +24 -15
  2. package/async-storage/index.cjs.d.ts +1 -1
  3. package/async-storage/index.d.ts +1 -1
  4. package/async-storage/index.js.flow +1 -1
  5. package/core/index.cjs.d.ts +1 -1
  6. package/core/index.d.ts +1 -1
  7. package/core/index.js.flow +1 -1
  8. package/index.cjs.d.ts +2 -1
  9. package/index.cjs.map +1 -1
  10. package/index.d.ts +2 -1
  11. package/index.js.flow +2 -1
  12. package/index.js.map +1 -1
  13. package/local/index.cjs.d.ts +10 -5
  14. package/local/index.cjs.map +1 -1
  15. package/local/index.d.ts +10 -5
  16. package/local/index.js.flow +14 -5
  17. package/local/index.js.map +1 -1
  18. package/log/index.cjs.d.ts +1 -1
  19. package/log/index.d.ts +1 -1
  20. package/log/index.js.flow +1 -1
  21. package/memory/index.cjs.d.ts +12 -7
  22. package/memory/index.cjs.map +1 -1
  23. package/memory/index.d.ts +12 -7
  24. package/memory/index.js.flow +19 -10
  25. package/memory/index.js.map +1 -1
  26. package/nil/index.cjs.d.ts +1 -1
  27. package/nil/index.d.ts +1 -1
  28. package/nil/index.js.flow +1 -1
  29. package/package.json +1 -1
  30. package/query/index.cjs.d.ts +10 -5
  31. package/query/index.cjs.map +1 -1
  32. package/query/index.d.ts +10 -5
  33. package/query/index.js.flow +14 -5
  34. package/query/index.js.map +1 -1
  35. package/rn/async/index.cjs.d.ts +10 -5
  36. package/rn/async/index.cjs.map +1 -1
  37. package/rn/async/index.d.ts +10 -5
  38. package/rn/async/index.js.flow +14 -5
  39. package/rn/async/index.js.map +1 -1
  40. package/rn/encrypted/index.cjs.d.ts +15 -5
  41. package/rn/encrypted/index.cjs.map +1 -1
  42. package/rn/encrypted/index.d.ts +15 -5
  43. package/rn/encrypted/index.js.flow +19 -5
  44. package/rn/encrypted/index.js.map +1 -1
  45. package/session/index.cjs.d.ts +10 -5
  46. package/session/index.cjs.map +1 -1
  47. package/session/index.d.ts +10 -5
  48. package/session/index.js.flow +14 -5
  49. package/session/index.js.map +1 -1
  50. package/storage/index.cjs.d.ts +1 -1
  51. package/storage/index.d.ts +1 -1
  52. package/storage/index.js.flow +1 -1
  53. package/tools/index.cjs.d.ts +1 -1
  54. package/tools/index.d.ts +1 -1
  55. package/tools/index.js.flow +1 -1
package/README.md CHANGED
@@ -19,6 +19,7 @@ Small module for [Effector](https://github.com/effector/effector) ☄️ to sync
19
19
  - [with query string](#with-query-string)
20
20
  - [with React Native AsyncStorage](#with-react-native-asyncstorage)
21
21
  - [with React Native EncryptedStorage](#with-react-native-encryptedstorage)
22
+ - [extra adapters](#extra-adapters)
22
23
  - [Usage with domains](#usage-with-domains)
23
24
  - [Formulae](#formulae)
24
25
  - [Units](#units)
@@ -63,7 +64,7 @@ $ npm install --save effector-storage
63
64
 
64
65
  ### with `localStorage`
65
66
 
66
- Docs: [effector-storage/local](https://github.com/yumauri/effector-storage/tree/master/src/local/README.md)
67
+ Docs: [effector-storage/local](https://github.com/yumauri/effector-storage/tree/main/src/local/README.md)
67
68
 
68
69
  ```javascript
69
70
  import { persist } from 'effector-storage/local'
@@ -79,7 +80,7 @@ Stores, persisted in `localStorage`, are automatically synced between two (or mo
79
80
 
80
81
  ### with `sessionStorage`
81
82
 
82
- Docs: [effector-storage/session](https://github.com/yumauri/effector-storage/tree/master/src/session/README.md)
83
+ Docs: [effector-storage/session](https://github.com/yumauri/effector-storage/tree/main/src/session/README.md)
83
84
 
84
85
  Same as above, just import `persist` from `'effector-storage/session'`:
85
86
 
@@ -91,7 +92,7 @@ Stores, persisted in `sessionStorage`, are synced between instances, but not bet
91
92
 
92
93
  ### with query string
93
94
 
94
- Docs: [effector-storage/query](https://github.com/yumauri/effector-storage/tree/master/src/query/README.md)
95
+ Docs: [effector-storage/query](https://github.com/yumauri/effector-storage/tree/main/src/query/README.md)
95
96
 
96
97
  You can _reflect_ plain string store value in query string parameter, using this adapter. Think of it like about synchronizing store value and query string parameter.
97
98
 
@@ -109,7 +110,9 @@ Use this only with plain string stores (`Store<string | null>`) to avoid strange
109
110
 
110
111
  ### with React Native AsyncStorage
111
112
 
112
- Docs: [effector-storage/rn/async](https://github.com/yumauri/effector-storage/tree/master/src/rn/async/README.md)
113
+ ❗️ Will be deprecated in next minor release and removed in next major release, in favor of [`@effector-storage/react-native-async-storage`](https://github.com/yumauri/effector-storage-extras/tree/main/packages/react-native-async-storage).
114
+
115
+ Docs: [effector-storage/rn/async](https://github.com/yumauri/effector-storage/tree/main/src/rn/async/README.md)
113
116
 
114
117
  ```javascript
115
118
  import { persist } from 'effector-storage/rn/async'
@@ -125,7 +128,9 @@ persist({ store: $counter })
125
128
 
126
129
  ### with React Native EncryptedStorage
127
130
 
128
- Docs: [effector-storage/rn/encrypted](https://github.com/yumauri/effector-storage/tree/master/src/rn/encrypted/README.md)
131
+ ❗️ Will be deprecated in next minor release and removed in next major release, in favor of [`@effector-storage/react-native-encrypted-storage`](https://github.com/yumauri/effector-storage-extras/tree/main/packages/react-native-encrypted-storage).
132
+
133
+ Docs: [effector-storage/rn/encrypted](https://github.com/yumauri/effector-storage/tree/main/src/rn/encrypted/README.md)
129
134
 
130
135
  ```javascript
131
136
  import { persist } from 'effector-storage/rn/encrypted'
@@ -139,6 +144,10 @@ persist({ store: $counter })
139
144
 
140
145
  ⚠️ Note, that [EncryptedStorage] is asynchronous (it is based on [AsyncStorage] actually).
141
146
 
147
+ ### extra adapters
148
+
149
+ You can find a collection of useful adapters in [effector-storage-extras](https://github.com/yumauri/effector-storage-extras). That side repository was created in order to not bloat `effector-storage` with dependencies and adapters, which depends on other libraries.
150
+
142
151
  ## Usage with domains
143
152
 
144
153
  You can use `persist` inside Domain's `onCreateStore` hook:
@@ -250,14 +259,14 @@ persist({
250
259
 
251
260
  There are two gotchas with contracts:
252
261
 
253
- 1. From `effector-storage` point of view it is absolutely normal, when there is no persisted value in the storage yet. So, `undefined` value is _always valid_, event if contract is not explicitly allows it.
254
- 2. `effector-storage` does not validate data, which is written to the storage. But it will validate it nonetheless, after persisting, so, if you write invalid data to the storage, `fail` will be triggered, but data _will be_ persisted.
262
+ 1. From `effector-storage` point of view it is absolutely normal, when there is no persisted value in the storage yet. So, `undefined` value is _always valid_, even if contract does not explicitly allow it.
263
+ 2. `effector-storage` does not prevent persisting invalid data to the storage, but it will validate it nonetheless, after persisting, so, if you write invalid data to the storage, `fail` will be triggered, but data will be persisted.
255
264
 
256
265
  ### Notes
257
266
 
258
267
  Without specifying `pickup` property, calling `persist` will immediately call adapter to get initial value. In case of synchronous storage (like `localStorage` or `sessionStorage`) this action will synchronously set store value, and call `done`/`fail`/`finally` right away. You should take that into account, if you adds some logic on `done`, for example — place `persist` after that logic (see issue [#38](https://github.com/yumauri/effector-storage/issues/38) for more details).
259
268
 
260
- You can modify adapter to be asynchronous to mitigate this behavior with [`async`](https://github.com/yumauri/effector-storage/tree/master/src/tools/README.md#async) function.
269
+ You can modify adapter to be asynchronous to mitigate this behavior with [`async`](https://github.com/yumauri/effector-storage/tree/main/src/tools/README.md#async) function.
261
270
 
262
271
  ## `createPersist` factory
263
272
 
@@ -316,7 +325,7 @@ Adapter is a function, which is called by the core `persist` function, and has f
316
325
  ```typescript
317
326
  interface StorageAdapter {
318
327
  <State>(key: string, update: (raw?: any) => any): {
319
- get(raw?: any, ctx?: any): State | Promise<State>
328
+ get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
320
329
  set(value: State, ctx?: any): void
321
330
  }
322
331
  keyArea?: any
@@ -342,7 +351,7 @@ In case it is omitted — adapter instances is used instead.
342
351
 
343
352
  #### noop
344
353
 
345
- Marks adapter as "no-op" for [`either`](https://github.com/yumauri/effector-storage/tree/master/src/tools/README.md#either) function.
354
+ Marks adapter as "no-op" for [`either`](https://github.com/yumauri/effector-storage/tree/main/src/tools/README.md#either) function.
346
355
 
347
356
  ### Synchronous storage adapter example
348
357
 
@@ -550,11 +559,11 @@ Use this approach with caution, beware of infinite circular updates. To avoid th
550
559
 
551
560
  ## TODO
552
561
 
553
- - [x] [localStorage] support (docs: [effector-storage/local](https://github.com/yumauri/effector-storage/tree/master/src/local/README.md))
554
- - [x] [sessionStorage] support (docs: [effector-storage/session](https://github.com/yumauri/effector-storage/tree/master/src/session/README.md))
555
- - [x] [query string](https://developer.mozilla.org/en-US/docs/Web/API/Location/search) support (docs: [effector-storage/query](https://github.com/yumauri/effector-storage/tree/master/src/query/README.md))
556
- - [x] [AsyncStorage] support (docs: [effector-storage/rn/async](https://github.com/yumauri/effector-storage/tree/master/src/rn/async/README.md))
557
- - [x] [EncryptedStorage] support (docs: [effector-storage/rn/encrypted](https://github.com/yumauri/effector-storage/tree/master/src/rn/encrypted/README.md))
562
+ - [x] [localStorage] support (docs: [effector-storage/local](https://github.com/yumauri/effector-storage/tree/main/src/local/README.md))
563
+ - [x] [sessionStorage] support (docs: [effector-storage/session](https://github.com/yumauri/effector-storage/tree/main/src/session/README.md))
564
+ - [x] [query string](https://developer.mozilla.org/en-US/docs/Web/API/Location/search) support (docs: [effector-storage/query](https://github.com/yumauri/effector-storage/tree/main/src/query/README.md))
565
+ - [x] [AsyncStorage] support (docs: [effector-storage/rn/async](https://github.com/yumauri/effector-storage/tree/main/src/rn/async/README.md))
566
+ - [x] [EncryptedStorage] support (docs: [effector-storage/rn/encrypted](https://github.com/yumauri/effector-storage/tree/main/src/rn/encrypted/README.md))
558
567
  - [ ] [IndexedDB] support
559
568
  - [ ] [Cookies] support
560
569
  - [ ] you name it support
@@ -1,6 +1,6 @@
1
1
  interface StorageAdapter {
2
2
  <State>(key: string, update: (raw?: any) => any): {
3
- get(raw?: any, ctx?: any): State | Promise<State>
3
+ get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
4
4
  set(value: State, ctx?: any): void
5
5
  }
6
6
  keyArea?: any
@@ -1,6 +1,6 @@
1
1
  interface StorageAdapter {
2
2
  <State>(key: string, update: (raw?: any) => any): {
3
- get(raw?: any, ctx?: any): State | Promise<State>
3
+ get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
4
4
  set(value: State, ctx?: any): void
5
5
  }
6
6
  keyArea?: any
@@ -10,7 +10,7 @@ declare interface StorageAdapter {
10
10
  key: string,
11
11
  update: (raw?: any) => any
12
12
  ): {
13
- get(raw?: any, ctx?: any): State | Promise<State>,
13
+ get(raw?: any, ctx?: any): State | Promise<State | void> | void,
14
14
  set(value: State, ctx?: any): void,
15
15
  ...
16
16
  };
@@ -2,7 +2,7 @@ import { Unit, Store, Event, Effect, Subscription } from 'effector'
2
2
 
3
3
  interface StorageAdapter {
4
4
  <State>(key: string, update: (raw?: any) => any): {
5
- get(raw?: any, ctx?: any): State | Promise<State>
5
+ get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
6
6
  set(value: State, ctx?: any): void
7
7
  }
8
8
  keyArea?: any
package/core/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { Unit, Store, Event, Effect, Subscription } from 'effector'
2
2
 
3
3
  interface StorageAdapter {
4
4
  <State>(key: string, update: (raw?: any) => any): {
5
- get(raw?: any, ctx?: any): State | Promise<State>
5
+ get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
6
6
  set(value: State, ctx?: any): void
7
7
  }
8
8
  keyArea?: any
@@ -11,7 +11,7 @@ declare interface StorageAdapter {
11
11
  key: string,
12
12
  update: (raw?: any) => any
13
13
  ): {
14
- get(raw?: any, ctx?: any): State | Promise<State>,
14
+ get(raw?: any, ctx?: any): State | Promise<State | void> | void,
15
15
  set(value: State, ctx?: any): void,
16
16
  ...
17
17
  };
package/index.cjs.d.ts CHANGED
@@ -11,7 +11,7 @@ export { async, either, farcached } from './tools'
11
11
 
12
12
  interface StorageAdapter {
13
13
  <State>(key: string, update: (raw?: any) => any): {
14
- get(raw?: any, ctx?: any): State | Promise<State>
14
+ get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
15
15
  set(value: State, ctx?: any): void
16
16
  }
17
17
  keyArea?: any
@@ -115,6 +115,7 @@ export {
115
115
  ConfigPersist,
116
116
  ConfigSourceTarget,
117
117
  ConfigStore,
118
+ Contract,
118
119
  Done,
119
120
  Fail,
120
121
  Finally,
package/index.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import type { ConfigPersist, Persist } from './types'\nimport { persist as base } from './core'\n\nexport type {\n ConfigPersist,\n ConfigSourceTarget,\n ConfigStore,\n Done,\n Fail,\n Finally,\n Persist,\n StorageAdapter,\n StorageAdapterFactory,\n} from './types'\n\n//\n// reexport adapters\n//\n\nexport type { AsyncStorageConfig } from './async-storage'\nexport type { LocalStorageConfig } from './local'\nexport type { LogConfig } from './log'\nexport type { MemoryConfig } from './memory'\nexport type { NilConfig } from './nil'\nexport type { QueryConfig } from './query'\nexport type { SessionStorageConfig } from './session'\nexport type { StorageConfig } from './storage'\n\nexport { asyncStorage } from './async-storage'\nexport { local } from './local'\nexport { log } from './log'\nexport { memory } from './memory'\nexport { nil } from './nil'\nexport { query } from './query'\nexport { session } from './session'\nexport { storage } from './storage'\n\n//\n// reexport tools\n//\n\nexport { async, either, farcached } from './tools'\n\n/**\n * Creates custom `persist`\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config: any) =>\n base({\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default `persist`\n */\nexport const persist: Persist = base\n"],"names":["persist","base","defaults","config"],"mappings":"+UAyDaA,EAAmBC,EAAAA,0SAXzB,SAAuBC,GAC5B,OAAQC,GACNF,EAAAA,QAAK,IACAC,KACAC,GAET"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import type { ConfigPersist, Persist } from './types'\nimport { persist as base } from './core'\n\nexport type {\n ConfigPersist,\n ConfigSourceTarget,\n ConfigStore,\n Contract,\n Done,\n Fail,\n Finally,\n Persist,\n StorageAdapter,\n StorageAdapterFactory,\n} from './types'\n\n//\n// reexport adapters\n//\n\nexport type { AsyncStorageConfig } from './async-storage'\nexport type { LocalStorageConfig } from './local'\nexport type { LogConfig } from './log'\nexport type { MemoryConfig } from './memory'\nexport type { NilConfig } from './nil'\nexport type { QueryConfig } from './query'\nexport type { SessionStorageConfig } from './session'\nexport type { StorageConfig } from './storage'\n\nexport { asyncStorage } from './async-storage'\nexport { local } from './local'\nexport { log } from './log'\nexport { memory } from './memory'\nexport { nil } from './nil'\nexport { query } from './query'\nexport { session } from './session'\nexport { storage } from './storage'\n\n//\n// reexport tools\n//\n\nexport { async, either, farcached } from './tools'\n\n/**\n * Creates custom `persist`\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config: any) =>\n base({\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default `persist`\n */\nexport const persist: Persist = base\n"],"names":["persist","base","defaults","config"],"mappings":"+UA0DaA,EAAmBC,EAAAA,0SAXzB,SAAuBC,GAC5B,OAAQC,GACNF,EAAAA,QAAK,IACAC,KACAC,GAET"}
package/index.d.ts CHANGED
@@ -11,7 +11,7 @@ export { async, either, farcached } from './tools'
11
11
 
12
12
  interface StorageAdapter {
13
13
  <State>(key: string, update: (raw?: any) => any): {
14
- get(raw?: any, ctx?: any): State | Promise<State>
14
+ get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
15
15
  set(value: State, ctx?: any): void
16
16
  }
17
17
  keyArea?: any
@@ -115,6 +115,7 @@ export {
115
115
  ConfigPersist,
116
116
  ConfigSourceTarget,
117
117
  ConfigStore,
118
+ Contract,
118
119
  Done,
119
120
  Fail,
120
121
  Finally,
package/index.js.flow CHANGED
@@ -20,7 +20,7 @@ declare interface StorageAdapter {
20
20
  key: string,
21
21
  update: (raw?: any) => any
22
22
  ): {
23
- get(raw?: any, ctx?: any): State | Promise<State>,
23
+ get(raw?: any, ctx?: any): State | Promise<State | void> | void,
24
24
  set(value: State, ctx?: any): void,
25
25
  ...
26
26
  };
@@ -134,6 +134,7 @@ declare export {
134
134
  ConfigPersist,
135
135
  ConfigSourceTarget,
136
136
  ConfigStore,
137
+ Contract,
137
138
  Done,
138
139
  Fail,
139
140
  Finally,
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { ConfigPersist, Persist } from './types'\nimport { persist as base } from './core'\n\nexport type {\n ConfigPersist,\n ConfigSourceTarget,\n ConfigStore,\n Done,\n Fail,\n Finally,\n Persist,\n StorageAdapter,\n StorageAdapterFactory,\n} from './types'\n\n//\n// reexport adapters\n//\n\nexport type { AsyncStorageConfig } from './async-storage'\nexport type { LocalStorageConfig } from './local'\nexport type { LogConfig } from './log'\nexport type { MemoryConfig } from './memory'\nexport type { NilConfig } from './nil'\nexport type { QueryConfig } from './query'\nexport type { SessionStorageConfig } from './session'\nexport type { StorageConfig } from './storage'\n\nexport { asyncStorage } from './async-storage'\nexport { local } from './local'\nexport { log } from './log'\nexport { memory } from './memory'\nexport { nil } from './nil'\nexport { query } from './query'\nexport { session } from './session'\nexport { storage } from './storage'\n\n//\n// reexport tools\n//\n\nexport { async, either, farcached } from './tools'\n\n/**\n * Creates custom `persist`\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config: any) =>\n base({\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default `persist`\n */\nexport const persist: Persist = base\n"],"names":["createPersist","defaults","config","base","persist"],"mappings":"gZA8CO,SAASA,EAAcC,GAC5B,OAAQC,GACNC,EAAK,IACAF,KACAC,GAET,CAKO,IAAME,EAAmBD"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { ConfigPersist, Persist } from './types'\nimport { persist as base } from './core'\n\nexport type {\n ConfigPersist,\n ConfigSourceTarget,\n ConfigStore,\n Contract,\n Done,\n Fail,\n Finally,\n Persist,\n StorageAdapter,\n StorageAdapterFactory,\n} from './types'\n\n//\n// reexport adapters\n//\n\nexport type { AsyncStorageConfig } from './async-storage'\nexport type { LocalStorageConfig } from './local'\nexport type { LogConfig } from './log'\nexport type { MemoryConfig } from './memory'\nexport type { NilConfig } from './nil'\nexport type { QueryConfig } from './query'\nexport type { SessionStorageConfig } from './session'\nexport type { StorageConfig } from './storage'\n\nexport { asyncStorage } from './async-storage'\nexport { local } from './local'\nexport { log } from './log'\nexport { memory } from './memory'\nexport { nil } from './nil'\nexport { query } from './query'\nexport { session } from './session'\nexport { storage } from './storage'\n\n//\n// reexport tools\n//\n\nexport { async, either, farcached } from './tools'\n\n/**\n * Creates custom `persist`\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config: any) =>\n base({\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default `persist`\n */\nexport const persist: Persist = base\n"],"names":["createPersist","defaults","config","base","persist"],"mappings":"gZA+CO,SAASA,EAAcC,GAC5B,OAAQC,GACNC,EAAK,IACAF,KACAC,GAET,CAKO,IAAME,EAAmBD"}
@@ -2,7 +2,7 @@ import { Unit, Store, Event, Effect, Subscription } from 'effector'
2
2
 
3
3
  interface StorageAdapter {
4
4
  <State>(key: string, update: (raw?: any) => any): {
5
- get(raw?: any, ctx?: any): State | Promise<State>
5
+ get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
6
6
  set(value: State, ctx?: any): void
7
7
  }
8
8
  keyArea?: any
@@ -62,6 +62,12 @@ interface ConfigJustSourceTarget<State> {
62
62
  source: Store<State> | Event<State> | Effect<State, any, any>
63
63
  target: Store<State> | Event<State> | Effect<State, any, any>
64
64
  }
65
+ interface ConfigStore$1<State, Err = Error>
66
+ extends ConfigCommon<State, Err>,
67
+ ConfigJustStore<State> {}
68
+ interface ConfigSourceTarget$1<State, Err = Error>
69
+ extends ConfigCommon<State, Err>,
70
+ ConfigJustSourceTarget<State> {}
65
71
 
66
72
  interface ConfigPersist extends ConfigPersist$1 {
67
73
  sync?: boolean | 'force'
@@ -76,12 +82,10 @@ interface LocalStorageConfig {
76
82
  }
77
83
  interface ConfigStore<State, Err = Error>
78
84
  extends LocalStorageConfig,
79
- ConfigCommon<State, Err>,
80
- ConfigJustStore<State> {}
85
+ ConfigStore$1<State, Err> {}
81
86
  interface ConfigSourceTarget<State, Err = Error>
82
87
  extends LocalStorageConfig,
83
- ConfigCommon<State, Err>,
84
- ConfigJustSourceTarget<State> {}
88
+ ConfigSourceTarget$1<State, Err> {}
85
89
  interface Persist {
86
90
  <State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription
87
91
  <State, Err = Error>(config: ConfigStore<State, Err>): Subscription
@@ -104,6 +108,7 @@ export {
104
108
  ConfigPersist,
105
109
  ConfigSourceTarget,
106
110
  ConfigStore,
111
+ Contract,
107
112
  Done,
108
113
  Fail,
109
114
  Finally,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/local/index.ts"],"sourcesContent":["import type { Subscription } from 'effector'\nimport type {\n ConfigPersist as BaseConfigPersist,\n ConfigCommon,\n ConfigJustStore,\n ConfigJustSourceTarget,\n StorageAdapter,\n} from '../types'\nimport { persist as base } from '../core'\nimport { nil } from '../nil'\nimport { storage } from '../storage'\n\nexport type {\n Done,\n Fail,\n Finally,\n StorageAdapter,\n StorageAdapterFactory,\n} from '../types'\n\nexport interface ConfigPersist extends BaseConfigPersist {\n sync?: boolean | 'force'\n timeout?: number\n}\n\nexport interface LocalStorageConfig {\n sync?: boolean | 'force'\n serialize?: (value: any) => string\n deserialize?: (value: string) => any\n timeout?: number\n def?: any\n}\n\nexport interface ConfigStore<State, Err = Error>\n extends LocalStorageConfig,\n ConfigCommon<State, Err>,\n ConfigJustStore<State> {}\n\nexport interface ConfigSourceTarget<State, Err = Error>\n extends LocalStorageConfig,\n ConfigCommon<State, Err>,\n ConfigJustSourceTarget<State> {}\n\nexport interface Persist {\n <State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription\n <State, Err = Error>(config: ConfigStore<State, Err>): Subscription\n}\n\n/**\n * Function, checking if `localStorage` exists\n */\nfunction supports() {\n try {\n return typeof localStorage !== 'undefined'\n } catch (error) {\n // accessing `localStorage` could throw an exception only in one case -\n // when `localStorage` IS supported, but blocked by security policies\n return true\n }\n}\n\n/**\n * Creates `localStorage` adapter\n */\nlocal.factory = true as const\nexport function local(config?: LocalStorageConfig): StorageAdapter {\n return supports()\n ? storage({\n storage: () => localStorage,\n sync: true,\n ...config,\n })\n : nil({ keyArea: 'local' })\n}\n\n/**\n * Creates custom partially applied `persist`\n * with predefined `localStorage` adapter\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config) =>\n base({\n adapter: local,\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default partially applied `persist`\n */\nexport const persist = createPersist()\n"],"names":["local","config","localStorage","error","supports","storage","sync","nil","keyArea","createPersist","defaults","base","adapter","factory","persist"],"mappings":"gHAiEO,SAASA,EAAMC,GACpB,OAfF,WACE,IACE,MAA+B,oBAAjBC,YACf,CAAC,MAAOC,GAGP,OAAO,CACT,CACF,CAOSC,GACHC,UAAQ,CACNA,QAASA,IAAMH,aACfI,MAAM,KACHL,IAELM,EAAAA,IAAI,CAAEC,QAAS,SACrB,CAMO,SAASC,EAAcC,GAC5B,OAAQT,GACNU,EAAAA,QAAK,CACHC,QAASZ,KACNU,KACAT,GAET,CAtBAD,EAAMa,SAAU,EA2BHC,IAAAA,EAAUL"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/local/index.ts"],"sourcesContent":["import type { Subscription } from 'effector'\nimport type {\n ConfigPersist as BaseConfigPersist,\n ConfigStore as BaseConfigStore,\n ConfigSourceTarget as BaseConfigSourceTarget,\n StorageAdapter,\n} from '../types'\nimport { persist as base } from '../core'\nimport { nil } from '../nil'\nimport { storage } from '../storage'\n\nexport type {\n Contract,\n Done,\n Fail,\n Finally,\n StorageAdapter,\n StorageAdapterFactory,\n} from '../types'\n\nexport interface ConfigPersist extends BaseConfigPersist {\n sync?: boolean | 'force'\n timeout?: number\n}\n\nexport interface LocalStorageConfig {\n sync?: boolean | 'force'\n serialize?: (value: any) => string\n deserialize?: (value: string) => any\n timeout?: number\n def?: any\n}\n\nexport interface ConfigStore<State, Err = Error>\n extends LocalStorageConfig,\n BaseConfigStore<State, Err> {}\n\nexport interface ConfigSourceTarget<State, Err = Error>\n extends LocalStorageConfig,\n BaseConfigSourceTarget<State, Err> {}\n\nexport interface Persist {\n <State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription\n <State, Err = Error>(config: ConfigStore<State, Err>): Subscription\n}\n\n/**\n * Function, checking if `localStorage` exists\n */\nfunction supports() {\n try {\n return typeof localStorage !== 'undefined'\n } catch (error) {\n // accessing `localStorage` could throw an exception only in one case -\n // when `localStorage` IS supported, but blocked by security policies\n return true\n }\n}\n\n/**\n * Creates `localStorage` adapter\n */\nlocal.factory = true as const\nexport function local(config?: LocalStorageConfig): StorageAdapter {\n return supports()\n ? storage({\n storage: () => localStorage,\n sync: true,\n ...config,\n })\n : nil({ keyArea: 'local' })\n}\n\n/**\n * Creates custom partially applied `persist`\n * with predefined `localStorage` adapter\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config) =>\n base({\n adapter: local,\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default partially applied `persist`\n */\nexport const persist = createPersist()\n"],"names":["local","config","localStorage","error","supports","storage","sync","nil","keyArea","createPersist","defaults","base","adapter","factory","persist"],"mappings":"gHA+DO,SAASA,EAAMC,GACpB,OAfF,WACE,IACE,MAA+B,oBAAjBC,YACf,CAAC,MAAOC,GAGP,OAAO,CACT,CACF,CAOSC,GACHC,UAAQ,CACNA,QAASA,IAAMH,aACfI,MAAM,KACHL,IAELM,EAAAA,IAAI,CAAEC,QAAS,SACrB,CAMO,SAASC,EAAcC,GAC5B,OAAQT,GACNU,EAAAA,QAAK,CACHC,QAASZ,KACNU,KACAT,GAET,CAtBAD,EAAMa,SAAU,EA2BHC,IAAAA,EAAUL"}
package/local/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { Unit, Store, Event, Effect, Subscription } from 'effector'
2
2
 
3
3
  interface StorageAdapter {
4
4
  <State>(key: string, update: (raw?: any) => any): {
5
- get(raw?: any, ctx?: any): State | Promise<State>
5
+ get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
6
6
  set(value: State, ctx?: any): void
7
7
  }
8
8
  keyArea?: any
@@ -62,6 +62,12 @@ interface ConfigJustSourceTarget<State> {
62
62
  source: Store<State> | Event<State> | Effect<State, any, any>
63
63
  target: Store<State> | Event<State> | Effect<State, any, any>
64
64
  }
65
+ interface ConfigStore$1<State, Err = Error>
66
+ extends ConfigCommon<State, Err>,
67
+ ConfigJustStore<State> {}
68
+ interface ConfigSourceTarget$1<State, Err = Error>
69
+ extends ConfigCommon<State, Err>,
70
+ ConfigJustSourceTarget<State> {}
65
71
 
66
72
  interface ConfigPersist extends ConfigPersist$1 {
67
73
  sync?: boolean | 'force'
@@ -76,12 +82,10 @@ interface LocalStorageConfig {
76
82
  }
77
83
  interface ConfigStore<State, Err = Error>
78
84
  extends LocalStorageConfig,
79
- ConfigCommon<State, Err>,
80
- ConfigJustStore<State> {}
85
+ ConfigStore$1<State, Err> {}
81
86
  interface ConfigSourceTarget<State, Err = Error>
82
87
  extends LocalStorageConfig,
83
- ConfigCommon<State, Err>,
84
- ConfigJustSourceTarget<State> {}
88
+ ConfigSourceTarget$1<State, Err> {}
85
89
  interface Persist {
86
90
  <State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription
87
91
  <State, Err = Error>(config: ConfigStore<State, Err>): Subscription
@@ -104,6 +108,7 @@ export {
104
108
  ConfigPersist,
105
109
  ConfigSourceTarget,
106
110
  ConfigStore,
111
+ Contract,
107
112
  Done,
108
113
  Fail,
109
114
  Finally,
@@ -11,7 +11,7 @@ declare interface StorageAdapter {
11
11
  key: string,
12
12
  update: (raw?: any) => any
13
13
  ): {
14
- get(raw?: any, ctx?: any): State | Promise<State>,
14
+ get(raw?: any, ctx?: any): State | Promise<State | void> | void,
15
15
  set(value: State, ctx?: any): void,
16
16
  ...
17
17
  };
@@ -83,6 +83,16 @@ declare interface ConfigJustSourceTarget<State> {
83
83
  source: Store<State> | Event<State> | Effect<State, any, any>;
84
84
  target: Store<State> | Event<State> | Effect<State, any, any>;
85
85
  }
86
+ declare type ConfigStore$1<State, Err = Error> = { ... } & ConfigCommon<
87
+ State,
88
+ Err
89
+ > &
90
+ ConfigJustStore<State>
91
+ declare type ConfigSourceTarget$1<State, Err = Error> = { ... } & ConfigCommon<
92
+ State,
93
+ Err
94
+ > &
95
+ ConfigJustSourceTarget<State>
86
96
  declare type ConfigPersist = {
87
97
  sync?: boolean | 'force',
88
98
  timeout?: number,
@@ -96,13 +106,11 @@ declare interface LocalStorageConfig {
96
106
  def?: any;
97
107
  }
98
108
  declare type ConfigStore<State, Err = Error> = { ... } & LocalStorageConfig &
99
- ConfigCommon<State, Err> &
100
- ConfigJustStore<State>
109
+ ConfigStore$1<State, Err>
101
110
  declare type ConfigSourceTarget<State, Err = Error> = {
102
111
  ...
103
112
  } & LocalStorageConfig &
104
- ConfigCommon<State, Err> &
105
- ConfigJustSourceTarget<State>
113
+ ConfigSourceTarget$1<State, Err>
106
114
  declare interface Persist {
107
115
  <State, Err>(config: ConfigSourceTarget<State, Err>): Subscription;
108
116
  <State, Err>(config: ConfigStore<State, Err>): Subscription;
@@ -120,6 +128,7 @@ declare export {
120
128
  ConfigPersist,
121
129
  ConfigSourceTarget,
122
130
  ConfigStore,
131
+ Contract,
123
132
  Done,
124
133
  Fail,
125
134
  Finally,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/local/index.ts"],"sourcesContent":["import type { Subscription } from 'effector'\nimport type {\n ConfigPersist as BaseConfigPersist,\n ConfigCommon,\n ConfigJustStore,\n ConfigJustSourceTarget,\n StorageAdapter,\n} from '../types'\nimport { persist as base } from '../core'\nimport { nil } from '../nil'\nimport { storage } from '../storage'\n\nexport type {\n Done,\n Fail,\n Finally,\n StorageAdapter,\n StorageAdapterFactory,\n} from '../types'\n\nexport interface ConfigPersist extends BaseConfigPersist {\n sync?: boolean | 'force'\n timeout?: number\n}\n\nexport interface LocalStorageConfig {\n sync?: boolean | 'force'\n serialize?: (value: any) => string\n deserialize?: (value: string) => any\n timeout?: number\n def?: any\n}\n\nexport interface ConfigStore<State, Err = Error>\n extends LocalStorageConfig,\n ConfigCommon<State, Err>,\n ConfigJustStore<State> {}\n\nexport interface ConfigSourceTarget<State, Err = Error>\n extends LocalStorageConfig,\n ConfigCommon<State, Err>,\n ConfigJustSourceTarget<State> {}\n\nexport interface Persist {\n <State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription\n <State, Err = Error>(config: ConfigStore<State, Err>): Subscription\n}\n\n/**\n * Function, checking if `localStorage` exists\n */\nfunction supports() {\n try {\n return typeof localStorage !== 'undefined'\n } catch (error) {\n // accessing `localStorage` could throw an exception only in one case -\n // when `localStorage` IS supported, but blocked by security policies\n return true\n }\n}\n\n/**\n * Creates `localStorage` adapter\n */\nlocal.factory = true as const\nexport function local(config?: LocalStorageConfig): StorageAdapter {\n return supports()\n ? storage({\n storage: () => localStorage,\n sync: true,\n ...config,\n })\n : nil({ keyArea: 'local' })\n}\n\n/**\n * Creates custom partially applied `persist`\n * with predefined `localStorage` adapter\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config) =>\n base({\n adapter: local,\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default partially applied `persist`\n */\nexport const persist = createPersist()\n"],"names":["local","config","localStorage","error","supports","storage","sync","nil","keyArea","createPersist","defaults","base","adapter","factory","persist"],"mappings":"+HAiEO,SAASA,EAAMC,GACpB,OAfF,WACE,IACE,MAA+B,oBAAjBC,YACf,CAAC,MAAOC,GAGP,OAAO,CACT,CACF,CAOSC,GACHC,EAAQ,CACNA,QAASA,IAAMH,aACfI,MAAM,KACHL,IAELM,EAAI,CAAEC,QAAS,SACrB,CAMO,SAASC,EAAcC,GAC5B,OAAQT,GACNU,EAAK,CACHC,QAASZ,KACNU,KACAT,GAET,CAtBAD,EAAMa,SAAU,EA2BHC,IAAAA,EAAUL"}
1
+ {"version":3,"file":"index.js","sources":["../../src/local/index.ts"],"sourcesContent":["import type { Subscription } from 'effector'\nimport type {\n ConfigPersist as BaseConfigPersist,\n ConfigStore as BaseConfigStore,\n ConfigSourceTarget as BaseConfigSourceTarget,\n StorageAdapter,\n} from '../types'\nimport { persist as base } from '../core'\nimport { nil } from '../nil'\nimport { storage } from '../storage'\n\nexport type {\n Contract,\n Done,\n Fail,\n Finally,\n StorageAdapter,\n StorageAdapterFactory,\n} from '../types'\n\nexport interface ConfigPersist extends BaseConfigPersist {\n sync?: boolean | 'force'\n timeout?: number\n}\n\nexport interface LocalStorageConfig {\n sync?: boolean | 'force'\n serialize?: (value: any) => string\n deserialize?: (value: string) => any\n timeout?: number\n def?: any\n}\n\nexport interface ConfigStore<State, Err = Error>\n extends LocalStorageConfig,\n BaseConfigStore<State, Err> {}\n\nexport interface ConfigSourceTarget<State, Err = Error>\n extends LocalStorageConfig,\n BaseConfigSourceTarget<State, Err> {}\n\nexport interface Persist {\n <State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription\n <State, Err = Error>(config: ConfigStore<State, Err>): Subscription\n}\n\n/**\n * Function, checking if `localStorage` exists\n */\nfunction supports() {\n try {\n return typeof localStorage !== 'undefined'\n } catch (error) {\n // accessing `localStorage` could throw an exception only in one case -\n // when `localStorage` IS supported, but blocked by security policies\n return true\n }\n}\n\n/**\n * Creates `localStorage` adapter\n */\nlocal.factory = true as const\nexport function local(config?: LocalStorageConfig): StorageAdapter {\n return supports()\n ? storage({\n storage: () => localStorage,\n sync: true,\n ...config,\n })\n : nil({ keyArea: 'local' })\n}\n\n/**\n * Creates custom partially applied `persist`\n * with predefined `localStorage` adapter\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config) =>\n base({\n adapter: local,\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default partially applied `persist`\n */\nexport const persist = createPersist()\n"],"names":["local","config","localStorage","error","supports","storage","sync","nil","keyArea","createPersist","defaults","base","adapter","factory","persist"],"mappings":"+HA+DO,SAASA,EAAMC,GACpB,OAfF,WACE,IACE,MAA+B,oBAAjBC,YACf,CAAC,MAAOC,GAGP,OAAO,CACT,CACF,CAOSC,GACHC,EAAQ,CACNA,QAASA,IAAMH,aACfI,MAAM,KACHL,IAELM,EAAI,CAAEC,QAAS,SACrB,CAMO,SAASC,EAAcC,GAC5B,OAAQT,GACNU,EAAK,CACHC,QAASZ,KACNU,KACAT,GAET,CAtBAD,EAAMa,SAAU,EA2BHC,IAAAA,EAAUL"}
@@ -1,6 +1,6 @@
1
1
  interface StorageAdapter {
2
2
  <State>(key: string, update: (raw?: any) => any): {
3
- get(raw?: any, ctx?: any): State | Promise<State>
3
+ get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
4
4
  set(value: State, ctx?: any): void
5
5
  }
6
6
  keyArea?: any
package/log/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  interface StorageAdapter {
2
2
  <State>(key: string, update: (raw?: any) => any): {
3
- get(raw?: any, ctx?: any): State | Promise<State>
3
+ get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
4
4
  set(value: State, ctx?: any): void
5
5
  }
6
6
  keyArea?: any
package/log/index.js.flow CHANGED
@@ -10,7 +10,7 @@ declare interface StorageAdapter {
10
10
  key: string,
11
11
  update: (raw?: any) => any
12
12
  ): {
13
- get(raw?: any, ctx?: any): State | Promise<State>,
13
+ get(raw?: any, ctx?: any): State | Promise<State | void> | void,
14
14
  set(value: State, ctx?: any): void,
15
15
  ...
16
16
  };
@@ -2,7 +2,7 @@ import { Unit, Store, Event, Effect, Subscription } from 'effector'
2
2
 
3
3
  interface StorageAdapter {
4
4
  <State>(key: string, update: (raw?: any) => any): {
5
- get(raw?: any, ctx?: any): State | Promise<State>
5
+ get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
6
6
  set(value: State, ctx?: any): void
7
7
  }
8
8
  keyArea?: any
@@ -38,7 +38,7 @@ type Finally<State, Err> =
38
38
  | (Fail<Err> & {
39
39
  status: 'fail'
40
40
  })
41
- interface ConfigPersist {
41
+ interface ConfigPersist$1 {
42
42
  pickup?: Unit<any>
43
43
  context?: Unit<any>
44
44
  keyPrefix?: string
@@ -62,6 +62,12 @@ interface ConfigJustSourceTarget<State> {
62
62
  source: Store<State> | Event<State> | Effect<State, any, any>
63
63
  target: Store<State> | Event<State> | Effect<State, any, any>
64
64
  }
65
+ interface ConfigStore$1<State, Err = Error>
66
+ extends ConfigCommon<State, Err>,
67
+ ConfigJustStore<State> {}
68
+ interface ConfigSourceTarget$1<State, Err = Error>
69
+ extends ConfigCommon<State, Err>,
70
+ ConfigJustSourceTarget<State> {}
65
71
 
66
72
  interface MemoryConfig {
67
73
  area?: Map<string, any>
@@ -71,12 +77,10 @@ declare namespace adapter {
71
77
  var factory: true
72
78
  }
73
79
 
74
- interface ConfigStore<State, Err = Error>
75
- extends ConfigCommon<State, Err>,
76
- ConfigJustStore<State> {}
80
+ interface ConfigPersist extends ConfigPersist$1 {}
81
+ interface ConfigStore<State, Err = Error> extends ConfigStore$1<State, Err> {}
77
82
  interface ConfigSourceTarget<State, Err = Error>
78
- extends ConfigCommon<State, Err>,
79
- ConfigJustSourceTarget<State> {}
83
+ extends ConfigSourceTarget$1<State, Err> {}
80
84
  interface Persist {
81
85
  <State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription
82
86
  <State, Err = Error>(config: ConfigStore<State, Err>): Subscription
@@ -96,6 +100,7 @@ export {
96
100
  ConfigPersist,
97
101
  ConfigSourceTarget,
98
102
  ConfigStore,
103
+ Contract,
99
104
  Done,
100
105
  Fail,
101
106
  Finally,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/memory/adapter.ts","../../src/memory/index.ts"],"sourcesContent":["import type { StorageAdapter } from '../types'\n\nconst data = new Map<string, any>()\n\nexport interface MemoryConfig {\n area?: Map<string, any>\n}\n\n/**\n * Memory adapter\n */\nadapter.factory = true as const\nexport function adapter({ area = data }: MemoryConfig = {}): StorageAdapter {\n const adapter: StorageAdapter = <State>(key: string) => ({\n get: () => area.get(key),\n set: (value: State) => area.set(key, value),\n })\n\n adapter.keyArea = area\n return adapter\n}\n","import type { Subscription } from 'effector'\nimport type {\n ConfigPersist,\n ConfigCommon,\n ConfigJustStore,\n ConfigJustSourceTarget,\n} from '../types'\nimport { persist as base } from '../core'\nimport { adapter } from './adapter'\n\nexport type {\n ConfigPersist,\n Done,\n Fail,\n Finally,\n StorageAdapter,\n StorageAdapterFactory,\n} from '../types'\nexport type { MemoryConfig } from './adapter'\n\nexport interface ConfigStore<State, Err = Error>\n extends ConfigCommon<State, Err>,\n ConfigJustStore<State> {}\n\nexport interface ConfigSourceTarget<State, Err = Error>\n extends ConfigCommon<State, Err>,\n ConfigJustSourceTarget<State> {}\n\nexport interface Persist {\n <State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription\n <State, Err = Error>(config: ConfigStore<State, Err>): Subscription\n}\n\n/**\n * Returns memory adapter\n */\nexport { adapter as memory }\n\n/**\n * Creates custom partially applied `persist`\n * with predefined `memory` adapter\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config) =>\n base({\n adapter: adapter(),\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default partially applied `persist`\n */\nexport const persist = createPersist()\n"],"names":["data","Map","adapter","area","key","get","set","value","keyArea","createPersist","defaults","config","base","factory","persist"],"mappings":"gDAEMA,EAAO,IAAIC,IAUV,SAASC,GAAQC,KAAEA,EAAOH,GAAuB,IACtD,IAAME,EAAkCE,IAAiB,CACvDC,IAAKA,IAAMF,EAAKE,IAAID,GACpBE,IAAMC,GAAiBJ,EAAKG,IAAIF,EAAKG,KAIvC,OADAL,EAAQM,QAAUL,EACXD,CACT,CCsBO,SAASO,EAAcC,GAC5B,OAAQC,GACNC,EAAAA,QAAK,CACHV,QAASA,OACNQ,KACAC,GAET,CDtCAT,EAAQW,SAAU,EC2CLC,IAAAA,EAAUL"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/memory/adapter.ts","../../src/memory/index.ts"],"sourcesContent":["import type { StorageAdapter } from '../types'\n\nconst data = new Map<string, any>()\n\nexport interface MemoryConfig {\n area?: Map<string, any>\n}\n\n/**\n * Memory adapter\n */\nadapter.factory = true as const\nexport function adapter({ area = data }: MemoryConfig = {}): StorageAdapter {\n const adapter: StorageAdapter = <State>(key: string) => ({\n get: () => area.get(key),\n set: (value: State) => area.set(key, value),\n })\n\n adapter.keyArea = area\n return adapter\n}\n","import type { Subscription } from 'effector'\nimport type {\n ConfigPersist as BaseConfigPersist,\n ConfigStore as BaseConfigStore,\n ConfigSourceTarget as BaseConfigSourceTarget,\n} from '../types'\nimport { persist as base } from '../core'\nimport { adapter } from './adapter'\n\nexport type {\n Contract,\n Done,\n Fail,\n Finally,\n StorageAdapter,\n StorageAdapterFactory,\n} from '../types'\nexport type { MemoryConfig } from './adapter'\n\nexport interface ConfigPersist extends BaseConfigPersist {}\n\nexport interface ConfigStore<State, Err = Error>\n extends BaseConfigStore<State, Err> {}\n\nexport interface ConfigSourceTarget<State, Err = Error>\n extends BaseConfigSourceTarget<State, Err> {}\n\nexport interface Persist {\n <State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription\n <State, Err = Error>(config: ConfigStore<State, Err>): Subscription\n}\n\n/**\n * Returns memory adapter\n */\nexport { adapter as memory }\n\n/**\n * Creates custom partially applied `persist`\n * with predefined `memory` adapter\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config) =>\n base({\n adapter: adapter(),\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default partially applied `persist`\n */\nexport const persist = createPersist()\n"],"names":["data","Map","adapter","area","key","get","set","value","keyArea","createPersist","defaults","config","base","factory","persist"],"mappings":"gDAEMA,EAAO,IAAIC,IAUV,SAASC,GAAQC,KAAEA,EAAOH,GAAuB,IACtD,IAAME,EAAkCE,IAAiB,CACvDC,IAAKA,IAAMF,EAAKE,IAAID,GACpBE,IAAMC,GAAiBJ,EAAKG,IAAIF,EAAKG,KAIvC,OADAL,EAAQM,QAAUL,EACXD,CACT,CCqBO,SAASO,EAAcC,GAC5B,OAAQC,GACNC,EAAAA,QAAK,CACHV,QAASA,OACNQ,KACAC,GAET,CDrCAT,EAAQW,SAAU,EC0CLC,IAAAA,EAAUL"}
package/memory/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { Unit, Store, Event, Effect, Subscription } from 'effector'
2
2
 
3
3
  interface StorageAdapter {
4
4
  <State>(key: string, update: (raw?: any) => any): {
5
- get(raw?: any, ctx?: any): State | Promise<State>
5
+ get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
6
6
  set(value: State, ctx?: any): void
7
7
  }
8
8
  keyArea?: any
@@ -38,7 +38,7 @@ type Finally<State, Err> =
38
38
  | (Fail<Err> & {
39
39
  status: 'fail'
40
40
  })
41
- interface ConfigPersist {
41
+ interface ConfigPersist$1 {
42
42
  pickup?: Unit<any>
43
43
  context?: Unit<any>
44
44
  keyPrefix?: string
@@ -62,6 +62,12 @@ interface ConfigJustSourceTarget<State> {
62
62
  source: Store<State> | Event<State> | Effect<State, any, any>
63
63
  target: Store<State> | Event<State> | Effect<State, any, any>
64
64
  }
65
+ interface ConfigStore$1<State, Err = Error>
66
+ extends ConfigCommon<State, Err>,
67
+ ConfigJustStore<State> {}
68
+ interface ConfigSourceTarget$1<State, Err = Error>
69
+ extends ConfigCommon<State, Err>,
70
+ ConfigJustSourceTarget<State> {}
65
71
 
66
72
  interface MemoryConfig {
67
73
  area?: Map<string, any>
@@ -71,12 +77,10 @@ declare namespace adapter {
71
77
  var factory: true
72
78
  }
73
79
 
74
- interface ConfigStore<State, Err = Error>
75
- extends ConfigCommon<State, Err>,
76
- ConfigJustStore<State> {}
80
+ interface ConfigPersist extends ConfigPersist$1 {}
81
+ interface ConfigStore<State, Err = Error> extends ConfigStore$1<State, Err> {}
77
82
  interface ConfigSourceTarget<State, Err = Error>
78
- extends ConfigCommon<State, Err>,
79
- ConfigJustSourceTarget<State> {}
83
+ extends ConfigSourceTarget$1<State, Err> {}
80
84
  interface Persist {
81
85
  <State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription
82
86
  <State, Err = Error>(config: ConfigStore<State, Err>): Subscription
@@ -96,6 +100,7 @@ export {
96
100
  ConfigPersist,
97
101
  ConfigSourceTarget,
98
102
  ConfigStore,
103
+ Contract,
99
104
  Done,
100
105
  Fail,
101
106
  Finally,