From 3198d58dcedbf7583914dbcc76984f6f7df8d2ef Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Tue, 22 Mar 2022 10:05:05 -0700 Subject: [PATCH] Exclude browser-only types from @firebase/util public types (#6088) --- .changeset/fluffy-seahorses-thank.md | 5 + common/api-review/util.api.md | 482 +++++++++++++++++++++++++++ packages/util/api-extractor.json | 23 ++ packages/util/package.json | 6 +- packages/util/src/indexeddb.ts | 21 ++ 5 files changed, 535 insertions(+), 2 deletions(-) create mode 100644 .changeset/fluffy-seahorses-thank.md create mode 100644 common/api-review/util.api.md create mode 100644 packages/util/api-extractor.json diff --git a/.changeset/fluffy-seahorses-thank.md b/.changeset/fluffy-seahorses-thank.md new file mode 100644 index 00000000000..03ccca2570b --- /dev/null +++ b/.changeset/fluffy-seahorses-thank.md @@ -0,0 +1,5 @@ +--- +'@firebase/util': patch +--- + +Remove unneeded types from public typings file. diff --git a/common/api-review/util.api.md b/common/api-review/util.api.md new file mode 100644 index 00000000000..21bcea8b894 --- /dev/null +++ b/common/api-review/util.api.md @@ -0,0 +1,482 @@ +## API Report File for "@firebase/util" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +// Warning: (ae-missing-release-tag) "areCookiesEnabled" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function areCookiesEnabled(): boolean; + +// Warning: (ae-missing-release-tag) "assert" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export const assert: (assertion: unknown, message: string) => void; + +// Warning: (ae-missing-release-tag) "assertionError" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export const assertionError: (message: string) => Error; + +// Warning: (ae-missing-release-tag) "async" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function async(fn: Function, onError?: ErrorFn): Function; + +// Warning: (ae-forgotten-export) The symbol "Base64" needs to be exported by the entry point index.d.ts +// Warning: (ae-missing-release-tag) "base64" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export const base64: Base64; + +// Warning: (ae-missing-release-tag) "base64Decode" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export const base64Decode: (str: string) => string | null; + +// Warning: (ae-missing-release-tag) "base64Encode" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export const base64Encode: (str: string) => string; + +// Warning: (ae-missing-release-tag) "base64urlEncodeWithoutPadding" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export const base64urlEncodeWithoutPadding: (str: string) => string; + +// Warning: (ae-missing-release-tag) "calculateBackoffMillis" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function calculateBackoffMillis(backoffCount: number, intervalMillis?: number, backoffFactor?: number): number; + +// Warning: (ae-missing-release-tag) "Compat" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export interface Compat { + // (undocumented) + _delegate: T; +} + +// Warning: (ae-missing-release-tag) "CompleteFn" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type CompleteFn = () => void; + +// Warning: (ae-missing-release-tag) "CONSTANTS" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export const CONSTANTS: { + NODE_CLIENT: boolean; + NODE_ADMIN: boolean; + SDK_VERSION: string; +}; + +// Warning: (ae-missing-release-tag) "contains" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function contains(obj: T, key: string): boolean; + +// Warning: (ae-missing-release-tag) "createMockUserToken" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function createMockUserToken(token: EmulatorMockTokenOptions, projectId?: string): string; + +// Warning: (ae-missing-release-tag) "createSubscribe" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function createSubscribe(executor: Executor, onNoObservers?: Executor): Subscribe; + +// Warning: (ae-internal-missing-underscore) The name "DBWrapper" should be prefixed with an underscore because the declaration is marked as @internal +// +// @internal (undocumented) +export class DBWrapper { + constructor(_db: IDBDatabase); + // (undocumented) + close(): void; + // Warning: (ae-forgotten-export) The symbol "ObjectStoreWrapper" needs to be exported by the entry point index.d.ts + // + // (undocumented) + createObjectStore(storeName: string, options?: IDBObjectStoreParameters): ObjectStoreWrapper; + // (undocumented) + objectStoreNames: DOMStringList; + // Warning: (ae-forgotten-export) The symbol "TransactionWrapper" needs to be exported by the entry point index.d.ts + // + // (undocumented) + transaction(storeNames: string[] | string, mode?: IDBTransactionMode): TransactionWrapper; +} + +// Warning: (ae-forgotten-export) The symbol "DecodedToken" needs to be exported by the entry point index.d.ts +// Warning: (ae-missing-release-tag) "decode" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export const decode: (token: string) => DecodedToken; + +// Warning: (ae-missing-release-tag) "deepCopy" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function deepCopy(value: T): T; + +// Warning: (ae-missing-release-tag) "deepEqual" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function deepEqual(a: object, b: object): boolean; + +// Warning: (ae-missing-release-tag) "deepExtend" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function deepExtend(target: unknown, source: unknown): unknown; + +// Warning: (ae-missing-release-tag) "Deferred" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export class Deferred { + constructor(); + // (undocumented) + promise: Promise; + // (undocumented) + reject: (value?: unknown) => void; + // (undocumented) + resolve: (value?: unknown) => void; + wrapCallback(callback?: (error?: unknown, value?: unknown) => void): (error: unknown, value?: unknown) => void; +} + +// Warning: (ae-internal-missing-underscore) The name "deleteDB" should be prefixed with an underscore because the declaration is marked as @internal +// +// @internal (undocumented) +export function deleteDB(dbName: string): Promise; + +// Warning: (ae-forgotten-export) The symbol "FirebaseIdToken" needs to be exported by the entry point index.d.ts +// Warning: (ae-missing-release-tag) "EmulatorMockTokenOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type EmulatorMockTokenOptions = ({ + user_id: string; +} | { + sub: string; +}) & Partial; + +// Warning: (ae-missing-release-tag) "ErrorData" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface ErrorData { + // (undocumented) + [key: string]: unknown; +} + +// Warning: (ae-missing-release-tag) "ErrorFactory" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export class ErrorFactory { + constructor(service: string, serviceName: string, errors: ErrorMap); + // (undocumented) + create(code: K, ...data: K extends keyof ErrorParams ? [ErrorParams[K]] : []): FirebaseError; + } + +// Warning: (ae-missing-release-tag) "ErrorFn" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type ErrorFn = (error: Error) => void; + +// Warning: (ae-missing-release-tag) "ErrorMap" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export type ErrorMap = { + readonly [K in ErrorCode]: string; +}; + +// Warning: (ae-missing-release-tag) "errorPrefix" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function errorPrefix(fnName: string, argName: string): string; + +// Warning: (ae-missing-release-tag) "Executor" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type Executor = (observer: Observer) => void; + +// Warning: (ae-missing-release-tag) "extractQuerystring" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function extractQuerystring(url: string): string; + +// Warning: (ae-missing-release-tag) "FirebaseError" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export class FirebaseError extends Error { + constructor( + code: string, message: string, + customData?: Record | undefined); + readonly code: string; + customData?: Record | undefined; + readonly name: string; +} + +// Warning: (ae-missing-release-tag) "FirebaseSignInProvider" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export type FirebaseSignInProvider = 'custom' | 'email' | 'password' | 'phone' | 'anonymous' | 'google.com' | 'facebook.com' | 'github.com' | 'twitter.com' | 'microsoft.com' | 'apple.com'; + +// Warning: (ae-missing-release-tag) "getGlobal" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function getGlobal(): typeof globalThis; + +// Warning: (ae-missing-release-tag) "getModularInstance" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getModularInstance(service: Compat | ExpService): ExpService; + +// Warning: (ae-missing-release-tag) "getUA" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function getUA(): string; + +// Warning: (ae-missing-release-tag) "isAdmin" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export const isAdmin: (token: string) => boolean; + +// Warning: (ae-missing-release-tag) "isBrowser" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function isBrowser(): boolean; + +// Warning: (ae-missing-release-tag) "isBrowserExtension" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function isBrowserExtension(): boolean; + +// Warning: (ae-missing-release-tag) "isElectron" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function isElectron(): boolean; + +// Warning: (ae-missing-release-tag) "isEmpty" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function isEmpty(obj: object): obj is {}; + +// Warning: (ae-missing-release-tag) "isIE" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function isIE(): boolean; + +// Warning: (ae-missing-release-tag) "isIndexedDBAvailable" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function isIndexedDBAvailable(): boolean; + +// Warning: (ae-missing-release-tag) "isMobileCordova" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function isMobileCordova(): boolean; + +// Warning: (ae-missing-release-tag) "isNode" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function isNode(): boolean; + +// Warning: (ae-missing-release-tag) "isNodeSdk" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function isNodeSdk(): boolean; + +// Warning: (ae-missing-release-tag) "isReactNative" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function isReactNative(): boolean; + +// Warning: (ae-missing-release-tag) "isSafari" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function isSafari(): boolean; + +// Warning: (ae-missing-release-tag) "issuedAtTime" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export const issuedAtTime: (token: string) => number | null; + +// Warning: (ae-missing-release-tag) "isUWP" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function isUWP(): boolean; + +// Warning: (ae-missing-release-tag) "isValidFormat" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export const isValidFormat: (token: string) => boolean; + +// Warning: (ae-missing-release-tag) "isValidTimestamp" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export const isValidTimestamp: (token: string) => boolean; + +// Warning: (ae-missing-release-tag) "jsonEval" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function jsonEval(str: string): unknown; + +// Warning: (ae-missing-release-tag) "map" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function map(obj: { + [key in K]: V; +}, fn: (value: V, key: K, obj: { + [key in K]: V; +}) => U, contextObj?: unknown): { + [key in K]: U; +}; + +// Warning: (ae-missing-release-tag) "MAX_VALUE_MILLIS" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export const MAX_VALUE_MILLIS: number; + +// Warning: (ae-missing-release-tag) "NextFn" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export type NextFn = (value: T) => void; + +// Warning: (ae-missing-release-tag) "Observable" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface Observable { + // (undocumented) + subscribe: Subscribe; +} + +// Warning: (ae-missing-release-tag) "Observer" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface Observer { + // (undocumented) + complete: CompleteFn; + // (undocumented) + error: ErrorFn; + // (undocumented) + next: NextFn; +} + +// Warning: (ae-internal-missing-underscore) The name "openDB" should be prefixed with an underscore because the declaration is marked as @internal +// +// @internal (undocumented) +export function openDB(dbName: string, dbVersion: number, upgradeCallback: (db: DBWrapper, oldVersion: number, newVersion: number | null, transaction: TransactionWrapper) => void): Promise; + +// Warning: (ae-missing-release-tag) "ordinal" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function ordinal(i: number): string; + +// Warning: (ae-missing-release-tag) "PartialObserver" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type PartialObserver = Partial>; + +// Warning: (ae-missing-release-tag) "querystring" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function querystring(querystringParams: { + [key: string]: string | number; +}): string; + +// Warning: (ae-missing-release-tag) "querystringDecode" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function querystringDecode(querystring: string): Record; + +// Warning: (ae-missing-release-tag) "RANDOM_FACTOR" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export const RANDOM_FACTOR = 0.5; + +// Warning: (ae-missing-release-tag) "safeGet" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function safeGet(obj: T, key: K): T[K] | undefined; + +// Warning: (ae-missing-release-tag) "Sha1" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export class Sha1 { + constructor(); + // (undocumented) + blockSize: number; + compress_(buf: number[] | Uint8Array | string, offset?: number): void; + // @override (undocumented) + digest(): number[]; + // (undocumented) + reset(): void; + // (undocumented) + update(bytes?: number[] | Uint8Array | string, length?: number): void; + } + +// Warning: (ae-missing-release-tag) "stringify" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function stringify(data: unknown): string; + +// Warning: (ae-missing-release-tag) "stringLength" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export const stringLength: (str: string) => number; + +// Warning: (ae-missing-release-tag) "StringLike" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface StringLike { + // (undocumented) + toString(): string; +} + +// Warning: (ae-missing-release-tag) "stringToByteArray" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export const stringToByteArray: (str: string) => number[]; + +// Warning: (ae-missing-release-tag) "Subscribe" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export interface Subscribe { + // (undocumented) + (next?: NextFn, error?: ErrorFn, complete?: CompleteFn): Unsubscribe; + // (undocumented) + (observer: PartialObserver): Unsubscribe; +} + +// Warning: (ae-missing-release-tag) "Unsubscribe" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type Unsubscribe = () => void; + +// Warning: (ae-missing-release-tag) "validateArgCount" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export const validateArgCount: (fnName: string, minCount: number, maxCount: number, argCount: number) => void; + +// Warning: (ae-missing-release-tag) "validateCallback" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function validateCallback(fnName: string, argumentName: string, callback: Function, optional: boolean): void; + +// Warning: (ae-missing-release-tag) "validateContextObject" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function validateContextObject(fnName: string, argumentName: string, context: unknown, optional: boolean): void; + +// Warning: (ae-missing-release-tag) "validateIndexedDBOpenable" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function validateIndexedDBOpenable(): Promise; + +// Warning: (ae-missing-release-tag) "validateNamespace" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function validateNamespace(fnName: string, namespace: string, optional: boolean): void; + + +// (No @packageDocumentation comment for this package) + +``` diff --git a/packages/util/api-extractor.json b/packages/util/api-extractor.json new file mode 100644 index 00000000000..ed2ce51c716 --- /dev/null +++ b/packages/util/api-extractor.json @@ -0,0 +1,23 @@ +{ + "extends": "../../config/api-extractor.json", + // Point it to your entry point d.ts file. + "mainEntryPointFilePath": "/dist/index.d.ts", + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "/dist/.d.ts", + "publicTrimmedFilePath": "/dist/-public.d.ts" + }, + "messages": { + "extractorMessageReporting": { + "ae-missing-release-tag": { + "logLevel": "warning", + "addToApiReportFile": true + } + }, + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + } + } +} \ No newline at end of file diff --git a/packages/util/package.json b/packages/util/package.json index 84f79b90f07..e6e016ca907 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -24,7 +24,7 @@ "scripts": { "lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'", "lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'", - "build": "rollup -c", + "build": "rollup -c && yarn api-report", "build:deps": "lerna run --scope @firebase/util --include-dependencies build", "dev": "rollup -c -w", "prettier": "prettier --write 'src/**/*.ts' 'test/**/*.ts'", @@ -32,7 +32,9 @@ "test:ci": "node ../../scripts/run_tests_in_ci.js -s test:all", "test:all": "run-p test:browser test:node", "test:browser": "karma start --single-run", - "test:node": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha test/**/*.test.* --config ../../config/mocharc.node.js" + "test:node": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha test/**/*.test.* --config ../../config/mocharc.node.js", + "api-report": "api-extractor run --local --verbose", + "typings:public": "node ../../scripts/build/use_typings.js ./dist/util-public.d.ts" }, "license": "Apache-2.0", "dependencies": { diff --git a/packages/util/src/indexeddb.ts b/packages/util/src/indexeddb.ts index b2d4546f18e..56fe355dc0c 100644 --- a/packages/util/src/indexeddb.ts +++ b/packages/util/src/indexeddb.ts @@ -15,6 +15,9 @@ * limitations under the License. */ +/** + * @internal + */ function promisifyRequest( request: IDBRequest, errorMessage: string @@ -29,6 +32,9 @@ function promisifyRequest( }); } +/** + * @internal + */ export class DBWrapper { objectStoreNames: DOMStringList; constructor(private _db: IDBDatabase) { @@ -55,6 +61,9 @@ export class DBWrapper { } } +/** + * @internal + */ class TransactionWrapper { complete: Promise; constructor(private _transaction: IDBTransaction) { @@ -75,6 +84,9 @@ class TransactionWrapper { } } +/** + * @internal + */ class ObjectStoreWrapper { constructor(private _store: IDBObjectStore) {} index(name: string): IndexWrapper { @@ -105,6 +117,9 @@ class ObjectStoreWrapper { } } +/** + * @internal + */ class IndexWrapper { constructor(private _index: IDBIndex) {} get(key: string): Promise { @@ -113,6 +128,9 @@ class IndexWrapper { } } +/** + * @internal + */ export function openDB( dbName: string, dbVersion: number, @@ -153,6 +171,9 @@ export function openDB( }); } +/** + * @internal + */ export async function deleteDB(dbName: string): Promise { return new Promise((resolve, reject) => { try {