Deprecation
Helpers exported by @morevoice/sdk from src/lib/deprecation.ts.
Exported from @morevoice/sdk (source: packages/sdk-ts/src/lib/deprecation.ts).
DeprecationNotice
Section titled “DeprecationNotice”interface DeprecationNotice { /** The request that got it first, e.g. `GET`. */ method: string; /** Its URL path, e.g. `/v1/calls`. */ path: string; /** When it was deprecated (RFC 9745 `Deprecation`), when the header carried a date. */ deprecatedAt: Date | null; /** When it stops working (RFC 8594 `Sunset`). */ sunset: Date | null; /** The migration guide (`Link: <…>; rel="deprecation"`, else `rel="sunset"`). */ link: string | undefined; /** The `MoreVoice-Version` the response was rendered in. */ apiVersion: string | undefined; /** A one-line, human-readable summary (what the default warning prints). */ message: string; /** Identifies the notice: the same for every response of one deprecation. */ key: string;}DeprecationHandler
Section titled “DeprecationHandler”type DeprecationHandler = (notice: DeprecationNotice) => void;parseDeprecationNotice()
Section titled “parseDeprecationNotice()”The notice a response carries, or null (no Deprecation and no Sunset header).
function parseDeprecationNotice(response: { headers: HeaderGetter }, request: { method: string; url: string }): DeprecationNotice | null;resetDeprecationNotices()
Section titled “resetDeprecationNotices()”Forget the notices already reported (tests).
function resetDeprecationNotices(): void;reportDeprecation()
Section titled “reportDeprecation()”Report a notice once per process: through handler when it is a function, as a warning when it is undefined, not at
all when it is null. Never throws (a failing handler, or --throw-deprecation, must not fail the API call).
Returns true when this call reported it.
function reportDeprecation(notice: DeprecationNotice, handler: DeprecationHandler | null | undefined): boolean;withDeprecationNotices()
Section titled “withDeprecationNotices()”Wrap a fetch so every response is checked for a deprecation notice (the client does this for you).
function withDeprecationNotices(fetchFn: FetchLike, handler: DeprecationHandler | null | undefined): FetchLike;