@levante-framework/firekit
Version:
A library to facilitate Firebase authentication and Firestore interaction for LEVANTE apps
127 lines (126 loc) • 3.98 kB
TypeScript
import { Auth } from 'firebase/auth';
import { Functions } from 'firebase/functions';
import { FirebaseStorage } from 'firebase/storage';
import { FirebasePerformance } from 'firebase/performance';
import { OrgLists } from '../interfaces';
import { Firestore } from 'firebase/firestore';
import { type Emulators } from '../firekit';
/** Remove null attributes from an object
* @function
* @param {Object} obj - Object to remove null attributes from
* @returns {Object} Object with null attributes removed
*/
export declare const removeNull: (obj: object) => object;
/** Remove undefined attributes from an object
* @function
* @param {Object} obj - Object to remove undefined attributes from
* @returns {Object} Object with undefined attributes removed
*/
export declare const removeUndefined: (obj: object) => object;
/** Recursively replace values in an object
* @function
* @param {Object} obj - Object to recursively replace values in
* @param {unknown} valueToReplace - Value to replace
* @param {unknown} replacementValue - Replacement value
* @returns {Object} Object with values recursively replaced
*/
export declare const replaceValues: (obj: {
[key: string]: unknown;
}, valueToReplace?: unknown, replacementValue?: unknown) => {
[key: string]: unknown;
};
export interface CommonFirebaseConfig {
projectId: string;
apiKey: string;
siteKey: string;
debugToken?: string;
}
export interface EmulatorFirebaseConfig extends CommonFirebaseConfig {
emulatorPorts: {
db: number;
auth: number;
functions: number;
};
}
export interface LiveFirebaseConfig extends CommonFirebaseConfig {
authDomain: string;
storageBucket: string;
messagingSenderId: string;
appId: string;
measurementId?: string;
}
export declare type FirebaseConfig = LiveFirebaseConfig | EmulatorFirebaseConfig;
export declare const safeInitializeApp: (config: LiveFirebaseConfig, name: string) => import("@firebase/app").FirebaseApp;
export declare enum AuthPersistence {
local = "local",
session = "session",
none = "none"
}
export interface MarkRawConfig {
auth?: boolean;
db?: boolean;
functions?: boolean;
}
export declare const initializeFirebaseProject: (config: FirebaseConfig, name: string, emulatorConfig?: Emulators | undefined, authPersistence?: AuthPersistence, markRawConfig?: MarkRawConfig) => Promise<{
firebaseApp: import("@firebase/app").FirebaseApp;
auth: Auth;
db: Firestore;
functions: Functions;
storage: FirebaseStorage;
perf: FirebasePerformance | undefined;
} | {
firebaseApp: import("@firebase/app").FirebaseApp;
auth: Auth;
db: Firestore;
functions: Functions;
storage: FirebaseStorage;
}>;
export declare const emptyOrg: () => {
current: never[];
all: never[];
dates: {};
};
export declare const emptyOrgList: () => OrgLists;
/**
* Merge new game parameters with old parameters with constraints
*
* The constraints are:
* - no new parameters may be added,
* - no old parameters may be removed,
* - any parameters that have been changed must have had ``null`` values in ``oldParams``
*
* @param oldParams - Old game parameters
* @param newParams - New game parameters
* @returns merged game parameters
*/
export declare const mergeGameParams: (oldParams: {
[key: string]: unknown;
}, newParams: {
[key: string]: unknown;
}) => {
keysAdded: boolean;
merged: {
[x: string]: unknown;
} & {
[key: string]: unknown;
};
};
export declare const crc32String: (inputString: string) => string;
interface Node {
id: string;
[key: string]: unknown;
}
interface OrgNodes {
districts?: Node[];
schools?: Node[];
classes?: Node[];
groups?: Node[];
families?: Node[];
}
interface TreeTableNode {
key: string;
data: Node;
children?: TreeTableNode[];
}
export declare const getTreeTableOrgs: (inputOrgs: OrgNodes) => TreeTableNode[];
export {};