Skip to content
This repository has been archived by the owner on May 27, 2022. It is now read-only.

Commit

Permalink
Rename package
Browse files Browse the repository at this point in the history
  • Loading branch information
javierbrea committed Nov 23, 2019
1 parent 801bb8d commit 900ae91
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 118 deletions.
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ cache:

addons:
sonarcloud:
organization: "javierbrea"
token:
secure: "$SONAR_TOKEN"
organization: "data-provider"
branch:
name: "$TRAVIS_CURRENT_BRANCH"

Expand All @@ -21,11 +19,11 @@ script:
- npm run test-ci
- npm run build
- npm run coveralls
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sonar-scanner; fi'
- 'if [ -n "$SONAR_TOKEN" ]; then sonar-scanner -Dsonar.login=${SONAR_TOKEN}; fi'

deploy:
provider: npm
email: "devops@xbyorange.com"
email: "javier.brea@gmail.com"
api_key: "$NPM_TOKEN"
on:
tags: true
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [TO BE DEPRECATED]
- "queriesDefaultValue" option has to be removed.

## [1.3.0] - 2019-11-23
### Changed
- Project migration. Read NOTICE for further info. All previous releases in this CHANGELOG file correspond to @xbyorange/mercury-browser-storage package distribution.

## [1.2.0] - 2019-10-16
### Added
- Add "queriesDefaultValue" option. If defined, queried instances will have default value corresponding to the value of query "key" in the default value object. If not, the behavior of "default value" will be the same than in previous versions, and will return the full object even for queried instances)
Expand Down
13 changes: 1 addition & 12 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,5 @@

END OF TERMS AND CONDITIONS

Copyright 2019 Javier Brea
Copyright 2019 XByOrange

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
6 changes: 6 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
data-provider browser-storage
Copyright 2019 Javier Brea

