diff --git a/docs-devsite/ai.objectschemarequest.md b/docs-devsite/ai.objectschemarequest.md new file mode 100644 index 00000000000..ccc554ab42f --- /dev/null +++ b/docs-devsite/ai.objectschemarequest.md @@ -0,0 +1,45 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ObjectSchemaRequest interface +Interface for JSON parameters in [SchemaType.OBJECT](./ai.md#schematypeobject_enummember) format when not using the [ObjectSchema](./ai.objectschema.md#objectschema_class) helper. + +Signature: + +```typescript +export interface ObjectSchemaRequest extends SchemaRequest +``` +Extends: [SchemaRequest](./ai.schemarequest.md#schemarequest_interface) + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [optionalProperties](./ai.objectschemarequest.md#objectschemarequestoptionalproperties) | never | This is not a property accepted in the final request to the backend, but is a client-side convenience property that is only usable by constructing a schema through the Schema.object() helper method. Populating this property will cause response errors if the object is not wrapped with Schema.object(). | +| [type](./ai.objectschemarequest.md#objectschemarequesttype) | [SchemaType.OBJECT](./ai.md#schematypeobject_enummember) | | + +## ObjectSchemaRequest.optionalProperties + +This is not a property accepted in the final request to the backend, but is a client-side convenience property that is only usable by constructing a schema through the `Schema.object()` helper method. Populating this property will cause response errors if the object is not wrapped with `Schema.object()`. + +Signature: + +```typescript +optionalProperties?: never; +``` + +## ObjectSchemaRequest.type + +Signature: + +```typescript +type: SchemaType.OBJECT; +``` diff --git a/packages/app-check-interop-types/index.d.ts b/packages/app-check-interop-types/index.d.ts index cc16c5e4680..504c63c5819 100644 --- a/packages/app-check-interop-types/index.d.ts +++ b/packages/app-check-interop-types/index.d.ts @@ -34,10 +34,10 @@ export interface FirebaseAppCheckInternal { removeTokenListener(listener: AppCheckTokenListener): void; } -type AppCheckTokenListener = (token: AppCheckTokenResult) => void; +export type AppCheckTokenListener = (token: AppCheckTokenResult) => void; // If the error field is defined, the token field will be populated with a dummy token -interface AppCheckTokenResult { +export interface AppCheckTokenResult { readonly token: string; readonly error?: Error; } diff --git a/packages/firebase/.gitignore b/packages/firebase/.gitignore index 228443ec909..ea616f7f428 100644 --- a/packages/firebase/.gitignore +++ b/packages/firebase/.gitignore @@ -1,4 +1,6 @@ /firebase*.js /firebase*.map /firebase*.gz -/firebase*.tgz \ No newline at end of file +/firebase*.tgz +/custom/*.d.ts +/packages \ No newline at end of file diff --git a/packages/firebase/compat/rollup-internal.config.js b/packages/firebase/compat/rollup-internal.config.js new file mode 100644 index 00000000000..2dfc4d1f29c --- /dev/null +++ b/packages/firebase/compat/rollup-internal.config.js @@ -0,0 +1,39 @@ +/** + * @license + * Copyright 2022 Google LLC + * + * 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. + */ + +/** + * Specialized config only for internal deployment to google3 repo, adds required license header to + * generated code. + */ + +// When run in google3, original rollup.config.js will have been renamed to rollup-main.config.js. +import baseBuilds from './rollup.config.js'; +import license from 'rollup-plugin-license'; + +const firebaseLicense = license({ + banner: `@license + Copyright ${new Date().getFullYear()} Google LLC. + SPDX-License-Identifier: Apache-2.0` +}); + +const buildsWithLicense = baseBuilds.map(build => { + return Object.assign({}, build, { + plugins: build.plugins.concat(firebaseLicense) + }); +}); + +export default buildsWithLicense; diff --git a/packages/firebase/custom/analytics-remote-config.ts b/packages/firebase/custom/analytics-remote-config.ts new file mode 100644 index 00000000000..db11a53fd3f --- /dev/null +++ b/packages/firebase/custom/analytics-remote-config.ts @@ -0,0 +1,23 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * 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 { registerVersion } from '@firebase/app'; +import { version } from '../package.json'; + +export * as app from '@firebase/app'; +export * as analytics from '@firebase/analytics'; +export * as remoteConfig from '@firebase/remote-config'; diff --git a/packages/firebase/custom/index.all.ts b/packages/firebase/custom/index.all.ts new file mode 100644 index 00000000000..2ad81407664 --- /dev/null +++ b/packages/firebase/custom/index.all.ts @@ -0,0 +1,34 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * 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 { registerVersion } from '@firebase/app'; +import { version } from '../package.json'; + +registerVersion('fire-js-all', version, 'cdn'); +export * as app from '@firebase/app'; +export * as ai from '@firebase/ai'; +export * as analytics from '@firebase/analytics'; +export * as appCheck from '@firebase/app-check'; +export * as auth from '@firebase/auth'; +export * as dataConnect from '@firebase/data-connect'; +export * as database from '@firebase/database'; +export * as firestore from '@firebase/firestore'; +export * as functions from '@firebase/functions'; +export * as installations from '@firebase/installations'; +export * as messaging from '@firebase/messaging'; +export * as performance from '@firebase/performance'; +export * as remoteConfig from '@firebase/remote-config'; diff --git a/packages/firebase/package.json b/packages/firebase/package.json index 4f785d15c8c..e82e55738c7 100644 --- a/packages/firebase/package.json +++ b/packages/firebase/package.json @@ -403,8 +403,9 @@ }, "scripts": { "build": "rollup -c && gulp cdn-type-module-path && yarn build:compat", - "build:internal": "rollup -c && gulp cdn-type-module-path-internal && yarn build:compat", + "build:internal": "rollup -c rollup-internal.config.js && gulp cdn-type-module-path-internal && yarn build:compat:internal", "build:compat": "rollup -c compat/rollup.config.js", + "build:compat:internal": "rollup -c compat/rollup-internal.config.js", "dev": "rollup -c -w", "test": "echo 'No test suite for firebase wrapper'", "test:ci": "echo 'No test suite for firebase wrapper'", @@ -446,6 +447,7 @@ "@rollup/plugin-node-resolve": "16.0.0", "rollup-plugin-sourcemaps": "0.6.3", "@rollup/plugin-terser": "0.4.4", + "rollup-plugin-dts": "5.3.1", "rollup-plugin-typescript2": "0.36.0", "rollup-plugin-uglify": "6.0.4", "gulp": "4.0.2", diff --git a/packages/firebase/rollup-internal.config.js b/packages/firebase/rollup-internal.config.js index 7511a41a502..512004e4499 100644 --- a/packages/firebase/rollup-internal.config.js +++ b/packages/firebase/rollup-internal.config.js @@ -21,8 +21,23 @@ */ // When run in google3, original rollup.config.js will have been renamed to rollup-main.config.js. -import baseBuilds from './rollup-main.config.js'; +import { cdnBuilds, plugins } from './rollup.config.js'; import license from 'rollup-plugin-license'; +import typescript from 'typescript'; +import rollupTypescriptPlugin from 'rollup-plugin-typescript2'; +import dts from 'rollup-plugin-dts'; +import { parse } from 'path'; + +const typescriptPluginCustom = rollupTypescriptPlugin({ + typescript, + allowJs: true, + include: ['*.ts', '**/*.ts', '*.js', '**/*.js'], + tsconfigOverride: { + compilerOptions: { + declaration: true + } + } +}); const firebaseLicense = license({ banner: `@license @@ -30,10 +45,48 @@ const firebaseLicense = license({ SPDX-License-Identifier: Apache-2.0` }); -const buildsWithLicense = baseBuilds.map(build => { +const buildsWithLicense = cdnBuilds.map(build => { return Object.assign({}, build, { plugins: build.plugins.concat(firebaseLicense) }); }); -export default buildsWithLicense; +/** + * Custom builds that include combinations of multiple products. + */ +const customBuilds = [ + { inputFile: 'custom/index.all.ts', outputFile: 'firebase.js' }, + { + inputFile: 'custom/analytics-remote-config.ts', + outputFile: 'firebase-analytics-rc.js' + } +] + .map(build => { + const { dir, name } = parse(build.inputFile); + return [ + { + input: build.inputFile, + output: { + file: build.outputFile, + sourcemap: true, + format: 'es' + }, + plugins: [...plugins, typescriptPluginCustom, firebaseLicense] + }, + { + input: `${dir}/${name}.d.ts`, + output: { + file: `dist/${name}.global.d.ts`, + format: 'es' + }, + plugins: [ + dts({ + respectExternal: true + }) + ] + } + ]; + }) + .flat(); + +export default [...buildsWithLicense, ...customBuilds]; diff --git a/packages/firebase/rollup.config.js b/packages/firebase/rollup.config.js index f96ff01666c..849bb394ef1 100644 --- a/packages/firebase/rollup.config.js +++ b/packages/firebase/rollup.config.js @@ -134,7 +134,7 @@ const componentBuilds = pkg.components /** * CDN script builds */ -const cdnBuilds = [ +export const cdnBuilds = [ { input: 'app/index.cdn.ts', output: { @@ -175,4 +175,6 @@ const cdnBuilds = [ }) ]; +export { plugins }; + export default [...appBuilds, ...componentBuilds, ...cdnBuilds];