/** * Fireblocks API * Fireblocks provides a suite of applications to manage digital asset operations and a complete development platform to build your business on the blockchain. - Visit our website for more information: [Fireblocks Website](https://fireblocks.com) - Visit our developer docs: [Fireblocks DevPortal](https://developers.fireblocks.com) * * The version of the OpenAPI document: 1.6.2 * Contact: developers@fireblocks.com * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import { BETA_STATE, EA_STATE, LIFECYCLE_STATE_HEADER, LINK_HEADER, OPERATION_ID_CONFIG_KEY, SUNSET_HEADER, SUPPRESS_ENV_VAR, buildLifecycleWarning, isSuppressed, operationIdFromConfig, WARNING_STATES, warnOnLifecycleState, } from '../utils/lifecycleWarning'; const SUNSET = 'Fri, 15 Jan 2027 00:00:00 GMT'; const MIGRATION_GUIDE = 'https://developer.fireblocks.com/docs/v2-migration'; const SUCCESSOR = 'https://api.fireblocks.io/v1/transactions_v2'; function headers(state?: string, sunset?: string, link?: string): Record { const result: Record = {}; if (state !== undefined) { result[LIFECYCLE_STATE_HEADER] = state; } if (sunset !== undefined) { result[SUNSET_HEADER] = sunset; } if (link !== undefined) { result[LINK_HEADER] = link; } return result; } describe('lifecycleWarning', () => { let consoleWarn: jest.SpyInstance; let originalSuppressionValue: string | undefined; beforeEach(() => { // A developer may export FIREBLOCKS_SDK_SUPPRESS_LIFECYCLE_WARNING in their shell // to quiet the warnings. Tests that expect a warning must not inherit that. originalSuppressionValue = process.env[SUPPRESS_ENV_VAR]; delete process.env[SUPPRESS_ENV_VAR]; // Warnings go to console - there is no customer-facing logger option. consoleWarn = jest.spyOn(console, 'warn').mockImplementation(() => undefined); }); afterEach(() => { consoleWarn.mockRestore(); if (originalSuppressionValue === undefined) { delete process.env[SUPPRESS_ENV_VAR]; } else { process.env[SUPPRESS_ENV_VAR] = originalSuppressionValue; } }); describe('emission', () => { it('emits one warning for a non-GA state', () => { warnOnLifecycleState(headers('ea'), 'createTransaction'); expect(consoleWarn).toHaveBeenCalledTimes(1); expect(consoleWarn.mock.calls[0][0]).toContain('createTransaction'); expect(consoleWarn.mock.calls[0][0]).toContain('EA (Early Availability)'); }); it('emits per execution, not once per operation', () => { warnOnLifecycleState(headers('ea'), 'createTransaction'); warnOnLifecycleState(headers('ea'), 'createTransaction'); expect(consoleWarn).toHaveBeenCalledTimes(2); }); it('emits for each distinct operation', () => { warnOnLifecycleState(headers('ea'), 'createTransaction'); warnOnLifecycleState(headers('closed'), 'getVaultAccount', 200); expect(consoleWarn).toHaveBeenCalledTimes(2); }); }); describe('silence', () => { it.each([ 'ga', 'internal', 'unlisted', 'beta', // retired names for ea: no longer recognised 'private_beta', 'quantum_preview', '', ' ', 'private beta', 'private-beta', '