abstracted-firebase
Advanced tools
Comparing version 0.16.4 to 0.16.5
import { SerializedQuery } from "serialized-query"; | ||
import { FirebaseDatabase, DataSnapshot, EventType } from "@firebase/database-types"; | ||
import { IEmitter, IFirebaseWatchHandler, IPathSetter, IMockLoadingState, IFirebaseConfig } from "./types"; | ||
import { IFirebaseConfig, IEmitter, IMockLoadingState, IFirebaseWatchHandler, IPathSetter } from "./types"; | ||
declare type Mock = import("firemock").Mock; | ||
declare type IMockAuthConfig = import("firemock").IMockAuthConfig; | ||
/** time by which the dynamically loaded mock library should be loaded */ | ||
@@ -75,3 +76,3 @@ export declare const MOCK_LOADING_TIMEOUT = 2000; | ||
callback(cb: (err: any, pathSetters: IPathSetter<any>[]) => void): void; | ||
execute(): Promise<any>; | ||
execute(): Promise<{}>; | ||
}; | ||
@@ -119,4 +120,4 @@ /** update, non-destructively, at a given path in the database */ | ||
protected abstract listenForConnectionStatus(): void; | ||
protected getFireMock(): Promise<void>; | ||
protected getFireMock(config?: IMockAuthConfig): Promise<void>; | ||
} | ||
export {}; |
@@ -28,3 +28,2 @@ "use strict"; | ||
this._mocking = true; | ||
this.getFireMock(); | ||
} | ||
@@ -258,21 +257,23 @@ else { | ||
async execute() { | ||
const updateHash = {}; | ||
const fullyQualifiedPaths = mps.map(i => (Object.assign({}, i, { path: [api._basePath, i.path].join("/").replace(/[\/]{2,3}/g, "/") }))); | ||
fullyQualifiedPaths.map(item => { | ||
updateHash[item.path] = item.value; | ||
return new Promise((resolve, reject) => { | ||
const updateHash = {}; | ||
const fullyQualifiedPaths = mps.map(i => (Object.assign({}, i, { path: [api._basePath, i.path].join("/").replace(/[\/]{2,3}/g, "/") }))); | ||
fullyQualifiedPaths.map(item => { | ||
updateHash[item.path] = item.value; | ||
}); | ||
return ref() | ||
.update(updateHash) | ||
.then(() => { | ||
if (callback) { | ||
callback(null, mps); | ||
resolve(); | ||
} | ||
}) | ||
.catch((e) => { | ||
if (callback) { | ||
callback(e, mps); | ||
} | ||
reject(e); | ||
}); | ||
}); | ||
return ref() | ||
.update(updateHash) | ||
.then(() => { | ||
if (callback) { | ||
callback(null, mps); | ||
return; | ||
} | ||
}) | ||
.catch((e) => { | ||
if (callback) { | ||
callback(e, mps); | ||
} | ||
throw e; | ||
}); | ||
} | ||
@@ -414,3 +415,3 @@ }; | ||
} | ||
async getFireMock() { | ||
async getFireMock(config = {}) { | ||
try { | ||
@@ -421,3 +422,3 @@ this._mockLoadingState = "loading"; | ||
this._mockLoadingState = "loaded"; | ||
this._mock = new FireMock.Mock(); | ||
this._mock = new FireMock.Mock({}, config); | ||
this._isConnected = true; | ||
@@ -424,0 +425,0 @@ this._mocking = true; |
import { SerializedQuery } from "serialized-query"; | ||
import { FirebaseDatabase, DataSnapshot, EventType } from "@firebase/database-types"; | ||
import { IEmitter, IFirebaseWatchHandler, IPathSetter, IMockLoadingState, IFirebaseConfig } from "./types"; | ||
import { IFirebaseConfig, IEmitter, IMockLoadingState, IFirebaseWatchHandler, IPathSetter } from "./types"; | ||
declare type Mock = import("firemock").Mock; | ||
declare type IMockAuthConfig = import("firemock").IMockAuthConfig; | ||
/** time by which the dynamically loaded mock library should be loaded */ | ||
@@ -75,3 +76,3 @@ export declare const MOCK_LOADING_TIMEOUT = 2000; | ||
callback(cb: (err: any, pathSetters: IPathSetter<any>[]) => void): void; | ||
execute(): Promise<any>; | ||
execute(): Promise<{}>; | ||
}; | ||
@@ -119,4 +120,4 @@ /** update, non-destructively, at a given path in the database */ | ||
protected abstract listenForConnectionStatus(): void; | ||
protected getFireMock(): Promise<void>; | ||
protected getFireMock(config?: IMockAuthConfig): Promise<void>; | ||
} | ||
export {}; |
@@ -26,3 +26,2 @@ // tslint:disable:no-implicit-dependencies | ||
this._mocking = true; | ||
this.getFireMock(); | ||
} | ||
@@ -256,21 +255,23 @@ else { | ||
async execute() { | ||
const updateHash = {}; | ||
const fullyQualifiedPaths = mps.map(i => (Object.assign({}, i, { path: [api._basePath, i.path].join("/").replace(/[\/]{2,3}/g, "/") }))); | ||
fullyQualifiedPaths.map(item => { | ||
updateHash[item.path] = item.value; | ||
return new Promise((resolve, reject) => { | ||
const updateHash = {}; | ||
const fullyQualifiedPaths = mps.map(i => (Object.assign({}, i, { path: [api._basePath, i.path].join("/").replace(/[\/]{2,3}/g, "/") }))); | ||
fullyQualifiedPaths.map(item => { | ||
updateHash[item.path] = item.value; | ||
}); | ||
return ref() | ||
.update(updateHash) | ||
.then(() => { | ||
if (callback) { | ||
callback(null, mps); | ||
resolve(); | ||
} | ||
}) | ||
.catch((e) => { | ||
if (callback) { | ||
callback(e, mps); | ||
} | ||
reject(e); | ||
}); | ||
}); | ||
return ref() | ||
.update(updateHash) | ||
.then(() => { | ||
if (callback) { | ||
callback(null, mps); | ||
return; | ||
} | ||
}) | ||
.catch((e) => { | ||
if (callback) { | ||
callback(e, mps); | ||
} | ||
throw e; | ||
}); | ||
} | ||
@@ -412,3 +413,3 @@ }; | ||
} | ||
async getFireMock() { | ||
async getFireMock(config = {}) { | ||
try { | ||
@@ -419,3 +420,3 @@ this._mockLoadingState = "loading"; | ||
this._mockLoadingState = "loaded"; | ||
this._mock = new FireMock.Mock(); | ||
this._mock = new FireMock.Mock({}, config); | ||
this._isConnected = true; | ||
@@ -422,0 +423,0 @@ this._mocking = true; |
import { SerializedQuery } from "serialized-query"; | ||
import { FirebaseDatabase, DataSnapshot, EventType } from "@firebase/database-types"; | ||
import { IEmitter, IFirebaseWatchHandler, IPathSetter, IMockLoadingState, IFirebaseConfig } from "./types"; | ||
import { IFirebaseConfig, IEmitter, IMockLoadingState, IFirebaseWatchHandler, IPathSetter } from "./types"; | ||
declare type Mock = import("firemock").Mock; | ||
declare type IMockAuthConfig = import("firemock").IMockAuthConfig; | ||
/** time by which the dynamically loaded mock library should be loaded */ | ||
@@ -75,3 +76,3 @@ export declare const MOCK_LOADING_TIMEOUT = 2000; | ||
callback(cb: (err: any, pathSetters: IPathSetter<any>[]) => void): void; | ||
execute(): Promise<any>; | ||
execute(): Promise<{}>; | ||
}; | ||
@@ -119,4 +120,4 @@ /** update, non-destructively, at a given path in the database */ | ||
protected abstract listenForConnectionStatus(): void; | ||
protected getFireMock(): Promise<void>; | ||
protected getFireMock(config?: IMockAuthConfig): Promise<void>; | ||
} | ||
export {}; |
@@ -38,3 +38,2 @@ (function (factory) { | ||
this._mocking = true; | ||
this.getFireMock(); | ||
} | ||
@@ -268,21 +267,23 @@ else { | ||
async execute() { | ||
const updateHash = {}; | ||
const fullyQualifiedPaths = mps.map(i => (Object.assign({}, i, { path: [api._basePath, i.path].join("/").replace(/[\/]{2,3}/g, "/") }))); | ||
fullyQualifiedPaths.map(item => { | ||
updateHash[item.path] = item.value; | ||
return new Promise((resolve, reject) => { | ||
const updateHash = {}; | ||
const fullyQualifiedPaths = mps.map(i => (Object.assign({}, i, { path: [api._basePath, i.path].join("/").replace(/[\/]{2,3}/g, "/") }))); | ||
fullyQualifiedPaths.map(item => { | ||
updateHash[item.path] = item.value; | ||
}); | ||
return ref() | ||
.update(updateHash) | ||
.then(() => { | ||
if (callback) { | ||
callback(null, mps); | ||
resolve(); | ||
} | ||
}) | ||
.catch((e) => { | ||
if (callback) { | ||
callback(e, mps); | ||
} | ||
reject(e); | ||
}); | ||
}); | ||
return ref() | ||
.update(updateHash) | ||
.then(() => { | ||
if (callback) { | ||
callback(null, mps); | ||
return; | ||
} | ||
}) | ||
.catch((e) => { | ||
if (callback) { | ||
callback(e, mps); | ||
} | ||
throw e; | ||
}); | ||
} | ||
@@ -424,3 +425,3 @@ }; | ||
} | ||
async getFireMock() { | ||
async getFireMock(config = {}) { | ||
try { | ||
@@ -431,3 +432,3 @@ this._mockLoadingState = "loading"; | ||
this._mockLoadingState = "loaded"; | ||
this._mock = new FireMock.Mock(); | ||
this._mock = new FireMock.Mock({}, config); | ||
this._isConnected = true; | ||
@@ -434,0 +435,0 @@ this._mocking = true; |
{ | ||
"name": "abstracted-firebase", | ||
"version": "0.16.4", | ||
"version": "0.16.5", | ||
"description": "Core functional library supporting 'abstracted-admin' and 'abstracted-client'", | ||
@@ -45,4 +45,4 @@ "license": "MIT", | ||
"@types/rimraf": "^2.0.1", | ||
"abstracted-admin": "^0.16.2", | ||
"abstracted-client": "^0.16.2", | ||
"abstracted-admin": "^0.16.3", | ||
"abstracted-client": "^0.16.4", | ||
"async-shelljs": "^0.1.2", | ||
@@ -52,5 +52,4 @@ "chai": "^4.2.0", | ||
"faker": "^4.1.0", | ||
"firebase": "^5.8.5", | ||
"firebase-admin": "^7.0.0", | ||
"firemock": "^0.19.1", | ||
"firemock": "^0.20.4", | ||
"js-yaml": "^3.12.0", | ||
@@ -61,3 +60,2 @@ "lodash": "^4.17.10", | ||
"rimraf": "^2.6.3", | ||
"rollup": "^1.2.3", | ||
"rollup-plugin-typescript2": "^0.19.3", | ||
@@ -64,0 +62,0 @@ "test-console": "^1.1.0", |
103531
26
2368