initial commit
This commit is contained in:
37
server/node_modules/firebase-admin/lib/data-connect/data-connect-api-client-internal.d.ts
generated
vendored
Normal file
37
server/node_modules/firebase-admin/lib/data-connect/data-connect-api-client-internal.d.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2024 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 { PrefixedFirebaseError } from '../utils/error';
|
||||
/**
|
||||
* When true the SDK should communicate with the Data Connect Emulator for all API
|
||||
* calls and also produce unsigned tokens.
|
||||
*/
|
||||
export declare function useEmulator(): boolean;
|
||||
export declare const DATA_CONNECT_ERROR_CODE_MAPPING: {
|
||||
[key: string]: DataConnectErrorCode;
|
||||
};
|
||||
export type DataConnectErrorCode = 'aborted' | 'invalid-argument' | 'invalid-credential' | 'internal-error' | 'permission-denied' | 'unauthenticated' | 'not-found' | 'unknown-error' | 'query-error';
|
||||
/**
|
||||
* Firebase Data Connect error code structure. This extends PrefixedFirebaseError.
|
||||
*
|
||||
* @param code - The error code.
|
||||
* @param message - The error message.
|
||||
* @constructor
|
||||
*/
|
||||
export declare class FirebaseDataConnectError extends PrefixedFirebaseError {
|
||||
constructor(code: DataConnectErrorCode, message: string);
|
||||
}
|
||||
361
server/node_modules/firebase-admin/lib/data-connect/data-connect-api-client-internal.js
generated
vendored
Normal file
361
server/node_modules/firebase-admin/lib/data-connect/data-connect-api-client-internal.js
generated
vendored
Normal file
@@ -0,0 +1,361 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
"use strict";
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2024 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.FirebaseDataConnectError = exports.DATA_CONNECT_ERROR_CODE_MAPPING = exports.DataConnectApiClient = void 0;
|
||||
exports.useEmulator = useEmulator;
|
||||
const api_request_1 = require("../utils/api-request");
|
||||
const error_1 = require("../utils/error");
|
||||
const utils = require("../utils/index");
|
||||
const validator = require("../utils/validator");
|
||||
const API_VERSION = 'v1alpha';
|
||||
/** The Firebase Data Connect backend base URL format. */
|
||||
const FIREBASE_DATA_CONNECT_BASE_URL_FORMAT = 'https://firebasedataconnect.googleapis.com/{version}/projects/{projectId}/locations/{locationId}/services/{serviceId}:{endpointId}';
|
||||
/** Firebase Data Connect base URl format when using the Data Connect emultor. */
|
||||
const FIREBASE_DATA_CONNECT_EMULATOR_BASE_URL_FORMAT = 'http://{host}/{version}/projects/{projectId}/locations/{locationId}/services/{serviceId}:{endpointId}';
|
||||
const EXECUTE_GRAPH_QL_ENDPOINT = 'executeGraphql';
|
||||
const EXECUTE_GRAPH_QL_READ_ENDPOINT = 'executeGraphqlRead';
|
||||
const DATA_CONNECT_CONFIG_HEADERS = {
|
||||
'X-Firebase-Client': `fire-admin-node/${utils.getSdkVersion()}`
|
||||
};
|
||||
/**
|
||||
* Class that facilitates sending requests to the Firebase Data Connect backend API.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class DataConnectApiClient {
|
||||
constructor(connectorConfig, app) {
|
||||
this.connectorConfig = connectorConfig;
|
||||
this.app = app;
|
||||
if (!validator.isNonNullObject(app) || !('options' in app)) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT, 'First argument passed to getDataConnect() must be a valid Firebase app instance.');
|
||||
}
|
||||
this.httpClient = new DataConnectHttpClient(app);
|
||||
}
|
||||
/**
|
||||
* Execute arbitrary GraphQL, including both read and write queries
|
||||
*
|
||||
* @param query - The GraphQL string to be executed.
|
||||
* @param options - GraphQL Options
|
||||
* @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
|
||||
*/
|
||||
async executeGraphql(query, options) {
|
||||
return this.executeGraphqlHelper(query, EXECUTE_GRAPH_QL_ENDPOINT, options);
|
||||
}
|
||||
/**
|
||||
* Execute arbitrary read-only GraphQL queries
|
||||
*
|
||||
* @param query - The GraphQL (read-only) string to be executed.
|
||||
* @param options - GraphQL Options
|
||||
* @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
|
||||
* @throws FirebaseDataConnectError
|
||||
*/
|
||||
async executeGraphqlRead(query, options) {
|
||||
return this.executeGraphqlHelper(query, EXECUTE_GRAPH_QL_READ_ENDPOINT, options);
|
||||
}
|
||||
async executeGraphqlHelper(query, endpoint, options) {
|
||||
if (!validator.isNonEmptyString(query)) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT, '`query` must be a non-empty string.');
|
||||
}
|
||||
if (typeof options !== 'undefined') {
|
||||
if (!validator.isNonNullObject(options)) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT, 'GraphqlOptions must be a non-null object');
|
||||
}
|
||||
}
|
||||
const data = {
|
||||
query,
|
||||
...(options?.variables && { variables: options?.variables }),
|
||||
...(options?.operationName && { operationName: options?.operationName }),
|
||||
...(options?.impersonate && { extensions: { impersonate: options?.impersonate } }),
|
||||
};
|
||||
return this.getUrl(API_VERSION, this.connectorConfig.location, this.connectorConfig.serviceId, endpoint)
|
||||
.then(async (url) => {
|
||||
const request = {
|
||||
method: 'POST',
|
||||
url,
|
||||
headers: DATA_CONNECT_CONFIG_HEADERS,
|
||||
data,
|
||||
};
|
||||
const resp = await this.httpClient.send(request);
|
||||
if (resp.data.errors && validator.isNonEmptyArray(resp.data.errors)) {
|
||||
const allMessages = resp.data.errors.map((error) => error.message).join(' ');
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.QUERY_ERROR, allMessages);
|
||||
}
|
||||
return Promise.resolve({
|
||||
data: resp.data.data,
|
||||
});
|
||||
})
|
||||
.then((resp) => {
|
||||
return resp;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw this.toFirebaseError(err);
|
||||
});
|
||||
}
|
||||
async getUrl(version, locationId, serviceId, endpointId) {
|
||||
return this.getProjectId()
|
||||
.then((projectId) => {
|
||||
const urlParams = {
|
||||
version,
|
||||
projectId,
|
||||
locationId,
|
||||
serviceId,
|
||||
endpointId
|
||||
};
|
||||
let urlFormat;
|
||||
if (useEmulator()) {
|
||||
urlFormat = utils.formatString(FIREBASE_DATA_CONNECT_EMULATOR_BASE_URL_FORMAT, {
|
||||
host: emulatorHost()
|
||||
});
|
||||
}
|
||||
else {
|
||||
urlFormat = FIREBASE_DATA_CONNECT_BASE_URL_FORMAT;
|
||||
}
|
||||
return utils.formatString(urlFormat, urlParams);
|
||||
});
|
||||
}
|
||||
getProjectId() {
|
||||
if (this.projectId) {
|
||||
return Promise.resolve(this.projectId);
|
||||
}
|
||||
return utils.findProjectId(this.app)
|
||||
.then((projectId) => {
|
||||
if (!validator.isNonEmptyString(projectId)) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.UNKNOWN, 'Failed to determine project ID. Initialize the '
|
||||
+ 'SDK with service account credentials or set project ID as an app option. '
|
||||
+ 'Alternatively, set the GOOGLE_CLOUD_PROJECT environment variable.');
|
||||
}
|
||||
this.projectId = projectId;
|
||||
return projectId;
|
||||
});
|
||||
}
|
||||
toFirebaseError(err) {
|
||||
if (err instanceof error_1.PrefixedFirebaseError) {
|
||||
return err;
|
||||
}
|
||||
const response = err.response;
|
||||
if (!response.isJson()) {
|
||||
return new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.UNKNOWN, `Unexpected response with status: ${response.status} and body: ${response.text}`);
|
||||
}
|
||||
const error = response.data.error || {};
|
||||
let code = exports.DATA_CONNECT_ERROR_CODE_MAPPING.UNKNOWN;
|
||||
if (error.status && error.status in exports.DATA_CONNECT_ERROR_CODE_MAPPING) {
|
||||
code = exports.DATA_CONNECT_ERROR_CODE_MAPPING[error.status];
|
||||
}
|
||||
const message = error.message || `Unknown server error: ${response.text}`;
|
||||
return new FirebaseDataConnectError(code, message);
|
||||
}
|
||||
/**
|
||||
* Converts JSON data into a GraphQL literal string.
|
||||
* Handles nested objects, arrays, strings, numbers, and booleans.
|
||||
* Ensures strings are properly escaped.
|
||||
*/
|
||||
objectToString(data) {
|
||||
if (typeof data === 'string') {
|
||||
const escapedString = data
|
||||
.replace(/\\/g, '\\\\') // Replace \ with \\
|
||||
.replace(/"/g, '\\"'); // Replace " with \"
|
||||
return `"${escapedString}"`;
|
||||
}
|
||||
if (typeof data === 'number' || typeof data === 'boolean' || data === null) {
|
||||
return String(data);
|
||||
}
|
||||
if (validator.isArray(data)) {
|
||||
const elements = data.map(item => this.objectToString(item)).join(', ');
|
||||
return `[${elements}]`;
|
||||
}
|
||||
if (typeof data === 'object' && data !== null) {
|
||||
// Filter out properties where the value is undefined BEFORE mapping
|
||||
const kvPairs = Object.entries(data)
|
||||
.filter(([, val]) => val !== undefined)
|
||||
.map(([key, val]) => {
|
||||
// GraphQL object keys are typically unquoted.
|
||||
return `${key}: ${this.objectToString(val)}`;
|
||||
});
|
||||
if (kvPairs.length === 0) {
|
||||
return '{}'; // Represent an object with no defined properties as {}
|
||||
}
|
||||
return `{ ${kvPairs.join(', ')} }`;
|
||||
}
|
||||
// If value is undefined (and not an object property, which is handled above,
|
||||
// e.g., if objectToString(undefined) is called directly or for an array element)
|
||||
// it should be represented as 'null'.
|
||||
if (typeof data === 'undefined') {
|
||||
return 'null';
|
||||
}
|
||||
// Fallback for any other types (e.g., Symbol, BigInt - though less common in GQL contexts)
|
||||
// Consider how these should be handled or if an error should be thrown.
|
||||
// For now, simple string conversion.
|
||||
return String(data);
|
||||
}
|
||||
formatTableName(tableName) {
|
||||
// Format tableName: first character to lowercase
|
||||
if (tableName && tableName.length > 0) {
|
||||
return tableName.charAt(0).toLowerCase() + tableName.slice(1);
|
||||
}
|
||||
return tableName;
|
||||
}
|
||||
handleBulkImportErrors(err) {
|
||||
if (err.code === `data-connect/${exports.DATA_CONNECT_ERROR_CODE_MAPPING.QUERY_ERROR}`) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.QUERY_ERROR, `${err.message}. Make sure that your table name passed in matches the type name in your GraphQL schema file.`);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
/**
|
||||
* Insert a single row into the specified table.
|
||||
*/
|
||||
async insert(tableName, data) {
|
||||
if (!validator.isNonEmptyString(tableName)) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT, '`tableName` must be a non-empty string.');
|
||||
}
|
||||
if (validator.isArray(data)) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT, '`data` must be an object, not an array, for single insert. For arrays, please use `insertMany` function.');
|
||||
}
|
||||
if (!validator.isNonNullObject(data)) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT, '`data` must be a non-null object.');
|
||||
}
|
||||
try {
|
||||
tableName = this.formatTableName(tableName);
|
||||
const gqlDataString = this.objectToString(data);
|
||||
const mutation = `mutation { ${tableName}_insert(data: ${gqlDataString}) }`;
|
||||
// Use internal executeGraphql
|
||||
return this.executeGraphql(mutation).catch(this.handleBulkImportErrors);
|
||||
}
|
||||
catch (e) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INTERNAL, `Failed to construct insert mutation: ${e.message}`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Insert multiple rows into the specified table.
|
||||
*/
|
||||
async insertMany(tableName, data) {
|
||||
if (!validator.isNonEmptyString(tableName)) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT, '`tableName` must be a non-empty string.');
|
||||
}
|
||||
if (!validator.isNonEmptyArray(data)) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT, '`data` must be a non-empty array for insertMany.');
|
||||
}
|
||||
try {
|
||||
tableName = this.formatTableName(tableName);
|
||||
const gqlDataString = this.objectToString(data);
|
||||
const mutation = `mutation { ${tableName}_insertMany(data: ${gqlDataString}) }`;
|
||||
// Use internal executeGraphql
|
||||
return this.executeGraphql(mutation).catch(this.handleBulkImportErrors);
|
||||
}
|
||||
catch (e) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INTERNAL, `Failed to construct insertMany mutation: ${e.message}`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Insert a single row into the specified table, or update it if it already exists.
|
||||
*/
|
||||
async upsert(tableName, data) {
|
||||
if (!validator.isNonEmptyString(tableName)) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT, '`tableName` must be a non-empty string.');
|
||||
}
|
||||
if (validator.isArray(data)) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT, '`data` must be an object, not an array, for single upsert. For arrays, please use `upsertMany` function.');
|
||||
}
|
||||
if (!validator.isNonNullObject(data)) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT, '`data` must be a non-null object.');
|
||||
}
|
||||
try {
|
||||
tableName = this.formatTableName(tableName);
|
||||
const gqlDataString = this.objectToString(data);
|
||||
const mutation = `mutation { ${tableName}_upsert(data: ${gqlDataString}) }`;
|
||||
// Use internal executeGraphql
|
||||
return this.executeGraphql(mutation).catch(this.handleBulkImportErrors);
|
||||
}
|
||||
catch (e) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INTERNAL, `Failed to construct upsert mutation: ${e.message}`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Insert multiple rows into the specified table, or update them if they already exist.
|
||||
*/
|
||||
async upsertMany(tableName, data) {
|
||||
if (!validator.isNonEmptyString(tableName)) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT, '`tableName` must be a non-empty string.');
|
||||
}
|
||||
if (!validator.isNonEmptyArray(data)) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT, '`data` must be a non-empty array for upsertMany.');
|
||||
}
|
||||
try {
|
||||
tableName = this.formatTableName(tableName);
|
||||
const gqlDataString = this.objectToString(data);
|
||||
const mutation = `mutation { ${tableName}_upsertMany(data: ${gqlDataString}) }`;
|
||||
// Use internal executeGraphql
|
||||
return this.executeGraphql(mutation).catch(this.handleBulkImportErrors);
|
||||
}
|
||||
catch (e) {
|
||||
throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INTERNAL, `Failed to construct upsertMany mutation: ${e.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.DataConnectApiClient = DataConnectApiClient;
|
||||
/**
|
||||
* Data Connect-specific HTTP client which uses the special "owner" token
|
||||
* when communicating with the Data Connect Emulator.
|
||||
*/
|
||||
class DataConnectHttpClient extends api_request_1.AuthorizedHttpClient {
|
||||
getToken() {
|
||||
if (useEmulator()) {
|
||||
return Promise.resolve('owner');
|
||||
}
|
||||
return super.getToken();
|
||||
}
|
||||
}
|
||||
function emulatorHost() {
|
||||
return process.env.DATA_CONNECT_EMULATOR_HOST;
|
||||
}
|
||||
/**
|
||||
* When true the SDK should communicate with the Data Connect Emulator for all API
|
||||
* calls and also produce unsigned tokens.
|
||||
*/
|
||||
function useEmulator() {
|
||||
return !!emulatorHost();
|
||||
}
|
||||
exports.DATA_CONNECT_ERROR_CODE_MAPPING = {
|
||||
ABORTED: 'aborted',
|
||||
INVALID_ARGUMENT: 'invalid-argument',
|
||||
INVALID_CREDENTIAL: 'invalid-credential',
|
||||
INTERNAL: 'internal-error',
|
||||
PERMISSION_DENIED: 'permission-denied',
|
||||
UNAUTHENTICATED: 'unauthenticated',
|
||||
NOT_FOUND: 'not-found',
|
||||
UNKNOWN: 'unknown-error',
|
||||
QUERY_ERROR: 'query-error',
|
||||
};
|
||||
/**
|
||||
* Firebase Data Connect error code structure. This extends PrefixedFirebaseError.
|
||||
*
|
||||
* @param code - The error code.
|
||||
* @param message - The error message.
|
||||
* @constructor
|
||||
*/
|
||||
class FirebaseDataConnectError extends error_1.PrefixedFirebaseError {
|
||||
constructor(code, message) {
|
||||
super('data-connect', code, message);
|
||||
/* tslint:disable:max-line-length */
|
||||
// Set the prototype explicitly. See the following link for more details:
|
||||
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
||||
/* tslint:enable:max-line-length */
|
||||
this.__proto__ = FirebaseDataConnectError.prototype;
|
||||
}
|
||||
}
|
||||
exports.FirebaseDataConnectError = FirebaseDataConnectError;
|
||||
95
server/node_modules/firebase-admin/lib/data-connect/data-connect-api.d.ts
generated
vendored
Normal file
95
server/node_modules/firebase-admin/lib/data-connect/data-connect-api.d.ts
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2024 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 { DecodedIdToken } from '../auth/token-verifier';
|
||||
/**
|
||||
* Interface representing a Data Connect connector configuration.
|
||||
*/
|
||||
export interface ConnectorConfig {
|
||||
/**
|
||||
* Location ID of the Data Connect service.
|
||||
*/
|
||||
location: string;
|
||||
/**
|
||||
* Service ID of the Data Connect service.
|
||||
*/
|
||||
serviceId: string;
|
||||
}
|
||||
/**
|
||||
* Interface representing GraphQL response.
|
||||
*/
|
||||
export interface ExecuteGraphqlResponse<GraphqlResponse> {
|
||||
/**
|
||||
* Data payload of the GraphQL response.
|
||||
*/
|
||||
data: GraphqlResponse;
|
||||
}
|
||||
/**
|
||||
* Interface representing GraphQL options.
|
||||
*/
|
||||
export interface GraphqlOptions<Variables> {
|
||||
/**
|
||||
* Values for GraphQL variables provided in this query or mutation.
|
||||
*/
|
||||
variables?: Variables;
|
||||
/**
|
||||
* The name of the GraphQL operation. Required only if `query` contains multiple operations.
|
||||
*/
|
||||
operationName?: string;
|
||||
/**
|
||||
* If set, impersonate a request with given Firebase Auth context and evaluate the auth
|
||||
* policies on the operation. If omitted, bypass any defined auth policies.
|
||||
*/
|
||||
impersonate?: ImpersonateAuthenticated | ImpersonateUnauthenticated;
|
||||
}
|
||||
/**
|
||||
* Type representing the partial claims of a Firebase Auth token used to evaluate the
|
||||
* Data Connect auth policy.
|
||||
*/
|
||||
export type AuthClaims = Partial<DecodedIdToken>;
|
||||
/**
|
||||
* Interface representing the impersonation of an authenticated user.
|
||||
*/
|
||||
export interface ImpersonateAuthenticated {
|
||||
/**
|
||||
* Evaluate the auth policy with a customized JWT auth token. Should follow the Firebase Auth token format.
|
||||
* https://firebase.google.com/docs/data-connect/cel-reference#auth-token-contents
|
||||
*
|
||||
* @example A verified user may have the following `authClaims`:
|
||||
* ```json
|
||||
* { "sub": "uid", "email_verified": true }
|
||||
* ```
|
||||
*/
|
||||
authClaims: AuthClaims;
|
||||
/**
|
||||
* Both `authClaims` and `unauthenticated` are mutually exclusive fields and should not be both set.
|
||||
*/
|
||||
unauthenticated?: never;
|
||||
}
|
||||
/**
|
||||
* Interface representing the impersonation of an unauthenticated user.
|
||||
*/
|
||||
export interface ImpersonateUnauthenticated {
|
||||
/**
|
||||
* Both `authClaims` and `unauthenticated` are mutually exclusive fields and should not be both set.
|
||||
*/
|
||||
authClaims?: never;
|
||||
/**
|
||||
* Evaluates the auth policy as an unauthenticated request. Can only be set to true.
|
||||
*/
|
||||
unauthenticated: true;
|
||||
}
|
||||
19
server/node_modules/firebase-admin/lib/data-connect/data-connect-api.js
generated
vendored
Normal file
19
server/node_modules/firebase-admin/lib/data-connect/data-connect-api.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
"use strict";
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2024 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 });
|
||||
89
server/node_modules/firebase-admin/lib/data-connect/data-connect.d.ts
generated
vendored
Normal file
89
server/node_modules/firebase-admin/lib/data-connect/data-connect.d.ts
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2024 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 { App } from '../app';
|
||||
import { ConnectorConfig, ExecuteGraphqlResponse, GraphqlOptions } from './data-connect-api';
|
||||
export declare class DataConnectService {
|
||||
private readonly appInternal;
|
||||
private dataConnectInstances;
|
||||
constructor(app: App);
|
||||
getDataConnect(connectorConfig: ConnectorConfig): DataConnect;
|
||||
/**
|
||||
* Returns the app associated with this `DataConnectService` instance.
|
||||
*
|
||||
* @returns The app associated with this `DataConnectService` instance.
|
||||
*/
|
||||
get app(): App;
|
||||
}
|
||||
/**
|
||||
* The Firebase `DataConnect` service interface.
|
||||
*/
|
||||
export declare class DataConnect {
|
||||
readonly connectorConfig: ConnectorConfig;
|
||||
readonly app: App;
|
||||
private readonly client;
|
||||
/**
|
||||
* Execute an arbitrary GraphQL query or mutation
|
||||
*
|
||||
* @param query - The GraphQL query or mutation.
|
||||
* @param options - Optional {@link GraphqlOptions} when executing a GraphQL query or mutation.
|
||||
*
|
||||
* @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
|
||||
*/
|
||||
executeGraphql<GraphqlResponse, Variables>(query: string, options?: GraphqlOptions<Variables>): Promise<ExecuteGraphqlResponse<GraphqlResponse>>;
|
||||
/**
|
||||
* Execute an arbitrary read-only GraphQL query
|
||||
*
|
||||
* @param query - The GraphQL read-only query.
|
||||
* @param options - Optional {@link GraphqlOptions} when executing a read-only GraphQL query.
|
||||
*
|
||||
* @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
|
||||
*/
|
||||
executeGraphqlRead<GraphqlResponse, Variables>(query: string, options?: GraphqlOptions<Variables>): Promise<ExecuteGraphqlResponse<GraphqlResponse>>;
|
||||
/**
|
||||
* Insert a single row into the specified table.
|
||||
*
|
||||
* @param tableName - The name of the table to insert data into.
|
||||
* @param variables - The data object to insert. The keys should correspond to the column names.
|
||||
* @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
|
||||
*/
|
||||
insert<GraphQlResponse, Variables extends object>(tableName: string, variables: Variables): Promise<ExecuteGraphqlResponse<GraphQlResponse>>;
|
||||
/**
|
||||
* Insert multiple rows into the specified table.
|
||||
*
|
||||
* @param tableName - The name of the table to insert data into.
|
||||
* @param variables - An array of data objects to insert. Each object's keys should correspond to the column names.
|
||||
* @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
|
||||
*/
|
||||
insertMany<GraphQlResponse, Variables extends Array<unknown>>(tableName: string, variables: Variables): Promise<ExecuteGraphqlResponse<GraphQlResponse>>;
|
||||
/**
|
||||
* Insert a single row into the specified table, or update it if it already exists.
|
||||
*
|
||||
* @param tableName - The name of the table to upsert data into.
|
||||
* @param variables - The data object to upsert. The keys should correspond to the column names.
|
||||
* @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
|
||||
*/
|
||||
upsert<GraphQlResponse, Variables extends object>(tableName: string, variables: Variables): Promise<ExecuteGraphqlResponse<GraphQlResponse>>;
|
||||
/**
|
||||
* Insert multiple rows into the specified table, or update them if they already exist.
|
||||
*
|
||||
* @param tableName - The name of the table to upsert data into.
|
||||
* @param variables - An array of data objects to upsert. Each object's keys should correspond to the column names.
|
||||
* @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
|
||||
*/
|
||||
upsertMany<GraphQlResponse, Variables extends Array<unknown>>(tableName: string, variables: Variables): Promise<ExecuteGraphqlResponse<GraphQlResponse>>;
|
||||
}
|
||||
125
server/node_modules/firebase-admin/lib/data-connect/data-connect.js
generated
vendored
Normal file
125
server/node_modules/firebase-admin/lib/data-connect/data-connect.js
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
"use strict";
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2024 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.DataConnect = exports.DataConnectService = void 0;
|
||||
const data_connect_api_client_internal_1 = require("./data-connect-api-client-internal");
|
||||
class DataConnectService {
|
||||
constructor(app) {
|
||||
this.dataConnectInstances = new Map();
|
||||
this.appInternal = app;
|
||||
}
|
||||
getDataConnect(connectorConfig) {
|
||||
const id = `${connectorConfig.location}-${connectorConfig.serviceId}`;
|
||||
const dc = this.dataConnectInstances.get(id);
|
||||
if (typeof dc !== 'undefined') {
|
||||
return dc;
|
||||
}
|
||||
const newInstance = new DataConnect(connectorConfig, this.appInternal);
|
||||
this.dataConnectInstances.set(id, newInstance);
|
||||
return newInstance;
|
||||
}
|
||||
/**
|
||||
* Returns the app associated with this `DataConnectService` instance.
|
||||
*
|
||||
* @returns The app associated with this `DataConnectService` instance.
|
||||
*/
|
||||
get app() {
|
||||
return this.appInternal;
|
||||
}
|
||||
}
|
||||
exports.DataConnectService = DataConnectService;
|
||||
/**
|
||||
* The Firebase `DataConnect` service interface.
|
||||
*/
|
||||
class DataConnect {
|
||||
/**
|
||||
* @param connectorConfig - The connector configuration.
|
||||
* @param app - The app for this `DataConnect` service.
|
||||
* @constructor
|
||||
* @internal
|
||||
*/
|
||||
constructor(connectorConfig, app) {
|
||||
this.connectorConfig = connectorConfig;
|
||||
this.app = app;
|
||||
this.client = new data_connect_api_client_internal_1.DataConnectApiClient(connectorConfig, app);
|
||||
}
|
||||
/**
|
||||
* Execute an arbitrary GraphQL query or mutation
|
||||
*
|
||||
* @param query - The GraphQL query or mutation.
|
||||
* @param options - Optional {@link GraphqlOptions} when executing a GraphQL query or mutation.
|
||||
*
|
||||
* @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
|
||||
*/
|
||||
executeGraphql(query, options) {
|
||||
return this.client.executeGraphql(query, options);
|
||||
}
|
||||
/**
|
||||
* Execute an arbitrary read-only GraphQL query
|
||||
*
|
||||
* @param query - The GraphQL read-only query.
|
||||
* @param options - Optional {@link GraphqlOptions} when executing a read-only GraphQL query.
|
||||
*
|
||||
* @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
|
||||
*/
|
||||
executeGraphqlRead(query, options) {
|
||||
return this.client.executeGraphqlRead(query, options);
|
||||
}
|
||||
/**
|
||||
* Insert a single row into the specified table.
|
||||
*
|
||||
* @param tableName - The name of the table to insert data into.
|
||||
* @param variables - The data object to insert. The keys should correspond to the column names.
|
||||
* @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
|
||||
*/
|
||||
insert(tableName, variables) {
|
||||
return this.client.insert(tableName, variables);
|
||||
}
|
||||
/**
|
||||
* Insert multiple rows into the specified table.
|
||||
*
|
||||
* @param tableName - The name of the table to insert data into.
|
||||
* @param variables - An array of data objects to insert. Each object's keys should correspond to the column names.
|
||||
* @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
|
||||
*/
|
||||
insertMany(tableName, variables) {
|
||||
return this.client.insertMany(tableName, variables);
|
||||
}
|
||||
/**
|
||||
* Insert a single row into the specified table, or update it if it already exists.
|
||||
*
|
||||
* @param tableName - The name of the table to upsert data into.
|
||||
* @param variables - The data object to upsert. The keys should correspond to the column names.
|
||||
* @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
|
||||
*/
|
||||
upsert(tableName, variables) {
|
||||
return this.client.upsert(tableName, variables);
|
||||
}
|
||||
/**
|
||||
* Insert multiple rows into the specified table, or update them if they already exist.
|
||||
*
|
||||
* @param tableName - The name of the table to upsert data into.
|
||||
* @param variables - An array of data objects to upsert. Each object's keys should correspond to the column names.
|
||||
* @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
|
||||
*/
|
||||
upsertMany(tableName, variables) {
|
||||
return this.client.upsertMany(tableName, variables);
|
||||
}
|
||||
}
|
||||
exports.DataConnect = DataConnect;
|
||||
61
server/node_modules/firebase-admin/lib/data-connect/index.d.ts
generated
vendored
Normal file
61
server/node_modules/firebase-admin/lib/data-connect/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2024 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.
|
||||
*/
|
||||
/**
|
||||
* Firebase Data Connect service.
|
||||
*
|
||||
* @packageDocumentation
|
||||
*/
|
||||
import { App } from '../app';
|
||||
import { DataConnect } from './data-connect';
|
||||
import { ConnectorConfig } from './data-connect-api';
|
||||
export { GraphqlOptions, ExecuteGraphqlResponse, ConnectorConfig, ImpersonateAuthenticated, ImpersonateUnauthenticated, AuthClaims } from './data-connect-api';
|
||||
export { DataConnect, } from './data-connect';
|
||||
/**
|
||||
* Gets the {@link DataConnect} service with the provided connector configuration
|
||||
* for the default app or a given app.
|
||||
*
|
||||
* `getDataConnect(connectorConfig)` can be called with no app argument to access the default
|
||||
* app's `DataConnect` service or as `getDataConnect(connectorConfig, app)` to access the
|
||||
* `DataConnect` service associated with a specific app.
|
||||
*
|
||||
* @example
|
||||
* ```javascript
|
||||
* const connectorConfig: ConnectorConfig = {
|
||||
* location: 'us-west2',
|
||||
* serviceId: 'my-service',
|
||||
* };
|
||||
*
|
||||
* // Get the `DataConnect` service for the default app
|
||||
* const defaultDataConnect = getDataConnect(connectorConfig);
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* ```javascript
|
||||
* // Get the `DataConnect` service for a given app
|
||||
* const otherDataConnect = getDataConnect(connectorConfig, otherApp);
|
||||
* ```
|
||||
*
|
||||
* @param connectorConfig - Connector configuration for the `DataConnect` service.
|
||||
*
|
||||
* @param app - Optional app for which to return the `DataConnect` service.
|
||||
* If not provided, the default `DataConnect` service is returned.
|
||||
*
|
||||
* @returns The default `DataConnect` service with the provided connector configuration
|
||||
* if no app is provided, or the `DataConnect` service associated with the provided app.
|
||||
*/
|
||||
export declare function getDataConnect(connectorConfig: ConnectorConfig, app?: App): DataConnect;
|
||||
71
server/node_modules/firebase-admin/lib/data-connect/index.js
generated
vendored
Normal file
71
server/node_modules/firebase-admin/lib/data-connect/index.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
"use strict";
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2024 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.DataConnect = void 0;
|
||||
exports.getDataConnect = getDataConnect;
|
||||
/**
|
||||
* Firebase Data Connect service.
|
||||
*
|
||||
* @packageDocumentation
|
||||
*/
|
||||
const app_1 = require("../app");
|
||||
const data_connect_1 = require("./data-connect");
|
||||
var data_connect_2 = require("./data-connect");
|
||||
Object.defineProperty(exports, "DataConnect", { enumerable: true, get: function () { return data_connect_2.DataConnect; } });
|
||||
/**
|
||||
* Gets the {@link DataConnect} service with the provided connector configuration
|
||||
* for the default app or a given app.
|
||||
*
|
||||
* `getDataConnect(connectorConfig)` can be called with no app argument to access the default
|
||||
* app's `DataConnect` service or as `getDataConnect(connectorConfig, app)` to access the
|
||||
* `DataConnect` service associated with a specific app.
|
||||
*
|
||||
* @example
|
||||
* ```javascript
|
||||
* const connectorConfig: ConnectorConfig = {
|
||||
* location: 'us-west2',
|
||||
* serviceId: 'my-service',
|
||||
* };
|
||||
*
|
||||
* // Get the `DataConnect` service for the default app
|
||||
* const defaultDataConnect = getDataConnect(connectorConfig);
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* ```javascript
|
||||
* // Get the `DataConnect` service for a given app
|
||||
* const otherDataConnect = getDataConnect(connectorConfig, otherApp);
|
||||
* ```
|
||||
*
|
||||
* @param connectorConfig - Connector configuration for the `DataConnect` service.
|
||||
*
|
||||
* @param app - Optional app for which to return the `DataConnect` service.
|
||||
* If not provided, the default `DataConnect` service is returned.
|
||||
*
|
||||
* @returns The default `DataConnect` service with the provided connector configuration
|
||||
* if no app is provided, or the `DataConnect` service associated with the provided app.
|
||||
*/
|
||||
function getDataConnect(connectorConfig, app) {
|
||||
if (typeof app === 'undefined') {
|
||||
app = (0, app_1.getApp)();
|
||||
}
|
||||
const firebaseApp = app;
|
||||
const dataConnectService = firebaseApp.getOrInitService('dataConnect', (app) => new data_connect_1.DataConnectService(app));
|
||||
return dataConnectService.getDataConnect(connectorConfig);
|
||||
}
|
||||
Reference in New Issue
Block a user