Initial commit

This commit is contained in:
talksik
2021-12-29 01:57:42 -08:00
commit ce39a60b42
4634 changed files with 997667 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
/*! firebase-admin v10.0.1 */
/*!
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Firestore, Settings } from '@google-cloud/firestore';
import { App } from '../app';
export declare class FirestoreService {
private appInternal;
private firestoreClient;
constructor(app: App);
/**
* Returns the app associated with this Storage instance.
*
* @returns The app associated with this Storage instance.
*/
get app(): App;
get client(): Firestore;
}
export declare function getFirestoreOptions(app: App): Settings;
+105
View File
@@ -0,0 +1,105 @@
/*! firebase-admin v10.0.1 */
"use strict";
/*!
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFirestoreOptions = exports.FirestoreService = void 0;
var error_1 = require("../utils/error");
var credential_internal_1 = require("../app/credential-internal");
var validator = require("../utils/validator");
var utils = require("../utils/index");
var FirestoreService = /** @class */ (function () {
function FirestoreService(app) {
this.firestoreClient = initFirestore(app);
this.appInternal = app;
}
Object.defineProperty(FirestoreService.prototype, "app", {
/**
* Returns the app associated with this Storage instance.
*
* @returns The app associated with this Storage instance.
*/
get: function () {
return this.appInternal;
},
enumerable: false,
configurable: true
});
Object.defineProperty(FirestoreService.prototype, "client", {
get: function () {
return this.firestoreClient;
},
enumerable: false,
configurable: true
});
return FirestoreService;
}());
exports.FirestoreService = FirestoreService;
function getFirestoreOptions(app) {
if (!validator.isNonNullObject(app) || !('options' in app)) {
throw new error_1.FirebaseFirestoreError({
code: 'invalid-argument',
message: 'First argument passed to admin.firestore() must be a valid Firebase app instance.',
});
}
var projectId = utils.getExplicitProjectId(app);
var credential = app.options.credential;
// eslint-disable-next-line @typescript-eslint/no-var-requires
var firebaseVersion = require('../../package.json').version;
if (credential instanceof credential_internal_1.ServiceAccountCredential) {
return {
credentials: {
private_key: credential.privateKey,
client_email: credential.clientEmail,
},
// When the SDK is initialized with ServiceAccountCredentials an explicit projectId is
// guaranteed to be available.
projectId: projectId,
firebaseVersion: firebaseVersion,
};
}
else if (credential_internal_1.isApplicationDefault(app.options.credential)) {
// Try to use the Google application default credentials.
// If an explicit project ID is not available, let Firestore client discover one from the
// environment. This prevents the users from having to set GOOGLE_CLOUD_PROJECT in GCP runtimes.
return validator.isNonEmptyString(projectId) ? { projectId: projectId, firebaseVersion: firebaseVersion } : { firebaseVersion: firebaseVersion };
}
throw new error_1.FirebaseFirestoreError({
code: 'invalid-credential',
message: 'Failed to initialize Google Cloud Firestore client with the available credentials. ' +
'Must initialize the SDK with a certificate credential or application default credentials ' +
'to use Cloud Firestore API.',
});
}
exports.getFirestoreOptions = getFirestoreOptions;
function initFirestore(app) {
var options = getFirestoreOptions(app);
var firestoreDatabase;
try {
// Lazy-load the Firestore implementation here, which in turns loads gRPC.
firestoreDatabase = require('@google-cloud/firestore').Firestore;
}
catch (err) {
throw new error_1.FirebaseFirestoreError({
code: 'missing-dependencies',
message: 'Failed to import the Cloud Firestore client library for Node.js. '
+ 'Make sure to install the "@google-cloud/firestore" npm package. '
+ ("Original error: " + err),
});
}
return new firestoreDatabase(options);
}
+55
View File
@@ -0,0 +1,55 @@
/*! firebase-admin v10.0.1 */
/*!
* Copyright 2021 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as _firestore from '@google-cloud/firestore';
import { App } from '../app';
export declare function firestore(app?: App): _firestore.Firestore;
export declare namespace firestore {
export import v1beta1 = _firestore.v1beta1;
export import v1 = _firestore.v1;
export import BulkWriter = _firestore.BulkWriter;
export import BulkWriterOptions = _firestore.BulkWriterOptions;
export import BundleBuilder = _firestore.BundleBuilder;
export import CollectionGroup = _firestore.CollectionGroup;
export import CollectionReference = _firestore.CollectionReference;
export import DocumentChange = _firestore.DocumentChange;
export import DocumentChangeType = _firestore.DocumentChangeType;
export import DocumentData = _firestore.DocumentData;
export import DocumentReference = _firestore.DocumentReference;
export import DocumentSnapshot = _firestore.DocumentSnapshot;
export import FieldPath = _firestore.FieldPath;
export import FieldValue = _firestore.FieldValue;
export import Firestore = _firestore.Firestore;
export import FirestoreDataConverter = _firestore.FirestoreDataConverter;
export import GeoPoint = _firestore.GeoPoint;
export import GrpcStatus = _firestore.GrpcStatus;
export import OrderByDirection = _firestore.OrderByDirection;
export import Precondition = _firestore.Precondition;
export import Query = _firestore.Query;
export import QueryDocumentSnapshot = _firestore.QueryDocumentSnapshot;
export import QueryPartition = _firestore.QueryPartition;
export import QuerySnapshot = _firestore.QuerySnapshot;
export import ReadOptions = _firestore.ReadOptions;
export import Settings = _firestore.Settings;
export import SetOptions = _firestore.SetOptions;
export import Timestamp = _firestore.Timestamp;
export import Transaction = _firestore.Transaction;
export import UpdateData = _firestore.UpdateData;
export import WhereFilterOp = _firestore.WhereFilterOp;
export import WriteBatch = _firestore.WriteBatch;
export import WriteResult = _firestore.WriteResult;
export import setLogFunction = _firestore.setLogFunction;
}
+48
View File
@@ -0,0 +1,48 @@
/*! firebase-admin v10.0.1 */
"use strict";
/*!
* Copyright 2021 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.firestore = void 0;
var _firestore = require("@google-cloud/firestore");
/* eslint-disable @typescript-eslint/no-namespace */
var firestore;
(function (firestore) {
/* eslint-disable @typescript-eslint/no-unused-vars */
// See https://github.com/typescript-eslint/typescript-eslint/issues/363
firestore.v1beta1 = _firestore.v1beta1;
firestore.v1 = _firestore.v1;
firestore.BulkWriter = _firestore.BulkWriter;
firestore.BundleBuilder = _firestore.BundleBuilder;
firestore.CollectionGroup = _firestore.CollectionGroup;
firestore.CollectionReference = _firestore.CollectionReference;
firestore.DocumentReference = _firestore.DocumentReference;
firestore.DocumentSnapshot = _firestore.DocumentSnapshot;
firestore.FieldPath = _firestore.FieldPath;
firestore.FieldValue = _firestore.FieldValue;
firestore.Firestore = _firestore.Firestore;
firestore.GeoPoint = _firestore.GeoPoint;
firestore.GrpcStatus = _firestore.GrpcStatus;
firestore.Query = _firestore.Query;
firestore.QueryDocumentSnapshot = _firestore.QueryDocumentSnapshot;
firestore.QueryPartition = _firestore.QueryPartition;
firestore.QuerySnapshot = _firestore.QuerySnapshot;
firestore.Timestamp = _firestore.Timestamp;
firestore.Transaction = _firestore.Transaction;
firestore.WriteBatch = _firestore.WriteBatch;
firestore.WriteResult = _firestore.WriteResult;
firestore.setLogFunction = _firestore.setLogFunction;
})(firestore = exports.firestore || (exports.firestore = {}));
+52
View File
@@ -0,0 +1,52 @@
/*! firebase-admin v10.0.1 */
/*!
* Copyright 2020 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Cloud Firestore.
*
* @packageDocumentation
*/
import { Firestore } from '@google-cloud/firestore';
import { App } from '../app';
export { BulkWriter, BulkWriterOptions, BundleBuilder, CollectionGroup, CollectionReference, DocumentChange, DocumentChangeType, DocumentData, DocumentReference, DocumentSnapshot, FieldPath, FieldValue, Firestore, FirestoreDataConverter, GeoPoint, GrpcStatus, OrderByDirection, Precondition, Query, QueryDocumentSnapshot, QueryPartition, QuerySnapshot, ReadOptions, Settings, SetOptions, Timestamp, Transaction, UpdateData, WhereFilterOp, WriteBatch, WriteResult, v1, setLogFunction, } from '@google-cloud/firestore';
/**
* Gets the {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore}
* service for the default app or a given app.
*
* `getFirestore()` can be called with no arguments to access the default
* app's `Firestore` service or as `getFirestore(app)` to access the
* `Firestore` service associated with a specific app.
*
* @example
* ```javascript
* // Get the Firestore service for the default app
* const defaultFirestore = getFirestore();
* ```
*
* @example
* ```javascript
* // Get the Firestore service for a specific app
* const otherFirestore = getFirestore(app);
* ```
*
* @param App - whose `Firestore` service to
* return. If not provided, the default `Firestore` service will be returned.
*
* @returns The default {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore}
* service if no app is provided or the `Firestore` service associated with the
* provided app.
*/
export declare function getFirestore(app?: App): Firestore;
+79
View File
@@ -0,0 +1,79 @@
/*! firebase-admin v10.0.1 */
"use strict";
/*!
* Copyright 2020 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFirestore = void 0;
var app_1 = require("../app");
var firestore_internal_1 = require("./firestore-internal");
var firestore_1 = require("@google-cloud/firestore");
Object.defineProperty(exports, "BulkWriter", { enumerable: true, get: function () { return firestore_1.BulkWriter; } });
Object.defineProperty(exports, "BundleBuilder", { enumerable: true, get: function () { return firestore_1.BundleBuilder; } });
Object.defineProperty(exports, "CollectionGroup", { enumerable: true, get: function () { return firestore_1.CollectionGroup; } });
Object.defineProperty(exports, "CollectionReference", { enumerable: true, get: function () { return firestore_1.CollectionReference; } });
Object.defineProperty(exports, "DocumentReference", { enumerable: true, get: function () { return firestore_1.DocumentReference; } });
Object.defineProperty(exports, "DocumentSnapshot", { enumerable: true, get: function () { return firestore_1.DocumentSnapshot; } });
Object.defineProperty(exports, "FieldPath", { enumerable: true, get: function () { return firestore_1.FieldPath; } });
Object.defineProperty(exports, "FieldValue", { enumerable: true, get: function () { return firestore_1.FieldValue; } });
Object.defineProperty(exports, "Firestore", { enumerable: true, get: function () { return firestore_1.Firestore; } });
Object.defineProperty(exports, "GeoPoint", { enumerable: true, get: function () { return firestore_1.GeoPoint; } });
Object.defineProperty(exports, "GrpcStatus", { enumerable: true, get: function () { return firestore_1.GrpcStatus; } });
Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return firestore_1.Query; } });
Object.defineProperty(exports, "QueryDocumentSnapshot", { enumerable: true, get: function () { return firestore_1.QueryDocumentSnapshot; } });
Object.defineProperty(exports, "QueryPartition", { enumerable: true, get: function () { return firestore_1.QueryPartition; } });
Object.defineProperty(exports, "QuerySnapshot", { enumerable: true, get: function () { return firestore_1.QuerySnapshot; } });
Object.defineProperty(exports, "Timestamp", { enumerable: true, get: function () { return firestore_1.Timestamp; } });
Object.defineProperty(exports, "Transaction", { enumerable: true, get: function () { return firestore_1.Transaction; } });
Object.defineProperty(exports, "WriteBatch", { enumerable: true, get: function () { return firestore_1.WriteBatch; } });
Object.defineProperty(exports, "WriteResult", { enumerable: true, get: function () { return firestore_1.WriteResult; } });
Object.defineProperty(exports, "v1", { enumerable: true, get: function () { return firestore_1.v1; } });
Object.defineProperty(exports, "setLogFunction", { enumerable: true, get: function () { return firestore_1.setLogFunction; } });
/**
* Gets the {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore}
* service for the default app or a given app.
*
* `getFirestore()` can be called with no arguments to access the default
* app's `Firestore` service or as `getFirestore(app)` to access the
* `Firestore` service associated with a specific app.
*
* @example
* ```javascript
* // Get the Firestore service for the default app
* const defaultFirestore = getFirestore();
* ```
*
* @example
* ```javascript
* // Get the Firestore service for a specific app
* const otherFirestore = getFirestore(app);
* ```
*
* @param App - whose `Firestore` service to
* return. If not provided, the default `Firestore` service will be returned.
*
* @returns The default {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore}
* service if no app is provided or the `Firestore` service associated with the
* provided app.
*/
function getFirestore(app) {
if (typeof app === 'undefined') {
app = app_1.getApp();
}
var firebaseApp = app;
var firestoreService = firebaseApp.getOrInitService('firestore', function (app) { return new firestore_internal_1.FirestoreService(app); });
return firestoreService.client;
}
exports.getFirestore = getFirestore;