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

Commit

Permalink
Merge pull request #1 from data-provider/v1.3.0
Browse files Browse the repository at this point in the history
V1.3.0
  • Loading branch information
javierbrea committed Nov 23, 2019
2 parents a24de51 + 1c9ab6c commit c3eb728
Show file tree
Hide file tree
Showing 14 changed files with 149 additions and 115 deletions.
8 changes: 3 additions & 5 deletions .travis.yml
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
Expand Up @@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- "queriesDefaultValue" option has to be removed.
- Options should be accepted only as second argument. "uuid" should be defined only using the "uuid" option, not as second argument.

## [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-memory 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
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
@@ -0,0 +1,6 @@
data-provider memory
Copyright 2019 Javier Brea

Portions of this software were developed at XbyOrange company.
Forked from XByOrange Mercury Memory v1.5.0, distributed under The Apache Software License, Version 2.0.
Github repository "xbyorange/mercury-memory" (https://github.com/XbyOrange/mercury-memory), branch master, commit a24de510820d7e30d1be7d0837f127ea88ea85d2. 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.
64 changes: 31 additions & 33 deletions README.md
Expand Up @@ -4,31 +4,29 @@

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

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

## Overview

This package provides a Mercury origin for handling memory objects.
This package provides a Data Provider origin for handling memory objects.

* __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-memory --save
npm i @data-provider/memory --save
```

## Api

`new Memory(defaultValue[, options || uuid][, options])`
* Arguments
* defaultValue - _`<Object>`_. Object to be stored. Default value is assigned too at the same time.
* uuid - _`<String>`_. Unique id to assign to returned Mercury instance. Useful when using [mercury `sources` handler][mercury-sources-docs-url]. __To be deprecated in next releases. Options object should be passed as second argument instead of uuid.__
* uuid - _`<String>`_. Unique id to assign to returned Data Provider instance. Useful when using [Data Provider `sources` handler][data-provider-sources-docs-url]. __To be deprecated in next releases. Options object should be passed as second argument instead of uuid.__
* 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.
* uuid - _`<String>`_ Unique id to assign to returned Mercury instance. Useful when using [mercury `sources` handler][mercury-sources-docs-url].
* tags - _`<String> or <Array of Strings>`_ Tags to assign to the instance. Useful when using [mercury `sources` handler][mercury-sources-docs-url]. A "memory" tag will be always added to provided tags by default.
* uuid - _`<String>`_ Unique id to assign to returned Data Provider instance. Useful when using [Data Provider `sources` handler][data-provider-sources-docs-url].
* tags - _`<String> or <Array of Strings>`_ Tags to assign to the instance. Useful when using [Data Provider `sources` handler][data-provider-sources-docs-url]. A "memory" tag will be always added to provided tags by default.

## Methods

Expand All @@ -47,7 +45,7 @@ All cache will be cleaned when the `update`, `delete` or `create` methods are ex
The default value of a "queried" instance will be the complete `defaultValue` object until the "queriesDefaultValue" option is set as `true`, in which case the default value will be the value of the key corresponding to the query:

```js
import { Memory } from "@xbyorange/mercury-memory";
import { Memory } from "@data-provider/memory";

const fooMemory = new Memory({
foo: "foo-value",
Expand All @@ -69,10 +67,10 @@ console.log(fooMemory.query("foo").read.value) // "foo"

## 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 { Memory } from "@xbyorange/mercury-memory";
import { Memory } from "@data-provider/memory";

const sessionDetails = new Memory({
userId: null,
Expand All @@ -85,12 +83,12 @@ sessionDetails.query("isLogedIn").update(true)

```

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


```js
import { Memory } from "@xbyorange/mercury-memory";
import { Api } from "@xbyorange/mercury-api";
import { Memory } from "@data-provider/memory";
import { Api } from "@data-provider/axios";

const currentAuthor = new Memory({
id: null
Expand Down Expand Up @@ -136,22 +134,22 @@ await currentAuthorBooks.read();
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

[coveralls-image]: https://coveralls.io/repos/github/XbyOrange/mercury-memory/badge.svg
[coveralls-url]: https://coveralls.io/github/XbyOrange/mercury-memory
[travisci-image]: https://travis-ci.com/xbyorange/mercury-memory.svg?branch=master
[travisci-url]: https://travis-ci.com/xbyorange/mercury-memory
[last-commit-image]: https://img.shields.io/github/last-commit/xbyorange/mercury-memory.svg
[last-commit-url]: https://github.com/xbyorange/mercury-memory/commits
[license-image]: https://img.shields.io/npm/l/@xbyorange/mercury-memory.svg
[license-url]: https://github.com/xbyorange/mercury-memory/blob/master/LICENSE
[npm-downloads-image]: https://img.shields.io/npm/dm/@xbyorange/mercury-memory.svg
[npm-downloads-url]: https://www.npmjs.com/package/@xbyorange/mercury-memory
[npm-dependencies-image]: https://img.shields.io/david/xbyorange/mercury-memory.svg
[npm-dependencies-url]: https://david-dm.org/xbyorange/mercury-memory
[quality-gate-image]: https://sonarcloud.io/api/project_badges/measure?project=xbyorange-mercury-memory&metric=alert_status
[quality-gate-url]: https://sonarcloud.io/dashboard?id=xbyorange-mercury-memory
[release-image]: https://img.shields.io/github/release-date/xbyorange/mercury-memory.svg
[release-url]: https://github.com/xbyorange/mercury-memory/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

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c3eb728

Please sign in to comment.