1.3.2 • Published 7 months ago

@leaddreamer/firebase-wrapper v1.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

view on
npm

@leaddreamer/firebase-wrapper

A set of helper-wrapper functions around firebase firestore, storage and auth. Intent is to treat Firestore as a hierarchical record-oriented database; originally conceived to port from one database to another.

Modules

Constants

FirebaseWrapper

A set of helper-wrapper functions around firebase firestore, storage and auth. all-in-one wrapper for a solid subset of CLIENT-SIDE Firebase functions, with a consistent interface. There is a parallel set for ADMIN-SIDE functions as well. Intent is to treat Firestore as a hierarchical record-oriented database; originally conceived to port from one database to another. NOTE: Most helpers return PROMISE.REJECT if no documents are returned. it is assumed projects using this library might want to have an explicitly error trap for such events.

FirebaseWrapper.FirebaseWrapper(config) ⇒

Kind: static method of FirebaseWrapper
Returns: none

ParamTypeDescription
configFirebaseConfigObjectFirebase Admin object

Example

//this specifically loads ALL the subsections, specifically for
//the Browser.  See later (tbd) notes for NodeJS

import FirebaseWrapper from "@leaddreamer/firebase-wrapper";
FirebaseWrapper(config); //see below
export * from "@leaddreamer/firebase-wrapper";

FirebaseWrapper~FirebaseConfigObject : Object

only authDomain, databaseURL and storageBucket are present when called from a cloud environment

Kind: inner typedef of FirebaseWrapper
Properties

NameTypeDescription
apiKeystringrequired api Key from Firebase Console,
appIdstringrequired app ID from Firebase Console
projectIdstringrequired Firebase projectID from Firebase console
authDomainstring(optional) auth domain from Firebase Console
databaseURLstring(optional) Firestore database URL from Firebase console
storageBucket:string(optional) URL of Firestore Storage Bucket
messagingSenderId:string(optional) ID for Messaing service from Firebase Console
measurementId:string(optional) Analytics/Measurement ID from Firebase Console
mapsAPIKeystring(optional) App ID for Google Maps API, from Google

FirebaseAuthWrapper/authAdmin

A set of helpers around Firebase admin SDK auth. Specific to use in Cloud Functions

FirebaseAuthWrapper/authAdmin.FirebaseAuthAdminWrapper(firebase)

Initializes the administrative Auth service of the provided firebase app. Also instantiates various constants and helper functions

Kind: static method of FirebaseAuthWrapper/authAdmin

ParamType
firebasefirebase

FirebaseAuthWrapper/authAdmin~getUser(userID) ⇒ Promise.<userData>

asynchronously fetches user data from Firestore Authentication

Kind: inner method of FirebaseAuthWrapper/authAdmin

ParamType
userIDstring

FirebaseAuthWrapper/authAdmin~DeleteUser(userID) ⇒ Promise

deletes a single user from the authentication system, identified by user ID

Kind: inner method of FirebaseAuthWrapper/authAdmin

ParamType
userIDstring

FirebaseAuthWrapper/authAdmin~setCustomClaims(uid, customClaim)

sets custom claims on user object overwrites other needed settings

Kind: inner method of FirebaseAuthWrapper/authAdmin

ParamTypeDescription
uidstringuser ID
customClaimObjectclaims object, less than 1000 Bytes. null clears

FirebaseAuthWrapper/authAdmin~addCustomClaims(uid, customClaim)

adds/merges to new claims to user customClaims

Kind: inner method of FirebaseAuthWrapper/authAdmin

ParamTypeDescription
uidstringuser ID
customClaimObjectclaims object to be merged with existing claims

FirebaseAuthWrapper/authAdmin~clearCustomClaims(uid)

removes all current customClaims on user (sets to null)

Kind: inner method of FirebaseAuthWrapper/authAdmin

ParamTypeDescription
uidstringuser ID

FirebaseAuthWrapper/authAdmin~PageUsers(pageSize, pageToken)

pages through the full list of users. Woefully inefficient.

Kind: inner method of FirebaseAuthWrapper/authAdmin

ParamTypeDescription
pageSizenumberdefault 1000
pageTokenobjectdefault null

FirebaseAuthWrapper/authClient

A set of helper-wrapper functions around firebase firestore, storage and auth. Intent is to treat Firestore as a hierarchical record-oriented database; originally conceived to port from one database to another.

Example

import * as firebase from "firebase/app";
import "firebase/auth";
import FirebaseAuth from "@leaddreamer/firebase-wrapper/FirebaseAuthWrapper";
//the next is optional - if you want the React component
import StyledFirebaseAuth from "react-firebaseui/StyledFirebaseAuth";
import {config} from "wherever-you-put-it";

((myconfig) {
try {
  firebase.app();
} catch (err) {
  firebase.initializeApp(myconfig);
}
FirebaseAuth(firebase, StyledFirebaseAuth);
})(config)

FirebaseAuthWrapper/authClient.FirebaseAuth : object

Kind: static property of FirebaseAuthWrapper/authClient

FirebaseAuthWrapper/authClient.FirebaseAuthSignInOptions : string

Kind: static property of FirebaseAuthWrapper/authClient

FirebaseAuthWrapper/authClient.FirebaseAuthClient(firebase)

Initializes the Auth service of the provided firebase app. Also instantiates various constants and helper functions

Kind: static method of FirebaseAuthWrapper/authClient

ParamType
firebasefirebase

FirebaseAuthWrapper/authClient.fetchToken(user) ⇒ external:promise

fetches our specific custom claim values from firebase auth

Kind: static method of FirebaseAuthWrapper/authClient
Fulfil: Returns a user token object
Reject: returns err

ParamType
userFirebaseAuthUser

FirebaseAuthWrapper/authClient.fetchJWT(user) ⇒ Promise.<JWT>

Fetch a JWT token for authenticated signed requests

Kind: static method of FirebaseAuthWrapper/authClient
Fulfil: Returnsa JWT token
Reject: returns an err

ParamType
userFirebaseAuthUser

FirebaseAuthWrapper/authClient.refreshAuthUser() ⇒ Promise.<void>

triggers an update of the Firebase Auth user object. A listener can be set to monitor these changes

Kind: static method of FirebaseAuthWrapper/authClient

FirebaseAuthWrapper/authClient.doCreateUserWithEmailAndPassword(email, password) ⇒ Promise.<UserCredential>

Creates AND SIGNS IN an authenticated user with the provided email and password Creates a new user account associated with the specified email address and password. On successful creation of the user account, this user will also be signed in to your application. User account creation can fail if the account already exists or the password is invalid. Note: The email address acts as a unique identifier for the user and enables an email-based password reset. This function will create a new user account and set the initial user password.

Kind: static method of FirebaseAuthWrapper/authClient

ParamType
emailstring
passwordstring

FirebaseAuthWrapper/authClient.doSignInWithEmailAndPassword(email, password) ⇒ Promise.<UserCredential>

SIGNS IN an existing authenticated user with the provided email and password Creates a new user account associated with the specified email address and password. On successful creation of the user account, this user will also be signed in to your application. User account creation can fail if the account already exists or the password is invalid. Note: The email address acts as a unique identifier for the user and enables an email-based password reset. This function will create a new user account and set the initial user password.

Kind: static method of FirebaseAuthWrapper/authClient

ParamType
emailstring
passwordstring

FirebaseAuthWrapper/authClient.doSignInWithGoogle()

Kind: static method of FirebaseAuthWrapper/authClient

FirebaseAuthWrapper/authClient.doSignInWithFacebook()

Kind: static method of FirebaseAuthWrapper/authClient

FirebaseAuthWrapper/authClient.doSignInWithTwitter()

Kind: static method of FirebaseAuthWrapper/authClient

FirebaseAuthWrapper/authClient.doSignOut()

Kind: static method of FirebaseAuthWrapper/authClient

FirebaseAuthWrapper/authClient.doPasswordReset()

Kind: static method of FirebaseAuthWrapper/authClient

FirebaseAuthWrapper/authClient.doSendEmailVerification()

Kind: static method of FirebaseAuthWrapper/authClient

FirebaseAuthWrapper/authClient.doPasswordUpdate()

Kind: static method of FirebaseAuthWrapper/authClient

FirebaseAuthWrapper/authClient.createAnonymousUser() ⇒ Promise.<UserCredential>

Kind: static method of FirebaseAuthWrapper/authClient

FirebaseAuthWrapper/authClient.attachAuthUserListener() ⇒ callback

Kind: static method of FirebaseAuthWrapper/authClient
Returns: callback - unsubscribe function
Properties

