abstracted-database
Advanced tools
Comparing version 0.4.0 to 0.5.1
@@ -0,6 +1,6 @@ | ||
import { DocumentChangeType as IFirestoreDbEvent, FirebaseFirestore } from '@firebase/firestore-types'; | ||
import { EventType as IRealTimeDbEvent, FirebaseDatabase } from '@firebase/database-types'; | ||
import { FirebaseApp } from '@firebase/app-types'; | ||
import { FirebaseAuth } from '@firebase/auth-types'; | ||
import { ISerializedQuery } from '@forest-fire/types'; | ||
import type { DocumentChangeType as IFirestoreDbEvent } from '@firebase/firestore-types'; | ||
import type { EventType as IRealTimeDbEvent, FirebaseDatabase } from "@firebase/database-types"; | ||
import type { FirebaseApp } from '@firebase/app-types'; | ||
import type { FirebaseFirestore } from '@firebase/firestore-types'; | ||
import type { Mock as MockDb } from 'firemock'; | ||
@@ -35,10 +35,2 @@ declare type IConfig = Record<string, any>; | ||
/** | ||
* Returns the `_database`. | ||
*/ | ||
protected get database(): FirebaseFirestore | FirebaseDatabase | undefined; | ||
/** | ||
* Sets the `_database`. | ||
*/ | ||
protected set database(value: FirebaseFirestore | FirebaseDatabase | undefined); | ||
/** | ||
* Initializes the Firebase app. | ||
@@ -54,3 +46,3 @@ */ | ||
*/ | ||
auth(): Promise<import("@firebase/auth-types").FirebaseAuth>; | ||
abstract auth(): Promise<FirebaseAuth>; | ||
/** | ||
@@ -73,3 +65,3 @@ * Indicates if the database is using the admin SDK. | ||
*/ | ||
abstract getList<T = any>(path: string | ISerializedQuery, idProp?: string): Promise<T[]>; | ||
abstract getList<T = any>(path: string | ISerializedQuery, idProp: string): Promise<T[]>; | ||
/** | ||
@@ -82,8 +74,8 @@ * Get's a push-key from the server at a given path. This ensures that | ||
*/ | ||
abstract getPushKey(path: string): Promise<string>; | ||
abstract getPushKey(path: string): Promise<string | void>; | ||
/** | ||
* Gets a snapshot from a given path in the Firebase DB and converts it to an | ||
* object where the snapshot's key is included as part of the record. | ||
* Gets a record from a given path in the Firebase DB and converts it to an | ||
* object where the record's key is included as part of the record. | ||
*/ | ||
abstract getRecord<T = any>(path: string, idProp?: string): Promise<T>; | ||
abstract getRecord<T = any>(path: string, idProp: string): Promise<T>; | ||
/** | ||
@@ -94,5 +86,9 @@ * Returns the value at a given path in the database. This method is a | ||
*/ | ||
abstract getValue<T = any>(path: string): Promise<T>; | ||
abstract getValue<T = any>(path: string): Promise<T | void>; | ||
/** | ||
* Update the database at a given path. Note that this operation is | ||
* Add a value in the database at a given path. | ||
*/ | ||
abstract add<T = any>(path: string, value: T): Promise<void>; | ||
/** | ||
* Updates the database at a given path. Note that this operation is | ||
* **non-destructive**, so assuming that the value you are passing in a | ||
@@ -109,8 +105,5 @@ * POJO/object then the properties sent in will be updated but if properties | ||
/** | ||
* Removes a path from the database. By default if you attempt to remove a | ||
* path in the database which _didn't_ exist it will throw a `database/remove` | ||
* error. If you'd prefer for this error to be ignored than you can pass in | ||
* **true** to the `ignoreMissing` parameter. | ||
* Removes a path from the database. | ||
*/ | ||
abstract remove<T = any>(path: string, ignoreMissing?: boolean): Promise<T>; | ||
abstract remove(path: string): Promise<void>; | ||
/** | ||
@@ -123,3 +116,3 @@ * Watch for Firebase events based on a DB path. | ||
*/ | ||
abstract unWatch(events: IFirestoreDbEvent[] | IRealTimeDbEvent[], cb?: any): void; | ||
abstract unWatch(events?: IFirestoreDbEvent[] | IRealTimeDbEvent[], cb?: any): void; | ||
/** | ||
@@ -126,0 +119,0 @@ * Returns a reference for a given path in Firebase |
@@ -38,9 +38,2 @@ "use strict"; | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -88,36 +81,2 @@ var AbstractedDatabase = /** @class */ (function () { | ||
}); | ||
Object.defineProperty(AbstractedDatabase.prototype, "database", { | ||
/** | ||
* Returns the `_database`. | ||
*/ | ||
get: function () { | ||
return this._database; | ||
}, | ||
/** | ||
* Sets the `_database`. | ||
*/ | ||
set: function (value) { | ||
this._database = value; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
* Returns the authentication API of the database. | ||
*/ | ||
AbstractedDatabase.prototype.auth = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('@firebase/auth')); })]; | ||
case 1: | ||
_a.sent(); | ||
if (this.app.auth) { | ||
return [2 /*return*/, this.app.auth()]; | ||
} | ||
throw new Error('Attempt to use auth module without having installed Firebase auth dependency'); | ||
} | ||
}); | ||
}); | ||
}; | ||
Object.defineProperty(AbstractedDatabase.prototype, "isAdminApi", { | ||
@@ -124,0 +83,0 @@ /** |
@@ -0,6 +1,6 @@ | ||
import { DocumentChangeType as IFirestoreDbEvent, FirebaseFirestore } from '@firebase/firestore-types'; | ||
import { EventType as IRealTimeDbEvent, FirebaseDatabase } from '@firebase/database-types'; | ||
import { FirebaseApp } from '@firebase/app-types'; | ||
import { FirebaseAuth } from '@firebase/auth-types'; | ||
import { ISerializedQuery } from '@forest-fire/types'; | ||
import type { DocumentChangeType as IFirestoreDbEvent } from '@firebase/firestore-types'; | ||
import type { EventType as IRealTimeDbEvent, FirebaseDatabase } from "@firebase/database-types"; | ||
import type { FirebaseApp } from '@firebase/app-types'; | ||
import type { FirebaseFirestore } from '@firebase/firestore-types'; | ||
import type { Mock as MockDb } from 'firemock'; | ||
@@ -35,10 +35,2 @@ declare type IConfig = Record<string, any>; | ||
/** | ||
* Returns the `_database`. | ||
*/ | ||
protected get database(): FirebaseFirestore | FirebaseDatabase | undefined; | ||
/** | ||
* Sets the `_database`. | ||
*/ | ||
protected set database(value: FirebaseFirestore | FirebaseDatabase | undefined); | ||
/** | ||
* Initializes the Firebase app. | ||
@@ -54,3 +46,3 @@ */ | ||
*/ | ||
auth(): Promise<import("@firebase/auth-types").FirebaseAuth>; | ||
abstract auth(): Promise<FirebaseAuth>; | ||
/** | ||
@@ -73,3 +65,3 @@ * Indicates if the database is using the admin SDK. | ||
*/ | ||
abstract getList<T = any>(path: string | ISerializedQuery, idProp?: string): Promise<T[]>; | ||
abstract getList<T = any>(path: string | ISerializedQuery, idProp: string): Promise<T[]>; | ||
/** | ||
@@ -82,8 +74,8 @@ * Get's a push-key from the server at a given path. This ensures that | ||
*/ | ||
abstract getPushKey(path: string): Promise<string>; | ||
abstract getPushKey(path: string): Promise<string | void>; | ||
/** | ||
* Gets a snapshot from a given path in the Firebase DB and converts it to an | ||
* object where the snapshot's key is included as part of the record. | ||
* Gets a record from a given path in the Firebase DB and converts it to an | ||
* object where the record's key is included as part of the record. | ||
*/ | ||
abstract getRecord<T = any>(path: string, idProp?: string): Promise<T>; | ||
abstract getRecord<T = any>(path: string, idProp: string): Promise<T>; | ||
/** | ||
@@ -94,5 +86,9 @@ * Returns the value at a given path in the database. This method is a | ||
*/ | ||
abstract getValue<T = any>(path: string): Promise<T>; | ||
abstract getValue<T = any>(path: string): Promise<T | void>; | ||
/** | ||
* Update the database at a given path. Note that this operation is | ||
* Add a value in the database at a given path. | ||
*/ | ||
abstract add<T = any>(path: string, value: T): Promise<void>; | ||
/** | ||
* Updates the database at a given path. Note that this operation is | ||
* **non-destructive**, so assuming that the value you are passing in a | ||
@@ -109,8 +105,5 @@ * POJO/object then the properties sent in will be updated but if properties | ||
/** | ||
* Removes a path from the database. By default if you attempt to remove a | ||
* path in the database which _didn't_ exist it will throw a `database/remove` | ||
* error. If you'd prefer for this error to be ignored than you can pass in | ||
* **true** to the `ignoreMissing` parameter. | ||
* Removes a path from the database. | ||
*/ | ||
abstract remove<T = any>(path: string, ignoreMissing?: boolean): Promise<T>; | ||
abstract remove(path: string): Promise<void>; | ||
/** | ||
@@ -123,3 +116,3 @@ * Watch for Firebase events based on a DB path. | ||
*/ | ||
abstract unWatch(events: IFirestoreDbEvent[] | IRealTimeDbEvent[], cb?: any): void; | ||
abstract unWatch(events?: IFirestoreDbEvent[] | IRealTimeDbEvent[], cb?: any): void; | ||
/** | ||
@@ -126,0 +119,0 @@ * Returns a reference for a given path in Firebase |
@@ -78,36 +78,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}); | ||
Object.defineProperty(AbstractedDatabase.prototype, "database", { | ||
/** | ||
* Returns the `_database`. | ||
*/ | ||
get: function () { | ||
return this._database; | ||
}, | ||
/** | ||
* Sets the `_database`. | ||
*/ | ||
set: function (value) { | ||
this._database = value; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
* Returns the authentication API of the database. | ||
*/ | ||
AbstractedDatabase.prototype.auth = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, import('@firebase/auth')]; | ||
case 1: | ||
_a.sent(); | ||
if (this.app.auth) { | ||
return [2 /*return*/, this.app.auth()]; | ||
} | ||
throw new Error('Attempt to use auth module without having installed Firebase auth dependency'); | ||
} | ||
}); | ||
}); | ||
}; | ||
Object.defineProperty(AbstractedDatabase.prototype, "isAdminApi", { | ||
@@ -114,0 +80,0 @@ /** |
{ | ||
"name": "abstracted-database", | ||
"version": "0.4.0", | ||
"version": "0.5.1", | ||
"description": "", | ||
@@ -20,2 +20,3 @@ "main": "dist/commonjs", | ||
"@firebase/app-types": "^0.6.0", | ||
"@firebase/auth-types": "^0.10.0", | ||
"@firebase/database-types": "^0.4.14", | ||
@@ -25,3 +26,2 @@ "@firebase/firestore-types": "^1.10.1" | ||
"dependencies": { | ||
"@firebase/auth": "^0.14.1", | ||
"firemock": "^0.37.5" | ||
@@ -28,0 +28,0 @@ }, |
@@ -0,7 +1,13 @@ | ||
import { | ||
DocumentChangeType as IFirestoreDbEvent, | ||
FirebaseFirestore | ||
} from '@firebase/firestore-types'; | ||
import { | ||
EventType as IRealTimeDbEvent, | ||
FirebaseDatabase | ||
} from '@firebase/database-types'; | ||
import { FirebaseApp } from '@firebase/app-types'; | ||
import { FirebaseAuth } from '@firebase/auth-types'; | ||
import { ISerializedQuery } from '@forest-fire/types'; | ||
import type { DocumentChangeType as IFirestoreDbEvent } from '@firebase/firestore-types' | ||
import type { EventType as IRealTimeDbEvent, FirebaseDatabase } from "@firebase/database-types"; | ||
import type { FirebaseApp } from '@firebase/app-types'; | ||
import type { FirebaseFirestore } from '@firebase/firestore-types'; | ||
import type { Mock as MockDb } from 'firemock' | ||
import type { Mock as MockDb } from 'firemock'; | ||
@@ -54,14 +60,2 @@ type IConfig = Record<string, any>; | ||
/** | ||
* Returns the `_database`. | ||
*/ | ||
protected get database() { | ||
return this._database; | ||
} | ||
/** | ||
* Sets the `_database`. | ||
*/ | ||
protected set database(value) { | ||
this._database = value; | ||
} | ||
/** | ||
* Initializes the Firebase app. | ||
@@ -77,11 +71,3 @@ */ | ||
*/ | ||
public async auth() { | ||
await import('@firebase/auth') | ||
if (this.app.auth) { | ||
return this.app.auth(); | ||
} | ||
throw new Error( | ||
'Attempt to use auth module without having installed Firebase auth dependency' | ||
); | ||
} | ||
public abstract async auth(): Promise<FirebaseAuth>; | ||
/** | ||
@@ -110,3 +96,3 @@ * Indicates if the database is using the admin SDK. | ||
path: string | ISerializedQuery, | ||
idProp?: string | ||
idProp: string | ||
): Promise<T[]>; | ||
@@ -120,10 +106,10 @@ /** | ||
*/ | ||
public abstract async getPushKey(path: string): Promise<string>; | ||
public abstract async getPushKey(path: string): Promise<string | void>; | ||
/** | ||
* Gets a snapshot from a given path in the Firebase DB and converts it to an | ||
* object where the snapshot's key is included as part of the record. | ||
* Gets a record from a given path in the Firebase DB and converts it to an | ||
* object where the record's key is included as part of the record. | ||
*/ | ||
public abstract async getRecord<T = any>( | ||
path: string, | ||
idProp?: string | ||
idProp: string | ||
): Promise<T>; | ||
@@ -135,5 +121,9 @@ /** | ||
*/ | ||
public abstract async getValue<T = any>(path: string): Promise<T>; | ||
public abstract async getValue<T = any>(path: string): Promise<T | void>; | ||
/** | ||
* Update the database at a given path. Note that this operation is | ||
* Add a value in the database at a given path. | ||
*/ | ||
public abstract async add<T = any>(path: string, value: T): Promise<void>; | ||
/** | ||
* Updates the database at a given path. Note that this operation is | ||
* **non-destructive**, so assuming that the value you are passing in a | ||
@@ -153,11 +143,5 @@ * POJO/object then the properties sent in will be updated but if properties | ||
/** | ||
* Removes a path from the database. By default if you attempt to remove a | ||
* path in the database which _didn't_ exist it will throw a `database/remove` | ||
* error. If you'd prefer for this error to be ignored than you can pass in | ||
* **true** to the `ignoreMissing` parameter. | ||
* Removes a path from the database. | ||
*/ | ||
public abstract async remove<T = any>( | ||
path: string, | ||
ignoreMissing?: boolean | ||
): Promise<T>; | ||
public abstract async remove(path: string): Promise<void>; | ||
/** | ||
@@ -174,3 +158,6 @@ * Watch for Firebase events based on a DB path. | ||
*/ | ||
public abstract unWatch(events: IFirestoreDbEvent[] | IRealTimeDbEvent[], cb?: any): void; | ||
public abstract unWatch( | ||
events?: IFirestoreDbEvent[] | IRealTimeDbEvent[], | ||
cb?: any | ||
): void; | ||
/** | ||
@@ -177,0 +164,0 @@ * Returns a reference for a given path in Firebase |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
54005
4
633
+ Added@firebase/auth-types@0.10.3(transitive)
- Removed@firebase/auth@^0.14.1
- Removed@firebase/app@0.10.17(transitive)
- Removed@firebase/app-types@0.9.3(transitive)
- Removed@firebase/auth@0.14.9(transitive)
- Removed@firebase/auth-types@0.10.1(transitive)
- Removed@firebase/component@0.6.11(transitive)
- Removed@firebase/logger@0.4.4(transitive)
- Removed@firebase/util@0.4.11.10.2(transitive)
- Removedidb@7.1.1(transitive)