Skip to content

Commit 6d22488

Browse files
authored
v8 (#76)
* feat: new JSONSchema, and shortcuts and auto-inference for basic types * feat: disallow null or undefined in setItem * feat: allow custom indexeddb database and store names (#78) * feat: better error management and move idb fallback to main service * internal: reduce surface api * fix: stringify all keys for interoperability * fix: better error management * feat: new getItem() signature (#79) * fix: catch stringify error * fix: catch quota error on localStorage setItem * fix: catch missing store error * fix: remove getUnsafeItem() * feat: new IDB storing behavior with no wrapping (#82) * feat: new prefix token for interop * feat: removeItem when storing null or undefined (#93) * feat: remove xSubscribe() methods (#96) * feat: separate localStorage and Map APIs (#100) * feat: iterating keys() * fix: deprecate xSubscribe * feat: rxjs 6.4 as minimum * fix: use openKeyCursor() when possible for perf * feat: schema option in set() * fix: throw when storing data that can't be serialized in localStorage (#104) * feat: engine and database info + opt-in for unwraped values in idb + new options system (#107) * fix: new interface for new options system * fix: test and doc about blob refused in idb in safari private
1 parent 3670169 commit 6d22488

File tree

130 files changed

+11936
-7592
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+11936
-7592
lines changed

.circleci/config.yml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,36 @@ jobs: # a collection of steps
77
- checkout
88
- restore_cache: # special step to restore the dependency cache
99
# Read about caching dependencies: https://circleci.com/docs/2.0/caching/
10-
key: dependency-cache-{{ checksum "package.json" }}
10+
key: dependency-cache-{{ checksum "package-lock.json" }}
1111
- run:
1212
name: install-npm-wee
1313
command: npm install
1414
- save_cache: # special step to save the dependency cache
15-
key: dependency-cache-{{ checksum "package.json" }}
15+
key: dependency-cache-{{ checksum "package-lock.json" }}
1616
paths:
1717
- ./node_modules
1818
- run: # run tests
1919
name: lint
2020
command: npm run lint
21-
build:
21+
test:
2222
docker: # run the steps with Docker
23-
- image: circleci/node:10 # ...with this image as the primary container; this is where all `steps` will run
23+
- image: circleci/node:10-browsers # ...with this image as the primary container; this is where all `steps` will run
2424
steps: # a collection of executable commands
2525
- checkout
2626
- restore_cache: # special step to restore the dependency cache
2727
# Read about caching dependencies: https://circleci.com/docs/2.0/caching/
28-
key: dependency-cache-{{ checksum "package.json" }}
28+
key: dependency-cache-{{ checksum "package-lock.json" }}
2929
- run:
3030
name: install-npm-wee
3131
command: npm install
3232
- save_cache: # special step to save the dependency cache
33-
key: dependency-cache-{{ checksum "package.json" }}
33+
key: dependency-cache-{{ checksum "package-lock.json" }}
3434
paths:
3535
- ./node_modules
3636
- run: # run tests
37-
name: build
38-
command: npm run build
39-
test:
37+
name: test
38+
command: npm test && npm run test:ivy
39+
ng80:
4040
docker: # run the steps with Docker
4141
- image: circleci/node:10-browsers # ...with this image as the primary container; this is where all `steps` will run
4242
steps: # a collection of executable commands
@@ -47,17 +47,16 @@ jobs: # a collection of steps
4747
- run:
4848
name: install-npm-wee
4949
command: npm install
50-
- save_cache: # special step to save the dependency cache
51-
key: dependency-cache-{{ checksum "package-lock.json" }}
52-
paths:
53-
- ./node_modules
50+
- run:
51+
name: downgrade
52+
command: npm run ci:ng80
5453
- run: # run tests
5554
name: test
56-
command: ./node_modules/.bin/ng test @ngx-pwa/local-storage --watch false
55+
command: npm test
5756
workflows:
5857
version: 2
59-
lint_and_build_and_test:
58+
test:
6059
jobs:
6160
- lint
62-
- build
6361
- test
62+
- ng80

CHANGELOG.md

Lines changed: 59 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,62 @@
22

33
This lib is fully documented and so you'll find detailed [migration guides](./MIGRATION.md).
44

5-
## 8.0.0-beta.x
5+
## 8.0.0-beta.13 (2019-05-27)
66

7-
v8 development is tracked in [#76](https://github.com/cyrilletuzi/angular-async-local-storage/pull/76).
7+
**A [full migration guide to version 8](./docs/MIGRATION_TO_V8.md) is available.**
88

9-
This will be an important release so **beta testers are very welcomed.**
9+
### Angular 8
10+
11+
v8 requires Angular 8.
12+
13+
### Feature: new `StorageMap` service
14+
15+
See the [general documentation](./README.md).
16+
17+
### Feature: validation is much easier!
18+
19+
- The schema used for validation can (and should) be passed directly as the second argument of `getItem()`
20+
- The returned type of `getItem()` is now inferred for basic types (`string`, `number`, `boolean`) and arrays of basic types (`string[]`, `number[]`, `boolean[]`)
21+
- Just use the new `JSONSchema` interface, IntelliSense will adjust itself based on the `type` option
22+
23+
See the new [validation guide](./docs/VALIDATION.md).
24+
25+
### Full review
26+
27+
This lib started as a little project and is now the first Angular library used for local storage.
28+
It was time to do a full review and refactoring, which results in:
29+
30+
- Better error management (see [README](./README.md#errors))
31+
- Better documentation
32+
- Better overall code (= easier to contribute)
33+
34+
### Other features
35+
36+
- `indexedDB` database and object store names default values are exported and can be changed
37+
(see the [interoperability guide](./docs/INTEROPERABILITY.md))
38+
- When trying to store `null` or `undefined`, `removeItem()` instead of just bypassing (meaning the old value was kept)
39+
40+
### Breaking changes
41+
42+
- **`type` now required for array, object, const and enum validation schemas**
43+
- `JSONSchemaNull` removed (useless, `null` doesn't require any validation)
44+
- `JSONSchema` no longer accepts extra properties
45+
- `getUnsafeItem()` is removed (was already deprecated in v7)
46+
47+
### Future breaking changes
48+
49+
- `.has()`, `.keys()` and `.size` are deprecated in `LocalStorage`. They will be removed in v9. They moved to the new `StorageMap` service.
50+
- `JSONSchemaNumeric` deprecated (will be removed in v9)
51+
- `LSGetItemsOptions` deprecated (not necessary anymore, will be removed in v9)
52+
- `LOCAL_STORAGE_PREFIX`, `LocalStorageProvidersConfig` and `localStorageProviders()` deprecated (will be removed in v9). Moved to `StorageModule.forRoot()`
53+
- `setItemSubscribe()`, `removeItemSubscribe()` and `clearSubscribe()` deprecated (will be removed in v9)
54+
55+
### Reduced public API
56+
57+
Should not concern you as it was internal stuff.
58+
59+
- `IndexedDBDatabase` and `LocalStorageDatabase` not exported anymore
60+
- `MockLocalDatabase` renamed and not exported anymore
1061

1162
## 7.4.1 (2019-01-27) / 5.3.6 and 6.2.3 and 7.4.2 (2019-02-25)
1263

@@ -27,6 +78,8 @@ This will be an important release so **beta testers are very welcomed.**
2778
- `has()` and `keys()` now work in Edge/IE too
2879
(fixes [#69](https://github.com/cyrilletuzi/angular-async-local-storage/issues/69))
2980

81+
Do *not* use: it's deprecated in v8.
82+
3083
## 7.3.0 (2019-01-03)
3184

3285
### Feature
@@ -59,6 +112,8 @@ This will be an important release so **beta testers are very welcomed.**
59112

60113
In v7.2, `has()` and `keys()` were not supported in Internet Explorer and Edge. Update to v7.4.
61114

115+
Do *not* use: it's deprecated in v8.
116+
62117
See [documentation](./docs/MAP_OPERATIONS.md).
63118

64119
### Breaking change (from v7.1 only)
@@ -87,7 +142,7 @@ These releases have been **deprecated** due to a critical regression.
87142
- `JSONSchemaConst`
88143
- `JSONSchemaEnum`
89144
- `JSONSchemaString`
90-
- `JSONSchemaNumeric`
145+
- `JSONSchemaNumeric` (deprecated in v8)
91146
- `JSONSchemaBoolean`
92147
- `JSONSchemaArray`
93148
- `JSONSchemaObject`
@@ -133,8 +188,6 @@ Validation of data is now required when using `getItem()`:
133188

134189
- New JSON Schema validation options supported (see [#18](https://github.com/cyrilletuzi/angular-async-local-storage/issues/18) for the full list).
135190

136-
- `setItemSubscribe()`, `removeItemSubscribe()`, `clearSubscribe()` methods for auto-subscription
137-
138191
- `localStorageProviders({ prefix: 'myapp' })` to avoid collision in multiple apps on same subdomain
139192

140193
### Breaking changes
@@ -206,12 +259,6 @@ If you want to keep your previous data, double the prefix, for example: `localSt
206259

207260
- `localStorageProviders({ prefix: 'myapp' })` to avoid collision in multiple apps on same subdomain
208261

209-
## 5.2.0 (2018-04-08)
210-
211-
### Feature
212-
213-
- `setItemSubscribe()`, `removeItemSubscribe()`, `clearSubscribe()` methods for auto-subscription
214-
215262
## 5.1.1 (2018-04-07)
216263

217264
### Bug fix

MIGRATION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- [Migration from the old `angular-async-local-storage` package to `@ngx-pwa/local-storage`](./docs/MIGRATION_TO_NEW_PACKAGE.md)
44
- [Migration to version 6](./docs/MIGRATION_TO_V6.md)
55
- [Migration to version 7](./docs/MIGRATION_TO_V7.md)
6+
- [Migration to version 8](./docs/MIGRATION_TO_V8.md)
67

78
[Full changelog available here.](./CHANGELOG.md)
89

0 commit comments

Comments
 (0)