NameType
nextAuthChangeProcess

FirebaseAuthWrapper/authClient.setPersistence()

Kind: static method of FirebaseAuthWrapper/authClient

FirebaseAuthWrapper/authClient~fromJSON() : object

Kind: inner method of FirebaseAuthWrapper/authClient
Properties

NameType
providerIdstring
signInMethodstring

FirebaseAuthWrapper/authClient~AdditionalUserInfo : object

Kind: inner typedef of FirebaseAuthWrapper/authClient
Properties

NameType
isNewUserboolean
profileobject
providerIdstring
usernamestring

FirebaseAuthWrapper/authClient~User : object

See https://firebase.google.com/docs/reference/js/firebase.User

Kind: inner typedef of FirebaseAuthWrapper/authClient

FirebaseAuthWrapper/authClient~UserCredential : object

Kind: inner typedef of FirebaseAuthWrapper/authClient
Properties

NameType
additionalUserInfoAdditionalUserInfo
credentialAuthCredential
operationType"signin" | "link" | "reauthenticate"
user"User"

FirebaseAuthWrapper/authClient~AuthChangeProcess : function

Kind: inner typedef of FirebaseAuthWrapper/authClient

ParamType
userUser

FirebaseCloudFunctionsWrapper

A set of helper-wrapper functions around firebase firestore, storage and auth. Intent is to treat Firestore as a hierarchical record-oriented database; originally conceived to port from one database to another.

FirebaseCloudFunctionsWrapper.FirebaseCloudFunctions(firebase)

Initializes the FirebaseCLoud function support

Kind: static method of FirebaseCloudFunctionsWrapper

ParamType
firebasefirebase

Example

import * as firebase from "firebase/app";
import "firebase/functions";
import FirebaseFunctions from "@leaddreamer/firebase-wrapper/FirebaseCloudFunctionsWrapper";
import {config} from "whereever-you-put-it";

((myconfig) {
try {
  firebase.app();
} catch (err) {
  firebase.initializeApp(myconfig);
}
FirebaseFunctions(firebase);
})(config)

FirebaseCloudFunctionsWrapper.CloudFunctions() ⇒ external:promise

Kind: static method of FirebaseCloudFunctionsWrapper
Fulfil: result as returns from call
Reject: err as returned from call
Example

result = await CloudFunctions("MyGloriousFunction")(argumentToFunction);

FirebaseCloudFunctionsWrapper.treeFromParams(Params) ⇒ RecordTree

Kind: static method of FirebaseCloudFunctionsWrapper
Sync:

ParamType
Paramsobject

FirebaseFirestoreWrapper

A set of helper-wrapper functions around firebase firestore, storage and auth. Intent is to treat Firestore as a hierarchical record-oriented database; originally conceived to port from one database to another.

FirebaseFirestoreWrapper.MAX_CONCURRENCY : number

maximum concurrent writes

Kind: static constant of FirebaseFirestoreWrapper

FirebaseFirestoreWrapper.FirebaseFirestore(firebase)

Initializes the Firestore service of the provided firebase app. Also instantiates various constants and helper functions

Kind: static method of FirebaseFirestoreWrapper

ParamType
firebasefirebase

Example

import * as firebase from "firebase/app";
import "firebase/firestore";
import FirebaseFirestore from "@leaddreamer/firebase-wrapper/FirebaseFirestoreWrapper";
import {config} from "whereever-you-put-it";

((myconfig) {
try {
  firebase.app();
} catch (err) {
  firebase.initializeApp(myconfig);
}
FirebaseFirestore(firebase);
})(config)

FirebaseFirestoreWrapper.createUniqueReference(tablePath, refPath) ⇒ DocumentReference


Creates a DocumentReference document to the collection referenced in parameter tablePath (relative to optional refPath). This is can be useful for Transactions and Batches, which can only get(), set() or update() existing documents. Tricksie!

Kind: static method of FirebaseFirestoreWrapper
Returns: DocumentReference - Firestore Document Reference

ParamTypeDescription
tablePathstringstring representing a valid path to a collection to create the new document in, relative to a document reference passed in
refPathstringan optional valid document reference to start the table path

FirebaseFirestoreWrapper.writeRecord(tablePath, data, refPath, batch, mergeOption) ⇒ Promise.<Record>


Writes a Firestore record to collection indicated by tablePath relative to option DocumentReference refPath

Kind: static method of FirebaseFirestoreWrapper

ParamTypeDescription
tablePathstringstring representing a valid path to a collection to create or update the document in, relative to a document reference passed in
dataRecordData/Record object to write to database
refPathstringan optional valid document reference to start the table path
batchWriteBatch | Transactionoptional chain token to include this operation as part of an Atomic Transaction
mergeOptionbooleanwhether to merge into existing data; default TRUE

FirebaseFirestoreWrapper.writeRecordByRefPath(data, refPath, Transaction, mergeOption) ⇒ Promise.<Record>

Writes given data object (or map) to the given documentReference

Kind: static method of FirebaseFirestoreWrapper
Returns: Promise.<Record> - data record as written

ParamTypeDescription
dataRecordObject/Map to be written back to the Firestore
refPathstringDocumentReference to write document to
TransactionWriteBatch | TransactionOptional Transaction to enclose this action in
mergeOptionbooleanwhether to merge into existin data; default TRUE

FirebaseFirestoreWrapper.writeBack(data, Transaction, mergeOption) ⇒ Promise.<Record>


Writes a local-schema document back to the Firestore. Assume object/map came from the firestore

Kind: static method of FirebaseFirestoreWrapper
Returns: Promise.<Record> - record as written.

ParamTypeDescription
dataRecordObject/Map to be written back to the Firestore
data.refPathstringrequired to be present
TransactionWriteBatch | TransactionOptional Transaction to enclose this action in
mergeOptionbooleanwhether to merge into existin data; default TRUE

FirebaseFirestoreWrapper.collectRecords(tablePath, refPath) ⇒ Promise.<Array.<Record>>

query for a SET of records

Kind: static method of FirebaseFirestoreWrapper

ParamTypeDescription
tablePathstringstring representing path ro requested collection
refPathstringstring representing a path to the relative PARENT of the requested collection

FirebaseFirestoreWrapper.collectRecordsByFilter(tablePath, refPath, filterArray, sortArray, limit) ⇒ Promise.<Array.<Record>>


Kind: static method of FirebaseFirestoreWrapper
Descriptions: returns an array of documents from Firestore

ParamTypeDescription
tablePathstringa properly formatted string representing the requested collection - always an ODD number of elements
refPathstring(optional) allows "table" parameter to reference a sub-collection of an existing document reference (I use a LOT of structured collections)
filterArrayfilterObjectan array of filterObjects The array is assumed to be sorted in the correct order - i.e. filterArray0 is added first; filterArraylength-1 last returns data as an array of objects (not dissimilar to Redux State objects) with both the documentID and documentReference added as fields.
sortArraysortObjecta 2xn array of sort (i.e. "orderBy") conditions
limitnumberlimit result to this number (if at all)

FirebaseFirestoreWrapper.collectRecordsInGroup(tableName) ⇒ Promise.<Array.<Record>>

query for a SET of records from a COLLECTIONGROUP - all collections of a similar name, regardless of parents. It is up to the User to ensure these are at a similar level/structure - Firestore just matches the name

Kind: static method of FirebaseFirestoreWrapper

ParamTypeDescription
tableNamestringstring describing the NAME of the collection group desired

FirebaseFirestoreWrapper.collectRecordsInGroupByFilter(tableName, filterArray) ⇒ Promise.<Array.<Record>>

queries for Records from a CollectionGroup, filtered by the passed array of filterObjects

Kind: static method of FirebaseFirestoreWrapper

ParamTypeDescription
tableNamestringstring describing the Name of the collectiongroup
filterArrayfilterObjectarray of objects describing filter operations

FirebaseFirestoreWrapper.fetchRecord(tablePath, Id, refPath, batch) ⇒ Promise.<(Record|WriteBatch|Transaction)>

retrieve a record from the Firestore. If a Batch object is passed, returns a chained Btahc object

Kind: static method of FirebaseFirestoreWrapper

ParamTypeDescription
tablePathstringpath to the enclosing collection
IdstringId of the specific document requested
refPathstringoptional document reference to base tablePath from
batchWriteBatch | Transactionoptional batch reference

FirebaseFirestoreWrapper.fetchRecordByRefPath(docRefPath, batch) ⇒ Promise.<Record>

fetches a single record from the database, using just a refPath to identify the document

Kind: static method of FirebaseFirestoreWrapper