Portions of this software were developed at XbyOrange company.
Forked from XByOrange Mercury Browser Storage v1.2.0, distributed under The Apache Software License, Version 2.0.
Github repository "xbyorange/mercury-browser-storage" (https://github.com/XbyOrange/mercury-browser-storage), branch master, commit 801bb8d598d85c021b40144ca1380af42a32e66f. The original project files were wrongly licensed because an error of the main maintainer, Javier Brea, who received instructions from the XbyOrange company about licensing it as Apache2.0, but didn't include the appropiate license header in all repository files by error. The error has been fixed and XbyOrange license headers have been added to all original files, as it was the real intention of the XbyOrange company.
72 changes: 35 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,41 @@

[![NPM downloads][npm-downloads-image]][npm-downloads-url] [![License][license-image]][license-url]

# ![Mercury Logo](assets/logos/mercury_wings_orange_100.png) Mercury Browser Storage

## Overview

This package provides Mercury browser localStorage and sessionStorage origins. It "wraps" localStorage and sessionStorage with a [Mercury][mercury-url] interface, providing:
This package provides Data Provider browser localStorage and sessionStorage origins. It "wraps" localStorage and sessionStorage with a [Data Provider][data-provider-url] interface, providing:

* __Mercury queries__ based on object keys.
* __Data Provider queries__ based on object keys.
* __Reactivity__ to CRUD actions. When a "create", "update" or "delete" method is called over an instance, the cache clean events are dispatched.

### Install

```bash
npm i @xbyorange/mercury-browser-storage --save
npm i @data-provider/browser-storage --save
```

## Api

* SessionStorage - _`<Class>`_ `new SessionStorage(namespace[, defaultValue[, options]])` - Class for instancing mercury objects persisted in the browser sessionStorage.
* SessionStorage - _`<Class>`_ `new SessionStorage(namespace[, defaultValue[, options]])` - Class for instancing Data Provider objects persisted in the browser sessionStorage.
* Arguments
* namespace - _`<String>`_. Namespace to be used in the sessionStorage object, in which the origin data will be persisted.
* defaultValue - _`<Any>`_ Default value until the first async read is resolved.
* options - `<Object>` containing properties:
* queriesDefaultValue - _`<Boolean>`_ If `true`, the default value of queried sources will be the value of the "key" in the query. If not defined, the default value of queried sources will be the full `defaultValue` object.
* tags - _`<String> or <Array of Strings>`_ Tags to assign to the instance. Useful when using [mercury `sources` handler][mercury-sources-docs-url]. Tags "browser-storage" and "session-storage" will be always added to provided tags by default.
* LocalStorage - _`<Class>`_ `new LocalStorage(namespace[, defaultValue[, options]])` - Class for instancing mercury objects persisted in the browser localStorage.
* tags - _`<String> or <Array of Strings>`_ Tags to assign to the instance. Useful when using [Data Provider `sources` handler][data-provider-sources-docs-url]. Tags "browser-storage" and "session-storage" will be always added to provided tags by default.
* LocalStorage - _`<Class>`_ `new LocalStorage(namespace[, defaultValue[, options]])` - Class for instancing Data Provider objects persisted in the browser localStorage.
* Arguments
* namespace - _`<String>`_. Namespace to be used in the localStorage object, in which the origin data will be persisted.
* defaultValue - _`<Any>`_ Default value until the first async read is resolved.
* options - `<Object>` containing properties:
* queriesDefaultValue - _`<Boolean>`_ If `true`, the default value of queried sources will be the value of the "key" in the query. If not defined, the default value of queried sources will be the full `defaultValue` object.
* tags - _`<String> or <Array of Strings>`_ Tags to assign to the instance. Useful when using [mercury `sources` handler][mercury-sources-docs-url]. Tags "browser-storage" and "local-storage" will be always added to provided tags by default.
* tags - _`<String> or <Array of Strings>`_ Tags to assign to the instance. Useful when using [Data Provider `sources` handler][data-provider-sources-docs-url]. Tags "browser-storage" and "local-storage" will be always added to provided tags by default.

## Common Methods

### query

`mercuryLocalStorage.query(key)`
`dataProviderLocalStorage.query(key)`
* Arguments
* key - `<String>` Key of the storage object to be read, updated, created or deleted.

Expand All @@ -50,10 +48,10 @@ All cache will be cleaned when the `update`, `delete` or `create` methods are ex

## Examples

Next example will be easier to understand if you are already familiarized with the [mercury][mercury-url] syntax.
Next example will be easier to understand if you are already familiarized with the [Data Provider][data-provider-url] syntax.

```js
import { SessionStorage } from "@xbyorange/mercury-browser-storage";
import { SessionStorage } from "@data-provider/browser-storage";

const sessionDetails = new SessionStorage("user", {
id: null,
Expand All @@ -66,12 +64,12 @@ sessionDetails.query("isLogedIn").update(true);

```

Use Mercury Browser Storage objects in combination with Api Origins, and take advantage of the built-in reactivity. Use the storage objects to query the api origins, and, when you update the storage object, the API object caches will be cleaned as a consequence:
Use Data Provider Browser Storage objects in combination with Api Origins, and take advantage of the built-in reactivity. Use the storage objects to query the api origins, and, when you update the storage object, the API object caches will be cleaned as a consequence:


```js
import { LocalStorage } from "@xbyorange/mercury-browser-storage";
import { Api } from "@xbyorange/mercury-api";
import { LocalStorage } from "@data-provider/browser-storage";
import { Api } from "@data-provider/axios";

const currentAuthor = new LocalStorage("current-author", {
id: null
Expand Down Expand Up @@ -117,32 +115,32 @@ await currentAuthorBooks.read();

### React

Please refer to the [react-mercury][react-mercury-url] documentation to see how simple is the data-binding between React Components and Mercury Browser Storage.
Please refer to the [@data-provider/connector-react][data-provider-connector-react-url] documentation to see how simple is the data-binding between React Components and Data Provider Browser Storage.

Connect a source to all components that need it. Mercury will rerender automatically connected components when data in sources is updated.
Connect a source to all components that need it. Data Provider will rerender automatically connected components when data in sources is updated.

## Contributing

Contributors are welcome.
Please read the [contributing guidelines](.github/CONTRIBUTING.md) and [code of conduct](.github/CODE_OF_CONDUCT.md).

[mercury-url]: https://github.com/xbyorange/mercury
[mercury-sources-docs-url]: https://github.com/XbyOrange/mercury/blob/master/docs/sources/api.md
[react-mercury-url]: https://github.com/xbyorange/react-mercury

[coveralls-image]: https://coveralls.io/repos/github/XbyOrange/mercury-browser-storage/badge.svg
[coveralls-url]: https://coveralls.io/github/XbyOrange/mercury-browser-storage
[travisci-image]: https://travis-ci.com/xbyorange/mercury-browser-storage.svg?branch=master
[travisci-url]: https://travis-ci.com/xbyorange/mercury-browser-storage
[last-commit-image]: https://img.shields.io/github/last-commit/xbyorange/mercury-browser-storage.svg
[last-commit-url]: https://github.com/xbyorange/mercury-browser-storage/commits
[license-image]: https://img.shields.io/npm/l/@xbyorange/mercury-browser-storage.svg
[license-url]: https://github.com/xbyorange/mercury-browser-storage/blob/master/LICENSE
[npm-downloads-image]: https://img.shields.io/npm/dm/@xbyorange/mercury-browser-storage.svg
[npm-downloads-url]: https://www.npmjs.com/package/@xbyorange/mercury-browser-storage
[npm-dependencies-image]: https://img.shields.io/david/xbyorange/mercury-browser-storage.svg
[npm-dependencies-url]: https://david-dm.org/xbyorange/mercury-browser-storage
[quality-gate-image]: https://sonarcloud.io/api/project_badges/measure?project=xbyorange-mercury-browser-storage&metric=alert_status
[quality-gate-url]: https://sonarcloud.io/dashboard?id=xbyorange-mercury-browser-storage
[release-image]: https://img.shields.io/github/release-date/xbyorange/mercury-browser-storage.svg
[release-url]: https://github.com/xbyorange/mercury-browser-storage/releases
[data-provider-url]: https://github.com/data-provider/core
[data-provider-sources-docs-url]: https://github.com/data-provider/core/blob/master/docs/sources/api.md
[data-provider-connector-react-url]: https://github.com/data-provider/connector-react

[coveralls-image]: https://coveralls.io/repos/github/data-provider/browser-storage/badge.svg
[coveralls-url]: https://coveralls.io/github/data-provider/browser-storage
[travisci-image]: https://travis-ci.com/data-provider/browser-storage.svg?branch=master
[travisci-url]: https://travis-ci.com/data-provider/browser-storage
[last-commit-image]: https://img.shields.io/github/last-commit/data-provider/browser-storage.svg
[last-commit-url]: https://github.com/data-provider/browser-storage/commits
[license-image]: https://img.shields.io/npm/l/@data-provider/browser-storage.svg
[license-url]: https://github.com/data-provider/browser-storage/blob/master/LICENSE
[npm-downloads-image]: https://img.shields.io/npm/dm/@data-provider/browser-storage.svg
[npm-downloads-url]: https://www.npmjs.com/package/@data-provider/browser-storage
[npm-dependencies-image]: https://img.shields.io/david/data-provider/browser-storage.svg
[npm-dependencies-url]: https://david-dm.org/data-provider/browser-storage
[quality-gate-image]: https://sonarcloud.io/api/project_badges/measure?project=data-provider-browser-storage&metric=alert_status
[quality-gate-url]: https://sonarcloud.io/dashboard?id=data-provider-browser-storage
[release-image]: https://img.shields.io/github/release-date/data-provider/browser-storage.svg
[release-url]: https://github.com/data-provider/browser-storage/releases
Binary file removed assets/logos/mercury_wings_orange_100.png
Binary file not shown.

0 comments on commit 900ae91

Please sign in to comment.