diff --git a/etc/firebase-admin.remote-config.api.md b/etc/firebase-admin.remote-config.api.md index dc48662e8c..ffbe404968 100644 --- a/etc/firebase-admin.remote-config.api.md +++ b/etc/firebase-admin.remote-config.api.md @@ -81,7 +81,7 @@ export interface ExplicitParameterValue { value: string; } -// @public +// @public @deprecated export interface FetchResponseData { config?: { [key: string]: string; @@ -236,10 +236,11 @@ export const RemoteConfigErrorCode: { // @public export type RemoteConfigErrorCode = typeof RemoteConfigErrorCode[keyof typeof RemoteConfigErrorCode]; -// @public +// @public @deprecated export class RemoteConfigFetchResponse { + // @deprecated constructor(app: App, serverConfig: ServerConfig, requestEtag?: string); - // (undocumented) + // @deprecated (undocumented) toJSON(): FetchResponseData; } diff --git a/src/remote-config/remote-config-api.ts b/src/remote-config/remote-config-api.ts index 0f2648d797..588bad7523 100644 --- a/src/remote-config/remote-config-api.ts +++ b/src/remote-config/remote-config-api.ts @@ -879,6 +879,10 @@ export interface ServerConfig { /** * JSON-serializable representation of evaluated config values. This can be consumed by * Remote Config web client SDKs. + * + * @deprecated Remote Config server-side rendering (SSR) hydration of the + * client SDK is no longer supported. This type will be removed in the + * next major release. */ export interface FetchResponseData { /** diff --git a/src/remote-config/remote-config.ts b/src/remote-config/remote-config.ts index 7e74fc9381..ba47866fa1 100644 --- a/src/remote-config/remote-config.ts +++ b/src/remote-config/remote-config.ts @@ -704,8 +704,14 @@ class VersionImpl implements Version { const HTTP_NOT_MODIFIED = 304; const HTTP_OK = 200; +let fetchResponseDeprecationWarned = false; + /** * Represents a fetch response that can be used to interact with RC's client SDK. + * + * @deprecated Remote Config server-side rendering (SSR) hydration of the + * client SDK is no longer supported. This class will be removed in the + * next major release. */ export class RemoteConfigFetchResponse { private response: FetchResponseData; @@ -714,8 +720,21 @@ export class RemoteConfigFetchResponse { * @param app - The app for this RemoteConfig service. * @param serverConfig - The server config for which to generate a fetch response. * @param requestEtag - A request eTag with which to compare the current response. + * + * @deprecated Remote Config server-side rendering (SSR) hydration of the + * client SDK is no longer supported. This class will be removed in the + * next major release. */ constructor(app: App, serverConfig: ServerConfig, requestEtag?: string) { + if (!fetchResponseDeprecationWarned) { + fetchResponseDeprecationWarned = true; + console.warn( + 'RemoteConfigFetchResponse is deprecated and will be removed in the next major ' + + 'release. Remote Config server-side rendering (SSR) hydration of the client SDK ' + + 'is no longer supported.' + ); + } + const config: { [key: string]: string } = {}; for (const [param, value] of Object.entries(serverConfig.getAll())) { config[param] = value.asString(); @@ -740,6 +759,10 @@ export class RemoteConfigFetchResponse { /** * @returns JSON representation of the fetch response that can be consumed * by the RC client SDK. + * + * @deprecated Remote Config server-side rendering (SSR) hydration of the + * client SDK is no longer supported. This method will be removed in the + * next major release. */ public toJSON(): FetchResponseData { return this.response; diff --git a/test/unit/remote-config/remote-config.spec.ts b/test/unit/remote-config/remote-config.spec.ts index ffd65f79de..3d25105d35 100644 --- a/test/unit/remote-config/remote-config.spec.ts +++ b/test/unit/remote-config/remote-config.spec.ts @@ -1585,6 +1585,27 @@ describe('RemoteConfig', () => { }); describe('RemoteConfigFetchResponse', () => { + let warnStub: sinon.SinonStub; + + beforeEach(() => { + warnStub = sinon.stub(console, 'warn'); + }); + + afterEach(() => { + warnStub.restore(); + }); + + // This test must run before any other construction of RemoteConfigFetchResponse + // in this process, since the deprecation warning is emitted only once per process. + it('should log a deprecation warning only once', () => { + const templateData = deepCopy(SERVER_REMOTE_CONFIG_RESPONSE) as ServerTemplateData; + const template = remoteConfig.initServerTemplate({ template: templateData }); + new RemoteConfigFetchResponse(mockApp, template.evaluate()); + new RemoteConfigFetchResponse(mockApp, template.evaluate()); + expect(warnStub).to.have.been.calledOnce; + expect(warnStub.firstCall.args[0]).to.include('RemoteConfigFetchResponse is deprecated'); + }); + it('should return a 200 response when supplied with no etag', () => { const templateData = deepCopy(SERVER_REMOTE_CONFIG_RESPONSE) as ServerTemplateData; // Defines remote parameter values.