ParamTypeDescription
docRefPathstringstring identifying the full path to the requested document
batchWriteBatch | Transactionobject for collecting batched operations

FirebaseFirestoreWrapper.fetchRecordByFilter(table, filterArray, refPath, batch) ⇒ Promise.<(Record|WriteBatch|Transaction)>

fetches a SINGLE record from the database, using just a filter to identify the document. DANGEROUSLY assumes the filter identifies a SINGLE document, even if the query always returns an array

Kind: static method of FirebaseFirestoreWrapper

ParamTypeDescription
tablestringa properly formatted string representing the requested collection - always an ODD number of elements
filterArrayfilterObjectarray of objects describing filter operations
refPathstringoptional document reference to base tablePath from
batchWriteBatch | Transactionoptional batch reference

FirebaseFirestoreWrapper.fetchRecordInGroupByFilter(table, filterArray, batch) ⇒ Promise.<(Record|WriteBatch|Transaction)>

fetches a SINGLE record from the database, using just a filter to identify the document. DANGEROUSLY assumes the filter identifies a SINGLE document, even if the query always returns an array

Kind: static method of FirebaseFirestoreWrapper

ParamTypeDescription
tablestringa properly formatted string representing the requested collection - always an ODD number of elements
filterArrayfilterObjectarray of objects describing filter operations
batchWriteBatch | Transactionoptional batch reference

FirebaseFirestoreWrapper.deleteRecord(table, record, refPath, batch) ⇒ Promise.<(Record|WriteBatch|Transaction)>

deletes a single record from the database

Kind: static method of FirebaseFirestoreWrapper

ParamTypeDescription
tablestringstring naming the parent collection of the document
recordRecord
refPathstringoptional document reference to base tablePath from
batchWriteBatch | Transactionoptional batch reference

FirebaseFirestoreWrapper.deleteRecordByRefPath(docRefPath, batch) ⇒ Promise.<(Record|WriteBatch|Transaction)>

deletes a single record from the database

Kind: static method of FirebaseFirestoreWrapper

ParamTypeDescription
docRefPathstringstring identifying the full path to the requested document
batchWriteBatch | Transactionoptional batch reference

FirebaseFirestoreWrapper.updateRecordFields(recordUpdate) ⇒ Promise.<Record>

update record by fields - Allows use of FieldPath options such as .delete(). Only specifically referenced fields will be affected. Assumes the originating docRef is passed as refPath: field

Kind: static method of FirebaseFirestoreWrapper

ParamTypeDescription
recordUpdateRecordobject of field:value entries to update.
recordUpdate.refPathstringfull path to document/record

FirebaseFirestoreWrapper.updateRecordByRefPath(docRefPath, data, batch) ⇒ Promise.<(Record|WriteBatch|Transaction)>


Kind: static method of FirebaseFirestoreWrapper

ParamTypeDescription
docRefPathstringfull path to document to update
dataRecordRecord of values to update
data.Idstringdocument Id of record
batchWriteBatch | Transactionbatching object

FirebaseFirestoreWrapper.writeArrayValue(fieldName, fieldValue, docRefPath, batch) ⇒ Promise.<(Record|WriteBatch|Transaction)>

adds a new value to a firestore record array entry

Kind: static method of FirebaseFirestoreWrapper

ParamTypeDescription
fieldNamestringthe string name of the array to be updated
fieldValueanythe value to add to the array
docRefPathstringthe reference path for the document to be updated
batchWriteBatch | Transactionoptional - used to chain transactions

FirebaseFirestoreWrapper.localBatchReturn(incomingBatch, internalBatch) ⇒ WriteBatch | Transaction

Kind: static method of FirebaseFirestoreWrapper
Returns: WriteBatch | Transaction - WriteBatch, Transaction or Void

ParamTypeDescription
incomingBatchWriteBatch | Transactiona batching object passed into the subroutine Internal Transaction will be added to the incoming batch
internalBatchWriteBatch | Transactiona batching object as built in the routine, built on the incomingBatch if it exists

Example

export const suboperation = (data, batch = null) => {
 let myBatch = batch || openWriteBatch(); //note short circuit
 //stuff that happens in the routine
 writeRecord(table, data, parent, myBatch);
 writeRecord(otherTable, otherData, otherParent, myBatch);
 return localBatchReturn(batch, myBatch);
}

FirebaseFirestoreWrapper.runTransaction(updateFunction) ⇒ Promise.<object>


creates and runs a series of record operations (executed in the param function) as an atomic operation. A transation object is passed to the callback parameter

Kind: static method of FirebaseFirestoreWrapper
Returns: Promise.<object> - a promise with the result of updateFunction
Category: Batch

ParamTypeDescription
updateFunctioncallbackcallback function that expects a Transaction token as it's sole argument. either all the included/chained record operations will succeed, or none

FirebaseFirestoreWrapper.openWriteBatch() ⇒ WriteBatch


Creates a WriteBatch object tocollect actions for Batch writing to backend

Kind: static method of FirebaseFirestoreWrapper
Returns: WriteBatch - object that operations are added to for a bulk operation
Category: Batch

FirebaseFirestoreWrapper.closeWriteBatch(batch) ⇒ Promise.<void>


Dispatches an asynchronous Closure to submit Batch

Kind: static method of FirebaseFirestoreWrapper
Category: Batch

ParamTypeDescription
batchWriteBatchWriteBatch to close

FirebaseFirestoreWrapper.openBulkWriter() ⇒ BulkWriter


Creates a bulkWriter object to collect actions for Bulk writing to backend offers parallel operations, writes only, does NOT check for contentions, admin/Node-side only.

Kind: static method of FirebaseFirestoreWrapper
Returns: BulkWriter - object that operations are added to for a bulk operation
Category: Batch

FirebaseFirestoreWrapper.closeBulkWriter(bulkWriter) ⇒ Promise.<void>


Dispatches an asynchronous Closure to complete BulkWriter

Kind: static method of FirebaseFirestoreWrapper
Category: Batch

ParamTypeDescription
bulkWriterBulkWriterbulkWriter to close

FirebaseFirestoreWrapper.documentId : Object

a fieldPath value to represent the document Id - WARNING Google Firestore has a bug, and this actually represents the FULL PATH to the document

Kind: static constant of FirebaseFirestoreWrapper
Category: FieldPath

FirebaseFirestoreWrapper.deleteFieldValue : Object

a sentinel value used to delete a field during an update operation

Kind: static constant of FirebaseFirestoreWrapper
Category: FieldValue

FirebaseFirestoreWrapper.serverTimestampFieldValue : Object

a sentinel value to set a field to a server-generated timestamp during set(0 or update())

Kind: static constant of FirebaseFirestoreWrapper
Category: FieldValue

FirebaseFirestoreWrapper.incrementFieldValue(n) ⇒


return a sentinel to incrment/decrement a field

Kind: static method of FirebaseFirestoreWrapper
Returns: a sentinel value
Category: FieldValue

