Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

firex-store

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firex-store - npm Package Compare versions

Comparing version 1.0.0-alpha1 to 1.1.0

docs/v1/.DS_Store

16

docs/v0/v0-usage.md

@@ -44,3 +44,3 @@

```javascript
import { firestoreMutations } from 'firex-store/v0'
export default {

@@ -72,3 +72,3 @@ namespaced: true,

```javascript
import { firestoreMutations, firestoreSubscribeAction } from 'firex-store/v0'
// modules: comment

@@ -97,3 +97,3 @@ export default {

<script>
import { actionTypes } from 'firex-store'
import { actionTypes } from 'firex-store/v0'

@@ -122,3 +122,3 @@ export default {

```javascript
import { firestoreMutations } from 'firex-store/v0'
export default {

@@ -148,2 +148,3 @@ namespaced: true,

```javascript
import { firestoreMutations, subscribeFirestore } from 'firex-store/v0'
export default {

@@ -186,2 +187,3 @@ namespaced: true,

```javascript
import { firestoreMutations, firestoreSubscribeAction, firestoreUnsubscribeAction } from 'firex-store/v0'
export default {

@@ -208,3 +210,3 @@ namespaced: true,

<script>
import { actionTypes } from 'firex-store'
import { actionTypes } from 'firex-store/v0'

@@ -230,2 +232,3 @@ export default {

```javascript
import { firestoreMutations, subscribeFirestore, unsubscribeFirestore } from 'firex-store/v0'
export default {

@@ -273,2 +276,4 @@ namespaced: true,

```javascript
import { findFirestore } from 'firex-store/v0'
export default {

@@ -382,2 +387,3 @@ namespaced: true,

```javascript
import { firestoreMutations, subscribeFirestore } from 'firex-store/v0'
export default {

@@ -384,0 +390,0 @@ namespaced: true,

@@ -25,2 +25,4 @@ # firex-store

- `v0` version is deprecated. It is removed @2.0.0
- Return values or state values bounded to Firestore has `docId`(documentId in Firestore) property.

@@ -30,5 +32,6 @@

- If you want to subscribe again after unsubscribing 'collection', set the property of the store you want to subscribe to `[]` and then subscribe.
- If you'd like to subscribe again after unsubscribing 'collection', set the property of the store you'd like to subscribe to `[]` and then subscribe.
## Usage
- see [here](v0-usage.md), please

@@ -1,2 +0,1 @@

export declare const FIREX_COLLECTION_UNSUBSCRIBER = "[firex-store] Firex Collection Unsubscriber";
export declare const FIREX_DOCUMENT_UNSUBSCRIBER = "[firex-store] Firex Document Unsubscriber";
export declare const FIREX_UNSUBSCRIBES = "[firex-store] Firex Unsubscribes";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FIREX_COLLECTION_UNSUBSCRIBER = '[firex-store] Firex Collection Unsubscriber';
exports.FIREX_DOCUMENT_UNSUBSCRIBER = '[firex-store] Firex Document Unsubscriber';
exports.FIREX_UNSUBSCRIBES = '[firex-store] Firex Unsubscribes';

@@ -1,1 +0,2 @@

export declare const NOT_CALL_BIND_TO_METHOD_YET = "You need to call bindTo method before call it.";
export declare const BIND_TO_METHOD_NOT_CALLED = "You need to call bindTo method before call it.";
export declare const UNSUBSCRIBE_METHOD_NOT_CALLED = "Unsubscribe method have been called, but not unsubscribed.";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NOT_CALL_BIND_TO_METHOD_YET = 'You need to call bindTo method before call it.';
exports.BIND_TO_METHOD_NOT_CALLED = 'You need to call bindTo method before call it.';
exports.UNSUBSCRIBE_METHOD_NOT_CALLED = 'Unsubscribe method have been called, but not unsubscribed.';

@@ -9,3 +9,3 @@ import { FirestoreRef } from '../types';

*/
declare class FirestoreReaderServiceFactory {
export declare class FirestoreReaderServiceFactory {
private _ref;

@@ -25,7 +25,1 @@ constructor(ref: FirestoreRef);

}
/**
* @description return factory of FirestoreSubscriber and FirestoreFinder
* @param ref: firebase.firestore.DocumentReference | firebase.firestore.CollectionReference | firebase.firestore.Query
*/
export declare const from: (ref: FirestoreRef) => FirestoreReaderServiceFactory;
export {};

@@ -30,6 +30,2 @@ "use strict";

}
/**
* @description return factory of FirestoreSubscriber and FirestoreFinder
* @param ref: firebase.firestore.DocumentReference | firebase.firestore.CollectionReference | firebase.firestore.Query
*/
exports.from = (ref) => new FirestoreReaderServiceFactory(ref);
exports.FirestoreReaderServiceFactory = FirestoreReaderServiceFactory;

@@ -5,4 +5,4 @@ export * from './store';

export { Payload, DocumentResult } from './models';
export { from } from './factories';
export { from, on } from './creators';
import * as v0 from './v0';
export { v0 };

@@ -11,5 +11,6 @@ "use strict";

exports.FirestoreUnsubscriber = services_1.FirestoreUnsubscriber;
var factories_1 = require("./factories");
exports.from = factories_1.from;
var creators_1 = require("./creators");
exports.from = creators_1.from;
exports.on = creators_1.on;
const v0 = require("./v0");
exports.v0 = v0;
export * from './document-result.model';
export * from './payload.model';
export * from './find.model';
export * from './subscribe.model';
export * from './unsubscribe.model';
export * from './finder.model';
export * from './subscriber.model';
export * from './unsubscriber.model';

@@ -8,3 +8,9 @@ "use strict";

: 'PARTIAL DATA NOT FOUND');
exports.notifyErrorOccurred = (error, errorHandler) => errorHandler ? errorHandler(error) : console.error(error);
exports.notifyErrorOccurred = (error, errorHandler) => {
const defaultErrorHandler = (error) => {
console.error(error);
return error;
};
return errorHandler ? errorHandler(error) : defaultErrorHandler(error);
};
exports.notifyCompletionIfDefined = (completionHandler) => {

@@ -11,0 +17,0 @@ if (completionHandler) {

@@ -1,7 +0,10 @@

import { Find } from '../models';
import { FirestoreRef } from '../types';
import { Finder } from '../models';
import { FirestoreRef, NullOr } from '../types';
import { FindCriteriaOptions } from '../options';
/**
* @description class find firestore data at once
* @returns null | error | any
* - error: if you defined errorHandler, it changed any
*
*
* @example

@@ -16,8 +19,8 @@ * FirestoreFinder

*/
export declare class FirestoreFinder implements Find {
export declare class FirestoreFinder implements Finder {
private _ref;
/**
* @description Make FirestoreFetcher instance
* @description Make FirestoreFinder instance
* @param ref: firebase.firestore.DocumentReference | firebase.firestore.CollectionReference | firebase.firestore.Query
* @returns FirestoreFetcher
* @returns FirestoreFinder
*/

@@ -29,7 +32,10 @@ static from(ref: FirestoreRef): FirestoreFinder;

* @description find firestore data at once
* @param options: { mapper,
* @param options: {
* mapper,
* errorHandler,
* completionHandler } | undefined
* @returns null | error | any
* - error: if you defined errorHandler, it changed any
*/
find<T = any>(options?: FindCriteriaOptions<T>): Promise<any>;
find<T = any>(options?: FindCriteriaOptions<T>): Promise<NullOr<T | any>>;
}

@@ -7,3 +7,6 @@ "use strict";

* @description class find firestore data at once
* @returns null | error | any
* - error: if you defined errorHandler, it changed any
*
*
* @example

@@ -23,5 +26,5 @@ * FirestoreFinder

/**
* @description Make FirestoreFetcher instance
* @description Make FirestoreFinder instance
* @param ref: firebase.firestore.DocumentReference | firebase.firestore.CollectionReference | firebase.firestore.Query
* @returns FirestoreFetcher
* @returns FirestoreFinder
*/

@@ -36,5 +39,8 @@ static from(ref) {

* @description find firestore data at once
* @param options: { mapper,
* @param options: {
* mapper,
* errorHandler,
* completionHandler } | undefined
* @returns null | error | any
* - error: if you defined errorHandler, it changed any
*/

@@ -41,0 +47,0 @@ find(options) {

@@ -1,2 +0,2 @@

import { Subscribe } from '../models';
import { Subscriber } from '../models';
import { FirestoreRef } from '../types';

@@ -19,3 +19,3 @@ import { Commit } from 'vuex';

*/
export declare class FirestoreSubscriber implements Subscribe {
export declare class FirestoreSubscriber implements Subscriber {
private _ref;

@@ -22,0 +22,0 @@ private _statePropName?;

@@ -5,2 +5,3 @@ "use strict";

const helpers_1 = require("./helpers");
const configurations_1 = require("../configurations");
/**

@@ -59,5 +60,11 @@ * @description class subscribe firestore data to state property

if (!this.statePropName) {
console.error(errors_1.NOT_CALL_BIND_TO_METHOD_YET);
console.error(errors_1.BIND_TO_METHOD_NOT_CALLED);
return;
}
if (!state[configurations_1.FIREX_UNSUBSCRIBES]) {
state[configurations_1.FIREX_UNSUBSCRIBES] = new Map();
}
if (state[configurations_1.FIREX_UNSUBSCRIBES].has(this.statePropName)) {
return;
}
helpers_1.isDocumentRef(this.ref)

@@ -64,0 +71,0 @@ ? helpers_1.subscribeFirestoreDocument({

@@ -1,2 +0,2 @@

import { Unsubscribe } from '../models';
import { Unsubscriber } from '../models';
/**

@@ -7,15 +7,15 @@ * @description class unsubscribe firestore data to state property

* FirestoreUnsubscriber
* .unbind('collection')
* .on('statePropName')
* .unsubscribe(state)
*/
export declare class FirestoreUnsubscriber implements Unsubscribe {
private _type;
export declare class FirestoreUnsubscriber implements Unsubscriber {
private _statePropName;
/**
* @description Make FirestoreUnsubscriber instance
* @param type: 'document' | 'collection'
* @param statePropName: string
* @returns FirestoreUnsubscriber
*/
static unbind(type: 'document' | 'collection'): FirestoreUnsubscriber;
constructor(type: 'document' | 'collection');
readonly type: 'document' | 'collection';
static on(statePropName: string): FirestoreUnsubscriber;
constructor(statePropName: string);
readonly statePropName: string;
/**

@@ -22,0 +22,0 @@ * @description unsubscribe firestore data

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const configurations_1 = require("../configurations");
const errors_1 = require("../errors");
/**

@@ -9,19 +10,19 @@ * @description class unsubscribe firestore data to state property

* FirestoreUnsubscriber
* .unbind('collection')
* .on('statePropName')
* .unsubscribe(state)
*/
class FirestoreUnsubscriber {
constructor(type) {
this._type = type;
constructor(statePropName) {
this._statePropName = statePropName;
}
/**
* @description Make FirestoreUnsubscriber instance
* @param type: 'document' | 'collection'
* @param statePropName: string
* @returns FirestoreUnsubscriber
*/
static unbind(type) {
return new FirestoreUnsubscriber(type);
static on(statePropName) {
return new FirestoreUnsubscriber(statePropName);
}
get type() {
return this._type;
get statePropName() {
return this._statePropName;
}

@@ -33,11 +34,14 @@ /**

unsubscribe(state) {
const prop = this.type === 'document'
? configurations_1.FIREX_DOCUMENT_UNSUBSCRIBER
: configurations_1.FIREX_COLLECTION_UNSUBSCRIBER;
if (state[prop]) {
state[prop]();
delete state[prop];
const unsubscribes = state[configurations_1.FIREX_UNSUBSCRIBES];
if (!unsubscribes || !unsubscribes.has(this.statePropName)) {
console.error(errors_1.UNSUBSCRIBE_METHOD_NOT_CALLED);
return;
}
const unsubscribe = unsubscribes.get(this.statePropName);
if (unsubscribe) {
unsubscribe();
}
unsubscribes.delete(this.statePropName);
}
}
exports.FirestoreUnsubscriber = FirestoreUnsubscriber;

@@ -7,7 +7,4 @@ "use strict";

exports.subscribeFirestoreCollection = ({ statePropName, state, commit, ref, options }) => {
if (state[configurations_1.FIREX_COLLECTION_UNSUBSCRIBER]) {
return;
}
const mutation = (changeType, payload) => call_mutation_1.callMutation({ mutationType: 'collection', changeType, commit, payload });
const unsubscriber = repositories_1.FirestoreRepository.subscribeAll({
const unsubscribe = repositories_1.FirestoreRepository.subscribeAll({
statePropName,

@@ -18,10 +15,8 @@ ref,

});
state[configurations_1.FIREX_COLLECTION_UNSUBSCRIBER] = unsubscriber;
const unsubscribes = state[configurations_1.FIREX_UNSUBSCRIBES];
unsubscribes.set(statePropName, unsubscribe);
};
exports.subscribeFirestoreDocument = ({ statePropName, state, commit, ref, options }) => {
if (state[configurations_1.FIREX_DOCUMENT_UNSUBSCRIBER]) {
return;
}
const mutation = (changeType, payload) => call_mutation_1.callMutation({ mutationType: 'document', changeType, commit, payload });
const unsubscriber = repositories_1.FirestoreRepository.subscribe({
const unsubscribe = repositories_1.FirestoreRepository.subscribe({
statePropName,

@@ -32,3 +27,4 @@ ref,

});
state[configurations_1.FIREX_DOCUMENT_UNSUBSCRIBER] = unsubscriber;
const unsubscribes = state[configurations_1.FIREX_UNSUBSCRIBES];
unsubscribes.set(statePropName, unsubscribe);
};

@@ -20,10 +20,17 @@ import { ActionTree } from 'vuex';

* afterMutationCalled } | undefined
* @returns ActionTree<any, any>
*
* @example
* import { firestoreSubscribeAction, FirestoreSubscriber, from } from 'firex-store'
* actions: {
* ...firestoreSubscribeAction(
* FirestoreSubscriber
* .from(firebase.firestore().collection('/comments'))
* .bindTo('comments'),
* { actionName: 'subscribeAll' }
* .from(firebase.firestore().collection('collection'))
* .bindTo('statePropName'),
* { actionName: 'customActionName' }
* ),
* ...firestoreSubscribeAction(
* from(firebase.firestore().collection('collection'))
* .bindTo('statePropName'),
* { actionName: 'customActionName2' }
* )

@@ -30,0 +37,0 @@ * }

@@ -14,10 +14,17 @@ "use strict";

* afterMutationCalled } | undefined
* @returns ActionTree<any, any>
*
* @example
* import { firestoreSubscribeAction, FirestoreSubscriber, from } from 'firex-store'
* actions: {
* ...firestoreSubscribeAction(
* FirestoreSubscriber
* .from(firebase.firestore().collection('/comments'))
* .bindTo('comments'),
* { actionName: 'subscribeAll' }
* .from(firebase.firestore().collection('collection'))
* .bindTo('statePropName'),
* { actionName: 'customActionName' }
* ),
* ...firestoreSubscribeAction(
* from(firebase.firestore().collection('collection'))
* .bindTo('statePropName'),
* { actionName: 'customActionName2' }
* )

@@ -24,0 +31,0 @@ * }

@@ -6,10 +6,17 @@ import { ActionTree } from 'vuex';

* @param firestoreUnsubscriber: FirestoreUnsubscriber instance
* @param options: { actionName: string } | undefined
* @param criteria: { type: 'document' | 'collection', actionName?: string }
* @returns ActionTree<any, any>
*
* @example
* import { firestoreUnsubscribeAction, FirestoreUnsubscriber, on } from 'firex-store'
*
* actions: {
* ...firestoreUnsubscribeAction(
* FirestoreUnsubscriber
* .unbind('collection'),
* { actionName: 'subscribeAll' }
* .on('statePropName'),
* { type: 'collection', actionName: 'customActionName' }
* ),
* ....firestoreUnsubscribeAction(
* on('statePropName'),
* { type: 'collection', actionName: 'customActionName2' }
* )

@@ -19,4 +26,5 @@ * }

*/
export declare const firestoreUnsubscribeAction: (firestoreUnsubscriber: FirestoreUnsubscriber, options?: {
actionName: string;
} | undefined) => ActionTree<any, any>;
export declare const firestoreUnsubscribeAction: (firestoreUnsubscriber: FirestoreUnsubscriber, criteria: {
type: "document" | "collection";
actionName?: string | undefined;
}) => ActionTree<any, any>;

@@ -7,10 +7,17 @@ "use strict";

* @param firestoreUnsubscriber: FirestoreUnsubscriber instance
* @param options: { actionName: string } | undefined
* @param criteria: { type: 'document' | 'collection', actionName?: string }
* @returns ActionTree<any, any>
*
* @example
* import { firestoreUnsubscribeAction, FirestoreUnsubscriber, on } from 'firex-store'
*
* actions: {
* ...firestoreUnsubscribeAction(
* FirestoreUnsubscriber
* .unbind('collection'),
* { actionName: 'subscribeAll' }
* .on('statePropName'),
* { type: 'collection', actionName: 'customActionName' }
* ),
* ....firestoreUnsubscribeAction(
* on('statePropName'),
* { type: 'collection', actionName: 'customActionName2' }
* )

@@ -20,7 +27,7 @@ * }

*/
exports.firestoreUnsubscribeAction = (firestoreUnsubscriber, options) => {
const defaultActionName = firestoreUnsubscriber.type === 'document'
exports.firestoreUnsubscribeAction = (firestoreUnsubscriber, criteria) => {
const defaultActionName = criteria.type === 'document'
? action_1.actionTypes.document.UNSUBSCRIBE
: action_1.actionTypes.collection.UNSUBSCRIBE;
const action = options && options.actionName ? options.actionName : defaultActionName;
const action = criteria && criteria.actionName ? criteria.actionName : defaultActionName;
const tree = {

@@ -27,0 +34,0 @@ [action]({ state }) {

@@ -10,1 +10,2 @@ export * from './error-handler.type';

export * from './not-found-handler.type';
export * from './unsubscribes.type';
{
"name": "firex-store",
"version": "1.0.0-alpha1",
"version": "1.1.0",
"description": "subscribe firebase data to vuex",

@@ -17,5 +17,3 @@ "main": "./lib/index.js",

"prepublishOnly": "npm test && npm run lint",
"preversion": "npm run lint",
"version": "npm run format && git add -A src",
"postversion": "git push && git push --tags"
"preversion": "npm run lint"
},

@@ -43,3 +41,3 @@ "repository": {

"@babel/preset-typescript": "^7.6.0",
"@types/jest": "^24.0.19",
"@types/jest": "^24.0.20",
"@typescript-eslint/eslint-plugin": "^2.5.0",

@@ -50,6 +48,6 @@ "@typescript-eslint/parser": "^2.5.0",

"babel-preset-env": "^1.7.0",
"eslint": "^6.5.1",
"eslint-config-prettier": "^6.4.0",
"eslint": "^6.6.0",
"eslint-config-prettier": "^6.5.0",
"eslint-plugin-prettier": "^3.1.1",
"firebase": "^7.2.1",
"firebase": "^7.2.2",
"jest": "^24.9.0",

@@ -56,0 +54,0 @@ "prettier": "^1.18.2",

@@ -9,7 +9,6 @@ # firex-store

## Installation
```
npm install --save firex-store@1.0.0-alpha1
npm install --save firex-store
```

@@ -21,21 +20,24 @@

others comming soon
## Important!
## Important
- Return values or state values bounded to Firestore has `docId`(documentId in Firestore) property.
- Return values or state values bound to Firestore has `docId`(documentId in Firestore) property.
- A store module cannot subscribe to more than one 'collection' and 'document'
- If you want to subscribe again after unsubscribing 'collection', set the property of the store you want to subscribe to `[]` and then subscribe.
- If you'd like to subscribe again after unsubscribing 'collection', set the property of the store you'd like to subscribe to `[]` and then subscribe.
## v1-alpha Usage
- See [here](docs/v1-alpha/v1-alpha-usage.md), please
## Usage
- See [here](docs/v1/v1-usage.md), please
### Difference from v0
- See [here](docs/v1-alpha/v1-alpha-difference-from-v0.md), please
## Difference from v0
- See [here](docs/v1/v1-difference-from-v0.md), please
## v0 Usage
- See [here](docs/v0/v0-usage.md), please
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc