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.5.2 to 1.6.0

lib/services/firestore-stream-subscriber.service.d.ts

107

docs/v1/v1-usage.md
## Usage
- [Subscribe Firestore, using firex-store actions](#1-subscribe-firestore-using-firex-store-actions)
- [Subscribe Firestore, using custom actions](#2-subscribe-firestore-using-custom-actions)
- [Unsubscribe Firestore, using firex-store actions](#3-unsubscribe-firestore-using-firex-store-actions)
- [Unsubscribe Firestore, using custom actions](#4-unsubscribe-firestore-using-custom-actions)
- [Fetch at Once](#5-fetch-at-once)
- [Subscribe at Once](#6-subscribe-at-once)
- [Add to firestore](#7-add-to-firestore)
- [Set to firestore](#8-set-to-firestore)
- [MergeSet to firestore (like Update)](#9-mergeSet-to-firestore-like-update)
- [Helpers](#10-helpers)
- [Subscribe Firestore, using firex-store actions](#subscribe-firestore-using-firex-store-actions)
- [Subscribe Firestore, using custom actions](#subscribe-firestore-using-custom-actions)
- [Subscribe Firestore, like rxjs](#subscribe-firestore-using-like-rxjs)
- [Unsubscribe Firestore, using firex-store actions](#unsubscribe-firestore-using-firex-store-actions)
- [Unsubscribe Firestore, using custom actions](#unsubscribe-firestore-using-custom-actions)
- [Fetch at Once](#fetch-at-once)
- [Subscribe at Once](#subscribe-at-once)
- [Add to firestore](#add-to-firestore)
- [Set to firestore](#set-to-firestore)
- [MergeSet to firestore (like Update)](#mergeSet-to-firestore-like-update)
- [Helpers](#helpers)
- [from and FirestoreReaderServiceFactory](#from-and-FirestoreReaderServiceFactory)

@@ -39,3 +40,3 @@ - [on](#on)

### 1. Subscribe Firestore, using firex-store actions
### Subscribe Firestore, using firex-store actions

@@ -129,3 +130,3 @@ - method: `firestoreMutations`

### 2. Subscribe Firestore, using custom actions
### Subscribe Firestore, using custom actions

@@ -206,4 +207,70 @@ - method: `firestoreMutations`

### 3. Unsubscribe Firestore, using firex-store actions
### Subscribe Firestore, using like rxjs
Ex. Unsubscribe collection, compared with `from(ref).bindTo('')`
#### use `from(ref).pipe(...args)`
```javascript
import { from, map, bndTo, firestoreMutations } from 'firex-store'
const toCharactor = (data) => ({ id: data.docId, name: `${data.first_name} ${data.family_name}` })
export default {
state: {
charactors: null,
isLoaded: false
},
mutations: {
...firestoreMutations('all'),
setIsLoaded: (state, paylaod) => {
state.charactors = payload
}
},
actions: {
subscribe: ({ commit, state }, { collectionName }) => {
from(firebase.collections(collectionName))
.pipe(
map(toCharactor),
bindTo('charactor'),
({ data }) => commit('setIsLoaded', data)
)
.subscribe(state, commit)
}
}
}
```
#### use `from(ref).bondTo(statePropName)`
```javascript
import { from, map, bndTo, firestoreMutations } from 'firex-store'
const toCharactor = (data) => ({ id: data.docId, name: `${data.first_name} ${data.family_name}` })
export default {
state: {
charactors: null,
isLoaded: false
},
mutations: {
...firestoreMutations('all'),
setIsLoaded: (state, paylaod) => {
state.charactors = payload
}
},
actions: {
subscribe: ({ commit, state }, { collectionName }) => {
from(firebase.collections(collectionName))
bindTo('charactors')
.subscribe(state, commit, {
afterMutationCalled: (data, isLast) => {
commit('setIsLoaded', isLast)
}
})
}
}
}
```
### Unsubscribe Firestore, using firex-store actions
Ex. Unsubscribe collection

@@ -287,3 +354,3 @@

### 4. Unsubscribe Firestore, using custom actions
### Unsubscribe Firestore, using custom actions

@@ -347,3 +414,3 @@ - class `FirestoreUnsubscriber`

## 5. Fetch at once
## Fetch at once

@@ -389,3 +456,3 @@ - class: `FirestoreFinder`

## 6. Subscribe at once
## Subscribe at once

@@ -434,3 +501,3 @@ - class: `FirestoreSubscriber`

## 7. Add to firestore
## Add to firestore

@@ -480,3 +547,3 @@ - class: `FirestoreAdder`

## 8. Set to firestore
## Set to firestore

@@ -531,3 +598,3 @@ - class: `FirestoreSetter`

## 9. MergeSet to firestore (like Update)
## MergeSet to firestore (like Update)

@@ -582,3 +649,3 @@ - class: `FirestoreMergeSetter`

## 10. Helpers
## Helpers

@@ -585,0 +652,0 @@ ### from and FirestoreReaderServiceFactory

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FIREX_UNSUBSCRIBES = void 0;
exports.FIREX_UNSUBSCRIBES = '[firex-store] Firex Unsubscribes';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.from = void 0;
const helpers_1 = require("./helpers");

@@ -4,0 +5,0 @@ /**

13

lib/creators/helpers/firestore-document-writer.facade.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FirestoreDocumentWriterFacade = void 0;
const services_1 = require("../../services");

@@ -52,8 +53,6 @@ /**

...options,
...{ mapper: this._mapper }
...{ mapper: this._mapper },
};
return this._isTransaction
? services_1.FirestoreSetter.to(this._ref)
.transaction()
.set(data, _options)
? services_1.FirestoreSetter.to(this._ref).transaction().set(data, _options)
: services_1.FirestoreSetter.to(this._ref).set(data, _options);

@@ -73,3 +72,3 @@ }

...options,
...{ mapper: this._mapper }
...{ mapper: this._mapper },
};

@@ -92,5 +91,3 @@ return this._isTransaction

return this._isTransaction
? services_1.FirestoreDeleter.to(this._ref)
.transaction()
.delete(options)
? services_1.FirestoreDeleter.to(this._ref).transaction().delete(options)
: services_1.FirestoreDeleter.to(this._ref).delete();

@@ -97,0 +94,0 @@ }

@@ -1,3 +0,4 @@

import { FirestoreRef } from '../../types';
import { FirestoreSubscriber, FirestoreFinder } from '../../services';
import { FirestoreRef, Context } from '../../types';
import { FirestoreSubscriber, FirestoreFinder, FirestoreStreamSubscriber } from '../../services';
import { Action } from 'stream-executor';
/**

@@ -8,2 +9,3 @@ * Factory of FirestoreSubscriber and FirestoreFinder

* @method once: return FirestoreFinder
* @method pipe(...args): return FirestoreStreamSubscriber
*/

@@ -24,2 +26,51 @@ export declare class FirestoreReaderServiceFactory {

once(): FirestoreFinder;
/**
* Subscribe firestore data like rxjs.
* @see see a comparison of usage with `from(ref).bindTo(statePropName)`
https://github.com/nor-ko-hi-jp/firex-store/blob/master/docs/v1/v1-usage.md#subscribe-firestore-using-like-rxjs
* @param act1 <T, U>(data: { isLast: boolean, data: T, bindTo: (statePropName: string) => void }) => U
* @param act2 <T, U>(data: T) => U
* @param act3 <T, U>(data: T) => U
* @param act4 <T, U>(data: T) => U
* @param act5 <T, U>(data: T) => U
* @param act6 <T, U>(data: T) => U
* @param act7 <T, U>(data: T) => U
* @param act8 <T, U>(data: T) => U
* @param act9 <T, U>(data: T) => U
* @param act10 <T, U>(data: T) => U
*
* @example
* import { from, map, bndTo, firestoreMutations } from 'firex-store'
*
* const toCharactor = (data) => ({ id: data.docId, name: `${data.first_name} ${data.family_name}` })
*
* export default {
* state: {
* charactors: null,
* isLoaded: false
* },
* mutations: {
* ...firestoreMutations('all'),
* setIsLoaded: (state, paylaod) => {
* state.charactors = payload
* }
* },
* actions: {
* subscribe: ({ commit, state }, { collectionName }) => {
* from(firebase.collections(collectionName))
* .pipe(
* map(toCharactor),
* bindTo('charactor'),
* ({ data }) => {
* commit('setIsLoaded', data)
* }
* )
* .subscribe(state, commit)
* }
* }
* }
*/
pipe<A, B, C, D, E, F, G, H, I, J>(act1: Action<Context<{
docId: string;
} & Record<string, any>>, A>, act2?: Action<A, B>, act3?: Action<B, C>, act4?: Action<C, D>, act5?: Action<D, E>, act6?: Action<E, F>, act7?: Action<F, G>, act8?: Action<G, H>, act9?: Action<H, I>, act10?: Action<I, J>): Pick<FirestoreStreamSubscriber, "subscribe">;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FirestoreReaderServiceFactory = void 0;
const services_1 = require("../../services");

@@ -9,2 +10,3 @@ /**

* @method once: return FirestoreFinder
* @method pipe(...args): return FirestoreStreamSubscriber
*/

@@ -30,3 +32,52 @@ class FirestoreReaderServiceFactory {

}
/**
* Subscribe firestore data like rxjs.
* @see see a comparison of usage with `from(ref).bindTo(statePropName)`
https://github.com/nor-ko-hi-jp/firex-store/blob/master/docs/v1/v1-usage.md#subscribe-firestore-using-like-rxjs
* @param act1 <T, U>(data: { isLast: boolean, data: T, bindTo: (statePropName: string) => void }) => U
* @param act2 <T, U>(data: T) => U
* @param act3 <T, U>(data: T) => U
* @param act4 <T, U>(data: T) => U
* @param act5 <T, U>(data: T) => U
* @param act6 <T, U>(data: T) => U
* @param act7 <T, U>(data: T) => U
* @param act8 <T, U>(data: T) => U
* @param act9 <T, U>(data: T) => U
* @param act10 <T, U>(data: T) => U
*
* @example
* import { from, map, bndTo, firestoreMutations } from 'firex-store'
*
* const toCharactor = (data) => ({ id: data.docId, name: `${data.first_name} ${data.family_name}` })
*
* export default {
* state: {
* charactors: null,
* isLoaded: false
* },
* mutations: {
* ...firestoreMutations('all'),
* setIsLoaded: (state, paylaod) => {
* state.charactors = payload
* }
* },
* actions: {
* subscribe: ({ commit, state }, { collectionName }) => {
* from(firebase.collections(collectionName))
* .pipe(
* map(toCharactor),
* bindTo('charactor'),
* ({ data }) => {
* commit('setIsLoaded', data)
* }
* )
* .subscribe(state, commit)
* }
* }
* }
*/
pipe(act1, act2, act3, act4, act5, act6, act7, act8, act9, act10) {
return services_1.FirestoreStreamSubscriber.from(this._ref).pipe(act1, act2, act3, act4, act5, act6, act7, act8, act9, act10);
}
}
exports.FirestoreReaderServiceFactory = FirestoreReaderServiceFactory;
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./firestore-reader-service.factory"));
__export(require("./firestore-document-writer.facade"));
__exportStar(require("./firestore-reader-service.factory"), exports);
__exportStar(require("./firestore-document-writer.facade"), exports);
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./from.creator"));
__export(require("./on.creator"));
__export(require("./to.creator"));
__exportStar(require("./from.creator"), exports);
__exportStar(require("./on.creator"), exports);
__exportStar(require("./to.creator"), exports);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.on = void 0;
const services_1 = require("../services");

@@ -4,0 +5,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.to = void 0;
const helpers_1 = require("./helpers");

@@ -4,0 +5,0 @@ const services_1 = require("../services");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.appErrorTree = void 0;
exports.appErrorTree = {
ID_HAS_ALREADY_BEEN_USED: {
name: 'Transaction Error',
message: 'This ID has already been used.'
message: 'This ID has already been used.',
},
DATA_EXISTED: {
name: 'Transaction Error',
message: 'data existed.'
message: 'data existed.',
},
DATA_NOT_EXISTED: {
name: 'Transaction Error',
message: 'data not existed.'
message: 'data not existed.',
},
NOT_IMPLEMENTED: {
name: 'Not Implemented Error',
message: 'To be implemented.'
}
message: 'To be implemented.',
},
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.errorMessageTree = void 0;
exports.errorMessageTree = {
BIND_TO_METHOD_NOT_CALLED: 'You need to call bindTo method before call it.',
UNSUBSCRIBE_METHOD_NOT_CALLED: 'Unsubscribe method have been called, but not unsubscribed.'
UNSUBSCRIBE_METHOD_NOT_CALLED: 'Unsubscribe method have been called, but not unsubscribed.',
};
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./app-error.tree"));
__export(require("./error-message.tree"));
__exportStar(require("./app-error.tree"), exports);
__exportStar(require("./error-message.tree"), exports);
export * from './store';
export { FirestoreFinder, FirestoreSubscriber, FirestoreUnsubscriber, FirestoreAdder, FirestoreMergeSetter, FirestoreSetter, FirestoreDeleter } from './services';
export { Mapper, AfterMutationCalled, ErrorHandler, CompletionHandler, NotFoundHandler } from './types';
export { FirestoreFinder, FirestoreSubscriber, FirestoreUnsubscriber, FirestoreAdder, FirestoreMergeSetter, FirestoreSetter, FirestoreDeleter, FirestoreStreamSubscriber, map, bindTo, } from './services';
export { Mapper, AfterMutationCalled, ErrorHandler, CompletionHandler, NotFoundHandler, } from './types';
export { Payload, DocumentResult, AppError, FirestoreMapper } from './models';

@@ -5,0 +5,0 @@ export { from, on, to } from './creators';

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./store"));
exports.v0 = void 0;
__exportStar(require("./store"), exports);
var services_1 = require("./services");
exports.FirestoreFinder = services_1.FirestoreFinder;
exports.FirestoreSubscriber = services_1.FirestoreSubscriber;
exports.FirestoreUnsubscriber = services_1.FirestoreUnsubscriber;
exports.FirestoreAdder = services_1.FirestoreAdder;
exports.FirestoreMergeSetter = services_1.FirestoreMergeSetter;
exports.FirestoreSetter = services_1.FirestoreSetter;
exports.FirestoreDeleter = services_1.FirestoreDeleter;
Object.defineProperty(exports, "FirestoreFinder", { enumerable: true, get: function () { return services_1.FirestoreFinder; } });
Object.defineProperty(exports, "FirestoreSubscriber", { enumerable: true, get: function () { return services_1.FirestoreSubscriber; } });
Object.defineProperty(exports, "FirestoreUnsubscriber", { enumerable: true, get: function () { return services_1.FirestoreUnsubscriber; } });
Object.defineProperty(exports, "FirestoreAdder", { enumerable: true, get: function () { return services_1.FirestoreAdder; } });
Object.defineProperty(exports, "FirestoreMergeSetter", { enumerable: true, get: function () { return services_1.FirestoreMergeSetter; } });
Object.defineProperty(exports, "FirestoreSetter", { enumerable: true, get: function () { return services_1.FirestoreSetter; } });
Object.defineProperty(exports, "FirestoreDeleter", { enumerable: true, get: function () { return services_1.FirestoreDeleter; } });
Object.defineProperty(exports, "FirestoreStreamSubscriber", { enumerable: true, get: function () { return services_1.FirestoreStreamSubscriber; } });
Object.defineProperty(exports, "map", { enumerable: true, get: function () { return services_1.map; } });
Object.defineProperty(exports, "bindTo", { enumerable: true, get: function () { return services_1.bindTo; } });
var models_1 = require("./models");
exports.FirestoreMapper = models_1.FirestoreMapper;
Object.defineProperty(exports, "FirestoreMapper", { enumerable: true, get: function () { return models_1.FirestoreMapper; } });
var creators_1 = require("./creators");
exports.from = creators_1.from;
exports.on = creators_1.on;
exports.to = creators_1.to;
Object.defineProperty(exports, "from", { enumerable: true, get: function () { return creators_1.from; } });
Object.defineProperty(exports, "on", { enumerable: true, get: function () { return creators_1.on; } });
Object.defineProperty(exports, "to", { enumerable: true, get: function () { return creators_1.to; } });
const v0 = require("./v0");
exports.v0 = v0;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FirestoreMapper = void 0;
const errors_1 = require("../errors");

@@ -4,0 +5,0 @@ /**

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./firestore-mapper.model"));
__exportStar(require("./document-result.model"), exports);
__exportStar(require("./payload.model"), exports);
__exportStar(require("./finder.model"), exports);
__exportStar(require("./subscriber.model"), exports);
__exportStar(require("./unsubscriber.model"), exports);
__exportStar(require("./app-error.model"), exports);
__exportStar(require("./adder.model"), exports);
__exportStar(require("./setter.model"), exports);
__exportStar(require("./merge-setter.model"), exports);
__exportStar(require("./transaction.model"), exports);
__exportStar(require("./deleter.model"), exports);
__exportStar(require("./firestore-mapper.model"), exports);
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./options.parameter"), exports);
__exportStar(require("./find-options.parameter"), exports);
__exportStar(require("./subscribe-options.parameter"), exports);
__exportStar(require("./add-options.parameter"), exports);
__exportStar(require("./set-options.parameter"), exports);
__exportStar(require("./transaction.parameter"), exports);
__exportStar(require("./delete-options.parameter"), exports);

@@ -1,4 +0,3 @@

export * from './mutation-handlers';
export * from './notifications';
export * from './to-document-result';
export * from './transactions';
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./mutation-handlers"));
__export(require("./notifications"));
__export(require("./to-document-result"));
__export(require("./transactions"));
__exportStar(require("./notifications"), exports);
__exportStar(require("./to-document-result"), exports);
__exportStar(require("./transactions"), exports);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.notifyCompletionIfDefined = exports.notifyErrorOccurred = exports.notifyNotFound = void 0;
exports.notifyNotFound = (type, notFoundHandler, isAll) => notFoundHandler

@@ -4,0 +5,0 @@ ? notFoundHandler(type, isAll)

import { Mapper } from '../../types';
import { DocumentResult } from '../../models';
export declare const toDocumentResult: <T = any>(snapshot: import("firebase").firestore.QueryDocumentSnapshot<import("firebase").firestore.DocumentData> | import("firebase").firestore.DocumentSnapshot<import("firebase").firestore.DocumentData>, mapper?: Mapper<T> | undefined) => DocumentResult;
export declare const toDocumentResult: <T = any>(snapshot: firebase.firestore.DocumentSnapshot | firebase.firestore.QueryDocumentSnapshot, mapper?: Mapper<T> | undefined) => DocumentResult;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toDocumentResult = void 0;
exports.toDocumentResult = (snapshot, mapper) => {

@@ -4,0 +5,0 @@ const data = { ...snapshot.data() };

@@ -14,4 +14,4 @@ import { AppErrorOr, ErrorHandler } from '../../types';

}
export declare const transactionOfSetOrMergeSet: <T = any>({ ref, data, merge, transaction, errorHandler }: SetTransactionParameter<T>) => Promise<AppErrorOr<void>>;
export declare const transacitonOfDelete: ({ ref, transaction, errorHandler }: DeleteTransactionParameter) => Promise<AppErrorOr<void>>;
export declare const transactionOfSetOrMergeSet: <T = any>({ ref, data, merge, transaction, errorHandler, }: SetTransactionParameter<T>) => Promise<AppErrorOr<void>>;
export declare const transacitonOfDelete: ({ ref, transaction, errorHandler, }: DeleteTransactionParameter) => Promise<AppErrorOr<void>>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transacitonOfDelete = exports.transactionOfSetOrMergeSet = void 0;
const errors_1 = require("../../errors");
const notifications_1 = require("./notifications");
const isAbleToSetOrMergeSet = (isMergeSet, snapshot) => (isMergeSet && snapshot.exists === true) || (!isMergeSet && !snapshot.data());
exports.transactionOfSetOrMergeSet = async ({ ref, data, merge, transaction, errorHandler }) => {
exports.transactionOfSetOrMergeSet = async ({ ref, data, merge, transaction, errorHandler, }) => {
const isMergeSet = merge;

@@ -29,3 +30,3 @@ const appErrorOrIsAbleToSetOrMergeSet = await transaction

};
exports.transacitonOfDelete = async ({ ref, transaction, errorHandler }) => {
exports.transacitonOfDelete = async ({ ref, transaction, errorHandler, }) => {
const appErrorOrIsExisted = await transaction

@@ -32,0 +33,0 @@ .get(ref)

@@ -1,5 +0,5 @@

import { CallMutation, NullOr, AppErrorOr, DocumentId, Unsubscribe, FirestoreRef } from '../types';
import { CallMutation, NullOr, AppErrorOr, DocumentId, Unsubscribe, FirestoreRef, MutationHandler } from '../types';
import { SubscribeOptionsParameter, FindOptionsParameter, AddOptionsParameter, SetOptionsParameter, DeleteOptionsParameter } from '../parameters';
import { DocumentResult } from '../models';
interface SubscribeParameter<T, U> extends SubscribeOptionsParameter<T> {
interface SubscribeOnceParameter<T, U> extends SubscribeOptionsParameter<T> {
statePropName: string;

@@ -9,2 +9,6 @@ ref: U;

}
interface SubscribeParameter<T, U> extends Pick<SubscribeOptionsParameter<T>, 'notFoundHandler' | 'errorHandler' | 'completionHandler'> {
ref: U;
mutationHandler: MutationHandler;
}
interface FindParameter<T, U> extends FindOptionsParameter<T> {

@@ -28,11 +32,11 @@ ref: U;

export declare class FirestoreRepository {
static subscribe<T = any>({ statePropName, ref, callMutation, mapper, errorHandler, completionHandler, afterMutationCalled, notFoundHandler }: SubscribeParameter<T, firebase.firestore.DocumentReference>): Unsubscribe;
static subscribeAll<T = any>({ statePropName, ref, callMutation, mapper, errorHandler, completionHandler, afterMutationCalled, notFoundHandler }: SubscribeParameter<T, firebase.firestore.CollectionReference | firebase.firestore.Query>): Unsubscribe;
static subscribeOnce<T = any>({ statePropName, ref, callMutation, mapper, errorHandler, completionHandler, afterMutationCalled, notFoundHandler }: SubscribeParameter<T, FirestoreRef>): Promise<NullOr<Error | T | T[] | DocumentResult | DocumentResult[]>>;
static find<T = any>({ ref, mapper, errorHandler, completionHandler }: FindParameter<T, firebase.firestore.DocumentReference>): Promise<NullOr<T | DocumentResult | Error>>;
static findAll<T = any>({ ref, mapper, errorHandler, completionHandler }: FindParameter<T, firebase.firestore.CollectionReference | firebase.firestore.Query>): Promise<NullOr<T[] | DocumentResult[] | Error>>;
static add<T = any>({ data, ref, mapper, errorHandler, completionHandler }: AddParameter<T, firebase.firestore.CollectionReference>): Promise<AppErrorOr<DocumentId>>;
static set<T>({ data, ref, merge, isTransaction, mapper, errorHandler, completionHandler }: SetParameter<T, firebase.firestore.DocumentReference>): Promise<AppErrorOr<void>>;
static delete({ ref, isTransaction, errorHandler, completionHandler }: DeleteParamater<firebase.firestore.DocumentReference>): Promise<AppErrorOr<void>>;
static subscribe<T = any>({ ref, mutationHandler, errorHandler, completionHandler, notFoundHandler, }: SubscribeParameter<T, firebase.firestore.DocumentReference>): Unsubscribe;
static subscribeAll<T = any>({ ref, mutationHandler, errorHandler, completionHandler, notFoundHandler, }: SubscribeParameter<T, firebase.firestore.CollectionReference | firebase.firestore.Query>): Unsubscribe;
static subscribeOnce<T = any>({ statePropName, ref, callMutation, mapper, errorHandler, completionHandler, afterMutationCalled, notFoundHandler, }: SubscribeOnceParameter<T, FirestoreRef>): Promise<NullOr<Error | T | T[] | DocumentResult | DocumentResult[]>>;
static find<T = any>({ ref, mapper, errorHandler, completionHandler, }: FindParameter<T, firebase.firestore.DocumentReference>): Promise<NullOr<T | DocumentResult | Error>>;
static findAll<T = any>({ ref, mapper, errorHandler, completionHandler, }: FindParameter<T, firebase.firestore.CollectionReference | firebase.firestore.Query>): Promise<NullOr<T[] | DocumentResult[] | Error>>;
static add<T = any>({ data, ref, mapper, errorHandler, completionHandler, }: AddParameter<T, firebase.firestore.CollectionReference>): Promise<AppErrorOr<DocumentId>>;
static set<T>({ data, ref, merge, isTransaction, mapper, errorHandler, completionHandler, }: SetParameter<T, firebase.firestore.DocumentReference>): Promise<AppErrorOr<void>>;
static delete({ ref, isTransaction, errorHandler, completionHandler, }: DeleteParamater<firebase.firestore.DocumentReference>): Promise<AppErrorOr<void>>;
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FirestoreRepository = void 0;
const helpers_1 = require("./helpers");
const utils_1 = require("../utils");
class FirestoreRepository {
static subscribe({ statePropName, ref, callMutation, mapper, errorHandler, completionHandler, afterMutationCalled, notFoundHandler }) {
static subscribe({ ref, mutationHandler, errorHandler, completionHandler, notFoundHandler, }) {
return ref.onSnapshot((snapshot) => !snapshot.exists
? helpers_1.notifyNotFound('document', notFoundHandler)
: helpers_1.callDocumentMutation({
statePropName,
snapshot,
callMutation,
mapper,
afterMutationCalled
}), (error) => helpers_1.notifyErrorOccurred(error, errorHandler), () => helpers_1.notifyCompletionIfDefined(completionHandler));
: mutationHandler({ ...snapshot.data(), docId: snapshot.id }, 'added', true), (error) => helpers_1.notifyErrorOccurred(error, errorHandler), () => helpers_1.notifyCompletionIfDefined(completionHandler));
}
static subscribeAll({ statePropName, ref, callMutation, mapper, errorHandler, completionHandler, afterMutationCalled, notFoundHandler }) {
return ref.onSnapshot((snapshot) => snapshot.empty
? helpers_1.notifyNotFound('collection', notFoundHandler, true)
: helpers_1.callCollectionMutation({
statePropName,
snapshot,
callMutation,
mapper,
afterMutationCalled,
notifyNotFound: () => helpers_1.notifyNotFound('collection', notFoundHandler, false)
}), (error) => helpers_1.notifyErrorOccurred(error, errorHandler), () => helpers_1.notifyCompletionIfDefined(completionHandler));
static subscribeAll({ ref, mutationHandler, errorHandler, completionHandler, notFoundHandler, }) {
return ref.onSnapshot((snapshot) => {
if (snapshot.empty) {
helpers_1.notifyNotFound('collection', notFoundHandler, true);
return;
}
const docChanges = snapshot.docChanges();
const docCount = docChanges.length;
docChanges.forEach((it, index) => {
mutationHandler({ ...it.doc.data(), docId: it.doc.id }, it.type, docCount === index + 1);
});
}, (error) => helpers_1.notifyErrorOccurred(error, errorHandler), () => helpers_1.notifyCompletionIfDefined(completionHandler));
}
static async subscribeOnce({ statePropName, ref, callMutation, mapper, errorHandler, completionHandler, afterMutationCalled, notFoundHandler }) {
static async subscribeOnce({ statePropName, ref, callMutation, mapper, errorHandler, completionHandler, afterMutationCalled, notFoundHandler, }) {
const result = utils_1.isDocumentRef(ref)

@@ -34,3 +30,3 @@ ? await this.find({

mapper,
errorHandler
errorHandler,
})

@@ -40,3 +36,3 @@ : await this.findAll({

mapper,
errorHandler
errorHandler,
});

@@ -62,3 +58,3 @@ if (result instanceof Error) {

}
static async find({ ref, mapper, errorHandler, completionHandler }) {
static async find({ ref, mapper, errorHandler, completionHandler, }) {
const result = await ref

@@ -71,3 +67,3 @@ .get()

}
static async findAll({ ref, mapper, errorHandler, completionHandler }) {
static async findAll({ ref, mapper, errorHandler, completionHandler, }) {
const result = await ref

@@ -86,3 +82,3 @@ .get()

}
static async add({ data, ref, mapper, errorHandler, completionHandler }) {
static async add({ data, ref, mapper, errorHandler, completionHandler, }) {
const _data = mapper ? mapper(data) : data;

@@ -96,3 +92,3 @@ const result = await ref

}
static async set({ data, ref, merge, isTransaction, mapper, errorHandler, completionHandler }) {
static async set({ data, ref, merge, isTransaction, mapper, errorHandler, completionHandler, }) {
const _data = mapper ? mapper(data) : data;

@@ -109,3 +105,3 @@ const result = !isTransaction

mapper,
errorHandler
errorHandler,
}));

@@ -115,3 +111,3 @@ helpers_1.notifyCompletionIfDefined(completionHandler);

}
static async delete({ ref, isTransaction, errorHandler, completionHandler }) {
static async delete({ ref, isTransaction, errorHandler, completionHandler, }) {
const result = !isTransaction

@@ -124,3 +120,3 @@ ? await ref

transaction,
errorHandler
errorHandler,
}));

@@ -127,0 +123,0 @@ helpers_1.notifyCompletionIfDefined(completionHandler);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FirestoreAdder = void 0;
const repositories_1 = require("../repositories");

@@ -59,3 +60,3 @@ /**

...options,
...{ mapper: this._mapper }
...{ mapper: this._mapper },
};

@@ -65,3 +66,3 @@ const result = await repositories_1.FirestoreRepository.add({

data: _data,
..._options
..._options,
});

@@ -68,0 +69,0 @@ return result;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FirestoreDeleter = void 0;
const repositories_1 = require("../repositories");

@@ -52,3 +53,3 @@ /**

isTransaction: this._isTransaction,
...options
...options,
});

@@ -55,0 +56,0 @@ return result;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FirestoreFinder = void 0;
const utils_1 = require("../utils");

@@ -65,3 +66,3 @@ const repositories_1 = require("../repositories");

...options,
...{ mapper: this._mapper }
...{ mapper: this._mapper },
};

@@ -68,0 +69,0 @@ return utils_1.isDocumentRef(this.ref)

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FirestoreMergeSetter = void 0;
const repositories_1 = require("../repositories");

@@ -77,3 +78,3 @@ /**

...options,
...{ mapper: this._mapper }
...{ mapper: this._mapper },
};

@@ -85,3 +86,3 @@ const result = await repositories_1.FirestoreRepository.set({

..._options,
merge: true
merge: true,
});

@@ -88,0 +89,0 @@ return result;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FirestoreSetter = void 0;
const repositories_1 = require("../repositories");

@@ -78,3 +79,3 @@ /**

...options,
...{ mapper: this._mapper }
...{ mapper: this._mapper },
};

@@ -86,3 +87,3 @@ const result = await repositories_1.FirestoreRepository.set({

..._options,
merge: false
merge: false,
});

@@ -89,0 +90,0 @@ return result;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FirestoreSubscriber = void 0;
const errors_1 = require("../errors");

@@ -100,6 +101,7 @@ const helpers_1 = require("./helpers");

...options,
...{ mapper: this._mapper }
...{ mapper: this._mapper },
};
is_document_ref_1.isDocumentRef(this.ref)
? helpers_1.subscribeFirestoreDocument({
const { subscribeFirestoreCollection, subscribeFirestoreDocument, } = helpers_1.createSubscriber().asProcedure();
const unsubscribe = is_document_ref_1.isDocumentRef(this.ref)
? subscribeFirestoreDocument({
statePropName: this.statePropName,

@@ -109,5 +111,5 @@ state,

ref: this.ref,
options: _options
options: _options,
})
: helpers_1.subscribeFirestoreCollection({
: subscribeFirestoreCollection({
statePropName: this.statePropName,

@@ -117,4 +119,6 @@ state,

ref: this.ref,
options: _options
options: _options,
});
const unsubscribes = state[configurations_1.FIREX_UNSUBSCRIBES];
unsubscribes.set(this.statePropName, unsubscribe);
}

@@ -137,6 +141,6 @@ /**

...options,
...{ mapper: this._mapper }
...{ mapper: this._mapper },
};
const mutationType = 'document';
const callMutation = helpers_1.createMutation({ mutationType, commit });
const callMutation = helpers_1.createMutation({ mutationType, commit })(this.statePropName);
await repositories_1.FirestoreRepository.subscribeOnce({

@@ -146,3 +150,3 @@ statePropName: this.statePropName,

callMutation,
..._options
..._options,
});

@@ -149,0 +153,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FirestoreUnsubscriber = void 0;
const configurations_1 = require("../configurations");

@@ -39,3 +40,3 @@ const errors_1 = require("../errors");

const unsubscribe = unsubscribes.get(this.statePropName);
if (unsubscribe) {
if (unsubscribe && typeof unsubscribe == 'function') {
unsubscribe();

@@ -42,0 +43,0 @@ }

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

}
export declare const callMutation: ({ mutationType, changeType, commit, payload }: Parameter) => void;
export declare const callMutation: ({ mutationType, changeType, commit, payload, }: Parameter) => void;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.callMutation = void 0;
const mutation_1 = require("../../store/types/mutation");
exports.callMutation = ({ mutationType, changeType, commit, payload }) => {
exports.callMutation = ({ mutationType, changeType, commit, payload, }) => {
const types = mutationType === 'document'

@@ -6,0 +7,0 @@ ? mutation_1.mutationTypes.document

@@ -7,3 +7,3 @@ import { CallMutation, MutationType } from '../../types';

}
export declare const createMutation: ({ mutationType, commit }: MutationParameter) => CallMutation;
export declare const createMutation: ({ mutationType, commit }: MutationParameter) => (statePropName: string) => CallMutation;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createMutation = void 0;
const call_mutation_1 = require("./call-mutation");
exports.createMutation = ({ mutationType, commit }) => (changeType, payload) => call_mutation_1.callMutation({ mutationType, changeType, commit, payload });
exports.createMutation = ({ mutationType, commit }) => (statePropName) => (changeType, { isLast, data }) => call_mutation_1.callMutation({
mutationType,
changeType,
commit,
payload: { statePropName, isLast, data },
});
export * from './call-mutation';
export * from './subscribe';
export * from './create-mutation';
export * from './create-mutation-handler';
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./call-mutation"));
__export(require("./subscribe"));
__export(require("./create-mutation"));
__exportStar(require("./call-mutation"), exports);
__exportStar(require("./subscribe"), exports);
__exportStar(require("./create-mutation"), exports);
__exportStar(require("./create-mutation-handler"), exports);

@@ -0,4 +1,6 @@

import { Context } from '../../types';
import { Commit } from 'vuex';
import { SubscribeOptionsParameter } from '../../parameters';
interface SubscribeParameter<T, U> {
import { Action } from 'stream-executor';
interface ProcedureParameter<T, U> {
statePropName: string;

@@ -8,6 +10,21 @@ state: any;

ref: T;
options?: SubscribeOptionsParameter<U>;
options: SubscribeOptionsParameter<U>;
}
export declare const subscribeFirestoreCollection: <T = any>({ statePropName, state, commit, ref, options }: SubscribeParameter<import("firebase").firestore.CollectionReference<import("firebase").firestore.DocumentData> | import("firebase").firestore.Query<import("firebase").firestore.DocumentData>, T>) => void;
export declare const subscribeFirestoreDocument: <T = any>({ statePropName, state, commit, ref, options }: SubscribeParameter<import("firebase").firestore.DocumentReference<import("firebase").firestore.DocumentData>, T>) => void;
interface StreamParameter<T> {
commit: Commit;
ref: T;
setUnsubscriber: (statePropName: string) => void;
actions: Action<Context<any>, Context<any>>[];
options: SubscribeOptionsParameter<any>;
}
export declare const createSubscriber: () => {
asProcedure: () => {
subscribeFirestoreCollection: <T = any>({ statePropName, commit, ref, options, }: ProcedureParameter<import("firebase").firestore.CollectionReference<import("firebase").firestore.DocumentData> | import("firebase").firestore.Query<import("firebase").firestore.DocumentData>, T>) => import("../../types").Unsubscribe;
subscribeFirestoreDocument: <T_1 = any>({ statePropName, commit, ref, options, }: ProcedureParameter<import("firebase").firestore.DocumentReference<import("firebase").firestore.DocumentData>, T_1>) => import("../../types").Unsubscribe;
};
asStream: () => {
subscribeFirestoreCollection: ({ commit, setUnsubscriber, actions, ref, options, }: StreamParameter<firebase.firestore.Query | firebase.firestore.CollectionReference>) => import("../../types").Unsubscribe;
subscribeFirestoreDocument: ({ commit, setUnsubscriber, actions, ref, options, }: StreamParameter<firebase.firestore.DocumentReference>) => import("../../types").Unsubscribe;
};
};
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const configurations_1 = require("../../configurations");
exports.createSubscriber = void 0;
const repositories_1 = require("../../repositories");
const create_mutation_1 = require("./create-mutation");
exports.subscribeFirestoreCollection = ({ statePropName, state, commit, ref, options }) => {
const callMutation = create_mutation_1.createMutation({ mutationType: 'collection', commit });
const unsubscribe = repositories_1.FirestoreRepository.subscribeAll({
statePropName,
ref,
callMutation,
...options
});
const unsubscribes = state[configurations_1.FIREX_UNSUBSCRIBES];
unsubscribes.set(statePropName, unsubscribe);
const create_mutation_handler_1 = require("./create-mutation-handler");
const asProcedure = () => {
const subscribeFirestoreCollection = ({ statePropName, commit, ref, options, }) => {
const { mapper, afterMutationCalled } = options;
const callMutation = create_mutation_1.createMutation({ mutationType: 'collection', commit });
const mutationHandler = create_mutation_handler_1.createMutationHandler().forProcedure(statePropName, callMutation, mapper, afterMutationCalled);
const unsubscribe = repositories_1.FirestoreRepository.subscribeAll({
ref,
mutationHandler,
...options,
});
return unsubscribe;
};
const subscribeFirestoreDocument = ({ statePropName, commit, ref, options, }) => {
const { mapper, afterMutationCalled } = options;
const callMutation = create_mutation_1.createMutation({ mutationType: 'document', commit });
const mutationHandler = create_mutation_handler_1.createMutationHandler().forProcedure(statePropName, callMutation, mapper, afterMutationCalled);
const unsubscribe = repositories_1.FirestoreRepository.subscribe({
ref,
mutationHandler,
...options,
});
return unsubscribe;
};
return { subscribeFirestoreCollection, subscribeFirestoreDocument };
};
exports.subscribeFirestoreDocument = ({ statePropName, state, commit, ref, options }) => {
const callMutation = create_mutation_1.createMutation({ mutationType: 'document', commit });
const unsubscribe = repositories_1.FirestoreRepository.subscribe({
statePropName,
ref,
callMutation,
...options
});
const unsubscribes = state[configurations_1.FIREX_UNSUBSCRIBES];
unsubscribes.set(statePropName, unsubscribe);
const asStream = () => {
const subscribeFirestoreCollection = ({ commit, setUnsubscriber, actions, ref, options, }) => {
const callMutation = create_mutation_1.createMutation({ mutationType: 'collection', commit });
const mutationHandler = create_mutation_handler_1.createMutationHandler().forStream(callMutation, setUnsubscriber, actions);
const unsubscribe = repositories_1.FirestoreRepository.subscribeAll({
ref,
mutationHandler,
...options,
});
return unsubscribe;
};
const subscribeFirestoreDocument = ({ commit, setUnsubscriber, actions, ref, options, }) => {
const callMutation = create_mutation_1.createMutation({ mutationType: 'document', commit });
const mutationHandler = create_mutation_handler_1.createMutationHandler().forStream(callMutation, setUnsubscriber, actions);
const unsubscribe = repositories_1.FirestoreRepository.subscribe({
ref,
mutationHandler,
...options,
});
return unsubscribe;
};
return { subscribeFirestoreCollection, subscribeFirestoreDocument };
};
exports.createSubscriber = () => {
return { asProcedure, asStream };
};

@@ -8,1 +8,2 @@ export * from './firestore-finder.service';

export * from './firestore-deleter.service';
export * from './firestore-stream-subscriber.service';
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./firestore-finder.service"));
__export(require("./firestore-subscriber.service"));
__export(require("./firestore-unsubscriber.service"));
__export(require("./firestore-adder.service"));
__export(require("./firestore-setter.service"));
__export(require("./firestore-merge-setter.service"));
__export(require("./firestore-deleter.service"));
__exportStar(require("./firestore-finder.service"), exports);
__exportStar(require("./firestore-subscriber.service"), exports);
__exportStar(require("./firestore-unsubscriber.service"), exports);
__exportStar(require("./firestore-adder.service"), exports);
__exportStar(require("./firestore-setter.service"), exports);
__exportStar(require("./firestore-merge-setter.service"), exports);
__exportStar(require("./firestore-deleter.service"), exports);
__exportStar(require("./firestore-stream-subscriber.service"), exports);
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./subscribe.action"));
__export(require("./unsubscribe.action"));
__exportStar(require("./subscribe.action"), exports);
__exportStar(require("./unsubscribe.action"), exports);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.firestoreSubscribeAction = void 0;
const action_1 = require("../types/action");

@@ -41,5 +42,5 @@ /**

firestoreSubscriber.subscribe(state, commit, options);
}
},
};
return tree;
};

@@ -26,4 +26,4 @@ import { ActionTree } from 'vuex';

export declare const firestoreUnsubscribeAction: (firestoreUnsubscriber: Unsubscriber, parameter: {
type: "document" | "collection";
actionName?: string | undefined;
type: 'document' | 'collection';
actionName?: string;
}) => ActionTree<any, any>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.firestoreUnsubscribeAction = void 0;
const action_1 = require("../types/action");

@@ -34,5 +35,5 @@ /**

firestoreUnsubscriber.unsubscribe(state);
}
},
};
return tree;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var mutations_1 = require("./mutations");
exports.firestoreMutations = mutations_1.firestoreMutations;
Object.defineProperty(exports, "firestoreMutations", { enumerable: true, get: function () { return mutations_1.firestoreMutations; } });
var actions_1 = require("./actions");
exports.firestoreSubscribeAction = actions_1.firestoreSubscribeAction;
exports.firestoreUnsubscribeAction = actions_1.firestoreUnsubscribeAction;
Object.defineProperty(exports, "firestoreSubscribeAction", { enumerable: true, get: function () { return actions_1.firestoreSubscribeAction; } });
Object.defineProperty(exports, "firestoreUnsubscribeAction", { enumerable: true, get: function () { return actions_1.firestoreUnsubscribeAction; } });
var action_1 = require("./types/action");
exports.actionTypes = action_1.actionTypes;
Object.defineProperty(exports, "actionTypes", { enumerable: true, get: function () { return action_1.actionTypes; } });
var mutation_1 = require("./types/mutation");
exports.mutationTypes = mutation_1.mutationTypes;
Object.defineProperty(exports, "mutationTypes", { enumerable: true, get: function () { return mutation_1.mutationTypes; } });
import { MutationTree } from 'vuex';
export declare const firestoreMutations: (type: import("../../types").MutationType) => MutationTree<any>;
export declare const firestoreMutations: (type: 'document' | 'collection' | 'all') => MutationTree<any>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.firestoreMutations = void 0;
const mutation_1 = require("../types/mutation");

@@ -18,3 +19,3 @@ const documentMutations = () => {

state[prop] = null;
}
},
};

@@ -50,3 +51,3 @@ };

state[prop].splice(index, 1);
}
},
};

@@ -63,5 +64,5 @@ };

...documentMutations(),
...collectionMutations()
...collectionMutations(),
};
}
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.actionTypes = void 0;
exports.actionTypes = {
collection: {
SUBSCRIBE: '[firex-store] Collection Subscribe',
UNSUBSCRIBE: '[firex-store] Collection Unsubscribe'
UNSUBSCRIBE: '[firex-store] Collection Unsubscribe',
},
document: {
SUBSCRIBE: '[firex-store] Document Subscribe',
UNSUBSCRIBE: '[firex-store] Document Unsubscribe'
UNSUBSCRIBE: '[firex-store] Document Unsubscribe',
},

@@ -28,3 +29,3 @@ // --- deprecated, follow variables will be removed ^2.0.0 ---

*/
COLLECTION_UNSUBSCRIBE: '[firex-store] Collection Unsubscribe'
COLLECTION_UNSUBSCRIBE: '[firex-store] Collection Unsubscribe',
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mutationTypes = void 0;
const documentTypes = {
ADD: '[firex-store] Add',
MODIFY: '[firex-store] Modify',
REMOVE: '[firex-store] Remove'
REMOVE: '[firex-store] Remove',
};

@@ -11,7 +12,7 @@ const collectionTypes = {

MODIFY: '[firex-store] Modify Array',
REMOVE: '[firex-store] Remove Array'
REMOVE: '[firex-store] Remove Array',
};
exports.mutationTypes = {
document: documentTypes,
collection: collectionTypes
collection: collectionTypes,
};
import { firestore } from 'firebase';
import { Payload } from '../models';
export declare type CallMutation = (changeType: firestore.DocumentChangeType, payload: Payload) => void;
export declare type CallMutation = (changeType: firestore.DocumentChangeType, payload: Omit<Payload, 'statePropName'>) => void;

@@ -16,1 +16,4 @@ export * from './error-handler.type';

export * from './unsubscribe.type';
export * from './context.type';
export * from './firestore-action.type';
export * from './mutation-handler.type';
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./error-handler.type"), exports);
__exportStar(require("./call-mutation.type"), exports);
__exportStar(require("./mapper.type"), exports);
__exportStar(require("./mutation-type.type"), exports);
__exportStar(require("./completion-handler.type"), exports);
__exportStar(require("./firestore-ref.type"), exports);
__exportStar(require("./null-or.type"), exports);
__exportStar(require("./after-mutation-called.type"), exports);
__exportStar(require("./not-found-handler.type"), exports);
__exportStar(require("./unsubscribes.type"), exports);
__exportStar(require("./app-error-or.type"), exports);
__exportStar(require("./document-id.type"), exports);
__exportStar(require("./either.type"), exports);
__exportStar(require("./document-or-collection.type"), exports);
__exportStar(require("./unsubscribe.type"), exports);
__exportStar(require("./context.type"), exports);
__exportStar(require("./firestore-action.type"), exports);
__exportStar(require("./mutation-handler.type"), exports);
import { Unsubscribe } from './unsubscribe.type';
declare type StatePropName = string;
export declare type Unsubscribes = Map<StatePropName, Unsubscribe>;
export declare type Unsubscribes = Map<StatePropName, Unsubscribe | string>;
export {};
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./is-document-ref"));
__exportStar(require("./is-document-ref"), exports);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isDocumentRef = void 0;
const firebase = require("firebase");
exports.isDocumentRef = (ref) => ref instanceof firebase.firestore.DocumentReference;

@@ -16,3 +16,3 @@ import { FindCriteriaOptions } from './options';

*/
export declare const findFirestore: <T = any>({ ref, options }: Criteria<FirestoreRef, T>) => Promise<NullOr<T>>;
export declare const findFirestore: <T = any>({ ref, options, }: Criteria<FirestoreRef, T>) => Promise<NullOr<T>>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findFirestore = void 0;
const service_1 = require("./service");

@@ -14,3 +15,3 @@ const is_document_ref_1 = require("./store/helpers/is-document-ref");

*/
exports.findFirestore = ({ ref, options }) => {
exports.findFirestore = ({ ref, options, }) => {
return is_document_ref_1.isDocumentRef(ref)

@@ -17,0 +18,0 @@ ? service_1.FirestoreService.find({ ref, ...options })

export * from './store';
export { findFirestore } from './find';
export { Mapper, AfterMutationCalled, ErrorHandler, CompletionHandler, NotFoundHandler } from './types';
export { Mapper, AfterMutationCalled, ErrorHandler, CompletionHandler, NotFoundHandler, } from './types';
export { Payload, DocumentResult } from './models';
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./store"));
__exportStar(require("./store"), exports);
var find_1 = require("./find");
exports.findFirestore = find_1.findFirestore;
Object.defineProperty(exports, "findFirestore", { enumerable: true, get: function () { return find_1.findFirestore; } });
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./document-result.interface"), exports);
__exportStar(require("./payload.interface"), exports);
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./criteria-options.interface"), exports);
__exportStar(require("./find-criteria-options.interface"), exports);
__exportStar(require("./subscribe-criteria-options.interface"), exports);
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./mutation-handlers"));
__export(require("./notifications"));
__export(require("./to-document-result"));
__exportStar(require("./mutation-handlers"), exports);
__exportStar(require("./notifications"), exports);
__exportStar(require("./to-document-result"), exports);

@@ -17,4 +17,4 @@ import { Mapper, CallMutation, AfterMutationCalled } from '../../types';

}
export declare const callDocumentMutation: <T = any>({ snapshot, callMutation, isLast, type, mapper, afterMutationCalled }: DocumentCriteria<T>) => void;
export declare const callCollectionMutation: <T = any>({ snapshot, callMutation, mapper, afterMutationCalled, notifyNotFound }: CollectionCriteria<T>) => void;
export declare const callDocumentMutation: <T = any>({ snapshot, callMutation, isLast, type, mapper, afterMutationCalled, }: DocumentCriteria<T>) => void;
export declare const callCollectionMutation: <T = any>({ snapshot, callMutation, mapper, afterMutationCalled, notifyNotFound, }: CollectionCriteria<T>) => void;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.callCollectionMutation = exports.callDocumentMutation = void 0;
const to_document_result_1 = require("./to-document-result");
exports.callDocumentMutation = ({ snapshot, callMutation, isLast, type, mapper, afterMutationCalled }) => {
exports.callDocumentMutation = ({ snapshot, callMutation, isLast, type, mapper, afterMutationCalled, }) => {
const _type = type ? type : 'added';

@@ -13,3 +14,3 @@ const data = to_document_result_1.toDocumentResult(snapshot, mapper);

};
exports.callCollectionMutation = ({ snapshot, callMutation, mapper, afterMutationCalled, notifyNotFound }) => {
exports.callCollectionMutation = ({ snapshot, callMutation, mapper, afterMutationCalled, notifyNotFound, }) => {
const length = snapshot.docChanges().length;

@@ -25,5 +26,5 @@ snapshot.docChanges().forEach((change, index) => {

mapper,
afterMutationCalled
afterMutationCalled,
});
});
};

@@ -1,4 +0,4 @@

import { NotFoundHandler, ErrorHandler, CompletionHandler } from '../../types';
export declare const notifyNotFound: (type: "document" | "collection", notFoundHandler?: NotFoundHandler | undefined, isAll?: boolean | undefined) => void;
import { NotFoundHandler, MutationType, ErrorHandler, CompletionHandler } from '../../types';
export declare const notifyNotFound: (type: MutationType, notFoundHandler?: NotFoundHandler | undefined, isAll?: boolean | undefined) => void;
export declare const notifyErrorOccurred: (error: any, errorHandler?: ErrorHandler | undefined) => any;
export declare const notifyCompletionIfDefined: (completionHandler?: CompletionHandler | undefined) => void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.notifyCompletionIfDefined = exports.notifyErrorOccurred = exports.notifyNotFound = void 0;
exports.notifyNotFound = (type, notFoundHandler, isAll) => notFoundHandler

@@ -4,0 +5,0 @@ ? notFoundHandler(type, isAll)

import { Mapper } from '../../types';
import { DocumentResult } from '../../models';
export declare const toDocumentResult: <T = any>(snapshot: import("firebase").firestore.QueryDocumentSnapshot<import("firebase").firestore.DocumentData> | import("firebase").firestore.DocumentSnapshot<import("firebase").firestore.DocumentData>, mapper?: Mapper<T> | undefined) => DocumentResult;
export declare const toDocumentResult: <T = any>(snapshot: firebase.firestore.DocumentSnapshot | firebase.firestore.QueryDocumentSnapshot, mapper?: Mapper<T> | undefined) => DocumentResult;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toDocumentResult = void 0;
exports.toDocumentResult = (snapshot, mapper) => {

@@ -4,0 +5,0 @@ const data = { ...snapshot.data() };

@@ -12,7 +12,7 @@ import { CallMutation, NullOr } from '../types';

export declare class FirestoreService {
static subscribe<T = any>({ ref, callMutation, mapper, errorHandler, completionHandler, afterMutationCalled, notFoundHandler, onCompleted }: SubscribeCriteria<T, firebase.firestore.DocumentReference>): Unsubscribe;
static subscribeAll<T = any>({ ref, callMutation, mapper, errorHandler, completionHandler, afterMutationCalled, notFoundHandler, onCompleted }: SubscribeCriteria<T, firebase.firestore.CollectionReference | firebase.firestore.Query>): Unsubscribe;
static find<T = any>({ ref, mapper, errorHandler, completionHandler, onCompleted }: FindCriteria<T, firebase.firestore.DocumentReference>): Promise<NullOr<T | any>>;
static findAll<T = any>({ ref, mapper, errorHandler, completionHandler, onCompleted }: FindCriteria<T, firebase.firestore.CollectionReference | firebase.firestore.Query>): Promise<NullOr<T[] | any | any[]>>;
static subscribe<T = any>({ ref, callMutation, mapper, errorHandler, completionHandler, afterMutationCalled, notFoundHandler, onCompleted, }: SubscribeCriteria<T, firebase.firestore.DocumentReference>): Unsubscribe;
static subscribeAll<T = any>({ ref, callMutation, mapper, errorHandler, completionHandler, afterMutationCalled, notFoundHandler, onCompleted, }: SubscribeCriteria<T, firebase.firestore.CollectionReference | firebase.firestore.Query>): Unsubscribe;
static find<T = any>({ ref, mapper, errorHandler, completionHandler, onCompleted, }: FindCriteria<T, firebase.firestore.DocumentReference>): Promise<NullOr<T | any>>;
static findAll<T = any>({ ref, mapper, errorHandler, completionHandler, onCompleted, }: FindCriteria<T, firebase.firestore.CollectionReference | firebase.firestore.Query>): Promise<NullOr<T[] | any | any[]>>;
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FirestoreService = void 0;
const helpers_1 = require("./helpers");
class FirestoreService {
static subscribe({ ref, callMutation, mapper, errorHandler, completionHandler, afterMutationCalled, notFoundHandler, onCompleted }) {
static subscribe({ ref, callMutation, mapper, errorHandler, completionHandler, afterMutationCalled, notFoundHandler, onCompleted, }) {
return ref.onSnapshot((snapshot) => !snapshot.exists

@@ -12,6 +13,6 @@ ? helpers_1.notifyNotFound('document', notFoundHandler)

mapper,
afterMutationCalled
afterMutationCalled,
}), (error) => helpers_1.notifyErrorOccurred(error, errorHandler), () => helpers_1.notifyCompletionIfDefined(completionHandler ? completionHandler : onCompleted));
}
static subscribeAll({ ref, callMutation, mapper, errorHandler, completionHandler, afterMutationCalled, notFoundHandler, onCompleted }) {
static subscribeAll({ ref, callMutation, mapper, errorHandler, completionHandler, afterMutationCalled, notFoundHandler, onCompleted, }) {
return ref.onSnapshot((snapshot) => snapshot.empty

@@ -24,6 +25,6 @@ ? helpers_1.notifyNotFound('collection', notFoundHandler, true)

afterMutationCalled,
notifyNotFound: () => helpers_1.notifyNotFound('collection', notFoundHandler, false)
notifyNotFound: () => helpers_1.notifyNotFound('collection', notFoundHandler, false),
}), (error) => helpers_1.notifyErrorOccurred(error, errorHandler), () => helpers_1.notifyCompletionIfDefined(completionHandler ? completionHandler : onCompleted));
}
static async find({ ref, mapper, errorHandler, completionHandler, onCompleted }) {
static async find({ ref, mapper, errorHandler, completionHandler, onCompleted, }) {
const result = await ref

@@ -36,3 +37,3 @@ .get()

}
static async findAll({ ref, mapper, errorHandler, completionHandler, onCompleted }) {
static async findAll({ ref, mapper, errorHandler, completionHandler, onCompleted, }) {
const result = await ref

@@ -39,0 +40,0 @@ .get()

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

export { firestoreSubscribeActions, firestoreSubscribeAction } from './subscribe-action';
export { firestoreUnsubscribeActions, firestoreUnsubscribeAction } from './unsibscribe-action';
export { firestoreSubscribeActions, firestoreSubscribeAction, } from './subscribe-action';
export { firestoreUnsubscribeActions, firestoreUnsubscribeAction, } from './unsibscribe-action';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var subscribe_action_1 = require("./subscribe-action");
exports.firestoreSubscribeActions = subscribe_action_1.firestoreSubscribeActions;
exports.firestoreSubscribeAction = subscribe_action_1.firestoreSubscribeAction;
Object.defineProperty(exports, "firestoreSubscribeActions", { enumerable: true, get: function () { return subscribe_action_1.firestoreSubscribeActions; } });
Object.defineProperty(exports, "firestoreSubscribeAction", { enumerable: true, get: function () { return subscribe_action_1.firestoreSubscribeAction; } });
var unsibscribe_action_1 = require("./unsibscribe-action");
exports.firestoreUnsubscribeActions = unsibscribe_action_1.firestoreUnsubscribeActions;
exports.firestoreUnsubscribeAction = unsibscribe_action_1.firestoreUnsubscribeAction;
Object.defineProperty(exports, "firestoreUnsubscribeActions", { enumerable: true, get: function () { return unsibscribe_action_1.firestoreUnsubscribeActions; } });
Object.defineProperty(exports, "firestoreUnsubscribeAction", { enumerable: true, get: function () { return unsibscribe_action_1.firestoreUnsubscribeAction; } });

@@ -22,3 +22,3 @@ import { ActionTree } from 'vuex';

*/
export declare const firestoreSubscribeActions: <T = any>({ ref, actionName, options }: Criteria<T>) => ActionTree<any, any>;
export declare const firestoreSubscribeActions: <T = any>({ ref, actionName, options, }: Criteria<T>) => ActionTree<any, any>;
/**

@@ -36,3 +36,3 @@ * subscribe firestore data to state property

*/
export declare const firestoreSubscribeAction: <T = any>({ ref, actionName, options }: Criteria<T>) => ActionTree<any, any>;
export declare const firestoreSubscribeAction: <T = any>({ ref, actionName, options, }: Criteria<T>) => ActionTree<any, any>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.firestoreSubscribeAction = exports.firestoreSubscribeActions = void 0;
const action_1 = require("../types/action");

@@ -18,3 +19,3 @@ const helpers_1 = require("../helpers");

*/
exports.firestoreSubscribeActions = ({ ref, actionName, options }) => {
exports.firestoreSubscribeActions = ({ ref, actionName, options, }) => {
const defaultActionName = helpers_1.isDocumentRef(ref)

@@ -27,3 +28,3 @@ ? action_1.actionTypes.document.SUBSCRIBE

helpers_1.subscribeFirestore({ state, commit, ref, options });
}
},
};

@@ -44,3 +45,3 @@ return tree;

*/
exports.firestoreSubscribeAction = ({ ref, actionName, options }) => {
exports.firestoreSubscribeAction = ({ ref, actionName, options, }) => {
const defaultActionName = helpers_1.isDocumentRef(ref)

@@ -53,5 +54,5 @@ ? action_1.actionTypes.document.SUBSCRIBE

helpers_1.subscribeFirestore({ state, commit, ref, options });
}
},
};
return tree;
};

@@ -13,3 +13,3 @@ import { MutationType } from '../../types';

*/
export declare const firestoreUnsubscribeActions: ({ type, actionName }: Criteria) => ActionTree<any, any>;
export declare const firestoreUnsubscribeActions: ({ type, actionName, }: Criteria) => ActionTree<any, any>;
/**

@@ -20,3 +20,3 @@ * unsubscribe firestore data

*/
export declare const firestoreUnsubscribeAction: ({ type, actionName }: Criteria) => ActionTree<any, any>;
export declare const firestoreUnsubscribeAction: ({ type, actionName, }: Criteria) => ActionTree<any, any>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.firestoreUnsubscribeAction = exports.firestoreUnsubscribeActions = void 0;
const action_1 = require("../types/action");

@@ -11,3 +12,3 @@ const helpers_1 = require("../helpers");

*/
exports.firestoreUnsubscribeActions = ({ type, actionName }) => {
exports.firestoreUnsubscribeActions = ({ type, actionName, }) => {
const defaultActionName = type === 'document'

@@ -20,3 +21,3 @@ ? action_1.actionTypes.document.UNSUBSCRIBE

helpers_1.unsubscribeFirestore({ state, type });
}
},
};

@@ -30,3 +31,3 @@ return tree;

*/
exports.firestoreUnsubscribeAction = ({ type, actionName }) => {
exports.firestoreUnsubscribeAction = ({ type, actionName, }) => {
const defaultActionName = type === 'document'

@@ -39,5 +40,5 @@ ? action_1.actionTypes.document.UNSUBSCRIBE

helpers_1.unsubscribeFirestore({ state, type });
}
},
};
return tree;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FIREX_DOCUMENT_UNSUBSCRIBER = exports.FIREX_COLLECTION_UNSUBSCRIBER = void 0;
exports.FIREX_COLLECTION_UNSUBSCRIBER = '[firex-store] Firex Collection Unsubscriber';
exports.FIREX_DOCUMENT_UNSUBSCRIBER = '[firex-store] Firex Document Unsubscriber';

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

}
export declare const callMutation: ({ mutationType, changeType, commit, payload }: Criteria) => void;
export declare const callMutation: ({ mutationType, changeType, commit, payload, }: Criteria) => void;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.callMutation = void 0;
const mutation_1 = require("../types/mutation");
exports.callMutation = ({ mutationType, changeType, commit, payload }) => {
exports.callMutation = ({ mutationType, changeType, commit, payload, }) => {
const types = mutationType === 'document'

@@ -6,0 +7,0 @@ ? mutation_1.mutationTypes.document

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./subscribe"));
__export(require("./unsubscribe"));
__export(require("./is-document-ref"));
__exportStar(require("./subscribe"), exports);
__exportStar(require("./unsubscribe"), exports);
__exportStar(require("./is-document-ref"), exports);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isDocumentRef = void 0;
const firebase = require("firebase");
exports.isDocumentRef = (ref) => ref instanceof firebase.firestore.DocumentReference;

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

*/
export declare const subscribeFirestore: <T = any>({ state, commit, ref, options }: Criteria<FirestoreRef, T>) => void;
export declare const subscribeFirestore: <T = any>({ state, commit, ref, options, }: Criteria<FirestoreRef, T>) => void;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.subscribeFirestore = void 0;
const configurations_1 = require("../configurations");

@@ -7,3 +8,3 @@ const service_1 = require("../../service");

const call_mutation_1 = require("./call-mutation");
const subscribeFirestoreCollection = ({ state, commit, ref, options }) => {
const subscribeFirestoreCollection = ({ state, commit, ref, options, }) => {
if (state[configurations_1.FIREX_COLLECTION_UNSUBSCRIBER]) {

@@ -16,7 +17,7 @@ return;

callMutation: mutation,
...options
...options,
});
state[configurations_1.FIREX_COLLECTION_UNSUBSCRIBER] = unsubscriber;
};
const subscribeFirestoreDocument = ({ state, commit, ref, options }) => {
const subscribeFirestoreDocument = ({ state, commit, ref, options, }) => {
if (state[configurations_1.FIREX_DOCUMENT_UNSUBSCRIBER]) {

@@ -29,3 +30,3 @@ return;

callMutation: mutation,
...options
...options,
});

@@ -47,3 +48,3 @@ state[configurations_1.FIREX_DOCUMENT_UNSUBSCRIBER] = unsubscriber;

*/
exports.subscribeFirestore = ({ state, commit, ref, options }) => {
exports.subscribeFirestore = ({ state, commit, ref, options, }) => {
is_document_ref_1.isDocumentRef(ref)

@@ -54,3 +55,3 @@ ? subscribeFirestoreDocument({

ref,
options
options,
})

@@ -61,4 +62,4 @@ : subscribeFirestoreCollection({

ref,
options
options,
});
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unsubscribeFirestore = void 0;
const configurations_1 = require("../configurations");

@@ -4,0 +5,0 @@ /**

export { firestoreMutations } from './mutations';
export { firestoreSubscribeAction, firestoreSubscribeActions, firestoreUnsubscribeAction, firestoreUnsubscribeActions } from './actions';
export { firestoreSubscribeAction, firestoreSubscribeActions, firestoreUnsubscribeAction, firestoreUnsubscribeActions, } from './actions';
export { subscribeFirestore, unsubscribeFirestore } from './helpers';
export { actionTypes } from './types/action';
export { mutationTypes } from './types/mutation';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var mutations_1 = require("./mutations");
exports.firestoreMutations = mutations_1.firestoreMutations;
Object.defineProperty(exports, "firestoreMutations", { enumerable: true, get: function () { return mutations_1.firestoreMutations; } });
var actions_1 = require("./actions");
exports.firestoreSubscribeAction = actions_1.firestoreSubscribeAction;
exports.firestoreSubscribeActions = actions_1.firestoreSubscribeActions;
exports.firestoreUnsubscribeAction = actions_1.firestoreUnsubscribeAction;
exports.firestoreUnsubscribeActions = actions_1.firestoreUnsubscribeActions;
Object.defineProperty(exports, "firestoreSubscribeAction", { enumerable: true, get: function () { return actions_1.firestoreSubscribeAction; } });
Object.defineProperty(exports, "firestoreSubscribeActions", { enumerable: true, get: function () { return actions_1.firestoreSubscribeActions; } });
Object.defineProperty(exports, "firestoreUnsubscribeAction", { enumerable: true, get: function () { return actions_1.firestoreUnsubscribeAction; } });
Object.defineProperty(exports, "firestoreUnsubscribeActions", { enumerable: true, get: function () { return actions_1.firestoreUnsubscribeActions; } });
var helpers_1 = require("./helpers");
exports.subscribeFirestore = helpers_1.subscribeFirestore;
exports.unsubscribeFirestore = helpers_1.unsubscribeFirestore;
Object.defineProperty(exports, "subscribeFirestore", { enumerable: true, get: function () { return helpers_1.subscribeFirestore; } });
Object.defineProperty(exports, "unsubscribeFirestore", { enumerable: true, get: function () { return helpers_1.unsubscribeFirestore; } });
var action_1 = require("./types/action");
exports.actionTypes = action_1.actionTypes;
Object.defineProperty(exports, "actionTypes", { enumerable: true, get: function () { return action_1.actionTypes; } });
var mutation_1 = require("./types/mutation");
exports.mutationTypes = mutation_1.mutationTypes;
Object.defineProperty(exports, "mutationTypes", { enumerable: true, get: function () { return mutation_1.mutationTypes; } });

@@ -7,3 +7,3 @@ import { MutationTree } from 'vuex';

}
export declare const firestoreMutations: ({ statePropName, type }: Criteria) => MutationTree<any>;
export declare const firestoreMutations: ({ statePropName, type, }: Criteria) => MutationTree<any>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.firestoreMutations = void 0;
const mutation_1 = require("../types/mutation");

@@ -15,3 +16,3 @@ const documentMutations = (prop) => {

state[prop] = null;
}
},
};

@@ -44,6 +45,6 @@ };

state[prop].splice(index, 1);
}
},
};
};
exports.firestoreMutations = ({ statePropName, type }) => {
exports.firestoreMutations = ({ statePropName, type, }) => {
return type === 'document'

@@ -50,0 +51,0 @@ ? documentMutations(statePropName)

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.actionTypes = void 0;
exports.actionTypes = {
collection: {
SUBSCRIBE: '[firex-store] Collection Subscribe',
UNSUBSCRIBE: '[firex-store] Collection Unsubscribe'
UNSUBSCRIBE: '[firex-store] Collection Unsubscribe',
},
document: {
SUBSCRIBE: '[firex-store] Document Subscribe',
UNSUBSCRIBE: '[firex-store] Document Unsubscribe'
UNSUBSCRIBE: '[firex-store] Document Unsubscribe',
},

@@ -28,3 +29,3 @@ // --- deprecated, follow variables will be removed ^2.0.0 ---

*/
COLLECTION_UNSUBSCRIBE: '[firex-store] Collection Unsubscribe'
COLLECTION_UNSUBSCRIBE: '[firex-store] Collection Unsubscribe',
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mutationTypes = void 0;
const documentTypes = {
ADD: '[firex-store] Add',
MODIFY: '[firex-store] Modify',
REMOVE: '[firex-store] Remove'
REMOVE: '[firex-store] Remove',
};

@@ -11,7 +12,7 @@ const collectionTypes = {

MODIFY: '[firex-store] Modify Array',
REMOVE: '[firex-store] Remove Array'
REMOVE: '[firex-store] Remove Array',
};
exports.mutationTypes = {
document: documentTypes,
collection: collectionTypes
collection: collectionTypes,
};
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./error-handler.type"), exports);
__exportStar(require("./call-mutation.type"), exports);
__exportStar(require("./mapper.type"), exports);
__exportStar(require("./mutation-type.type"), exports);
__exportStar(require("./completion-handler.type"), exports);
__exportStar(require("./firestore-ref.type"), exports);
__exportStar(require("./null-or.type"), exports);
__exportStar(require("./after-mutation-called.type"), exports);
__exportStar(require("./not-found-handler.type"), exports);
__exportStar(require("./on-completed.type"), exports);
{
"name": "firex-store",
"version": "1.5.2",
"version": "1.6.0",
"description": "Subscribe and write firestore data, easily",

@@ -37,22 +37,23 @@ "main": "./lib/index.js",

"@babel/plugin-syntax-object-rest-spread": "^7.8.3",
"@babel/plugin-transform-modules-commonjs": "^7.8.3",
"@babel/preset-typescript": "^7.8.3",
"@types/jest": "^25.1.4",
"@typescript-eslint/eslint-plugin": "^2.23.0",
"@typescript-eslint/parser": "^2.23.0",
"@vue/test-utils": "^1.0.0-beta.32",
"@babel/plugin-transform-modules-commonjs": "^7.9.6",
"@babel/preset-typescript": "^7.9.0",
"@types/jest": "^25.2.2",
"@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^2.33.0",
"@vue/test-utils": "^1.0.2",
"babel-jest": "^26.0.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.7.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-prettier": "^3.1.2",
"firebase": "^7.11.0",
"eslint": "^7.0.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.3",
"firebase": "^7.14.4",
"flush-promises": "^1.0.2",
"jest": "^25.1.0",
"prettier": "^1.19.1",
"ts-jest": "^25.2.1",
"typescript": "^3.8.3",
"jest": "^26.0.1",
"prettier": "^2.0.5",
"ts-jest": "^26.0.0",
"typescript": "^3.9.2",
"vue": "^2.6.11",
"vue-template-compiler": "^2.6.11",
"vuex": "^3.1.3"
"vuex": "^3.4.0"
},

@@ -62,3 +63,6 @@ "files": [

"docs/**/*"
]
],
"dependencies": {
"stream-executor": "^1.3.1"
}
}
# firex-store
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
[![CircleCI](https://circleci.com/gh/nor-ko-hi-jp/firex-store.svg?style=svg)](https://circleci.com/gh/nor-ko-hi-jp/firex-store)
![Main](https://github.com/nor-ko-hi-jp/firex-store/workflows/Main/badge.svg?branch=develop)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/nor-ko-hi-jp/firex-store/issues)

@@ -30,3 +30,3 @@

```js
import { to, from, on, firestoreMutations } from 'firex-store'
import { to, from, on, firestoreMutations, bindTo, map } from 'firex-store'
import { Model } from '~/model'

@@ -38,3 +38,4 @@ import { firestore } from '~/plugins/firebase'

state: {
comments: []
comments: [],
isLoaded: false
},

@@ -44,4 +45,19 @@ mutations: {

// ...firestoreMutations('all')
setIsLoaded: (state, isLast) => {
state.isLoaded = isLast
}
},
actions: {
streamSubscribe: ({ state, commit }) => {
const toComment = (data) => new Comment(...data)
const ref = firestore.collection('comments')
// write code like Rxjs
from(ref)
.pipe(
map(toComment), // option
bindTo('comments'), // required
(({ isLast }) => commit('setIsLoaded', isLast)) //option
)
.subscribe(state, commit)
},
subscribe: ({ state, commit }) => {

@@ -112,4 +128,2 @@ const ref = firestore.collection('comments')

others comming soon
## Important

@@ -119,3 +133,3 @@

- A store module cannot subscribe to more than one 'collection' and 'document'
- A state in store cannot subscribe to more than one 'collection' and 'document'

@@ -122,0 +136,0 @@ - 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.

Sorry, the diff of this file is not supported yet

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