ParamDescription
nIf either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range (Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1. If the current field value is not of type number, or if the field does not yet exist, the transformation sets the field to the given value.

FirebaseFirestoreWrapper.arrayRemoveFieldValue(elements) ⇒ sentinelValue


returns a sentinel to remove elements from array field

Kind: static method of FirebaseFirestoreWrapper
Returns: sentinelValue - a sentinel value
Category: FieldValue

ParamDescription
elementsREST expanded list of elements to remove

FirebaseFirestoreWrapper.arrayUnionFieldValue(elements) ⇒


return a sentinel to add/join elements to array field

Kind: static method of FirebaseFirestoreWrapper
Returns: a sentinel value
Category: FieldValue

ParamDescription
elementsREST expanded list of elements to add

FirebaseFirestoreWrapper.ListenRecords(tablePath, refPath, dataCallback, errCallback) ⇒ unsubscribe


sets up a listener for changes to a single record

Kind: static method of FirebaseFirestoreWrapper
Returns: unsubscribe - function to be called to release subscription
Category: Listeners

ParamTypeDescription
tablePathstringstring describing relative path to document
refPathstringstring describing path to parent document
dataCallbackCollectionListenerfunction to be called with changes to record
errCallbackcallbackfunction to be called when an error occurs in listener

FirebaseFirestoreWrapper.ListenQuery(table, filterArray, sortArray, refPath, dataCallback, errCallback) ⇒ unsubscribe


Sets up a listener to a query

Kind: static method of FirebaseFirestoreWrapper
Returns: unsubscribe - function to be called to release subscription
Category: Listeners

ParamTypeDescription
tablestringName of table to query too - may be sub-collection of optional reference
filterArrayfilterObjecta 3xn array of filter(i.e. "where") conditions
sortArraysortObjectan (optional) 2xn array of sort (i.e. "orderBy") conditions
refPathstringAn optional Firestore DocumentReference. If present, the "table" parameter above is relative to this reference
dataCallbackCollectionListenercallback function with query results
errCallbackcallbackcallback function with error results

FirebaseFirestoreWrapper.ListenCollectionGroupRecords(tablePath, refPath, dataCallback, errCallback) ⇒ callback


sets up a listener for changes to a collectionGroup

Kind: static method of FirebaseFirestoreWrapper
Returns: callback - function to be called to release subscription
Category: Listeners

ParamTypeDescription
tablePathstringstring describing relative path to document
refPathstringstring describing path to parent document
dataCallbackCollectionListenerfunction to be called with changes to record
errCallbackcallbackfunction to be called when an error occurs in listener

FirebaseFirestoreWrapper.ListenCollectionGroupQuery(table, filterArray, sortArray, dataCallback, errCallback) ⇒ unsubscribe


sets up a listener for changes to a collectionGroup by query

Kind: static method of FirebaseFirestoreWrapper
Returns: unsubscribe - function to be called to release subscription
Category: Listeners

ParamTypeDescription
tablestringstring describing the name of a collectionGroup
filterArrayfilterObjecta 3xn array of filter(i.e. "where") conditions
sortArraysortObjectan (optional) 2xn array of sort (i.e. "orderBy") conditions
dataCallbackCollectionListenerfunction to be called with changes to record
errCallbackcallbackfunction to be called when an error occurs in listener

FirebaseFirestoreWrapper.ListenRecord(tablePath, Id, refPath, dataCallback, errCallback) ⇒ unsubscribe

Listen to changes to a single record

Kind: static method of FirebaseFirestoreWrapper
Returns: unsubscribe - function to be called to release subscription
Category: Listeners

ParamTypeDescription
tablePathstringstring describing relative path to requested record
Idstringstring of Id of requested document
refPathstringstring od full path to parent document
dataCallbackRecordListenercallback to handle changes to requested document
errCallbackcallbackcallback to handle error reporting and operations

FirebaseFirestoreWrapper.PaginateFetch

Kind: static class of FirebaseFirestoreWrapper
Category: Paginator

new exports.PaginateFetch(table, filterArray, sortArray, refPath, limit)

constructs an object to paginate through large Firestore Tables

ParamTypeDefaultDescription
tablestringa properly formatted string representing the requested collection - always an ODD number of elements
filterArrayarrayan (optional) 3xn array of filter(i.e. "where") conditions The array is assumed to be sorted in the correct order - i.e. filterArray0 is added first; filterArraylength-1 last returns data as an array of objects (not dissimilar to Redux State objects) with both the documentID and documentReference added as fields.
sortArrayarraya 2xn array of sort (i.e. "orderBy") conditions
refPathstringnull(optional) allows "table" parameter to reference a sub-collection of an existing document reference (I use a LOT of structured collections)
limitnumberpage size

paginateFetch.limit : number

current limit of query results

Kind: instance property of PaginateFetch

paginateFetch.status : PagingStatus

current status of pagination -1 pending; 0 uninitialized; 1 updated;

Kind: instance property of PaginateFetch

paginateFetch.PageForward() ⇒ Promise.<RecordArray>

executes the query again to fetch the next set of records

Kind: instance method of PaginateFetch
Returns: Promise.<RecordArray> - returns an array of record - the next page

paginateFetch.PageBack() ⇒ Promise.<RecordArray>

executes the query again to fetch the previous set of records

Kind: instance method of PaginateFetch
Returns: Promise.<RecordArray> - returns an array of record - the next page

FirebaseFirestoreWrapper.PaginateGroupFetch

Kind: static class of FirebaseFirestoreWrapper
Category: Paginator

new exports.PaginateGroupFetch(group, filterArray, sortArray, limit)

constructs an object to paginate through large Firestore Tables

ParamTypeDefaultDescription
groupstringa properly formatted string representing the requested collection - always an ODD number of elements
filterArrayfilterObjectan (optional) 3xn array of filter(i.e. "where") conditions
sortArraysortObjecta 2xn array of sort (i.e. "orderBy") conditions The array(s) are assumed to be sorted in the correct order - i.e. filterArray0 is added first; filterArraylength-1 last returns data as an array of objects (not dissimilar to Redux State objects) with both the documentID and documentReference added as fields.
limitnumber(optional)

paginateGroupFetch.limit : number

current limit basis for listener query

Kind: instance property of PaginateGroupFetch

paginateGroupFetch.status : PagingStatus

current status of listener -1 pending; 0 uninitialized; 1 updated;

Kind: instance property of PaginateGroupFetch

paginateGroupFetch.PageForward() ⇒ Promise.<RecordArray>

executes the query again to fetch the next set of records

Kind: instance method of PaginateGroupFetch
Returns: Promise.<RecordArray> - returns an array of record - the next page

paginateGroupFetch.PageBack() ⇒ Promise.<RecordArray>

executes the query again to fetch the previous set of records

Kind: instance method of PaginateGroupFetch
Returns: Promise.<RecordArray> - returns an array of record - the next page

FirebaseFirestoreWrapper.PaginatedListener

Kind: static class of FirebaseFirestoreWrapper
Category: Paginator

new exports.PaginatedListener(table, filterArray, sortArray, refPath, limit, dataCallback, errCallback)

Creates an object to allow for paginating a listener for table read from Firestore. REQUIRES a sorting choice; masks some subscribe/unsubscribe action for paging forward/backward

ParamTypeDefaultDescription
tablestringa properly formatted string representing the requested collection - always an ODD number of elements
filterArrayfilterObjectan (optional) 3xn array of filter(i.e. "where") conditions
sortArraysortObjecta 2xn array of sort (i.e. "orderBy") conditions
refPathrefPath(optional) allows "table" parameter to reference a sub-collection of an existing document reference (I use a LOT of structured collections) The array is assumed to be sorted in the correct order - i.e. filterArray0 is added first; filterArraylength-1 last returns data as an array of objects (not dissimilar to Redux State objects) with both the documentID and documentReference added as fields.
limitnumber(optional)
dataCallbackcallback
errCallbackcallback

paginatedListener.limit : number

current limit basis for listener query

Kind: instance property of PaginatedListener

paginatedListener.status : number

current status of listener

Kind: instance property of PaginatedListener

paginatedListener.PageForward() ⇒ unsubscribe

resets the listener query to the next page of results. Unsubscribes from the current listener, constructs a new query, and sets it as the new listener

Kind: instance method of PaginatedListener
Returns: unsubscribe - returns the unsubscriber function (for lifecycle events)

paginatedListener.PageBack() ⇒ unsubscribe

resets the listener query to the next page of results. Unsubscribes from the current listener, constructs a new query, and sets it\ as the new listener

Kind: instance method of PaginatedListener
Returns: unsubscribe - returns the unsubscriber function (for lifecycle events)

paginatedListener.ChangeLimit(newLimit) ⇒ unsubscribe

sets page size limit to new value, and restarts the paged listener

Kind: instance method of PaginatedListener
Returns: unsubscribe - returns the unsubscriber function (for lifecycle events)

ParamType
newLimitnumber

paginatedListener.ChangeFilter(filterArray) ⇒ unsubscribe

changes the filter on the subscription This has to unsubscribe the current listener, create a new query, then apply it as the listener

Kind: instance method of PaginatedListener
Returns: unsubscribe - returns the unsubscriber function (for lifecycle events)

ParamTypeDescription
filterArrayfilterObjectan array of filter descriptors

paginatedListener.unsubscribe()

IF unsubscribe function is set, run it.

Kind: instance method of PaginatedListener

FirebaseFirestoreWrapper.ownerFilter(owner, queryFilter) ⇒ filterObject

Contructs a filter that selects only the "owner" section of a collectionGroup query - in other words, descendents of a particular top=level document. This takes advantage of Firestore's indexing, which "names"/indexes all documents using the FULL PATH to the document, starting from the top-most, i.e.: TOP_COLLECTION/{dociId}/NEXT_COLLECTION/{docId}/NEXT_NEXT_COLLECTION/{etc} This functions knowns NOTHING about the actual schema; it simply uses the path of the indicated "owner" as starting portion of ALL the "child" documents of the owner. It also takes advantage of the strictly alpha-numeric nature of the path string. As such, ALL children paths strings MUST be "greater than" the owner bare path, and MUST be LESS THAN the alpha-numerically "next" value: e.g. if the "owner" path is TOP_COLLECTION/abcdefg, then

/TOP_COLLECTION/abcdefh > name > //TOP_COLLECTION/abcdefg (assuming LEXICAL SORT) IMPORTANT NOTE: Because this filter uses an INEQUALITY, .sortBy() conditions are not supported

Kind: static method of FirebaseFirestoreWrapper
Category: Tree Slice

ParamTypeDescription
ownerRecord
queryFilterfilterObjectadditional filter parameters

FirebaseFirestoreWrapper.listenSlice(owner, collectionName, dataCallback, response, errCallback, response) ⇒ callback

Uses the ownerFilter (above) to establish a listener to "just" the parts of a collectionGroup that are descendants of the passed "owner" record.

Kind: static method of FirebaseFirestoreWrapper
Returns: callback - function to be called to release subscription
Category: Tree Slice

ParamTypeDescription
ownerRecord
owner.refPathstringstring representing the full path to the Firestore document.
collectionNamestringname of the desired collectionGroup
dataCallbackcallbackfunction to be called with changes to record
responseQuerySnapshot
errCallbackcallbackfunction to be called when an error occurs in listener
responsestring

FirebaseFirestoreWrapper.fetchSlice(owner, collectionName) ⇒ QuerySnapshot

Wrapper around database fetch, using ownerFilter above to select/fetch just an "owner" parent document's descendants from a collectionGroup

Kind: static method of FirebaseFirestoreWrapper
Returns: QuerySnapshot - response
Category: Tree Slice

ParamTypeDescription
ownerRecord
owner.refPathstringstring representing the full path to the Firestore document.
collectionNamestringname of the desired collectionGroup

FirebaseFirestoreWrapper.querySlice(owner, collectionName, queryFilter) ⇒ QuerySnapshot

Wrapper around database fetch, using ownerFilter above to select/fetch just an "owner" parent document's descendants from a collectionGroup

Kind: static method of FirebaseFirestoreWrapper
Returns: QuerySnapshot - response
Category: Tree Slice

ParamTypeDescription
ownerRecord
owner.refPathstringstring representing the full path to the Firestore document.
collectionNamestringname of the desired collectionGroup
queryFilterfilterObjectfilter parameters

FirebaseFirestoreWrapper.listenQuerySlice(owner, collectionName, filterArray, dataCallback, response, errCallback, response) ⇒ callback

Uses the ownerFilter (above) to establish a listener to "just" the parts of a collectionGroup that are descendants of the passed "owner" record.

Kind: static method of FirebaseFirestoreWrapper
Returns: callback - function to be called to release subscription
Category: Tree Slice

ParamTypeDescription
ownerRecord
owner.refPathstringstring representing the full path to the Firestore document.
collectionNamestringname of the desired collectionGroup
filterArrayfilterObjectfilter parameters
dataCallbackcallbackfunction to be called with changes to record
responseQuerySnapshot
errCallbackcallbackfunction to be called when an error occurs in listener
responsestring

FirebaseFirestoreWrapper.ownerType(record) ⇒ string

Returns the "type" (collection name) of the top-most parent of a record, derived from the refPath

Kind: static method of FirebaseFirestoreWrapper
Returns: string - the collection name
Category: Tree Slice

ParamType
recordRecord

FirebaseFirestoreWrapper.ownerId(record) ⇒ string

Returns the Id (documentId) of the top-most parent of a record, derived from the refPath

Kind: static method of FirebaseFirestoreWrapper
Returns: string - the Id
Category: Tree Slice

ParamType
recordRecord

FirebaseFirestoreWrapper.ownerRefPath(record) ⇒ string

Returns the Id (documentId) of the top-most parent of a record, derived from the refPath

Kind: static method of FirebaseFirestoreWrapper
Returns: string - the Id
Category: Tree Slice

ParamType
recordRecord

FirebaseFirestoreWrapper.ownerByChild(record) ⇒ Record

Returns the bare owner record reference to the parent (root) of a provided child

Kind: static method of FirebaseFirestoreWrapper
Returns: Record - reference to the parent (root) record
Category: Tree Slice

ParamTypeDescription
recordRecordchild record

FirebaseFirestoreWrapper.fetchOwner(record) ⇒ Document

returns the record for the top-most parent of a record, derived from the refPath

Kind: static method of FirebaseFirestoreWrapper
Category: Tree Slice

ParamType
recordRecord

FirebaseFirestoreWrapper.typedPaginatedListener ⇐ PaginatedListener

Kind: static class of FirebaseFirestoreWrapper
Extends: PaginatedListener
Category: Typed

new exports.typedPaginatedListener(type, parent, pageSize, dataCallback, errCallback)

Implements a PaginatedListener using type syntax

ParamTypeDescription
typestringthe "type" (CollectionName) for this record
parentRecordObjectthe (optional) parent for this record (i.e. a sub-type)
parent.refPathstringthe only required part of a parent record
pageSizenumberthe page size requested
dataCallbackCollectionListenerthe callback where data is returned
errCallbackcallbackcallback for errors

FirebaseFirestoreWrapper.recordType(record) ⇒ string

Returns the "type" (collection name) the passed record is stored in, derived from the refPath

Kind: static method of FirebaseFirestoreWrapper
Returns: string - the collection name
Category: Typed

ParamType
recordRecord

FirebaseFirestoreWrapper.recordId() ⇒ string

Returns the Id (documentId) of the passed record derived from the refPath

Kind: static method of FirebaseFirestoreWrapper
Returns: string - the Id
Category: Typed

FirebaseFirestoreWrapper.typedWrite(data, parent, type, batch) ⇒ Promise

optionally batched record update - abstracts batch process from specific types

Kind: static method of FirebaseFirestoreWrapper
Returns: Promise - WriteBatch, Transaction or Void
Category: Typed

ParamTypeDescription
dataRecordthe data object/record to update. This will create a new one if it doesn't exist
data.refPathstringonly part used
parentRecordparent object (if any) this belongs to
parent.refPathstringfull path to parent document
typestringname of type of object - i.e. the sub-collection name
batchWriteBatch | Transactionbatching object. Transaction will be added to the batch

FirebaseFirestoreWrapper.typedWriteByTree(data, tree, type, batch) ⇒ Promise

optionally batched record update - abstracts batch process from specific types

Kind: static method of FirebaseFirestoreWrapper
Returns: Promise - WriteBatch, Transaction or Void
Category: Typed

ParamTypeDescription
dataRecordthe data object/record to update. This will create a new one if it doesn't exist
treeArtistTreeObject with properties of refPath segments
typestringname of type of object - i.e. the sub-collection name
batchWriteBatch | Transactionbatching object. Transaction will be added to the batch

FirebaseFirestoreWrapper.typedWriteByChild(data, tree, type, batch) ⇒ Promise

optionally batched record update - abstracts batch process from specific types

Kind: static method of FirebaseFirestoreWrapper
Returns: Promise - WriteBatch, Transaction or Void
Category: Typed

ParamTypeDescription
dataRecordthe data object/record to update. This will create a new one if it doesn't exist
treeArtistTreeObject with properties of refPath segments
typestringname of type of object - i.e. the sub-collection name
batchWriteBatch | Transactionbatching object. Transaction will be added to the batch

FirebaseFirestoreWrapper.typedCreate(data, parent, type, batch) ⇒ Promise

Creates a new document reference of the indicated type, and writes it to the backend. Specific intent is when the Id needs to be pre-specified, or shared outside this function. Normal writing action will silently create a new document, which has to then be found by query

Kind: static method of FirebaseFirestoreWrapper
Returns: Promise - WriteBatch, Transaction or Void
Category: Typed

ParamTypeDescription
dataRecordthe data object/record to create. This will create a new one if it doesn't exist
parentRecordparent object (if any) this belongs to
parent.refPathstringfull path to parent document
typestringname of type of object - i.e. the sub-collection name
batchWriteBatch | Transactionbatching object. Transaction will be added to the batch

FirebaseFirestoreWrapper.treeFromChild(child) ⇒ RecordTree

Extracts a tree of document ID's from a child document (assumes is a child)

Kind: static method of FirebaseFirestoreWrapper
Category: Typed

ParamTypeDescription
childRecorddocument (regardless of depth) of a tree
child.refPathstring

FirebaseFirestoreWrapper.typedTablePathFromTree(tree, type, branchType) ⇒ string

Builds a refPath down to a desired collection/type from an existing RecordTree Map.

Kind: static method of FirebaseFirestoreWrapper
Returns: string - constructed TablePath (collection)
Category: Typed

ParamTypeDescription
treeRecordTree
typestring
branchTypestringa collection name to start branching from. This is in case tree was built from a sister collection/document

FirebaseFirestoreWrapper.typedRefPathFromTree(tree, type) ⇒ string

Builds a refPath down to a desired collection/type from an existing RecordTree Map.

Kind: static method of FirebaseFirestoreWrapper
Returns: string - constructed refPath (document)
Category: Typed

ParamType
treeRecordTree
typestring

FirebaseFirestoreWrapper.typedIdFromChild(child, type)

Looks up a "tree" to find the Id of the document at the requested collection level ("type")

Kind: static method of FirebaseFirestoreWrapper
Category: Typed

ParamTypeDescription
childRecorddocument (regardless of depth) of a tree
child.refPathstring
typestringname of desired type/collection level in tree

FirebaseFirestoreWrapper.typedTablePathFromChild(child, type) ⇒ string

Builds a refPath up to a desired collection/type from an existing child in a tree

Kind: static method of FirebaseFirestoreWrapper
Returns: string - constructed refPath (collection)
Category: Typed

ParamTypeDescription
childRecorddocument (regardless of depth) of a tree
child.refPathstring
typestring

FirebaseFirestoreWrapper.typedRefPathFromChild(child, type) ⇒ string

Builds a refPath up to a desired collection/type from an existing child in a tree

Kind: static method of FirebaseFirestoreWrapper
Returns: string - constructed refPath (document)
Category: Typed

ParamTypeDescription
childRecorddocument (regardless of depth) of a tree
child.refPathstring
typestring

FirebaseFirestoreWrapper.typedFetchFromChild(child, refPath, type, batch) ⇒ Promise.<RecordObject>

function to fetch a document from "up" the collection/document tree of a child document

Kind: static method of FirebaseFirestoreWrapper
Category: Typed

ParamTypeDescription
childRecordassumed to be an object in a collection/document Tree
refPathstring
typestringtype/collection to fetch parent document from
batchWriteBatch | Transactionoptional batch object to chain

FirebaseFirestoreWrapper.typedFetchFromTree(tree, refPath, type, batch) ⇒ Promise.<RecordObject>

function to fetch a document from "up" the collection/document tree of a child document

Kind: static method of FirebaseFirestoreWrapper
Category: Typed

ParamTypeDescription
treeRecordTreeassumed to be an object in a collection/document Tree
refPathstring
typestringtype/collection to fetch parent document from
batchWriteBatch | Transactionoptional batch object to chain

FirebaseFirestoreWrapper.typedCollectFromTree(tree, type, batch) ⇒ Promise.<RecordArray>

function to collect documents from "up" the collection/document tree of a child document

Kind: static method of FirebaseFirestoreWrapper
Category: Typed

ParamTypeDescription
treeRecordTreeassumed to be an object in a collection/document Tree
typestringtype/collection to fetch parent document from
batchWriteBatch | Transactionoptional batch object to chain

FirebaseFirestoreWrapper.typedCollectFromChild(child, type, batch)

function to collect documents from "up" the collection/document tree of a child document

Kind: static method of FirebaseFirestoreWrapper
Category: Typed

ParamTypeDescription
childRecordassumed to be an object in a collection/document Tree
typestringtype/collection to fetch parent document from
batchWriteBatch | Transactionoptional batch object to chain

FirebaseFirestoreWrapper.typedListener(type, parent, batch, type, dataCallback, errCallback) ⇒ callback

Uses the ownerFilter (above) to establish a listener to "just" the parts of a collectionGroup that are descendants of the passed "owner" record.

Kind: static method of FirebaseFirestoreWrapper
Returns: callback - function to be called to release subscription
Category: Typed

ParamTypeDescription
typestringname of type of object - i.e. the sub-collection name
parentRecordparent object (if any) this belongs to
parent.refPathstringfull path to parent document
batchWriteBatch | Transactionbatching object. Transaction will be added to the batch
typestringname of the desired collectionGroup
dataCallbackCollectionListenerfunction to be called with changes to record
errCallbackcallbackfunction to be called when an error occurs in listener

FirebaseFirestoreWrapper~timestamp

Kind: inner class of FirebaseFirestoreWrapper

new timestamp()

class for a Firestore timestamp processor

FirebaseStorageWrapper

A set of helper-wrapper functions around firebase firestore, storage and auth. Intent is to treat Firestore as a hierarchical record-oriented database; originally conceived to port from one database to another.

FirebaseStorageWrapper.FirebaseStorageWrapper(firebase)

Initializes the Auth service of the provided firebase app. Also instantiates various constants and helper functions

Kind: static method of FirebaseStorageWrapper

ParamType
firebasefirebase

Example

import * as firebase from "firebase/app";
import "firebase/storage";
import FirebaseStorage from "@leaddreamer/firebase-wrapper/FirebaseStorageWrapper";
import {config} from "whereever-you-put-it";

((myconfig) {
try {
  firebase.app();
} catch (err) {
  firebase.initializeApp(myconfig);
}
FirebaseStorage(firebase);
})(config);

FirebaseStorageWrapper.makeStorageRefFromRecord(record, key, filename) ⇒ StorageReference

Kind: static method of FirebaseStorageWrapper
Returns: StorageReference - a Firestore Storage Reference

ParamTypeDescription
recordstringA firestore document Record - the '/' separated collection/ document path is used as the path to the stored item.
keystringAn optional string identifying the specific field an stored item is associated with
filenamestringan optional name to be associated with the stored item.

FirebaseStorageWrapper.listReference(storageReference, optionsObject) ⇒ ListResult

Kind: static method of FirebaseStorageWrapper

ParamTypeDescription
storageReferenceStorageReferencea storage reference to a "directory", not a file. More accurate to state that it is treated as a directory, since such niceties are a Firestore convention, not a physical reality
optionsObjectListOptions

FirebaseStorageWrapper.makeFileURLFromRecord(record, key, filename) ⇒ external:promise

Kind: static method of FirebaseStorageWrapper
Fulfil: string a "long-lived" URL to access the file.
Reject: string

ParamTypeDescription
recordRecordObjectA firestore document Record - the '/' separated collection/ document path is used as the path to the stored item.
keystringAn optional string identifying the specific field an stored item is associated with
filenamestringan optional name to be associated with the stored item.

FirebaseStorageWrapper.makePrivateURLFromRecord(record, key) ⇒ string

Kind: static method of FirebaseStorageWrapper
Returns: string - The resulting Security-Rule-compliant URL

ParamTypeDescription
recordRecordObjectA firestore document Record - the '/' separated collection/ document path is used as the path to the stored item.
keystringAn optional string identifying the specific field an stored item is associated with

FirebaseStorageWrapper.makePrivateURLFromReference(reference, key) ⇒ string

Kind: static method of FirebaseStorageWrapper
Returns: string - The resulting Security-Rule-compliant URL

ParamTypeDescription
referenceStorageReferenceA firestore document Record - the '/' separated collection/ document path is used as the path to the stored item.
keystringAn optional string identifying the specific field an stored item is associated with

FirebaseStorageWrapper.makePrivateURLFromPath(fullPath) ⇒ string

This function is part of a storage scheme that uses parallel structures between Firestore collection/documents and Storage paths. The concept here is all Storage items are part of/belong to Firestore documents. This function takes a full path to a Storage object and turns it into URL. If "type"is not included, the URL will return the metadata, not the contents. Note this simply makes the URL - it does not carry out any operations

Kind: static method of FirebaseStorageWrapper
Returns: string - constructed Security-Rule-compliant URL

ParamTypeDescription
fullPathstringrequired path to the stored item.

FirebaseStorageWrapper.storeBlobByRecord(blob, record, key, filename) ⇒ UploadTask

Firestore's document sizes can be limited - 1MB - so our system stores larger digital "blobs" in a parallel Firestore Storage.

Kind: static method of FirebaseStorageWrapper
Returns: UploadTask - Firestore Storage UploadTask Object

ParamTypeDescription
blobblobA data blob in DataURI format to store in Storage
recordRecordObjectA firestore document Record - the '/' separated collection/ document path is used as the path to the stored item.
keystringAn optional string identifying the specific field an stored item is associated with
filenamestringan optional name to be associated with the stored item.

FirebaseStorageWrapper.storeDataURLByRecord(dataURL, record, key, filename) ⇒

Firestore's document sizes can be limited - 1MB - so our system stores larger digital "blobs" in a parallel Firestore Storage.

Kind: static method of FirebaseStorageWrapper
Returns: Firestore Storage UploadTask Object

ParamTypeDescription
dataURLdataURLA data blob in DataURI format to store in Storage
recordRecordObjectA firestore document Record - the '/' separated collection/ document path is used as the path to the stored item.
keystringAn optional string identifying the specific field an stored item is associated with
filenamestringan optional name to be associated with the stored item.

FirebaseStorageWrapper.getDefaultImageURL(key) ⇒ string

Kind: static method of FirebaseStorageWrapper

ParamTypeDescription
keystringname/key of default image file

FirebaseStorageWrapper.getURLFromFilePath(filePath) ⇒ string

Kind: static method of FirebaseStorageWrapper

ParamType
filePathstring

FirebaseStorageWrapper.dataURLToBlob(dataURL) ⇒ Object

Kind: static method of FirebaseStorageWrapper
Returns: Object - {ext: extension, base64: data}

ParamType
dataURLobject

FirebaseStorageWrapper~File : object

Kind: inner typedef of FirebaseStorageWrapper
Properties

NameTypeDescription
metadataFileMetadata
aclobject
namestring//various methods

FirebaseStorageWrapper~FileMetadata : object

Kind: inner typedef of FirebaseStorageWrapper
Properties

NameTypeDescription
kindstring:"storage#object"
idstring
selfLinkstring
namestring
bucketstring
generationlong
metagenerationlong
contentTypestring
timeCreateddatetime
updateddatetime
customTimedatetime
timeDeleteddatetime
temporaryHoldboolean
eventBasedHoldboolean
retentionExpirationTimedatetime
storageClassstring
timeStorageClassUpdateddatetime
sizeulong
md5Hashstring
mediaLinkstring
contentEncodingstring
contentDispositionstring
contentLanguagestring
cacheControlstring
metadataobjectCustom metadata key:value pairs
metadata.firebaseStorageDownloadTokensstring
metadata.keystring
aclobjectAccessControls
ownerobject
owner.entitystring
owner.entityIdstring
crc32cstring
componentCountinteger
etagstring
customerEncryptionobject
customerEncryption.encryptionAlgorithmstring
customerEncryption.keySha256string
kmsKeyNamestring

FirebaseStorageAdminEmulator

A set of helper-wrapper functions around firebase storage Intent is to treat Firestore as a hierarchical record-oriented database and Storage as a parallel structure originally conceived to port from one database to another.

FirebaseStorageAdminEmulator.FirebaseStorageAdminEmulator(firebase)

Initializes the Storage service of the provided firebase app. Also instantiates various constants and helper functions. This is a WRAPPER around CLOUD STORAGE (admin) functions to emulate FIREBASE functionality, keeping a similar API between client & cloud code. NOTE: admin "references" ARE NOT the same as client references, and are NOT interchangeable. Do not mix client & admin code (not actually possible in this wrapper)

Kind: static method of FirebaseStorageAdminEmulator

ParamType
firebasefirebase

FirebaseStorageAdminEmulator~adminRef

Kind: inner class of FirebaseStorageAdminEmulator

new adminRef(bucket, path)

Create a class that emulates a Firebase Storage storageRef using Firebase Admin Cloud Storage Functions. This is not an exact replica, but one with similar static members and methods. Intended for use with a higher-level Wrapper library This returns an object that has many of the same members and methods as a Firebase storageRef, but only in conjunction with the methods here, and likely only with the "wrapper" it is defined for.

ParamTypeDescription
bucketStorageBucketA bucket instance
pathstringa string representing the "path" to the intended target document

adminRef.fileRef : storageRef

used to affect file operations to emulate Firebase Storage functions

Kind: instance property of adminRef

adminRef.fullPath : string

Full path, including file name

Kind: instance property of adminRef

adminRef.name : string

filename portion only

Kind: instance property of adminRef

adminRef.bucket : string

name of containing bucket

Kind: instance property of adminRef

adminRef.parent : storageRef

Cloud Storage object don't really have a parent or root

Kind: instance property of adminRef

adminRef.storage : storageApp

app instance

Kind: instance property of adminRef

adminRef.metadata : string

access token

Kind: instance property of adminRef

FirebaseStorageAdminEmulator~child

creates and returns a new adminRef object from existin path(path) ⇒ StorageRefEmulation Kind: inner method of FirebaseStorageAdminEmulator

ParamTypeDescription
pathstringa relative path from the existing storageRef to create child

FirebaseStorageAdminEmulator~delete

Deletes the referenced storage item() ⇒ Promise Kind: inner method of FirebaseStorageAdminEmulator

FirebaseStorageAdminEmulator~getDownloadURL

Generates a long-lived (essentially permanent until revoked) Public-Access URL for a storage item in FIREBASE (not Cloud Storage) format() ⇒ string Kind: inner method of FirebaseStorageAdminEmulator

FirebaseStorageAdminEmulator~getToken

Fetches (or creates as needed) a unique token for a storage object() ⇒ Promise.<string> Kind: inner method of FirebaseStorageAdminEmulator

FirebaseStorageAdminEmulator~getMetadata

Fetches the FileMetadata for the storage object. Custom/Client metadata is located in FileMetadata.metadata() ⇒ FileMetadata Kind: inner method of FirebaseStorageAdminEmulator

FirebaseStorageAdminEmulator~put(data, metadata) ⇒ Promise.<object>

puts a block of data (and optional metadata) into storage at location specified by adminRef

Kind: inner method of FirebaseStorageAdminEmulator

ParamType
datablob
metadataobject

FirebaseStorageAdminEmulator~putString(dataString, stringFormat, metadata) ⇒ Promise.<object>

puts a string (possibly encoded data) into a storage file described by the provided reference.

Kind: inner method of FirebaseStorageAdminEmulator

ParamType
dataStringstring
stringFormatstring
metadataFileMetadata

PAGINATE_INIT : number

Kind: global constant
Category: Paginate Constants

PAGINATE_PENDING : number

Kind: global constant
Category: Paginate Constants

PAGINATE_UPDATED : number

Kind: global constant
Category: Paginate Constants

PAGINATE_END : number

Kind: global constant
Category: Paginate Constants

PAGINATE_DEFAULT : number

Kind: global constant
Category: Paginate Constants

PAGINATE_CHOICES : number

Kind: global constant
Category: Paginate Constants


© 2020-2021 Tracy Hall

1.3.4-beta.29

9 months ago

1.3.4-beta.28

9 months ago

1.3.4-beta.27

9 months ago

1.3.4-beta.26

9 months ago

1.3.4-beta.25

9 months ago

1.3.4-beta.23

9 months ago

1.3.4-beta.22

9 months ago

1.3.4-beta.21

9 months ago

1.3.4-beta.20

9 months ago

1.3.4-beta.19

9 months ago

1.3.4-beta.18

9 months ago

1.3.4-beta.17

9 months ago

1.3.4-beta.16

9 months ago

1.3.4-beta.15

9 months ago

1.3.4-beta.14

9 months ago

1.3.4-beta.13

9 months ago

1.3.4-beta.12

9 months ago

1.3.4-beta.11

9 months ago

1.3.4-beta.10

9 months ago

1.3.4-beta.46

7 months ago

1.3.4-beta.45

8 months ago

1.3.4-beta.38

8 months ago

1.3.4-beta.37

8 months ago

1.3.4-beta.36

8 months ago

1.3.4-beta.35

8 months ago

1.3.4-beta.34

8 months ago

1.3.4-beta.33

8 months ago

1.3.4-beta.32

8 months ago

1.3.4-beta.30

9 months ago

1.3.4-beta.0

10 months ago

1.3.4-beta.4

9 months ago

1.3.4-beta.2

9 months ago

1.3.4-beta.1

10 months ago

1.3.4-beta.8

9 months ago

1.3.4-beta.7

9 months ago

1.3.4-beta.6

9 months ago

1.3.4-beta.5

9 months ago

1.3.4-beta.9

9 months ago

1.3.3-beta.0

11 months ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.1-beta.14

1 year ago

1.3.1-beta.15

1 year ago

1.3.1-beta.16

1 year ago

1.3.1-beta.17

1 year ago

1.3.1-beta.19

1 year ago

1.3.1-beta.24

1 year ago

1.3.1-beta.25

1 year ago

1.3.1-beta.20

1 year ago

1.3.1-beta.21

1 year ago

1.3.1-beta.22

1 year ago

1.3.1-beta.23

1 year ago

1.1.1

1 year ago

1.3.1-beta.13

1 year ago

1.3.1-beta.10

1 year ago

1.3.1-beta.11

1 year ago

1.3.1-beta.9

1 year ago

1.3.1-beta.8

1 year ago

1.3.1-beta.7

2 years ago

1.3.1-beta.1

2 years ago

1.3.1-beta.0

2 years ago

1.3.1-beta.6

2 years ago

1.3.1-beta.5

2 years ago

1.3.1-beta.4

2 years ago

1.3.1-beta.3

2 years ago

1.3.1-beta.2

2 years ago

1.3.0

2 years ago

1.2.1-beta.0

2 years ago

1.2.1-beta.1

2 years ago

1.2.1-beta.3

2 years ago

1.1.2-beta.2

2 years ago

1.1.2-beta.4

2 years ago

1.1.2-beta.3

2 years ago

1.1.2-beta.6

2 years ago

1.1.2-beta.5

2 years ago

1.1.2-beta.8

2 years ago

1.1.2-beta.7

2 years ago

1.1.4-beta-.0

2 years ago

1.0.264

2 years ago

1.0.265

2 years ago

1.0.268

2 years ago

1.0.269

2 years ago

1.1.5-beta.1

2 years ago

1.1.5-beta.0

2 years ago

1.1.5-beta.3

2 years ago

1.1.5-beta.2

2 years ago

1.1.5-beta.9

2 years ago

1.1.5-beta.8

2 years ago

1.1.5-beta.5

2 years ago

1.1.5-beta.4

2 years ago

1.1.5-beta.7

2 years ago

1.1.5-beta.6

2 years ago

1.1.0

2 years ago

1.1.3

2 years ago

1.1.5-beta-.0

2 years ago

1.0.275

2 years ago

1.0.274

2 years ago

1.0.276

2 years ago

1.0.271

2 years ago

1.0.273

2 years ago

1.0.272

2 years ago

1.1.2-beta.11

2 years ago

1.1.2-beta.10

2 years ago

1.1.2-beta.13

2 years ago

1.1.2-beta.12

2 years ago

1.1.2-beta.15

2 years ago

1.1.2-beta.14

2 years ago

1.1.2-beta.17

2 years ago

1.1.2-beta.16

2 years ago

1.1.5-beta.15

2 years ago

1.1.5-beta.16

2 years ago

1.1.5-beta.17

2 years ago

1.1.5-beta.18

2 years ago

1.1.5-beta.11

2 years ago

1.1.5-beta.12

2 years ago

1.1.5-beta.13

2 years ago

1.1.5-beta.14

2 years ago

1.0.263

2 years ago

1.0.260

2 years ago

1.0.262

2 years ago

1.0.253

2 years ago

1.0.252

2 years ago

1.0.255

2 years ago

1.0.254

2 years ago

1.0.251

2 years ago

1.0.250

2 years ago

1.0.256

2 years ago

1.0.259

2 years ago

1.0.258

2 years ago

1.0.228

2 years ago

1.0.227

2 years ago

1.0.229

2 years ago

1.0.224

2 years ago

1.0.223

2 years ago

1.0.226

2 years ago

1.0.225

2 years ago

1.0.242

2 years ago

1.0.241

2 years ago

1.0.244

2 years ago

1.0.243

2 years ago

1.0.240

2 years ago

1.0.249

2 years ago

1.0.246

2 years ago

1.0.245

2 years ago

1.0.248

2 years ago

1.0.247

2 years ago

1.0.231

2 years ago

1.0.230

2 years ago

1.0.233

2 years ago

1.0.232

2 years ago

1.0.239

2 years ago

1.0.238

2 years ago

1.0.235

2 years ago

1.0.234

2 years ago

1.0.237

2 years ago

1.0.236

2 years ago

1.0.222

2 years ago

1.0.221

2 years ago

1.0.217

2 years ago

1.0.219

2 years ago

1.0.216

3 years ago

1.0.208

3 years ago

1.0.207

3 years ago

1.0.211

3 years ago

1.0.210

3 years ago

1.0.213

3 years ago

1.0.212

3 years ago

1.0.215

3 years ago

1.0.214

3 years ago

1.0.209

3 years ago

1.0.200

3 years ago

1.0.206

3 years ago

1.0.205

3 years ago

1.0.202

3 years ago

1.0.201

3 years ago

1.0.204

3 years ago

1.0.203

3 years ago

1.0.198

3 years ago

1.0.197

3 years ago

1.0.199

3 years ago

1.0.196

3 years ago

1.0.187

3 years ago

1.0.186

3 years ago

1.0.189

3 years ago

1.0.188

3 years ago

1.0.183

3 years ago

1.0.182

3 years ago

1.0.185

3 years ago

1.0.184

3 years ago

1.0.194

3 years ago

1.0.193

3 years ago

1.0.195

3 years ago

1.0.190

3 years ago

1.0.192

3 years ago

1.0.191

3 years ago

1.0.181

3 years ago

1.0.180

3 years ago

1.0.179

3 years ago

1.0.143

3 years ago

1.0.142

3 years ago

1.0.144

3 years ago

1.0.141

3 years ago

1.0.140

3 years ago

1.0.147

3 years ago

1.0.146

3 years ago

1.0.149

3 years ago

1.0.148

3 years ago

1.0.132

3 years ago

1.0.131

3 years ago

1.0.134

3 years ago

1.0.133

3 years ago

1.0.130

3 years ago

1.0.139

3 years ago

1.0.136

3 years ago

1.0.135

3 years ago

1.0.138

3 years ago

1.0.137

3 years ago

1.0.165

3 years ago

1.0.164

3 years ago

1.0.167

3 years ago

1.0.166

3 years ago

1.0.161

3 years ago

1.0.160

3 years ago

1.0.163

3 years ago

1.0.162

3 years ago

1.0.169

3 years ago

1.0.168

3 years ago

1.0.154

3 years ago

1.0.153

3 years ago

1.0.156

3 years ago

1.0.155

3 years ago

1.0.150

3 years ago

1.0.152

3 years ago

1.0.151

3 years ago

1.0.158

3 years ago

1.0.157

3 years ago

1.0.159

3 years ago

1.0.176

3 years ago

1.0.175

3 years ago

1.0.174

3 years ago

1.0.173

3 years ago

1.0.170

3 years ago

1.0.129

3 years ago

1.0.128

3 years ago

1.0.125

3 years ago

1.0.121

3 years ago

1.0.123

3 years ago

1.0.122

3 years ago

1.0.124

3 years ago

1.0.120

3 years ago

1.0.110

3 years ago

1.0.112

3 years ago

1.0.111

3 years ago

1.0.118

3 years ago

1.0.117

3 years ago

1.0.119

3 years ago

1.0.114

3 years ago

1.0.113

3 years ago

1.0.116

3 years ago

1.0.115

3 years ago

1.0.107

3 years ago

1.0.106

3 years ago

1.0.109

3 years ago

1.0.108

3 years ago

1.0.103

3 years ago

1.0.102

3 years ago

1.0.105

3 years ago

1.0.104

3 years ago

1.0.101

3 years ago

1.0.100

3 years ago

1.0.89

3 years ago

1.0.90

3 years ago

1.0.95

3 years ago

1.0.94

3 years ago

1.0.93

3 years ago

1.0.99

3 years ago

1.0.98

3 years ago

1.0.97

3 years ago

1.0.96

3 years ago

1.0.84

3 years ago

1.0.83

3 years ago

1.0.88

3 years ago

1.0.87

3 years ago

1.0.85

3 years ago

1.0.79

3 years ago

1.0.78

3 years ago

1.0.80

3 years ago

1.0.82

3 years ago

1.0.81

3 years ago

1.0.72

3 years ago

1.0.71

3 years ago

1.0.70

3 years ago

1.0.69

3 years ago

1.0.68

3 years ago

1.0.67

3 years ago

1.0.62

3 years ago

1.0.66

3 years ago

1.0.65

3 years ago

1.0.64

3 years ago

1.0.63

3 years ago

1.0.61

3 years ago

1.0.60

3 years ago

1.0.59

3 years ago

1.0.57

3 years ago

1.0.56

3 years ago

1.0.55

3 years ago

1.0.54

3 years ago

1.0.53

3 years ago

1.0.52

3 years ago

1.0.51

3 years ago

1.0.50

3 years ago

1.0.49

3 years ago

1.0.48

3 years ago

1.0.47

3 years ago

1.0.46

3 years ago

1.0.44

3 years ago

1.0.45

3 years ago

1.0.43

3 years ago

1.0.42

3 years ago

1.0.41

3 years ago

1.0.40

3 years ago

1.0.39

3 years ago

1.0.38

3 years ago

1.0.37

3 years ago

1.0.33

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.36

3 years ago

1.0.35

3 years ago

1.0.34

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago