firebase-admin 9.3.0 → 9.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/auth/action-code-settings-builder.js +1 -1
- package/lib/auth/auth-api-request.js +98 -25
- package/lib/auth/auth-config.js +15 -15
- package/lib/auth/auth.js +82 -61
- package/lib/auth/identifier.js +3 -2
- package/lib/auth/index.d.ts +1868 -0
- package/lib/{credential/credential-interfaces.js → auth/index.js} +1 -1
- package/lib/auth/tenant-manager.js +1 -1
- package/lib/auth/tenant.js +7 -1
- package/lib/auth/token-generator.js +6 -4
- package/lib/auth/token-verifier.js +32 -36
- package/lib/auth/user-import-builder.js +18 -15
- package/lib/auth/user-record.js +4 -4
- package/lib/credential/credential-internal.js +1 -2
- package/lib/credential/credential.js +8 -122
- package/lib/credential/index.d.ts +169 -0
- package/lib/credential/index.js +5 -17
- package/lib/database/database-internal.js +19 -26
- package/lib/database/index.d.ts +89 -0
- package/lib/database/index.js +12 -28
- package/lib/default-namespace.js +2 -1
- package/lib/firebase-app.js +26 -48
- package/lib/firebase-namespace-api.d.ts +238 -0
- package/lib/{firebase-service.js → firebase-namespace-api.js} +2 -2
- package/lib/{database/database.js → firebase-namespace.d.ts} +14 -7
- package/lib/firebase-namespace.js +22 -92
- package/lib/firestore/firestore-internal.js +2 -19
- package/lib/firestore/index.d.ts +50 -0
- package/lib/firestore/index.js +28 -43
- package/lib/index.d.ts +3 -932
- package/lib/index.js +2 -1
- package/lib/instance-id/index.d.ts +81 -0
- package/lib/instance-id/index.js +1 -10
- package/lib/instance-id/instance-id-request-internal.js +2 -1
- package/lib/instance-id/instance-id.js +1 -19
- package/lib/machine-learning/index.d.ts +249 -0
- package/lib/{messaging/messaging-types.js → machine-learning/index.js} +2 -2
- package/lib/machine-learning/machine-learning-api-client.js +1 -1
- package/lib/machine-learning/machine-learning-utils.js +1 -1
- package/lib/machine-learning/machine-learning.js +3 -22
- package/lib/messaging/batch-request-internal.js +1 -1
- package/lib/messaging/index.d.ts +1174 -0
- package/lib/messaging/index.js +1 -24
- package/lib/messaging/messaging-api-request-internal.js +2 -1
- package/lib/messaging/messaging-errors-internal.js +1 -1
- package/lib/messaging/messaging-internal.js +1 -1
- package/lib/messaging/messaging.js +21 -25
- package/lib/project-management/android-app.js +7 -6
- package/lib/project-management/index.d.ts +363 -0
- package/lib/project-management/index.js +23 -25
- package/lib/project-management/ios-app.js +5 -4
- package/lib/project-management/project-management-api-request-internal.js +5 -5
- package/lib/project-management/project-management.js +9 -26
- package/lib/remote-config/index.d.ts +359 -0
- package/lib/remote-config/index.js +1 -26
- package/lib/remote-config/remote-config-api-client-internal.js +3 -3
- package/lib/remote-config/remote-config.js +15 -32
- package/lib/security-rules/index.d.ts +216 -0
- package/lib/security-rules/index.js +1 -24
- package/lib/security-rules/security-rules-api-client-internal.js +1 -1
- package/lib/security-rules/security-rules-internal.js +1 -1
- package/lib/security-rules/security-rules.js +6 -15
- package/lib/storage/index.d.ts +60 -0
- package/lib/storage/index.js +1 -10
- package/lib/storage/storage.js +2 -19
- package/lib/utils/api-request.js +10 -3
- package/lib/utils/deep-copy.js +2 -1
- package/lib/utils/error.js +2 -1
- package/lib/utils/index.js +6 -5
- package/lib/utils/validator.js +2 -1
- package/package.json +15 -12
- package/lib/auth.d.ts +0 -2016
- package/lib/credential.d.ts +0 -150
- package/lib/database.d.ts +0 -1663
- package/lib/instance-id.d.ts +0 -37
- package/lib/messaging.d.ts +0 -1341
- package/lib/project-management/app-metadata.js +0 -37
- package/lib/project-management.d.ts +0 -361
- package/lib/remote-config/remote-config-api-client.js +0 -36
- package/lib/remote-config.d.ts +0 -350
- package/lib/security-rules.d.ts +0 -192
- package/lib/storage.d.ts +0 -40
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/*! firebase-admin v9.5.0 */
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2020 Google Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/// <reference types="node" />
|
|
18
|
+
import { Agent } from 'http';
|
|
19
|
+
import { auth } from './auth/index';
|
|
20
|
+
import { credential } from './credential/index';
|
|
21
|
+
import { database } from './database/index';
|
|
22
|
+
import { firestore } from './firestore/index';
|
|
23
|
+
import { instanceId } from './instance-id/index';
|
|
24
|
+
import { machineLearning } from './machine-learning/index';
|
|
25
|
+
import { messaging } from './messaging/index';
|
|
26
|
+
import { projectManagement } from './project-management/index';
|
|
27
|
+
import { remoteConfig } from './remote-config/index';
|
|
28
|
+
import { securityRules } from './security-rules/index';
|
|
29
|
+
import { storage } from './storage/index';
|
|
30
|
+
/**
|
|
31
|
+
* `FirebaseError` is a subclass of the standard JavaScript `Error` object. In
|
|
32
|
+
* addition to a message string and stack trace, it contains a string code.
|
|
33
|
+
*/
|
|
34
|
+
export interface FirebaseError {
|
|
35
|
+
/**
|
|
36
|
+
* Error codes are strings using the following format: `"service/string-code"`.
|
|
37
|
+
* Some examples include `"auth/invalid-uid"` and
|
|
38
|
+
* `"messaging/invalid-recipient"`.
|
|
39
|
+
*
|
|
40
|
+
* While the message for a given error can change, the code will remain the same
|
|
41
|
+
* between backward-compatible versions of the Firebase SDK.
|
|
42
|
+
*/
|
|
43
|
+
code: string;
|
|
44
|
+
/**
|
|
45
|
+
* An explanatory message for the error that just occurred.
|
|
46
|
+
*
|
|
47
|
+
* This message is designed to be helpful to you, the developer. Because
|
|
48
|
+
* it generally does not convey meaningful information to end users,
|
|
49
|
+
* this message should not be displayed in your application.
|
|
50
|
+
*/
|
|
51
|
+
message: string;
|
|
52
|
+
/**
|
|
53
|
+
* A string value containing the execution backtrace when the error originally
|
|
54
|
+
* occurred.
|
|
55
|
+
*
|
|
56
|
+
* This information can be useful to you and can be sent to
|
|
57
|
+
* {@link https://firebase.google.com/support/ Firebase Support} to help
|
|
58
|
+
* explain the cause of an error.
|
|
59
|
+
*/
|
|
60
|
+
stack?: string;
|
|
61
|
+
/**
|
|
62
|
+
* @return A JSON-serializable representation of this object.
|
|
63
|
+
*/
|
|
64
|
+
toJSON(): object;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Composite type which includes both a `FirebaseError` object and an index
|
|
68
|
+
* which can be used to get the errored item.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```javascript
|
|
72
|
+
* var registrationTokens = [token1, token2, token3];
|
|
73
|
+
* admin.messaging().subscribeToTopic(registrationTokens, 'topic-name')
|
|
74
|
+
* .then(function(response) {
|
|
75
|
+
* if (response.failureCount > 0) {
|
|
76
|
+
* console.log("Following devices unsucessfully subscribed to topic:");
|
|
77
|
+
* response.errors.forEach(function(error) {
|
|
78
|
+
* var invalidToken = registrationTokens[error.index];
|
|
79
|
+
* console.log(invalidToken, error.error);
|
|
80
|
+
* });
|
|
81
|
+
* } else {
|
|
82
|
+
* console.log("All devices successfully subscribed to topic:", response);
|
|
83
|
+
* }
|
|
84
|
+
* })
|
|
85
|
+
* .catch(function(error) {
|
|
86
|
+
* console.log("Error subscribing to topic:", error);
|
|
87
|
+
* });
|
|
88
|
+
*```
|
|
89
|
+
*/
|
|
90
|
+
export interface FirebaseArrayIndexError {
|
|
91
|
+
/**
|
|
92
|
+
* The index of the errored item within the original array passed as part of the
|
|
93
|
+
* called API method.
|
|
94
|
+
*/
|
|
95
|
+
index: number;
|
|
96
|
+
/**
|
|
97
|
+
* The error object.
|
|
98
|
+
*/
|
|
99
|
+
error: FirebaseError;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Available options to pass to [`initializeApp()`](admin#.initializeApp).
|
|
103
|
+
*/
|
|
104
|
+
export interface AppOptions {
|
|
105
|
+
/**
|
|
106
|
+
* A {@link credential.Credential `Credential`} object used to
|
|
107
|
+
* authenticate the Admin SDK.
|
|
108
|
+
*
|
|
109
|
+
* See [Initialize the SDK](/docs/admin/setup#initialize_the_sdk) for detailed
|
|
110
|
+
* documentation and code samples.
|
|
111
|
+
*/
|
|
112
|
+
credential?: credential.Credential;
|
|
113
|
+
/**
|
|
114
|
+
* The object to use as the [`auth`](/docs/reference/security/database/#auth)
|
|
115
|
+
* variable in your Realtime Database Rules when the Admin SDK reads from or
|
|
116
|
+
* writes to the Realtime Database. This allows you to downscope the Admin SDK
|
|
117
|
+
* from its default full read and write privileges.
|
|
118
|
+
*
|
|
119
|
+
* You can pass `null` to act as an unauthenticated client.
|
|
120
|
+
*
|
|
121
|
+
* See
|
|
122
|
+
* [Authenticate with limited privileges](/docs/database/admin/start#authenticate-with-limited-privileges)
|
|
123
|
+
* for detailed documentation and code samples.
|
|
124
|
+
*/
|
|
125
|
+
databaseAuthVariableOverride?: object | null;
|
|
126
|
+
/**
|
|
127
|
+
* The URL of the Realtime Database from which to read and write data.
|
|
128
|
+
*/
|
|
129
|
+
databaseURL?: string;
|
|
130
|
+
/**
|
|
131
|
+
* The ID of the service account to be used for signing custom tokens. This
|
|
132
|
+
* can be found in the `client_email` field of a service account JSON file.
|
|
133
|
+
*/
|
|
134
|
+
serviceAccountId?: string;
|
|
135
|
+
/**
|
|
136
|
+
* The name of the Google Cloud Storage bucket used for storing application data.
|
|
137
|
+
* Use only the bucket name without any prefixes or additions (do *not* prefix
|
|
138
|
+
* the name with "gs://").
|
|
139
|
+
*/
|
|
140
|
+
storageBucket?: string;
|
|
141
|
+
/**
|
|
142
|
+
* The ID of the Google Cloud project associated with the App.
|
|
143
|
+
*/
|
|
144
|
+
projectId?: string;
|
|
145
|
+
/**
|
|
146
|
+
* An [HTTP Agent](https://nodejs.org/api/http.html#http_class_http_agent)
|
|
147
|
+
* to be used when making outgoing HTTP calls. This Agent instance is used
|
|
148
|
+
* by all services that make REST calls (e.g. `auth`, `messaging`,
|
|
149
|
+
* `projectManagement`).
|
|
150
|
+
*
|
|
151
|
+
* Realtime Database and Firestore use other means of communicating with
|
|
152
|
+
* the backend servers, so they do not use this HTTP Agent. `Credential`
|
|
153
|
+
* instances also do not use this HTTP Agent, but instead support
|
|
154
|
+
* specifying an HTTP Agent in the corresponding factory methods.
|
|
155
|
+
*/
|
|
156
|
+
httpAgent?: Agent;
|
|
157
|
+
}
|
|
158
|
+
export declare namespace app {
|
|
159
|
+
/**
|
|
160
|
+
* A Firebase app holds the initialization information for a collection of
|
|
161
|
+
* services.
|
|
162
|
+
*
|
|
163
|
+
* Do not call this constructor directly. Instead, use
|
|
164
|
+
* {@link
|
|
165
|
+
* https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp
|
|
166
|
+
* `admin.initializeApp()`}
|
|
167
|
+
* to create an app.
|
|
168
|
+
*/
|
|
169
|
+
interface App {
|
|
170
|
+
/**
|
|
171
|
+
* The (read-only) name for this app.
|
|
172
|
+
*
|
|
173
|
+
* The default app's name is `"[DEFAULT]"`.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```javascript
|
|
177
|
+
* // The default app's name is "[DEFAULT]"
|
|
178
|
+
* admin.initializeApp(defaultAppConfig);
|
|
179
|
+
* console.log(admin.app().name); // "[DEFAULT]"
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```javascript
|
|
184
|
+
* // A named app's name is what you provide to initializeApp()
|
|
185
|
+
* var otherApp = admin.initializeApp(otherAppConfig, "other");
|
|
186
|
+
* console.log(otherApp.name); // "other"
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
name: string;
|
|
190
|
+
/**
|
|
191
|
+
* The (read-only) configuration options for this app. These are the original
|
|
192
|
+
* parameters given in
|
|
193
|
+
* {@link
|
|
194
|
+
* https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp
|
|
195
|
+
* `admin.initializeApp()`}.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```javascript
|
|
199
|
+
* var app = admin.initializeApp(config);
|
|
200
|
+
* console.log(app.options.credential === config.credential); // true
|
|
201
|
+
* console.log(app.options.databaseURL === config.databaseURL); // true
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
options: AppOptions;
|
|
205
|
+
auth(): auth.Auth;
|
|
206
|
+
database(url?: string): database.Database;
|
|
207
|
+
firestore(): firestore.Firestore;
|
|
208
|
+
instanceId(): instanceId.InstanceId;
|
|
209
|
+
machineLearning(): machineLearning.MachineLearning;
|
|
210
|
+
messaging(): messaging.Messaging;
|
|
211
|
+
projectManagement(): projectManagement.ProjectManagement;
|
|
212
|
+
remoteConfig(): remoteConfig.RemoteConfig;
|
|
213
|
+
securityRules(): securityRules.SecurityRules;
|
|
214
|
+
storage(): storage.Storage;
|
|
215
|
+
/**
|
|
216
|
+
* Renders this local `FirebaseApp` unusable and frees the resources of
|
|
217
|
+
* all associated services (though it does *not* clean up any backend
|
|
218
|
+
* resources). When running the SDK locally, this method
|
|
219
|
+
* must be called to ensure graceful termination of the process.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```javascript
|
|
223
|
+
* app.delete()
|
|
224
|
+
* .then(function() {
|
|
225
|
+
* console.log("App deleted successfully");
|
|
226
|
+
* })
|
|
227
|
+
* .catch(function(error) {
|
|
228
|
+
* console.log("Error deleting app:", error);
|
|
229
|
+
* });
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
delete(): Promise<void>;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
export declare const SDK_VERSION: string;
|
|
236
|
+
export declare const apps: (app.App | null)[];
|
|
237
|
+
export declare function app(name?: string): app.App;
|
|
238
|
+
export declare function initializeApp(options?: AppOptions, name?: string): app.App;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! firebase-admin v9.
|
|
1
|
+
/*! firebase-admin v9.5.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
|
-
* Copyright
|
|
4
|
+
* Copyright 2020 Google Inc.
|
|
5
5
|
*
|
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
* you may not use this file except in compliance with the License.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin v9.
|
|
2
|
-
"use strict";
|
|
1
|
+
/*! firebase-admin v9.5.0 */
|
|
3
2
|
/*!
|
|
4
3
|
* Copyright 2020 Google Inc.
|
|
5
4
|
*
|
|
@@ -15,8 +14,16 @@
|
|
|
15
14
|
* See the License for the specific language governing permissions and
|
|
16
15
|
* limitations under the License.
|
|
17
16
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
|
|
18
|
+
export * from './credential/index';
|
|
19
|
+
export * from './firebase-namespace-api';
|
|
20
|
+
export * from './auth/index';
|
|
21
|
+
export * from './database/index';
|
|
22
|
+
export * from './firestore/index';
|
|
23
|
+
export * from './instance-id/index';
|
|
24
|
+
export * from './machine-learning/index';
|
|
25
|
+
export * from './messaging/index';
|
|
26
|
+
export * from './project-management/index';
|
|
27
|
+
export * from './remote-config/index';
|
|
28
|
+
export * from './security-rules/index';
|
|
29
|
+
export * from './storage/index';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/*! firebase-admin v9.
|
|
1
|
+
/*! firebase-admin v9.5.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
|
+
* @license
|
|
4
5
|
* Copyright 2017 Google Inc.
|
|
5
6
|
*
|
|
6
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -18,7 +19,6 @@
|
|
|
18
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
20
|
exports.FirebaseNamespace = exports.FirebaseNamespaceInternals = exports.FIREBASE_CONFIG_VAR = void 0;
|
|
20
21
|
var fs = require("fs");
|
|
21
|
-
var deep_copy_1 = require("./utils/deep-copy");
|
|
22
22
|
var error_1 = require("./utils/error");
|
|
23
23
|
var firebase_app_1 = require("./firebase-app");
|
|
24
24
|
var credential_1 = require("./credential/credential");
|
|
@@ -38,21 +38,18 @@ exports.FIREBASE_CONFIG_VAR = 'FIREBASE_CONFIG';
|
|
|
38
38
|
var FirebaseNamespaceInternals = /** @class */ (function () {
|
|
39
39
|
function FirebaseNamespaceInternals(firebase_) {
|
|
40
40
|
this.firebase_ = firebase_;
|
|
41
|
-
this.serviceFactories = {};
|
|
42
41
|
this.apps_ = {};
|
|
43
|
-
this.appHooks_ = {};
|
|
44
42
|
}
|
|
45
43
|
/**
|
|
46
|
-
* Initializes the
|
|
44
|
+
* Initializes the App instance.
|
|
47
45
|
*
|
|
48
|
-
* @param
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* @param {string} [appName] Optional name of the FirebaseApp instance.
|
|
46
|
+
* @param options Optional options for the App instance. If none present will try to initialize
|
|
47
|
+
* from the FIREBASE_CONFIG environment variable. If the environment variable contains a string
|
|
48
|
+
* that starts with '{' it will be parsed as JSON, otherwise it will be assumed to be pointing
|
|
49
|
+
* to a file.
|
|
50
|
+
* @param appName Optional name of the FirebaseApp instance.
|
|
54
51
|
*
|
|
55
|
-
* @return
|
|
52
|
+
* @return A new App instance.
|
|
56
53
|
*/
|
|
57
54
|
FirebaseNamespaceInternals.prototype.initializeApp = function (options, appName) {
|
|
58
55
|
if (appName === void 0) { appName = DEFAULT_APP_NAME; }
|
|
@@ -79,15 +76,14 @@ var FirebaseNamespaceInternals = /** @class */ (function () {
|
|
|
79
76
|
}
|
|
80
77
|
var app = new firebase_app_1.FirebaseApp(options, appName, this);
|
|
81
78
|
this.apps_[appName] = app;
|
|
82
|
-
this.callAppHooks_(app, 'create');
|
|
83
79
|
return app;
|
|
84
80
|
};
|
|
85
81
|
/**
|
|
86
|
-
* Returns the
|
|
82
|
+
* Returns the App instance with the provided name (or the default App instance
|
|
87
83
|
* if no name is provided).
|
|
88
84
|
*
|
|
89
|
-
* @param
|
|
90
|
-
* @return
|
|
85
|
+
* @param appName Optional name of the FirebaseApp instance to return.
|
|
86
|
+
* @return The App instance which has the provided name.
|
|
91
87
|
*/
|
|
92
88
|
FirebaseNamespaceInternals.prototype.app = function (appName) {
|
|
93
89
|
if (appName === void 0) { appName = DEFAULT_APP_NAME; }
|
|
@@ -104,9 +100,7 @@ var FirebaseNamespaceInternals = /** @class */ (function () {
|
|
|
104
100
|
};
|
|
105
101
|
Object.defineProperty(FirebaseNamespaceInternals.prototype, "apps", {
|
|
106
102
|
/*
|
|
107
|
-
* Returns an array of all the non-deleted
|
|
108
|
-
*
|
|
109
|
-
* @return {Array<FirebaseApp>} An array of all the non-deleted FirebaseApp instances
|
|
103
|
+
* Returns an array of all the non-deleted App instances.
|
|
110
104
|
*/
|
|
111
105
|
get: function () {
|
|
112
106
|
var _this = this;
|
|
@@ -117,77 +111,14 @@ var FirebaseNamespaceInternals = /** @class */ (function () {
|
|
|
117
111
|
configurable: true
|
|
118
112
|
});
|
|
119
113
|
/*
|
|
120
|
-
* Removes the specified
|
|
121
|
-
*
|
|
122
|
-
* @param {string} appName The name of the FirebaseApp instance to remove.
|
|
114
|
+
* Removes the specified App instance.
|
|
123
115
|
*/
|
|
124
116
|
FirebaseNamespaceInternals.prototype.removeApp = function (appName) {
|
|
125
117
|
if (typeof appName === 'undefined') {
|
|
126
|
-
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_NAME,
|
|
118
|
+
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_NAME, 'No Firebase app name provided. App name must be a non-empty string.');
|
|
127
119
|
}
|
|
128
120
|
var appToRemove = this.app(appName);
|
|
129
|
-
this.
|
|
130
|
-
delete this.apps_[appName];
|
|
131
|
-
};
|
|
132
|
-
/*
|
|
133
|
-
* Registers a new service on this Firebase namespace.
|
|
134
|
-
*
|
|
135
|
-
* @param {string} serviceName The name of the Firebase service to register.
|
|
136
|
-
* @param {FirebaseServiceFactory} createService A factory method to generate an instance of the Firebase service.
|
|
137
|
-
* @param {object} [serviceProperties] Optional properties to extend this Firebase namespace with.
|
|
138
|
-
* @param {AppHook} [appHook] Optional callback that handles app-related events like app creation and deletion.
|
|
139
|
-
* @return {FirebaseServiceNamespace<FirebaseServiceInterface>} The Firebase service's namespace.
|
|
140
|
-
*/
|
|
141
|
-
FirebaseNamespaceInternals.prototype.registerService = function (serviceName, createService, serviceProperties, appHook) {
|
|
142
|
-
var _this = this;
|
|
143
|
-
var errorMessage;
|
|
144
|
-
if (typeof serviceName === 'undefined') {
|
|
145
|
-
errorMessage = "No service name provided. Service name must be a non-empty string.";
|
|
146
|
-
}
|
|
147
|
-
else if (typeof serviceName !== 'string' || serviceName === '') {
|
|
148
|
-
errorMessage = "Invalid service name \"" + serviceName + "\" provided. Service name must be a non-empty string.";
|
|
149
|
-
}
|
|
150
|
-
else if (serviceName in this.serviceFactories) {
|
|
151
|
-
errorMessage = "Firebase service named \"" + serviceName + "\" has already been registered.";
|
|
152
|
-
}
|
|
153
|
-
if (typeof errorMessage !== 'undefined') {
|
|
154
|
-
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INTERNAL_ERROR, "INTERNAL ASSERT FAILED: " + errorMessage);
|
|
155
|
-
}
|
|
156
|
-
this.serviceFactories[serviceName] = createService;
|
|
157
|
-
if (appHook) {
|
|
158
|
-
this.appHooks_[serviceName] = appHook;
|
|
159
|
-
}
|
|
160
|
-
// The service namespace is an accessor function which takes a FirebaseApp instance
|
|
161
|
-
// or uses the default app if no FirebaseApp instance is provided
|
|
162
|
-
var serviceNamespace = function (appArg) {
|
|
163
|
-
if (typeof appArg === 'undefined') {
|
|
164
|
-
appArg = _this.app();
|
|
165
|
-
}
|
|
166
|
-
// Forward service instance lookup to the FirebaseApp
|
|
167
|
-
return appArg[serviceName]();
|
|
168
|
-
};
|
|
169
|
-
// ... and a container for service-level properties.
|
|
170
|
-
if (serviceProperties !== undefined) {
|
|
171
|
-
deep_copy_1.deepExtend(serviceNamespace, serviceProperties);
|
|
172
|
-
}
|
|
173
|
-
// Monkey-patch the service namespace onto the Firebase namespace
|
|
174
|
-
this.firebase_[serviceName] = serviceNamespace;
|
|
175
|
-
return serviceNamespace;
|
|
176
|
-
};
|
|
177
|
-
/**
|
|
178
|
-
* Calls the app hooks corresponding to the provided event name for each service within the
|
|
179
|
-
* provided FirebaseApp instance.
|
|
180
|
-
*
|
|
181
|
-
* @param {FirebaseApp} app The FirebaseApp instance whose app hooks to call.
|
|
182
|
-
* @param {string} eventName The event name representing which app hooks to call.
|
|
183
|
-
*/
|
|
184
|
-
FirebaseNamespaceInternals.prototype.callAppHooks_ = function (app, eventName) {
|
|
185
|
-
var _this = this;
|
|
186
|
-
Object.keys(this.serviceFactories).forEach(function (serviceName) {
|
|
187
|
-
if (_this.appHooks_[serviceName]) {
|
|
188
|
-
_this.appHooks_[serviceName](eventName, app);
|
|
189
|
-
}
|
|
190
|
-
});
|
|
121
|
+
delete this.apps_[appToRemove.name];
|
|
191
122
|
};
|
|
192
123
|
/**
|
|
193
124
|
* Parse the file pointed to by the FIREBASE_CONFIG_VAR, if it exists.
|
|
@@ -408,16 +339,17 @@ var FirebaseNamespace = /** @class */ (function () {
|
|
|
408
339
|
enumerable: false,
|
|
409
340
|
configurable: true
|
|
410
341
|
});
|
|
342
|
+
// TODO: Change the return types to app.App in the following methods.
|
|
411
343
|
/**
|
|
412
344
|
* Initializes the FirebaseApp instance.
|
|
413
345
|
*
|
|
414
|
-
* @param
|
|
346
|
+
* @param options Optional options for the FirebaseApp instance.
|
|
415
347
|
* If none present will try to initialize from the FIREBASE_CONFIG environment variable.
|
|
416
348
|
* If the environment variable contains a string that starts with '{' it will be parsed as JSON,
|
|
417
349
|
* otherwise it will be assumed to be pointing to a file.
|
|
418
|
-
* @param
|
|
350
|
+
* @param appName Optional name of the FirebaseApp instance.
|
|
419
351
|
*
|
|
420
|
-
* @return
|
|
352
|
+
* @return A new FirebaseApp instance.
|
|
421
353
|
*/
|
|
422
354
|
FirebaseNamespace.prototype.initializeApp = function (options, appName) {
|
|
423
355
|
return this.INTERNAL.initializeApp(options, appName);
|
|
@@ -426,8 +358,8 @@ var FirebaseNamespace = /** @class */ (function () {
|
|
|
426
358
|
* Returns the FirebaseApp instance with the provided name (or the default FirebaseApp instance
|
|
427
359
|
* if no name is provided).
|
|
428
360
|
*
|
|
429
|
-
* @param
|
|
430
|
-
* @return
|
|
361
|
+
* @param appName Optional name of the FirebaseApp instance to return.
|
|
362
|
+
* @return The FirebaseApp instance which has the provided name.
|
|
431
363
|
*/
|
|
432
364
|
FirebaseNamespace.prototype.app = function (appName) {
|
|
433
365
|
return this.INTERNAL.app(appName);
|
|
@@ -435,8 +367,6 @@ var FirebaseNamespace = /** @class */ (function () {
|
|
|
435
367
|
Object.defineProperty(FirebaseNamespace.prototype, "apps", {
|
|
436
368
|
/*
|
|
437
369
|
* Returns an array of all the non-deleted FirebaseApp instances.
|
|
438
|
-
*
|
|
439
|
-
* @return {Array<FirebaseApp>} An array of all the non-deleted FirebaseApp instances
|
|
440
370
|
*/
|
|
441
371
|
get: function () {
|
|
442
372
|
return this.INTERNAL.apps;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/*! firebase-admin v9.
|
|
1
|
+
/*! firebase-admin v9.5.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
|
+
* @license
|
|
4
5
|
* Copyright 2017 Google Inc.
|
|
5
6
|
*
|
|
6
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -21,26 +22,8 @@ var error_1 = require("../utils/error");
|
|
|
21
22
|
var credential_internal_1 = require("../credential/credential-internal");
|
|
22
23
|
var validator = require("../utils/validator");
|
|
23
24
|
var utils = require("../utils/index");
|
|
24
|
-
/**
|
|
25
|
-
* Internals of a Firestore instance.
|
|
26
|
-
*/
|
|
27
|
-
var FirestoreInternals = /** @class */ (function () {
|
|
28
|
-
function FirestoreInternals() {
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Deletes the service and its associated resources.
|
|
32
|
-
*
|
|
33
|
-
* @return {Promise<()>} An empty Promise that will be fulfilled when the service is deleted.
|
|
34
|
-
*/
|
|
35
|
-
FirestoreInternals.prototype.delete = function () {
|
|
36
|
-
// There are no resources to clean up.
|
|
37
|
-
return Promise.resolve();
|
|
38
|
-
};
|
|
39
|
-
return FirestoreInternals;
|
|
40
|
-
}());
|
|
41
25
|
var FirestoreService = /** @class */ (function () {
|
|
42
26
|
function FirestoreService(app) {
|
|
43
|
-
this.INTERNAL = new FirestoreInternals();
|
|
44
27
|
this.firestoreClient = initFirestore(app);
|
|
45
28
|
this.appInternal = app;
|
|
46
29
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*! firebase-admin v9.5.0 */
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2020 Google Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { app } from '../firebase-namespace-api';
|
|
18
|
+
import * as _firestore from '@google-cloud/firestore';
|
|
19
|
+
export declare function firestore(app?: app.App): _firestore.Firestore;
|
|
20
|
+
export declare namespace firestore {
|
|
21
|
+
export import v1beta1 = _firestore.v1beta1;
|
|
22
|
+
export import v1 = _firestore.v1;
|
|
23
|
+
export import BulkWriter = _firestore.BulkWriter;
|
|
24
|
+
export import BulkWriterOptions = _firestore.BulkWriterOptions;
|
|
25
|
+
export import CollectionGroup = _firestore.CollectionGroup;
|
|
26
|
+
export import CollectionReference = _firestore.CollectionReference;
|
|
27
|
+
export import DocumentChangeType = _firestore.DocumentChangeType;
|
|
28
|
+
export import DocumentData = _firestore.DocumentData;
|
|
29
|
+
export import DocumentReference = _firestore.DocumentReference;
|
|
30
|
+
export import DocumentSnapshot = _firestore.DocumentSnapshot;
|
|
31
|
+
export import FieldPath = _firestore.FieldPath;
|
|
32
|
+
export import FieldValue = _firestore.FieldValue;
|
|
33
|
+
export import Firestore = _firestore.Firestore;
|
|
34
|
+
export import FirestoreDataConverter = _firestore.FirestoreDataConverter;
|
|
35
|
+
export import GeoPoint = _firestore.GeoPoint;
|
|
36
|
+
export import GrpcStatus = _firestore.GrpcStatus;
|
|
37
|
+
export import Precondition = _firestore.Precondition;
|
|
38
|
+
export import Query = _firestore.Query;
|
|
39
|
+
export import QueryDocumentSnapshot = _firestore.QueryDocumentSnapshot;
|
|
40
|
+
export import QueryPartition = _firestore.QueryPartition;
|
|
41
|
+
export import QuerySnapshot = _firestore.QuerySnapshot;
|
|
42
|
+
export import ReadOptions = _firestore.ReadOptions;
|
|
43
|
+
export import Settings = _firestore.Settings;
|
|
44
|
+
export import Timestamp = _firestore.Timestamp;
|
|
45
|
+
export import Transaction = _firestore.Transaction;
|
|
46
|
+
export import UpdateData = _firestore.UpdateData;
|
|
47
|
+
export import WriteBatch = _firestore.WriteBatch;
|
|
48
|
+
export import WriteResult = _firestore.WriteResult;
|
|
49
|
+
export import setLogFunction = _firestore.setLogFunction;
|
|
50
|
+
}
|
package/lib/firestore/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin v9.
|
|
1
|
+
/*! firebase-admin v9.5.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* Copyright 2020 Google Inc.
|
|
@@ -16,47 +16,32 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.
|
|
19
|
+
exports.firestore = void 0;
|
|
20
20
|
var _firestore = require("@google-cloud/firestore");
|
|
21
|
-
var firebaseAdmin = require("../index");
|
|
22
|
-
function firestore(app) {
|
|
23
|
-
if (typeof (app) === 'undefined') {
|
|
24
|
-
app = firebaseAdmin.app();
|
|
25
|
-
}
|
|
26
|
-
return app.firestore();
|
|
27
|
-
}
|
|
28
|
-
exports.firestore = firestore;
|
|
29
|
-
/**
|
|
30
|
-
* We must define a namespace to make the typings work correctly. Otherwise
|
|
31
|
-
* `admin.firestore()` cannot be called like a function. Temporarily,
|
|
32
|
-
* admin.firestore is used as the namespace name because we cannot barrel
|
|
33
|
-
* re-export the contents from firestore, and we want it to
|
|
34
|
-
* match the namespacing in the re-export inside src/index.d.ts
|
|
35
|
-
*/
|
|
36
21
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
37
|
-
var
|
|
38
|
-
(function (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
})(
|
|
22
|
+
var firestore;
|
|
23
|
+
(function (firestore) {
|
|
24
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
25
|
+
// See https://github.com/typescript-eslint/typescript-eslint/issues/363
|
|
26
|
+
firestore.v1beta1 = _firestore.v1beta1;
|
|
27
|
+
firestore.v1 = _firestore.v1;
|
|
28
|
+
firestore.BulkWriter = _firestore.BulkWriter;
|
|
29
|
+
firestore.CollectionGroup = _firestore.CollectionGroup;
|
|
30
|
+
firestore.CollectionReference = _firestore.CollectionReference;
|
|
31
|
+
firestore.DocumentReference = _firestore.DocumentReference;
|
|
32
|
+
firestore.DocumentSnapshot = _firestore.DocumentSnapshot;
|
|
33
|
+
firestore.FieldPath = _firestore.FieldPath;
|
|
34
|
+
firestore.FieldValue = _firestore.FieldValue;
|
|
35
|
+
firestore.Firestore = _firestore.Firestore;
|
|
36
|
+
firestore.GeoPoint = _firestore.GeoPoint;
|
|
37
|
+
firestore.GrpcStatus = _firestore.GrpcStatus;
|
|
38
|
+
firestore.Query = _firestore.Query;
|
|
39
|
+
firestore.QueryDocumentSnapshot = _firestore.QueryDocumentSnapshot;
|
|
40
|
+
firestore.QueryPartition = _firestore.QueryPartition;
|
|
41
|
+
firestore.QuerySnapshot = _firestore.QuerySnapshot;
|
|
42
|
+
firestore.Timestamp = _firestore.Timestamp;
|
|
43
|
+
firestore.Transaction = _firestore.Transaction;
|
|
44
|
+
firestore.WriteBatch = _firestore.WriteBatch;
|
|
45
|
+
firestore.WriteResult = _firestore.WriteResult;
|
|
46
|
+
firestore.setLogFunction = _firestore.setLogFunction;
|
|
47
|
+
})(firestore = exports.firestore || (exports.firestore = {}));
|