Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions etc/firebase-admin.app.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ export interface Credential {
// @public (undocumented)
export function deleteApp(app: App): Promise<void>;

// @public
export interface FirebaseArrayIndexError {
error: FirebaseError;
index: number;
}

// @public
export interface FirebaseError {
code: string;
message: string;
stack?: string;
toJSON(): object;
}

// @public (undocumented)
export function getApp(name?: string): App;

Expand Down
79 changes: 79 additions & 0 deletions src/app/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,82 @@ export interface App {
*/
options: AppOptions;
}

/**
* `FirebaseError` is a subclass of the standard JavaScript `Error` object. In
* addition to a message string and stack trace, it contains a string code.
*/
export interface FirebaseError {

/**
* Error codes are strings using the following format: `"service/string-code"`.
* Some examples include `"auth/invalid-uid"` and
* `"messaging/invalid-recipient"`.
*
* While the message for a given error can change, the code will remain the same
* between backward-compatible versions of the Firebase SDK.
*/
code: string;

/**
* An explanatory message for the error that just occurred.
*
* This message is designed to be helpful to you, the developer. Because
* it generally does not convey meaningful information to end users,
* this message should not be displayed in your application.
*/
message: string;

/**
* A string value containing the execution backtrace when the error originally
* occurred.
*
* This information can be useful to you and can be sent to
* {@link https://firebase.google.com/support/ Firebase Support} to help
* explain the cause of an error.
*/
stack?: string;

/**
* @return A JSON-serializable representation of this object.
*/
toJSON(): object;
}

/**
* Composite type which includes both a `FirebaseError` object and an index
* which can be used to get the errored item.
*
* @example
* ```javascript
* var registrationTokens = [token1, token2, token3];
* admin.messaging().subscribeToTopic(registrationTokens, 'topic-name')
* .then(function(response) {
* if (response.failureCount > 0) {
* console.log("Following devices unsucessfully subscribed to topic:");
* response.errors.forEach(function(error) {
* var invalidToken = registrationTokens[error.index];
* console.log(invalidToken, error.error);
* });
* } else {
* console.log("All devices successfully subscribed to topic:", response);
* }
* })
* .catch(function(error) {
* console.log("Error subscribing to topic:", error);
* });
*```
*/
export interface FirebaseArrayIndexError {

/**
* The index of the errored item within the original array passed as part of the
* called API method.
*/
index: number;

/**
* The error object.
*/
error: FirebaseError;
}
2 changes: 1 addition & 1 deletion src/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import { getSdkVersion } from '../utils';

export { App, AppOptions } from './core'
export { App, AppOptions, FirebaseArrayIndexError, FirebaseError } from './core'
export { initializeApp, getApp, getApps, deleteApp } from './lifecycle';

export { Credential, ServiceAccount, GoogleOAuthAccessToken } from './credential';
Expand Down
2 changes: 1 addition & 1 deletion src/auth/user-import-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

import { FirebaseArrayIndexError } from '../app/index';
import { deepCopy, deepExtend } from '../utils/deep-copy';
import * as utils from '../utils';
import * as validator from '../utils/validator';
import { AuthClientErrorCode, FirebaseAuthError } from '../utils/error';
import { FirebaseArrayIndexError } from '../firebase-namespace-api';
import {
UpdateMultiFactorInfoRequest, UpdatePhoneMultiFactorInfoRequest, MultiFactorUpdateSettings
} from './auth-config';
Expand Down
79 changes: 0 additions & 79 deletions src/firebase-namespace-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,85 +29,6 @@ import { App as AppCore, AppOptions } from './app/index';

export * from './app/index';

/**
* `FirebaseError` is a subclass of the standard JavaScript `Error` object. In
* addition to a message string and stack trace, it contains a string code.
*/
export interface FirebaseError {

/**
* Error codes are strings using the following format: `"service/string-code"`.
* Some examples include `"auth/invalid-uid"` and
* `"messaging/invalid-recipient"`.
*
* While the message for a given error can change, the code will remain the same
* between backward-compatible versions of the Firebase SDK.
*/
code: string;

/**
* An explanatory message for the error that just occurred.
*
* This message is designed to be helpful to you, the developer. Because
* it generally does not convey meaningful information to end users,
* this message should not be displayed in your application.
*/
message: string;

/**
* A string value containing the execution backtrace when the error originally
* occurred.
*
* This information can be useful to you and can be sent to
* {@link https://firebase.google.com/support/ Firebase Support} to help
* explain the cause of an error.
*/
stack?: string;

/**
* @return A JSON-serializable representation of this object.
*/
toJSON(): object;
}

/**
* Composite type which includes both a `FirebaseError` object and an index
* which can be used to get the errored item.
*
* @example
* ```javascript
* var registrationTokens = [token1, token2, token3];
* admin.messaging().subscribeToTopic(registrationTokens, 'topic-name')
* .then(function(response) {
* if (response.failureCount > 0) {
* console.log("Following devices unsucessfully subscribed to topic:");
* response.errors.forEach(function(error) {
* var invalidToken = registrationTokens[error.index];
* console.log(invalidToken, error.error);
* });
* } else {
* console.log("All devices successfully subscribed to topic:", response);
* }
* })
* .catch(function(error) {
* console.log("Error subscribing to topic:", error);
* });
*```
*/
export interface FirebaseArrayIndexError {

/**
* The index of the errored item within the original array passed as part of the
* called API method.
*/
index: number;

/**
* The error object.
*/
error: FirebaseError;
}

// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace app {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/messaging/messaging-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { FirebaseArrayIndexError, FirebaseError } from '../firebase-namespace-api';
import { FirebaseArrayIndexError, FirebaseError } from '../app/index';

export interface BaseMessage {
data?: { [key: string]: string };
Expand Down
8 changes: 4 additions & 4 deletions test/unit/auth/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import * as chaiAsPromised from 'chai-as-promised';
import * as utils from '../utils';
import * as mocks from '../../resources/mocks';

import { Auth, TenantAwareAuth, BaseAuth } from '../../../src/auth/index';
import { UserRecord } from '../../../src/auth/user-record';
import { FirebaseApp } from '../../../src/app/firebase-app';
import {
AuthRequestHandler, TenantAwareAuthRequestHandler, AbstractAuthRequestHandler,
Expand All @@ -41,10 +39,12 @@ import {
OIDCConfig, SAMLConfig, OIDCConfigServerResponse, SAMLConfigServerResponse,
} from '../../../src/auth/auth-config';
import { deepCopy } from '../../../src/utils/deep-copy';
import { TenantManager } from '../../../src/auth/tenant-manager';
import { ServiceAccountCredential } from '../../../src/app/credential-internal';
import { HttpClient } from '../../../src/utils/api-request';
import { DecodedIdToken, UpdateRequest, AuthProviderConfigFilter } from '../../../src/auth/index';
import {
Auth, TenantAwareAuth, BaseAuth, UserRecord, DecodedIdToken,
UpdateRequest, AuthProviderConfigFilter, TenantManager,
} from '../../../src/auth/index';

chai.should();
chai.use(sinonChai);
Expand Down
5 changes: 2 additions & 3 deletions test/unit/auth/tenant-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ import * as chaiAsPromised from 'chai-as-promised';
import * as mocks from '../../resources/mocks';
import { FirebaseApp } from '../../../src/app/firebase-app';
import { AuthRequestHandler } from '../../../src/auth/auth-api-request';
import { Tenant, TenantServerResponse } from '../../../src/auth/tenant';
import { TenantManager } from '../../../src/auth/tenant-manager';
import { TenantServerResponse } from '../../../src/auth/tenant';
import { AuthClientErrorCode, FirebaseAuthError } from '../../../src/utils/error';
import {
CreateTenantRequest, UpdateTenantRequest, ListTenantsResult,
CreateTenantRequest, UpdateTenantRequest, ListTenantsResult, Tenant, TenantManager,
} from '../../../src/auth/index';

chai.should();
Expand Down
4 changes: 2 additions & 2 deletions test/unit/auth/tenant.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import * as chaiAsPromised from 'chai-as-promised';

import { deepCopy } from '../../../src/utils/deep-copy';
import { EmailSignInConfig, MultiFactorAuthConfig } from '../../../src/auth/auth-config';
import { Tenant, TenantServerResponse } from '../../../src/auth/tenant';
import { TenantServerResponse } from '../../../src/auth/tenant';
import {
CreateTenantRequest, UpdateTenantRequest, EmailSignInProviderConfig,
CreateTenantRequest, UpdateTenantRequest, EmailSignInProviderConfig, Tenant,
} from '../../../src/auth/index';

chai.should();
Expand Down
2 changes: 1 addition & 1 deletion test/unit/instance-id/instance-id.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import * as chaiAsPromised from 'chai-as-promised';
import * as utils from '../utils';
import * as mocks from '../../resources/mocks';

import { InstanceId } from '../../../src/instance-id/instance-id';
import { InstanceId } from '../../../src/instance-id/index';
import { FirebaseInstanceIdRequestHandler } from '../../../src/instance-id/instance-id-request-internal';
import { FirebaseApp } from '../../../src/app/firebase-app';
import { FirebaseInstanceIdError, InstanceIdClientErrorCode } from '../../../src/utils/error';
Expand Down
3 changes: 1 addition & 2 deletions test/unit/messaging/messaging.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ import { FirebaseApp } from '../../../src/app/firebase-app';
import {
Message, MessagingOptions, MessagingPayload, MessagingDevicesResponse,
MessagingDeviceGroupResponse, MessagingTopicManagementResponse, BatchResponse,
SendResponse, MulticastMessage,
SendResponse, MulticastMessage, Messaging,
} from '../../../src/messaging/index';
import { Messaging } from '../../../src/messaging/messaging';
import { BLACKLISTED_OPTIONS_KEYS, BLACKLISTED_DATA_PAYLOAD_KEYS } from '../../../src/messaging/messaging-internal';
import { HttpClient } from '../../../src/utils/api-request';
import { getSdkVersion } from '../../../src/utils/index';
Expand Down
8 changes: 3 additions & 5 deletions test/unit/remote-config/remote-config-api-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import * as _ from 'lodash';
import * as chai from 'chai';
import * as sinon from 'sinon';
import { remoteConfig } from '../../../src/remote-config/index';
import {
FirebaseRemoteConfigError,
RemoteConfigApiClient
Expand All @@ -31,10 +30,9 @@ import { FirebaseAppError } from '../../../src/utils/error';
import { FirebaseApp } from '../../../src/app/firebase-app';
import { deepCopy } from '../../../src/utils/deep-copy';
import { getSdkVersion } from '../../../src/utils/index';

import RemoteConfigTemplate = remoteConfig.RemoteConfigTemplate;
import Version = remoteConfig.Version;
import ListVersionsResult = remoteConfig.ListVersionsResult;
import {
RemoteConfigTemplate, Version, ListVersionsResult,
} from '../../../src/remote-config/index';

const expect = chai.expect;

Expand Down
2 changes: 1 addition & 1 deletion test/unit/storage/storage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { expect } from 'chai';

import * as mocks from '../../resources/mocks';
import { FirebaseApp } from '../../../src/app/firebase-app';
import { Storage } from '../../../src/storage/storage';
import { Storage } from '../../../src/storage/index';

describe('Storage', () => {
let mockApp: FirebaseApp;
Expand Down