mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2025-09-23 05:40:19 +00:00
push all website files
This commit is contained in:
17
website/node_modules/firebase-functions/.npmignore
generated
vendored
Normal file
17
website/node_modules/firebase-functions/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
.tmp
|
||||
coverage
|
||||
.vscode
|
||||
.idea
|
||||
tsconfig.*
|
||||
tslint.*
|
||||
.travis.yml
|
||||
.github
|
||||
|
||||
# Don't include the raw typescript
|
||||
src
|
||||
spec
|
||||
integration_test
|
||||
# TODO(rjh) add back once testing isn't just a joke
|
||||
testing
|
||||
lib/testing.*
|
||||
*.tgz
|
4
website/node_modules/firebase-functions/.prettierrc
generated
vendored
Normal file
4
website/node_modules/firebase-functions/.prettierrc
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "es5"
|
||||
}
|
21
website/node_modules/firebase-functions/LICENSE
generated
vendored
Normal file
21
website/node_modules/firebase-functions/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Firebase
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
36
website/node_modules/firebase-functions/README.md
generated
vendored
Normal file
36
website/node_modules/firebase-functions/README.md
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
# Firebase SDK for Cloud Functions
|
||||
|
||||
The `firebase-functions` package provides an SDK for defining Cloud Functions for Firebase.
|
||||
|
||||
Cloud Functions is a hosted, private, and scalable Node.js environment where you can run JavaScript code. The Firebase SDK for Cloud Functions integrates the Firebase platform by letting you write code that responds to events and invokes functionality exposed by other Firebase features.
|
||||
|
||||
## Learn more
|
||||
|
||||
Learn more about the Firebase SDK for Cloud Functions in the [Firebase documentation](https://firebase.google.com/docs/functions/) or [check out our samples](https://github.com/firebase/functions-samples).
|
||||
|
||||
## Migrating to v1
|
||||
|
||||
To migrate from a beta version of firebase-functions to v1, please refer to the [migration guide](https://firebase.google.com/docs/functions/beta-v1-diff).
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
// functions/index.js
|
||||
const functions = require('firebase-functions');
|
||||
const notifyUsers = require('./notify-users');
|
||||
|
||||
exports.newPost = functions.database
|
||||
.ref('/posts/{postId}')
|
||||
.onCreate((snapshot, context) => {
|
||||
console.log('Received new post with ID:', context.params.postId);
|
||||
return notifyUsers(snapshot.val());
|
||||
});
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
To contribute a change, [check out the contributing guide](.github/CONTRIBUTING.md).
|
||||
|
||||
## License
|
||||
|
||||
© Google, 2017. Licensed under [The MIT License](LICENSE).
|
1
website/node_modules/firebase-functions/changelog.txt
generated
vendored
Normal file
1
website/node_modules/firebase-functions/changelog.txt
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
feature - Added support for Remote Config triggered functions with `functions.remoteConfig`.
|
1
website/node_modules/firebase-functions/lib/apps.d.ts
generated
vendored
Normal file
1
website/node_modules/firebase-functions/lib/apps.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
103
website/node_modules/firebase-functions/lib/apps.js
generated
vendored
Normal file
103
website/node_modules/firebase-functions/lib/apps.js
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const _ = require("lodash");
|
||||
const firebase = require("firebase-admin");
|
||||
const config_1 = require("./config");
|
||||
/** @internal */
|
||||
function apps() {
|
||||
if (typeof apps.singleton === 'undefined') {
|
||||
apps.init();
|
||||
}
|
||||
return apps.singleton;
|
||||
}
|
||||
exports.apps = apps;
|
||||
/** @internal */
|
||||
(function (apps) {
|
||||
/** @internal */
|
||||
apps.garbageCollectionInterval = 2 * 60 * 1000;
|
||||
/** @internal */
|
||||
function delay(delay) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(resolve, delay);
|
||||
});
|
||||
}
|
||||
apps.delay = delay;
|
||||
apps.init = () => (apps.singleton = new Apps());
|
||||
/** @internal */
|
||||
class Apps {
|
||||
constructor() {
|
||||
this._refCounter = {};
|
||||
}
|
||||
_appAlive(appName) {
|
||||
try {
|
||||
let app = firebase.app(appName);
|
||||
return !_.get(app, 'isDeleted_');
|
||||
}
|
||||
catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
_destroyApp(appName) {
|
||||
if (!this._appAlive(appName)) {
|
||||
return;
|
||||
}
|
||||
firebase
|
||||
.app(appName)
|
||||
.delete()
|
||||
.catch(_.noop);
|
||||
}
|
||||
retain() {
|
||||
let increment = (n) => {
|
||||
return (n || 0) + 1;
|
||||
};
|
||||
// Increment counter for admin because function might use event.data.ref
|
||||
_.update(this._refCounter, '__admin__', increment);
|
||||
}
|
||||
release() {
|
||||
let decrement = (n) => {
|
||||
return n - 1;
|
||||
};
|
||||
return delay(apps.garbageCollectionInterval).then(() => {
|
||||
_.update(this._refCounter, '__admin__', decrement);
|
||||
_.forEach(this._refCounter, (count, key) => {
|
||||
if (count <= 0) {
|
||||
this._destroyApp(key);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
get admin() {
|
||||
if (this._appAlive('__admin__')) {
|
||||
return firebase.app('__admin__');
|
||||
}
|
||||
return firebase.initializeApp(this.firebaseArgs, '__admin__');
|
||||
}
|
||||
get firebaseArgs() {
|
||||
return _.assign({}, config_1.firebaseConfig(), {
|
||||
credential: firebase.credential.applicationDefault(),
|
||||
});
|
||||
}
|
||||
}
|
||||
apps.Apps = Apps;
|
||||
})(apps = exports.apps || (exports.apps = {}));
|
107
website/node_modules/firebase-functions/lib/cloud-functions.d.ts
generated
vendored
Normal file
107
website/node_modules/firebase-functions/lib/cloud-functions.d.ts
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
/// <reference types="express" />
|
||||
import { Request, Response } from 'express';
|
||||
import { DeploymentOptions } from './function-builder';
|
||||
export { Request, Response };
|
||||
/** The context in which an event occurred.
|
||||
* An EventContext describes:
|
||||
* - The time an event occurred.
|
||||
* - A unique identifier of the event.
|
||||
* - The resource on which the event occurred, if applicable.
|
||||
* - Authorization of the request that triggered the event, if applicable and available.
|
||||
*/
|
||||
export interface EventContext {
|
||||
/** ID of the event */
|
||||
eventId: string;
|
||||
/** Timestamp for when the event occured (ISO string) */
|
||||
timestamp: string;
|
||||
/** Type of event */
|
||||
eventType: string;
|
||||
/** Resource that triggered the event */
|
||||
resource: Resource;
|
||||
/** Key-value pairs that represent the values of wildcards in a database reference */
|
||||
params: {
|
||||
[option: string]: any;
|
||||
};
|
||||
/** Type of authentication for the triggering action, valid value are: 'ADMIN', 'USER',
|
||||
* 'UNAUTHENTICATED'. Only available for database functions.
|
||||
*/
|
||||
authType?: 'ADMIN' | 'USER' | 'UNAUTHENTICATED';
|
||||
/** Firebase auth variable for the user whose action triggered the function. Field will be
|
||||
* null for unauthenticated users, and will not exist for admin users. Only available
|
||||
* for database functions.
|
||||
*/
|
||||
auth?: {
|
||||
uid: string;
|
||||
token: object;
|
||||
};
|
||||
}
|
||||
/** Change describes a change of state - "before" represents the state prior
|
||||
* to the event, "after" represents the state after the event.
|
||||
*/
|
||||
export declare class Change<T> {
|
||||
before: T;
|
||||
after: T;
|
||||
constructor(before?: T, after?: T);
|
||||
}
|
||||
/** ChangeJson is the JSON format used to construct a Change object. */
|
||||
export interface ChangeJson {
|
||||
/** Key-value pairs representing state of data before the change.
|
||||
* If `fieldMask` is set, then only fields that changed are present in `before`.
|
||||
*/
|
||||
before?: any;
|
||||
/** Key-value pairs representing state of data after the change. */
|
||||
after?: any;
|
||||
/** Comma-separated string that represents names of field that changed. */
|
||||
fieldMask?: string;
|
||||
}
|
||||
export declare namespace Change {
|
||||
/** Factory method for creating a Change from a `before` object and an `after` object. */
|
||||
function fromObjects<T>(before: T, after: T): Change<T>;
|
||||
/** Factory method for creating a Change from a JSON and an optional customizer function to be
|
||||
* applied to both the `before` and the `after` fields.
|
||||
*/
|
||||
function fromJSON<T>(json: ChangeJson, customizer?: (x: any) => T): Change<T>;
|
||||
}
|
||||
/** Resource is a standard format for defining a resource (google.rpc.context.AttributeContext.Resource).
|
||||
* In Cloud Functions, it is the resource that triggered the function - such as a storage bucket.
|
||||
*/
|
||||
export interface Resource {
|
||||
service: string;
|
||||
name: string;
|
||||
type?: string;
|
||||
labels?: {
|
||||
[tag: string]: string;
|
||||
};
|
||||
}
|
||||
/** TriggerAnnotated is used internally by the firebase CLI to understand what type of Cloud Function to deploy. */
|
||||
export interface TriggerAnnotated {
|
||||
__trigger: {
|
||||
httpsTrigger?: {};
|
||||
eventTrigger?: {
|
||||
eventType: string;
|
||||
resource: string;
|
||||
service: string;
|
||||
};
|
||||
labels?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
regions?: string[];
|
||||
timeout?: string;
|
||||
availableMemoryMb?: number;
|
||||
};
|
||||
}
|
||||
/** A Runnable has a `run` method which directly invokes the user-defined function - useful for unit testing. */
|
||||
export interface Runnable<T> {
|
||||
run: (data: T, context: any) => PromiseLike<any> | any;
|
||||
}
|
||||
/**
|
||||
* An HttpsFunction is both an object that exports its trigger definitions at __trigger and
|
||||
* can be called as a function that takes an express.js Request and Response object.
|
||||
*/
|
||||
export declare type HttpsFunction = TriggerAnnotated & ((req: Request, resp: Response) => void);
|
||||
/**
|
||||
* A CloudFunction is both an object that exports its trigger definitions at __trigger and
|
||||
* can be called as a function using the raw JS API for Google Cloud Functions.
|
||||
*/
|
||||
export declare type CloudFunction<T> = Runnable<T> & TriggerAnnotated & ((input: any, context?: any) => PromiseLike<any> | any);
|
||||
export declare function optsToTrigger(opts: DeploymentOptions): any;
|
218
website/node_modules/firebase-functions/lib/cloud-functions.js
generated
vendored
Normal file
218
website/node_modules/firebase-functions/lib/cloud-functions.js
generated
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const _ = require("lodash");
|
||||
const WILDCARD_REGEX = new RegExp('{[^/{}]*}', 'g');
|
||||
/** Change describes a change of state - "before" represents the state prior
|
||||
* to the event, "after" represents the state after the event.
|
||||
*/
|
||||
class Change {
|
||||
constructor(before, after) {
|
||||
this.before = before;
|
||||
this.after = after;
|
||||
}
|
||||
}
|
||||
exports.Change = Change;
|
||||
(function (Change) {
|
||||
function reinterpretCast(x) {
|
||||
return x;
|
||||
}
|
||||
/** Factory method for creating a Change from a `before` object and an `after` object. */
|
||||
function fromObjects(before, after) {
|
||||
return new Change(before, after);
|
||||
}
|
||||
Change.fromObjects = fromObjects;
|
||||
/** Factory method for creating a Change from a JSON and an optional customizer function to be
|
||||
* applied to both the `before` and the `after` fields.
|
||||
*/
|
||||
function fromJSON(json, customizer = reinterpretCast) {
|
||||
let before = _.assign({}, json.before);
|
||||
if (json.fieldMask) {
|
||||
before = applyFieldMask(before, json.after, json.fieldMask);
|
||||
}
|
||||
return Change.fromObjects(customizer(before || {}), customizer(json.after || {}));
|
||||
}
|
||||
Change.fromJSON = fromJSON;
|
||||
/** @internal */
|
||||
function applyFieldMask(sparseBefore, after, fieldMask) {
|
||||
let before = _.assign({}, after);
|
||||
let masks = fieldMask.split(',');
|
||||
_.forEach(masks, mask => {
|
||||
const val = _.get(sparseBefore, mask);
|
||||
if (typeof val === 'undefined') {
|
||||
_.unset(before, mask);
|
||||
}
|
||||
else {
|
||||
_.set(before, mask, val);
|
||||
}
|
||||
});
|
||||
return before;
|
||||
}
|
||||
Change.applyFieldMask = applyFieldMask;
|
||||
})(Change = exports.Change || (exports.Change = {}));
|
||||
/** @internal */
|
||||
function makeCloudFunction({ provider, eventType, triggerResource, service, dataConstructor = (raw) => raw.data, handler, before = () => {
|
||||
return;
|
||||
}, after = () => {
|
||||
return;
|
||||
}, legacyEventType, opts = {}, }) {
|
||||
let cloudFunction;
|
||||
let cloudFunctionNewSignature = (data, context) => {
|
||||
if (legacyEventType && context.eventType === legacyEventType) {
|
||||
// v1beta1 event flow has different format for context, transform them to new format.
|
||||
context.eventType = provider + '.' + eventType;
|
||||
context.resource = {
|
||||
service: service,
|
||||
name: context.resource,
|
||||
};
|
||||
}
|
||||
let event = {
|
||||
data,
|
||||
context,
|
||||
};
|
||||
if (provider === 'google.firebase.database') {
|
||||
context.authType = _detectAuthType(event);
|
||||
if (context.authType !== 'ADMIN') {
|
||||
context.auth = _makeAuth(event, context.authType);
|
||||
}
|
||||
else {
|
||||
delete context.auth;
|
||||
}
|
||||
}
|
||||
context.params = context.params || _makeParams(context, triggerResource);
|
||||
before(event);
|
||||
let dataOrChange = dataConstructor(event);
|
||||
let promise = handler(dataOrChange, context);
|
||||
if (typeof promise === 'undefined') {
|
||||
console.warn('Function returned undefined, expected Promise or value');
|
||||
}
|
||||
return Promise.resolve(promise)
|
||||
.then(result => {
|
||||
after(event);
|
||||
return result;
|
||||
})
|
||||
.catch(err => {
|
||||
after(event);
|
||||
return Promise.reject(err);
|
||||
});
|
||||
};
|
||||
if (process.env.X_GOOGLE_NEW_FUNCTION_SIGNATURE === 'true') {
|
||||
cloudFunction = cloudFunctionNewSignature;
|
||||
}
|
||||
else {
|
||||
cloudFunction = (raw) => {
|
||||
let context;
|
||||
// In Node 6 runtime, function called with single event param
|
||||
let data = _.get(raw, 'data');
|
||||
if (isEvent(raw)) {
|
||||
// new eventflow v1beta2 format
|
||||
context = _.cloneDeep(raw.context);
|
||||
}
|
||||
else {
|
||||
// eventflow v1beta1 format
|
||||
context = _.omit(raw, 'data');
|
||||
}
|
||||
return cloudFunctionNewSignature(data, context);
|
||||
};
|
||||
}
|
||||
Object.defineProperty(cloudFunction, '__trigger', {
|
||||
get: () => {
|
||||
let trigger = _.assign(optsToTrigger(opts), {
|
||||
eventTrigger: {
|
||||
resource: triggerResource(),
|
||||
eventType: legacyEventType || provider + '.' + eventType,
|
||||
service,
|
||||
},
|
||||
});
|
||||
return trigger;
|
||||
},
|
||||
});
|
||||
cloudFunction.run = handler;
|
||||
return cloudFunction;
|
||||
}
|
||||
exports.makeCloudFunction = makeCloudFunction;
|
||||
function isEvent(event) {
|
||||
return _.has(event, 'context');
|
||||
}
|
||||
function _makeParams(context, triggerResourceGetter) {
|
||||
if (context.params) {
|
||||
// In unit testing, user may directly provide `context.params`.
|
||||
return context.params;
|
||||
}
|
||||
if (!context.resource) {
|
||||
// In unit testing, `resource` may be unpopulated for a test event.
|
||||
return {};
|
||||
}
|
||||
let triggerResource = triggerResourceGetter();
|
||||
let wildcards = triggerResource.match(WILDCARD_REGEX);
|
||||
let params = {};
|
||||
if (wildcards) {
|
||||
let triggerResourceParts = _.split(triggerResource, '/');
|
||||
let eventResourceParts = _.split(context.resource.name, '/');
|
||||
_.forEach(wildcards, wildcard => {
|
||||
let wildcardNoBraces = wildcard.slice(1, -1);
|
||||
let position = _.indexOf(triggerResourceParts, wildcard);
|
||||
params[wildcardNoBraces] = eventResourceParts[position];
|
||||
});
|
||||
}
|
||||
return params;
|
||||
}
|
||||
function _makeAuth(event, authType) {
|
||||
if (authType === 'UNAUTHENTICATED') {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
uid: _.get(event, 'context.auth.variable.uid'),
|
||||
token: _.get(event, 'context.auth.variable.token'),
|
||||
};
|
||||
}
|
||||
function _detectAuthType(event) {
|
||||
if (_.get(event, 'context.auth.admin')) {
|
||||
return 'ADMIN';
|
||||
}
|
||||
if (_.has(event, 'context.auth.variable')) {
|
||||
return 'USER';
|
||||
}
|
||||
return 'UNAUTHENTICATED';
|
||||
}
|
||||
function optsToTrigger(opts) {
|
||||
let trigger = {};
|
||||
if (opts.regions) {
|
||||
trigger.regions = opts.regions;
|
||||
}
|
||||
if (opts.timeoutSeconds) {
|
||||
trigger.timeout = opts.timeoutSeconds.toString() + 's';
|
||||
}
|
||||
if (opts.memory) {
|
||||
const memoryLookup = {
|
||||
'128MB': 128,
|
||||
'256MB': 256,
|
||||
'512MB': 512,
|
||||
'1GB': 1024,
|
||||
'2GB': 2048,
|
||||
};
|
||||
trigger.availableMemoryMb = _.get(memoryLookup, opts.memory);
|
||||
}
|
||||
return trigger;
|
||||
}
|
||||
exports.optsToTrigger = optsToTrigger;
|
6
website/node_modules/firebase-functions/lib/config.d.ts
generated
vendored
Normal file
6
website/node_modules/firebase-functions/lib/config.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export declare function config(): config.Config;
|
||||
export declare namespace config {
|
||||
type Config = {
|
||||
[key: string]: any;
|
||||
};
|
||||
}
|
87
website/node_modules/firebase-functions/lib/config.js
generated
vendored
Normal file
87
website/node_modules/firebase-functions/lib/config.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function config() {
|
||||
if (typeof config.singleton === 'undefined') {
|
||||
init();
|
||||
}
|
||||
return config.singleton;
|
||||
}
|
||||
exports.config = config;
|
||||
(function (config) {
|
||||
})(config = exports.config || (exports.config = {}));
|
||||
/* @internal */
|
||||
function firebaseConfig() {
|
||||
// The FIREBASE_PROJECT environment variable was introduced to help local emulation with `firebase-tools` 3.18
|
||||
// Unfortunately, API review decided that the name should be FIREBASE_CONFIG to avoid confusions that Firebase has
|
||||
// a separate project from Google Cloud. This accepts both versions, preferring the documented name.
|
||||
const env = process.env.FIREBASE_CONFIG || process.env.FIREBASE_PROJECT;
|
||||
if (env) {
|
||||
return JSON.parse(env);
|
||||
}
|
||||
// Could have Runtime Config with Firebase in it as an ENV value.
|
||||
try {
|
||||
const config = JSON.parse(process.env.CLOUD_RUNTIME_CONFIG);
|
||||
if (config.firebase) {
|
||||
return config.firebase;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
// Do nothing
|
||||
}
|
||||
// Could have Runtime Config with Firebase in it as an ENV location or default.
|
||||
try {
|
||||
const path = process.env.CLOUD_RUNTIME_CONFIG || '../../../.runtimeconfig.json';
|
||||
const config = require(path);
|
||||
if (config.firebase) {
|
||||
return config.firebase;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
// Do nothing
|
||||
}
|
||||
return null;
|
||||
}
|
||||
exports.firebaseConfig = firebaseConfig;
|
||||
function init() {
|
||||
try {
|
||||
const parsed = JSON.parse(process.env.CLOUD_RUNTIME_CONFIG);
|
||||
delete parsed.firebase;
|
||||
config.singleton = parsed;
|
||||
return;
|
||||
}
|
||||
catch (e) {
|
||||
// Do nothing
|
||||
}
|
||||
try {
|
||||
let path = process.env.CLOUD_RUNTIME_CONFIG || '../../../.runtimeconfig.json';
|
||||
const parsed = require(path);
|
||||
delete parsed.firebase;
|
||||
config.singleton = parsed;
|
||||
return;
|
||||
}
|
||||
catch (e) {
|
||||
// Do nothing
|
||||
}
|
||||
config.singleton = {};
|
||||
}
|
4
website/node_modules/firebase-functions/lib/encoder.d.ts
generated
vendored
Normal file
4
website/node_modules/firebase-functions/lib/encoder.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export declare function dateToTimestampProto(timeString?: string): {
|
||||
seconds: number;
|
||||
nanos: number;
|
||||
};
|
38
website/node_modules/firebase-functions/lib/encoder.js
generated
vendored
Normal file
38
website/node_modules/firebase-functions/lib/encoder.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function dateToTimestampProto(timeString) {
|
||||
if (typeof timeString === 'undefined') {
|
||||
return;
|
||||
}
|
||||
let date = new Date(timeString);
|
||||
let seconds = Math.floor(date.getTime() / 1000);
|
||||
let nanos = 0;
|
||||
if (timeString.length > 20) {
|
||||
const nanoString = timeString.substring(20, timeString.length - 1);
|
||||
const trailingZeroes = 9 - nanoString.length;
|
||||
nanos = parseInt(nanoString, 10) * Math.pow(10, trailingZeroes);
|
||||
}
|
||||
return { seconds, nanos };
|
||||
}
|
||||
exports.dateToTimestampProto = dateToTimestampProto;
|
87
website/node_modules/firebase-functions/lib/function-builder.d.ts
generated
vendored
Normal file
87
website/node_modules/firebase-functions/lib/function-builder.d.ts
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/// <reference types="express" />
|
||||
import * as express from 'express';
|
||||
import * as analytics from './providers/analytics';
|
||||
import * as auth from './providers/auth';
|
||||
import * as crashlytics from './providers/crashlytics';
|
||||
import * as database from './providers/database';
|
||||
import * as firestore from './providers/firestore';
|
||||
import * as https from './providers/https';
|
||||
import * as pubsub from './providers/pubsub';
|
||||
import * as remoteConfig from './providers/remoteConfig';
|
||||
import * as storage from './providers/storage';
|
||||
import { CloudFunction, EventContext, HttpsFunction } from './cloud-functions';
|
||||
/**
|
||||
* Configure the regions that the function is deployed to.
|
||||
* @param region Region string.
|
||||
* For example: `functions.region('us-east1')`
|
||||
*/
|
||||
export declare function region(region: string): FunctionBuilder;
|
||||
/**
|
||||
* Configure runtime options for the function.
|
||||
* @param runtimeOptions Object with 2 optional fields:
|
||||
* 1. `timeoutSeconds`: timeout for the function in seconds.
|
||||
* 2. `memory`: amount of memory to allocate to the function,
|
||||
* possible values are: '128MB', '256MB', '512MB', '1GB', and '2GB'.
|
||||
*/
|
||||
export declare function runWith(runtimeOptions: {
|
||||
timeoutSeconds?: number;
|
||||
memory?: '128MB' | '256MB' | '512MB' | '1GB' | '2GB';
|
||||
}): FunctionBuilder;
|
||||
export interface DeploymentOptions {
|
||||
regions?: string[];
|
||||
timeoutSeconds?: number;
|
||||
memory?: string;
|
||||
}
|
||||
export declare class FunctionBuilder {
|
||||
private options;
|
||||
constructor(options: DeploymentOptions);
|
||||
/**
|
||||
* Configure the regions that the function is deployed to.
|
||||
* @param region Region string.
|
||||
* For example: `functions.region('us-east1')`
|
||||
*/
|
||||
region: (region: string) => this;
|
||||
/**
|
||||
* Configure runtime options for the function.
|
||||
* @param runtimeOptions Object with 2 optional fields:
|
||||
* 1. timeoutSeconds: timeout for the function in seconds.
|
||||
* 2. memory: amount of memory to allocate to the function, possible values are:
|
||||
* '128MB', '256MB', '512MB', '1GB', and '2GB'.
|
||||
*/
|
||||
runWith: (runtimeOptions: {
|
||||
timeoutSeconds?: number;
|
||||
memory?: "128MB" | "256MB" | "512MB" | "1GB" | "2GB";
|
||||
}) => this;
|
||||
readonly https: {
|
||||
onRequest: (handler: (req: express.Request, resp: express.Response) => void) => HttpsFunction;
|
||||
onCall: (handler: (data: any, context: https.CallableContext) => any) => HttpsFunction;
|
||||
};
|
||||
readonly database: {
|
||||
instance: (instance: string) => database.InstanceBuilder;
|
||||
ref: (path: string) => database.RefBuilder;
|
||||
};
|
||||
readonly firestore: {
|
||||
document: (path: string) => firestore.DocumentBuilder;
|
||||
namespace: (namespace: string) => firestore.NamespaceBuilder;
|
||||
database: (database: string) => firestore.DatabaseBuilder;
|
||||
};
|
||||
readonly crashlytics: {
|
||||
issue: () => crashlytics.IssueBuilder;
|
||||
};
|
||||
readonly analytics: {
|
||||
event: (analyticsEventType: string) => analytics.AnalyticsEventBuilder;
|
||||
};
|
||||
readonly remoteConfig: {
|
||||
onUpdate: (handler: (version: remoteConfig.TemplateVersion, context: EventContext) => any) => CloudFunction<remoteConfig.TemplateVersion>;
|
||||
};
|
||||
readonly storage: {
|
||||
bucket: (bucket?: string) => storage.BucketBuilder;
|
||||
object: () => storage.ObjectBuilder;
|
||||
};
|
||||
readonly pubsub: {
|
||||
topic: (topic: string) => pubsub.TopicBuilder;
|
||||
};
|
||||
readonly auth: {
|
||||
user: () => auth.UserBuilder;
|
||||
};
|
||||
}
|
212
website/node_modules/firebase-functions/lib/function-builder.js
generated
vendored
Normal file
212
website/node_modules/firebase-functions/lib/function-builder.js
generated
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const _ = require("lodash");
|
||||
const analytics = require("./providers/analytics");
|
||||
const auth = require("./providers/auth");
|
||||
const crashlytics = require("./providers/crashlytics");
|
||||
const database = require("./providers/database");
|
||||
const firestore = require("./providers/firestore");
|
||||
const https = require("./providers/https");
|
||||
const pubsub = require("./providers/pubsub");
|
||||
const remoteConfig = require("./providers/remoteConfig");
|
||||
const storage = require("./providers/storage");
|
||||
/**
|
||||
* Configure the regions that the function is deployed to.
|
||||
* @param region Region string.
|
||||
* For example: `functions.region('us-east1')`
|
||||
*/
|
||||
function region(region) {
|
||||
return new FunctionBuilder({ regions: [region] });
|
||||
}
|
||||
exports.region = region;
|
||||
/**
|
||||
* Configure runtime options for the function.
|
||||
* @param runtimeOptions Object with 2 optional fields:
|
||||
* 1. `timeoutSeconds`: timeout for the function in seconds.
|
||||
* 2. `memory`: amount of memory to allocate to the function,
|
||||
* possible values are: '128MB', '256MB', '512MB', '1GB', and '2GB'.
|
||||
*/
|
||||
function runWith(runtimeOptions) {
|
||||
if (runtimeOptions.memory &&
|
||||
!_.includes(['128MB', '256MB', '512MB', '1GB', '2GB'], runtimeOptions.memory)) {
|
||||
throw new Error("The only valid memory allocation values are: '128MB', '256MB', '512MB', '1GB', and '2GB'");
|
||||
}
|
||||
return new FunctionBuilder(runtimeOptions);
|
||||
}
|
||||
exports.runWith = runWith;
|
||||
class FunctionBuilder {
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
/**
|
||||
* Configure the regions that the function is deployed to.
|
||||
* @param region Region string.
|
||||
* For example: `functions.region('us-east1')`
|
||||
*/
|
||||
this.region = (region) => {
|
||||
this.options.regions = [region];
|
||||
return this;
|
||||
};
|
||||
/**
|
||||
* Configure runtime options for the function.
|
||||
* @param runtimeOptions Object with 2 optional fields:
|
||||
* 1. timeoutSeconds: timeout for the function in seconds.
|
||||
* 2. memory: amount of memory to allocate to the function, possible values are:
|
||||
* '128MB', '256MB', '512MB', '1GB', and '2GB'.
|
||||
*/
|
||||
this.runWith = (runtimeOptions) => {
|
||||
if (runtimeOptions.memory &&
|
||||
!_.includes(['128MB', '256MB', '512MB', '1GB', '2GB'], runtimeOptions.memory)) {
|
||||
throw new Error("The only valid memory allocation values are: '128MB', '256MB', '512MB', '1GB', and '2GB'");
|
||||
}
|
||||
this.options = _.assign(this.options, runtimeOptions);
|
||||
return this;
|
||||
};
|
||||
}
|
||||
get https() {
|
||||
return {
|
||||
/**
|
||||
* Handle HTTP requests.
|
||||
* @param handler A function that takes a request and response object,
|
||||
* same signature as an Express app.
|
||||
*/
|
||||
onRequest: (handler) => https._onRequestWithOpts(handler, this.options),
|
||||
/**
|
||||
* Declares a callable method for clients to call using a Firebase SDK.
|
||||
* @param handler A method that takes a data and context and returns a value.
|
||||
*/
|
||||
onCall: (handler) => https._onCallWithOpts(handler, this.options),
|
||||
};
|
||||
}
|
||||
get database() {
|
||||
return {
|
||||
/**
|
||||
* Selects a database instance that will trigger the function.
|
||||
* If omitted, will pick the default database for your project.
|
||||
* @param instance The Realtime Database instance to use.
|
||||
*/
|
||||
instance: (instance) => database._instanceWithOpts(instance, this.options),
|
||||
/**
|
||||
* Select Firebase Realtime Database Reference to listen to.
|
||||
*
|
||||
* This method behaves very similarly to the method of the same name in the
|
||||
* client and Admin Firebase SDKs. Any change to the Database that affects the
|
||||
* data at or below the provided `path` will fire an event in Cloud Functions.
|
||||
*
|
||||
* There are three important differences between listening to a Realtime
|
||||
* Database event in Cloud Functions and using the Realtime Database in the
|
||||
* client and Admin SDKs:
|
||||
* 1. Cloud Functions allows wildcards in the `path` name. Any `path` component
|
||||
* in curly brackets (`{}`) is a wildcard that matches all strings. The value
|
||||
* that matched a certain invocation of a Cloud Function is returned as part
|
||||
* of the `context.params` object. For example, `ref("messages/{messageId}")`
|
||||
* matches changes at `/messages/message1` or `/messages/message2`, resulting
|
||||
* in `context.params.messageId` being set to `"message1"` or `"message2"`,
|
||||
* respectively.
|
||||
* 2. Cloud Functions do not fire an event for data that already existed before
|
||||
* the Cloud Function was deployed.
|
||||
* 3. Cloud Function events have access to more information, including information
|
||||
* about the user who triggered the Cloud Function.
|
||||
* @param ref Path of the database to listen to.
|
||||
*/
|
||||
ref: (path) => database._refWithOpts(path, this.options),
|
||||
};
|
||||
}
|
||||
get firestore() {
|
||||
return {
|
||||
/**
|
||||
* Select the Firestore document to listen to for events.
|
||||
* @param path Full database path to listen to. This includes the name of
|
||||
* the collection that the document is a part of. For example, if the
|
||||
* collection is named "users" and the document is named "Ada", then the
|
||||
* path is "/users/Ada".
|
||||
*/
|
||||
document: (path) => firestore._documentWithOpts(path, this.options),
|
||||
/** @internal */
|
||||
namespace: (namespace) => firestore._namespaceWithOpts(namespace, this.options),
|
||||
/** @internal */
|
||||
database: (database) => firestore._databaseWithOpts(database, this.options),
|
||||
};
|
||||
}
|
||||
get crashlytics() {
|
||||
return {
|
||||
/**
|
||||
* Handle events related to Crashlytics issues. An issue in Crashlytics is an
|
||||
* aggregation of crashes which have a shared root cause.
|
||||
*/
|
||||
issue: () => crashlytics._issueWithOpts(this.options),
|
||||
};
|
||||
}
|
||||
get analytics() {
|
||||
return {
|
||||
/**
|
||||
* Select analytics events to listen to for events.
|
||||
* @param analyticsEventType Name of the analytics event type.
|
||||
*/
|
||||
event: (analyticsEventType) => analytics._eventWithOpts(analyticsEventType, this.options),
|
||||
};
|
||||
}
|
||||
get remoteConfig() {
|
||||
return {
|
||||
/**
|
||||
* Handle all updates (including rollbacks) that affect a Remote Config
|
||||
* project.
|
||||
* @param handler A function that takes the updated Remote Config template
|
||||
* version metadata as an argument.
|
||||
*/
|
||||
onUpdate: (handler) => remoteConfig._onUpdateWithOpts(handler, this.options),
|
||||
};
|
||||
}
|
||||
get storage() {
|
||||
return {
|
||||
/**
|
||||
* The optional bucket function allows you to choose which buckets' events to handle.
|
||||
* This step can be bypassed by calling object() directly, which will use the default
|
||||
* Cloud Storage for Firebase bucket.
|
||||
* @param bucket Name of the Google Cloud Storage bucket to listen to.
|
||||
*/
|
||||
bucket: (bucket) => storage._bucketWithOpts(this.options, bucket),
|
||||
/**
|
||||
* Handle events related to Cloud Storage objects.
|
||||
*/
|
||||
object: () => storage._objectWithOpts(this.options),
|
||||
};
|
||||
}
|
||||
get pubsub() {
|
||||
return {
|
||||
/** Select Cloud Pub/Sub topic to listen to.
|
||||
* @param topic Name of Pub/Sub topic, must belong to the same project as the function.
|
||||
*/
|
||||
topic: (topic) => pubsub._topicWithOpts(topic, this.options),
|
||||
};
|
||||
}
|
||||
get auth() {
|
||||
return {
|
||||
/**
|
||||
* Handle events related to Firebase authentication users.
|
||||
*/
|
||||
user: () => auth._userWithOpts(this.options),
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.FunctionBuilder = FunctionBuilder;
|
13
website/node_modules/firebase-functions/lib/index.d.ts
generated
vendored
Normal file
13
website/node_modules/firebase-functions/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import * as analytics from './providers/analytics';
|
||||
import * as auth from './providers/auth';
|
||||
import * as crashlytics from './providers/crashlytics';
|
||||
import * as database from './providers/database';
|
||||
import * as firestore from './providers/firestore';
|
||||
import * as https from './providers/https';
|
||||
import * as pubsub from './providers/pubsub';
|
||||
import * as remoteConfig from './providers/remoteConfig';
|
||||
import * as storage from './providers/storage';
|
||||
export { analytics, auth, crashlytics, database, firestore, https, pubsub, remoteConfig, storage };
|
||||
export * from './config';
|
||||
export * from './cloud-functions';
|
||||
export * from './function-builder';
|
70
website/node_modules/firebase-functions/lib/index.js
generated
vendored
Normal file
70
website/node_modules/firebase-functions/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// Providers:
|
||||
const analytics = require("./providers/analytics");
|
||||
exports.analytics = analytics;
|
||||
const auth = require("./providers/auth");
|
||||
exports.auth = auth;
|
||||
const crashlytics = require("./providers/crashlytics");
|
||||
exports.crashlytics = crashlytics;
|
||||
const database = require("./providers/database");
|
||||
exports.database = database;
|
||||
const firestore = require("./providers/firestore");
|
||||
exports.firestore = firestore;
|
||||
const https = require("./providers/https");
|
||||
exports.https = https;
|
||||
const pubsub = require("./providers/pubsub");
|
||||
exports.pubsub = pubsub;
|
||||
const remoteConfig = require("./providers/remoteConfig");
|
||||
exports.remoteConfig = remoteConfig;
|
||||
const storage = require("./providers/storage");
|
||||
exports.storage = storage;
|
||||
const config_1 = require("./config");
|
||||
// // Exported root types:
|
||||
__export(require("./config"));
|
||||
__export(require("./cloud-functions"));
|
||||
__export(require("./function-builder"));
|
||||
// TEMPORARY WORKAROUND (BUG 63586213):
|
||||
// Until the Cloud Functions builder can publish FIREBASE_CONFIG, automatically provide it on import based on what
|
||||
// we can deduce.
|
||||
if (!process.env.FIREBASE_CONFIG) {
|
||||
const cfg = config_1.firebaseConfig();
|
||||
if (cfg) {
|
||||
process.env.FIREBASE_CONFIG = JSON.stringify(cfg);
|
||||
}
|
||||
else if (process.env.GCLOUD_PROJECT) {
|
||||
console.warn('Warning, estimating Firebase Config based on GCLOUD_PROJECT. Initializing firebase-admin may fail');
|
||||
process.env.FIREBASE_CONFIG = JSON.stringify({
|
||||
databaseURL: `https://${process.env.GCLOUD_PROJECT}.firebaseio.com`,
|
||||
storageBucket: `${process.env.GCLOUD_PROJECT}.appspot.com`,
|
||||
projectId: process.env.GCLOUD_PROJECT,
|
||||
});
|
||||
}
|
||||
else {
|
||||
console.warn('Warning, FIREBASE_CONFIG environment variable is missing. Initializing firebase-admin will fail');
|
||||
}
|
||||
}
|
206
website/node_modules/firebase-functions/lib/providers/analytics.d.ts
generated
vendored
Normal file
206
website/node_modules/firebase-functions/lib/providers/analytics.d.ts
generated
vendored
Normal file
@@ -0,0 +1,206 @@
|
||||
import { CloudFunction, EventContext } from '../cloud-functions';
|
||||
/**
|
||||
* Select analytics events to listen to for events.
|
||||
* @param analyticsEventType Name of the analytics event type.
|
||||
*/
|
||||
export declare function event(analyticsEventType: string): AnalyticsEventBuilder;
|
||||
/**
|
||||
* The Firebase Analytics event builder interface.
|
||||
*
|
||||
* Access via [`functions.analytics.event()`](functions.analytics#event).
|
||||
*/
|
||||
export declare class AnalyticsEventBuilder {
|
||||
private triggerResource;
|
||||
private opts;
|
||||
/**
|
||||
* Event handler that fires every time a Firebase Analytics event occurs.
|
||||
*
|
||||
* @param {!function(!functions.Event<!functions.analytics.AnalyticsEvent>)}
|
||||
* handler Event handler that fires every time a Firebase Analytics event
|
||||
* occurs.
|
||||
*
|
||||
* @return {!functions.CloudFunction<!functions.analytics.AnalyticsEvent>} A
|
||||
* Cloud Function you can export.
|
||||
*/
|
||||
onLog(handler: (event: AnalyticsEvent, context: EventContext) => PromiseLike<any> | any): CloudFunction<AnalyticsEvent>;
|
||||
}
|
||||
/**
|
||||
* Interface representing a Firebase Analytics event that was logged for a specific user.
|
||||
*/
|
||||
export declare class AnalyticsEvent {
|
||||
/**
|
||||
* The date on which the event.was logged.
|
||||
* (`YYYYMMDD` format in the registered timezone of your app).
|
||||
*/
|
||||
reportingDate: string;
|
||||
/** The name of the event. */
|
||||
name: string;
|
||||
/**
|
||||
* A map of parameters and their values associated with the event.
|
||||
*
|
||||
* Note: Values in this map are cast to the most appropriate type. Due to
|
||||
* the nature of JavaScript's number handling, this might entail a loss of
|
||||
* precision in cases of very large integers.
|
||||
*/
|
||||
params: {
|
||||
[key: string]: any;
|
||||
};
|
||||
/** UTC client time when the event happened. */
|
||||
logTime: string;
|
||||
/** UTC client time when the previous event happened. */
|
||||
previousLogTime?: string;
|
||||
/** Value parameter in USD. */
|
||||
valueInUSD?: number;
|
||||
/** User-related dimensions. */
|
||||
user?: UserDimensions;
|
||||
}
|
||||
/**
|
||||
* Interface representing the user who triggered the events.
|
||||
*/
|
||||
export declare class UserDimensions {
|
||||
/**
|
||||
* The user ID set via the `setUserId` API.
|
||||
* [Android](https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.html#setUserId(java.lang.String))
|
||||
* [iOS](https://firebase.google.com/docs/reference/ios/firebaseanalytics/api/reference/Classes/FIRAnalytics#/c:objc(cs)FIRAnalytics(cm)setUserID)
|
||||
*/
|
||||
userId?: string;
|
||||
/** The time (in UTC) at which the user first opened the app. */
|
||||
firstOpenTime?: string;
|
||||
/**
|
||||
* A map of user properties set with the
|
||||
* [`setUserProperty`](https://firebase.google.com/docs/analytics/android/properties) API.
|
||||
*
|
||||
* All values are [`UserPropertyValue`](functions.analytics.UserPropertyValue) objects.
|
||||
*/
|
||||
userProperties: {
|
||||
[key: string]: UserPropertyValue;
|
||||
};
|
||||
/** Device information. */
|
||||
deviceInfo: DeviceInfo;
|
||||
/** User's geographic information. */
|
||||
geoInfo: GeoInfo;
|
||||
/** App information. */
|
||||
appInfo?: AppInfo;
|
||||
/** Information regarding the bundle in which these events were uploaded. */
|
||||
bundleInfo: ExportBundleInfo;
|
||||
}
|
||||
/**
|
||||
* Predefined or custom properties stored on the client side.
|
||||
*/
|
||||
export declare class UserPropertyValue {
|
||||
/** Last set value of a user property. */
|
||||
value: string;
|
||||
/** UTC client time when the user property was last set. */
|
||||
setTime: string;
|
||||
}
|
||||
/**
|
||||
* Interface representing the device that triggered these Firebase Analytics events.
|
||||
*/
|
||||
export interface DeviceInfo {
|
||||
/**
|
||||
* Device category.
|
||||
* Examples: "tablet" or "mobile".
|
||||
*/
|
||||
deviceCategory?: string;
|
||||
/**
|
||||
* Device brand name.
|
||||
* Examples: "Samsung", "HTC"
|
||||
*/
|
||||
mobileBrandName?: string;
|
||||
/**
|
||||
* Device model name in human-readable format.
|
||||
* Example: "iPhone 7"
|
||||
*/
|
||||
mobileModelName?: string;
|
||||
/**
|
||||
* Device marketing name.
|
||||
* Example: "Galaxy S4 Mini"
|
||||
*/
|
||||
mobileMarketingName?: string;
|
||||
/**
|
||||
* Device model, as read from the OS.
|
||||
* Example: "iPhone9,1"
|
||||
*/
|
||||
deviceModel?: string;
|
||||
/**
|
||||
* Device OS version when data capture ended.
|
||||
* Example: "4.4.2"
|
||||
*/
|
||||
platformVersion?: string;
|
||||
/**
|
||||
* Vendor specific device identifier. This is IDFV on iOS. Not used for Android.
|
||||
* Example: '599F9C00-92DC-4B5C-9464-7971F01F8370'
|
||||
*/
|
||||
deviceId?: string;
|
||||
/**
|
||||
* The type of the [`resettable_device_id`](https://support.google.com/dfp_premium/answer/6238701?hl=en)
|
||||
* is IDFA on iOS (when available) and AdId on Android.
|
||||
*
|
||||
* Example: "71683BF9-FA3B-4B0D-9535-A1F05188BAF3"
|
||||
*/
|
||||
resettableDeviceId?: string;
|
||||
/**
|
||||
* The user language in language-country format, where language is an ISO 639
|
||||
* value and country is an ISO 3166 value.
|
||||
*
|
||||
* Examples: "en-us", "en-za", "zh-tw", "jp"
|
||||
*/
|
||||
userDefaultLanguage: string;
|
||||
/**
|
||||
* The time zone of the device when data was uploaded, as seconds skew from UTC.
|
||||
* Use this to calculate the device's local time for [`event.timestamp`](functions.Event#timestamp)`.
|
||||
*/
|
||||
deviceTimeZoneOffsetSeconds: number;
|
||||
/**
|
||||
* The device's Limit Ad Tracking setting.
|
||||
* When `true`, you cannot use `resettableDeviceId` for remarketing, demographics or influencing ads serving
|
||||
* behaviour. However, you can use resettableDeviceId for conversion tracking and campaign attribution.
|
||||
*/
|
||||
limitedAdTracking: boolean;
|
||||
}
|
||||
/**
|
||||
* Interface representing the geographic origin of the events.
|
||||
*/
|
||||
export interface GeoInfo {
|
||||
/** The geographic continent. Example: "Americas". */
|
||||
continent?: string;
|
||||
/** The geographic country. Example: "Brazil". */
|
||||
country?: string;
|
||||
/** The geographic region. Example: "State of Sao Paulo". */
|
||||
region?: string;
|
||||
/** The geographic city. Example: "Sao Paulo". */
|
||||
city?: string;
|
||||
}
|
||||
/**
|
||||
* Interface representing the application that triggered these events.
|
||||
*/
|
||||
export interface AppInfo {
|
||||
/**
|
||||
* The app's version name.
|
||||
* Examples: "1.0", "4.3.1.1.213361", "2.3 (1824253)", "v1.8b22p6".
|
||||
*/
|
||||
appVersion?: string;
|
||||
/**
|
||||
* Unique id for this instance of the app.
|
||||
* Example: "71683BF9FA3B4B0D9535A1F05188BAF3".
|
||||
*/
|
||||
appInstanceId: string;
|
||||
/**
|
||||
* The identifier of the store that installed the app.
|
||||
* Examples: "com.sec.android.app.samsungapps", "com.amazon.venezia", "com.nokia.nstore".
|
||||
*/
|
||||
appStore?: string;
|
||||
/** The app platform. Examples: "ANDROID", "IOS". */
|
||||
appPlatform: string;
|
||||
/** Unique application identifier within an app store. */
|
||||
appId?: string;
|
||||
}
|
||||
/**
|
||||
* Interface representing the bundle in which these events were uploaded.
|
||||
*/
|
||||
export declare class ExportBundleInfo {
|
||||
/** Monotonically increasing index for each bundle set by the Analytics SDK. */
|
||||
bundleSequenceId: number;
|
||||
/** Timestamp offset (in milliseconds) between collection time and upload time. */
|
||||
serverTimestampOffset: number;
|
||||
}
|
236
website/node_modules/firebase-functions/lib/providers/analytics.js
generated
vendored
Normal file
236
website/node_modules/firebase-functions/lib/providers/analytics.js
generated
vendored
Normal file
@@ -0,0 +1,236 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the 'Software'), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const _ = require("lodash");
|
||||
const cloud_functions_1 = require("../cloud-functions");
|
||||
/** @internal */
|
||||
exports.provider = 'google.analytics';
|
||||
/** @internal */
|
||||
exports.service = 'app-measurement.com';
|
||||
/**
|
||||
* Select analytics events to listen to for events.
|
||||
* @param analyticsEventType Name of the analytics event type.
|
||||
*/
|
||||
function event(analyticsEventType) {
|
||||
return _eventWithOpts(analyticsEventType, {});
|
||||
}
|
||||
exports.event = event;
|
||||
/** @internal */
|
||||
function _eventWithOpts(analyticsEventType, opts) {
|
||||
return new AnalyticsEventBuilder(() => {
|
||||
if (!process.env.GCLOUD_PROJECT) {
|
||||
throw new Error('process.env.GCLOUD_PROJECT is not set.');
|
||||
}
|
||||
return ('projects/' + process.env.GCLOUD_PROJECT + '/events/' + analyticsEventType);
|
||||
}, opts);
|
||||
}
|
||||
exports._eventWithOpts = _eventWithOpts;
|
||||
/**
|
||||
* The Firebase Analytics event builder interface.
|
||||
*
|
||||
* Access via [`functions.analytics.event()`](functions.analytics#event).
|
||||
*/
|
||||
class AnalyticsEventBuilder {
|
||||
/** @internal */
|
||||
constructor(triggerResource, opts) {
|
||||
this.triggerResource = triggerResource;
|
||||
this.opts = opts;
|
||||
}
|
||||
/**
|
||||
* Event handler that fires every time a Firebase Analytics event occurs.
|
||||
*
|
||||
* @param {!function(!functions.Event<!functions.analytics.AnalyticsEvent>)}
|
||||
* handler Event handler that fires every time a Firebase Analytics event
|
||||
* occurs.
|
||||
*
|
||||
* @return {!functions.CloudFunction<!functions.analytics.AnalyticsEvent>} A
|
||||
* Cloud Function you can export.
|
||||
*/
|
||||
onLog(handler) {
|
||||
const dataConstructor = (raw) => {
|
||||
return new AnalyticsEvent(raw.data);
|
||||
};
|
||||
return cloud_functions_1.makeCloudFunction({
|
||||
handler,
|
||||
provider: exports.provider,
|
||||
eventType: 'event.log',
|
||||
service: exports.service,
|
||||
legacyEventType: `providers/google.firebase.analytics/eventTypes/event.log`,
|
||||
triggerResource: this.triggerResource,
|
||||
dataConstructor,
|
||||
opts: this.opts,
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.AnalyticsEventBuilder = AnalyticsEventBuilder;
|
||||
/**
|
||||
* Interface representing a Firebase Analytics event that was logged for a specific user.
|
||||
*/
|
||||
class AnalyticsEvent {
|
||||
/** @internal */
|
||||
constructor(wireFormat) {
|
||||
this.params = {}; // In case of absent field, show empty (not absent) map.
|
||||
if (wireFormat.eventDim && wireFormat.eventDim.length > 0) {
|
||||
// If there's an eventDim, there'll always be exactly one.
|
||||
let eventDim = wireFormat.eventDim[0];
|
||||
copyField(eventDim, this, 'name');
|
||||
copyField(eventDim, this, 'params', p => _.mapValues(p, unwrapValue));
|
||||
copyFieldTo(eventDim, this, 'valueInUsd', 'valueInUSD');
|
||||
copyFieldTo(eventDim, this, 'date', 'reportingDate');
|
||||
copyTimestampToString(eventDim, this, 'timestampMicros', 'logTime');
|
||||
copyTimestampToString(eventDim, this, 'previousTimestampMicros', 'previousLogTime');
|
||||
}
|
||||
copyFieldTo(wireFormat, this, 'userDim', 'user', dim => new UserDimensions(dim));
|
||||
}
|
||||
}
|
||||
exports.AnalyticsEvent = AnalyticsEvent;
|
||||
/**
|
||||
* Interface representing the user who triggered the events.
|
||||
*/
|
||||
class UserDimensions {
|
||||
/** @internal */
|
||||
constructor(wireFormat) {
|
||||
// These are interfaces or primitives, no transformation needed.
|
||||
copyFields(wireFormat, this, [
|
||||
'userId',
|
||||
'deviceInfo',
|
||||
'geoInfo',
|
||||
'appInfo',
|
||||
]);
|
||||
// The following fields do need transformations of some sort.
|
||||
copyTimestampToString(wireFormat, this, 'firstOpenTimestampMicros', 'firstOpenTime');
|
||||
this.userProperties = {}; // With no entries in the wire format, present an empty (as opposed to absent) map.
|
||||
copyField(wireFormat, this, 'userProperties', r => _.mapValues(r, p => new UserPropertyValue(p)));
|
||||
copyField(wireFormat, this, 'bundleInfo', r => new ExportBundleInfo(r));
|
||||
// BUG(36000368) Remove when no longer necessary
|
||||
/* tslint:disable:no-string-literal */
|
||||
if (!this.userId && this.userProperties['user_id']) {
|
||||
this.userId = this.userProperties['user_id'].value;
|
||||
}
|
||||
/* tslint:enable:no-string-literal */
|
||||
}
|
||||
}
|
||||
exports.UserDimensions = UserDimensions;
|
||||
/**
|
||||
* Predefined or custom properties stored on the client side.
|
||||
*/
|
||||
class UserPropertyValue {
|
||||
/** @internal */
|
||||
constructor(wireFormat) {
|
||||
copyField(wireFormat, this, 'value', unwrapValueAsString);
|
||||
copyTimestampToString(wireFormat, this, 'setTimestampUsec', 'setTime');
|
||||
}
|
||||
}
|
||||
exports.UserPropertyValue = UserPropertyValue;
|
||||
/**
|
||||
* Interface representing the bundle in which these events were uploaded.
|
||||
*/
|
||||
class ExportBundleInfo {
|
||||
/** @internal */
|
||||
constructor(wireFormat) {
|
||||
copyField(wireFormat, this, 'bundleSequenceId');
|
||||
copyTimestampToMillis(wireFormat, this, 'serverTimestampOffsetMicros', 'serverTimestampOffset');
|
||||
}
|
||||
}
|
||||
exports.ExportBundleInfo = ExportBundleInfo;
|
||||
function copyFieldTo(from, to, fromField, toField, transform = _.identity) {
|
||||
if (from[fromField] !== undefined) {
|
||||
to[toField] = transform(from[fromField]);
|
||||
}
|
||||
}
|
||||
function copyField(from, to, field, transform = _.identity) {
|
||||
copyFieldTo(from, to, field, field, transform);
|
||||
}
|
||||
function copyFields(from, to, fields) {
|
||||
for (let field of fields) {
|
||||
copyField(from, to, field);
|
||||
}
|
||||
}
|
||||
// The incoming payload will have fields like:
|
||||
// {
|
||||
// 'myInt': {
|
||||
// 'intValue': '123'
|
||||
// },
|
||||
// 'myDouble': {
|
||||
// 'doubleValue': 1.0
|
||||
// },
|
||||
// 'myFloat': {
|
||||
// 'floatValue': 1.1
|
||||
// },
|
||||
// 'myString': {
|
||||
// 'stringValue': 'hi!'
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// The following method will remove these four types of 'xValue' fields, flattening them
|
||||
// to just their values, as a string:
|
||||
// {
|
||||
// 'myInt': '123',
|
||||
// 'myDouble': '1.0',
|
||||
// 'myFloat': '1.1',
|
||||
// 'myString': 'hi!'
|
||||
// }
|
||||
//
|
||||
// Note that while 'intValue' will have a quoted payload, 'doubleValue' and 'floatValue' will not. This
|
||||
// is due to the encoding library, which renders int64 values as strings to avoid loss of precision. This
|
||||
// method always returns a string, similarly to avoid loss of precision, unlike the less-conservative
|
||||
// 'unwrapValue' method just below.
|
||||
function unwrapValueAsString(wrapped) {
|
||||
let key = _.keys(wrapped)[0];
|
||||
return _.toString(wrapped[key]);
|
||||
}
|
||||
// Ditto as the method above, but returning the values in the idiomatic JavaScript type (string for strings,
|
||||
// number for numbers):
|
||||
// {
|
||||
// 'myInt': 123,
|
||||
// 'myDouble': 1.0,
|
||||
// 'myFloat': 1.1,
|
||||
// 'myString': 'hi!'
|
||||
// }
|
||||
//
|
||||
// The field names in the incoming xValue fields identify the type a value has, which for JavaScript's
|
||||
// purposes can be divided into 'number' versus 'string'. This method will render all the numbers as
|
||||
// JavaScript's 'number' type, since we prefer using idiomatic types. Note that this may lead to loss
|
||||
// in precision for int64 fields, so use with care.
|
||||
const xValueNumberFields = ['intValue', 'floatValue', 'doubleValue'];
|
||||
function unwrapValue(wrapped) {
|
||||
let key = _.keys(wrapped)[0];
|
||||
let value = unwrapValueAsString(wrapped);
|
||||
return _.includes(xValueNumberFields, key) ? _.toNumber(value) : value;
|
||||
}
|
||||
// The JSON payload delivers timestamp fields as strings of timestamps denoted in microseconds.
|
||||
// The JavaScript convention is to use numbers denoted in milliseconds. This method
|
||||
// makes it easy to convert a field of one type into the other.
|
||||
function copyTimestampToMillis(from, to, fromName, toName) {
|
||||
if (from[fromName] !== undefined) {
|
||||
to[toName] = _.round(from[fromName] / 1000);
|
||||
}
|
||||
}
|
||||
// The JSON payload delivers timestamp fields as strings of timestamps denoted in microseconds.
|
||||
// In our SDK, we'd like to present timestamp as ISO-format strings. This method makes it easy
|
||||
// to convert a field of one type into the other.
|
||||
function copyTimestampToString(from, to, fromName, toName) {
|
||||
if (from[fromName] !== undefined) {
|
||||
to[toName] = new Date(from[fromName] / 1000).toISOString();
|
||||
}
|
||||
}
|
33
website/node_modules/firebase-functions/lib/providers/auth.d.ts
generated
vendored
Normal file
33
website/node_modules/firebase-functions/lib/providers/auth.d.ts
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import { CloudFunction, EventContext } from '../cloud-functions';
|
||||
import * as firebase from 'firebase-admin';
|
||||
/**
|
||||
* Handle events related to Firebase authentication users.
|
||||
*/
|
||||
export declare function user(): UserBuilder;
|
||||
export declare class UserRecordMetadata implements firebase.auth.UserMetadata {
|
||||
creationTime: string;
|
||||
lastSignInTime: string;
|
||||
constructor(creationTime: string, lastSignInTime: string);
|
||||
/** Returns a plain JavaScript object with the properties of UserRecordMetadata. */
|
||||
toJSON(): {
|
||||
creationTime: string;
|
||||
lastSignInTime: string;
|
||||
};
|
||||
}
|
||||
/** Builder used to create Cloud Functions for Firebase Auth user lifecycle events. */
|
||||
export declare class UserBuilder {
|
||||
private triggerResource;
|
||||
private opts;
|
||||
private static dataConstructor(raw);
|
||||
/** Respond to the creation of a Firebase Auth user. */
|
||||
onCreate(handler: (user: UserRecord, context: EventContext) => PromiseLike<any> | any): CloudFunction<UserRecord>;
|
||||
/** Respond to the deletion of a Firebase Auth user. */
|
||||
onDelete(handler: (user: UserRecord, context: EventContext) => PromiseLike<any> | any): CloudFunction<UserRecord>;
|
||||
private onOperation(handler, eventType);
|
||||
}
|
||||
/**
|
||||
* The UserRecord passed to Cloud Functions is the same UserRecord that is returned by the Firebase Admin
|
||||
* SDK.
|
||||
*/
|
||||
export declare type UserRecord = firebase.auth.UserRecord;
|
||||
export declare function userRecordConstructor(wireData: Object): firebase.auth.UserRecord;
|
143
website/node_modules/firebase-functions/lib/providers/auth.js
generated
vendored
Normal file
143
website/node_modules/firebase-functions/lib/providers/auth.js
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const cloud_functions_1 = require("../cloud-functions");
|
||||
const _ = require("lodash");
|
||||
/** @internal */
|
||||
exports.provider = 'google.firebase.auth';
|
||||
/** @internal */
|
||||
exports.service = 'firebaseauth.googleapis.com';
|
||||
/**
|
||||
* Handle events related to Firebase authentication users.
|
||||
*/
|
||||
function user() {
|
||||
return _userWithOpts({});
|
||||
}
|
||||
exports.user = user;
|
||||
/** @internal */
|
||||
function _userWithOpts(opts) {
|
||||
return new UserBuilder(() => {
|
||||
if (!process.env.GCLOUD_PROJECT) {
|
||||
throw new Error('process.env.GCLOUD_PROJECT is not set.');
|
||||
}
|
||||
return 'projects/' + process.env.GCLOUD_PROJECT;
|
||||
}, opts);
|
||||
}
|
||||
exports._userWithOpts = _userWithOpts;
|
||||
class UserRecordMetadata {
|
||||
constructor(creationTime, lastSignInTime) {
|
||||
this.creationTime = creationTime;
|
||||
this.lastSignInTime = lastSignInTime;
|
||||
}
|
||||
/** Returns a plain JavaScript object with the properties of UserRecordMetadata. */
|
||||
toJSON() {
|
||||
return {
|
||||
creationTime: this.creationTime,
|
||||
lastSignInTime: this.lastSignInTime,
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.UserRecordMetadata = UserRecordMetadata;
|
||||
/** Builder used to create Cloud Functions for Firebase Auth user lifecycle events. */
|
||||
class UserBuilder {
|
||||
/** @internal */
|
||||
constructor(triggerResource, opts) {
|
||||
this.triggerResource = triggerResource;
|
||||
this.opts = opts;
|
||||
}
|
||||
static dataConstructor(raw) {
|
||||
return userRecordConstructor(raw.data);
|
||||
}
|
||||
/** Respond to the creation of a Firebase Auth user. */
|
||||
onCreate(handler) {
|
||||
return this.onOperation(handler, 'user.create');
|
||||
}
|
||||
/** Respond to the deletion of a Firebase Auth user. */
|
||||
onDelete(handler) {
|
||||
return this.onOperation(handler, 'user.delete');
|
||||
}
|
||||
onOperation(handler, eventType) {
|
||||
return cloud_functions_1.makeCloudFunction({
|
||||
handler,
|
||||
provider: exports.provider,
|
||||
eventType,
|
||||
service: exports.service,
|
||||
triggerResource: this.triggerResource,
|
||||
dataConstructor: UserBuilder.dataConstructor,
|
||||
legacyEventType: `providers/firebase.auth/eventTypes/${eventType}`,
|
||||
opts: this.opts,
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.UserBuilder = UserBuilder;
|
||||
function userRecordConstructor(wireData) {
|
||||
// Falsey values from the wire format proto get lost when converted to JSON, this adds them back.
|
||||
let falseyValues = {
|
||||
email: null,
|
||||
emailVerified: false,
|
||||
displayName: null,
|
||||
photoURL: null,
|
||||
phoneNumber: null,
|
||||
disabled: false,
|
||||
providerData: [],
|
||||
customClaims: {},
|
||||
passwordSalt: null,
|
||||
passwordHash: null,
|
||||
tokensValidAfterTime: null,
|
||||
};
|
||||
let record = _.assign({}, falseyValues, wireData);
|
||||
let meta = _.get(record, 'metadata');
|
||||
if (meta) {
|
||||
_.set(record, 'metadata', new UserRecordMetadata(
|
||||
// Transform payload to firebase-admin v5.0.0 format because wire format is different (BUG 63167395)
|
||||
meta.createdAt || meta.creationTime, meta.lastSignedInAt || meta.lastSignInTime));
|
||||
}
|
||||
else {
|
||||
_.set(record, 'metadata', new UserRecordMetadata(null, null));
|
||||
}
|
||||
_.forEach(record.providerData, entry => {
|
||||
_.set(entry, 'toJSON', () => {
|
||||
return entry;
|
||||
});
|
||||
});
|
||||
_.set(record, 'toJSON', () => {
|
||||
const json = _.pick(record, [
|
||||
'uid',
|
||||
'email',
|
||||
'emailVerified',
|
||||
'displayName',
|
||||
'photoURL',
|
||||
'phoneNumber',
|
||||
'disabled',
|
||||
'passwordHash',
|
||||
'passwordSalt',
|
||||
'tokensValidAfterTime',
|
||||
]);
|
||||
json.metadata = _.get(record, 'metadata').toJSON();
|
||||
json.customClaims = _.cloneDeep(record.customClaims);
|
||||
json.providerData = _.map(record.providerData, entry => entry.toJSON());
|
||||
return json;
|
||||
});
|
||||
return record;
|
||||
}
|
||||
exports.userRecordConstructor = userRecordConstructor;
|
57
website/node_modules/firebase-functions/lib/providers/crashlytics.d.ts
generated
vendored
Normal file
57
website/node_modules/firebase-functions/lib/providers/crashlytics.d.ts
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
import { CloudFunction, EventContext } from '../cloud-functions';
|
||||
/**
|
||||
* Handle events related to Crashlytics issues. An issue in Crashlytics is an
|
||||
* aggregation of crashes which have a shared root cause.
|
||||
*/
|
||||
export declare function issue(): IssueBuilder;
|
||||
/** Builder used to create Cloud Functions for Crashlytics issue events. */
|
||||
export declare class IssueBuilder {
|
||||
private triggerResource;
|
||||
private opts;
|
||||
/** Handle Crashlytics New Issue events. */
|
||||
onNew(handler: (issue: Issue, context: EventContext) => PromiseLike<any> | any): CloudFunction<Issue>;
|
||||
/** Handle Crashlytics Regressed Issue events. */
|
||||
onRegressed(handler: (issue: Issue, context: EventContext) => PromiseLike<any> | any): CloudFunction<Issue>;
|
||||
/** Handle Crashlytics Velocity Alert events. */
|
||||
onVelocityAlert(handler: (issue: Issue, context: EventContext) => PromiseLike<any> | any): CloudFunction<Issue>;
|
||||
private onEvent(handler, eventType);
|
||||
}
|
||||
/**
|
||||
* Interface representing a Crashlytics issue event that was logged for a specific issue.
|
||||
*/
|
||||
export interface Issue {
|
||||
/** Fabric Issue ID. */
|
||||
issueId: string;
|
||||
/** Issue title. */
|
||||
issueTitle: string;
|
||||
/** App information. */
|
||||
appInfo: AppInfo;
|
||||
/** When the issue was created (ISO8601 time stamp). */
|
||||
createTime: string;
|
||||
/** When the issue was resolved, if the issue has been resolved (ISO8601 time stamp). */
|
||||
resolvedTime?: string;
|
||||
/** Contains details about the velocity alert, if this event was triggered by a velocity alert. */
|
||||
velocityAlert?: VelocityAlert;
|
||||
}
|
||||
export interface VelocityAlert {
|
||||
/** The percentage of sessions which have been impacted by this issue. Example: .04 */
|
||||
crashPercentage: number;
|
||||
/** The number of crashes that this issue has caused. */
|
||||
crashes: number;
|
||||
}
|
||||
/**
|
||||
* Interface representing the application where this issue occurred.
|
||||
*/
|
||||
export interface AppInfo {
|
||||
/** The app's name. Example: "My Awesome App". */
|
||||
appName: string;
|
||||
/** The app's platform. Examples: "android", "ios". */
|
||||
appPlatform: string;
|
||||
/** Unique application identifier within an app store, either the Android package name or the iOS bundle id. */
|
||||
appId: string;
|
||||
/**
|
||||
* The latest app version which is affected by the issue.
|
||||
* Examples: "1.0", "4.3.1.1.213361", "2.3 (1824253)", "v1.8b22p6".
|
||||
*/
|
||||
latestAppVersion: string;
|
||||
}
|
82
website/node_modules/firebase-functions/lib/providers/crashlytics.js
generated
vendored
Normal file
82
website/node_modules/firebase-functions/lib/providers/crashlytics.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const cloud_functions_1 = require("../cloud-functions");
|
||||
/** @internal */
|
||||
exports.provider = 'google.firebase.crashlytics';
|
||||
/** @internal */
|
||||
exports.service = 'fabric.io';
|
||||
/**
|
||||
* Handle events related to Crashlytics issues. An issue in Crashlytics is an
|
||||
* aggregation of crashes which have a shared root cause.
|
||||
*/
|
||||
function issue() {
|
||||
return _issueWithOpts({});
|
||||
}
|
||||
exports.issue = issue;
|
||||
/** @internal */
|
||||
function _issueWithOpts(opts) {
|
||||
return new IssueBuilder(() => {
|
||||
if (!process.env.GCLOUD_PROJECT) {
|
||||
throw new Error('process.env.GCLOUD_PROJECT is not set.');
|
||||
}
|
||||
return 'projects/' + process.env.GCLOUD_PROJECT;
|
||||
}, opts);
|
||||
}
|
||||
exports._issueWithOpts = _issueWithOpts;
|
||||
/** Builder used to create Cloud Functions for Crashlytics issue events. */
|
||||
class IssueBuilder {
|
||||
/** @internal */
|
||||
constructor(triggerResource, opts) {
|
||||
this.triggerResource = triggerResource;
|
||||
this.opts = opts;
|
||||
}
|
||||
/** @internal */
|
||||
onNewDetected(handler) {
|
||||
throw new Error('"onNewDetected" is now deprecated, please use "onNew"');
|
||||
}
|
||||
/** Handle Crashlytics New Issue events. */
|
||||
onNew(handler) {
|
||||
return this.onEvent(handler, 'issue.new');
|
||||
}
|
||||
/** Handle Crashlytics Regressed Issue events. */
|
||||
onRegressed(handler) {
|
||||
return this.onEvent(handler, 'issue.regressed');
|
||||
}
|
||||
/** Handle Crashlytics Velocity Alert events. */
|
||||
onVelocityAlert(handler) {
|
||||
return this.onEvent(handler, 'issue.velocityAlert');
|
||||
}
|
||||
onEvent(handler, eventType) {
|
||||
return cloud_functions_1.makeCloudFunction({
|
||||
handler,
|
||||
provider: exports.provider,
|
||||
eventType,
|
||||
service: exports.service,
|
||||
legacyEventType: `providers/firebase.crashlytics/eventTypes/${eventType}`,
|
||||
triggerResource: this.triggerResource,
|
||||
opts: this.opts,
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.IssueBuilder = IssueBuilder;
|
82
website/node_modules/firebase-functions/lib/providers/database.d.ts
generated
vendored
Normal file
82
website/node_modules/firebase-functions/lib/providers/database.d.ts
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
import { CloudFunction, EventContext, Change } from '../cloud-functions';
|
||||
import * as firebase from 'firebase-admin';
|
||||
/**
|
||||
* Selects a database instance that will trigger the function.
|
||||
* If omitted, will pick the default database for your project.
|
||||
* @param instance The Realtime Database instance to use.
|
||||
*/
|
||||
export declare function instance(instance: string): InstanceBuilder;
|
||||
/**
|
||||
* Select Firebase Realtime Database Reference to listen to.
|
||||
*
|
||||
* This method behaves very similarly to the method of the same name in the
|
||||
* client and Admin Firebase SDKs. Any change to the Database that affects the
|
||||
* data at or below the provided `path` will fire an event in Cloud Functions.
|
||||
*
|
||||
* There are three important differences between listening to a Realtime
|
||||
* Database event in Cloud Functions and using the Realtime Database in the
|
||||
* client and Admin SDKs:
|
||||
* 1. Cloud Functions allows wildcards in the `path` name. Any `path` component
|
||||
* in curly brackets (`{}`) is a wildcard that matches all strings. The value
|
||||
* that matched a certain invocation of a Cloud Function is returned as part
|
||||
* of the `context.params` object. For example, `ref("messages/{messageId}")`
|
||||
* matches changes at `/messages/message1` or `/messages/message2`, resulting
|
||||
* in `context.params.messageId` being set to `"message1"` or `"message2"`,
|
||||
* respectively.
|
||||
* 2. Cloud Functions do not fire an event for data that already existed before
|
||||
* the Cloud Function was deployed.
|
||||
* 3. Cloud Function events have access to more information, including information
|
||||
* about the user who triggered the Cloud Function.
|
||||
* @param ref Path of the database to listen to.
|
||||
*/
|
||||
export declare function ref(path: string): RefBuilder;
|
||||
export declare class InstanceBuilder {
|
||||
private instance;
|
||||
private opts;
|
||||
ref(path: string): RefBuilder;
|
||||
}
|
||||
/** Builder used to create Cloud Functions for Firebase Realtime Database References. */
|
||||
export declare class RefBuilder {
|
||||
private apps;
|
||||
private triggerResource;
|
||||
private opts;
|
||||
/** Respond to any write that affects a ref. */
|
||||
onWrite(handler: (change: Change<DataSnapshot>, context: EventContext) => PromiseLike<any> | any): CloudFunction<Change<DataSnapshot>>;
|
||||
/** Respond to update on a ref. */
|
||||
onUpdate(handler: (change: Change<DataSnapshot>, context: EventContext) => PromiseLike<any> | any): CloudFunction<Change<DataSnapshot>>;
|
||||
/** Respond to new data on a ref. */
|
||||
onCreate(handler: (snapshot: DataSnapshot, context: EventContext) => PromiseLike<any> | any): CloudFunction<DataSnapshot>;
|
||||
/** Respond to all data being deleted from a ref. */
|
||||
onDelete(handler: (snapshot: DataSnapshot, context: EventContext) => PromiseLike<any> | any): CloudFunction<DataSnapshot>;
|
||||
private onOperation<T>(handler, eventType, dataConstructor);
|
||||
private changeConstructor;
|
||||
}
|
||||
export declare class DataSnapshot {
|
||||
private app;
|
||||
instance: string;
|
||||
private _ref;
|
||||
private _path;
|
||||
private _data;
|
||||
private _childPath;
|
||||
constructor(data: any, path?: string, app?: firebase.app.App, instance?: string);
|
||||
/** Ref returns a reference to the database with full admin access. */
|
||||
readonly ref: firebase.database.Reference;
|
||||
readonly key: string;
|
||||
val(): any;
|
||||
exportVal(): any;
|
||||
getPriority(): string | number | null;
|
||||
exists(): boolean;
|
||||
child(childPath: string): DataSnapshot;
|
||||
forEach(action: (a: DataSnapshot) => boolean): boolean;
|
||||
hasChild(childPath: string): boolean;
|
||||
hasChildren(): boolean;
|
||||
numChildren(): number;
|
||||
/**
|
||||
* Prints the value of the snapshot; use '.previous.toJSON()' and '.current.toJSON()' to explicitly see
|
||||
* the previous and current values of the snapshot.
|
||||
*/
|
||||
toJSON(): Object;
|
||||
private _checkAndConvertToArray(node);
|
||||
private _dup(childPath?);
|
||||
private _fullPath();
|
||||
}
|
315
website/node_modules/firebase-functions/lib/providers/database.js
generated
vendored
Normal file
315
website/node_modules/firebase-functions/lib/providers/database.js
generated
vendored
Normal file
@@ -0,0 +1,315 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const _ = require("lodash");
|
||||
const apps_1 = require("../apps");
|
||||
const cloud_functions_1 = require("../cloud-functions");
|
||||
const utils_1 = require("../utils");
|
||||
const config_1 = require("../config");
|
||||
/** @internal */
|
||||
exports.provider = 'google.firebase.database';
|
||||
/** @internal */
|
||||
exports.service = 'firebaseio.com';
|
||||
// NOTE(inlined): Should we relax this a bit to allow staging or alternate implementations of our API?
|
||||
const databaseURLRegex = new RegExp('https://([^.]+).firebaseio.com');
|
||||
/**
|
||||
* Selects a database instance that will trigger the function.
|
||||
* If omitted, will pick the default database for your project.
|
||||
* @param instance The Realtime Database instance to use.
|
||||
*/
|
||||
function instance(instance) {
|
||||
return _instanceWithOpts(instance, {});
|
||||
}
|
||||
exports.instance = instance;
|
||||
/**
|
||||
* Select Firebase Realtime Database Reference to listen to.
|
||||
*
|
||||
* This method behaves very similarly to the method of the same name in the
|
||||
* client and Admin Firebase SDKs. Any change to the Database that affects the
|
||||
* data at or below the provided `path` will fire an event in Cloud Functions.
|
||||
*
|
||||
* There are three important differences between listening to a Realtime
|
||||
* Database event in Cloud Functions and using the Realtime Database in the
|
||||
* client and Admin SDKs:
|
||||
* 1. Cloud Functions allows wildcards in the `path` name. Any `path` component
|
||||
* in curly brackets (`{}`) is a wildcard that matches all strings. The value
|
||||
* that matched a certain invocation of a Cloud Function is returned as part
|
||||
* of the `context.params` object. For example, `ref("messages/{messageId}")`
|
||||
* matches changes at `/messages/message1` or `/messages/message2`, resulting
|
||||
* in `context.params.messageId` being set to `"message1"` or `"message2"`,
|
||||
* respectively.
|
||||
* 2. Cloud Functions do not fire an event for data that already existed before
|
||||
* the Cloud Function was deployed.
|
||||
* 3. Cloud Function events have access to more information, including information
|
||||
* about the user who triggered the Cloud Function.
|
||||
* @param ref Path of the database to listen to.
|
||||
*/
|
||||
function ref(path) {
|
||||
return _refWithOpts(path, {});
|
||||
}
|
||||
exports.ref = ref;
|
||||
/** @internal */
|
||||
function _instanceWithOpts(instance, opts) {
|
||||
return new InstanceBuilder(instance, opts);
|
||||
}
|
||||
exports._instanceWithOpts = _instanceWithOpts;
|
||||
class InstanceBuilder {
|
||||
/* @internal */
|
||||
constructor(instance, opts) {
|
||||
this.instance = instance;
|
||||
this.opts = opts;
|
||||
}
|
||||
ref(path) {
|
||||
const normalized = utils_1.normalizePath(path);
|
||||
return new RefBuilder(apps_1.apps(), () => `projects/_/instances/${this.instance}/refs/${normalized}`, this.opts);
|
||||
}
|
||||
}
|
||||
exports.InstanceBuilder = InstanceBuilder;
|
||||
/** @internal */
|
||||
function _refWithOpts(path, opts) {
|
||||
const resourceGetter = () => {
|
||||
const normalized = utils_1.normalizePath(path);
|
||||
const databaseURL = config_1.firebaseConfig().databaseURL;
|
||||
if (!databaseURL) {
|
||||
throw new Error('Missing expected firebase config value databaseURL, ' +
|
||||
'config is actually' +
|
||||
JSON.stringify(config_1.firebaseConfig()) +
|
||||
'\n If you are unit testing, please set process.env.FIREBASE_CONFIG');
|
||||
}
|
||||
const match = databaseURL.match(databaseURLRegex);
|
||||
if (!match) {
|
||||
throw new Error('Invalid value for config firebase.databaseURL: ' + databaseURL);
|
||||
}
|
||||
const subdomain = match[1];
|
||||
return `projects/_/instances/${subdomain}/refs/${normalized}`;
|
||||
};
|
||||
return new RefBuilder(apps_1.apps(), resourceGetter, opts);
|
||||
}
|
||||
exports._refWithOpts = _refWithOpts;
|
||||
/** Builder used to create Cloud Functions for Firebase Realtime Database References. */
|
||||
class RefBuilder {
|
||||
/** @internal */
|
||||
constructor(apps, triggerResource, opts) {
|
||||
this.apps = apps;
|
||||
this.triggerResource = triggerResource;
|
||||
this.opts = opts;
|
||||
this.changeConstructor = (raw) => {
|
||||
let [dbInstance, path] = resourceToInstanceAndPath(raw.context.resource.name);
|
||||
let before = new DataSnapshot(raw.data.data, path, this.apps.admin, dbInstance);
|
||||
let after = new DataSnapshot(utils_1.applyChange(raw.data.data, raw.data.delta), path, this.apps.admin, dbInstance);
|
||||
return {
|
||||
before: before,
|
||||
after: after,
|
||||
};
|
||||
};
|
||||
}
|
||||
/** Respond to any write that affects a ref. */
|
||||
onWrite(handler) {
|
||||
return this.onOperation(handler, 'ref.write', this.changeConstructor);
|
||||
}
|
||||
/** Respond to update on a ref. */
|
||||
onUpdate(handler) {
|
||||
return this.onOperation(handler, 'ref.update', this.changeConstructor);
|
||||
}
|
||||
/** Respond to new data on a ref. */
|
||||
onCreate(handler) {
|
||||
let dataConstructor = (raw) => {
|
||||
let [dbInstance, path] = resourceToInstanceAndPath(raw.context.resource.name);
|
||||
return new DataSnapshot(raw.data.delta, path, this.apps.admin, dbInstance);
|
||||
};
|
||||
return this.onOperation(handler, 'ref.create', dataConstructor);
|
||||
}
|
||||
/** Respond to all data being deleted from a ref. */
|
||||
onDelete(handler) {
|
||||
let dataConstructor = (raw) => {
|
||||
let [dbInstance, path] = resourceToInstanceAndPath(raw.context.resource.name);
|
||||
return new DataSnapshot(raw.data.data, path, this.apps.admin, dbInstance);
|
||||
};
|
||||
return this.onOperation(handler, 'ref.delete', dataConstructor);
|
||||
}
|
||||
onOperation(handler, eventType, dataConstructor) {
|
||||
return cloud_functions_1.makeCloudFunction({
|
||||
handler,
|
||||
provider: exports.provider,
|
||||
service: exports.service,
|
||||
eventType,
|
||||
legacyEventType: `providers/${exports.provider}/eventTypes/${eventType}`,
|
||||
triggerResource: this.triggerResource,
|
||||
dataConstructor: dataConstructor,
|
||||
before: event => this.apps.retain(),
|
||||
after: event => this.apps.release(),
|
||||
opts: this.opts,
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.RefBuilder = RefBuilder;
|
||||
/* Utility function to extract database reference from resource string */
|
||||
/** @internal */
|
||||
function resourceToInstanceAndPath(resource) {
|
||||
let resourceRegex = `projects/([^/]+)/instances/([^/]+)/refs(/.+)?`;
|
||||
let match = resource.match(new RegExp(resourceRegex));
|
||||
if (!match) {
|
||||
throw new Error(`Unexpected resource string for Firebase Realtime Database event: ${resource}. ` +
|
||||
'Expected string in the format of "projects/_/instances/{firebaseioSubdomain}/refs/{ref=**}"');
|
||||
}
|
||||
let [, project, dbInstanceName, path] = match;
|
||||
if (project !== '_') {
|
||||
throw new Error(`Expect project to be '_' in a Firebase Realtime Database event`);
|
||||
}
|
||||
let dbInstance = 'https://' + dbInstanceName + '.firebaseio.com';
|
||||
return [dbInstance, path];
|
||||
}
|
||||
exports.resourceToInstanceAndPath = resourceToInstanceAndPath;
|
||||
class DataSnapshot {
|
||||
constructor(data, path, // path will be undefined for the database root
|
||||
app, instance) {
|
||||
this.app = app;
|
||||
if (instance) {
|
||||
// SDK always supplies instance, but user's unit tests may not
|
||||
this.instance = instance;
|
||||
}
|
||||
else if (app) {
|
||||
this.instance = app.options.databaseURL;
|
||||
}
|
||||
else if (process.env.GCLOUD_PROJECT) {
|
||||
this.instance =
|
||||
'https://' + process.env.GCLOUD_PROJECT + '.firebaseio.com';
|
||||
}
|
||||
this._path = path;
|
||||
this._data = data;
|
||||
}
|
||||
/** Ref returns a reference to the database with full admin access. */
|
||||
get ref() {
|
||||
if (!this.app) {
|
||||
// may be unpopulated in user's unit tests
|
||||
throw new Error('Please supply a Firebase app in the constructor for DataSnapshot' +
|
||||
' in order to use the .ref method.');
|
||||
}
|
||||
if (!this._ref) {
|
||||
this._ref = this.app.database(this.instance).ref(this._fullPath());
|
||||
}
|
||||
return this._ref;
|
||||
}
|
||||
get key() {
|
||||
let last = _.last(utils_1.pathParts(this._fullPath()));
|
||||
return !last || last === '' ? null : last;
|
||||
}
|
||||
val() {
|
||||
let parts = utils_1.pathParts(this._childPath);
|
||||
let source = this._data;
|
||||
let node = _.cloneDeep(parts.length ? _.get(source, parts, null) : source);
|
||||
return this._checkAndConvertToArray(node);
|
||||
}
|
||||
// TODO(inlined): figure out what to do here
|
||||
exportVal() {
|
||||
return this.val();
|
||||
}
|
||||
// TODO(inlined): figure out what to do here
|
||||
getPriority() {
|
||||
return 0;
|
||||
}
|
||||
exists() {
|
||||
return !_.isNull(this.val());
|
||||
}
|
||||
child(childPath) {
|
||||
if (!childPath) {
|
||||
return this;
|
||||
}
|
||||
return this._dup(childPath);
|
||||
}
|
||||
forEach(action) {
|
||||
let val = this.val();
|
||||
if (_.isPlainObject(val)) {
|
||||
return _.some(val, (value, key) => action(this.child(key)) === true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
hasChild(childPath) {
|
||||
return this.child(childPath).exists();
|
||||
}
|
||||
hasChildren() {
|
||||
let val = this.val();
|
||||
return _.isPlainObject(val) && _.keys(val).length > 0;
|
||||
}
|
||||
numChildren() {
|
||||
let val = this.val();
|
||||
return _.isPlainObject(val) ? Object.keys(val).length : 0;
|
||||
}
|
||||
/**
|
||||
* Prints the value of the snapshot; use '.previous.toJSON()' and '.current.toJSON()' to explicitly see
|
||||
* the previous and current values of the snapshot.
|
||||
*/
|
||||
toJSON() {
|
||||
return this.val();
|
||||
}
|
||||
/* Recursive function to check if keys are numeric & convert node object to array if they are */
|
||||
_checkAndConvertToArray(node) {
|
||||
if (node === null || typeof node === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
if (typeof node !== 'object') {
|
||||
return node;
|
||||
}
|
||||
let obj = {};
|
||||
let numKeys = 0;
|
||||
let maxKey = 0;
|
||||
let allIntegerKeys = true;
|
||||
for (let key in node) {
|
||||
if (!node.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
let childNode = node[key];
|
||||
obj[key] = this._checkAndConvertToArray(childNode);
|
||||
numKeys++;
|
||||
const integerRegExp = /^(0|[1-9]\d*)$/;
|
||||
if (allIntegerKeys && integerRegExp.test(key)) {
|
||||
maxKey = Math.max(maxKey, Number(key));
|
||||
}
|
||||
else {
|
||||
allIntegerKeys = false;
|
||||
}
|
||||
}
|
||||
if (allIntegerKeys && maxKey < 2 * numKeys) {
|
||||
// convert to array.
|
||||
let array = [];
|
||||
_.forOwn(obj, (val, key) => {
|
||||
array[key] = val;
|
||||
});
|
||||
return array;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
_dup(childPath) {
|
||||
let dup = new DataSnapshot(this._data, undefined, this.app, this.instance);
|
||||
[dup._path, dup._childPath] = [this._path, this._childPath];
|
||||
if (childPath) {
|
||||
dup._childPath = utils_1.joinPath(dup._childPath, childPath);
|
||||
}
|
||||
return dup;
|
||||
}
|
||||
_fullPath() {
|
||||
let out = (this._path || '') + '/' + (this._childPath || '');
|
||||
return out;
|
||||
}
|
||||
}
|
||||
exports.DataSnapshot = DataSnapshot;
|
36
website/node_modules/firebase-functions/lib/providers/firestore.d.ts
generated
vendored
Normal file
36
website/node_modules/firebase-functions/lib/providers/firestore.d.ts
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import * as firebase from 'firebase-admin';
|
||||
import { CloudFunction, Change, EventContext } from '../cloud-functions';
|
||||
export declare type DocumentSnapshot = firebase.firestore.DocumentSnapshot;
|
||||
/**
|
||||
* Select the Firestore document to listen to for events.
|
||||
* @param path Full database path to listen to. This includes the name of
|
||||
* the collection that the document is a part of. For example, if the
|
||||
* collection is named "users" and the document is named "Ada", then the
|
||||
* path is "/users/Ada".
|
||||
*/
|
||||
export declare function document(path: string): DocumentBuilder;
|
||||
export declare class DatabaseBuilder {
|
||||
private database;
|
||||
private opts;
|
||||
namespace(namespace: string): NamespaceBuilder;
|
||||
document(path: string): DocumentBuilder;
|
||||
}
|
||||
export declare class NamespaceBuilder {
|
||||
private database;
|
||||
private opts;
|
||||
private namespace;
|
||||
document(path: string): DocumentBuilder;
|
||||
}
|
||||
export declare class DocumentBuilder {
|
||||
private triggerResource;
|
||||
private opts;
|
||||
/** Respond to all document writes (creates, updates, or deletes). */
|
||||
onWrite(handler: (change: Change<DocumentSnapshot>, context: EventContext) => PromiseLike<any> | any): CloudFunction<Change<DocumentSnapshot>>;
|
||||
/** Respond only to document updates. */
|
||||
onUpdate(handler: (change: Change<DocumentSnapshot>, context: EventContext) => PromiseLike<any> | any): CloudFunction<Change<DocumentSnapshot>>;
|
||||
/** Respond only to document creations. */
|
||||
onCreate(handler: (snapshot: DocumentSnapshot, context: EventContext) => PromiseLike<any> | any): CloudFunction<DocumentSnapshot>;
|
||||
/** Respond only to document deletions. */
|
||||
onDelete(handler: (snapshot: DocumentSnapshot, context: EventContext) => PromiseLike<any> | any): CloudFunction<DocumentSnapshot>;
|
||||
private onOperation<T>(handler, eventType, dataConstructor);
|
||||
}
|
182
website/node_modules/firebase-functions/lib/providers/firestore.js
generated
vendored
Normal file
182
website/node_modules/firebase-functions/lib/providers/firestore.js
generated
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path_1 = require("path");
|
||||
const _ = require("lodash");
|
||||
const firebase = require("firebase-admin");
|
||||
const apps_1 = require("../apps");
|
||||
const cloud_functions_1 = require("../cloud-functions");
|
||||
const encoder_1 = require("../encoder");
|
||||
/** @internal */
|
||||
exports.provider = 'google.firestore';
|
||||
/** @internal */
|
||||
exports.service = 'firestore.googleapis.com';
|
||||
/** @internal */
|
||||
exports.defaultDatabase = '(default)';
|
||||
let firestoreInstance;
|
||||
/**
|
||||
* Select the Firestore document to listen to for events.
|
||||
* @param path Full database path to listen to. This includes the name of
|
||||
* the collection that the document is a part of. For example, if the
|
||||
* collection is named "users" and the document is named "Ada", then the
|
||||
* path is "/users/Ada".
|
||||
*/
|
||||
function document(path) {
|
||||
return _documentWithOpts(path, {});
|
||||
}
|
||||
exports.document = document;
|
||||
/** @internal */
|
||||
// Multiple namespaces are not yet supported by Firestore.
|
||||
function namespace(namespace) {
|
||||
return _namespaceWithOpts(namespace, {});
|
||||
}
|
||||
exports.namespace = namespace;
|
||||
/** @internal */
|
||||
// Multiple databases are not yet supported by Firestore.
|
||||
function database(database) {
|
||||
return _databaseWithOpts(database, {});
|
||||
}
|
||||
exports.database = database;
|
||||
/** @internal */
|
||||
function _databaseWithOpts(database = exports.defaultDatabase, opts) {
|
||||
return new DatabaseBuilder(database, opts);
|
||||
}
|
||||
exports._databaseWithOpts = _databaseWithOpts;
|
||||
/** @internal */
|
||||
function _namespaceWithOpts(namespace, opts) {
|
||||
return _databaseWithOpts(exports.defaultDatabase, opts).namespace(namespace);
|
||||
}
|
||||
exports._namespaceWithOpts = _namespaceWithOpts;
|
||||
/** @internal */
|
||||
function _documentWithOpts(path, opts) {
|
||||
return _databaseWithOpts(exports.defaultDatabase, opts).document(path);
|
||||
}
|
||||
exports._documentWithOpts = _documentWithOpts;
|
||||
class DatabaseBuilder {
|
||||
/** @internal */
|
||||
constructor(database, opts) {
|
||||
this.database = database;
|
||||
this.opts = opts;
|
||||
}
|
||||
namespace(namespace) {
|
||||
return new NamespaceBuilder(this.database, this.opts, namespace);
|
||||
}
|
||||
document(path) {
|
||||
return new NamespaceBuilder(this.database, this.opts).document(path);
|
||||
}
|
||||
}
|
||||
exports.DatabaseBuilder = DatabaseBuilder;
|
||||
class NamespaceBuilder {
|
||||
/** @internal */
|
||||
constructor(database, opts, namespace) {
|
||||
this.database = database;
|
||||
this.opts = opts;
|
||||
this.namespace = namespace;
|
||||
}
|
||||
document(path) {
|
||||
return new DocumentBuilder(() => {
|
||||
if (!process.env.GCLOUD_PROJECT) {
|
||||
throw new Error('process.env.GCLOUD_PROJECT is not set.');
|
||||
}
|
||||
let database = path_1.posix.join('projects', process.env.GCLOUD_PROJECT, 'databases', this.database);
|
||||
return path_1.posix.join(database, this.namespace ? `documents@${this.namespace}` : 'documents', path);
|
||||
}, this.opts);
|
||||
}
|
||||
}
|
||||
exports.NamespaceBuilder = NamespaceBuilder;
|
||||
function _getValueProto(data, resource, valueFieldName) {
|
||||
if (_.isEmpty(_.get(data, valueFieldName))) {
|
||||
// Firestore#snapshot_ takes resource string instead of proto for a non-existent snapshot
|
||||
return resource;
|
||||
}
|
||||
let proto = {
|
||||
fields: _.get(data, [valueFieldName, 'fields'], {}),
|
||||
createTime: encoder_1.dateToTimestampProto(_.get(data, [valueFieldName, 'createTime'])),
|
||||
updateTime: encoder_1.dateToTimestampProto(_.get(data, [valueFieldName, 'updateTime'])),
|
||||
name: _.get(data, [valueFieldName, 'name'], resource),
|
||||
};
|
||||
return proto;
|
||||
}
|
||||
/** @internal */
|
||||
function snapshotConstructor(event) {
|
||||
if (!firestoreInstance) {
|
||||
firestoreInstance = firebase.firestore(apps_1.apps().admin);
|
||||
firestoreInstance.settings({ timestampsInSnapshots: true });
|
||||
}
|
||||
let valueProto = _getValueProto(event.data, event.context.resource.name, 'value');
|
||||
let readTime = encoder_1.dateToTimestampProto(_.get(event, 'data.value.readTime'));
|
||||
return firestoreInstance.snapshot_(valueProto, readTime, 'json');
|
||||
}
|
||||
exports.snapshotConstructor = snapshotConstructor;
|
||||
/** @internal */
|
||||
// TODO remove this function when wire format changes to new format
|
||||
function beforeSnapshotConstructor(event) {
|
||||
if (!firestoreInstance) {
|
||||
firestoreInstance = firebase.firestore(apps_1.apps().admin);
|
||||
firestoreInstance.settings({ timestampsInSnapshots: true });
|
||||
}
|
||||
let oldValueProto = _getValueProto(event.data, event.context.resource.name, 'oldValue');
|
||||
let oldReadTime = encoder_1.dateToTimestampProto(_.get(event, 'data.oldValue.readTime'));
|
||||
return firestoreInstance.snapshot_(oldValueProto, oldReadTime, 'json');
|
||||
}
|
||||
exports.beforeSnapshotConstructor = beforeSnapshotConstructor;
|
||||
function changeConstructor(raw) {
|
||||
return cloud_functions_1.Change.fromObjects(beforeSnapshotConstructor(raw), snapshotConstructor(raw));
|
||||
}
|
||||
class DocumentBuilder {
|
||||
/** @internal */
|
||||
constructor(triggerResource, opts) {
|
||||
this.triggerResource = triggerResource;
|
||||
this.opts = opts;
|
||||
// TODO what validation do we want to do here?
|
||||
}
|
||||
/** Respond to all document writes (creates, updates, or deletes). */
|
||||
onWrite(handler) {
|
||||
return this.onOperation(handler, 'document.write', changeConstructor);
|
||||
}
|
||||
/** Respond only to document updates. */
|
||||
onUpdate(handler) {
|
||||
return this.onOperation(handler, 'document.update', changeConstructor);
|
||||
}
|
||||
/** Respond only to document creations. */
|
||||
onCreate(handler) {
|
||||
return this.onOperation(handler, 'document.create', snapshotConstructor);
|
||||
}
|
||||
/** Respond only to document deletions. */
|
||||
onDelete(handler) {
|
||||
return this.onOperation(handler, 'document.delete', beforeSnapshotConstructor);
|
||||
}
|
||||
onOperation(handler, eventType, dataConstructor) {
|
||||
return cloud_functions_1.makeCloudFunction({
|
||||
handler,
|
||||
provider: exports.provider,
|
||||
eventType,
|
||||
service: exports.service,
|
||||
triggerResource: this.triggerResource,
|
||||
legacyEventType: `providers/cloud.firestore/eventTypes/${eventType}`,
|
||||
dataConstructor,
|
||||
opts: this.opts,
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.DocumentBuilder = DocumentBuilder;
|
91
website/node_modules/firebase-functions/lib/providers/https.d.ts
generated
vendored
Normal file
91
website/node_modules/firebase-functions/lib/providers/https.d.ts
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
/// <reference types="express" />
|
||||
import * as express from 'express';
|
||||
import * as firebase from 'firebase-admin';
|
||||
import { HttpsFunction, Runnable } from '../cloud-functions';
|
||||
/**
|
||||
* Handle HTTP requests.
|
||||
* @param handler A function that takes a request and response object,
|
||||
* same signature as an Express app.
|
||||
*/
|
||||
export declare function onRequest(handler: (req: express.Request, resp: express.Response) => void): HttpsFunction;
|
||||
/**
|
||||
* Declares a callable method for clients to call using a Firebase SDK.
|
||||
* @param handler A method that takes a data and context and returns a value.
|
||||
*/
|
||||
export declare function onCall(handler: (data: any, context: CallableContext) => any | Promise<any>): HttpsFunction & Runnable<any>;
|
||||
/**
|
||||
* The set of Firebase Functions status codes. The codes are the same at the
|
||||
* ones exposed by gRPC here:
|
||||
* https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
|
||||
*
|
||||
* Possible values:
|
||||
* - 'cancelled': The operation was cancelled (typically by the caller).
|
||||
* - 'unknown': Unknown error or an error from a different error domain.
|
||||
* - 'invalid-argument': Client specified an invalid argument. Note that this
|
||||
* differs from 'failed-precondition'. 'invalid-argument' indicates
|
||||
* arguments that are problematic regardless of the state of the system
|
||||
* (e.g. an invalid field name).
|
||||
* - 'deadline-exceeded': Deadline expired before operation could complete.
|
||||
* For operations that change the state of the system, this error may be
|
||||
* returned even if the operation has completed successfully. For example,
|
||||
* a successful response from a server could have been delayed long enough
|
||||
* for the deadline to expire.
|
||||
* - 'not-found': Some requested document was not found.
|
||||
* - 'already-exists': Some document that we attempted to create already
|
||||
* exists.
|
||||
* - 'permission-denied': The caller does not have permission to execute the
|
||||
* specified operation.
|
||||
* - 'resource-exhausted': Some resource has been exhausted, perhaps a
|
||||
* per-user quota, or perhaps the entire file system is out of space.
|
||||
* - 'failed-precondition': Operation was rejected because the system is not
|
||||
* in a state required for the operation's execution.
|
||||
* - 'aborted': The operation was aborted, typically due to a concurrency
|
||||
* issue like transaction aborts, etc.
|
||||
* - 'out-of-range': Operation was attempted past the valid range.
|
||||
* - 'unimplemented': Operation is not implemented or not supported/enabled.
|
||||
* - 'internal': Internal errors. Means some invariants expected by
|
||||
* underlying system has been broken. If you see one of these errors,
|
||||
* something is very broken.
|
||||
* - 'unavailable': The service is currently unavailable. This is most likely
|
||||
* a transient condition and may be corrected by retrying with a backoff.
|
||||
* - 'data-loss': Unrecoverable data loss or corruption.
|
||||
* - 'unauthenticated': The request does not have valid authentication
|
||||
* credentials for the operation.
|
||||
*/
|
||||
export declare type FunctionsErrorCode = 'ok' | 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated';
|
||||
/**
|
||||
* An explicit error that can be thrown from a handler to send an error to the
|
||||
* client that called the function.
|
||||
*/
|
||||
export declare class HttpsError extends Error {
|
||||
/**
|
||||
* A standard error code that will be returned to the client. This also
|
||||
* determines the HTTP status code of the response, as defined in code.proto.
|
||||
*/
|
||||
readonly code: FunctionsErrorCode;
|
||||
/**
|
||||
* Extra data to be converted to JSON and included in the error response.
|
||||
*/
|
||||
readonly details?: any;
|
||||
constructor(code: FunctionsErrorCode, message?: string, details?: any);
|
||||
}
|
||||
/**
|
||||
* The interface for metadata for the API as passed to the handler.
|
||||
*/
|
||||
export interface CallableContext {
|
||||
/**
|
||||
* The result of decoding and verifying a Firebase Auth ID token.
|
||||
*/
|
||||
auth?: {
|
||||
uid: string;
|
||||
token: firebase.auth.DecodedIdToken;
|
||||
};
|
||||
/**
|
||||
* An unverified token for a Firebase Instance ID.
|
||||
*/
|
||||
instanceIdToken?: string;
|
||||
/**
|
||||
* The raw request handled by the callable.
|
||||
*/
|
||||
rawRequest: express.Request;
|
||||
}
|
359
website/node_modules/firebase-functions/lib/providers/https.js
generated
vendored
Normal file
359
website/node_modules/firebase-functions/lib/providers/https.js
generated
vendored
Normal file
@@ -0,0 +1,359 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const _ = require("lodash");
|
||||
const cors = require("cors");
|
||||
const apps_1 = require("../apps");
|
||||
const cloud_functions_1 = require("../cloud-functions");
|
||||
/**
|
||||
* Handle HTTP requests.
|
||||
* @param handler A function that takes a request and response object,
|
||||
* same signature as an Express app.
|
||||
*/
|
||||
function onRequest(handler) {
|
||||
return _onRequestWithOpts(handler, {});
|
||||
}
|
||||
exports.onRequest = onRequest;
|
||||
/**
|
||||
* Declares a callable method for clients to call using a Firebase SDK.
|
||||
* @param handler A method that takes a data and context and returns a value.
|
||||
*/
|
||||
function onCall(handler) {
|
||||
return _onCallWithOpts(handler, {});
|
||||
}
|
||||
exports.onCall = onCall;
|
||||
/** @internal */
|
||||
function _onRequestWithOpts(handler, opts) {
|
||||
// lets us add __trigger without altering handler:
|
||||
let cloudFunction = (req, res) => {
|
||||
handler(req, res);
|
||||
};
|
||||
cloudFunction.__trigger = _.assign(cloud_functions_1.optsToTrigger(opts), { httpsTrigger: {} });
|
||||
// TODO parse the opts
|
||||
return cloudFunction;
|
||||
}
|
||||
exports._onRequestWithOpts = _onRequestWithOpts;
|
||||
/**
|
||||
* Standard error codes for different ways a request can fail, as defined by:
|
||||
* https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
|
||||
*
|
||||
* This map is used primarily to convert from a client error code string to
|
||||
* to the HTTP format error code string, and make sure it's in the supported set.
|
||||
*/
|
||||
const errorCodeMap = {
|
||||
ok: 'OK',
|
||||
cancelled: 'CANCELLED',
|
||||
unknown: 'UNKNOWN',
|
||||
'invalid-argument': 'INVALID_ARGUMENT',
|
||||
'deadline-exceeded': 'DEADLINE_EXCEEDED',
|
||||
'not-found': 'NOT_FOUND',
|
||||
'already-exists': 'ALREADY_EXISTS',
|
||||
'permission-denied': 'PERMISSION_DENIED',
|
||||
unauthenticated: 'UNAUTHENTICATED',
|
||||
'resource-exhausted': 'RESOURCE_EXHAUSTED',
|
||||
'failed-precondition': 'FAILED_PRECONDITION',
|
||||
aborted: 'ABORTED',
|
||||
'out-of-range': 'OUT_OF_RANGE',
|
||||
unimplemented: 'UNIMPLEMENTED',
|
||||
internal: 'INTERNAL',
|
||||
unavailable: 'UNAVAILABLE',
|
||||
'data-loss': 'DATA_LOSS',
|
||||
};
|
||||
/**
|
||||
* An explicit error that can be thrown from a handler to send an error to the
|
||||
* client that called the function.
|
||||
*/
|
||||
class HttpsError extends Error {
|
||||
constructor(code, message, details) {
|
||||
super(message);
|
||||
// This is a workaround for a bug in TypeScript when extending Error:
|
||||
// tslint:disable-next-line
|
||||
// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
||||
Object.setPrototypeOf(this, HttpsError.prototype);
|
||||
if (!errorCodeMap[code]) {
|
||||
throw new Error('Unknown error status: ' + code);
|
||||
}
|
||||
this.code = code;
|
||||
this.details = details;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
* A string representation of the Google error code for this error for HTTP.
|
||||
*/
|
||||
get status() {
|
||||
return errorCodeMap[this.code];
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
* Returns the canonical http status code for the given error.
|
||||
*/
|
||||
get httpStatus() {
|
||||
switch (this.code) {
|
||||
case 'ok':
|
||||
return 200;
|
||||
case 'cancelled':
|
||||
return 499;
|
||||
case 'unknown':
|
||||
return 500;
|
||||
case 'invalid-argument':
|
||||
return 400;
|
||||
case 'deadline-exceeded':
|
||||
return 504;
|
||||
case 'not-found':
|
||||
return 404;
|
||||
case 'already-exists':
|
||||
return 409;
|
||||
case 'permission-denied':
|
||||
return 403;
|
||||
case 'unauthenticated':
|
||||
return 401;
|
||||
case 'resource-exhausted':
|
||||
return 429;
|
||||
case 'failed-precondition':
|
||||
return 400;
|
||||
case 'aborted':
|
||||
return 409;
|
||||
case 'out-of-range':
|
||||
return 400;
|
||||
case 'unimplemented':
|
||||
return 501;
|
||||
case 'internal':
|
||||
return 500;
|
||||
case 'unavailable':
|
||||
return 503;
|
||||
case 'data-loss':
|
||||
return 500;
|
||||
// This should never happen as long as the type system is doing its job.
|
||||
default:
|
||||
throw 'Invalid error code: ' + this.code;
|
||||
}
|
||||
}
|
||||
/** @internal */
|
||||
toJSON() {
|
||||
const json = {
|
||||
status: this.status,
|
||||
message: this.message,
|
||||
};
|
||||
if (!_.isUndefined(this.details)) {
|
||||
json.details = this.details;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
}
|
||||
exports.HttpsError = HttpsError;
|
||||
// Returns true if req is a properly formatted callable request.
|
||||
function isValidRequest(req) {
|
||||
// The body must not be empty.
|
||||
if (!req.body) {
|
||||
console.warn('Request is missing body.');
|
||||
return false;
|
||||
}
|
||||
// Make sure it's a POST.
|
||||
if (req.method !== 'POST') {
|
||||
console.warn('Request has invalid method.', req.method);
|
||||
return false;
|
||||
}
|
||||
// Check that the Content-Type is JSON.
|
||||
let contentType = (req.header('Content-Type') || '').toLowerCase();
|
||||
// If it has a charset, just ignore it for now.
|
||||
const semiColon = contentType.indexOf(';');
|
||||
if (semiColon >= 0) {
|
||||
contentType = contentType.substr(0, semiColon).trim();
|
||||
}
|
||||
if (contentType !== 'application/json') {
|
||||
console.warn('Request has incorrect Content-Type.', contentType);
|
||||
return false;
|
||||
}
|
||||
// The body must have data.
|
||||
if (_.isUndefined(req.body.data)) {
|
||||
console.warn('Request body is missing data.', req.body);
|
||||
return false;
|
||||
}
|
||||
// TODO(klimt): Allow only whitelisted http headers.
|
||||
// Verify that the body does not have any extra fields.
|
||||
const extras = _.omit(req.body, 'data');
|
||||
if (!_.isEmpty(extras)) {
|
||||
console.warn('Request body has extra fields.', extras);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const LONG_TYPE = 'type.googleapis.com/google.protobuf.Int64Value';
|
||||
const UNSIGNED_LONG_TYPE = 'type.googleapis.com/google.protobuf.UInt64Value';
|
||||
/**
|
||||
* Encodes arbitrary data in our special format for JSON.
|
||||
* This is exposed only for testing.
|
||||
*/
|
||||
/** @internal */
|
||||
function encode(data) {
|
||||
if (_.isNull(data) || _.isUndefined(data)) {
|
||||
return null;
|
||||
}
|
||||
// Oddly, _.isFinite(new Number(x)) always returns false, so unwrap Numbers.
|
||||
if (data instanceof Number) {
|
||||
data = data.valueOf();
|
||||
}
|
||||
if (_.isFinite(data)) {
|
||||
// Any number in JS is safe to put directly in JSON and parse as a double
|
||||
// without any loss of precision.
|
||||
return data;
|
||||
}
|
||||
if (_.isBoolean(data)) {
|
||||
return data;
|
||||
}
|
||||
if (_.isString(data)) {
|
||||
return data;
|
||||
}
|
||||
if (_.isArray(data)) {
|
||||
return _.map(data, encode);
|
||||
}
|
||||
if (_.isObject(data)) {
|
||||
// It's not safe to use _.forEach, because the object might be 'array-like'
|
||||
// if it has a key called 'length'. Note that this intentionally overrides
|
||||
// any toJSON method that an object may have.
|
||||
return _.mapValues(data, encode);
|
||||
}
|
||||
// If we got this far, the data is not encodable.
|
||||
console.error('Data cannot be encoded in JSON.', data);
|
||||
throw new Error('Data cannot be encoded in JSON: ' + data);
|
||||
}
|
||||
exports.encode = encode;
|
||||
/**
|
||||
* Decodes our special format for JSON into native types.
|
||||
* This is exposed only for testing.
|
||||
*/
|
||||
/** @internal */
|
||||
function decode(data) {
|
||||
if (data === null) {
|
||||
return data;
|
||||
}
|
||||
if (data['@type']) {
|
||||
switch (data['@type']) {
|
||||
case LONG_TYPE:
|
||||
// Fall through and handle this the same as unsigned.
|
||||
case UNSIGNED_LONG_TYPE: {
|
||||
// Technically, this could work return a valid number for malformed
|
||||
// data if there was a number followed by garbage. But it's just not
|
||||
// worth all the extra code to detect that case.
|
||||
const value = parseFloat(data.value);
|
||||
if (_.isNaN(value)) {
|
||||
console.error('Data cannot be decoded from JSON.', data);
|
||||
throw new Error('Data cannot be decoded from JSON: ' + data);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
default: {
|
||||
console.error('Data cannot be decoded from JSON.', data);
|
||||
throw new Error('Data cannot be decoded from JSON: ' + data);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_.isArray(data)) {
|
||||
return _.map(data, decode);
|
||||
}
|
||||
if (_.isObject(data)) {
|
||||
// It's not safe to use _.forEach, because the object might be 'array-like'
|
||||
// if it has a key called 'length'.
|
||||
return _.mapValues(data, decode);
|
||||
}
|
||||
// Anything else is safe to return.
|
||||
return data;
|
||||
}
|
||||
exports.decode = decode;
|
||||
const corsHandler = cors({ origin: true, methods: 'POST' });
|
||||
/** @internal */
|
||||
function _onCallWithOpts(handler, opts) {
|
||||
const func = (req, res) => __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
if (!isValidRequest(req)) {
|
||||
console.error('Invalid request', req);
|
||||
throw new HttpsError('invalid-argument', 'Bad Request');
|
||||
}
|
||||
const context = { rawRequest: req };
|
||||
const authorization = req.header('Authorization');
|
||||
if (authorization) {
|
||||
const match = authorization.match(/^Bearer (.*)$/);
|
||||
if (!match) {
|
||||
throw new HttpsError('unauthenticated', 'Unauthenticated');
|
||||
}
|
||||
const idToken = match[1];
|
||||
try {
|
||||
const authToken = yield apps_1.apps()
|
||||
.admin.auth()
|
||||
.verifyIdToken(idToken);
|
||||
context.auth = {
|
||||
uid: authToken.uid,
|
||||
token: authToken,
|
||||
};
|
||||
}
|
||||
catch (e) {
|
||||
throw new HttpsError('unauthenticated', 'Unauthenticated');
|
||||
}
|
||||
}
|
||||
const instanceId = req.header('Firebase-Instance-ID-Token');
|
||||
if (instanceId) {
|
||||
// Validating the token requires an http request, so we don't do it.
|
||||
// If the user wants to use it for something, it will be validated then.
|
||||
// Currently, the only real use case for this token is for sending
|
||||
// pushes with FCM. In that case, the FCM APIs will validate the token.
|
||||
context.instanceIdToken = req.header('Firebase-Instance-ID-Token');
|
||||
}
|
||||
const data = decode(req.body.data);
|
||||
let result = yield handler(data, context);
|
||||
// Encode the result as JSON to preserve types like Dates.
|
||||
result = encode(result);
|
||||
// If there was some result, encode it in the body.
|
||||
const responseBody = { result };
|
||||
res.status(200).send(responseBody);
|
||||
}
|
||||
catch (error) {
|
||||
if (!(error instanceof HttpsError)) {
|
||||
// This doesn't count as an 'explicit' error.
|
||||
console.error('Unhandled error', error);
|
||||
error = new HttpsError('internal', 'INTERNAL');
|
||||
}
|
||||
const status = error.httpStatus;
|
||||
const body = { error: error.toJSON() };
|
||||
res.status(status).send(body);
|
||||
}
|
||||
});
|
||||
// Wrap the function with a cors handler.
|
||||
const corsFunc = (req, res) => {
|
||||
return corsHandler(req, res, () => func(req, res));
|
||||
};
|
||||
corsFunc.__trigger = _.assign(cloud_functions_1.optsToTrigger(opts), {
|
||||
httpsTrigger: {},
|
||||
labels: { 'deployment-callable': 'true' },
|
||||
});
|
||||
corsFunc.run = handler;
|
||||
return corsFunc;
|
||||
}
|
||||
exports._onCallWithOpts = _onCallWithOpts;
|
29
website/node_modules/firebase-functions/lib/providers/pubsub.d.ts
generated
vendored
Normal file
29
website/node_modules/firebase-functions/lib/providers/pubsub.d.ts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import { CloudFunction, EventContext } from '../cloud-functions';
|
||||
/** Select Cloud Pub/Sub topic to listen to.
|
||||
* @param topic Name of Pub/Sub topic, must belong to the same project as the function.
|
||||
*/
|
||||
export declare function topic(topic: string): TopicBuilder;
|
||||
/** Builder used to create Cloud Functions for Google Pub/Sub topics. */
|
||||
export declare class TopicBuilder {
|
||||
private triggerResource;
|
||||
private opts;
|
||||
/** Handle a Pub/Sub message that was published to a Cloud Pub/Sub topic */
|
||||
onPublish(handler: (message: Message, context: EventContext) => PromiseLike<any> | any): CloudFunction<Message>;
|
||||
}
|
||||
/**
|
||||
* A Pub/Sub message.
|
||||
*
|
||||
* This class has an additional .json helper which will correctly deserialize any
|
||||
* message that was a JSON object when published with the JS SDK. .json will throw
|
||||
* if the message is not a base64 encoded JSON string.
|
||||
*/
|
||||
export declare class Message {
|
||||
readonly data: string;
|
||||
readonly attributes: {
|
||||
[key: string]: string;
|
||||
};
|
||||
private _json;
|
||||
constructor(data: any);
|
||||
readonly json: any;
|
||||
toJSON(): any;
|
||||
}
|
98
website/node_modules/firebase-functions/lib/providers/pubsub.js
generated
vendored
Normal file
98
website/node_modules/firebase-functions/lib/providers/pubsub.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const cloud_functions_1 = require("../cloud-functions");
|
||||
/** @internal */
|
||||
exports.provider = 'google.pubsub';
|
||||
/** @internal */
|
||||
exports.service = 'pubsub.googleapis.com';
|
||||
/** Select Cloud Pub/Sub topic to listen to.
|
||||
* @param topic Name of Pub/Sub topic, must belong to the same project as the function.
|
||||
*/
|
||||
function topic(topic) {
|
||||
return _topicWithOpts(topic, {});
|
||||
}
|
||||
exports.topic = topic;
|
||||
/** @internal */
|
||||
function _topicWithOpts(topic, opts) {
|
||||
if (topic.indexOf('/') !== -1) {
|
||||
throw new Error('Topic name may not have a /');
|
||||
}
|
||||
return new TopicBuilder(() => {
|
||||
if (!process.env.GCLOUD_PROJECT) {
|
||||
throw new Error('process.env.GCLOUD_PROJECT is not set.');
|
||||
}
|
||||
return `projects/${process.env.GCLOUD_PROJECT}/topics/${topic}`;
|
||||
}, opts);
|
||||
}
|
||||
exports._topicWithOpts = _topicWithOpts;
|
||||
/** Builder used to create Cloud Functions for Google Pub/Sub topics. */
|
||||
class TopicBuilder {
|
||||
/** @internal */
|
||||
constructor(triggerResource, opts) {
|
||||
this.triggerResource = triggerResource;
|
||||
this.opts = opts;
|
||||
}
|
||||
/** Handle a Pub/Sub message that was published to a Cloud Pub/Sub topic */
|
||||
onPublish(handler) {
|
||||
return cloud_functions_1.makeCloudFunction({
|
||||
handler,
|
||||
provider: exports.provider,
|
||||
service: exports.service,
|
||||
triggerResource: this.triggerResource,
|
||||
eventType: 'topic.publish',
|
||||
dataConstructor: raw => new Message(raw.data),
|
||||
opts: this.opts,
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.TopicBuilder = TopicBuilder;
|
||||
/**
|
||||
* A Pub/Sub message.
|
||||
*
|
||||
* This class has an additional .json helper which will correctly deserialize any
|
||||
* message that was a JSON object when published with the JS SDK. .json will throw
|
||||
* if the message is not a base64 encoded JSON string.
|
||||
*/
|
||||
class Message {
|
||||
constructor(data) {
|
||||
[this.data, this.attributes, this._json] = [
|
||||
data.data,
|
||||
data.attributes || {},
|
||||
data.json,
|
||||
];
|
||||
}
|
||||
get json() {
|
||||
if (typeof this._json === 'undefined') {
|
||||
this._json = JSON.parse(new Buffer(this.data, 'base64').toString('utf8'));
|
||||
}
|
||||
return this._json;
|
||||
}
|
||||
toJSON() {
|
||||
return {
|
||||
data: this.data,
|
||||
attributes: this.attributes,
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.Message = Message;
|
35
website/node_modules/firebase-functions/lib/providers/remoteConfig.d.ts
generated
vendored
Normal file
35
website/node_modules/firebase-functions/lib/providers/remoteConfig.d.ts
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
import { CloudFunction, EventContext } from '../cloud-functions';
|
||||
/**
|
||||
* Handle all updates (including rollbacks) that affect a Remote Config project.
|
||||
* @param handler A function that takes the updated Remote Config template
|
||||
* version metadata as an argument.
|
||||
*/
|
||||
export declare function onUpdate(handler: (version: TemplateVersion, context: EventContext) => PromiseLike<any> | any): CloudFunction<TemplateVersion>;
|
||||
/**
|
||||
* Interface representing a Remote Config template version metadata object that
|
||||
* was emitted when the project was updated.
|
||||
*/
|
||||
export interface TemplateVersion {
|
||||
/** The version number of the updated Remote Config template. */
|
||||
versionNumber: number;
|
||||
/** When the template was updated in format (ISO8601 timestamp). */
|
||||
updateTime: string;
|
||||
/** Metadata about the account that performed the update. */
|
||||
updateUser: RemoteConfigUser;
|
||||
/** A description associated with the particular Remote Config template. */
|
||||
description: string;
|
||||
/** The origin of the caller. */
|
||||
updateOrigin: string;
|
||||
/** The type of update action that was performed. */
|
||||
updateType: string;
|
||||
/**
|
||||
* The version number of the Remote Config template that was rolled back to,
|
||||
* if the update was a rollback.
|
||||
*/
|
||||
rollbackSource?: number;
|
||||
}
|
||||
export interface RemoteConfigUser {
|
||||
name?: string;
|
||||
email: string;
|
||||
imageUrl?: string;
|
||||
}
|
52
website/node_modules/firebase-functions/lib/providers/remoteConfig.js
generated
vendored
Normal file
52
website/node_modules/firebase-functions/lib/providers/remoteConfig.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the 'Software'), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const cloud_functions_1 = require("../cloud-functions");
|
||||
/** @internal */
|
||||
exports.provider = 'google.firebase.remoteconfig';
|
||||
/** @internal */
|
||||
exports.service = 'firebaseremoteconfig.googleapis.com';
|
||||
/**
|
||||
* Handle all updates (including rollbacks) that affect a Remote Config project.
|
||||
* @param handler A function that takes the updated Remote Config template
|
||||
* version metadata as an argument.
|
||||
*/
|
||||
function onUpdate(handler) {
|
||||
return _onUpdateWithOpts(handler, {});
|
||||
}
|
||||
exports.onUpdate = onUpdate;
|
||||
/** @internal */
|
||||
function _onUpdateWithOpts(handler, opts) {
|
||||
if (!process.env.GCLOUD_PROJECT) {
|
||||
throw new Error('process.env.GCLOUD_PROJECT is not set.');
|
||||
}
|
||||
return cloud_functions_1.makeCloudFunction({
|
||||
handler,
|
||||
provider: exports.provider,
|
||||
service: exports.service,
|
||||
triggerResource: () => `projects/${process.env.GCLOUD_PROJECT}`,
|
||||
eventType: 'update',
|
||||
opts: opts,
|
||||
});
|
||||
}
|
||||
exports._onUpdateWithOpts = _onUpdateWithOpts;
|
85
website/node_modules/firebase-functions/lib/providers/storage.d.ts
generated
vendored
Normal file
85
website/node_modules/firebase-functions/lib/providers/storage.d.ts
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
import { CloudFunction, EventContext } from '../cloud-functions';
|
||||
/**
|
||||
* The optional bucket function allows you to choose which buckets' events to handle.
|
||||
* This step can be bypassed by calling object() directly, which will use the default
|
||||
* Cloud Storage for Firebase bucket.
|
||||
* @param bucket Name of the Google Cloud Storage bucket to listen to.
|
||||
*/
|
||||
export declare function bucket(bucket?: string): BucketBuilder;
|
||||
/**
|
||||
* Handle events related to Cloud Storage objects.
|
||||
*/
|
||||
export declare function object(): ObjectBuilder;
|
||||
export declare class BucketBuilder {
|
||||
private triggerResource;
|
||||
private opts;
|
||||
/** Handle events for objects in this bucket. */
|
||||
object(): ObjectBuilder;
|
||||
}
|
||||
export declare class ObjectBuilder {
|
||||
private triggerResource;
|
||||
private opts;
|
||||
/** Respond to archiving of an object, this is only for buckets that enabled object versioning. */
|
||||
onArchive(handler: (object: ObjectMetadata, context: EventContext) => PromiseLike<any> | any): CloudFunction<ObjectMetadata>;
|
||||
/** Respond to the deletion of an object (not to archiving, if object versioning is enabled). */
|
||||
onDelete(handler: (object: ObjectMetadata, context: EventContext) => PromiseLike<any> | any): CloudFunction<ObjectMetadata>;
|
||||
/** Respond to the successful creation of an object. */
|
||||
onFinalize(handler: (object: ObjectMetadata, context: EventContext) => PromiseLike<any> | any): CloudFunction<ObjectMetadata>;
|
||||
/** Respond to metadata updates of existing objects. */
|
||||
onMetadataUpdate(handler: (object: ObjectMetadata, context: EventContext) => PromiseLike<any> | any): CloudFunction<ObjectMetadata>;
|
||||
private onOperation(handler, eventType);
|
||||
}
|
||||
export interface ObjectMetadata {
|
||||
kind: string;
|
||||
id: string;
|
||||
bucket: string;
|
||||
storageClass: string;
|
||||
size: string;
|
||||
timeCreated: string;
|
||||
updated: string;
|
||||
selfLink?: string;
|
||||
name?: string;
|
||||
generation?: string;
|
||||
contentType?: string;
|
||||
metageneration?: string;
|
||||
timeDeleted?: string;
|
||||
timeStorageClassUpdated?: string;
|
||||
md5Hash?: string;
|
||||
mediaLink?: string;
|
||||
contentEncoding?: string;
|
||||
contentDisposition?: string;
|
||||
contentLanguage?: string;
|
||||
cacheControl?: string;
|
||||
metadata?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
acl?: [{
|
||||
kind?: string;
|
||||
id?: string;
|
||||
selfLink?: string;
|
||||
bucket?: string;
|
||||
object?: string;
|
||||
generation?: string;
|
||||
entity?: string;
|
||||
role?: string;
|
||||
email?: string;
|
||||
entityId?: string;
|
||||
domain?: string;
|
||||
projectTeam?: {
|
||||
projectNumber?: string;
|
||||
team?: string;
|
||||
};
|
||||
etag?: string;
|
||||
}];
|
||||
owner?: {
|
||||
entity?: string;
|
||||
entityId?: string;
|
||||
};
|
||||
crc32c?: string;
|
||||
componentCount?: string;
|
||||
etag?: string;
|
||||
customerEncryption?: {
|
||||
encryptionAlgorithm?: string;
|
||||
keySha256?: string;
|
||||
};
|
||||
}
|
118
website/node_modules/firebase-functions/lib/providers/storage.js
generated
vendored
Normal file
118
website/node_modules/firebase-functions/lib/providers/storage.js
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const cloud_functions_1 = require("../cloud-functions");
|
||||
const config_1 = require("../config");
|
||||
/** @internal */
|
||||
exports.provider = 'google.storage';
|
||||
/** @internal */
|
||||
exports.service = 'storage.googleapis.com';
|
||||
/**
|
||||
* The optional bucket function allows you to choose which buckets' events to handle.
|
||||
* This step can be bypassed by calling object() directly, which will use the default
|
||||
* Cloud Storage for Firebase bucket.
|
||||
* @param bucket Name of the Google Cloud Storage bucket to listen to.
|
||||
*/
|
||||
function bucket(bucket) {
|
||||
return _bucketWithOpts({}, bucket);
|
||||
}
|
||||
exports.bucket = bucket;
|
||||
/**
|
||||
* Handle events related to Cloud Storage objects.
|
||||
*/
|
||||
function object() {
|
||||
return _objectWithOpts({});
|
||||
}
|
||||
exports.object = object;
|
||||
/** @internal */
|
||||
function _bucketWithOpts(opts, bucket) {
|
||||
const resourceGetter = () => {
|
||||
bucket = bucket || config_1.firebaseConfig().storageBucket;
|
||||
if (!bucket) {
|
||||
throw new Error('Missing bucket name. If you are unit testing, please provide a bucket name' +
|
||||
' through `functions.storage.bucket(bucketName)`, or set process.env.FIREBASE_CONFIG.');
|
||||
}
|
||||
if (!/^[a-z\d][a-z\d\\._-]{1,230}[a-z\d]$/.test(bucket)) {
|
||||
throw new Error(`Invalid bucket name ${bucket}`);
|
||||
}
|
||||
return `projects/_/buckets/${bucket}`;
|
||||
};
|
||||
return new BucketBuilder(resourceGetter, opts);
|
||||
}
|
||||
exports._bucketWithOpts = _bucketWithOpts;
|
||||
/** @internal */
|
||||
function _objectWithOpts(opts) {
|
||||
return _bucketWithOpts(opts).object();
|
||||
}
|
||||
exports._objectWithOpts = _objectWithOpts;
|
||||
class BucketBuilder {
|
||||
/** @internal */
|
||||
constructor(triggerResource, opts) {
|
||||
this.triggerResource = triggerResource;
|
||||
this.opts = opts;
|
||||
}
|
||||
/** Handle events for objects in this bucket. */
|
||||
object() {
|
||||
return new ObjectBuilder(this.triggerResource, this.opts);
|
||||
}
|
||||
}
|
||||
exports.BucketBuilder = BucketBuilder;
|
||||
class ObjectBuilder {
|
||||
/** @internal */
|
||||
constructor(triggerResource, opts) {
|
||||
this.triggerResource = triggerResource;
|
||||
this.opts = opts;
|
||||
}
|
||||
/** @internal */
|
||||
onChange(handler) {
|
||||
throw new Error('"onChange" is now deprecated, please use "onArchive", "onDelete", ' +
|
||||
'"onFinalize", or "onMetadataUpdate".');
|
||||
}
|
||||
/** Respond to archiving of an object, this is only for buckets that enabled object versioning. */
|
||||
onArchive(handler) {
|
||||
return this.onOperation(handler, 'object.archive');
|
||||
}
|
||||
/** Respond to the deletion of an object (not to archiving, if object versioning is enabled). */
|
||||
onDelete(handler) {
|
||||
return this.onOperation(handler, 'object.delete');
|
||||
}
|
||||
/** Respond to the successful creation of an object. */
|
||||
onFinalize(handler) {
|
||||
return this.onOperation(handler, 'object.finalize');
|
||||
}
|
||||
/** Respond to metadata updates of existing objects. */
|
||||
onMetadataUpdate(handler) {
|
||||
return this.onOperation(handler, 'object.metadataUpdate');
|
||||
}
|
||||
onOperation(handler, eventType) {
|
||||
return cloud_functions_1.makeCloudFunction({
|
||||
handler,
|
||||
provider: exports.provider,
|
||||
service: exports.service,
|
||||
eventType,
|
||||
triggerResource: this.triggerResource,
|
||||
opts: this.opts,
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.ObjectBuilder = ObjectBuilder;
|
6
website/node_modules/firebase-functions/lib/utils.d.ts
generated
vendored
Normal file
6
website/node_modules/firebase-functions/lib/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export declare function normalizePath(path: string): string;
|
||||
export declare function pathParts(path: string): string[];
|
||||
export declare function joinPath(base: string, child: string): string;
|
||||
export declare function applyChange(src: any, dest: any): any;
|
||||
export declare function pruneNulls(obj: any): any;
|
||||
export declare function valAt(source: any, path?: string): any;
|
97
website/node_modules/firebase-functions/lib/utils.js
generated
vendored
Normal file
97
website/node_modules/firebase-functions/lib/utils.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const _ = require("lodash");
|
||||
function normalizePath(path) {
|
||||
if (!path) {
|
||||
return '';
|
||||
}
|
||||
return path.replace(/^\//, '').replace(/\/$/, '');
|
||||
}
|
||||
exports.normalizePath = normalizePath;
|
||||
function pathParts(path) {
|
||||
if (!path || path === '' || path === '/') {
|
||||
return [];
|
||||
}
|
||||
return normalizePath(path).split('/');
|
||||
}
|
||||
exports.pathParts = pathParts;
|
||||
function joinPath(base, child) {
|
||||
return pathParts(base)
|
||||
.concat(pathParts(child))
|
||||
.join('/');
|
||||
}
|
||||
exports.joinPath = joinPath;
|
||||
function applyChange(src, dest) {
|
||||
// if not mergeable, don't merge
|
||||
if (!_.isPlainObject(dest) || !_.isPlainObject(src)) {
|
||||
return dest;
|
||||
}
|
||||
return pruneNulls(_.merge({}, src, dest));
|
||||
}
|
||||
exports.applyChange = applyChange;
|
||||
function pruneNulls(obj) {
|
||||
for (let key in obj) {
|
||||
if (obj[key] === null) {
|
||||
delete obj[key];
|
||||
}
|
||||
else if (_.isPlainObject(obj[key])) {
|
||||
pruneNulls(obj[key]);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
exports.pruneNulls = pruneNulls;
|
||||
function valAt(source, path) {
|
||||
if (source === null) {
|
||||
return null;
|
||||
}
|
||||
else if (typeof source !== 'object') {
|
||||
return path ? null : source;
|
||||
}
|
||||
let parts = pathParts(path);
|
||||
if (!parts.length) {
|
||||
return source;
|
||||
}
|
||||
let cur = source;
|
||||
let leaf;
|
||||
while (parts.length) {
|
||||
let key = parts.shift();
|
||||
if (cur[key] === null || leaf) {
|
||||
return null;
|
||||
}
|
||||
else if (typeof cur[key] === 'object') {
|
||||
if (parts.length) {
|
||||
cur = cur[key];
|
||||
}
|
||||
else {
|
||||
return cur[key];
|
||||
}
|
||||
}
|
||||
else {
|
||||
leaf = cur[key];
|
||||
}
|
||||
}
|
||||
return leaf;
|
||||
}
|
||||
exports.valAt = valAt;
|
97
website/node_modules/firebase-functions/package.json
generated
vendored
Normal file
97
website/node_modules/firebase-functions/package.json
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
{
|
||||
"_from": "firebase-functions@latest",
|
||||
"_id": "firebase-functions@2.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-gvWjfIu/q0jXSE/4JY+6XZyJWVzk0TeGLJAfKE4Y7W/cUxkycogc7EIBJSEMdHnxFAD3GE6VgCrhtTTmUud6Sw==",
|
||||
"_location": "/firebase-functions",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "firebase-functions@latest",
|
||||
"name": "firebase-functions",
|
||||
"escapedName": "firebase-functions",
|
||||
"rawSpec": "latest",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-2.1.0.tgz",
|
||||
"_shasum": "10973f9055092aaa8ed5bd26410426a9790a99ea",
|
||||
"_spec": "firebase-functions@latest",
|
||||
"_where": "C:\\Users\\jlevi\\Downloads\\tr2022-strategy-master\\tr2022-strategy-master\\data analysis",
|
||||
"author": {
|
||||
"name": "Firebase Team"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/firebase/firebase-functions/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@types/cors": "^2.8.1",
|
||||
"@types/express": "^4.11.1",
|
||||
"@types/jsonwebtoken": "^7.2.6",
|
||||
"@types/lodash": "^4.14.34",
|
||||
"cors": "^2.8.4",
|
||||
"express": "^4.16.2",
|
||||
"jsonwebtoken": "^8.2.1",
|
||||
"lodash": "^4.6.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Firebase SDK for Cloud Functions",
|
||||
"devDependencies": {
|
||||
"@types/chai": "^3.4.32",
|
||||
"@types/chai-as-promised": "0.0.28",
|
||||
"@types/mocha": "^5.2.5",
|
||||
"@types/mock-require": "^1.3.3",
|
||||
"@types/nock": "^0.54.32",
|
||||
"@types/node": "^6.0.38",
|
||||
"@types/sinon": "^1.16.29",
|
||||
"chai": "^3.5.0",
|
||||
"chai-as-promised": "^5.2.0",
|
||||
"firebase-admin": "~6.0.0",
|
||||
"istanbul": "^0.4.2",
|
||||
"mocha": "^5.2.0",
|
||||
"mock-require": "^2.0.1",
|
||||
"nock": "^9.0.0",
|
||||
"prettier": "^1.13.7",
|
||||
"sinon": "^1.17.4",
|
||||
"typescript": "~2.8.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/firebase/firebase-functions#readme",
|
||||
"keywords": [
|
||||
"firebase",
|
||||
"functions",
|
||||
"google",
|
||||
"cloud"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"name": "firebase-functions",
|
||||
"peerDependencies": {
|
||||
"firebase-admin": "~6.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/firebase/firebase-functions.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.release.json",
|
||||
"build:pack": "rm -rf lib && npm install && node_modules/.bin/tsc -p tsconfig.release.json && npm pack",
|
||||
"build:release": "npm install --production && npm install typescript firebase-admin && node_modules/.bin/tsc -p tsconfig.release.json",
|
||||
"format": "prettier --write '**/*.ts'",
|
||||
"mocha": "mocha .tmp/spec/index.spec.js",
|
||||
"postinstall": "node ./upgrade-warning",
|
||||
"posttest": "npm run format && rm -rf .tmp",
|
||||
"pretest": "tsc && cp -r spec/fixtures .tmp/spec",
|
||||
"test": "npm run mocha"
|
||||
},
|
||||
"typings": "lib/index.d.ts",
|
||||
"version": "2.1.0"
|
||||
}
|
15
website/node_modules/firebase-functions/upgrade-warning
generated
vendored
Normal file
15
website/node_modules/firebase-functions/upgrade-warning
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
const message = `
|
||||
======== WARNING! ========
|
||||
|
||||
This upgrade of firebase-functions contains breaking changes if you are upgrading from a version below v1.0.0.
|
||||
|
||||
To see a complete list of these breaking changes, please go to:
|
||||
|
||||
https://firebase.google.com/docs/functions/beta-v1-diff
|
||||
`;
|
||||
|
||||
console.log(message);
|
Reference in New Issue
Block a user