initial commit
This commit is contained in:
3
server/node_modules/@firebase/app-check-interop-types/README.md
generated
vendored
Normal file
3
server/node_modules/@firebase/app-check-interop-types/README.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# @firebase/app-check-interop-types
|
||||
|
||||
**This package is not intended for direct usage, and should only be used via the officially supported [firebase](https://www.npmjs.com/package/firebase) package.**
|
||||
51
server/node_modules/@firebase/app-check-interop-types/index.d.ts
generated
vendored
Normal file
51
server/node_modules/@firebase/app-check-interop-types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export interface FirebaseAppCheckInternal {
|
||||
// Get the current AttestationToken. Attaches to the most recent in-flight request if one
|
||||
// is present. Returns null if no token is present and no token requests are in-flight.
|
||||
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult>;
|
||||
|
||||
// Always returns a fresh limited-use token suitable for Replay Protection.
|
||||
// The returned token must be used and consumed as soon as possible.
|
||||
getLimitedUseToken(): Promise<AppCheckTokenResult>;
|
||||
|
||||
// Registers a listener to changes in the token state. There can be more than one listener
|
||||
// registered at the same time for one or more FirebaseAppAttestation instances. The
|
||||
// listeners call back on the UI thread whenever the current token associated with this
|
||||
// FirebaseAppAttestation changes.
|
||||
addTokenListener(listener: AppCheckTokenListener): void;
|
||||
|
||||
// Unregisters a listener to changes in the token state.
|
||||
removeTokenListener(listener: AppCheckTokenListener): void;
|
||||
}
|
||||
|
||||
type AppCheckTokenListener = (token: AppCheckTokenResult) => void;
|
||||
|
||||
// If the error field is defined, the token field will be populated with a dummy token
|
||||
interface AppCheckTokenResult {
|
||||
readonly token: string;
|
||||
readonly error?: Error;
|
||||
}
|
||||
|
||||
export type AppCheckInternalComponentName = 'app-check-internal';
|
||||
|
||||
declare module '@firebase/component' {
|
||||
interface NameServiceMapping {
|
||||
'app-check-internal': FirebaseAppCheckInternal;
|
||||
}
|
||||
}
|
||||
25
server/node_modules/@firebase/app-check-interop-types/package.json
generated
vendored
Normal file
25
server/node_modules/@firebase/app-check-interop-types/package.json
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@firebase/app-check-interop-types",
|
||||
"version": "0.3.3",
|
||||
"description": "@firebase/app-check-interop-types Types",
|
||||
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
"test": "tsc",
|
||||
"test:ci": "node ../../scripts/run_tests_in_ci.js"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts"
|
||||
],
|
||||
"repository": {
|
||||
"directory": "packages/app-check-interop-types",
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/firebase/firebase-js-sdk.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/firebase/firebase-js-sdk/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "5.5.4"
|
||||
}
|
||||
}
|
||||
3
server/node_modules/@firebase/app-types/README.md
generated
vendored
Normal file
3
server/node_modules/@firebase/app-types/README.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# @firebase/app-types
|
||||
|
||||
**This package is not intended for direct usage, and should only be used via the officially supported [firebase](https://www.npmjs.com/package/firebase) package.**
|
||||
129
server/node_modules/@firebase/app-types/index.d.ts
generated
vendored
Normal file
129
server/node_modules/@firebase/app-types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { LogCallback, LogLevelString, LogOptions } from '@firebase/logger';
|
||||
|
||||
export type FirebaseOptions = {
|
||||
apiKey?: string;
|
||||
authDomain?: string;
|
||||
databaseURL?: string;
|
||||
projectId?: string;
|
||||
storageBucket?: string;
|
||||
messagingSenderId?: string;
|
||||
appId?: string;
|
||||
measurementId?: string;
|
||||
};
|
||||
|
||||
export interface FirebaseAppConfig {
|
||||
name?: string;
|
||||
automaticDataCollectionEnabled?: boolean;
|
||||
}
|
||||
|
||||
export class FirebaseApp {
|
||||
/**
|
||||
* The (read-only) name (identifier) for this App. '[DEFAULT]' is the default
|
||||
* App.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The (read-only) configuration options from the app initialization.
|
||||
*/
|
||||
options: FirebaseOptions;
|
||||
|
||||
/**
|
||||
* The settable config flag for GDPR opt-in/opt-out
|
||||
*/
|
||||
automaticDataCollectionEnabled: boolean;
|
||||
|
||||
/**
|
||||
* Make the given App unusable and free resources.
|
||||
*/
|
||||
delete(): Promise<void>;
|
||||
}
|
||||
|
||||
export interface FirebaseNamespace {
|
||||
/**
|
||||
* Create (and initialize) a FirebaseApp.
|
||||
*
|
||||
* @param options Options to configure the services used in the App.
|
||||
* @param config The optional config for your firebase app
|
||||
*/
|
||||
initializeApp(
|
||||
options: FirebaseOptions,
|
||||
config?: FirebaseAppConfig
|
||||
): FirebaseApp;
|
||||
/**
|
||||
* Create (and initialize) a FirebaseApp.
|
||||
*
|
||||
* @param options Options to configure the services used in the App.
|
||||
* @param name The optional name of the app to initialize ('[DEFAULT]' if
|
||||
* omitted)
|
||||
*/
|
||||
initializeApp(options: FirebaseOptions, name?: string): FirebaseApp;
|
||||
|
||||
app: {
|
||||
/**
|
||||
* Retrieve an instance of a FirebaseApp.
|
||||
*
|
||||
* Usage: firebase.app()
|
||||
*
|
||||
* @param name The optional name of the app to return ('[DEFAULT]' if omitted)
|
||||
*/
|
||||
(name?: string): FirebaseApp;
|
||||
|
||||
/**
|
||||
* For testing FirebaseApp instances:
|
||||
* app() instanceof firebase.app.App
|
||||
*
|
||||
* DO NOT call this constuctor directly (use firebase.app() instead).
|
||||
*/
|
||||
App: typeof FirebaseApp;
|
||||
};
|
||||
|
||||
/**
|
||||
* A (read-only) array of all the initialized Apps.
|
||||
*/
|
||||
apps: FirebaseApp[];
|
||||
|
||||
/**
|
||||
* Registers a library's name and version for platform logging purposes.
|
||||
* @param library Name of 1p or 3p library (e.g. firestore, angularfire)
|
||||
* @param version Current version of that library.
|
||||
*/
|
||||
registerVersion(library: string, version: string, variant?: string): void;
|
||||
|
||||
// Sets log level for all Firebase components.
|
||||
setLogLevel(logLevel: LogLevelString): void;
|
||||
|
||||
// Sets log handler for all Firebase components.
|
||||
onLog(logCallback: LogCallback, options?: LogOptions): void;
|
||||
|
||||
// The current SDK version.
|
||||
SDK_VERSION: string;
|
||||
}
|
||||
|
||||
export interface VersionService {
|
||||
library: string;
|
||||
version: string;
|
||||
}
|
||||
|
||||
declare module '@firebase/component' {
|
||||
interface NameServiceMapping {
|
||||
'app-version': VersionService;
|
||||
'platform-identifier': VersionService;
|
||||
}
|
||||
}
|
||||
29
server/node_modules/@firebase/app-types/package.json
generated
vendored
Normal file
29
server/node_modules/@firebase/app-types/package.json
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "@firebase/app-types",
|
||||
"version": "0.9.3",
|
||||
"description": "@firebase/app Types",
|
||||
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
"test": "tsc",
|
||||
"test:ci": "node ../../scripts/run_tests_in_ci.js"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"private.d.ts"
|
||||
],
|
||||
"repository": {
|
||||
"directory": "packages/app-types",
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/firebase/firebase-js-sdk.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/firebase/firebase-js-sdk/issues"
|
||||
},
|
||||
"dependency": {
|
||||
"@firebase/logger": "0.2.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "5.5.4"
|
||||
}
|
||||
}
|
||||
165
server/node_modules/@firebase/app-types/private.d.ts
generated
vendored
Normal file
165
server/node_modules/@firebase/app-types/private.d.ts
generated
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* THIS FILE IS FOR INTERNAL USAGE ONLY, IF YOU ARE NOT DEVELOPING THE FIREBASE
|
||||
* SDKs, PLEASE DO NOT REFERENCE THIS FILE AS IT MAY CHANGE WITHOUT WARNING
|
||||
*/
|
||||
|
||||
import { FirebaseApp, FirebaseNamespace } from '@firebase/app-types';
|
||||
import { Observer, Subscribe } from '@firebase/util';
|
||||
import { FirebaseError, ErrorFactory } from '@firebase/util';
|
||||
import { Component, ComponentContainer, Name } from '@firebase/component';
|
||||
|
||||
export interface FirebaseServiceInternals {
|
||||
/**
|
||||
* Delete the service and free it's resources - called from
|
||||
* app.delete().
|
||||
*/
|
||||
delete(): Promise<void>;
|
||||
}
|
||||
|
||||
// Services are exposed through instances - each of which is associated with a
|
||||
// FirebaseApp.
|
||||
export interface FirebaseService {
|
||||
app: FirebaseApp;
|
||||
INTERNAL?: FirebaseServiceInternals;
|
||||
}
|
||||
|
||||
export type AppHook = (event: string, app: FirebaseApp) => void;
|
||||
|
||||
/**
|
||||
* Firebase Services create instances given a Firebase App instance and can
|
||||
* optionally add properties and methods to each FirebaseApp via the extendApp()
|
||||
* function.
|
||||
*/
|
||||
export interface FirebaseServiceFactory {
|
||||
(
|
||||
app: FirebaseApp,
|
||||
extendApp?: (props: { [prop: string]: any }) => void,
|
||||
instanceString?: string
|
||||
): FirebaseService;
|
||||
}
|
||||
|
||||
export interface PlatformLoggerService {
|
||||
getPlatformInfoString(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* All ServiceNamespaces extend from FirebaseServiceNamespace
|
||||
*/
|
||||
export interface FirebaseServiceNamespace<T extends FirebaseService> {
|
||||
(app?: FirebaseApp): T;
|
||||
}
|
||||
|
||||
export interface FirebaseAuthTokenData {
|
||||
accessToken: string;
|
||||
}
|
||||
|
||||
export interface FirebaseAppInternals {
|
||||
getToken(refreshToken?: boolean): Promise<FirebaseAuthTokenData | null>;
|
||||
getUid(): string | null;
|
||||
addAuthTokenListener(fn: (token: string | null) => void): void;
|
||||
removeAuthTokenListener(fn: (token: string | null) => void): void;
|
||||
analytics: {
|
||||
logEvent: (
|
||||
eventName: string,
|
||||
eventParams: { [key: string]: any },
|
||||
options?: { global: boolean }
|
||||
) => void;
|
||||
};
|
||||
}
|
||||
|
||||
export interface _FirebaseApp extends FirebaseApp {
|
||||
container: ComponentContainer;
|
||||
_addComponent<T extends Name>(component: Component<T>): void;
|
||||
_addOrOverwriteComponent<T extends Name>(component: Component<T>): void;
|
||||
_removeServiceInstance(name: string, instanceIdentifier?: string): void;
|
||||
}
|
||||
export interface _FirebaseNamespace extends FirebaseNamespace {
|
||||
INTERNAL: {
|
||||
/**
|
||||
* Internal API to register a Firebase Service into the firebase namespace.
|
||||
*
|
||||
* Each service will create a child namespace (firebase.<name>) which acts as
|
||||
* both a namespace for service specific properties, and also as a service
|
||||
* accessor function (firebase.<name>() or firebase.<name>(app)).
|
||||
*
|
||||
* @param name The Firebase Service being registered.
|
||||
* @param createService Factory function to create a service instance.
|
||||
* @param serviceProperties Properties to copy to the service's namespace.
|
||||
* @param appHook All appHooks called before initializeApp returns to caller.
|
||||
* @param allowMultipleInstances Whether the registered service supports
|
||||
* multiple instances per app. If not specified, the default is false.
|
||||
*/
|
||||
registerComponent<T extends Name>(
|
||||
component: Component<T>
|
||||
): FirebaseServiceNamespace<FirebaseService> | null;
|
||||
|
||||
/**
|
||||
* Just used for testing to start from a fresh namespace.
|
||||
*/
|
||||
createFirebaseNamespace(): FirebaseNamespace;
|
||||
|
||||
/**
|
||||
* Internal API to install properties on the top-level firebase namespace.
|
||||
* @prop props The top level properties of this object are copied to the
|
||||
* namespace.
|
||||
*/
|
||||
extendNamespace(props: { [prop: string]: any }): void;
|
||||
|
||||
/**
|
||||
* Create a Subscribe function. A proxy Observer is created so that
|
||||
* events can be sent to single Observer to be fanned out automatically.
|
||||
*/
|
||||
createSubscribe<T>(
|
||||
executor: (observer: Observer<T>) => void,
|
||||
onNoObservers?: (observer: Observer<T>) => void
|
||||
): Subscribe<T>;
|
||||
|
||||
/**
|
||||
* Utility exposed for internal testing.
|
||||
*/
|
||||
deepExtend(target: any, source: any): any;
|
||||
|
||||
/**
|
||||
* Internal API to remove an app from the list of registered apps.
|
||||
*/
|
||||
removeApp(name: string): void;
|
||||
|
||||
/**
|
||||
* registered components.
|
||||
*/
|
||||
components: Map<string, Component>;
|
||||
|
||||
/*
|
||||
* Convert service name to factory name to use.
|
||||
*/
|
||||
useAsService(app: FirebaseApp, serviceName: string): string | null;
|
||||
|
||||
/**
|
||||
* Use to construct all thrown FirebaseError's.
|
||||
*/
|
||||
ErrorFactory: typeof ErrorFactory;
|
||||
};
|
||||
}
|
||||
|
||||
declare module '@firebase/component' {
|
||||
interface NameServiceMapping {
|
||||
'platform-logger': PlatformLoggerService;
|
||||
}
|
||||
}
|
||||
3
server/node_modules/@firebase/auth-interop-types/README.md
generated
vendored
Normal file
3
server/node_modules/@firebase/auth-interop-types/README.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# @firebase/auth-interop-types
|
||||
|
||||
**This package is not intended for direct usage, and should only be used via the officially supported [firebase](https://www.npmjs.com/package/firebase) package.**
|
||||
35
server/node_modules/@firebase/auth-interop-types/index.d.ts
generated
vendored
Normal file
35
server/node_modules/@firebase/auth-interop-types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export interface FirebaseAuthTokenData {
|
||||
accessToken: string;
|
||||
}
|
||||
|
||||
export interface FirebaseAuthInternal {
|
||||
getToken(refreshToken?: boolean): Promise<FirebaseAuthTokenData | null>;
|
||||
getUid(): string | null;
|
||||
addAuthTokenListener(fn: (token: string | null) => void): void;
|
||||
removeAuthTokenListener(fn: (token: string | null) => void): void;
|
||||
}
|
||||
|
||||
export type FirebaseAuthInternalName = 'auth-internal';
|
||||
|
||||
declare module '@firebase/component' {
|
||||
interface NameServiceMapping {
|
||||
'auth-internal': FirebaseAuthInternal;
|
||||
}
|
||||
}
|
||||
25
server/node_modules/@firebase/auth-interop-types/package.json
generated
vendored
Normal file
25
server/node_modules/@firebase/auth-interop-types/package.json
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@firebase/auth-interop-types",
|
||||
"version": "0.2.4",
|
||||
"description": "@firebase/auth interop Types",
|
||||
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
"test": "tsc",
|
||||
"test:ci": "node ../../scripts/run_tests_in_ci.js"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts"
|
||||
],
|
||||
"repository": {
|
||||
"directory": "packages/auth-types",
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/firebase/firebase-js-sdk.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/firebase/firebase-js-sdk/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "5.5.4"
|
||||
}
|
||||
}
|
||||
12
server/node_modules/@firebase/component/README.md
generated
vendored
Normal file
12
server/node_modules/@firebase/component/README.md
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# @firebase/component
|
||||
|
||||
_NOTE: This is specifically tailored for Firebase JS SDK usage, if you are not a
|
||||
member of the Firebase team, please avoid using this package_
|
||||
|
||||
## Usage
|
||||
|
||||
**ES Modules**
|
||||
|
||||
```javascript
|
||||
import { Component } from '@firebase/component';
|
||||
```
|
||||
20
server/node_modules/@firebase/component/dist/esm/index.d.ts
generated
vendored
Normal file
20
server/node_modules/@firebase/component/dist/esm/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export { Component } from './src/component';
|
||||
export { ComponentContainer } from './src/component_container';
|
||||
export { Provider } from './src/provider';
|
||||
export { ComponentType, InstanceFactory, InstantiationMode, NameServiceMapping, Name, InstanceFactoryOptions } from './src/types';
|
||||
408
server/node_modules/@firebase/component/dist/esm/index.esm.js
generated
vendored
Normal file
408
server/node_modules/@firebase/component/dist/esm/index.esm.js
generated
vendored
Normal file
@@ -0,0 +1,408 @@
|
||||
import { Deferred } from '@firebase/util';
|
||||
|
||||
/**
|
||||
* Component for service name T, e.g. `auth`, `auth-internal`
|
||||
*/
|
||||
class Component {
|
||||
/**
|
||||
*
|
||||
* @param name The public service name, e.g. app, auth, firestore, database
|
||||
* @param instanceFactory Service factory responsible for creating the public interface
|
||||
* @param type whether the service provided by the component is public or private
|
||||
*/
|
||||
constructor(name, instanceFactory, type) {
|
||||
this.name = name;
|
||||
this.instanceFactory = instanceFactory;
|
||||
this.type = type;
|
||||
this.multipleInstances = false;
|
||||
/**
|
||||
* Properties to be added to the service namespace
|
||||
*/
|
||||
this.serviceProps = {};
|
||||
this.instantiationMode = "LAZY" /* InstantiationMode.LAZY */;
|
||||
this.onInstanceCreated = null;
|
||||
}
|
||||
setInstantiationMode(mode) {
|
||||
this.instantiationMode = mode;
|
||||
return this;
|
||||
}
|
||||
setMultipleInstances(multipleInstances) {
|
||||
this.multipleInstances = multipleInstances;
|
||||
return this;
|
||||
}
|
||||
setServiceProps(props) {
|
||||
this.serviceProps = props;
|
||||
return this;
|
||||
}
|
||||
setInstanceCreatedCallback(callback) {
|
||||
this.onInstanceCreated = callback;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
const DEFAULT_ENTRY_NAME = '[DEFAULT]';
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* Provider for instance for service name T, e.g. 'auth', 'auth-internal'
|
||||
* NameServiceMapping[T] is an alias for the type of the instance
|
||||
*/
|
||||
class Provider {
|
||||
constructor(name, container) {
|
||||
this.name = name;
|
||||
this.container = container;
|
||||
this.component = null;
|
||||
this.instances = new Map();
|
||||
this.instancesDeferred = new Map();
|
||||
this.instancesOptions = new Map();
|
||||
this.onInitCallbacks = new Map();
|
||||
}
|
||||
/**
|
||||
* @param identifier A provider can provide multiple instances of a service
|
||||
* if this.component.multipleInstances is true.
|
||||
*/
|
||||
get(identifier) {
|
||||
// if multipleInstances is not supported, use the default name
|
||||
const normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
|
||||
if (!this.instancesDeferred.has(normalizedIdentifier)) {
|
||||
const deferred = new Deferred();
|
||||
this.instancesDeferred.set(normalizedIdentifier, deferred);
|
||||
if (this.isInitialized(normalizedIdentifier) ||
|
||||
this.shouldAutoInitialize()) {
|
||||
// initialize the service if it can be auto-initialized
|
||||
try {
|
||||
const instance = this.getOrInitializeService({
|
||||
instanceIdentifier: normalizedIdentifier
|
||||
});
|
||||
if (instance) {
|
||||
deferred.resolve(instance);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
// when the instance factory throws an exception during get(), it should not cause
|
||||
// a fatal error. We just return the unresolved promise in this case.
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.instancesDeferred.get(normalizedIdentifier).promise;
|
||||
}
|
||||
getImmediate(options) {
|
||||
// if multipleInstances is not supported, use the default name
|
||||
const normalizedIdentifier = this.normalizeInstanceIdentifier(options?.identifier);
|
||||
const optional = options?.optional ?? false;
|
||||
if (this.isInitialized(normalizedIdentifier) ||
|
||||
this.shouldAutoInitialize()) {
|
||||
try {
|
||||
return this.getOrInitializeService({
|
||||
instanceIdentifier: normalizedIdentifier
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (optional) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// In case a component is not initialized and should/cannot be auto-initialized at the moment, return null if the optional flag is set, or throw
|
||||
if (optional) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw Error(`Service ${this.name} is not available`);
|
||||
}
|
||||
}
|
||||
}
|
||||
getComponent() {
|
||||
return this.component;
|
||||
}
|
||||
setComponent(component) {
|
||||
if (component.name !== this.name) {
|
||||
throw Error(`Mismatching Component ${component.name} for Provider ${this.name}.`);
|
||||
}
|
||||
if (this.component) {
|
||||
throw Error(`Component for ${this.name} has already been provided`);
|
||||
}
|
||||
this.component = component;
|
||||
// return early without attempting to initialize the component if the component requires explicit initialization (calling `Provider.initialize()`)
|
||||
if (!this.shouldAutoInitialize()) {
|
||||
return;
|
||||
}
|
||||
// if the service is eager, initialize the default instance
|
||||
if (isComponentEager(component)) {
|
||||
try {
|
||||
this.getOrInitializeService({ instanceIdentifier: DEFAULT_ENTRY_NAME });
|
||||
}
|
||||
catch (e) {
|
||||
// when the instance factory for an eager Component throws an exception during the eager
|
||||
// initialization, it should not cause a fatal error.
|
||||
// TODO: Investigate if we need to make it configurable, because some component may want to cause
|
||||
// a fatal error in this case?
|
||||
}
|
||||
}
|
||||
// Create service instances for the pending promises and resolve them
|
||||
// NOTE: if this.multipleInstances is false, only the default instance will be created
|
||||
// and all promises with resolve with it regardless of the identifier.
|
||||
for (const [instanceIdentifier, instanceDeferred] of this.instancesDeferred.entries()) {
|
||||
const normalizedIdentifier = this.normalizeInstanceIdentifier(instanceIdentifier);
|
||||
try {
|
||||
// `getOrInitializeService()` should always return a valid instance since a component is guaranteed. use ! to make typescript happy.
|
||||
const instance = this.getOrInitializeService({
|
||||
instanceIdentifier: normalizedIdentifier
|
||||
});
|
||||
instanceDeferred.resolve(instance);
|
||||
}
|
||||
catch (e) {
|
||||
// when the instance factory throws an exception, it should not cause
|
||||
// a fatal error. We just leave the promise unresolved.
|
||||
}
|
||||
}
|
||||
}
|
||||
clearInstance(identifier = DEFAULT_ENTRY_NAME) {
|
||||
this.instancesDeferred.delete(identifier);
|
||||
this.instancesOptions.delete(identifier);
|
||||
this.instances.delete(identifier);
|
||||
}
|
||||
// app.delete() will call this method on every provider to delete the services
|
||||
// TODO: should we mark the provider as deleted?
|
||||
async delete() {
|
||||
const services = Array.from(this.instances.values());
|
||||
await Promise.all([
|
||||
...services
|
||||
.filter(service => 'INTERNAL' in service) // legacy services
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
.map(service => service.INTERNAL.delete()),
|
||||
...services
|
||||
.filter(service => '_delete' in service) // modularized services
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
.map(service => service._delete())
|
||||
]);
|
||||
}
|
||||
isComponentSet() {
|
||||
return this.component != null;
|
||||
}
|
||||
isInitialized(identifier = DEFAULT_ENTRY_NAME) {
|
||||
return this.instances.has(identifier);
|
||||
}
|
||||
getOptions(identifier = DEFAULT_ENTRY_NAME) {
|
||||
return this.instancesOptions.get(identifier) || {};
|
||||
}
|
||||
initialize(opts = {}) {
|
||||
const { options = {} } = opts;
|
||||
const normalizedIdentifier = this.normalizeInstanceIdentifier(opts.instanceIdentifier);
|
||||
if (this.isInitialized(normalizedIdentifier)) {
|
||||
throw Error(`${this.name}(${normalizedIdentifier}) has already been initialized`);
|
||||
}
|
||||
if (!this.isComponentSet()) {
|
||||
throw Error(`Component ${this.name} has not been registered yet`);
|
||||
}
|
||||
const instance = this.getOrInitializeService({
|
||||
instanceIdentifier: normalizedIdentifier,
|
||||
options
|
||||
});
|
||||
// resolve any pending promise waiting for the service instance
|
||||
for (const [instanceIdentifier, instanceDeferred] of this.instancesDeferred.entries()) {
|
||||
const normalizedDeferredIdentifier = this.normalizeInstanceIdentifier(instanceIdentifier);
|
||||
if (normalizedIdentifier === normalizedDeferredIdentifier) {
|
||||
instanceDeferred.resolve(instance);
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param callback - a function that will be invoked after the provider has been initialized by calling provider.initialize().
|
||||
* The function is invoked SYNCHRONOUSLY, so it should not execute any longrunning tasks in order to not block the program.
|
||||
*
|
||||
* @param identifier An optional instance identifier
|
||||
* @returns a function to unregister the callback
|
||||
*/
|
||||
onInit(callback, identifier) {
|
||||
const normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
|
||||
const existingCallbacks = this.onInitCallbacks.get(normalizedIdentifier) ??
|
||||
new Set();
|
||||
existingCallbacks.add(callback);
|
||||
this.onInitCallbacks.set(normalizedIdentifier, existingCallbacks);
|
||||
const existingInstance = this.instances.get(normalizedIdentifier);
|
||||
if (existingInstance) {
|
||||
callback(existingInstance, normalizedIdentifier);
|
||||
}
|
||||
return () => {
|
||||
existingCallbacks.delete(callback);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Invoke onInit callbacks synchronously
|
||||
* @param instance the service instance`
|
||||
*/
|
||||
invokeOnInitCallbacks(instance, identifier) {
|
||||
const callbacks = this.onInitCallbacks.get(identifier);
|
||||
if (!callbacks) {
|
||||
return;
|
||||
}
|
||||
for (const callback of callbacks) {
|
||||
try {
|
||||
callback(instance, identifier);
|
||||
}
|
||||
catch {
|
||||
// ignore errors in the onInit callback
|
||||
}
|
||||
}
|
||||
}
|
||||
getOrInitializeService({ instanceIdentifier, options = {} }) {
|
||||
let instance = this.instances.get(instanceIdentifier);
|
||||
if (!instance && this.component) {
|
||||
instance = this.component.instanceFactory(this.container, {
|
||||
instanceIdentifier: normalizeIdentifierForFactory(instanceIdentifier),
|
||||
options
|
||||
});
|
||||
this.instances.set(instanceIdentifier, instance);
|
||||
this.instancesOptions.set(instanceIdentifier, options);
|
||||
/**
|
||||
* Invoke onInit listeners.
|
||||
* Note this.component.onInstanceCreated is different, which is used by the component creator,
|
||||
* while onInit listeners are registered by consumers of the provider.
|
||||
*/
|
||||
this.invokeOnInitCallbacks(instance, instanceIdentifier);
|
||||
/**
|
||||
* Order is important
|
||||
* onInstanceCreated() should be called after this.instances.set(instanceIdentifier, instance); which
|
||||
* makes `isInitialized()` return true.
|
||||
*/
|
||||
if (this.component.onInstanceCreated) {
|
||||
try {
|
||||
this.component.onInstanceCreated(this.container, instanceIdentifier, instance);
|
||||
}
|
||||
catch {
|
||||
// ignore errors in the onInstanceCreatedCallback
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance || null;
|
||||
}
|
||||
normalizeInstanceIdentifier(identifier = DEFAULT_ENTRY_NAME) {
|
||||
if (this.component) {
|
||||
return this.component.multipleInstances ? identifier : DEFAULT_ENTRY_NAME;
|
||||
}
|
||||
else {
|
||||
return identifier; // assume multiple instances are supported before the component is provided.
|
||||
}
|
||||
}
|
||||
shouldAutoInitialize() {
|
||||
return (!!this.component &&
|
||||
this.component.instantiationMode !== "EXPLICIT" /* InstantiationMode.EXPLICIT */);
|
||||
}
|
||||
}
|
||||
// undefined should be passed to the service factory for the default instance
|
||||
function normalizeIdentifierForFactory(identifier) {
|
||||
return identifier === DEFAULT_ENTRY_NAME ? undefined : identifier;
|
||||
}
|
||||
function isComponentEager(component) {
|
||||
return component.instantiationMode === "EAGER" /* InstantiationMode.EAGER */;
|
||||
}
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* ComponentContainer that provides Providers for service name T, e.g. `auth`, `auth-internal`
|
||||
*/
|
||||
class ComponentContainer {
|
||||
constructor(name) {
|
||||
this.name = name;
|
||||
this.providers = new Map();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component Component being added
|
||||
* @param overwrite When a component with the same name has already been registered,
|
||||
* if overwrite is true: overwrite the existing component with the new component and create a new
|
||||
* provider with the new component. It can be useful in tests where you want to use different mocks
|
||||
* for different tests.
|
||||
* if overwrite is false: throw an exception
|
||||
*/
|
||||
addComponent(component) {
|
||||
const provider = this.getProvider(component.name);
|
||||
if (provider.isComponentSet()) {
|
||||
throw new Error(`Component ${component.name} has already been registered with ${this.name}`);
|
||||
}
|
||||
provider.setComponent(component);
|
||||
}
|
||||
addOrOverwriteComponent(component) {
|
||||
const provider = this.getProvider(component.name);
|
||||
if (provider.isComponentSet()) {
|
||||
// delete the existing provider from the container, so we can register the new component
|
||||
this.providers.delete(component.name);
|
||||
}
|
||||
this.addComponent(component);
|
||||
}
|
||||
/**
|
||||
* getProvider provides a type safe interface where it can only be called with a field name
|
||||
* present in NameServiceMapping interface.
|
||||
*
|
||||
* Firebase SDKs providing services should extend NameServiceMapping interface to register
|
||||
* themselves.
|
||||
*/
|
||||
getProvider(name) {
|
||||
if (this.providers.has(name)) {
|
||||
return this.providers.get(name);
|
||||
}
|
||||
// create a Provider for a service that hasn't registered with Firebase
|
||||
const provider = new Provider(name, this);
|
||||
this.providers.set(name, provider);
|
||||
return provider;
|
||||
}
|
||||
getProviders() {
|
||||
return Array.from(this.providers.values());
|
||||
}
|
||||
}
|
||||
|
||||
export { Component, ComponentContainer, Provider };
|
||||
//# sourceMappingURL=index.esm.js.map
|
||||
1
server/node_modules/@firebase/component/dist/esm/index.esm.js.map
generated
vendored
Normal file
1
server/node_modules/@firebase/component/dist/esm/index.esm.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
server/node_modules/@firebase/component/dist/esm/package.json
generated
vendored
Normal file
1
server/node_modules/@firebase/component/dist/esm/package.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"type":"module"}
|
||||
43
server/node_modules/@firebase/component/dist/esm/src/component.d.ts
generated
vendored
Normal file
43
server/node_modules/@firebase/component/dist/esm/src/component.d.ts
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { InstantiationMode, InstanceFactory, ComponentType, Dictionary, Name, onInstanceCreatedCallback } from './types';
|
||||
/**
|
||||
* Component for service name T, e.g. `auth`, `auth-internal`
|
||||
*/
|
||||
export declare class Component<T extends Name = Name> {
|
||||
readonly name: T;
|
||||
readonly instanceFactory: InstanceFactory<T>;
|
||||
readonly type: ComponentType;
|
||||
multipleInstances: boolean;
|
||||
/**
|
||||
* Properties to be added to the service namespace
|
||||
*/
|
||||
serviceProps: Dictionary;
|
||||
instantiationMode: InstantiationMode;
|
||||
onInstanceCreated: onInstanceCreatedCallback<T> | null;
|
||||
/**
|
||||
*
|
||||
* @param name The public service name, e.g. app, auth, firestore, database
|
||||
* @param instanceFactory Service factory responsible for creating the public interface
|
||||
* @param type whether the service provided by the component is public or private
|
||||
*/
|
||||
constructor(name: T, instanceFactory: InstanceFactory<T>, type: ComponentType);
|
||||
setInstantiationMode(mode: InstantiationMode): this;
|
||||
setMultipleInstances(multipleInstances: boolean): this;
|
||||
setServiceProps(props: Dictionary): this;
|
||||
setInstanceCreatedCallback(callback: onInstanceCreatedCallback<T>): this;
|
||||
}
|
||||
47
server/node_modules/@firebase/component/dist/esm/src/component_container.d.ts
generated
vendored
Normal file
47
server/node_modules/@firebase/component/dist/esm/src/component_container.d.ts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Provider } from './provider';
|
||||
import { Component } from './component';
|
||||
import { Name } from './types';
|
||||
/**
|
||||
* ComponentContainer that provides Providers for service name T, e.g. `auth`, `auth-internal`
|
||||
*/
|
||||
export declare class ComponentContainer {
|
||||
private readonly name;
|
||||
private readonly providers;
|
||||
constructor(name: string);
|
||||
/**
|
||||
*
|
||||
* @param component Component being added
|
||||
* @param overwrite When a component with the same name has already been registered,
|
||||
* if overwrite is true: overwrite the existing component with the new component and create a new
|
||||
* provider with the new component. It can be useful in tests where you want to use different mocks
|
||||
* for different tests.
|
||||
* if overwrite is false: throw an exception
|
||||
*/
|
||||
addComponent<T extends Name>(component: Component<T>): void;
|
||||
addOrOverwriteComponent<T extends Name>(component: Component<T>): void;
|
||||
/**
|
||||
* getProvider provides a type safe interface where it can only be called with a field name
|
||||
* present in NameServiceMapping interface.
|
||||
*
|
||||
* Firebase SDKs providing services should extend NameServiceMapping interface to register
|
||||
* themselves.
|
||||
*/
|
||||
getProvider<T extends Name>(name: T): Provider<T>;
|
||||
getProviders(): Array<Provider<Name>>;
|
||||
}
|
||||
17
server/node_modules/@firebase/component/dist/esm/src/constants.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/component/dist/esm/src/constants.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export declare const DEFAULT_ENTRY_NAME = "[DEFAULT]";
|
||||
79
server/node_modules/@firebase/component/dist/esm/src/provider.d.ts
generated
vendored
Normal file
79
server/node_modules/@firebase/component/dist/esm/src/provider.d.ts
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { ComponentContainer } from './component_container';
|
||||
import { InitializeOptions, Name, NameServiceMapping, OnInitCallBack } from './types';
|
||||
import { Component } from './component';
|
||||
/**
|
||||
* Provider for instance for service name T, e.g. 'auth', 'auth-internal'
|
||||
* NameServiceMapping[T] is an alias for the type of the instance
|
||||
*/
|
||||
export declare class Provider<T extends Name> {
|
||||
private readonly name;
|
||||
private readonly container;
|
||||
private component;
|
||||
private readonly instances;
|
||||
private readonly instancesDeferred;
|
||||
private readonly instancesOptions;
|
||||
private onInitCallbacks;
|
||||
constructor(name: T, container: ComponentContainer);
|
||||
/**
|
||||
* @param identifier A provider can provide multiple instances of a service
|
||||
* if this.component.multipleInstances is true.
|
||||
*/
|
||||
get(identifier?: string): Promise<NameServiceMapping[T]>;
|
||||
/**
|
||||
*
|
||||
* @param options.identifier A provider can provide multiple instances of a service
|
||||
* if this.component.multipleInstances is true.
|
||||
* @param options.optional If optional is false or not provided, the method throws an error when
|
||||
* the service is not immediately available.
|
||||
* If optional is true, the method returns null if the service is not immediately available.
|
||||
*/
|
||||
getImmediate(options: {
|
||||
identifier?: string;
|
||||
optional: true;
|
||||
}): NameServiceMapping[T] | null;
|
||||
getImmediate(options?: {
|
||||
identifier?: string;
|
||||
optional?: false;
|
||||
}): NameServiceMapping[T];
|
||||
getComponent(): Component<T> | null;
|
||||
setComponent(component: Component<T>): void;
|
||||
clearInstance(identifier?: string): void;
|
||||
delete(): Promise<void>;
|
||||
isComponentSet(): boolean;
|
||||
isInitialized(identifier?: string): boolean;
|
||||
getOptions(identifier?: string): Record<string, unknown>;
|
||||
initialize(opts?: InitializeOptions): NameServiceMapping[T];
|
||||
/**
|
||||
*
|
||||
* @param callback - a function that will be invoked after the provider has been initialized by calling provider.initialize().
|
||||
* The function is invoked SYNCHRONOUSLY, so it should not execute any longrunning tasks in order to not block the program.
|
||||
*
|
||||
* @param identifier An optional instance identifier
|
||||
* @returns a function to unregister the callback
|
||||
*/
|
||||
onInit(callback: OnInitCallBack<T>, identifier?: string): () => void;
|
||||
/**
|
||||
* Invoke onInit callbacks synchronously
|
||||
* @param instance the service instance`
|
||||
*/
|
||||
private invokeOnInitCallbacks;
|
||||
private getOrInitializeService;
|
||||
private normalizeInstanceIdentifier;
|
||||
private shouldAutoInitialize;
|
||||
}
|
||||
62
server/node_modules/@firebase/component/dist/esm/src/types.d.ts
generated
vendored
Normal file
62
server/node_modules/@firebase/component/dist/esm/src/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { ComponentContainer } from './component_container';
|
||||
export declare const enum InstantiationMode {
|
||||
LAZY = "LAZY",// Currently most components are LAZY in JS SDK
|
||||
EAGER = "EAGER",// EAGER components are initialized immediately upon registration
|
||||
EXPLICIT = "EXPLICIT"
|
||||
}
|
||||
/**
|
||||
* PUBLIC: A public component provides a set of public APIs to customers. A service namespace will be patched
|
||||
* onto `firebase` namespace. Assume the component name is `test`, customers will be able
|
||||
* to get the service by calling `firebase.test()` or `app.test()` where `app` is a `FirebaseApp` instance.
|
||||
*
|
||||
* PRIVATE: A private component provides a set of private APIs that are used internally by other
|
||||
* Firebase SDKs. No service namespace is created in `firebase` namespace and customers have no way to get them.
|
||||
*/
|
||||
export declare const enum ComponentType {
|
||||
PUBLIC = "PUBLIC",
|
||||
PRIVATE = "PRIVATE",
|
||||
VERSION = "VERSION"
|
||||
}
|
||||
export interface InstanceFactoryOptions {
|
||||
instanceIdentifier?: string;
|
||||
options?: {};
|
||||
}
|
||||
export type InitializeOptions = InstanceFactoryOptions;
|
||||
/**
|
||||
* Factory to create an instance of type T, given a ComponentContainer.
|
||||
* ComponentContainer is the IOC container that provides {@link Provider}
|
||||
* for dependencies.
|
||||
*
|
||||
* NOTE: The container only provides {@link Provider} rather than the actual instances of dependencies.
|
||||
* It is useful for lazily loaded dependencies and optional dependencies.
|
||||
*/
|
||||
export type InstanceFactory<T extends Name> = (container: ComponentContainer, options: InstanceFactoryOptions) => NameServiceMapping[T];
|
||||
export type onInstanceCreatedCallback<T extends Name> = (container: ComponentContainer, instanceIdentifier: string, instance: NameServiceMapping[T]) => void;
|
||||
export interface Dictionary {
|
||||
[key: string]: unknown;
|
||||
}
|
||||
/**
|
||||
* This interface will be extended by Firebase SDKs to provide service name and service type mapping.
|
||||
* It is used as a generic constraint to ensure type safety.
|
||||
*/
|
||||
export interface NameServiceMapping {
|
||||
}
|
||||
export type Name = keyof NameServiceMapping;
|
||||
export type Service = NameServiceMapping[Name];
|
||||
export type OnInitCallBack<T extends Name> = (instance: NameServiceMapping[T], identifier: string) => void;
|
||||
17
server/node_modules/@firebase/component/dist/esm/test/setup.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/component/dist/esm/test/setup.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
5
server/node_modules/@firebase/component/dist/esm/test/util.d.ts
generated
vendored
Normal file
5
server/node_modules/@firebase/component/dist/esm/test/util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { FirebaseApp } from '@firebase/app-types';
|
||||
import { InstanceFactory, InstantiationMode, Name } from '../src/types';
|
||||
import { Component } from '../src/component';
|
||||
export declare function getFakeApp(appName?: string): FirebaseApp;
|
||||
export declare function getFakeComponent<T extends Name>(name: T, factory: InstanceFactory<T>, multipleInstance?: boolean, instantiationMode?: InstantiationMode): Component<T>;
|
||||
414
server/node_modules/@firebase/component/dist/index.cjs.js
generated
vendored
Normal file
414
server/node_modules/@firebase/component/dist/index.cjs.js
generated
vendored
Normal file
@@ -0,0 +1,414 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var util = require('@firebase/util');
|
||||
|
||||
/**
|
||||
* Component for service name T, e.g. `auth`, `auth-internal`
|
||||
*/
|
||||
class Component {
|
||||
/**
|
||||
*
|
||||
* @param name The public service name, e.g. app, auth, firestore, database
|
||||
* @param instanceFactory Service factory responsible for creating the public interface
|
||||
* @param type whether the service provided by the component is public or private
|
||||
*/
|
||||
constructor(name, instanceFactory, type) {
|
||||
this.name = name;
|
||||
this.instanceFactory = instanceFactory;
|
||||
this.type = type;
|
||||
this.multipleInstances = false;
|
||||
/**
|
||||
* Properties to be added to the service namespace
|
||||
*/
|
||||
this.serviceProps = {};
|
||||
this.instantiationMode = "LAZY" /* InstantiationMode.LAZY */;
|
||||
this.onInstanceCreated = null;
|
||||
}
|
||||
setInstantiationMode(mode) {
|
||||
this.instantiationMode = mode;
|
||||
return this;
|
||||
}
|
||||
setMultipleInstances(multipleInstances) {
|
||||
this.multipleInstances = multipleInstances;
|
||||
return this;
|
||||
}
|
||||
setServiceProps(props) {
|
||||
this.serviceProps = props;
|
||||
return this;
|
||||
}
|
||||
setInstanceCreatedCallback(callback) {
|
||||
this.onInstanceCreated = callback;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
const DEFAULT_ENTRY_NAME = '[DEFAULT]';
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* Provider for instance for service name T, e.g. 'auth', 'auth-internal'
|
||||
* NameServiceMapping[T] is an alias for the type of the instance
|
||||
*/
|
||||
class Provider {
|
||||
constructor(name, container) {
|
||||
this.name = name;
|
||||
this.container = container;
|
||||
this.component = null;
|
||||
this.instances = new Map();
|
||||
this.instancesDeferred = new Map();
|
||||
this.instancesOptions = new Map();
|
||||
this.onInitCallbacks = new Map();
|
||||
}
|
||||
/**
|
||||
* @param identifier A provider can provide multiple instances of a service
|
||||
* if this.component.multipleInstances is true.
|
||||
*/
|
||||
get(identifier) {
|
||||
// if multipleInstances is not supported, use the default name
|
||||
const normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
|
||||
if (!this.instancesDeferred.has(normalizedIdentifier)) {
|
||||
const deferred = new util.Deferred();
|
||||
this.instancesDeferred.set(normalizedIdentifier, deferred);
|
||||
if (this.isInitialized(normalizedIdentifier) ||
|
||||
this.shouldAutoInitialize()) {
|
||||
// initialize the service if it can be auto-initialized
|
||||
try {
|
||||
const instance = this.getOrInitializeService({
|
||||
instanceIdentifier: normalizedIdentifier
|
||||
});
|
||||
if (instance) {
|
||||
deferred.resolve(instance);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
// when the instance factory throws an exception during get(), it should not cause
|
||||
// a fatal error. We just return the unresolved promise in this case.
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.instancesDeferred.get(normalizedIdentifier).promise;
|
||||
}
|
||||
getImmediate(options) {
|
||||
// if multipleInstances is not supported, use the default name
|
||||
const normalizedIdentifier = this.normalizeInstanceIdentifier(options?.identifier);
|
||||
const optional = options?.optional ?? false;
|
||||
if (this.isInitialized(normalizedIdentifier) ||
|
||||
this.shouldAutoInitialize()) {
|
||||
try {
|
||||
return this.getOrInitializeService({
|
||||
instanceIdentifier: normalizedIdentifier
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (optional) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// In case a component is not initialized and should/cannot be auto-initialized at the moment, return null if the optional flag is set, or throw
|
||||
if (optional) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw Error(`Service ${this.name} is not available`);
|
||||
}
|
||||
}
|
||||
}
|
||||
getComponent() {
|
||||
return this.component;
|
||||
}
|
||||
setComponent(component) {
|
||||
if (component.name !== this.name) {
|
||||
throw Error(`Mismatching Component ${component.name} for Provider ${this.name}.`);
|
||||
}
|
||||
if (this.component) {
|
||||
throw Error(`Component for ${this.name} has already been provided`);
|
||||
}
|
||||
this.component = component;
|
||||
// return early without attempting to initialize the component if the component requires explicit initialization (calling `Provider.initialize()`)
|
||||
if (!this.shouldAutoInitialize()) {
|
||||
return;
|
||||
}
|
||||
// if the service is eager, initialize the default instance
|
||||
if (isComponentEager(component)) {
|
||||
try {
|
||||
this.getOrInitializeService({ instanceIdentifier: DEFAULT_ENTRY_NAME });
|
||||
}
|
||||
catch (e) {
|
||||
// when the instance factory for an eager Component throws an exception during the eager
|
||||
// initialization, it should not cause a fatal error.
|
||||
// TODO: Investigate if we need to make it configurable, because some component may want to cause
|
||||
// a fatal error in this case?
|
||||
}
|
||||
}
|
||||
// Create service instances for the pending promises and resolve them
|
||||
// NOTE: if this.multipleInstances is false, only the default instance will be created
|
||||
// and all promises with resolve with it regardless of the identifier.
|
||||
for (const [instanceIdentifier, instanceDeferred] of this.instancesDeferred.entries()) {
|
||||
const normalizedIdentifier = this.normalizeInstanceIdentifier(instanceIdentifier);
|
||||
try {
|
||||
// `getOrInitializeService()` should always return a valid instance since a component is guaranteed. use ! to make typescript happy.
|
||||
const instance = this.getOrInitializeService({
|
||||
instanceIdentifier: normalizedIdentifier
|
||||
});
|
||||
instanceDeferred.resolve(instance);
|
||||
}
|
||||
catch (e) {
|
||||
// when the instance factory throws an exception, it should not cause
|
||||
// a fatal error. We just leave the promise unresolved.
|
||||
}
|
||||
}
|
||||
}
|
||||
clearInstance(identifier = DEFAULT_ENTRY_NAME) {
|
||||
this.instancesDeferred.delete(identifier);
|
||||
this.instancesOptions.delete(identifier);
|
||||
this.instances.delete(identifier);
|
||||
}
|
||||
// app.delete() will call this method on every provider to delete the services
|
||||
// TODO: should we mark the provider as deleted?
|
||||
async delete() {
|
||||
const services = Array.from(this.instances.values());
|
||||
await Promise.all([
|
||||
...services
|
||||
.filter(service => 'INTERNAL' in service) // legacy services
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
.map(service => service.INTERNAL.delete()),
|
||||
...services
|
||||
.filter(service => '_delete' in service) // modularized services
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
.map(service => service._delete())
|
||||
]);
|
||||
}
|
||||
isComponentSet() {
|
||||
return this.component != null;
|
||||
}
|
||||
isInitialized(identifier = DEFAULT_ENTRY_NAME) {
|
||||
return this.instances.has(identifier);
|
||||
}
|
||||
getOptions(identifier = DEFAULT_ENTRY_NAME) {
|
||||
return this.instancesOptions.get(identifier) || {};
|
||||
}
|
||||
initialize(opts = {}) {
|
||||
const { options = {} } = opts;
|
||||
const normalizedIdentifier = this.normalizeInstanceIdentifier(opts.instanceIdentifier);
|
||||
if (this.isInitialized(normalizedIdentifier)) {
|
||||
throw Error(`${this.name}(${normalizedIdentifier}) has already been initialized`);
|
||||
}
|
||||
if (!this.isComponentSet()) {
|
||||
throw Error(`Component ${this.name} has not been registered yet`);
|
||||
}
|
||||
const instance = this.getOrInitializeService({
|
||||
instanceIdentifier: normalizedIdentifier,
|
||||
options
|
||||
});
|
||||
// resolve any pending promise waiting for the service instance
|
||||
for (const [instanceIdentifier, instanceDeferred] of this.instancesDeferred.entries()) {
|
||||
const normalizedDeferredIdentifier = this.normalizeInstanceIdentifier(instanceIdentifier);
|
||||
if (normalizedIdentifier === normalizedDeferredIdentifier) {
|
||||
instanceDeferred.resolve(instance);
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param callback - a function that will be invoked after the provider has been initialized by calling provider.initialize().
|
||||
* The function is invoked SYNCHRONOUSLY, so it should not execute any longrunning tasks in order to not block the program.
|
||||
*
|
||||
* @param identifier An optional instance identifier
|
||||
* @returns a function to unregister the callback
|
||||
*/
|
||||
onInit(callback, identifier) {
|
||||
const normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
|
||||
const existingCallbacks = this.onInitCallbacks.get(normalizedIdentifier) ??
|
||||
new Set();
|
||||
existingCallbacks.add(callback);
|
||||
this.onInitCallbacks.set(normalizedIdentifier, existingCallbacks);
|
||||
const existingInstance = this.instances.get(normalizedIdentifier);
|
||||
if (existingInstance) {
|
||||
callback(existingInstance, normalizedIdentifier);
|
||||
}
|
||||
return () => {
|
||||
existingCallbacks.delete(callback);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Invoke onInit callbacks synchronously
|
||||
* @param instance the service instance`
|
||||
*/
|
||||
invokeOnInitCallbacks(instance, identifier) {
|
||||
const callbacks = this.onInitCallbacks.get(identifier);
|
||||
if (!callbacks) {
|
||||
return;
|
||||
}
|
||||
for (const callback of callbacks) {
|
||||
try {
|
||||
callback(instance, identifier);
|
||||
}
|
||||
catch {
|
||||
// ignore errors in the onInit callback
|
||||
}
|
||||
}
|
||||
}
|
||||
getOrInitializeService({ instanceIdentifier, options = {} }) {
|
||||
let instance = this.instances.get(instanceIdentifier);
|
||||
if (!instance && this.component) {
|
||||
instance = this.component.instanceFactory(this.container, {
|
||||
instanceIdentifier: normalizeIdentifierForFactory(instanceIdentifier),
|
||||
options
|
||||
});
|
||||
this.instances.set(instanceIdentifier, instance);
|
||||
this.instancesOptions.set(instanceIdentifier, options);
|
||||
/**
|
||||
* Invoke onInit listeners.
|
||||
* Note this.component.onInstanceCreated is different, which is used by the component creator,
|
||||
* while onInit listeners are registered by consumers of the provider.
|
||||
*/
|
||||
this.invokeOnInitCallbacks(instance, instanceIdentifier);
|
||||
/**
|
||||
* Order is important
|
||||
* onInstanceCreated() should be called after this.instances.set(instanceIdentifier, instance); which
|
||||
* makes `isInitialized()` return true.
|
||||
*/
|
||||
if (this.component.onInstanceCreated) {
|
||||
try {
|
||||
this.component.onInstanceCreated(this.container, instanceIdentifier, instance);
|
||||
}
|
||||
catch {
|
||||
// ignore errors in the onInstanceCreatedCallback
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance || null;
|
||||
}
|
||||
normalizeInstanceIdentifier(identifier = DEFAULT_ENTRY_NAME) {
|
||||
if (this.component) {
|
||||
return this.component.multipleInstances ? identifier : DEFAULT_ENTRY_NAME;
|
||||
}
|
||||
else {
|
||||
return identifier; // assume multiple instances are supported before the component is provided.
|
||||
}
|
||||
}
|
||||
shouldAutoInitialize() {
|
||||
return (!!this.component &&
|
||||
this.component.instantiationMode !== "EXPLICIT" /* InstantiationMode.EXPLICIT */);
|
||||
}
|
||||
}
|
||||
// undefined should be passed to the service factory for the default instance
|
||||
function normalizeIdentifierForFactory(identifier) {
|
||||
return identifier === DEFAULT_ENTRY_NAME ? undefined : identifier;
|
||||
}
|
||||
function isComponentEager(component) {
|
||||
return component.instantiationMode === "EAGER" /* InstantiationMode.EAGER */;
|
||||
}
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* ComponentContainer that provides Providers for service name T, e.g. `auth`, `auth-internal`
|
||||
*/
|
||||
class ComponentContainer {
|
||||
constructor(name) {
|
||||
this.name = name;
|
||||
this.providers = new Map();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component Component being added
|
||||
* @param overwrite When a component with the same name has already been registered,
|
||||
* if overwrite is true: overwrite the existing component with the new component and create a new
|
||||
* provider with the new component. It can be useful in tests where you want to use different mocks
|
||||
* for different tests.
|
||||
* if overwrite is false: throw an exception
|
||||
*/
|
||||
addComponent(component) {
|
||||
const provider = this.getProvider(component.name);
|
||||
if (provider.isComponentSet()) {
|
||||
throw new Error(`Component ${component.name} has already been registered with ${this.name}`);
|
||||
}
|
||||
provider.setComponent(component);
|
||||
}
|
||||
addOrOverwriteComponent(component) {
|
||||
const provider = this.getProvider(component.name);
|
||||
if (provider.isComponentSet()) {
|
||||
// delete the existing provider from the container, so we can register the new component
|
||||
this.providers.delete(component.name);
|
||||
}
|
||||
this.addComponent(component);
|
||||
}
|
||||
/**
|
||||
* getProvider provides a type safe interface where it can only be called with a field name
|
||||
* present in NameServiceMapping interface.
|
||||
*
|
||||
* Firebase SDKs providing services should extend NameServiceMapping interface to register
|
||||
* themselves.
|
||||
*/
|
||||
getProvider(name) {
|
||||
if (this.providers.has(name)) {
|
||||
return this.providers.get(name);
|
||||
}
|
||||
// create a Provider for a service that hasn't registered with Firebase
|
||||
const provider = new Provider(name, this);
|
||||
this.providers.set(name, provider);
|
||||
return provider;
|
||||
}
|
||||
getProviders() {
|
||||
return Array.from(this.providers.values());
|
||||
}
|
||||
}
|
||||
|
||||
exports.Component = Component;
|
||||
exports.ComponentContainer = ComponentContainer;
|
||||
exports.Provider = Provider;
|
||||
//# sourceMappingURL=index.cjs.js.map
|
||||
1
server/node_modules/@firebase/component/dist/index.cjs.js.map
generated
vendored
Normal file
1
server/node_modules/@firebase/component/dist/index.cjs.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
20
server/node_modules/@firebase/component/dist/index.d.ts
generated
vendored
Normal file
20
server/node_modules/@firebase/component/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export { Component } from './src/component';
|
||||
export { ComponentContainer } from './src/component_container';
|
||||
export { Provider } from './src/provider';
|
||||
export { ComponentType, InstanceFactory, InstantiationMode, NameServiceMapping, Name, InstanceFactoryOptions } from './src/types';
|
||||
43
server/node_modules/@firebase/component/dist/src/component.d.ts
generated
vendored
Normal file
43
server/node_modules/@firebase/component/dist/src/component.d.ts
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { InstantiationMode, InstanceFactory, ComponentType, Dictionary, Name, onInstanceCreatedCallback } from './types';
|
||||
/**
|
||||
* Component for service name T, e.g. `auth`, `auth-internal`
|
||||
*/
|
||||
export declare class Component<T extends Name = Name> {
|
||||
readonly name: T;
|
||||
readonly instanceFactory: InstanceFactory<T>;
|
||||
readonly type: ComponentType;
|
||||
multipleInstances: boolean;
|
||||
/**
|
||||
* Properties to be added to the service namespace
|
||||
*/
|
||||
serviceProps: Dictionary;
|
||||
instantiationMode: InstantiationMode;
|
||||
onInstanceCreated: onInstanceCreatedCallback<T> | null;
|
||||
/**
|
||||
*
|
||||
* @param name The public service name, e.g. app, auth, firestore, database
|
||||
* @param instanceFactory Service factory responsible for creating the public interface
|
||||
* @param type whether the service provided by the component is public or private
|
||||
*/
|
||||
constructor(name: T, instanceFactory: InstanceFactory<T>, type: ComponentType);
|
||||
setInstantiationMode(mode: InstantiationMode): this;
|
||||
setMultipleInstances(multipleInstances: boolean): this;
|
||||
setServiceProps(props: Dictionary): this;
|
||||
setInstanceCreatedCallback(callback: onInstanceCreatedCallback<T>): this;
|
||||
}
|
||||
47
server/node_modules/@firebase/component/dist/src/component_container.d.ts
generated
vendored
Normal file
47
server/node_modules/@firebase/component/dist/src/component_container.d.ts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Provider } from './provider';
|
||||
import { Component } from './component';
|
||||
import { Name } from './types';
|
||||
/**
|
||||
* ComponentContainer that provides Providers for service name T, e.g. `auth`, `auth-internal`
|
||||
*/
|
||||
export declare class ComponentContainer {
|
||||
private readonly name;
|
||||
private readonly providers;
|
||||
constructor(name: string);
|
||||
/**
|
||||
*
|
||||
* @param component Component being added
|
||||
* @param overwrite When a component with the same name has already been registered,
|
||||
* if overwrite is true: overwrite the existing component with the new component and create a new
|
||||
* provider with the new component. It can be useful in tests where you want to use different mocks
|
||||
* for different tests.
|
||||
* if overwrite is false: throw an exception
|
||||
*/
|
||||
addComponent<T extends Name>(component: Component<T>): void;
|
||||
addOrOverwriteComponent<T extends Name>(component: Component<T>): void;
|
||||
/**
|
||||
* getProvider provides a type safe interface where it can only be called with a field name
|
||||
* present in NameServiceMapping interface.
|
||||
*
|
||||
* Firebase SDKs providing services should extend NameServiceMapping interface to register
|
||||
* themselves.
|
||||
*/
|
||||
getProvider<T extends Name>(name: T): Provider<T>;
|
||||
getProviders(): Array<Provider<Name>>;
|
||||
}
|
||||
17
server/node_modules/@firebase/component/dist/src/constants.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/component/dist/src/constants.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export declare const DEFAULT_ENTRY_NAME = "[DEFAULT]";
|
||||
79
server/node_modules/@firebase/component/dist/src/provider.d.ts
generated
vendored
Normal file
79
server/node_modules/@firebase/component/dist/src/provider.d.ts
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { ComponentContainer } from './component_container';
|
||||
import { InitializeOptions, Name, NameServiceMapping, OnInitCallBack } from './types';
|
||||
import { Component } from './component';
|
||||
/**
|
||||
* Provider for instance for service name T, e.g. 'auth', 'auth-internal'
|
||||
* NameServiceMapping[T] is an alias for the type of the instance
|
||||
*/
|
||||
export declare class Provider<T extends Name> {
|
||||
private readonly name;
|
||||
private readonly container;
|
||||
private component;
|
||||
private readonly instances;
|
||||
private readonly instancesDeferred;
|
||||
private readonly instancesOptions;
|
||||
private onInitCallbacks;
|
||||
constructor(name: T, container: ComponentContainer);
|
||||
/**
|
||||
* @param identifier A provider can provide multiple instances of a service
|
||||
* if this.component.multipleInstances is true.
|
||||
*/
|
||||
get(identifier?: string): Promise<NameServiceMapping[T]>;
|
||||
/**
|
||||
*
|
||||
* @param options.identifier A provider can provide multiple instances of a service
|
||||
* if this.component.multipleInstances is true.
|
||||
* @param options.optional If optional is false or not provided, the method throws an error when
|
||||
* the service is not immediately available.
|
||||
* If optional is true, the method returns null if the service is not immediately available.
|
||||
*/
|
||||
getImmediate(options: {
|
||||
identifier?: string;
|
||||
optional: true;
|
||||
}): NameServiceMapping[T] | null;
|
||||
getImmediate(options?: {
|
||||
identifier?: string;
|
||||
optional?: false;
|
||||
}): NameServiceMapping[T];
|
||||
getComponent(): Component<T> | null;
|
||||
setComponent(component: Component<T>): void;
|
||||
clearInstance(identifier?: string): void;
|
||||
delete(): Promise<void>;
|
||||
isComponentSet(): boolean;
|
||||
isInitialized(identifier?: string): boolean;
|
||||
getOptions(identifier?: string): Record<string, unknown>;
|
||||
initialize(opts?: InitializeOptions): NameServiceMapping[T];
|
||||
/**
|
||||
*
|
||||
* @param callback - a function that will be invoked after the provider has been initialized by calling provider.initialize().
|
||||
* The function is invoked SYNCHRONOUSLY, so it should not execute any longrunning tasks in order to not block the program.
|
||||
*
|
||||
* @param identifier An optional instance identifier
|
||||
* @returns a function to unregister the callback
|
||||
*/
|
||||
onInit(callback: OnInitCallBack<T>, identifier?: string): () => void;
|
||||
/**
|
||||
* Invoke onInit callbacks synchronously
|
||||
* @param instance the service instance`
|
||||
*/
|
||||
private invokeOnInitCallbacks;
|
||||
private getOrInitializeService;
|
||||
private normalizeInstanceIdentifier;
|
||||
private shouldAutoInitialize;
|
||||
}
|
||||
62
server/node_modules/@firebase/component/dist/src/types.d.ts
generated
vendored
Normal file
62
server/node_modules/@firebase/component/dist/src/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { ComponentContainer } from './component_container';
|
||||
export declare const enum InstantiationMode {
|
||||
LAZY = "LAZY",// Currently most components are LAZY in JS SDK
|
||||
EAGER = "EAGER",// EAGER components are initialized immediately upon registration
|
||||
EXPLICIT = "EXPLICIT"
|
||||
}
|
||||
/**
|
||||
* PUBLIC: A public component provides a set of public APIs to customers. A service namespace will be patched
|
||||
* onto `firebase` namespace. Assume the component name is `test`, customers will be able
|
||||
* to get the service by calling `firebase.test()` or `app.test()` where `app` is a `FirebaseApp` instance.
|
||||
*
|
||||
* PRIVATE: A private component provides a set of private APIs that are used internally by other
|
||||
* Firebase SDKs. No service namespace is created in `firebase` namespace and customers have no way to get them.
|
||||
*/
|
||||
export declare const enum ComponentType {
|
||||
PUBLIC = "PUBLIC",
|
||||
PRIVATE = "PRIVATE",
|
||||
VERSION = "VERSION"
|
||||
}
|
||||
export interface InstanceFactoryOptions {
|
||||
instanceIdentifier?: string;
|
||||
options?: {};
|
||||
}
|
||||
export type InitializeOptions = InstanceFactoryOptions;
|
||||
/**
|
||||
* Factory to create an instance of type T, given a ComponentContainer.
|
||||
* ComponentContainer is the IOC container that provides {@link Provider}
|
||||
* for dependencies.
|
||||
*
|
||||
* NOTE: The container only provides {@link Provider} rather than the actual instances of dependencies.
|
||||
* It is useful for lazily loaded dependencies and optional dependencies.
|
||||
*/
|
||||
export type InstanceFactory<T extends Name> = (container: ComponentContainer, options: InstanceFactoryOptions) => NameServiceMapping[T];
|
||||
export type onInstanceCreatedCallback<T extends Name> = (container: ComponentContainer, instanceIdentifier: string, instance: NameServiceMapping[T]) => void;
|
||||
export interface Dictionary {
|
||||
[key: string]: unknown;
|
||||
}
|
||||
/**
|
||||
* This interface will be extended by Firebase SDKs to provide service name and service type mapping.
|
||||
* It is used as a generic constraint to ensure type safety.
|
||||
*/
|
||||
export interface NameServiceMapping {
|
||||
}
|
||||
export type Name = keyof NameServiceMapping;
|
||||
export type Service = NameServiceMapping[Name];
|
||||
export type OnInitCallBack<T extends Name> = (instance: NameServiceMapping[T], identifier: string) => void;
|
||||
17
server/node_modules/@firebase/component/dist/test/setup.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/component/dist/test/setup.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
5
server/node_modules/@firebase/component/dist/test/util.d.ts
generated
vendored
Normal file
5
server/node_modules/@firebase/component/dist/test/util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { FirebaseApp } from '@firebase/app-types';
|
||||
import { InstanceFactory, InstantiationMode, Name } from '../src/types';
|
||||
import { Component } from '../src/component';
|
||||
export declare function getFakeApp(appName?: string): FirebaseApp;
|
||||
export declare function getFakeComponent<T extends Name>(name: T, factory: InstanceFactory<T>, multipleInstance?: boolean, instantiationMode?: InstantiationMode): Component<T>;
|
||||
61
server/node_modules/@firebase/component/package.json
generated
vendored
Normal file
61
server/node_modules/@firebase/component/package.json
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"name": "@firebase/component",
|
||||
"version": "0.7.0",
|
||||
"description": "Firebase Component Platform",
|
||||
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
||||
"main": "dist/index.cjs.js",
|
||||
"browser": "dist/esm/index.esm.js",
|
||||
"module": "dist/esm/index.esm.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"require": "./dist/index.cjs.js",
|
||||
"default": "./dist/esm/index.esm.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
|
||||
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
|
||||
"build": "rollup -c",
|
||||
"build:deps": "lerna run --scope @firebase/component --include-dependencies build",
|
||||
"dev": "rollup -c -w",
|
||||
"test": "run-p --npm-path npm lint test:all",
|
||||
"test:all": "run-p --npm-path npm test:browser test:node",
|
||||
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:all",
|
||||
"test:browser": "karma start",
|
||||
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha src/**/*.test.ts --config ../../config/mocharc.node.js",
|
||||
"trusted-type-check": "tsec -p tsconfig.json --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@firebase/util": "1.13.0",
|
||||
"tslib": "^2.1.0"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"rollup": "2.79.2",
|
||||
"rollup-plugin-typescript2": "0.36.0",
|
||||
"typescript": "5.5.4"
|
||||
},
|
||||
"repository": {
|
||||
"directory": "packages/component",
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/firebase/firebase-js-sdk.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/firebase/firebase-js-sdk/issues"
|
||||
},
|
||||
"typings": "dist/index.d.ts",
|
||||
"nyc": {
|
||||
"extension": [
|
||||
".ts"
|
||||
],
|
||||
"reportDir": "./coverage/node"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
}
|
||||
}
|
||||
5
server/node_modules/@firebase/database-compat/README.md
generated
vendored
Normal file
5
server/node_modules/@firebase/database-compat/README.md
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
# @firebase/database-compat
|
||||
|
||||
This is the compatibility layer for the Firebase Realtime Database component of the Firebase JS SDK.
|
||||
|
||||
**This package is not intended for direct usage, and should only be used via the officially supported [firebase](https://www.npmjs.com/package/firebase) package.**
|
||||
74
server/node_modules/@firebase/database-compat/dist/database-compat/src/api/Database.d.ts
generated
vendored
Normal file
74
server/node_modules/@firebase/database-compat/dist/database-compat/src/api/Database.d.ts
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { FirebaseApp } from '@firebase/app-types';
|
||||
import { FirebaseService } from '@firebase/app-types/private';
|
||||
import { forceLongPolling, forceWebSockets, Database as ModularDatabase } from '@firebase/database';
|
||||
import { Compat, EmulatorMockTokenOptions } from '@firebase/util';
|
||||
import { Reference } from './Reference';
|
||||
/**
|
||||
* Class representing a firebase database.
|
||||
*/
|
||||
export declare class Database implements FirebaseService, Compat<ModularDatabase> {
|
||||
readonly _delegate: ModularDatabase;
|
||||
readonly app: FirebaseApp;
|
||||
static readonly ServerValue: {
|
||||
TIMESTAMP: object;
|
||||
increment: (delta: number) => object;
|
||||
};
|
||||
/**
|
||||
* The constructor should not be called by users of our public API.
|
||||
*/
|
||||
constructor(_delegate: ModularDatabase, app: FirebaseApp);
|
||||
INTERNAL: {
|
||||
delete: () => Promise<void>;
|
||||
forceWebSockets: typeof forceWebSockets;
|
||||
forceLongPolling: typeof forceLongPolling;
|
||||
};
|
||||
/**
|
||||
* Modify this instance to communicate with the Realtime Database emulator.
|
||||
*
|
||||
* <p>Note: This method must be called before performing any other operation.
|
||||
*
|
||||
* @param host - the emulator host (ex: localhost)
|
||||
* @param port - the emulator port (ex: 8080)
|
||||
* @param options.mockUserToken - the mock auth token to use for unit testing Security Rules
|
||||
*/
|
||||
useEmulator(host: string, port: number, options?: {
|
||||
mockUserToken?: EmulatorMockTokenOptions;
|
||||
}): void;
|
||||
/**
|
||||
* Returns a reference to the root or to the path specified in the provided
|
||||
* argument.
|
||||
*
|
||||
* @param path - The relative string path or an existing Reference to a database
|
||||
* location.
|
||||
* @throws If a Reference is provided, throws if it does not belong to the
|
||||
* same project.
|
||||
* @returns Firebase reference.
|
||||
*/
|
||||
ref(path?: string): Reference;
|
||||
ref(path?: Reference): Reference;
|
||||
/**
|
||||
* Returns a reference to the root or the path specified in url.
|
||||
* We throw a exception if the url is not in the same domain as the
|
||||
* current repo.
|
||||
* @returns Firebase reference.
|
||||
*/
|
||||
refFromURL(url: string): Reference;
|
||||
goOffline(): void;
|
||||
goOnline(): void;
|
||||
}
|
||||
207
server/node_modules/@firebase/database-compat/dist/database-compat/src/api/Reference.d.ts
generated
vendored
Normal file
207
server/node_modules/@firebase/database-compat/dist/database-compat/src/api/Reference.d.ts
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { DataSnapshot as ModularDataSnapshot, Query as ExpQuery, DatabaseReference as ModularReference } from '@firebase/database';
|
||||
import { Compat } from '@firebase/util';
|
||||
import { Database } from './Database';
|
||||
import { OnDisconnect } from './onDisconnect';
|
||||
import { TransactionResult } from './TransactionResult';
|
||||
/**
|
||||
* Class representing a firebase data snapshot. It wraps a SnapshotNode and
|
||||
* surfaces the public methods (val, forEach, etc.) we want to expose.
|
||||
*/
|
||||
export declare class DataSnapshot implements Compat<ModularDataSnapshot> {
|
||||
readonly _database: Database;
|
||||
readonly _delegate: ModularDataSnapshot;
|
||||
constructor(_database: Database, _delegate: ModularDataSnapshot);
|
||||
/**
|
||||
* Retrieves the snapshot contents as JSON. Returns null if the snapshot is
|
||||
* empty.
|
||||
*
|
||||
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
||||
*/
|
||||
val(): unknown;
|
||||
/**
|
||||
* Returns the snapshot contents as JSON, including priorities of node. Suitable for exporting
|
||||
* the entire node contents.
|
||||
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
||||
*/
|
||||
exportVal(): unknown;
|
||||
toJSON(): unknown;
|
||||
/**
|
||||
* Returns whether the snapshot contains a non-null value.
|
||||
*
|
||||
* @returns Whether the snapshot contains a non-null value, or is empty.
|
||||
*/
|
||||
exists(): boolean;
|
||||
/**
|
||||
* Returns a DataSnapshot of the specified child node's contents.
|
||||
*
|
||||
* @param path - Path to a child.
|
||||
* @returns DataSnapshot for child node.
|
||||
*/
|
||||
child(path: string): DataSnapshot;
|
||||
/**
|
||||
* Returns whether the snapshot contains a child at the specified path.
|
||||
*
|
||||
* @param path - Path to a child.
|
||||
* @returns Whether the child exists.
|
||||
*/
|
||||
hasChild(path: string): boolean;
|
||||
/**
|
||||
* Returns the priority of the object, or null if no priority was set.
|
||||
*
|
||||
* @returns The priority.
|
||||
*/
|
||||
getPriority(): string | number | null;
|
||||
/**
|
||||
* Iterates through child nodes and calls the specified action for each one.
|
||||
*
|
||||
* @param action - Callback function to be called
|
||||
* for each child.
|
||||
* @returns True if forEach was canceled by action returning true for
|
||||
* one of the child nodes.
|
||||
*/
|
||||
forEach(action: (snapshot: IteratedDataSnapshot) => boolean | void): boolean;
|
||||
/**
|
||||
* Returns whether this DataSnapshot has children.
|
||||
* @returns True if the DataSnapshot contains 1 or more child nodes.
|
||||
*/
|
||||
hasChildren(): boolean;
|
||||
get key(): string;
|
||||
/**
|
||||
* Returns the number of children for this DataSnapshot.
|
||||
* @returns The number of children that this DataSnapshot contains.
|
||||
*/
|
||||
numChildren(): number;
|
||||
/**
|
||||
* @returns The Firebase reference for the location this snapshot's data came
|
||||
* from.
|
||||
*/
|
||||
getRef(): Reference;
|
||||
get ref(): Reference;
|
||||
}
|
||||
/**
|
||||
* Represents a child snapshot of a `Reference` that is being iterated over. The key will never be undefined.
|
||||
*/
|
||||
export interface IteratedDataSnapshot extends DataSnapshot {
|
||||
key: string;
|
||||
}
|
||||
export interface SnapshotCallback {
|
||||
(dataSnapshot: DataSnapshot, previousChildName?: string | null): unknown;
|
||||
}
|
||||
/**
|
||||
* A Query represents a filter to be applied to a firebase location. This object purely represents the
|
||||
* query expression (and exposes our public API to build the query). The actual query logic is in ViewBase.js.
|
||||
*
|
||||
* Since every Firebase reference is a query, Firebase inherits from this object.
|
||||
*/
|
||||
export declare class Query implements Compat<ExpQuery> {
|
||||
readonly database: Database;
|
||||
readonly _delegate: ExpQuery;
|
||||
constructor(database: Database, _delegate: ExpQuery);
|
||||
on(eventType: string, callback: SnapshotCallback, cancelCallbackOrContext?: ((a: Error) => unknown) | object | null, context?: object | null): SnapshotCallback;
|
||||
off(eventType?: string, callback?: SnapshotCallback, context?: object | null): void;
|
||||
/**
|
||||
* Get the server-value for this query, or return a cached value if not connected.
|
||||
*/
|
||||
get(): Promise<DataSnapshot>;
|
||||
/**
|
||||
* Attaches a listener, waits for the first event, and then removes the listener
|
||||
*/
|
||||
once(eventType: string, callback?: SnapshotCallback, failureCallbackOrContext?: ((a: Error) => void) | object | null, context?: object | null): Promise<DataSnapshot>;
|
||||
/**
|
||||
* Set a limit and anchor it to the start of the window.
|
||||
*/
|
||||
limitToFirst(limit: number): Query;
|
||||
/**
|
||||
* Set a limit and anchor it to the end of the window.
|
||||
*/
|
||||
limitToLast(limit: number): Query;
|
||||
/**
|
||||
* Given a child path, return a new query ordered by the specified grandchild path.
|
||||
*/
|
||||
orderByChild(path: string): Query;
|
||||
/**
|
||||
* Return a new query ordered by the KeyIndex
|
||||
*/
|
||||
orderByKey(): Query;
|
||||
/**
|
||||
* Return a new query ordered by the PriorityIndex
|
||||
*/
|
||||
orderByPriority(): Query;
|
||||
/**
|
||||
* Return a new query ordered by the ValueIndex
|
||||
*/
|
||||
orderByValue(): Query;
|
||||
startAt(value?: number | string | boolean | null, name?: string | null): Query;
|
||||
startAfter(value?: number | string | boolean | null, name?: string | null): Query;
|
||||
endAt(value?: number | string | boolean | null, name?: string | null): Query;
|
||||
endBefore(value?: number | string | boolean | null, name?: string | null): Query;
|
||||
/**
|
||||
* Load the selection of children with exactly the specified value, and, optionally,
|
||||
* the specified name.
|
||||
*/
|
||||
equalTo(value: number | string | boolean | null, name?: string): Query;
|
||||
/**
|
||||
* @returns URL for this location.
|
||||
*/
|
||||
toString(): string;
|
||||
toJSON(): string;
|
||||
/**
|
||||
* Return true if this query and the provided query are equivalent; otherwise, return false.
|
||||
*/
|
||||
isEqual(other: Query): boolean;
|
||||
/**
|
||||
* Helper used by .on and .once to extract the context and or cancel arguments.
|
||||
* @param fnName - The function name (on or once)
|
||||
*
|
||||
*/
|
||||
private static getCancelAndContextArgs_;
|
||||
get ref(): Reference;
|
||||
}
|
||||
export declare class Reference extends Query implements Compat<ModularReference> {
|
||||
readonly database: Database;
|
||||
readonly _delegate: ModularReference;
|
||||
then: Promise<Reference>['then'];
|
||||
catch: Promise<Reference>['catch'];
|
||||
/**
|
||||
* Call options:
|
||||
* new Reference(Repo, Path) or
|
||||
* new Reference(url: string, string|RepoManager)
|
||||
*
|
||||
* Externally - this is the firebase.database.Reference type.
|
||||
*/
|
||||
constructor(database: Database, _delegate: ModularReference);
|
||||
/** @returns {?string} */
|
||||
getKey(): string | null;
|
||||
child(pathString: string): Reference;
|
||||
/** @returns {?Reference} */
|
||||
getParent(): Reference | null;
|
||||
/** @returns {!Reference} */
|
||||
getRoot(): Reference;
|
||||
set(newVal: unknown, onComplete?: (error: Error | null) => void): Promise<void>;
|
||||
update(values: object, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
setWithPriority(newVal: unknown, newPriority: string | number | null, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
remove(onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
transaction(transactionUpdate: (currentData: unknown) => unknown, onComplete?: (error: Error | null, committed: boolean, dataSnapshot: DataSnapshot | null) => void, applyLocally?: boolean): Promise<TransactionResult>;
|
||||
setPriority(priority: string | number | null, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
push(value?: unknown, onComplete?: (a: Error | null) => void): Reference;
|
||||
onDisconnect(): OnDisconnect;
|
||||
get key(): string | null;
|
||||
get parent(): Reference | null;
|
||||
get root(): Reference;
|
||||
}
|
||||
26
server/node_modules/@firebase/database-compat/dist/database-compat/src/api/TransactionResult.d.ts
generated
vendored
Normal file
26
server/node_modules/@firebase/database-compat/dist/database-compat/src/api/TransactionResult.d.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { DataSnapshot } from './Reference';
|
||||
export declare class TransactionResult {
|
||||
committed: boolean;
|
||||
snapshot: DataSnapshot;
|
||||
/**
|
||||
* A type for the resolve value of Firebase.transaction.
|
||||
*/
|
||||
constructor(committed: boolean, snapshot: DataSnapshot);
|
||||
toJSON(): object;
|
||||
}
|
||||
41
server/node_modules/@firebase/database-compat/dist/database-compat/src/api/internal.d.ts
generated
vendored
Normal file
41
server/node_modules/@firebase/database-compat/dist/database-compat/src/api/internal.d.ts
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { FirebaseAppCheckInternal } from '@firebase/app-check-interop-types';
|
||||
import { FirebaseApp } from '@firebase/app-types';
|
||||
import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
|
||||
import * as types from '@firebase/database-types';
|
||||
/**
|
||||
* Used by console to create a database based on the app,
|
||||
* passed database URL and a custom auth implementation.
|
||||
*
|
||||
* @param app - A valid FirebaseApp-like object
|
||||
* @param url - A valid Firebase databaseURL
|
||||
* @param version - custom version e.g. firebase-admin version
|
||||
* @param customAuthImpl - custom auth implementation
|
||||
*/
|
||||
export declare function initStandalone<T>({ app, url, version, customAuthImpl, customAppCheckImpl, namespace, nodeAdmin }: {
|
||||
app: FirebaseApp;
|
||||
url: string;
|
||||
version: string;
|
||||
customAuthImpl: FirebaseAuthInternal;
|
||||
customAppCheckImpl?: FirebaseAppCheckInternal;
|
||||
namespace: T;
|
||||
nodeAdmin?: boolean;
|
||||
}): {
|
||||
instance: types.Database;
|
||||
namespace: T;
|
||||
};
|
||||
27
server/node_modules/@firebase/database-compat/dist/database-compat/src/api/onDisconnect.d.ts
generated
vendored
Normal file
27
server/node_modules/@firebase/database-compat/dist/database-compat/src/api/onDisconnect.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { OnDisconnect as ModularOnDisconnect } from '@firebase/database';
|
||||
import { Compat } from '@firebase/util';
|
||||
export declare class OnDisconnect implements Compat<ModularOnDisconnect> {
|
||||
readonly _delegate: ModularOnDisconnect;
|
||||
constructor(_delegate: ModularOnDisconnect);
|
||||
cancel(onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
remove(onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
set(value: unknown, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
setWithPriority(value: unknown, priority: number | string | null, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
update(objectToMerge: Record<string, unknown>, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
}
|
||||
72
server/node_modules/@firebase/database-compat/dist/database-compat/src/index.d.ts
generated
vendored
Normal file
72
server/node_modules/@firebase/database-compat/dist/database-compat/src/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { FirebaseNamespace } from '@firebase/app-compat';
|
||||
import * as types from '@firebase/database-types';
|
||||
export declare function registerDatabase(instance: FirebaseNamespace): void;
|
||||
declare module '@firebase/app-compat' {
|
||||
interface FirebaseNamespace {
|
||||
database?: {
|
||||
(app?: FirebaseApp): types.FirebaseDatabase;
|
||||
enableLogging: typeof types.enableLogging;
|
||||
ServerValue: types.ServerValue;
|
||||
Database: typeof types.FirebaseDatabase;
|
||||
};
|
||||
}
|
||||
interface FirebaseApp {
|
||||
database?(databaseURL?: string): types.FirebaseDatabase;
|
||||
}
|
||||
}
|
||||
|
||||
import { FirebaseApp as FirebaseAppCompat } from "@firebase/app-compat";
|
||||
import { type DatabaseReference, type EmulatorMockTokenOptions, type DataSnapshot, type Database, type EventType, type Unsubscribe, type ListenOptions, type OnDisconnect, type ThenableReference, type QueryConstraint, type Query, type TransactionOptions, type TransactionResult } from "@firebase/database";
|
||||
declare module "@firebase/database" {
|
||||
function child(parent: types.Reference, path: string): DatabaseReference;
|
||||
function connectDatabaseEmulator(db: types.FirebaseDatabase, host: string, port: number, options?: {
|
||||
mockUserToken?: EmulatorMockTokenOptions | string;
|
||||
}): void;
|
||||
function get(query: types.Query): Promise<DataSnapshot>;
|
||||
function getDatabase(app?: FirebaseAppCompat, url?: string): Database;
|
||||
function goOffline(db: types.FirebaseDatabase): void;
|
||||
function goOnline(db: types.FirebaseDatabase): void;
|
||||
function off(query: types.Query, eventType?: EventType, callback?: (snapshot: DataSnapshot, previousChildName?: string | null) => unknown): void;
|
||||
function onChildAdded(query: types.Query, callback: (snapshot: DataSnapshot, previousChildName?: string | null) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
|
||||
function onChildAdded(query: types.Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;
|
||||
function onChildAdded(query: types.Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
|
||||
function onChildChanged(query: types.Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
|
||||
function onChildChanged(query: types.Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;
|
||||
function onChildChanged(query: types.Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
|
||||
function onChildMoved(query: types.Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
|
||||
function onChildMoved(query: types.Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;
|
||||
function onChildMoved(query: types.Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
|
||||
function onChildRemoved(query: types.Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
|
||||
function onChildRemoved(query: types.Query, callback: (snapshot: DataSnapshot) => unknown, options: ListenOptions): Unsubscribe;
|
||||
function onChildRemoved(query: types.Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
|
||||
function onDisconnect(ref: types.Reference): OnDisconnect;
|
||||
function onValue(query: types.Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
|
||||
function onValue(query: types.Query, callback: (snapshot: DataSnapshot) => unknown, options: ListenOptions): Unsubscribe;
|
||||
function onValue(query: types.Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
|
||||
function push(parent: types.Reference, value?: unknown): ThenableReference;
|
||||
function query(query: types.Query, ...queryConstraints: QueryConstraint[]): Query;
|
||||
function ref(db: types.FirebaseDatabase, path?: string): DatabaseReference;
|
||||
function refFromURL(db: types.FirebaseDatabase, url: string): DatabaseReference;
|
||||
function remove(ref: types.Reference): Promise<void>;
|
||||
function runTransaction(ref: types.Reference, transactionUpdate: (currentData: any) => unknown, options?: TransactionOptions): Promise<TransactionResult>;
|
||||
function set(ref: types.Reference, value: unknown): Promise<void>;
|
||||
function setPriority(ref: types.Reference, priority: string | number | null): Promise<void>;
|
||||
function setWithPriority(ref: types.Reference, value: unknown, priority: string | number | null): Promise<void>;
|
||||
function update(ref: types.Reference, values: object): Promise<void>;
|
||||
}
|
||||
30
server/node_modules/@firebase/database-compat/dist/database-compat/src/index.node.d.ts
generated
vendored
Normal file
30
server/node_modules/@firebase/database-compat/dist/database-compat/src/index.node.d.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import * as types from '@firebase/database-types';
|
||||
declare module '@firebase/app-compat' {
|
||||
interface FirebaseNamespace {
|
||||
database?: {
|
||||
(app?: FirebaseApp): types.FirebaseDatabase;
|
||||
enableLogging: typeof types.enableLogging;
|
||||
ServerValue: types.ServerValue;
|
||||
Database: typeof types.FirebaseDatabase;
|
||||
};
|
||||
}
|
||||
interface FirebaseApp {
|
||||
database?(): types.FirebaseDatabase;
|
||||
}
|
||||
}
|
||||
52
server/node_modules/@firebase/database-compat/dist/database-compat/src/index.standalone.d.ts
generated
vendored
Normal file
52
server/node_modules/@firebase/database-compat/dist/database-compat/src/index.standalone.d.ts
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { FirebaseApp } from '@firebase/app-types';
|
||||
import { enableLogging } from '@firebase/database';
|
||||
import { Database } from './api/Database';
|
||||
import * as INTERNAL from './api/internal';
|
||||
import { DataSnapshot, Query, Reference } from './api/Reference';
|
||||
declare const ServerValue: {
|
||||
TIMESTAMP: object;
|
||||
increment: (delta: number) => object;
|
||||
};
|
||||
/**
|
||||
* A one off register function which returns a database based on the app and
|
||||
* passed database URL. (Used by the Admin SDK)
|
||||
*
|
||||
* @param app - A valid FirebaseApp-like object
|
||||
* @param url - A valid Firebase databaseURL
|
||||
* @param version - custom version e.g. firebase-admin version
|
||||
* @param nodeAdmin - true if the SDK is being initialized from Firebase Admin.
|
||||
*/
|
||||
export declare function initStandalone(app: FirebaseApp, url: string, version: string, nodeAdmin?: boolean): {
|
||||
instance: import("@firebase/database-types").Database;
|
||||
namespace: {
|
||||
Reference: typeof Reference;
|
||||
Query: typeof Query;
|
||||
Database: typeof Database;
|
||||
DataSnapshot: typeof DataSnapshot;
|
||||
enableLogging: typeof enableLogging;
|
||||
INTERNAL: typeof INTERNAL;
|
||||
ServerValue: {
|
||||
TIMESTAMP: object;
|
||||
increment: (delta: number) => object;
|
||||
};
|
||||
};
|
||||
};
|
||||
export { Database, Query, Reference, enableLogging, ServerValue };
|
||||
export { OnDisconnect } from '@firebase/database';
|
||||
export { DataSnapshot } from './api/Reference';
|
||||
17
server/node_modules/@firebase/database-compat/dist/database-compat/src/util/util.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/database-compat/src/util/util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export declare const warn: (msg: string) => void;
|
||||
18
server/node_modules/@firebase/database-compat/dist/database-compat/src/util/validation.d.ts
generated
vendored
Normal file
18
server/node_modules/@firebase/database-compat/dist/database-compat/src/util/validation.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export declare const validateBoolean: (fnName: string, argumentName: string, bool: unknown, optional: boolean) => void;
|
||||
export declare const validateEventType: (fnName: string, eventType: string, optional: boolean) => void;
|
||||
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/browser/crawler_support.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/browser/crawler_support.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/database.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/database.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import '../src/index';
|
||||
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/datasnapshot.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/datasnapshot.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
34
server/node_modules/@firebase/database-compat/dist/database-compat/test/helpers/events.d.ts
generated
vendored
Normal file
34
server/node_modules/@firebase/database-compat/dist/database-compat/test/helpers/events.d.ts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* A set of functions to clean up event handlers.
|
||||
*/
|
||||
export declare let eventCleanupHandlers: any[];
|
||||
/** Clean up outstanding event handlers */
|
||||
export declare function eventCleanup(): void;
|
||||
/**
|
||||
* Creates a struct which waits for many events.
|
||||
* @param pathAndEvents - an array of tuples of [Firebase, [event type strings]]
|
||||
*/
|
||||
export declare function eventTestHelper(pathAndEvents: any, helperName?: any): {
|
||||
promise: Promise<unknown>;
|
||||
initPromise: Promise<unknown>;
|
||||
waiter: () => boolean;
|
||||
watchesInitializedWaiter: () => boolean;
|
||||
unregister: () => void;
|
||||
addExpectedEvents(moreEvents: any): void;
|
||||
};
|
||||
42
server/node_modules/@firebase/database-compat/dist/database-compat/test/helpers/util.d.ts
generated
vendored
Normal file
42
server/node_modules/@firebase/database-compat/dist/database-compat/test/helpers/util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import '../../src/index';
|
||||
import { Path } from '../../../database/src/core/util/Path';
|
||||
import { Query, Reference } from '../../src/api/Reference';
|
||||
export declare const TEST_PROJECT: any;
|
||||
export declare const DATABASE_ADDRESS: any;
|
||||
export declare const DATABASE_URL: any;
|
||||
export declare function createTestApp(): import("@firebase/app-compat").FirebaseApp;
|
||||
/**
|
||||
* Gets or creates a root node to the test namespace. All calls sharing the
|
||||
* value of opt_i will share an app context.
|
||||
*/
|
||||
export declare function getRootNode(i?: number, ref?: string): any;
|
||||
/**
|
||||
* Create multiple refs to the same top level
|
||||
* push key - each on its own Firebase.Context.
|
||||
*/
|
||||
export declare function getRandomNode(numNodes?: any): Reference | Reference[];
|
||||
export declare function getQueryValue(query: Query): Promise<unknown>;
|
||||
export declare function pause(milliseconds: number): Promise<void>;
|
||||
export declare function getPath(query: Query): string;
|
||||
export declare function shuffle(arr: any, randFn?: () => number): void;
|
||||
export declare function getFreshRepo(path: Path): any;
|
||||
export declare function getFreshRepoFromReference(ref: any): any;
|
||||
export declare function getSnap(path: any): any;
|
||||
export declare function getVal(path: any): any;
|
||||
export declare function canCreateExtraConnections(): boolean;
|
||||
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/info.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/info.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/order.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/order.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/order_by.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/order_by.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/promise.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/promise.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/query.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/query.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/servervalues.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/servervalues.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/transaction.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/database-compat/test/transaction.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import '../src/index';
|
||||
860
server/node_modules/@firebase/database-compat/dist/index.esm.js
generated
vendored
Normal file
860
server/node_modules/@firebase/database-compat/dist/index.esm.js
generated
vendored
Normal file
@@ -0,0 +1,860 @@
|
||||
import firebase from '@firebase/app-compat';
|
||||
import { ComponentContainer, Provider, Component } from '@firebase/component';
|
||||
import { _validatePathString, onChildMoved, onChildChanged, onChildRemoved, onChildAdded, onValue, off, get, query, limitToFirst, limitToLast, orderByChild, orderByKey, orderByPriority, orderByValue, startAt, startAfter, endAt, endBefore, equalTo, _ReferenceImpl, _QueryImpl, _QueryParams, child, set, _validateWritablePath, update, setWithPriority, remove, runTransaction, setPriority, push, OnDisconnect as OnDisconnect$1, forceWebSockets, forceLongPolling, connectDatabaseEmulator, refFromURL, ref, goOffline, goOnline, serverTimestamp, increment, _setSDKVersion, _repoManagerDatabaseFromApp, enableLogging } from '@firebase/database';
|
||||
import { errorPrefix, validateArgCount, validateCallback, validateContextObject, Deferred } from '@firebase/util';
|
||||
import { Logger } from '@firebase/logger';
|
||||
|
||||
const name = "@firebase/database-compat";
|
||||
const version = "2.1.0";
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
const logClient = new Logger('@firebase/database-compat');
|
||||
const warn = function (msg) {
|
||||
const message = 'FIREBASE WARNING: ' + msg;
|
||||
logClient.warn(message);
|
||||
};
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
const validateBoolean = function (fnName, argumentName, bool, optional) {
|
||||
if (optional && bool === undefined) {
|
||||
return;
|
||||
}
|
||||
if (typeof bool !== 'boolean') {
|
||||
throw new Error(errorPrefix(fnName, argumentName) + 'must be a boolean.');
|
||||
}
|
||||
};
|
||||
const validateEventType = function (fnName, eventType, optional) {
|
||||
if (optional && eventType === undefined) {
|
||||
return;
|
||||
}
|
||||
switch (eventType) {
|
||||
case 'value':
|
||||
case 'child_added':
|
||||
case 'child_removed':
|
||||
case 'child_changed':
|
||||
case 'child_moved':
|
||||
break;
|
||||
default:
|
||||
throw new Error(errorPrefix(fnName, 'eventType') +
|
||||
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
||||
'"child_changed", or "child_moved".');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
class OnDisconnect {
|
||||
constructor(_delegate) {
|
||||
this._delegate = _delegate;
|
||||
}
|
||||
cancel(onComplete) {
|
||||
validateArgCount('OnDisconnect.cancel', 0, 1, arguments.length);
|
||||
validateCallback('OnDisconnect.cancel', 'onComplete', onComplete, true);
|
||||
const result = this._delegate.cancel();
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
remove(onComplete) {
|
||||
validateArgCount('OnDisconnect.remove', 0, 1, arguments.length);
|
||||
validateCallback('OnDisconnect.remove', 'onComplete', onComplete, true);
|
||||
const result = this._delegate.remove();
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
set(value, onComplete) {
|
||||
validateArgCount('OnDisconnect.set', 1, 2, arguments.length);
|
||||
validateCallback('OnDisconnect.set', 'onComplete', onComplete, true);
|
||||
const result = this._delegate.set(value);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
setWithPriority(value, priority, onComplete) {
|
||||
validateArgCount('OnDisconnect.setWithPriority', 2, 3, arguments.length);
|
||||
validateCallback('OnDisconnect.setWithPriority', 'onComplete', onComplete, true);
|
||||
const result = this._delegate.setWithPriority(value, priority);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
update(objectToMerge, onComplete) {
|
||||
validateArgCount('OnDisconnect.update', 1, 2, arguments.length);
|
||||
if (Array.isArray(objectToMerge)) {
|
||||
const newObjectToMerge = {};
|
||||
for (let i = 0; i < objectToMerge.length; ++i) {
|
||||
newObjectToMerge['' + i] = objectToMerge[i];
|
||||
}
|
||||
objectToMerge = newObjectToMerge;
|
||||
warn('Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the ' +
|
||||
'existing data, or an Object with integer keys if you really do want to only update some of the children.');
|
||||
}
|
||||
validateCallback('OnDisconnect.update', 'onComplete', onComplete, true);
|
||||
const result = this._delegate.update(objectToMerge);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
class TransactionResult {
|
||||
/**
|
||||
* A type for the resolve value of Firebase.transaction.
|
||||
*/
|
||||
constructor(committed, snapshot) {
|
||||
this.committed = committed;
|
||||
this.snapshot = snapshot;
|
||||
}
|
||||
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
||||
// for end-users
|
||||
toJSON() {
|
||||
validateArgCount('TransactionResult.toJSON', 0, 1, arguments.length);
|
||||
return { committed: this.committed, snapshot: this.snapshot.toJSON() };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* Class representing a firebase data snapshot. It wraps a SnapshotNode and
|
||||
* surfaces the public methods (val, forEach, etc.) we want to expose.
|
||||
*/
|
||||
class DataSnapshot {
|
||||
constructor(_database, _delegate) {
|
||||
this._database = _database;
|
||||
this._delegate = _delegate;
|
||||
}
|
||||
/**
|
||||
* Retrieves the snapshot contents as JSON. Returns null if the snapshot is
|
||||
* empty.
|
||||
*
|
||||
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
||||
*/
|
||||
val() {
|
||||
validateArgCount('DataSnapshot.val', 0, 0, arguments.length);
|
||||
return this._delegate.val();
|
||||
}
|
||||
/**
|
||||
* Returns the snapshot contents as JSON, including priorities of node. Suitable for exporting
|
||||
* the entire node contents.
|
||||
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
||||
*/
|
||||
exportVal() {
|
||||
validateArgCount('DataSnapshot.exportVal', 0, 0, arguments.length);
|
||||
return this._delegate.exportVal();
|
||||
}
|
||||
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
||||
// for end-users
|
||||
toJSON() {
|
||||
// Optional spacer argument is unnecessary because we're depending on recursion rather than stringifying the content
|
||||
validateArgCount('DataSnapshot.toJSON', 0, 1, arguments.length);
|
||||
return this._delegate.toJSON();
|
||||
}
|
||||
/**
|
||||
* Returns whether the snapshot contains a non-null value.
|
||||
*
|
||||
* @returns Whether the snapshot contains a non-null value, or is empty.
|
||||
*/
|
||||
exists() {
|
||||
validateArgCount('DataSnapshot.exists', 0, 0, arguments.length);
|
||||
return this._delegate.exists();
|
||||
}
|
||||
/**
|
||||
* Returns a DataSnapshot of the specified child node's contents.
|
||||
*
|
||||
* @param path - Path to a child.
|
||||
* @returns DataSnapshot for child node.
|
||||
*/
|
||||
child(path) {
|
||||
validateArgCount('DataSnapshot.child', 0, 1, arguments.length);
|
||||
// Ensure the childPath is a string (can be a number)
|
||||
path = String(path);
|
||||
_validatePathString('DataSnapshot.child', 'path', path, false);
|
||||
return new DataSnapshot(this._database, this._delegate.child(path));
|
||||
}
|
||||
/**
|
||||
* Returns whether the snapshot contains a child at the specified path.
|
||||
*
|
||||
* @param path - Path to a child.
|
||||
* @returns Whether the child exists.
|
||||
*/
|
||||
hasChild(path) {
|
||||
validateArgCount('DataSnapshot.hasChild', 1, 1, arguments.length);
|
||||
_validatePathString('DataSnapshot.hasChild', 'path', path, false);
|
||||
return this._delegate.hasChild(path);
|
||||
}
|
||||
/**
|
||||
* Returns the priority of the object, or null if no priority was set.
|
||||
*
|
||||
* @returns The priority.
|
||||
*/
|
||||
getPriority() {
|
||||
validateArgCount('DataSnapshot.getPriority', 0, 0, arguments.length);
|
||||
return this._delegate.priority;
|
||||
}
|
||||
/**
|
||||
* Iterates through child nodes and calls the specified action for each one.
|
||||
*
|
||||
* @param action - Callback function to be called
|
||||
* for each child.
|
||||
* @returns True if forEach was canceled by action returning true for
|
||||
* one of the child nodes.
|
||||
*/
|
||||
forEach(action) {
|
||||
validateArgCount('DataSnapshot.forEach', 1, 1, arguments.length);
|
||||
validateCallback('DataSnapshot.forEach', 'action', action, false);
|
||||
return this._delegate.forEach(expDataSnapshot => action(new DataSnapshot(this._database, expDataSnapshot)));
|
||||
}
|
||||
/**
|
||||
* Returns whether this DataSnapshot has children.
|
||||
* @returns True if the DataSnapshot contains 1 or more child nodes.
|
||||
*/
|
||||
hasChildren() {
|
||||
validateArgCount('DataSnapshot.hasChildren', 0, 0, arguments.length);
|
||||
return this._delegate.hasChildren();
|
||||
}
|
||||
get key() {
|
||||
return this._delegate.key;
|
||||
}
|
||||
/**
|
||||
* Returns the number of children for this DataSnapshot.
|
||||
* @returns The number of children that this DataSnapshot contains.
|
||||
*/
|
||||
numChildren() {
|
||||
validateArgCount('DataSnapshot.numChildren', 0, 0, arguments.length);
|
||||
return this._delegate.size;
|
||||
}
|
||||
/**
|
||||
* @returns The Firebase reference for the location this snapshot's data came
|
||||
* from.
|
||||
*/
|
||||
getRef() {
|
||||
validateArgCount('DataSnapshot.ref', 0, 0, arguments.length);
|
||||
return new Reference(this._database, this._delegate.ref);
|
||||
}
|
||||
get ref() {
|
||||
return this.getRef();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A Query represents a filter to be applied to a firebase location. This object purely represents the
|
||||
* query expression (and exposes our public API to build the query). The actual query logic is in ViewBase.js.
|
||||
*
|
||||
* Since every Firebase reference is a query, Firebase inherits from this object.
|
||||
*/
|
||||
class Query {
|
||||
constructor(database, _delegate) {
|
||||
this.database = database;
|
||||
this._delegate = _delegate;
|
||||
}
|
||||
on(eventType, callback, cancelCallbackOrContext, context) {
|
||||
validateArgCount('Query.on', 2, 4, arguments.length);
|
||||
validateCallback('Query.on', 'callback', callback, false);
|
||||
const ret = Query.getCancelAndContextArgs_('Query.on', cancelCallbackOrContext, context);
|
||||
const valueCallback = (expSnapshot, previousChildName) => {
|
||||
callback.call(ret.context, new DataSnapshot(this.database, expSnapshot), previousChildName);
|
||||
};
|
||||
valueCallback.userCallback = callback;
|
||||
valueCallback.context = ret.context;
|
||||
const cancelCallback = ret.cancel?.bind(ret.context);
|
||||
switch (eventType) {
|
||||
case 'value':
|
||||
onValue(this._delegate, valueCallback, cancelCallback);
|
||||
return callback;
|
||||
case 'child_added':
|
||||
onChildAdded(this._delegate, valueCallback, cancelCallback);
|
||||
return callback;
|
||||
case 'child_removed':
|
||||
onChildRemoved(this._delegate, valueCallback, cancelCallback);
|
||||
return callback;
|
||||
case 'child_changed':
|
||||
onChildChanged(this._delegate, valueCallback, cancelCallback);
|
||||
return callback;
|
||||
case 'child_moved':
|
||||
onChildMoved(this._delegate, valueCallback, cancelCallback);
|
||||
return callback;
|
||||
default:
|
||||
throw new Error(errorPrefix('Query.on', 'eventType') +
|
||||
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
||||
'"child_changed", or "child_moved".');
|
||||
}
|
||||
}
|
||||
off(eventType, callback, context) {
|
||||
validateArgCount('Query.off', 0, 3, arguments.length);
|
||||
validateEventType('Query.off', eventType, true);
|
||||
validateCallback('Query.off', 'callback', callback, true);
|
||||
validateContextObject('Query.off', 'context', context, true);
|
||||
if (callback) {
|
||||
const valueCallback = () => { };
|
||||
valueCallback.userCallback = callback;
|
||||
valueCallback.context = context;
|
||||
off(this._delegate, eventType, valueCallback);
|
||||
}
|
||||
else {
|
||||
off(this._delegate, eventType);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the server-value for this query, or return a cached value if not connected.
|
||||
*/
|
||||
get() {
|
||||
return get(this._delegate).then(expSnapshot => {
|
||||
return new DataSnapshot(this.database, expSnapshot);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Attaches a listener, waits for the first event, and then removes the listener
|
||||
*/
|
||||
once(eventType, callback, failureCallbackOrContext, context) {
|
||||
validateArgCount('Query.once', 1, 4, arguments.length);
|
||||
validateCallback('Query.once', 'callback', callback, true);
|
||||
const ret = Query.getCancelAndContextArgs_('Query.once', failureCallbackOrContext, context);
|
||||
const deferred = new Deferred();
|
||||
const valueCallback = (expSnapshot, previousChildName) => {
|
||||
const result = new DataSnapshot(this.database, expSnapshot);
|
||||
if (callback) {
|
||||
callback.call(ret.context, result, previousChildName);
|
||||
}
|
||||
deferred.resolve(result);
|
||||
};
|
||||
valueCallback.userCallback = callback;
|
||||
valueCallback.context = ret.context;
|
||||
const cancelCallback = (error) => {
|
||||
if (ret.cancel) {
|
||||
ret.cancel.call(ret.context, error);
|
||||
}
|
||||
deferred.reject(error);
|
||||
};
|
||||
switch (eventType) {
|
||||
case 'value':
|
||||
onValue(this._delegate, valueCallback, cancelCallback, {
|
||||
onlyOnce: true
|
||||
});
|
||||
break;
|
||||
case 'child_added':
|
||||
onChildAdded(this._delegate, valueCallback, cancelCallback, {
|
||||
onlyOnce: true
|
||||
});
|
||||
break;
|
||||
case 'child_removed':
|
||||
onChildRemoved(this._delegate, valueCallback, cancelCallback, {
|
||||
onlyOnce: true
|
||||
});
|
||||
break;
|
||||
case 'child_changed':
|
||||
onChildChanged(this._delegate, valueCallback, cancelCallback, {
|
||||
onlyOnce: true
|
||||
});
|
||||
break;
|
||||
case 'child_moved':
|
||||
onChildMoved(this._delegate, valueCallback, cancelCallback, {
|
||||
onlyOnce: true
|
||||
});
|
||||
break;
|
||||
default:
|
||||
throw new Error(errorPrefix('Query.once', 'eventType') +
|
||||
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
||||
'"child_changed", or "child_moved".');
|
||||
}
|
||||
return deferred.promise;
|
||||
}
|
||||
/**
|
||||
* Set a limit and anchor it to the start of the window.
|
||||
*/
|
||||
limitToFirst(limit) {
|
||||
validateArgCount('Query.limitToFirst', 1, 1, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, limitToFirst(limit)));
|
||||
}
|
||||
/**
|
||||
* Set a limit and anchor it to the end of the window.
|
||||
*/
|
||||
limitToLast(limit) {
|
||||
validateArgCount('Query.limitToLast', 1, 1, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, limitToLast(limit)));
|
||||
}
|
||||
/**
|
||||
* Given a child path, return a new query ordered by the specified grandchild path.
|
||||
*/
|
||||
orderByChild(path) {
|
||||
validateArgCount('Query.orderByChild', 1, 1, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, orderByChild(path)));
|
||||
}
|
||||
/**
|
||||
* Return a new query ordered by the KeyIndex
|
||||
*/
|
||||
orderByKey() {
|
||||
validateArgCount('Query.orderByKey', 0, 0, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, orderByKey()));
|
||||
}
|
||||
/**
|
||||
* Return a new query ordered by the PriorityIndex
|
||||
*/
|
||||
orderByPriority() {
|
||||
validateArgCount('Query.orderByPriority', 0, 0, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, orderByPriority()));
|
||||
}
|
||||
/**
|
||||
* Return a new query ordered by the ValueIndex
|
||||
*/
|
||||
orderByValue() {
|
||||
validateArgCount('Query.orderByValue', 0, 0, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, orderByValue()));
|
||||
}
|
||||
startAt(value = null, name) {
|
||||
validateArgCount('Query.startAt', 0, 2, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, startAt(value, name)));
|
||||
}
|
||||
startAfter(value = null, name) {
|
||||
validateArgCount('Query.startAfter', 0, 2, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, startAfter(value, name)));
|
||||
}
|
||||
endAt(value = null, name) {
|
||||
validateArgCount('Query.endAt', 0, 2, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, endAt(value, name)));
|
||||
}
|
||||
endBefore(value = null, name) {
|
||||
validateArgCount('Query.endBefore', 0, 2, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, endBefore(value, name)));
|
||||
}
|
||||
/**
|
||||
* Load the selection of children with exactly the specified value, and, optionally,
|
||||
* the specified name.
|
||||
*/
|
||||
equalTo(value, name) {
|
||||
validateArgCount('Query.equalTo', 1, 2, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, equalTo(value, name)));
|
||||
}
|
||||
/**
|
||||
* @returns URL for this location.
|
||||
*/
|
||||
toString() {
|
||||
validateArgCount('Query.toString', 0, 0, arguments.length);
|
||||
return this._delegate.toString();
|
||||
}
|
||||
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
||||
// for end-users.
|
||||
toJSON() {
|
||||
// An optional spacer argument is unnecessary for a string.
|
||||
validateArgCount('Query.toJSON', 0, 1, arguments.length);
|
||||
return this._delegate.toJSON();
|
||||
}
|
||||
/**
|
||||
* Return true if this query and the provided query are equivalent; otherwise, return false.
|
||||
*/
|
||||
isEqual(other) {
|
||||
validateArgCount('Query.isEqual', 1, 1, arguments.length);
|
||||
if (!(other instanceof Query)) {
|
||||
const error = 'Query.isEqual failed: First argument must be an instance of firebase.database.Query.';
|
||||
throw new Error(error);
|
||||
}
|
||||
return this._delegate.isEqual(other._delegate);
|
||||
}
|
||||
/**
|
||||
* Helper used by .on and .once to extract the context and or cancel arguments.
|
||||
* @param fnName - The function name (on or once)
|
||||
*
|
||||
*/
|
||||
static getCancelAndContextArgs_(fnName, cancelOrContext, context) {
|
||||
const ret = { cancel: undefined, context: undefined };
|
||||
if (cancelOrContext && context) {
|
||||
ret.cancel = cancelOrContext;
|
||||
validateCallback(fnName, 'cancel', ret.cancel, true);
|
||||
ret.context = context;
|
||||
validateContextObject(fnName, 'context', ret.context, true);
|
||||
}
|
||||
else if (cancelOrContext) {
|
||||
// we have either a cancel callback or a context.
|
||||
if (typeof cancelOrContext === 'object' && cancelOrContext !== null) {
|
||||
// it's a context!
|
||||
ret.context = cancelOrContext;
|
||||
}
|
||||
else if (typeof cancelOrContext === 'function') {
|
||||
ret.cancel = cancelOrContext;
|
||||
}
|
||||
else {
|
||||
throw new Error(errorPrefix(fnName, 'cancelOrContext') +
|
||||
' must either be a cancel callback or a context object.');
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
get ref() {
|
||||
return new Reference(this.database, new _ReferenceImpl(this._delegate._repo, this._delegate._path));
|
||||
}
|
||||
}
|
||||
class Reference extends Query {
|
||||
/**
|
||||
* Call options:
|
||||
* new Reference(Repo, Path) or
|
||||
* new Reference(url: string, string|RepoManager)
|
||||
*
|
||||
* Externally - this is the firebase.database.Reference type.
|
||||
*/
|
||||
constructor(database, _delegate) {
|
||||
super(database, new _QueryImpl(_delegate._repo, _delegate._path, new _QueryParams(), false));
|
||||
this.database = database;
|
||||
this._delegate = _delegate;
|
||||
}
|
||||
/** @returns {?string} */
|
||||
getKey() {
|
||||
validateArgCount('Reference.key', 0, 0, arguments.length);
|
||||
return this._delegate.key;
|
||||
}
|
||||
child(pathString) {
|
||||
validateArgCount('Reference.child', 1, 1, arguments.length);
|
||||
if (typeof pathString === 'number') {
|
||||
pathString = String(pathString);
|
||||
}
|
||||
return new Reference(this.database, child(this._delegate, pathString));
|
||||
}
|
||||
/** @returns {?Reference} */
|
||||
getParent() {
|
||||
validateArgCount('Reference.parent', 0, 0, arguments.length);
|
||||
const parent = this._delegate.parent;
|
||||
return parent ? new Reference(this.database, parent) : null;
|
||||
}
|
||||
/** @returns {!Reference} */
|
||||
getRoot() {
|
||||
validateArgCount('Reference.root', 0, 0, arguments.length);
|
||||
return new Reference(this.database, this._delegate.root);
|
||||
}
|
||||
set(newVal, onComplete) {
|
||||
validateArgCount('Reference.set', 1, 2, arguments.length);
|
||||
validateCallback('Reference.set', 'onComplete', onComplete, true);
|
||||
const result = set(this._delegate, newVal);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
update(values, onComplete) {
|
||||
validateArgCount('Reference.update', 1, 2, arguments.length);
|
||||
if (Array.isArray(values)) {
|
||||
const newObjectToMerge = {};
|
||||
for (let i = 0; i < values.length; ++i) {
|
||||
newObjectToMerge['' + i] = values[i];
|
||||
}
|
||||
values = newObjectToMerge;
|
||||
warn('Passing an Array to Firebase.update() is deprecated. ' +
|
||||
'Use set() if you want to overwrite the existing data, or ' +
|
||||
'an Object with integer keys if you really do want to ' +
|
||||
'only update some of the children.');
|
||||
}
|
||||
_validateWritablePath('Reference.update', this._delegate._path);
|
||||
validateCallback('Reference.update', 'onComplete', onComplete, true);
|
||||
const result = update(this._delegate, values);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
setWithPriority(newVal, newPriority, onComplete) {
|
||||
validateArgCount('Reference.setWithPriority', 2, 3, arguments.length);
|
||||
validateCallback('Reference.setWithPriority', 'onComplete', onComplete, true);
|
||||
const result = setWithPriority(this._delegate, newVal, newPriority);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
remove(onComplete) {
|
||||
validateArgCount('Reference.remove', 0, 1, arguments.length);
|
||||
validateCallback('Reference.remove', 'onComplete', onComplete, true);
|
||||
const result = remove(this._delegate);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
transaction(transactionUpdate, onComplete, applyLocally) {
|
||||
validateArgCount('Reference.transaction', 1, 3, arguments.length);
|
||||
validateCallback('Reference.transaction', 'transactionUpdate', transactionUpdate, false);
|
||||
validateCallback('Reference.transaction', 'onComplete', onComplete, true);
|
||||
validateBoolean('Reference.transaction', 'applyLocally', applyLocally, true);
|
||||
const result = runTransaction(this._delegate, transactionUpdate, {
|
||||
applyLocally
|
||||
}).then(transactionResult => new TransactionResult(transactionResult.committed, new DataSnapshot(this.database, transactionResult.snapshot)));
|
||||
if (onComplete) {
|
||||
result.then(transactionResult => onComplete(null, transactionResult.committed, transactionResult.snapshot), error => onComplete(error, false, null));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
setPriority(priority, onComplete) {
|
||||
validateArgCount('Reference.setPriority', 1, 2, arguments.length);
|
||||
validateCallback('Reference.setPriority', 'onComplete', onComplete, true);
|
||||
const result = setPriority(this._delegate, priority);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
push(value, onComplete) {
|
||||
validateArgCount('Reference.push', 0, 2, arguments.length);
|
||||
validateCallback('Reference.push', 'onComplete', onComplete, true);
|
||||
const expPromise = push(this._delegate, value);
|
||||
const promise = expPromise.then(expRef => new Reference(this.database, expRef));
|
||||
if (onComplete) {
|
||||
promise.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
const result = new Reference(this.database, expPromise);
|
||||
result.then = promise.then.bind(promise);
|
||||
result.catch = promise.catch.bind(promise, undefined);
|
||||
return result;
|
||||
}
|
||||
onDisconnect() {
|
||||
_validateWritablePath('Reference.onDisconnect', this._delegate._path);
|
||||
return new OnDisconnect(new OnDisconnect$1(this._delegate._repo, this._delegate._path));
|
||||
}
|
||||
get key() {
|
||||
return this.getKey();
|
||||
}
|
||||
get parent() {
|
||||
return this.getParent();
|
||||
}
|
||||
get root() {
|
||||
return this.getRoot();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* Class representing a firebase database.
|
||||
*/
|
||||
class Database {
|
||||
/**
|
||||
* The constructor should not be called by users of our public API.
|
||||
*/
|
||||
constructor(_delegate, app) {
|
||||
this._delegate = _delegate;
|
||||
this.app = app;
|
||||
this.INTERNAL = {
|
||||
delete: () => this._delegate._delete(),
|
||||
forceWebSockets,
|
||||
forceLongPolling
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Modify this instance to communicate with the Realtime Database emulator.
|
||||
*
|
||||
* <p>Note: This method must be called before performing any other operation.
|
||||
*
|
||||
* @param host - the emulator host (ex: localhost)
|
||||
* @param port - the emulator port (ex: 8080)
|
||||
* @param options.mockUserToken - the mock auth token to use for unit testing Security Rules
|
||||
*/
|
||||
useEmulator(host, port, options = {}) {
|
||||
connectDatabaseEmulator(this._delegate, host, port, options);
|
||||
}
|
||||
ref(path) {
|
||||
validateArgCount('database.ref', 0, 1, arguments.length);
|
||||
if (path instanceof Reference) {
|
||||
const childRef = refFromURL(this._delegate, path.toString());
|
||||
return new Reference(this, childRef);
|
||||
}
|
||||
else {
|
||||
const childRef = ref(this._delegate, path);
|
||||
return new Reference(this, childRef);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns a reference to the root or the path specified in url.
|
||||
* We throw a exception if the url is not in the same domain as the
|
||||
* current repo.
|
||||
* @returns Firebase reference.
|
||||
*/
|
||||
refFromURL(url) {
|
||||
const apiName = 'database.refFromURL';
|
||||
validateArgCount(apiName, 1, 1, arguments.length);
|
||||
const childRef = refFromURL(this._delegate, url);
|
||||
return new Reference(this, childRef);
|
||||
}
|
||||
// Make individual repo go offline.
|
||||
goOffline() {
|
||||
validateArgCount('database.goOffline', 0, 0, arguments.length);
|
||||
return goOffline(this._delegate);
|
||||
}
|
||||
goOnline() {
|
||||
validateArgCount('database.goOnline', 0, 0, arguments.length);
|
||||
return goOnline(this._delegate);
|
||||
}
|
||||
}
|
||||
Database.ServerValue = {
|
||||
TIMESTAMP: serverTimestamp(),
|
||||
increment: (delta) => increment(delta)
|
||||
};
|
||||
|
||||
/**
|
||||
* Used by console to create a database based on the app,
|
||||
* passed database URL and a custom auth implementation.
|
||||
*
|
||||
* @param app - A valid FirebaseApp-like object
|
||||
* @param url - A valid Firebase databaseURL
|
||||
* @param version - custom version e.g. firebase-admin version
|
||||
* @param customAuthImpl - custom auth implementation
|
||||
*/
|
||||
function initStandalone({ app, url, version, customAuthImpl, customAppCheckImpl, namespace, nodeAdmin = false }) {
|
||||
_setSDKVersion(version);
|
||||
const container = new ComponentContainer('database-standalone');
|
||||
/**
|
||||
* ComponentContainer('database-standalone') is just a placeholder that doesn't perform
|
||||
* any actual function.
|
||||
*/
|
||||
const authProvider = new Provider('auth-internal', container);
|
||||
authProvider.setComponent(new Component('auth-internal', () => customAuthImpl, "PRIVATE" /* ComponentType.PRIVATE */));
|
||||
let appCheckProvider = undefined;
|
||||
if (customAppCheckImpl) {
|
||||
appCheckProvider = new Provider('app-check-internal', container);
|
||||
appCheckProvider.setComponent(new Component('app-check-internal', () => customAppCheckImpl, "PRIVATE" /* ComponentType.PRIVATE */));
|
||||
}
|
||||
return {
|
||||
instance: new Database(_repoManagerDatabaseFromApp(app, authProvider, appCheckProvider, url, nodeAdmin), app),
|
||||
namespace
|
||||
};
|
||||
}
|
||||
|
||||
var INTERNAL = /*#__PURE__*/Object.freeze({
|
||||
__proto__: null,
|
||||
initStandalone: initStandalone
|
||||
});
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
const ServerValue = Database.ServerValue;
|
||||
function registerDatabase(instance) {
|
||||
// Register the Database Service with the 'firebase' namespace.
|
||||
instance.INTERNAL.registerComponent(new Component('database-compat', (container, { instanceIdentifier: url }) => {
|
||||
/* Dependencies */
|
||||
// getImmediate for FirebaseApp will always succeed
|
||||
const app = container.getProvider('app-compat').getImmediate();
|
||||
const databaseExp = container
|
||||
.getProvider('database')
|
||||
.getImmediate({ identifier: url });
|
||||
return new Database(databaseExp, app);
|
||||
}, "PUBLIC" /* ComponentType.PUBLIC */)
|
||||
.setServiceProps(
|
||||
// firebase.database namespace properties
|
||||
{
|
||||
Reference,
|
||||
Query,
|
||||
Database,
|
||||
DataSnapshot,
|
||||
enableLogging,
|
||||
INTERNAL,
|
||||
ServerValue
|
||||
})
|
||||
.setMultipleInstances(true));
|
||||
instance.registerVersion(name, version);
|
||||
}
|
||||
registerDatabase(firebase);
|
||||
|
||||
export { registerDatabase };
|
||||
//# sourceMappingURL=index.esm.js.map
|
||||
1
server/node_modules/@firebase/database-compat/dist/index.esm.js.map
generated
vendored
Normal file
1
server/node_modules/@firebase/database-compat/dist/index.esm.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
864
server/node_modules/@firebase/database-compat/dist/index.js
generated
vendored
Normal file
864
server/node_modules/@firebase/database-compat/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,864 @@
|
||||
'use strict';
|
||||
|
||||
var firebase = require('@firebase/app-compat');
|
||||
var component = require('@firebase/component');
|
||||
var database = require('@firebase/database');
|
||||
var util = require('@firebase/util');
|
||||
var logger = require('@firebase/logger');
|
||||
|
||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
||||
|
||||
var firebase__default = /*#__PURE__*/_interopDefaultLegacy(firebase);
|
||||
|
||||
const name = "@firebase/database-compat";
|
||||
const version = "2.1.0";
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
const logClient = new logger.Logger('@firebase/database-compat');
|
||||
const warn = function (msg) {
|
||||
const message = 'FIREBASE WARNING: ' + msg;
|
||||
logClient.warn(message);
|
||||
};
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
const validateBoolean = function (fnName, argumentName, bool, optional) {
|
||||
if (optional && bool === undefined) {
|
||||
return;
|
||||
}
|
||||
if (typeof bool !== 'boolean') {
|
||||
throw new Error(util.errorPrefix(fnName, argumentName) + 'must be a boolean.');
|
||||
}
|
||||
};
|
||||
const validateEventType = function (fnName, eventType, optional) {
|
||||
if (optional && eventType === undefined) {
|
||||
return;
|
||||
}
|
||||
switch (eventType) {
|
||||
case 'value':
|
||||
case 'child_added':
|
||||
case 'child_removed':
|
||||
case 'child_changed':
|
||||
case 'child_moved':
|
||||
break;
|
||||
default:
|
||||
throw new Error(util.errorPrefix(fnName, 'eventType') +
|
||||
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
||||
'"child_changed", or "child_moved".');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
class OnDisconnect {
|
||||
constructor(_delegate) {
|
||||
this._delegate = _delegate;
|
||||
}
|
||||
cancel(onComplete) {
|
||||
util.validateArgCount('OnDisconnect.cancel', 0, 1, arguments.length);
|
||||
util.validateCallback('OnDisconnect.cancel', 'onComplete', onComplete, true);
|
||||
const result = this._delegate.cancel();
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
remove(onComplete) {
|
||||
util.validateArgCount('OnDisconnect.remove', 0, 1, arguments.length);
|
||||
util.validateCallback('OnDisconnect.remove', 'onComplete', onComplete, true);
|
||||
const result = this._delegate.remove();
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
set(value, onComplete) {
|
||||
util.validateArgCount('OnDisconnect.set', 1, 2, arguments.length);
|
||||
util.validateCallback('OnDisconnect.set', 'onComplete', onComplete, true);
|
||||
const result = this._delegate.set(value);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
setWithPriority(value, priority, onComplete) {
|
||||
util.validateArgCount('OnDisconnect.setWithPriority', 2, 3, arguments.length);
|
||||
util.validateCallback('OnDisconnect.setWithPriority', 'onComplete', onComplete, true);
|
||||
const result = this._delegate.setWithPriority(value, priority);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
update(objectToMerge, onComplete) {
|
||||
util.validateArgCount('OnDisconnect.update', 1, 2, arguments.length);
|
||||
if (Array.isArray(objectToMerge)) {
|
||||
const newObjectToMerge = {};
|
||||
for (let i = 0; i < objectToMerge.length; ++i) {
|
||||
newObjectToMerge['' + i] = objectToMerge[i];
|
||||
}
|
||||
objectToMerge = newObjectToMerge;
|
||||
warn('Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the ' +
|
||||
'existing data, or an Object with integer keys if you really do want to only update some of the children.');
|
||||
}
|
||||
util.validateCallback('OnDisconnect.update', 'onComplete', onComplete, true);
|
||||
const result = this._delegate.update(objectToMerge);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
class TransactionResult {
|
||||
/**
|
||||
* A type for the resolve value of Firebase.transaction.
|
||||
*/
|
||||
constructor(committed, snapshot) {
|
||||
this.committed = committed;
|
||||
this.snapshot = snapshot;
|
||||
}
|
||||
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
||||
// for end-users
|
||||
toJSON() {
|
||||
util.validateArgCount('TransactionResult.toJSON', 0, 1, arguments.length);
|
||||
return { committed: this.committed, snapshot: this.snapshot.toJSON() };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* Class representing a firebase data snapshot. It wraps a SnapshotNode and
|
||||
* surfaces the public methods (val, forEach, etc.) we want to expose.
|
||||
*/
|
||||
class DataSnapshot {
|
||||
constructor(_database, _delegate) {
|
||||
this._database = _database;
|
||||
this._delegate = _delegate;
|
||||
}
|
||||
/**
|
||||
* Retrieves the snapshot contents as JSON. Returns null if the snapshot is
|
||||
* empty.
|
||||
*
|
||||
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
||||
*/
|
||||
val() {
|
||||
util.validateArgCount('DataSnapshot.val', 0, 0, arguments.length);
|
||||
return this._delegate.val();
|
||||
}
|
||||
/**
|
||||
* Returns the snapshot contents as JSON, including priorities of node. Suitable for exporting
|
||||
* the entire node contents.
|
||||
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
||||
*/
|
||||
exportVal() {
|
||||
util.validateArgCount('DataSnapshot.exportVal', 0, 0, arguments.length);
|
||||
return this._delegate.exportVal();
|
||||
}
|
||||
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
||||
// for end-users
|
||||
toJSON() {
|
||||
// Optional spacer argument is unnecessary because we're depending on recursion rather than stringifying the content
|
||||
util.validateArgCount('DataSnapshot.toJSON', 0, 1, arguments.length);
|
||||
return this._delegate.toJSON();
|
||||
}
|
||||
/**
|
||||
* Returns whether the snapshot contains a non-null value.
|
||||
*
|
||||
* @returns Whether the snapshot contains a non-null value, or is empty.
|
||||
*/
|
||||
exists() {
|
||||
util.validateArgCount('DataSnapshot.exists', 0, 0, arguments.length);
|
||||
return this._delegate.exists();
|
||||
}
|
||||
/**
|
||||
* Returns a DataSnapshot of the specified child node's contents.
|
||||
*
|
||||
* @param path - Path to a child.
|
||||
* @returns DataSnapshot for child node.
|
||||
*/
|
||||
child(path) {
|
||||
util.validateArgCount('DataSnapshot.child', 0, 1, arguments.length);
|
||||
// Ensure the childPath is a string (can be a number)
|
||||
path = String(path);
|
||||
database._validatePathString('DataSnapshot.child', 'path', path, false);
|
||||
return new DataSnapshot(this._database, this._delegate.child(path));
|
||||
}
|
||||
/**
|
||||
* Returns whether the snapshot contains a child at the specified path.
|
||||
*
|
||||
* @param path - Path to a child.
|
||||
* @returns Whether the child exists.
|
||||
*/
|
||||
hasChild(path) {
|
||||
util.validateArgCount('DataSnapshot.hasChild', 1, 1, arguments.length);
|
||||
database._validatePathString('DataSnapshot.hasChild', 'path', path, false);
|
||||
return this._delegate.hasChild(path);
|
||||
}
|
||||
/**
|
||||
* Returns the priority of the object, or null if no priority was set.
|
||||
*
|
||||
* @returns The priority.
|
||||
*/
|
||||
getPriority() {
|
||||
util.validateArgCount('DataSnapshot.getPriority', 0, 0, arguments.length);
|
||||
return this._delegate.priority;
|
||||
}
|
||||
/**
|
||||
* Iterates through child nodes and calls the specified action for each one.
|
||||
*
|
||||
* @param action - Callback function to be called
|
||||
* for each child.
|
||||
* @returns True if forEach was canceled by action returning true for
|
||||
* one of the child nodes.
|
||||
*/
|
||||
forEach(action) {
|
||||
util.validateArgCount('DataSnapshot.forEach', 1, 1, arguments.length);
|
||||
util.validateCallback('DataSnapshot.forEach', 'action', action, false);
|
||||
return this._delegate.forEach(expDataSnapshot => action(new DataSnapshot(this._database, expDataSnapshot)));
|
||||
}
|
||||
/**
|
||||
* Returns whether this DataSnapshot has children.
|
||||
* @returns True if the DataSnapshot contains 1 or more child nodes.
|
||||
*/
|
||||
hasChildren() {
|
||||
util.validateArgCount('DataSnapshot.hasChildren', 0, 0, arguments.length);
|
||||
return this._delegate.hasChildren();
|
||||
}
|
||||
get key() {
|
||||
return this._delegate.key;
|
||||
}
|
||||
/**
|
||||
* Returns the number of children for this DataSnapshot.
|
||||
* @returns The number of children that this DataSnapshot contains.
|
||||
*/
|
||||
numChildren() {
|
||||
util.validateArgCount('DataSnapshot.numChildren', 0, 0, arguments.length);
|
||||
return this._delegate.size;
|
||||
}
|
||||
/**
|
||||
* @returns The Firebase reference for the location this snapshot's data came
|
||||
* from.
|
||||
*/
|
||||
getRef() {
|
||||
util.validateArgCount('DataSnapshot.ref', 0, 0, arguments.length);
|
||||
return new Reference(this._database, this._delegate.ref);
|
||||
}
|
||||
get ref() {
|
||||
return this.getRef();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A Query represents a filter to be applied to a firebase location. This object purely represents the
|
||||
* query expression (and exposes our public API to build the query). The actual query logic is in ViewBase.js.
|
||||
*
|
||||
* Since every Firebase reference is a query, Firebase inherits from this object.
|
||||
*/
|
||||
class Query {
|
||||
constructor(database, _delegate) {
|
||||
this.database = database;
|
||||
this._delegate = _delegate;
|
||||
}
|
||||
on(eventType, callback, cancelCallbackOrContext, context) {
|
||||
util.validateArgCount('Query.on', 2, 4, arguments.length);
|
||||
util.validateCallback('Query.on', 'callback', callback, false);
|
||||
const ret = Query.getCancelAndContextArgs_('Query.on', cancelCallbackOrContext, context);
|
||||
const valueCallback = (expSnapshot, previousChildName) => {
|
||||
callback.call(ret.context, new DataSnapshot(this.database, expSnapshot), previousChildName);
|
||||
};
|
||||
valueCallback.userCallback = callback;
|
||||
valueCallback.context = ret.context;
|
||||
const cancelCallback = ret.cancel?.bind(ret.context);
|
||||
switch (eventType) {
|
||||
case 'value':
|
||||
database.onValue(this._delegate, valueCallback, cancelCallback);
|
||||
return callback;
|
||||
case 'child_added':
|
||||
database.onChildAdded(this._delegate, valueCallback, cancelCallback);
|
||||
return callback;
|
||||
case 'child_removed':
|
||||
database.onChildRemoved(this._delegate, valueCallback, cancelCallback);
|
||||
return callback;
|
||||
case 'child_changed':
|
||||
database.onChildChanged(this._delegate, valueCallback, cancelCallback);
|
||||
return callback;
|
||||
case 'child_moved':
|
||||
database.onChildMoved(this._delegate, valueCallback, cancelCallback);
|
||||
return callback;
|
||||
default:
|
||||
throw new Error(util.errorPrefix('Query.on', 'eventType') +
|
||||
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
||||
'"child_changed", or "child_moved".');
|
||||
}
|
||||
}
|
||||
off(eventType, callback, context) {
|
||||
util.validateArgCount('Query.off', 0, 3, arguments.length);
|
||||
validateEventType('Query.off', eventType, true);
|
||||
util.validateCallback('Query.off', 'callback', callback, true);
|
||||
util.validateContextObject('Query.off', 'context', context, true);
|
||||
if (callback) {
|
||||
const valueCallback = () => { };
|
||||
valueCallback.userCallback = callback;
|
||||
valueCallback.context = context;
|
||||
database.off(this._delegate, eventType, valueCallback);
|
||||
}
|
||||
else {
|
||||
database.off(this._delegate, eventType);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the server-value for this query, or return a cached value if not connected.
|
||||
*/
|
||||
get() {
|
||||
return database.get(this._delegate).then(expSnapshot => {
|
||||
return new DataSnapshot(this.database, expSnapshot);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Attaches a listener, waits for the first event, and then removes the listener
|
||||
*/
|
||||
once(eventType, callback, failureCallbackOrContext, context) {
|
||||
util.validateArgCount('Query.once', 1, 4, arguments.length);
|
||||
util.validateCallback('Query.once', 'callback', callback, true);
|
||||
const ret = Query.getCancelAndContextArgs_('Query.once', failureCallbackOrContext, context);
|
||||
const deferred = new util.Deferred();
|
||||
const valueCallback = (expSnapshot, previousChildName) => {
|
||||
const result = new DataSnapshot(this.database, expSnapshot);
|
||||
if (callback) {
|
||||
callback.call(ret.context, result, previousChildName);
|
||||
}
|
||||
deferred.resolve(result);
|
||||
};
|
||||
valueCallback.userCallback = callback;
|
||||
valueCallback.context = ret.context;
|
||||
const cancelCallback = (error) => {
|
||||
if (ret.cancel) {
|
||||
ret.cancel.call(ret.context, error);
|
||||
}
|
||||
deferred.reject(error);
|
||||
};
|
||||
switch (eventType) {
|
||||
case 'value':
|
||||
database.onValue(this._delegate, valueCallback, cancelCallback, {
|
||||
onlyOnce: true
|
||||
});
|
||||
break;
|
||||
case 'child_added':
|
||||
database.onChildAdded(this._delegate, valueCallback, cancelCallback, {
|
||||
onlyOnce: true
|
||||
});
|
||||
break;
|
||||
case 'child_removed':
|
||||
database.onChildRemoved(this._delegate, valueCallback, cancelCallback, {
|
||||
onlyOnce: true
|
||||
});
|
||||
break;
|
||||
case 'child_changed':
|
||||
database.onChildChanged(this._delegate, valueCallback, cancelCallback, {
|
||||
onlyOnce: true
|
||||
});
|
||||
break;
|
||||
case 'child_moved':
|
||||
database.onChildMoved(this._delegate, valueCallback, cancelCallback, {
|
||||
onlyOnce: true
|
||||
});
|
||||
break;
|
||||
default:
|
||||
throw new Error(util.errorPrefix('Query.once', 'eventType') +
|
||||
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
||||
'"child_changed", or "child_moved".');
|
||||
}
|
||||
return deferred.promise;
|
||||
}
|
||||
/**
|
||||
* Set a limit and anchor it to the start of the window.
|
||||
*/
|
||||
limitToFirst(limit) {
|
||||
util.validateArgCount('Query.limitToFirst', 1, 1, arguments.length);
|
||||
return new Query(this.database, database.query(this._delegate, database.limitToFirst(limit)));
|
||||
}
|
||||
/**
|
||||
* Set a limit and anchor it to the end of the window.
|
||||
*/
|
||||
limitToLast(limit) {
|
||||
util.validateArgCount('Query.limitToLast', 1, 1, arguments.length);
|
||||
return new Query(this.database, database.query(this._delegate, database.limitToLast(limit)));
|
||||
}
|
||||
/**
|
||||
* Given a child path, return a new query ordered by the specified grandchild path.
|
||||
*/
|
||||
orderByChild(path) {
|
||||
util.validateArgCount('Query.orderByChild', 1, 1, arguments.length);
|
||||
return new Query(this.database, database.query(this._delegate, database.orderByChild(path)));
|
||||
}
|
||||
/**
|
||||
* Return a new query ordered by the KeyIndex
|
||||
*/
|
||||
orderByKey() {
|
||||
util.validateArgCount('Query.orderByKey', 0, 0, arguments.length);
|
||||
return new Query(this.database, database.query(this._delegate, database.orderByKey()));
|
||||
}
|
||||
/**
|
||||
* Return a new query ordered by the PriorityIndex
|
||||
*/
|
||||
orderByPriority() {
|
||||
util.validateArgCount('Query.orderByPriority', 0, 0, arguments.length);
|
||||
return new Query(this.database, database.query(this._delegate, database.orderByPriority()));
|
||||
}
|
||||
/**
|
||||
* Return a new query ordered by the ValueIndex
|
||||
*/
|
||||
orderByValue() {
|
||||
util.validateArgCount('Query.orderByValue', 0, 0, arguments.length);
|
||||
return new Query(this.database, database.query(this._delegate, database.orderByValue()));
|
||||
}
|
||||
startAt(value = null, name) {
|
||||
util.validateArgCount('Query.startAt', 0, 2, arguments.length);
|
||||
return new Query(this.database, database.query(this._delegate, database.startAt(value, name)));
|
||||
}
|
||||
startAfter(value = null, name) {
|
||||
util.validateArgCount('Query.startAfter', 0, 2, arguments.length);
|
||||
return new Query(this.database, database.query(this._delegate, database.startAfter(value, name)));
|
||||
}
|
||||
endAt(value = null, name) {
|
||||
util.validateArgCount('Query.endAt', 0, 2, arguments.length);
|
||||
return new Query(this.database, database.query(this._delegate, database.endAt(value, name)));
|
||||
}
|
||||
endBefore(value = null, name) {
|
||||
util.validateArgCount('Query.endBefore', 0, 2, arguments.length);
|
||||
return new Query(this.database, database.query(this._delegate, database.endBefore(value, name)));
|
||||
}
|
||||
/**
|
||||
* Load the selection of children with exactly the specified value, and, optionally,
|
||||
* the specified name.
|
||||
*/
|
||||
equalTo(value, name) {
|
||||
util.validateArgCount('Query.equalTo', 1, 2, arguments.length);
|
||||
return new Query(this.database, database.query(this._delegate, database.equalTo(value, name)));
|
||||
}
|
||||
/**
|
||||
* @returns URL for this location.
|
||||
*/
|
||||
toString() {
|
||||
util.validateArgCount('Query.toString', 0, 0, arguments.length);
|
||||
return this._delegate.toString();
|
||||
}
|
||||
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
||||
// for end-users.
|
||||
toJSON() {
|
||||
// An optional spacer argument is unnecessary for a string.
|
||||
util.validateArgCount('Query.toJSON', 0, 1, arguments.length);
|
||||
return this._delegate.toJSON();
|
||||
}
|
||||
/**
|
||||
* Return true if this query and the provided query are equivalent; otherwise, return false.
|
||||
*/
|
||||
isEqual(other) {
|
||||
util.validateArgCount('Query.isEqual', 1, 1, arguments.length);
|
||||
if (!(other instanceof Query)) {
|
||||
const error = 'Query.isEqual failed: First argument must be an instance of firebase.database.Query.';
|
||||
throw new Error(error);
|
||||
}
|
||||
return this._delegate.isEqual(other._delegate);
|
||||
}
|
||||
/**
|
||||
* Helper used by .on and .once to extract the context and or cancel arguments.
|
||||
* @param fnName - The function name (on or once)
|
||||
*
|
||||
*/
|
||||
static getCancelAndContextArgs_(fnName, cancelOrContext, context) {
|
||||
const ret = { cancel: undefined, context: undefined };
|
||||
if (cancelOrContext && context) {
|
||||
ret.cancel = cancelOrContext;
|
||||
util.validateCallback(fnName, 'cancel', ret.cancel, true);
|
||||
ret.context = context;
|
||||
util.validateContextObject(fnName, 'context', ret.context, true);
|
||||
}
|
||||
else if (cancelOrContext) {
|
||||
// we have either a cancel callback or a context.
|
||||
if (typeof cancelOrContext === 'object' && cancelOrContext !== null) {
|
||||
// it's a context!
|
||||
ret.context = cancelOrContext;
|
||||
}
|
||||
else if (typeof cancelOrContext === 'function') {
|
||||
ret.cancel = cancelOrContext;
|
||||
}
|
||||
else {
|
||||
throw new Error(util.errorPrefix(fnName, 'cancelOrContext') +
|
||||
' must either be a cancel callback or a context object.');
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
get ref() {
|
||||
return new Reference(this.database, new database._ReferenceImpl(this._delegate._repo, this._delegate._path));
|
||||
}
|
||||
}
|
||||
class Reference extends Query {
|
||||
/**
|
||||
* Call options:
|
||||
* new Reference(Repo, Path) or
|
||||
* new Reference(url: string, string|RepoManager)
|
||||
*
|
||||
* Externally - this is the firebase.database.Reference type.
|
||||
*/
|
||||
constructor(database$1, _delegate) {
|
||||
super(database$1, new database._QueryImpl(_delegate._repo, _delegate._path, new database._QueryParams(), false));
|
||||
this.database = database$1;
|
||||
this._delegate = _delegate;
|
||||
}
|
||||
/** @returns {?string} */
|
||||
getKey() {
|
||||
util.validateArgCount('Reference.key', 0, 0, arguments.length);
|
||||
return this._delegate.key;
|
||||
}
|
||||
child(pathString) {
|
||||
util.validateArgCount('Reference.child', 1, 1, arguments.length);
|
||||
if (typeof pathString === 'number') {
|
||||
pathString = String(pathString);
|
||||
}
|
||||
return new Reference(this.database, database.child(this._delegate, pathString));
|
||||
}
|
||||
/** @returns {?Reference} */
|
||||
getParent() {
|
||||
util.validateArgCount('Reference.parent', 0, 0, arguments.length);
|
||||
const parent = this._delegate.parent;
|
||||
return parent ? new Reference(this.database, parent) : null;
|
||||
}
|
||||
/** @returns {!Reference} */
|
||||
getRoot() {
|
||||
util.validateArgCount('Reference.root', 0, 0, arguments.length);
|
||||
return new Reference(this.database, this._delegate.root);
|
||||
}
|
||||
set(newVal, onComplete) {
|
||||
util.validateArgCount('Reference.set', 1, 2, arguments.length);
|
||||
util.validateCallback('Reference.set', 'onComplete', onComplete, true);
|
||||
const result = database.set(this._delegate, newVal);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
update(values, onComplete) {
|
||||
util.validateArgCount('Reference.update', 1, 2, arguments.length);
|
||||
if (Array.isArray(values)) {
|
||||
const newObjectToMerge = {};
|
||||
for (let i = 0; i < values.length; ++i) {
|
||||
newObjectToMerge['' + i] = values[i];
|
||||
}
|
||||
values = newObjectToMerge;
|
||||
warn('Passing an Array to Firebase.update() is deprecated. ' +
|
||||
'Use set() if you want to overwrite the existing data, or ' +
|
||||
'an Object with integer keys if you really do want to ' +
|
||||
'only update some of the children.');
|
||||
}
|
||||
database._validateWritablePath('Reference.update', this._delegate._path);
|
||||
util.validateCallback('Reference.update', 'onComplete', onComplete, true);
|
||||
const result = database.update(this._delegate, values);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
setWithPriority(newVal, newPriority, onComplete) {
|
||||
util.validateArgCount('Reference.setWithPriority', 2, 3, arguments.length);
|
||||
util.validateCallback('Reference.setWithPriority', 'onComplete', onComplete, true);
|
||||
const result = database.setWithPriority(this._delegate, newVal, newPriority);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
remove(onComplete) {
|
||||
util.validateArgCount('Reference.remove', 0, 1, arguments.length);
|
||||
util.validateCallback('Reference.remove', 'onComplete', onComplete, true);
|
||||
const result = database.remove(this._delegate);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
transaction(transactionUpdate, onComplete, applyLocally) {
|
||||
util.validateArgCount('Reference.transaction', 1, 3, arguments.length);
|
||||
util.validateCallback('Reference.transaction', 'transactionUpdate', transactionUpdate, false);
|
||||
util.validateCallback('Reference.transaction', 'onComplete', onComplete, true);
|
||||
validateBoolean('Reference.transaction', 'applyLocally', applyLocally, true);
|
||||
const result = database.runTransaction(this._delegate, transactionUpdate, {
|
||||
applyLocally
|
||||
}).then(transactionResult => new TransactionResult(transactionResult.committed, new DataSnapshot(this.database, transactionResult.snapshot)));
|
||||
if (onComplete) {
|
||||
result.then(transactionResult => onComplete(null, transactionResult.committed, transactionResult.snapshot), error => onComplete(error, false, null));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
setPriority(priority, onComplete) {
|
||||
util.validateArgCount('Reference.setPriority', 1, 2, arguments.length);
|
||||
util.validateCallback('Reference.setPriority', 'onComplete', onComplete, true);
|
||||
const result = database.setPriority(this._delegate, priority);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
push(value, onComplete) {
|
||||
util.validateArgCount('Reference.push', 0, 2, arguments.length);
|
||||
util.validateCallback('Reference.push', 'onComplete', onComplete, true);
|
||||
const expPromise = database.push(this._delegate, value);
|
||||
const promise = expPromise.then(expRef => new Reference(this.database, expRef));
|
||||
if (onComplete) {
|
||||
promise.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
const result = new Reference(this.database, expPromise);
|
||||
result.then = promise.then.bind(promise);
|
||||
result.catch = promise.catch.bind(promise, undefined);
|
||||
return result;
|
||||
}
|
||||
onDisconnect() {
|
||||
database._validateWritablePath('Reference.onDisconnect', this._delegate._path);
|
||||
return new OnDisconnect(new database.OnDisconnect(this._delegate._repo, this._delegate._path));
|
||||
}
|
||||
get key() {
|
||||
return this.getKey();
|
||||
}
|
||||
get parent() {
|
||||
return this.getParent();
|
||||
}
|
||||
get root() {
|
||||
return this.getRoot();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* Class representing a firebase database.
|
||||
*/
|
||||
class Database {
|
||||
/**
|
||||
* The constructor should not be called by users of our public API.
|
||||
*/
|
||||
constructor(_delegate, app) {
|
||||
this._delegate = _delegate;
|
||||
this.app = app;
|
||||
this.INTERNAL = {
|
||||
delete: () => this._delegate._delete(),
|
||||
forceWebSockets: database.forceWebSockets,
|
||||
forceLongPolling: database.forceLongPolling
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Modify this instance to communicate with the Realtime Database emulator.
|
||||
*
|
||||
* <p>Note: This method must be called before performing any other operation.
|
||||
*
|
||||
* @param host - the emulator host (ex: localhost)
|
||||
* @param port - the emulator port (ex: 8080)
|
||||
* @param options.mockUserToken - the mock auth token to use for unit testing Security Rules
|
||||
*/
|
||||
useEmulator(host, port, options = {}) {
|
||||
database.connectDatabaseEmulator(this._delegate, host, port, options);
|
||||
}
|
||||
ref(path) {
|
||||
util.validateArgCount('database.ref', 0, 1, arguments.length);
|
||||
if (path instanceof Reference) {
|
||||
const childRef = database.refFromURL(this._delegate, path.toString());
|
||||
return new Reference(this, childRef);
|
||||
}
|
||||
else {
|
||||
const childRef = database.ref(this._delegate, path);
|
||||
return new Reference(this, childRef);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns a reference to the root or the path specified in url.
|
||||
* We throw a exception if the url is not in the same domain as the
|
||||
* current repo.
|
||||
* @returns Firebase reference.
|
||||
*/
|
||||
refFromURL(url) {
|
||||
const apiName = 'database.refFromURL';
|
||||
util.validateArgCount(apiName, 1, 1, arguments.length);
|
||||
const childRef = database.refFromURL(this._delegate, url);
|
||||
return new Reference(this, childRef);
|
||||
}
|
||||
// Make individual repo go offline.
|
||||
goOffline() {
|
||||
util.validateArgCount('database.goOffline', 0, 0, arguments.length);
|
||||
return database.goOffline(this._delegate);
|
||||
}
|
||||
goOnline() {
|
||||
util.validateArgCount('database.goOnline', 0, 0, arguments.length);
|
||||
return database.goOnline(this._delegate);
|
||||
}
|
||||
}
|
||||
Database.ServerValue = {
|
||||
TIMESTAMP: database.serverTimestamp(),
|
||||
increment: (delta) => database.increment(delta)
|
||||
};
|
||||
|
||||
/**
|
||||
* Used by console to create a database based on the app,
|
||||
* passed database URL and a custom auth implementation.
|
||||
*
|
||||
* @param app - A valid FirebaseApp-like object
|
||||
* @param url - A valid Firebase databaseURL
|
||||
* @param version - custom version e.g. firebase-admin version
|
||||
* @param customAuthImpl - custom auth implementation
|
||||
*/
|
||||
function initStandalone({ app, url, version, customAuthImpl, customAppCheckImpl, namespace, nodeAdmin = false }) {
|
||||
database._setSDKVersion(version);
|
||||
const container = new component.ComponentContainer('database-standalone');
|
||||
/**
|
||||
* ComponentContainer('database-standalone') is just a placeholder that doesn't perform
|
||||
* any actual function.
|
||||
*/
|
||||
const authProvider = new component.Provider('auth-internal', container);
|
||||
authProvider.setComponent(new component.Component('auth-internal', () => customAuthImpl, "PRIVATE" /* ComponentType.PRIVATE */));
|
||||
let appCheckProvider = undefined;
|
||||
if (customAppCheckImpl) {
|
||||
appCheckProvider = new component.Provider('app-check-internal', container);
|
||||
appCheckProvider.setComponent(new component.Component('app-check-internal', () => customAppCheckImpl, "PRIVATE" /* ComponentType.PRIVATE */));
|
||||
}
|
||||
return {
|
||||
instance: new Database(database._repoManagerDatabaseFromApp(app, authProvider, appCheckProvider, url, nodeAdmin), app),
|
||||
namespace
|
||||
};
|
||||
}
|
||||
|
||||
var INTERNAL = /*#__PURE__*/Object.freeze({
|
||||
__proto__: null,
|
||||
initStandalone: initStandalone
|
||||
});
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
const ServerValue = Database.ServerValue;
|
||||
function registerDatabase(instance) {
|
||||
// Register the Database Service with the 'firebase' namespace.
|
||||
instance.INTERNAL.registerComponent(new component.Component('database-compat', (container, { instanceIdentifier: url }) => {
|
||||
/* Dependencies */
|
||||
// getImmediate for FirebaseApp will always succeed
|
||||
const app = container.getProvider('app-compat').getImmediate();
|
||||
const databaseExp = container
|
||||
.getProvider('database')
|
||||
.getImmediate({ identifier: url });
|
||||
return new Database(databaseExp, app);
|
||||
}, "PUBLIC" /* ComponentType.PUBLIC */)
|
||||
.setServiceProps(
|
||||
// firebase.database namespace properties
|
||||
{
|
||||
Reference,
|
||||
Query,
|
||||
Database,
|
||||
DataSnapshot,
|
||||
enableLogging: database.enableLogging,
|
||||
INTERNAL,
|
||||
ServerValue
|
||||
})
|
||||
.setMultipleInstances(true));
|
||||
instance.registerVersion(name, version, 'node');
|
||||
}
|
||||
registerDatabase(firebase__default["default"]);
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
server/node_modules/@firebase/database-compat/dist/index.js.map
generated
vendored
Normal file
1
server/node_modules/@firebase/database-compat/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
19814
server/node_modules/@firebase/database-compat/dist/index.standalone.js
generated
vendored
Normal file
19814
server/node_modules/@firebase/database-compat/dist/index.standalone.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
server/node_modules/@firebase/database-compat/dist/index.standalone.js.map
generated
vendored
Normal file
1
server/node_modules/@firebase/database-compat/dist/index.standalone.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
74
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/api/Database.d.ts
generated
vendored
Normal file
74
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/api/Database.d.ts
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { FirebaseApp } from '@firebase/app-types';
|
||||
import { FirebaseService } from '@firebase/app-types/private';
|
||||
import { forceLongPolling, forceWebSockets, Database as ModularDatabase } from '@firebase/database';
|
||||
import { Compat, EmulatorMockTokenOptions } from '@firebase/util';
|
||||
import { Reference } from './Reference';
|
||||
/**
|
||||
* Class representing a firebase database.
|
||||
*/
|
||||
export declare class Database implements FirebaseService, Compat<ModularDatabase> {
|
||||
readonly _delegate: ModularDatabase;
|
||||
readonly app: FirebaseApp;
|
||||
static readonly ServerValue: {
|
||||
TIMESTAMP: object;
|
||||
increment: (delta: number) => object;
|
||||
};
|
||||
/**
|
||||
* The constructor should not be called by users of our public API.
|
||||
*/
|
||||
constructor(_delegate: ModularDatabase, app: FirebaseApp);
|
||||
INTERNAL: {
|
||||
delete: () => Promise<void>;
|
||||
forceWebSockets: typeof forceWebSockets;
|
||||
forceLongPolling: typeof forceLongPolling;
|
||||
};
|
||||
/**
|
||||
* Modify this instance to communicate with the Realtime Database emulator.
|
||||
*
|
||||
* <p>Note: This method must be called before performing any other operation.
|
||||
*
|
||||
* @param host - the emulator host (ex: localhost)
|
||||
* @param port - the emulator port (ex: 8080)
|
||||
* @param options.mockUserToken - the mock auth token to use for unit testing Security Rules
|
||||
*/
|
||||
useEmulator(host: string, port: number, options?: {
|
||||
mockUserToken?: EmulatorMockTokenOptions;
|
||||
}): void;
|
||||
/**
|
||||
* Returns a reference to the root or to the path specified in the provided
|
||||
* argument.
|
||||
*
|
||||
* @param path - The relative string path or an existing Reference to a database
|
||||
* location.
|
||||
* @throws If a Reference is provided, throws if it does not belong to the
|
||||
* same project.
|
||||
* @returns Firebase reference.
|
||||
*/
|
||||
ref(path?: string): Reference;
|
||||
ref(path?: Reference): Reference;
|
||||
/**
|
||||
* Returns a reference to the root or the path specified in url.
|
||||
* We throw a exception if the url is not in the same domain as the
|
||||
* current repo.
|
||||
* @returns Firebase reference.
|
||||
*/
|
||||
refFromURL(url: string): Reference;
|
||||
goOffline(): void;
|
||||
goOnline(): void;
|
||||
}
|
||||
207
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/api/Reference.d.ts
generated
vendored
Normal file
207
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/api/Reference.d.ts
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { DataSnapshot as ModularDataSnapshot, Query as ExpQuery, DatabaseReference as ModularReference } from '@firebase/database';
|
||||
import { Compat } from '@firebase/util';
|
||||
import { Database } from './Database';
|
||||
import { OnDisconnect } from './onDisconnect';
|
||||
import { TransactionResult } from './TransactionResult';
|
||||
/**
|
||||
* Class representing a firebase data snapshot. It wraps a SnapshotNode and
|
||||
* surfaces the public methods (val, forEach, etc.) we want to expose.
|
||||
*/
|
||||
export declare class DataSnapshot implements Compat<ModularDataSnapshot> {
|
||||
readonly _database: Database;
|
||||
readonly _delegate: ModularDataSnapshot;
|
||||
constructor(_database: Database, _delegate: ModularDataSnapshot);
|
||||
/**
|
||||
* Retrieves the snapshot contents as JSON. Returns null if the snapshot is
|
||||
* empty.
|
||||
*
|
||||
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
||||
*/
|
||||
val(): unknown;
|
||||
/**
|
||||
* Returns the snapshot contents as JSON, including priorities of node. Suitable for exporting
|
||||
* the entire node contents.
|
||||
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
||||
*/
|
||||
exportVal(): unknown;
|
||||
toJSON(): unknown;
|
||||
/**
|
||||
* Returns whether the snapshot contains a non-null value.
|
||||
*
|
||||
* @returns Whether the snapshot contains a non-null value, or is empty.
|
||||
*/
|
||||
exists(): boolean;
|
||||
/**
|
||||
* Returns a DataSnapshot of the specified child node's contents.
|
||||
*
|
||||
* @param path - Path to a child.
|
||||
* @returns DataSnapshot for child node.
|
||||
*/
|
||||
child(path: string): DataSnapshot;
|
||||
/**
|
||||
* Returns whether the snapshot contains a child at the specified path.
|
||||
*
|
||||
* @param path - Path to a child.
|
||||
* @returns Whether the child exists.
|
||||
*/
|
||||
hasChild(path: string): boolean;
|
||||
/**
|
||||
* Returns the priority of the object, or null if no priority was set.
|
||||
*
|
||||
* @returns The priority.
|
||||
*/
|
||||
getPriority(): string | number | null;
|
||||
/**
|
||||
* Iterates through child nodes and calls the specified action for each one.
|
||||
*
|
||||
* @param action - Callback function to be called
|
||||
* for each child.
|
||||
* @returns True if forEach was canceled by action returning true for
|
||||
* one of the child nodes.
|
||||
*/
|
||||
forEach(action: (snapshot: IteratedDataSnapshot) => boolean | void): boolean;
|
||||
/**
|
||||
* Returns whether this DataSnapshot has children.
|
||||
* @returns True if the DataSnapshot contains 1 or more child nodes.
|
||||
*/
|
||||
hasChildren(): boolean;
|
||||
get key(): string;
|
||||
/**
|
||||
* Returns the number of children for this DataSnapshot.
|
||||
* @returns The number of children that this DataSnapshot contains.
|
||||
*/
|
||||
numChildren(): number;
|
||||
/**
|
||||
* @returns The Firebase reference for the location this snapshot's data came
|
||||
* from.
|
||||
*/
|
||||
getRef(): Reference;
|
||||
get ref(): Reference;
|
||||
}
|
||||
/**
|
||||
* Represents a child snapshot of a `Reference` that is being iterated over. The key will never be undefined.
|
||||
*/
|
||||
export interface IteratedDataSnapshot extends DataSnapshot {
|
||||
key: string;
|
||||
}
|
||||
export interface SnapshotCallback {
|
||||
(dataSnapshot: DataSnapshot, previousChildName?: string | null): unknown;
|
||||
}
|
||||
/**
|
||||
* A Query represents a filter to be applied to a firebase location. This object purely represents the
|
||||
* query expression (and exposes our public API to build the query). The actual query logic is in ViewBase.js.
|
||||
*
|
||||
* Since every Firebase reference is a query, Firebase inherits from this object.
|
||||
*/
|
||||
export declare class Query implements Compat<ExpQuery> {
|
||||
readonly database: Database;
|
||||
readonly _delegate: ExpQuery;
|
||||
constructor(database: Database, _delegate: ExpQuery);
|
||||
on(eventType: string, callback: SnapshotCallback, cancelCallbackOrContext?: ((a: Error) => unknown) | object | null, context?: object | null): SnapshotCallback;
|
||||
off(eventType?: string, callback?: SnapshotCallback, context?: object | null): void;
|
||||
/**
|
||||
* Get the server-value for this query, or return a cached value if not connected.
|
||||
*/
|
||||
get(): Promise<DataSnapshot>;
|
||||
/**
|
||||
* Attaches a listener, waits for the first event, and then removes the listener
|
||||
*/
|
||||
once(eventType: string, callback?: SnapshotCallback, failureCallbackOrContext?: ((a: Error) => void) | object | null, context?: object | null): Promise<DataSnapshot>;
|
||||
/**
|
||||
* Set a limit and anchor it to the start of the window.
|
||||
*/
|
||||
limitToFirst(limit: number): Query;
|
||||
/**
|
||||
* Set a limit and anchor it to the end of the window.
|
||||
*/
|
||||
limitToLast(limit: number): Query;
|
||||
/**
|
||||
* Given a child path, return a new query ordered by the specified grandchild path.
|
||||
*/
|
||||
orderByChild(path: string): Query;
|
||||
/**
|
||||
* Return a new query ordered by the KeyIndex
|
||||
*/
|
||||
orderByKey(): Query;
|
||||
/**
|
||||
* Return a new query ordered by the PriorityIndex
|
||||
*/
|
||||
orderByPriority(): Query;
|
||||
/**
|
||||
* Return a new query ordered by the ValueIndex
|
||||
*/
|
||||
orderByValue(): Query;
|
||||
startAt(value?: number | string | boolean | null, name?: string | null): Query;
|
||||
startAfter(value?: number | string | boolean | null, name?: string | null): Query;
|
||||
endAt(value?: number | string | boolean | null, name?: string | null): Query;
|
||||
endBefore(value?: number | string | boolean | null, name?: string | null): Query;
|
||||
/**
|
||||
* Load the selection of children with exactly the specified value, and, optionally,
|
||||
* the specified name.
|
||||
*/
|
||||
equalTo(value: number | string | boolean | null, name?: string): Query;
|
||||
/**
|
||||
* @returns URL for this location.
|
||||
*/
|
||||
toString(): string;
|
||||
toJSON(): string;
|
||||
/**
|
||||
* Return true if this query and the provided query are equivalent; otherwise, return false.
|
||||
*/
|
||||
isEqual(other: Query): boolean;
|
||||
/**
|
||||
* Helper used by .on and .once to extract the context and or cancel arguments.
|
||||
* @param fnName - The function name (on or once)
|
||||
*
|
||||
*/
|
||||
private static getCancelAndContextArgs_;
|
||||
get ref(): Reference;
|
||||
}
|
||||
export declare class Reference extends Query implements Compat<ModularReference> {
|
||||
readonly database: Database;
|
||||
readonly _delegate: ModularReference;
|
||||
then: Promise<Reference>['then'];
|
||||
catch: Promise<Reference>['catch'];
|
||||
/**
|
||||
* Call options:
|
||||
* new Reference(Repo, Path) or
|
||||
* new Reference(url: string, string|RepoManager)
|
||||
*
|
||||
* Externally - this is the firebase.database.Reference type.
|
||||
*/
|
||||
constructor(database: Database, _delegate: ModularReference);
|
||||
/** @returns {?string} */
|
||||
getKey(): string | null;
|
||||
child(pathString: string): Reference;
|
||||
/** @returns {?Reference} */
|
||||
getParent(): Reference | null;
|
||||
/** @returns {!Reference} */
|
||||
getRoot(): Reference;
|
||||
set(newVal: unknown, onComplete?: (error: Error | null) => void): Promise<void>;
|
||||
update(values: object, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
setWithPriority(newVal: unknown, newPriority: string | number | null, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
remove(onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
transaction(transactionUpdate: (currentData: unknown) => unknown, onComplete?: (error: Error | null, committed: boolean, dataSnapshot: DataSnapshot | null) => void, applyLocally?: boolean): Promise<TransactionResult>;
|
||||
setPriority(priority: string | number | null, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
push(value?: unknown, onComplete?: (a: Error | null) => void): Reference;
|
||||
onDisconnect(): OnDisconnect;
|
||||
get key(): string | null;
|
||||
get parent(): Reference | null;
|
||||
get root(): Reference;
|
||||
}
|
||||
26
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/api/TransactionResult.d.ts
generated
vendored
Normal file
26
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/api/TransactionResult.d.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { DataSnapshot } from './Reference';
|
||||
export declare class TransactionResult {
|
||||
committed: boolean;
|
||||
snapshot: DataSnapshot;
|
||||
/**
|
||||
* A type for the resolve value of Firebase.transaction.
|
||||
*/
|
||||
constructor(committed: boolean, snapshot: DataSnapshot);
|
||||
toJSON(): object;
|
||||
}
|
||||
41
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/api/internal.d.ts
generated
vendored
Normal file
41
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/api/internal.d.ts
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { FirebaseAppCheckInternal } from '@firebase/app-check-interop-types';
|
||||
import { FirebaseApp } from '@firebase/app-types';
|
||||
import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
|
||||
import * as types from '@firebase/database-types';
|
||||
/**
|
||||
* Used by console to create a database based on the app,
|
||||
* passed database URL and a custom auth implementation.
|
||||
*
|
||||
* @param app - A valid FirebaseApp-like object
|
||||
* @param url - A valid Firebase databaseURL
|
||||
* @param version - custom version e.g. firebase-admin version
|
||||
* @param customAuthImpl - custom auth implementation
|
||||
*/
|
||||
export declare function initStandalone<T>({ app, url, version, customAuthImpl, customAppCheckImpl, namespace, nodeAdmin }: {
|
||||
app: FirebaseApp;
|
||||
url: string;
|
||||
version: string;
|
||||
customAuthImpl: FirebaseAuthInternal;
|
||||
customAppCheckImpl?: FirebaseAppCheckInternal;
|
||||
namespace: T;
|
||||
nodeAdmin?: boolean;
|
||||
}): {
|
||||
instance: types.Database;
|
||||
namespace: T;
|
||||
};
|
||||
27
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/api/onDisconnect.d.ts
generated
vendored
Normal file
27
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/api/onDisconnect.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { OnDisconnect as ModularOnDisconnect } from '@firebase/database';
|
||||
import { Compat } from '@firebase/util';
|
||||
export declare class OnDisconnect implements Compat<ModularOnDisconnect> {
|
||||
readonly _delegate: ModularOnDisconnect;
|
||||
constructor(_delegate: ModularOnDisconnect);
|
||||
cancel(onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
remove(onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
set(value: unknown, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
setWithPriority(value: unknown, priority: number | string | null, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
update(objectToMerge: Record<string, unknown>, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
}
|
||||
32
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/index.d.ts
generated
vendored
Normal file
32
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { FirebaseNamespace } from '@firebase/app-compat';
|
||||
import * as types from '@firebase/database-types';
|
||||
export declare function registerDatabase(instance: FirebaseNamespace): void;
|
||||
declare module '@firebase/app-compat' {
|
||||
interface FirebaseNamespace {
|
||||
database?: {
|
||||
(app?: FirebaseApp): types.FirebaseDatabase;
|
||||
enableLogging: typeof types.enableLogging;
|
||||
ServerValue: types.ServerValue;
|
||||
Database: typeof types.FirebaseDatabase;
|
||||
};
|
||||
}
|
||||
interface FirebaseApp {
|
||||
database?(databaseURL?: string): types.FirebaseDatabase;
|
||||
}
|
||||
}
|
||||
30
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/index.node.d.ts
generated
vendored
Normal file
30
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/index.node.d.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import * as types from '@firebase/database-types';
|
||||
declare module '@firebase/app-compat' {
|
||||
interface FirebaseNamespace {
|
||||
database?: {
|
||||
(app?: FirebaseApp): types.FirebaseDatabase;
|
||||
enableLogging: typeof types.enableLogging;
|
||||
ServerValue: types.ServerValue;
|
||||
Database: typeof types.FirebaseDatabase;
|
||||
};
|
||||
}
|
||||
interface FirebaseApp {
|
||||
database?(): types.FirebaseDatabase;
|
||||
}
|
||||
}
|
||||
52
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/index.standalone.d.ts
generated
vendored
Normal file
52
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/index.standalone.d.ts
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { FirebaseApp } from '@firebase/app-types';
|
||||
import { enableLogging } from '@firebase/database';
|
||||
import { Database } from './api/Database';
|
||||
import * as INTERNAL from './api/internal';
|
||||
import { DataSnapshot, Query, Reference } from './api/Reference';
|
||||
declare const ServerValue: {
|
||||
TIMESTAMP: object;
|
||||
increment: (delta: number) => object;
|
||||
};
|
||||
/**
|
||||
* A one off register function which returns a database based on the app and
|
||||
* passed database URL. (Used by the Admin SDK)
|
||||
*
|
||||
* @param app - A valid FirebaseApp-like object
|
||||
* @param url - A valid Firebase databaseURL
|
||||
* @param version - custom version e.g. firebase-admin version
|
||||
* @param nodeAdmin - true if the SDK is being initialized from Firebase Admin.
|
||||
*/
|
||||
export declare function initStandalone(app: FirebaseApp, url: string, version: string, nodeAdmin?: boolean): {
|
||||
instance: import("@firebase/database-types").Database;
|
||||
namespace: {
|
||||
Reference: typeof Reference;
|
||||
Query: typeof Query;
|
||||
Database: typeof Database;
|
||||
DataSnapshot: typeof DataSnapshot;
|
||||
enableLogging: typeof enableLogging;
|
||||
INTERNAL: typeof INTERNAL;
|
||||
ServerValue: {
|
||||
TIMESTAMP: object;
|
||||
increment: (delta: number) => object;
|
||||
};
|
||||
};
|
||||
};
|
||||
export { Database, Query, Reference, enableLogging, ServerValue };
|
||||
export { OnDisconnect } from '@firebase/database';
|
||||
export { DataSnapshot } from './api/Reference';
|
||||
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/util/util.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/util/util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export declare const warn: (msg: string) => void;
|
||||
18
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/util/validation.d.ts
generated
vendored
Normal file
18
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/src/util/validation.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export declare const validateBoolean: (fnName: string, argumentName: string, bool: unknown, optional: boolean) => void;
|
||||
export declare const validateEventType: (fnName: string, eventType: string, optional: boolean) => void;
|
||||
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/browser/crawler_support.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/browser/crawler_support.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/database.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/database.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import '../src/index';
|
||||
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/datasnapshot.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/datasnapshot.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
34
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/helpers/events.d.ts
generated
vendored
Normal file
34
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/helpers/events.d.ts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* A set of functions to clean up event handlers.
|
||||
*/
|
||||
export declare let eventCleanupHandlers: any[];
|
||||
/** Clean up outstanding event handlers */
|
||||
export declare function eventCleanup(): void;
|
||||
/**
|
||||
* Creates a struct which waits for many events.
|
||||
* @param pathAndEvents - an array of tuples of [Firebase, [event type strings]]
|
||||
*/
|
||||
export declare function eventTestHelper(pathAndEvents: any, helperName?: any): {
|
||||
promise: Promise<unknown>;
|
||||
initPromise: Promise<unknown>;
|
||||
waiter: () => boolean;
|
||||
watchesInitializedWaiter: () => boolean;
|
||||
unregister: () => void;
|
||||
addExpectedEvents(moreEvents: any): void;
|
||||
};
|
||||
42
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/helpers/util.d.ts
generated
vendored
Normal file
42
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/helpers/util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import '../../src/index';
|
||||
import { Path } from '../../../database/src/core/util/Path';
|
||||
import { Query, Reference } from '../../src/api/Reference';
|
||||
export declare const TEST_PROJECT: any;
|
||||
export declare const DATABASE_ADDRESS: any;
|
||||
export declare const DATABASE_URL: any;
|
||||
export declare function createTestApp(): import("@firebase/app-compat").FirebaseApp;
|
||||
/**
|
||||
* Gets or creates a root node to the test namespace. All calls sharing the
|
||||
* value of opt_i will share an app context.
|
||||
*/
|
||||
export declare function getRootNode(i?: number, ref?: string): any;
|
||||
/**
|
||||
* Create multiple refs to the same top level
|
||||
* push key - each on its own Firebase.Context.
|
||||
*/
|
||||
export declare function getRandomNode(numNodes?: any): Reference | Reference[];
|
||||
export declare function getQueryValue(query: Query): Promise<unknown>;
|
||||
export declare function pause(milliseconds: number): Promise<void>;
|
||||
export declare function getPath(query: Query): string;
|
||||
export declare function shuffle(arr: any, randFn?: () => number): void;
|
||||
export declare function getFreshRepo(path: Path): any;
|
||||
export declare function getFreshRepoFromReference(ref: any): any;
|
||||
export declare function getSnap(path: any): any;
|
||||
export declare function getVal(path: any): any;
|
||||
export declare function canCreateExtraConnections(): boolean;
|
||||
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/info.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/info.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/order.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/order.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/order_by.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/order_by.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/promise.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/promise.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/query.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/query.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/servervalues.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/servervalues.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/transaction.test.d.ts
generated
vendored
Normal file
17
server/node_modules/@firebase/database-compat/dist/node-esm/database-compat/test/transaction.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import '../src/index';
|
||||
858
server/node_modules/@firebase/database-compat/dist/node-esm/index.js
generated
vendored
Normal file
858
server/node_modules/@firebase/database-compat/dist/node-esm/index.js
generated
vendored
Normal file
@@ -0,0 +1,858 @@
|
||||
import firebase from '@firebase/app-compat';
|
||||
import { ComponentContainer, Provider, Component } from '@firebase/component';
|
||||
import { _validatePathString, onChildMoved, onChildChanged, onChildRemoved, onChildAdded, onValue, off, get, query, limitToFirst, limitToLast, orderByChild, orderByKey, orderByPriority, orderByValue, startAt, startAfter, endAt, endBefore, equalTo, _ReferenceImpl, _QueryImpl, _QueryParams, child, set, _validateWritablePath, update, setWithPriority, remove, runTransaction, setPriority, push, OnDisconnect as OnDisconnect$1, forceWebSockets, forceLongPolling, connectDatabaseEmulator, refFromURL, ref, goOffline, goOnline, serverTimestamp, increment, _setSDKVersion, _repoManagerDatabaseFromApp, enableLogging } from '@firebase/database';
|
||||
import { errorPrefix, validateArgCount, validateCallback, validateContextObject, Deferred } from '@firebase/util';
|
||||
import { Logger } from '@firebase/logger';
|
||||
|
||||
const name = "@firebase/database-compat";
|
||||
const version = "2.1.0";
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
const logClient = new Logger('@firebase/database-compat');
|
||||
const warn = function (msg) {
|
||||
const message = 'FIREBASE WARNING: ' + msg;
|
||||
logClient.warn(message);
|
||||
};
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
const validateBoolean = function (fnName, argumentName, bool, optional) {
|
||||
if (optional && bool === undefined) {
|
||||
return;
|
||||
}
|
||||
if (typeof bool !== 'boolean') {
|
||||
throw new Error(errorPrefix(fnName, argumentName) + 'must be a boolean.');
|
||||
}
|
||||
};
|
||||
const validateEventType = function (fnName, eventType, optional) {
|
||||
if (optional && eventType === undefined) {
|
||||
return;
|
||||
}
|
||||
switch (eventType) {
|
||||
case 'value':
|
||||
case 'child_added':
|
||||
case 'child_removed':
|
||||
case 'child_changed':
|
||||
case 'child_moved':
|
||||
break;
|
||||
default:
|
||||
throw new Error(errorPrefix(fnName, 'eventType') +
|
||||
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
||||
'"child_changed", or "child_moved".');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
class OnDisconnect {
|
||||
constructor(_delegate) {
|
||||
this._delegate = _delegate;
|
||||
}
|
||||
cancel(onComplete) {
|
||||
validateArgCount('OnDisconnect.cancel', 0, 1, arguments.length);
|
||||
validateCallback('OnDisconnect.cancel', 'onComplete', onComplete, true);
|
||||
const result = this._delegate.cancel();
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
remove(onComplete) {
|
||||
validateArgCount('OnDisconnect.remove', 0, 1, arguments.length);
|
||||
validateCallback('OnDisconnect.remove', 'onComplete', onComplete, true);
|
||||
const result = this._delegate.remove();
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
set(value, onComplete) {
|
||||
validateArgCount('OnDisconnect.set', 1, 2, arguments.length);
|
||||
validateCallback('OnDisconnect.set', 'onComplete', onComplete, true);
|
||||
const result = this._delegate.set(value);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
setWithPriority(value, priority, onComplete) {
|
||||
validateArgCount('OnDisconnect.setWithPriority', 2, 3, arguments.length);
|
||||
validateCallback('OnDisconnect.setWithPriority', 'onComplete', onComplete, true);
|
||||
const result = this._delegate.setWithPriority(value, priority);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
update(objectToMerge, onComplete) {
|
||||
validateArgCount('OnDisconnect.update', 1, 2, arguments.length);
|
||||
if (Array.isArray(objectToMerge)) {
|
||||
const newObjectToMerge = {};
|
||||
for (let i = 0; i < objectToMerge.length; ++i) {
|
||||
newObjectToMerge['' + i] = objectToMerge[i];
|
||||
}
|
||||
objectToMerge = newObjectToMerge;
|
||||
warn('Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the ' +
|
||||
'existing data, or an Object with integer keys if you really do want to only update some of the children.');
|
||||
}
|
||||
validateCallback('OnDisconnect.update', 'onComplete', onComplete, true);
|
||||
const result = this._delegate.update(objectToMerge);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
class TransactionResult {
|
||||
/**
|
||||
* A type for the resolve value of Firebase.transaction.
|
||||
*/
|
||||
constructor(committed, snapshot) {
|
||||
this.committed = committed;
|
||||
this.snapshot = snapshot;
|
||||
}
|
||||
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
||||
// for end-users
|
||||
toJSON() {
|
||||
validateArgCount('TransactionResult.toJSON', 0, 1, arguments.length);
|
||||
return { committed: this.committed, snapshot: this.snapshot.toJSON() };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* Class representing a firebase data snapshot. It wraps a SnapshotNode and
|
||||
* surfaces the public methods (val, forEach, etc.) we want to expose.
|
||||
*/
|
||||
class DataSnapshot {
|
||||
constructor(_database, _delegate) {
|
||||
this._database = _database;
|
||||
this._delegate = _delegate;
|
||||
}
|
||||
/**
|
||||
* Retrieves the snapshot contents as JSON. Returns null if the snapshot is
|
||||
* empty.
|
||||
*
|
||||
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
||||
*/
|
||||
val() {
|
||||
validateArgCount('DataSnapshot.val', 0, 0, arguments.length);
|
||||
return this._delegate.val();
|
||||
}
|
||||
/**
|
||||
* Returns the snapshot contents as JSON, including priorities of node. Suitable for exporting
|
||||
* the entire node contents.
|
||||
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
||||
*/
|
||||
exportVal() {
|
||||
validateArgCount('DataSnapshot.exportVal', 0, 0, arguments.length);
|
||||
return this._delegate.exportVal();
|
||||
}
|
||||
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
||||
// for end-users
|
||||
toJSON() {
|
||||
// Optional spacer argument is unnecessary because we're depending on recursion rather than stringifying the content
|
||||
validateArgCount('DataSnapshot.toJSON', 0, 1, arguments.length);
|
||||
return this._delegate.toJSON();
|
||||
}
|
||||
/**
|
||||
* Returns whether the snapshot contains a non-null value.
|
||||
*
|
||||
* @returns Whether the snapshot contains a non-null value, or is empty.
|
||||
*/
|
||||
exists() {
|
||||
validateArgCount('DataSnapshot.exists', 0, 0, arguments.length);
|
||||
return this._delegate.exists();
|
||||
}
|
||||
/**
|
||||
* Returns a DataSnapshot of the specified child node's contents.
|
||||
*
|
||||
* @param path - Path to a child.
|
||||
* @returns DataSnapshot for child node.
|
||||
*/
|
||||
child(path) {
|
||||
validateArgCount('DataSnapshot.child', 0, 1, arguments.length);
|
||||
// Ensure the childPath is a string (can be a number)
|
||||
path = String(path);
|
||||
_validatePathString('DataSnapshot.child', 'path', path, false);
|
||||
return new DataSnapshot(this._database, this._delegate.child(path));
|
||||
}
|
||||
/**
|
||||
* Returns whether the snapshot contains a child at the specified path.
|
||||
*
|
||||
* @param path - Path to a child.
|
||||
* @returns Whether the child exists.
|
||||
*/
|
||||
hasChild(path) {
|
||||
validateArgCount('DataSnapshot.hasChild', 1, 1, arguments.length);
|
||||
_validatePathString('DataSnapshot.hasChild', 'path', path, false);
|
||||
return this._delegate.hasChild(path);
|
||||
}
|
||||
/**
|
||||
* Returns the priority of the object, or null if no priority was set.
|
||||
*
|
||||
* @returns The priority.
|
||||
*/
|
||||
getPriority() {
|
||||
validateArgCount('DataSnapshot.getPriority', 0, 0, arguments.length);
|
||||
return this._delegate.priority;
|
||||
}
|
||||
/**
|
||||
* Iterates through child nodes and calls the specified action for each one.
|
||||
*
|
||||
* @param action - Callback function to be called
|
||||
* for each child.
|
||||
* @returns True if forEach was canceled by action returning true for
|
||||
* one of the child nodes.
|
||||
*/
|
||||
forEach(action) {
|
||||
validateArgCount('DataSnapshot.forEach', 1, 1, arguments.length);
|
||||
validateCallback('DataSnapshot.forEach', 'action', action, false);
|
||||
return this._delegate.forEach(expDataSnapshot => action(new DataSnapshot(this._database, expDataSnapshot)));
|
||||
}
|
||||
/**
|
||||
* Returns whether this DataSnapshot has children.
|
||||
* @returns True if the DataSnapshot contains 1 or more child nodes.
|
||||
*/
|
||||
hasChildren() {
|
||||
validateArgCount('DataSnapshot.hasChildren', 0, 0, arguments.length);
|
||||
return this._delegate.hasChildren();
|
||||
}
|
||||
get key() {
|
||||
return this._delegate.key;
|
||||
}
|
||||
/**
|
||||
* Returns the number of children for this DataSnapshot.
|
||||
* @returns The number of children that this DataSnapshot contains.
|
||||
*/
|
||||
numChildren() {
|
||||
validateArgCount('DataSnapshot.numChildren', 0, 0, arguments.length);
|
||||
return this._delegate.size;
|
||||
}
|
||||
/**
|
||||
* @returns The Firebase reference for the location this snapshot's data came
|
||||
* from.
|
||||
*/
|
||||
getRef() {
|
||||
validateArgCount('DataSnapshot.ref', 0, 0, arguments.length);
|
||||
return new Reference(this._database, this._delegate.ref);
|
||||
}
|
||||
get ref() {
|
||||
return this.getRef();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A Query represents a filter to be applied to a firebase location. This object purely represents the
|
||||
* query expression (and exposes our public API to build the query). The actual query logic is in ViewBase.js.
|
||||
*
|
||||
* Since every Firebase reference is a query, Firebase inherits from this object.
|
||||
*/
|
||||
class Query {
|
||||
constructor(database, _delegate) {
|
||||
this.database = database;
|
||||
this._delegate = _delegate;
|
||||
}
|
||||
on(eventType, callback, cancelCallbackOrContext, context) {
|
||||
validateArgCount('Query.on', 2, 4, arguments.length);
|
||||
validateCallback('Query.on', 'callback', callback, false);
|
||||
const ret = Query.getCancelAndContextArgs_('Query.on', cancelCallbackOrContext, context);
|
||||
const valueCallback = (expSnapshot, previousChildName) => {
|
||||
callback.call(ret.context, new DataSnapshot(this.database, expSnapshot), previousChildName);
|
||||
};
|
||||
valueCallback.userCallback = callback;
|
||||
valueCallback.context = ret.context;
|
||||
const cancelCallback = ret.cancel?.bind(ret.context);
|
||||
switch (eventType) {
|
||||
case 'value':
|
||||
onValue(this._delegate, valueCallback, cancelCallback);
|
||||
return callback;
|
||||
case 'child_added':
|
||||
onChildAdded(this._delegate, valueCallback, cancelCallback);
|
||||
return callback;
|
||||
case 'child_removed':
|
||||
onChildRemoved(this._delegate, valueCallback, cancelCallback);
|
||||
return callback;
|
||||
case 'child_changed':
|
||||
onChildChanged(this._delegate, valueCallback, cancelCallback);
|
||||
return callback;
|
||||
case 'child_moved':
|
||||
onChildMoved(this._delegate, valueCallback, cancelCallback);
|
||||
return callback;
|
||||
default:
|
||||
throw new Error(errorPrefix('Query.on', 'eventType') +
|
||||
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
||||
'"child_changed", or "child_moved".');
|
||||
}
|
||||
}
|
||||
off(eventType, callback, context) {
|
||||
validateArgCount('Query.off', 0, 3, arguments.length);
|
||||
validateEventType('Query.off', eventType, true);
|
||||
validateCallback('Query.off', 'callback', callback, true);
|
||||
validateContextObject('Query.off', 'context', context, true);
|
||||
if (callback) {
|
||||
const valueCallback = () => { };
|
||||
valueCallback.userCallback = callback;
|
||||
valueCallback.context = context;
|
||||
off(this._delegate, eventType, valueCallback);
|
||||
}
|
||||
else {
|
||||
off(this._delegate, eventType);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the server-value for this query, or return a cached value if not connected.
|
||||
*/
|
||||
get() {
|
||||
return get(this._delegate).then(expSnapshot => {
|
||||
return new DataSnapshot(this.database, expSnapshot);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Attaches a listener, waits for the first event, and then removes the listener
|
||||
*/
|
||||
once(eventType, callback, failureCallbackOrContext, context) {
|
||||
validateArgCount('Query.once', 1, 4, arguments.length);
|
||||
validateCallback('Query.once', 'callback', callback, true);
|
||||
const ret = Query.getCancelAndContextArgs_('Query.once', failureCallbackOrContext, context);
|
||||
const deferred = new Deferred();
|
||||
const valueCallback = (expSnapshot, previousChildName) => {
|
||||
const result = new DataSnapshot(this.database, expSnapshot);
|
||||
if (callback) {
|
||||
callback.call(ret.context, result, previousChildName);
|
||||
}
|
||||
deferred.resolve(result);
|
||||
};
|
||||
valueCallback.userCallback = callback;
|
||||
valueCallback.context = ret.context;
|
||||
const cancelCallback = (error) => {
|
||||
if (ret.cancel) {
|
||||
ret.cancel.call(ret.context, error);
|
||||
}
|
||||
deferred.reject(error);
|
||||
};
|
||||
switch (eventType) {
|
||||
case 'value':
|
||||
onValue(this._delegate, valueCallback, cancelCallback, {
|
||||
onlyOnce: true
|
||||
});
|
||||
break;
|
||||
case 'child_added':
|
||||
onChildAdded(this._delegate, valueCallback, cancelCallback, {
|
||||
onlyOnce: true
|
||||
});
|
||||
break;
|
||||
case 'child_removed':
|
||||
onChildRemoved(this._delegate, valueCallback, cancelCallback, {
|
||||
onlyOnce: true
|
||||
});
|
||||
break;
|
||||
case 'child_changed':
|
||||
onChildChanged(this._delegate, valueCallback, cancelCallback, {
|
||||
onlyOnce: true
|
||||
});
|
||||
break;
|
||||
case 'child_moved':
|
||||
onChildMoved(this._delegate, valueCallback, cancelCallback, {
|
||||
onlyOnce: true
|
||||
});
|
||||
break;
|
||||
default:
|
||||
throw new Error(errorPrefix('Query.once', 'eventType') +
|
||||
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
||||
'"child_changed", or "child_moved".');
|
||||
}
|
||||
return deferred.promise;
|
||||
}
|
||||
/**
|
||||
* Set a limit and anchor it to the start of the window.
|
||||
*/
|
||||
limitToFirst(limit) {
|
||||
validateArgCount('Query.limitToFirst', 1, 1, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, limitToFirst(limit)));
|
||||
}
|
||||
/**
|
||||
* Set a limit and anchor it to the end of the window.
|
||||
*/
|
||||
limitToLast(limit) {
|
||||
validateArgCount('Query.limitToLast', 1, 1, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, limitToLast(limit)));
|
||||
}
|
||||
/**
|
||||
* Given a child path, return a new query ordered by the specified grandchild path.
|
||||
*/
|
||||
orderByChild(path) {
|
||||
validateArgCount('Query.orderByChild', 1, 1, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, orderByChild(path)));
|
||||
}
|
||||
/**
|
||||
* Return a new query ordered by the KeyIndex
|
||||
*/
|
||||
orderByKey() {
|
||||
validateArgCount('Query.orderByKey', 0, 0, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, orderByKey()));
|
||||
}
|
||||
/**
|
||||
* Return a new query ordered by the PriorityIndex
|
||||
*/
|
||||
orderByPriority() {
|
||||
validateArgCount('Query.orderByPriority', 0, 0, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, orderByPriority()));
|
||||
}
|
||||
/**
|
||||
* Return a new query ordered by the ValueIndex
|
||||
*/
|
||||
orderByValue() {
|
||||
validateArgCount('Query.orderByValue', 0, 0, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, orderByValue()));
|
||||
}
|
||||
startAt(value = null, name) {
|
||||
validateArgCount('Query.startAt', 0, 2, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, startAt(value, name)));
|
||||
}
|
||||
startAfter(value = null, name) {
|
||||
validateArgCount('Query.startAfter', 0, 2, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, startAfter(value, name)));
|
||||
}
|
||||
endAt(value = null, name) {
|
||||
validateArgCount('Query.endAt', 0, 2, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, endAt(value, name)));
|
||||
}
|
||||
endBefore(value = null, name) {
|
||||
validateArgCount('Query.endBefore', 0, 2, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, endBefore(value, name)));
|
||||
}
|
||||
/**
|
||||
* Load the selection of children with exactly the specified value, and, optionally,
|
||||
* the specified name.
|
||||
*/
|
||||
equalTo(value, name) {
|
||||
validateArgCount('Query.equalTo', 1, 2, arguments.length);
|
||||
return new Query(this.database, query(this._delegate, equalTo(value, name)));
|
||||
}
|
||||
/**
|
||||
* @returns URL for this location.
|
||||
*/
|
||||
toString() {
|
||||
validateArgCount('Query.toString', 0, 0, arguments.length);
|
||||
return this._delegate.toString();
|
||||
}
|
||||
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
||||
// for end-users.
|
||||
toJSON() {
|
||||
// An optional spacer argument is unnecessary for a string.
|
||||
validateArgCount('Query.toJSON', 0, 1, arguments.length);
|
||||
return this._delegate.toJSON();
|
||||
}
|
||||
/**
|
||||
* Return true if this query and the provided query are equivalent; otherwise, return false.
|
||||
*/
|
||||
isEqual(other) {
|
||||
validateArgCount('Query.isEqual', 1, 1, arguments.length);
|
||||
if (!(other instanceof Query)) {
|
||||
const error = 'Query.isEqual failed: First argument must be an instance of firebase.database.Query.';
|
||||
throw new Error(error);
|
||||
}
|
||||
return this._delegate.isEqual(other._delegate);
|
||||
}
|
||||
/**
|
||||
* Helper used by .on and .once to extract the context and or cancel arguments.
|
||||
* @param fnName - The function name (on or once)
|
||||
*
|
||||
*/
|
||||
static getCancelAndContextArgs_(fnName, cancelOrContext, context) {
|
||||
const ret = { cancel: undefined, context: undefined };
|
||||
if (cancelOrContext && context) {
|
||||
ret.cancel = cancelOrContext;
|
||||
validateCallback(fnName, 'cancel', ret.cancel, true);
|
||||
ret.context = context;
|
||||
validateContextObject(fnName, 'context', ret.context, true);
|
||||
}
|
||||
else if (cancelOrContext) {
|
||||
// we have either a cancel callback or a context.
|
||||
if (typeof cancelOrContext === 'object' && cancelOrContext !== null) {
|
||||
// it's a context!
|
||||
ret.context = cancelOrContext;
|
||||
}
|
||||
else if (typeof cancelOrContext === 'function') {
|
||||
ret.cancel = cancelOrContext;
|
||||
}
|
||||
else {
|
||||
throw new Error(errorPrefix(fnName, 'cancelOrContext') +
|
||||
' must either be a cancel callback or a context object.');
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
get ref() {
|
||||
return new Reference(this.database, new _ReferenceImpl(this._delegate._repo, this._delegate._path));
|
||||
}
|
||||
}
|
||||
class Reference extends Query {
|
||||
/**
|
||||
* Call options:
|
||||
* new Reference(Repo, Path) or
|
||||
* new Reference(url: string, string|RepoManager)
|
||||
*
|
||||
* Externally - this is the firebase.database.Reference type.
|
||||
*/
|
||||
constructor(database, _delegate) {
|
||||
super(database, new _QueryImpl(_delegate._repo, _delegate._path, new _QueryParams(), false));
|
||||
this.database = database;
|
||||
this._delegate = _delegate;
|
||||
}
|
||||
/** @returns {?string} */
|
||||
getKey() {
|
||||
validateArgCount('Reference.key', 0, 0, arguments.length);
|
||||
return this._delegate.key;
|
||||
}
|
||||
child(pathString) {
|
||||
validateArgCount('Reference.child', 1, 1, arguments.length);
|
||||
if (typeof pathString === 'number') {
|
||||
pathString = String(pathString);
|
||||
}
|
||||
return new Reference(this.database, child(this._delegate, pathString));
|
||||
}
|
||||
/** @returns {?Reference} */
|
||||
getParent() {
|
||||
validateArgCount('Reference.parent', 0, 0, arguments.length);
|
||||
const parent = this._delegate.parent;
|
||||
return parent ? new Reference(this.database, parent) : null;
|
||||
}
|
||||
/** @returns {!Reference} */
|
||||
getRoot() {
|
||||
validateArgCount('Reference.root', 0, 0, arguments.length);
|
||||
return new Reference(this.database, this._delegate.root);
|
||||
}
|
||||
set(newVal, onComplete) {
|
||||
validateArgCount('Reference.set', 1, 2, arguments.length);
|
||||
validateCallback('Reference.set', 'onComplete', onComplete, true);
|
||||
const result = set(this._delegate, newVal);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
update(values, onComplete) {
|
||||
validateArgCount('Reference.update', 1, 2, arguments.length);
|
||||
if (Array.isArray(values)) {
|
||||
const newObjectToMerge = {};
|
||||
for (let i = 0; i < values.length; ++i) {
|
||||
newObjectToMerge['' + i] = values[i];
|
||||
}
|
||||
values = newObjectToMerge;
|
||||
warn('Passing an Array to Firebase.update() is deprecated. ' +
|
||||
'Use set() if you want to overwrite the existing data, or ' +
|
||||
'an Object with integer keys if you really do want to ' +
|
||||
'only update some of the children.');
|
||||
}
|
||||
_validateWritablePath('Reference.update', this._delegate._path);
|
||||
validateCallback('Reference.update', 'onComplete', onComplete, true);
|
||||
const result = update(this._delegate, values);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
setWithPriority(newVal, newPriority, onComplete) {
|
||||
validateArgCount('Reference.setWithPriority', 2, 3, arguments.length);
|
||||
validateCallback('Reference.setWithPriority', 'onComplete', onComplete, true);
|
||||
const result = setWithPriority(this._delegate, newVal, newPriority);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
remove(onComplete) {
|
||||
validateArgCount('Reference.remove', 0, 1, arguments.length);
|
||||
validateCallback('Reference.remove', 'onComplete', onComplete, true);
|
||||
const result = remove(this._delegate);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
transaction(transactionUpdate, onComplete, applyLocally) {
|
||||
validateArgCount('Reference.transaction', 1, 3, arguments.length);
|
||||
validateCallback('Reference.transaction', 'transactionUpdate', transactionUpdate, false);
|
||||
validateCallback('Reference.transaction', 'onComplete', onComplete, true);
|
||||
validateBoolean('Reference.transaction', 'applyLocally', applyLocally, true);
|
||||
const result = runTransaction(this._delegate, transactionUpdate, {
|
||||
applyLocally
|
||||
}).then(transactionResult => new TransactionResult(transactionResult.committed, new DataSnapshot(this.database, transactionResult.snapshot)));
|
||||
if (onComplete) {
|
||||
result.then(transactionResult => onComplete(null, transactionResult.committed, transactionResult.snapshot), error => onComplete(error, false, null));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
setPriority(priority, onComplete) {
|
||||
validateArgCount('Reference.setPriority', 1, 2, arguments.length);
|
||||
validateCallback('Reference.setPriority', 'onComplete', onComplete, true);
|
||||
const result = setPriority(this._delegate, priority);
|
||||
if (onComplete) {
|
||||
result.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
push(value, onComplete) {
|
||||
validateArgCount('Reference.push', 0, 2, arguments.length);
|
||||
validateCallback('Reference.push', 'onComplete', onComplete, true);
|
||||
const expPromise = push(this._delegate, value);
|
||||
const promise = expPromise.then(expRef => new Reference(this.database, expRef));
|
||||
if (onComplete) {
|
||||
promise.then(() => onComplete(null), error => onComplete(error));
|
||||
}
|
||||
const result = new Reference(this.database, expPromise);
|
||||
result.then = promise.then.bind(promise);
|
||||
result.catch = promise.catch.bind(promise, undefined);
|
||||
return result;
|
||||
}
|
||||
onDisconnect() {
|
||||
_validateWritablePath('Reference.onDisconnect', this._delegate._path);
|
||||
return new OnDisconnect(new OnDisconnect$1(this._delegate._repo, this._delegate._path));
|
||||
}
|
||||
get key() {
|
||||
return this.getKey();
|
||||
}
|
||||
get parent() {
|
||||
return this.getParent();
|
||||
}
|
||||
get root() {
|
||||
return this.getRoot();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* Class representing a firebase database.
|
||||
*/
|
||||
class Database {
|
||||
/**
|
||||
* The constructor should not be called by users of our public API.
|
||||
*/
|
||||
constructor(_delegate, app) {
|
||||
this._delegate = _delegate;
|
||||
this.app = app;
|
||||
this.INTERNAL = {
|
||||
delete: () => this._delegate._delete(),
|
||||
forceWebSockets,
|
||||
forceLongPolling
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Modify this instance to communicate with the Realtime Database emulator.
|
||||
*
|
||||
* <p>Note: This method must be called before performing any other operation.
|
||||
*
|
||||
* @param host - the emulator host (ex: localhost)
|
||||
* @param port - the emulator port (ex: 8080)
|
||||
* @param options.mockUserToken - the mock auth token to use for unit testing Security Rules
|
||||
*/
|
||||
useEmulator(host, port, options = {}) {
|
||||
connectDatabaseEmulator(this._delegate, host, port, options);
|
||||
}
|
||||
ref(path) {
|
||||
validateArgCount('database.ref', 0, 1, arguments.length);
|
||||
if (path instanceof Reference) {
|
||||
const childRef = refFromURL(this._delegate, path.toString());
|
||||
return new Reference(this, childRef);
|
||||
}
|
||||
else {
|
||||
const childRef = ref(this._delegate, path);
|
||||
return new Reference(this, childRef);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns a reference to the root or the path specified in url.
|
||||
* We throw a exception if the url is not in the same domain as the
|
||||
* current repo.
|
||||
* @returns Firebase reference.
|
||||
*/
|
||||
refFromURL(url) {
|
||||
const apiName = 'database.refFromURL';
|
||||
validateArgCount(apiName, 1, 1, arguments.length);
|
||||
const childRef = refFromURL(this._delegate, url);
|
||||
return new Reference(this, childRef);
|
||||
}
|
||||
// Make individual repo go offline.
|
||||
goOffline() {
|
||||
validateArgCount('database.goOffline', 0, 0, arguments.length);
|
||||
return goOffline(this._delegate);
|
||||
}
|
||||
goOnline() {
|
||||
validateArgCount('database.goOnline', 0, 0, arguments.length);
|
||||
return goOnline(this._delegate);
|
||||
}
|
||||
}
|
||||
Database.ServerValue = {
|
||||
TIMESTAMP: serverTimestamp(),
|
||||
increment: (delta) => increment(delta)
|
||||
};
|
||||
|
||||
/**
|
||||
* Used by console to create a database based on the app,
|
||||
* passed database URL and a custom auth implementation.
|
||||
*
|
||||
* @param app - A valid FirebaseApp-like object
|
||||
* @param url - A valid Firebase databaseURL
|
||||
* @param version - custom version e.g. firebase-admin version
|
||||
* @param customAuthImpl - custom auth implementation
|
||||
*/
|
||||
function initStandalone({ app, url, version, customAuthImpl, customAppCheckImpl, namespace, nodeAdmin = false }) {
|
||||
_setSDKVersion(version);
|
||||
const container = new ComponentContainer('database-standalone');
|
||||
/**
|
||||
* ComponentContainer('database-standalone') is just a placeholder that doesn't perform
|
||||
* any actual function.
|
||||
*/
|
||||
const authProvider = new Provider('auth-internal', container);
|
||||
authProvider.setComponent(new Component('auth-internal', () => customAuthImpl, "PRIVATE" /* ComponentType.PRIVATE */));
|
||||
let appCheckProvider = undefined;
|
||||
if (customAppCheckImpl) {
|
||||
appCheckProvider = new Provider('app-check-internal', container);
|
||||
appCheckProvider.setComponent(new Component('app-check-internal', () => customAppCheckImpl, "PRIVATE" /* ComponentType.PRIVATE */));
|
||||
}
|
||||
return {
|
||||
instance: new Database(_repoManagerDatabaseFromApp(app, authProvider, appCheckProvider, url, nodeAdmin), app),
|
||||
namespace
|
||||
};
|
||||
}
|
||||
|
||||
var INTERNAL = /*#__PURE__*/Object.freeze({
|
||||
__proto__: null,
|
||||
initStandalone: initStandalone
|
||||
});
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
const ServerValue = Database.ServerValue;
|
||||
function registerDatabase(instance) {
|
||||
// Register the Database Service with the 'firebase' namespace.
|
||||
instance.INTERNAL.registerComponent(new Component('database-compat', (container, { instanceIdentifier: url }) => {
|
||||
/* Dependencies */
|
||||
// getImmediate for FirebaseApp will always succeed
|
||||
const app = container.getProvider('app-compat').getImmediate();
|
||||
const databaseExp = container
|
||||
.getProvider('database')
|
||||
.getImmediate({ identifier: url });
|
||||
return new Database(databaseExp, app);
|
||||
}, "PUBLIC" /* ComponentType.PUBLIC */)
|
||||
.setServiceProps(
|
||||
// firebase.database namespace properties
|
||||
{
|
||||
Reference,
|
||||
Query,
|
||||
Database,
|
||||
DataSnapshot,
|
||||
enableLogging,
|
||||
INTERNAL,
|
||||
ServerValue
|
||||
})
|
||||
.setMultipleInstances(true));
|
||||
instance.registerVersion(name, version, 'node');
|
||||
}
|
||||
registerDatabase(firebase);
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
server/node_modules/@firebase/database-compat/dist/node-esm/index.js.map
generated
vendored
Normal file
1
server/node_modules/@firebase/database-compat/dist/node-esm/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
server/node_modules/@firebase/database-compat/dist/node-esm/package.json
generated
vendored
Normal file
1
server/node_modules/@firebase/database-compat/dist/node-esm/package.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"type":"module"}
|
||||
74
server/node_modules/@firebase/database-compat/package.json
generated
vendored
Normal file
74
server/node_modules/@firebase/database-compat/package.json
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
{
|
||||
"name": "@firebase/database-compat",
|
||||
"version": "2.1.0",
|
||||
"description": "The Realtime Database component of the Firebase JS SDK.",
|
||||
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
||||
"main": "dist/index.js",
|
||||
"browser": "dist/index.esm.js",
|
||||
"module": "dist/index.esm.js",
|
||||
"license": "Apache-2.0",
|
||||
"typings": "dist/database-compat/src/index.d.ts",
|
||||
"files": [
|
||||
"dist",
|
||||
"standalone/package.json"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/database-compat/src/index.d.ts",
|
||||
"node": {
|
||||
"types": "./dist/database-compat/src/index.node.d.ts",
|
||||
"import": "./dist/node-esm/index.js",
|
||||
"require": "./dist/index.js"
|
||||
},
|
||||
"browser": {
|
||||
"require": "./dist/index.js",
|
||||
"import": "./dist/index.esm.js"
|
||||
},
|
||||
"default": "./dist/index.esm.js"
|
||||
},
|
||||
"./standalone": {
|
||||
"types": "./dist/database-compat/src/index.standalone.d.ts",
|
||||
"node": "./dist/index.standalone.js",
|
||||
"default": "./dist/index.standalone.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
|
||||
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
|
||||
"prettier": "prettier --write '*.js' '*.ts' '@(src|test)/**/*.ts'",
|
||||
"build": "rollup -c rollup.config.js",
|
||||
"build:release": "yarn build && yarn add-compat-overloads",
|
||||
"build:deps": "lerna run --scope @firebase/database-compat --include-dependencies build",
|
||||
"dev": "rollup -c -w",
|
||||
"test": "run-p --npm-path npm lint test:browser test:node",
|
||||
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test",
|
||||
"test:browser": "karma start",
|
||||
"test:node": "TS_NODE_FILES=true TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file src/index.node.ts --config ../../config/mocharc.node.js",
|
||||
"trusted-type-check": "tsec -p tsconfig.json --noEmit",
|
||||
"add-compat-overloads": "ts-node-script ../../scripts/build/create-overloads.ts -i ../database/dist/public.d.ts -o dist/database-compat/src/index.d.ts -a -r Database:types.FirebaseDatabase -r Query:types.Query -r DatabaseReference:types.Reference -r FirebaseApp:FirebaseAppCompat --moduleToEnhance @firebase/database"
|
||||
},
|
||||
"dependencies": {
|
||||
"@firebase/database": "1.1.0",
|
||||
"@firebase/database-types": "1.0.16",
|
||||
"@firebase/logger": "0.5.0",
|
||||
"@firebase/util": "1.13.0",
|
||||
"@firebase/component": "0.7.0",
|
||||
"tslib": "^2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@firebase/app-compat": "0.5.0",
|
||||
"typescript": "5.5.4"
|
||||
},
|
||||
"repository": {
|
||||
"directory": "packages/database-compat",
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/firebase/firebase-js-sdk.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/firebase/firebase-js-sdk/issues"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
}
|
||||
}
|
||||
7
server/node_modules/@firebase/database-compat/standalone/package.json
generated
vendored
Normal file
7
server/node_modules/@firebase/database-compat/standalone/package.json
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "@firebase/database-compat/standalone",
|
||||
"description": "The entry point for sharing code with Admin SDK",
|
||||
"main": "../dist/index.standalone.js",
|
||||
"typings": "../dist/database-compat/src/index.standalone.d.ts",
|
||||
"private": true
|
||||
}
|
||||
3
server/node_modules/@firebase/database-types/README.md
generated
vendored
Normal file
3
server/node_modules/@firebase/database-types/README.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# @firebase/database-types
|
||||
|
||||
**This package is not intended for direct usage, and should only be used via the officially supported [firebase](https://www.npmjs.com/package/firebase) package.**
|
||||
181
server/node_modules/@firebase/database-types/index.d.ts
generated
vendored
Normal file
181
server/node_modules/@firebase/database-types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FirebaseApp } from '@firebase/app-types';
|
||||
import { EmulatorMockTokenOptions } from '@firebase/util';
|
||||
|
||||
/**
|
||||
* Represents a child snapshot of a `Reference` that is being iterated over. The key will never be undefined.
|
||||
*/
|
||||
export interface IteratedDataSnapshot extends DataSnapshot {
|
||||
key: string; // key of the location of this snapshot.
|
||||
}
|
||||
|
||||
export interface DataSnapshot {
|
||||
child(path: string): DataSnapshot;
|
||||
exists(): boolean;
|
||||
exportVal(): any;
|
||||
forEach(action: (a: IteratedDataSnapshot) => boolean | void): boolean;
|
||||
getPriority(): string | number | null;
|
||||
hasChild(path: string): boolean;
|
||||
hasChildren(): boolean;
|
||||
key: string | null;
|
||||
numChildren(): number;
|
||||
ref: Reference;
|
||||
toJSON(): Object | null;
|
||||
val(): any;
|
||||
}
|
||||
|
||||
export interface Database {
|
||||
app: FirebaseApp;
|
||||
useEmulator(
|
||||
host: string,
|
||||
port: number,
|
||||
options?: {
|
||||
mockUserToken?: EmulatorMockTokenOptions | string;
|
||||
}
|
||||
): void;
|
||||
goOffline(): void;
|
||||
goOnline(): void;
|
||||
ref(path?: string | Reference): Reference;
|
||||
refFromURL(url: string): Reference;
|
||||
}
|
||||
|
||||
export class FirebaseDatabase implements Database {
|
||||
private constructor();
|
||||
app: FirebaseApp;
|
||||
useEmulator(
|
||||
host: string,
|
||||
port: number,
|
||||
options?: {
|
||||
mockUserToken?: EmulatorMockTokenOptions | string;
|
||||
}
|
||||
): void;
|
||||
goOffline(): void;
|
||||
goOnline(): void;
|
||||
ref(path?: string | Reference): Reference;
|
||||
refFromURL(url: string): Reference;
|
||||
}
|
||||
|
||||
export interface OnDisconnect {
|
||||
cancel(onComplete?: (a: Error | null) => any): Promise<void>;
|
||||
remove(onComplete?: (a: Error | null) => any): Promise<void>;
|
||||
set(value: any, onComplete?: (a: Error | null) => any): Promise<void>;
|
||||
setWithPriority(
|
||||
value: any,
|
||||
priority: number | string | null,
|
||||
onComplete?: (a: Error | null) => any
|
||||
): Promise<any>;
|
||||
update(values: Object, onComplete?: (a: Error | null) => any): Promise<any>;
|
||||
}
|
||||
|
||||
type EventType =
|
||||
| 'value'
|
||||
| 'child_added'
|
||||
| 'child_changed'
|
||||
| 'child_moved'
|
||||
| 'child_removed';
|
||||
|
||||
export interface Query {
|
||||
endBefore(value: number | string | boolean | null, key?: string): Query;
|
||||
endAt(value: number | string | boolean | null, key?: string): Query;
|
||||
equalTo(value: number | string | boolean | null, key?: string): Query;
|
||||
isEqual(other: Query | null): boolean;
|
||||
limitToFirst(limit: number): Query;
|
||||
limitToLast(limit: number): Query;
|
||||
off(
|
||||
eventType?: EventType,
|
||||
callback?: (a: DataSnapshot, b?: string | null) => any,
|
||||
context?: Object | null
|
||||
): void;
|
||||
get(): Promise<DataSnapshot>;
|
||||
on(
|
||||
eventType: EventType,
|
||||
callback: (a: DataSnapshot, b?: string | null) => any,
|
||||
cancelCallbackOrContext?: ((a: Error) => any) | Object | null,
|
||||
context?: Object | null
|
||||
): (a: DataSnapshot | null, b?: string | null) => any;
|
||||
once(
|
||||
eventType: EventType,
|
||||
successCallback?: (a: DataSnapshot, b?: string | null) => any,
|
||||
failureCallbackOrContext?: ((a: Error) => void) | Object | null,
|
||||
context?: Object | null
|
||||
): Promise<DataSnapshot>;
|
||||
orderByChild(path: string): Query;
|
||||
orderByKey(): Query;
|
||||
orderByPriority(): Query;
|
||||
orderByValue(): Query;
|
||||
ref: Reference;
|
||||
startAt(value: number | string | boolean | null, key?: string): Query;
|
||||
startAfter(value: number | string | boolean | null, key?: string): Query;
|
||||
toJSON(): Object;
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
export interface Reference extends Query {
|
||||
child(path: string): Reference;
|
||||
key: string | null;
|
||||
onDisconnect(): OnDisconnect;
|
||||
parent: Reference | null;
|
||||
push(value?: any, onComplete?: (a: Error | null) => any): ThenableReference;
|
||||
remove(onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
root: Reference;
|
||||
set(value: any, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
setPriority(
|
||||
priority: string | number | null,
|
||||
onComplete: (a: Error | null) => void
|
||||
): Promise<void>;
|
||||
setWithPriority(
|
||||
newVal: any,
|
||||
newPriority: string | number | null,
|
||||
onComplete?: (a: Error | null) => void
|
||||
): Promise<void>;
|
||||
transaction(
|
||||
transactionUpdate: (a: any) => any,
|
||||
onComplete?: (a: Error | null, b: boolean, c: DataSnapshot | null) => void,
|
||||
applyLocally?: boolean
|
||||
): Promise<TransactionResult>;
|
||||
update(values: Object, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||
}
|
||||
|
||||
export interface ServerValue {
|
||||
TIMESTAMP: Object;
|
||||
increment(delta: number): Object;
|
||||
}
|
||||
|
||||
export interface TransactionResult {
|
||||
committed: boolean;
|
||||
snapshot: DataSnapshot;
|
||||
}
|
||||
|
||||
export interface ThenableReference
|
||||
extends Reference,
|
||||
Pick<Promise<Reference>, 'then' | 'catch'> {
|
||||
key: string;
|
||||
parent: Reference;
|
||||
}
|
||||
|
||||
export function enableLogging(
|
||||
logger?: boolean | ((a: string) => any),
|
||||
persistent?: boolean
|
||||
): any;
|
||||
|
||||
declare module '@firebase/component' {
|
||||
interface NameServiceMapping {
|
||||
'database-compat': FirebaseDatabase;
|
||||
}
|
||||
}
|
||||
29
server/node_modules/@firebase/database-types/package.json
generated
vendored
Normal file
29
server/node_modules/@firebase/database-types/package.json
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "@firebase/database-types",
|
||||
"version": "1.0.16",
|
||||
"description": "@firebase/database Types",
|
||||
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
"test": "tsc",
|
||||
"test:ci": "node ../../scripts/run_tests_in_ci.js"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts"
|
||||
],
|
||||
"dependencies": {
|
||||
"@firebase/app-types": "0.9.3",
|
||||
"@firebase/util": "1.13.0"
|
||||
},
|
||||
"repository": {
|
||||
"directory": "packages/database-types",
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/firebase/firebase-js-sdk.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/firebase/firebase-js-sdk/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "5.5.4"
|
||||
}
|
||||
}
|
||||
5
server/node_modules/@firebase/database/README.md
generated
vendored
Normal file
5
server/node_modules/@firebase/database/README.md
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
# @firebase/database
|
||||
|
||||
This is the Firebase Realtime Database component of the Firebase JS SDK.
|
||||
|
||||
**This package is not intended for direct usage, and should only be used via the officially supported [firebase](https://www.npmjs.com/package/firebase) package.**
|
||||
14089
server/node_modules/@firebase/database/dist/index.cjs.js
generated
vendored
Normal file
14089
server/node_modules/@firebase/database/dist/index.cjs.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
server/node_modules/@firebase/database/dist/index.cjs.js.map
generated
vendored
Normal file
1
server/node_modules/@firebase/database/dist/index.cjs.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
14032
server/node_modules/@firebase/database/dist/index.esm.js
generated
vendored
Normal file
14032
server/node_modules/@firebase/database/dist/index.esm.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
server/node_modules/@firebase/database/dist/index.esm.js.map
generated
vendored
Normal file
1
server/node_modules/@firebase/database/dist/index.esm.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
14109
server/node_modules/@firebase/database/dist/index.node.cjs.js
generated
vendored
Normal file
14109
server/node_modules/@firebase/database/dist/index.node.cjs.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
server/node_modules/@firebase/database/dist/index.node.cjs.js.map
generated
vendored
Normal file
1
server/node_modules/@firebase/database/dist/index.node.cjs.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
14052
server/node_modules/@firebase/database/dist/index.standalone.js
generated
vendored
Normal file
14052
server/node_modules/@firebase/database/dist/index.standalone.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user