bannerify-js 0.0.19 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -552,7 +552,7 @@ var ky = createInstance();
552
552
  var distribution_default = ky;
553
553
 
554
554
  // package.json
555
- var version = "0.0.16";
555
+ var version = "0.0.20";
556
556
 
557
557
  // src/telemetry.ts
558
558
  function getTelemetry() {
@@ -600,7 +600,7 @@ var Bannerify = class {
600
600
  const telemetry = getTelemetry();
601
601
  this.baseUrl = opts?.baseUrl || "https://api-beta.bannerify.co/v1";
602
602
  this.client = distribution_default.create({
603
- fetch: opts?.fetch || fetch,
603
+ fetch: opts?.fetch || globalThis.fetch,
604
604
  prefixUrl: this.baseUrl,
605
605
  headers: {
606
606
  Authorization: `Bearer ${apiKey}`,
@@ -615,7 +615,7 @@ var Bannerify = class {
615
615
  baseUrl;
616
616
  async createImage(templateId, options) {
617
617
  try {
618
- const res = this.client.get("templates/createImage", {
618
+ const res = await this.client.post("templates/createImage", {
619
619
  json: {
620
620
  modifications: options?.modifications ?? [],
621
621
  // template: JSON.stringify(options?.template ?? {}),
@@ -661,6 +661,9 @@ var Bannerify = class {
661
661
  if (options?.modifications) {
662
662
  searchParams.set("modifications", JSON.stringify(options?.modifications));
663
663
  }
664
+ if (options?.nocache) {
665
+ searchParams.set("nocache", "true");
666
+ }
664
667
  searchParams.set("templateId", templateId);
665
668
  searchParams.sort();
666
669
  searchParams.set("sign", await this.#hashText(searchParams.toString() + searchParams.get("apiKeyMd5")));
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/errors/HTTPError.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/errors/TimeoutError.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/is.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/merge.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/core/constants.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/normalize.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/timeout.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/delay.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/options.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/core/Ky.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/index.ts","../package.json","../src/telemetry.ts","../src/types.ts","../src/client.ts"],"sourcesContent":["export * from './client'\nexport type { Modification } from './interface'","import type {NormalizedOptions} from '../types/options.js';\n\n// eslint-lint-disable-next-line @typescript-eslint/naming-convention\nexport class HTTPError extends Error {\n\tpublic response: Response;\n\tpublic request: Request;\n\tpublic options: NormalizedOptions;\n\n\tconstructor(response: Response, request: Request, options: NormalizedOptions) {\n\t\tconst code = (response.status || response.status === 0) ? response.status : '';\n\t\tconst title = response.statusText || '';\n\t\tconst status = `${code} ${title}`.trim();\n\t\tconst reason = status ? `status code ${status}` : 'an unknown error';\n\n\t\tsuper(`Request failed with ${reason}`);\n\n\t\tthis.name = 'HTTPError';\n\t\tthis.response = response;\n\t\tthis.request = request;\n\t\tthis.options = options;\n\t}\n}\n","export class TimeoutError extends Error {\n\tpublic request: Request;\n\n\tconstructor(request: Request) {\n\t\tsuper('Request timed out');\n\t\tthis.name = 'TimeoutError';\n\t\tthis.request = request;\n\t}\n}\n","// eslint-disable-next-line @typescript-eslint/ban-types\nexport const isObject = (value: unknown): value is object => value !== null && typeof value === 'object';\n","import type {KyHeadersInit, Options} from '../types/options.js';\nimport {isObject} from './is.js';\n\nexport const validateAndMerge = (...sources: Array<Partial<Options> | undefined>): Partial<Options> => {\n\tfor (const source of sources) {\n\t\tif ((!isObject(source) || Array.isArray(source)) && source !== undefined) {\n\t\t\tthrow new TypeError('The `options` argument must be an object');\n\t\t}\n\t}\n\n\treturn deepMerge({}, ...sources);\n};\n\nexport const mergeHeaders = (source1: KyHeadersInit = {}, source2: KyHeadersInit = {}) => {\n\tconst result = new globalThis.Headers(source1 as HeadersInit);\n\tconst isHeadersInstance = source2 instanceof globalThis.Headers;\n\tconst source = new globalThis.Headers(source2 as HeadersInit);\n\n\tfor (const [key, value] of source.entries()) {\n\t\tif ((isHeadersInstance && value === 'undefined') || value === undefined) {\n\t\t\tresult.delete(key);\n\t\t} else {\n\t\t\tresult.set(key, value);\n\t\t}\n\t}\n\n\treturn result;\n};\n\n// TODO: Make this strongly-typed (no `any`).\nexport const deepMerge = <T>(...sources: Array<Partial<T> | undefined>): T => {\n\tlet returnValue: any = {};\n\tlet headers = {};\n\n\tfor (const source of sources) {\n\t\tif (Array.isArray(source)) {\n\t\t\tif (!Array.isArray(returnValue)) {\n\t\t\t\treturnValue = [];\n\t\t\t}\n\n\t\t\treturnValue = [...returnValue, ...source];\n\t\t} else if (isObject(source)) {\n\t\t\tfor (let [key, value] of Object.entries(source)) {\n\t\t\t\tif (isObject(value) && key in returnValue) {\n\t\t\t\t\tvalue = deepMerge(returnValue[key], value);\n\t\t\t\t}\n\n\t\t\t\treturnValue = {...returnValue, [key]: value};\n\t\t\t}\n\n\t\t\tif (isObject((source as any).headers)) {\n\t\t\t\theaders = mergeHeaders(headers, (source as any).headers);\n\t\t\t\treturnValue.headers = headers;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn returnValue;\n};\n","import type {Expect, Equal} from '@type-challenges/utils';\nimport {type HttpMethod, type KyOptionsRegistry} from '../types/options.js';\nimport {type RequestInitRegistry} from '../types/request.js';\n\nexport const supportsRequestStreams = (() => {\n\tlet duplexAccessed = false;\n\tlet hasContentType = false;\n\tconst supportsReadableStream = typeof globalThis.ReadableStream === 'function';\n\tconst supportsRequest = typeof globalThis.Request === 'function';\n\n\tif (supportsReadableStream && supportsRequest) {\n\t\thasContentType = new globalThis.Request('https://empty.invalid', {\n\t\t\tbody: new globalThis.ReadableStream(),\n\t\t\tmethod: 'POST',\n\t\t\t// @ts-expect-error - Types are outdated.\n\t\t\tget duplex() {\n\t\t\t\tduplexAccessed = true;\n\t\t\t\treturn 'half';\n\t\t\t},\n\t\t}).headers.has('Content-Type');\n\t}\n\n\treturn duplexAccessed && !hasContentType;\n})();\n\nexport const supportsAbortController = typeof globalThis.AbortController === 'function';\nexport const supportsResponseStreams = typeof globalThis.ReadableStream === 'function';\nexport const supportsFormData = typeof globalThis.FormData === 'function';\n\nexport const requestMethods = ['get', 'post', 'put', 'patch', 'head', 'delete'] as const;\n\nconst validate = <T extends Array<true>>() => undefined as unknown as T;\nvalidate<[\n\tExpect<Equal<typeof requestMethods[number], HttpMethod>>,\n]>();\n\nexport const responseTypes = {\n\tjson: 'application/json',\n\ttext: 'text/*',\n\tformData: 'multipart/form-data',\n\tarrayBuffer: '*/*',\n\tblob: '*/*',\n} as const;\n\n// The maximum value of a 32bit int (see issue #117)\nexport const maxSafeTimeout = 2_147_483_647;\n\nexport const stop = Symbol('stop');\n\nexport const kyOptionKeys: KyOptionsRegistry = {\n\tjson: true,\n\tparseJson: true,\n\tsearchParams: true,\n\tprefixUrl: true,\n\tretry: true,\n\ttimeout: true,\n\thooks: true,\n\tthrowHttpErrors: true,\n\tonDownloadProgress: true,\n\tfetch: true,\n};\n\nexport const requestOptionsRegistry: RequestInitRegistry = {\n\tmethod: true,\n\theaders: true,\n\tbody: true,\n\tmode: true,\n\tcredentials: true,\n\tcache: true,\n\tredirect: true,\n\treferrer: true,\n\treferrerPolicy: true,\n\tintegrity: true,\n\tkeepalive: true,\n\tsignal: true,\n\twindow: true,\n\tdispatcher: true,\n\tduplex: true,\n};\n","import {requestMethods} from '../core/constants.js';\nimport type {HttpMethod} from '../types/options.js';\nimport type {RetryOptions} from '../types/retry.js';\n\nexport const normalizeRequestMethod = (input: string): string =>\n\trequestMethods.includes(input as HttpMethod) ? input.toUpperCase() : input;\n\nconst retryMethods = ['get', 'put', 'head', 'delete', 'options', 'trace'];\n\nconst retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];\n\nconst retryAfterStatusCodes = [413, 429, 503];\n\nconst defaultRetryOptions: Required<RetryOptions> = {\n\tlimit: 2,\n\tmethods: retryMethods,\n\tstatusCodes: retryStatusCodes,\n\tafterStatusCodes: retryAfterStatusCodes,\n\tmaxRetryAfter: Number.POSITIVE_INFINITY,\n\tbackoffLimit: Number.POSITIVE_INFINITY,\n\tdelay: attemptCount => 0.3 * (2 ** (attemptCount - 1)) * 1000,\n};\n\nexport const normalizeRetryOptions = (retry: number | RetryOptions = {}): Required<RetryOptions> => {\n\tif (typeof retry === 'number') {\n\t\treturn {\n\t\t\t...defaultRetryOptions,\n\t\t\tlimit: retry,\n\t\t};\n\t}\n\n\tif (retry.methods && !Array.isArray(retry.methods)) {\n\t\tthrow new Error('retry.methods must be an array');\n\t}\n\n\tif (retry.statusCodes && !Array.isArray(retry.statusCodes)) {\n\t\tthrow new Error('retry.statusCodes must be an array');\n\t}\n\n\treturn {\n\t\t...defaultRetryOptions,\n\t\t...retry,\n\t\tafterStatusCodes: retryAfterStatusCodes,\n\t};\n};\n","import {TimeoutError} from '../errors/TimeoutError.js';\n\nexport type TimeoutOptions = {\n\ttimeout: number;\n\tfetch: typeof fetch;\n};\n\n// `Promise.race()` workaround (#91)\nexport default async function timeout(\n\trequest: Request,\n\tinit: RequestInit,\n\tabortController: AbortController | undefined,\n\toptions: TimeoutOptions,\n): Promise<Response> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tif (abortController) {\n\t\t\t\tabortController.abort();\n\t\t\t}\n\n\t\t\treject(new TimeoutError(request));\n\t\t}, options.timeout);\n\n\t\tvoid options\n\t\t\t.fetch(request, init)\n\t\t\t.then(resolve)\n\t\t\t.catch(reject)\n\t\t\t.then(() => {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t});\n\t});\n}\n","// https://github.com/sindresorhus/delay/tree/ab98ae8dfcb38e1593286c94d934e70d14a4e111\n\nimport {type InternalOptions} from '../types/options.js';\n\nexport type DelayOptions = {\n\tsignal?: InternalOptions['signal'];\n};\n\nexport default async function delay(\n\tms: number,\n\t{signal}: DelayOptions,\n): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal) {\n\t\t\tsignal.throwIfAborted();\n\t\t\tsignal.addEventListener('abort', abortHandler, {once: true});\n\t\t}\n\n\t\tfunction abortHandler() {\n\t\t\tclearTimeout(timeoutId);\n\t\t\treject(signal!.reason);\n\t\t}\n\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tsignal?.removeEventListener('abort', abortHandler);\n\t\t\tresolve();\n\t\t}, ms);\n\t});\n}\n","import {kyOptionKeys, requestOptionsRegistry} from '../core/constants.js';\n\nexport const findUnknownOptions = (\n\trequest: Request,\n\toptions: Record<string, unknown>,\n): Record<string, unknown> => {\n\tconst unknownOptions: Record<string, unknown> = {};\n\n\tfor (const key in options) {\n\t\tif (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && !(key in request)) {\n\t\t\tunknownOptions[key] = options[key];\n\t\t}\n\t}\n\n\treturn unknownOptions;\n};\n","import {HTTPError} from '../errors/HTTPError.js';\nimport {TimeoutError} from '../errors/TimeoutError.js';\nimport type {Hooks} from '../types/hooks.js';\nimport type {Input, InternalOptions, NormalizedOptions, Options, SearchParamsInit} from '../types/options.js';\nimport {type ResponsePromise} from '../types/ResponsePromise.js';\nimport {deepMerge, mergeHeaders} from '../utils/merge.js';\nimport {normalizeRequestMethod, normalizeRetryOptions} from '../utils/normalize.js';\nimport timeout, {type TimeoutOptions} from '../utils/timeout.js';\nimport delay from '../utils/delay.js';\nimport {type ObjectEntries} from '../utils/types.js';\nimport {findUnknownOptions} from '../utils/options.js';\nimport {\n\tmaxSafeTimeout,\n\tresponseTypes,\n\tstop,\n\tsupportsAbortController,\n\tsupportsFormData,\n\tsupportsResponseStreams,\n\tsupportsRequestStreams,\n} from './constants.js';\n\nexport class Ky {\n\tstatic create(input: Input, options: Options): ResponsePromise {\n\t\tconst ky = new Ky(input, options);\n\n\t\tconst fn = async (): Promise<Response> => {\n\t\t\tif (typeof ky._options.timeout === 'number' && ky._options.timeout > maxSafeTimeout) {\n\t\t\t\tthrow new RangeError(`The \\`timeout\\` option cannot be greater than ${maxSafeTimeout}`);\n\t\t\t}\n\n\t\t\t// Delay the fetch so that body method shortcuts can set the Accept header\n\t\t\tawait Promise.resolve();\n\t\t\tlet response = await ky._fetch();\n\n\t\t\tfor (const hook of ky._options.hooks.afterResponse) {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\tconst modifiedResponse = await hook(\n\t\t\t\t\tky.request,\n\t\t\t\t\tky._options as NormalizedOptions,\n\t\t\t\t\tky._decorateResponse(response.clone()),\n\t\t\t\t);\n\n\t\t\t\tif (modifiedResponse instanceof globalThis.Response) {\n\t\t\t\t\tresponse = modifiedResponse;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tky._decorateResponse(response);\n\n\t\t\tif (!response.ok && ky._options.throwHttpErrors) {\n\t\t\t\tlet error = new HTTPError(response, ky.request, (ky._options as unknown) as NormalizedOptions);\n\n\t\t\t\tfor (const hook of ky._options.hooks.beforeError) {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\terror = await hook(error);\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\t// If `onDownloadProgress` is passed, it uses the stream API internally\n\t\t\t/* istanbul ignore next */\n\t\t\tif (ky._options.onDownloadProgress) {\n\t\t\t\tif (typeof ky._options.onDownloadProgress !== 'function') {\n\t\t\t\t\tthrow new TypeError('The `onDownloadProgress` option must be a function');\n\t\t\t\t}\n\n\t\t\t\tif (!supportsResponseStreams) {\n\t\t\t\t\tthrow new Error('Streams are not supported in your environment. `ReadableStream` is missing.');\n\t\t\t\t}\n\n\t\t\t\treturn ky._stream(response.clone(), ky._options.onDownloadProgress);\n\t\t\t}\n\n\t\t\treturn response;\n\t\t};\n\n\t\tconst isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase());\n\t\tconst result = (isRetriableMethod ? ky._retry(fn) : fn()) as ResponsePromise;\n\n\t\tfor (const [type, mimeType] of Object.entries(responseTypes) as ObjectEntries<typeof responseTypes>) {\n\t\t\tresult[type] = async () => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\t\tky.request.headers.set('accept', ky.request.headers.get('accept') || mimeType);\n\n\t\t\t\tconst awaitedResult = await result;\n\t\t\t\tconst response = awaitedResult.clone();\n\n\t\t\t\tif (type === 'json') {\n\t\t\t\t\tif (response.status === 204) {\n\t\t\t\t\t\treturn '';\n\t\t\t\t\t}\n\n\t\t\t\t\tconst arrayBuffer = await response.clone().arrayBuffer();\n\t\t\t\t\tconst responseSize = arrayBuffer.byteLength;\n\t\t\t\t\tif (responseSize === 0) {\n\t\t\t\t\t\treturn '';\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.parseJson) {\n\t\t\t\t\t\treturn options.parseJson(await response.text());\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn response[type]();\n\t\t\t};\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tpublic request: Request;\n\tprotected abortController?: AbortController;\n\tprotected _retryCount = 0;\n\tprotected _input: Input;\n\tprotected _options: InternalOptions;\n\n\t// eslint-disable-next-line complexity\n\tconstructor(input: Input, options: Options = {}) {\n\t\tthis._input = input;\n\t\tthis._options = {\n\t\t\t// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208\n\t\t\tcredentials: (this._input as Request).credentials || 'same-origin',\n\t\t\t...options,\n\t\t\theaders: mergeHeaders((this._input as Request).headers, options.headers),\n\t\t\thooks: deepMerge<Required<Hooks>>(\n\t\t\t\t{\n\t\t\t\t\tbeforeRequest: [],\n\t\t\t\t\tbeforeRetry: [],\n\t\t\t\t\tbeforeError: [],\n\t\t\t\t\tafterResponse: [],\n\t\t\t\t},\n\t\t\t\toptions.hooks,\n\t\t\t),\n\t\t\tmethod: normalizeRequestMethod(options.method ?? (this._input as Request).method),\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\tprefixUrl: String(options.prefixUrl || ''),\n\t\t\tretry: normalizeRetryOptions(options.retry),\n\t\t\tthrowHttpErrors: options.throwHttpErrors !== false,\n\t\t\ttimeout: options.timeout ?? 10_000,\n\t\t\tfetch: options.fetch ?? globalThis.fetch.bind(globalThis),\n\t\t};\n\n\t\tif (typeof this._input !== 'string' && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {\n\t\t\tthrow new TypeError('`input` must be a string, URL, or Request');\n\t\t}\n\n\t\tif (this._options.prefixUrl && typeof this._input === 'string') {\n\t\t\tif (this._input.startsWith('/')) {\n\t\t\t\tthrow new Error('`input` must not begin with a slash when using `prefixUrl`');\n\t\t\t}\n\n\t\t\tif (!this._options.prefixUrl.endsWith('/')) {\n\t\t\t\tthis._options.prefixUrl += '/';\n\t\t\t}\n\n\t\t\tthis._input = this._options.prefixUrl + this._input;\n\t\t}\n\n\t\tif (supportsAbortController) {\n\t\t\tthis.abortController = new globalThis.AbortController();\n\t\t\tif (this._options.signal) {\n\t\t\t\tconst originalSignal = this._options.signal;\n\n\t\t\t\tthis._options.signal.addEventListener('abort', () => {\n\t\t\t\t\tthis.abortController!.abort(originalSignal.reason);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tthis._options.signal = this.abortController.signal;\n\t\t}\n\n\t\tif (supportsRequestStreams) {\n\t\t\t// @ts-expect-error - Types are outdated.\n\t\t\tthis._options.duplex = 'half';\n\t\t}\n\n\t\tthis.request = new globalThis.Request(this._input as RequestInfo, this._options as RequestInit);\n\n\t\tif (this._options.searchParams) {\n\t\t\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\t\t\tconst textSearchParams = typeof this._options.searchParams === 'string'\n\t\t\t\t? this._options.searchParams.replace(/^\\?/, '')\n\t\t\t\t: new URLSearchParams(this._options.searchParams as unknown as SearchParamsInit).toString();\n\t\t\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\t\t\tconst searchParams = '?' + textSearchParams;\n\t\t\tconst url = this.request.url.replace(/(?:\\?.*?)?(?=#|$)/, searchParams);\n\n\t\t\t// To provide correct form boundary, Content-Type header should be deleted each time when new Request instantiated from another one\n\t\t\tif (\n\t\t\t\t((supportsFormData && this._options.body instanceof globalThis.FormData)\n\t\t\t\t\t|| this._options.body instanceof URLSearchParams) && !(this._options.headers && (this._options.headers as Record<string, string>)['content-type'])\n\t\t\t) {\n\t\t\t\tthis.request.headers.delete('content-type');\n\t\t\t}\n\n\t\t\t// The spread of `this.request` is required as otherwise it misses the `duplex` option for some reason and throws.\n\t\t\tthis.request = new globalThis.Request(new globalThis.Request(url, {...this.request}), this._options as RequestInit);\n\t\t}\n\n\t\tif (this._options.json !== undefined) {\n\t\t\tthis._options.body = JSON.stringify(this._options.json);\n\t\t\tthis.request.headers.set('content-type', this._options.headers.get('content-type') ?? 'application/json');\n\t\t\tthis.request = new globalThis.Request(this.request, {body: this._options.body});\n\t\t}\n\t}\n\n\tprotected _calculateRetryDelay(error: unknown) {\n\t\tthis._retryCount++;\n\n\t\tif (this._retryCount < this._options.retry.limit && !(error instanceof TimeoutError)) {\n\t\t\tif (error instanceof HTTPError) {\n\t\t\t\tif (!this._options.retry.statusCodes.includes(error.response.status)) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\n\t\t\t\tconst retryAfter = error.response.headers.get('Retry-After');\n\t\t\t\tif (retryAfter && this._options.retry.afterStatusCodes.includes(error.response.status)) {\n\t\t\t\t\tlet after = Number(retryAfter);\n\t\t\t\t\tif (Number.isNaN(after)) {\n\t\t\t\t\t\tafter = Date.parse(retryAfter) - Date.now();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tafter *= 1000;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._options.retry.maxRetryAfter !== undefined && after > this._options.retry.maxRetryAfter) {\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn after;\n\t\t\t\t}\n\n\t\t\t\tif (error.response.status === 413) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst retryDelay = this._options.retry.delay(this._retryCount);\n\t\t\treturn Math.min(this._options.retry.backoffLimit, retryDelay);\n\t\t}\n\n\t\treturn 0;\n\t}\n\n\tprotected _decorateResponse(response: Response): Response {\n\t\tif (this._options.parseJson) {\n\t\t\tresponse.json = async () => this._options.parseJson!(await response.text());\n\t\t}\n\n\t\treturn response;\n\t}\n\n\tprotected async _retry<T extends (...args: any) => Promise<any>>(fn: T): Promise<ReturnType<T> | void> {\n\t\ttry {\n\t\t\treturn await fn();\n\t\t} catch (error) {\n\t\t\tconst ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);\n\t\t\tif (ms !== 0 && this._retryCount > 0) {\n\t\t\t\tawait delay(ms, {signal: this._options.signal});\n\n\t\t\t\tfor (const hook of this._options.hooks.beforeRetry) {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\tconst hookResult = await hook({\n\t\t\t\t\t\trequest: this.request,\n\t\t\t\t\t\toptions: (this._options as unknown) as NormalizedOptions,\n\t\t\t\t\t\terror: error as Error,\n\t\t\t\t\t\tretryCount: this._retryCount,\n\t\t\t\t\t});\n\n\t\t\t\t\t// If `stop` is returned from the hook, the retry process is stopped\n\t\t\t\t\tif (hookResult === stop) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn this._retry(fn);\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprotected async _fetch(): Promise<Response> {\n\t\tfor (const hook of this._options.hooks.beforeRequest) {\n\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\tconst result = await hook(this.request, (this._options as unknown) as NormalizedOptions);\n\n\t\t\tif (result instanceof Request) {\n\t\t\t\tthis.request = result;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (result instanceof Response) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\n\t\tconst nonRequestOptions = findUnknownOptions(this.request, this._options);\n\n\t\tif (this._options.timeout === false) {\n\t\t\treturn this._options.fetch(this.request.clone(), nonRequestOptions);\n\t\t}\n\n\t\treturn timeout(this.request.clone(), nonRequestOptions, this.abortController, this._options as TimeoutOptions);\n\t}\n\n\t/* istanbul ignore next */\n\tprotected _stream(response: Response, onDownloadProgress: Options['onDownloadProgress']) {\n\t\tconst totalBytes = Number(response.headers.get('content-length')) || 0;\n\t\tlet transferredBytes = 0;\n\n\t\tif (response.status === 204) {\n\t\t\tif (onDownloadProgress) {\n\t\t\t\tonDownloadProgress({percent: 1, totalBytes, transferredBytes}, new Uint8Array());\n\t\t\t}\n\n\t\t\treturn new globalThis.Response(\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\tstatus: response.status,\n\t\t\t\t\tstatusText: response.statusText,\n\t\t\t\t\theaders: response.headers,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\treturn new globalThis.Response(\n\t\t\tnew globalThis.ReadableStream({\n\t\t\t\tasync start(controller) {\n\t\t\t\t\tconst reader = response.body!.getReader();\n\n\t\t\t\t\tif (onDownloadProgress) {\n\t\t\t\t\t\tonDownloadProgress({percent: 0, transferredBytes: 0, totalBytes}, new Uint8Array());\n\t\t\t\t\t}\n\n\t\t\t\t\tasync function read() {\n\t\t\t\t\t\tconst {done, value} = await reader.read();\n\t\t\t\t\t\tif (done) {\n\t\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (onDownloadProgress) {\n\t\t\t\t\t\t\ttransferredBytes += value.byteLength;\n\t\t\t\t\t\t\tconst percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;\n\t\t\t\t\t\t\tonDownloadProgress({percent, transferredBytes, totalBytes}, value);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontroller.enqueue(value);\n\t\t\t\t\t\tawait read();\n\t\t\t\t\t}\n\n\t\t\t\t\tawait read();\n\t\t\t\t},\n\t\t\t}),\n\t\t\t{\n\t\t\t\tstatus: response.status,\n\t\t\t\tstatusText: response.statusText,\n\t\t\t\theaders: response.headers,\n\t\t\t},\n\t\t);\n\t}\n}\n","/*! MIT License © Sindre Sorhus */\n\nimport {Ky} from './core/Ky.js';\nimport {requestMethods, stop} from './core/constants.js';\nimport type {KyInstance} from './types/ky.js';\nimport type {Input, Options} from './types/options.js';\nimport {validateAndMerge} from './utils/merge.js';\nimport {type Mutable} from './utils/types.js';\n\nconst createInstance = (defaults?: Partial<Options>): KyInstance => {\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\tconst ky: Partial<Mutable<KyInstance>> = (input: Input, options?: Options) => Ky.create(input, validateAndMerge(defaults, options));\n\n\tfor (const method of requestMethods) {\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\tky[method] = (input: Input, options?: Options) => Ky.create(input, validateAndMerge(defaults, options, {method}));\n\t}\n\n\tky.create = (newDefaults?: Partial<Options>) => createInstance(validateAndMerge(newDefaults));\n\tky.extend = (newDefaults?: Partial<Options>) => createInstance(validateAndMerge(defaults, newDefaults));\n\tky.stop = stop;\n\n\treturn ky as KyInstance;\n};\n\nconst ky = createInstance();\n\nexport default ky;\n\nexport type {KyInstance} from './types/ky.js';\n\nexport type {\n\tOptions,\n\tNormalizedOptions,\n\tRetryOptions,\n\tSearchParamsOption,\n\tDownloadProgress,\n} from './types/options.js';\n\nexport type {\n\tHooks,\n\tBeforeRequestHook,\n\tBeforeRetryHook,\n\tBeforeRetryState,\n\tBeforeErrorHook,\n\tAfterResponseHook,\n} from './types/hooks.js';\n\nexport type {ResponsePromise} from './types/ResponsePromise.js';\nexport type {KyResponse} from './types/response.js';\nexport {HTTPError} from './errors/HTTPError.js';\nexport {TimeoutError} from './errors/TimeoutError.js';\n","{\n \"name\": \"bannerify-js\",\n \"version\": \"0.0.16\",\n \"description\": \"\",\n \"type\": \"module\",\n \"main\": \"dist/index.js\",\n \"module\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"scripts\": {\n \"test\": \"bun test\",\n \"play\": \"tsx playground/test.ts\",\n \"openapi\": \"openapi-typescript https://api-beta.bannerify.co/openapi -o ./src/openapi.d.ts\",\n \"openapi-local\": \"openapi-typescript http://127.0.0.1:5173/api/openapi -o ./src/openapi.d.ts\",\n \"build:watch\": \"tsup --watch\",\n \"build\": \"tsup\"\n },\n \"exports\": {\n \".\": {\n \"require\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"keywords\": [],\n \"files\": [\n \"dist\"\n ],\n \"author\": \"Duc An <an@bannerify.co>\",\n \"license\": \"ISC\",\n \"devDependencies\": {\n \"@faker-js/faker\": \"^8.4.1\",\n \"@types/node\": \"18.15.3\",\n \"bun-types\": \"^1.0.20\",\n \"chart.js\": \"^4.4.1\",\n \"ky\": \"^1.1.3\",\n \"openapi-typescript\": \"^6.7.3\",\n \"tsup\": \"^8.0.1\",\n \"tsx\": \"^4.7.0\",\n \"typescript\": \"5.2.2\"\n }\n}\n","import { version } from '../package.json'\n\nexport type Telemetry = {\n sdkVersions: string[];\n platform?: string;\n runtime?: string;\n};\n\nexport function getTelemetry(): Telemetry | null {\n let platform: string | undefined\n let runtime: string | undefined\n const sdkVersions = [`bannerify-js@${version}`]\n\n try {\n if (process?.env?.UNKEY_DISABLE_TELEMETRY) {\n return null\n }\n platform = process.env.VERCEL ? 'vercel' : process.env.AWS_REGION ? 'aws' : undefined\n\n // @ts-ignore\n if (typeof EdgeRuntime !== 'undefined') {\n runtime = 'edge-light'\n } else if (typeof caches !== 'undefined') {\n runtime = 'cloudflare'\n } else if (process?.version) {\n runtime = `node@${process.version}`\n } else {\n runtime = 'fetch-compatible'\n }\n\n } catch (_error) {\n }\n\n return { platform, runtime, sdkVersions }\n}","import { paths } from './openapi'\n\ntype codes = '400' | '401' | '403' | '404' | '500';\n\nexport type ErrorResponse =\n paths['/v1/liveness']['get']['responses'][codes]['content']['application/json'];\n\nexport const timeoutError = {\n error: {\n // @ts-ignore\n code: 'TIMEOUT_ERROR',\n message: 'No response',\n docs: '',\n requestId: 'N/A',\n },\n}\n\nexport type Result<R> =\n | {\n result: R;\n error?: never;\n}\n | {\n result?: never;\n error: ErrorResponse['error'] | typeof timeoutError;\n};","import ky, { HTTPError, TimeoutError } from 'ky'\nimport { getTelemetry } from './telemetry'\nimport { Modification } from './interface'\nimport { ErrorResponse, Result, timeoutError } from './types'\n\ninterface Options {\n apiKey: string\n fetch?: typeof fetch\n baseUrl?: string\n // default 10s\n timeout?: number\n}\n\ntype CreateOptions = {\n modifications?: Modification[]\n // template?: Modification\n // @default: png\n format?: 'svg' | 'png'\n}\n\nexport function createClient(apiKey: string, opts?: Options) {\n return new Bannerify(apiKey, opts)\n}\n\nexport class Bannerify {\n private readonly client: typeof ky\n\n private readonly baseUrl: string\n\n constructor(\n private readonly apiKey: string,\n private readonly opts?: Options\n ) {\n const telemetry = getTelemetry()\n this.baseUrl = opts?.baseUrl || 'https://api-beta.bannerify.co/v1'\n this.client = ky.create({\n fetch: opts?.fetch || fetch,\n prefixUrl: this.baseUrl,\n headers: {\n Authorization: `Bearer ${apiKey}`,\n 'X-SDK-Version': `${telemetry?.sdkVersions}`,\n 'X-Platform': telemetry?.platform,\n 'X-Runtime': telemetry?.runtime,\n },\n timeout: opts?.timeout ?? 10e3,\n })\n }\n\n async createImage(\n templateId: string,\n options?: CreateOptions,\n ): Promise<Result<ArrayBuffer | string>> {\n try {\n const res = this.client.get('templates/createImage', {\n json: {\n modifications: options?.modifications ?? [],\n // template: JSON.stringify(options?.template ?? {}),\n templateId,\n apiKey: this.apiKey,\n format: options?.format as string,\n },\n })\n if (options?.format === 'svg') {\n return { result: await res.text() }\n }\n return { result: await res.arrayBuffer() }\n } catch (e: any) {\n if (e instanceof HTTPError) {\n return await e.response.json() as ErrorResponse\n }\n if (e instanceof TimeoutError) {\n return timeoutError as ErrorResponse\n }\n throw e\n }\n }\n\n async createPdf(\n templateId: string,\n options?: CreateOptions,\n ) {\n throw new Error('Not yet implemented')\n }\n\n async createPermanentImage() {\n throw new Error('Not yet implemented')\n }\n\n #hashText = async (text: string) => {\n const myText = new TextEncoder().encode(text)\n const myDigest = await crypto.subtle.digest({ name: 'SHA-256' }, myText)\n const hashArray = Array.from(new Uint8Array(myDigest))\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')\n return hashHex\n }\n\n async generateImageSignedUrl(\n templateId: string,\n options?: CreateOptions,\n ) {\n const apiKeyAsMd5 = await this.#hashText(this.apiKey)\n const searchParams = new URLSearchParams()\n searchParams.set('apiKeyMd5', apiKeyAsMd5)\n if (options?.format === 'svg') {\n searchParams.set('format', 'svg')\n }\n if (options?.modifications) {\n searchParams.set('modifications', JSON.stringify(options?.modifications))\n }\n searchParams.set('templateId', templateId)\n searchParams.sort()\n // TODO update to this.opts.apiKey\n searchParams.set('sign', await this.#hashText(searchParams.toString() + searchParams.get('apiKeyMd5')))\n return `${this.baseUrl}/templates/signedurl?${searchParams.toString()}`\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGM,IAAO,YAAP,cAAyB,MAAK;EAKnC,YAAY,UAAoB,SAAkB,SAA0B;AAC3E,UAAM,OAAQ,SAAS,UAAU,SAAS,WAAW,IAAK,SAAS,SAAS;AAC5E,UAAM,QAAQ,SAAS,cAAc;AACrC,UAAM,SAAS,GAAG,IAAI,IAAI,KAAK,GAAG,KAAI;AACtC,UAAM,SAAS,SAAS,eAAe,MAAM,KAAK;AAElD,UAAM,uBAAuB,MAAM,EAAE;AAV/B,WAAA,eAAA,MAAA,YAAA;;;;;;AACA,WAAA,eAAA,MAAA,WAAA;;;;;;AACA,WAAA,eAAA,MAAA,WAAA;;;;;;AAUN,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AO,OAAO,OAAO,EAAE,MAAM,UAAU,GAAG,MAAM;AACvE,UAAM,YAAY,MAAM,KAAK,IAAI,WAAW,QAAQ,CAAC;AACrD,UAAM,UAAU,UAAU,IAAI,OAAK,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AAC3E,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,uBACJ,YACA,SACA;AACA,UAAM,cAAc,MAAM,KAAK,UAAU,KAAK,MAAM;AACpD,UAAM,eAAe,IAAI,gBAAgB;AACzC,iBAAa,IAAI,aAAa,WAAW;AACzC,QAAI,SAAS,WAAW,OAAO;AAC7B,mBAAa,IAAI,UAAU,KAAK;AAAA,IAClC;AACA,QAAI,SAAS,eAAe;AAC1B,mBAAa,IAAI,iBAAiB,KAAK,UAAU,SAAS,aAAa,CAAC;AAAA,IAC1E;AACA,iBAAa,IAAI,cAAc,UAAU;AACzC,iBAAa,KAAK;AAElB,iBAAa,IAAI,QAAQ,MAAM,KAAK,UAAU,aAAa,SAAS,IAAI,aAAa,IAAI,WAAW,CAAC,CAAC;AACtG,WAAO,GAAG,KAAK,OAAO,wBAAwB,aAAa,SAAS,CAAC;AAAA,EACvE;AACF;","names":["ky","ky"]}
1
+ {"version":3,"sources":["../src/index.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/errors/HTTPError.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/errors/TimeoutError.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/is.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/merge.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/core/constants.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/normalize.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/timeout.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/delay.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/options.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/core/Ky.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/index.ts","../package.json","../src/telemetry.ts","../src/types.ts","../src/client.ts"],"sourcesContent":["export * from './client'\nexport type { Modification } from './interface'","import type {NormalizedOptions} from '../types/options.js';\n\n// eslint-lint-disable-next-line @typescript-eslint/naming-convention\nexport class HTTPError extends Error {\n\tpublic response: Response;\n\tpublic request: Request;\n\tpublic options: NormalizedOptions;\n\n\tconstructor(response: Response, request: Request, options: NormalizedOptions) {\n\t\tconst code = (response.status || response.status === 0) ? response.status : '';\n\t\tconst title = response.statusText || '';\n\t\tconst status = `${code} ${title}`.trim();\n\t\tconst reason = status ? `status code ${status}` : 'an unknown error';\n\n\t\tsuper(`Request failed with ${reason}`);\n\n\t\tthis.name = 'HTTPError';\n\t\tthis.response = response;\n\t\tthis.request = request;\n\t\tthis.options = options;\n\t}\n}\n","export class TimeoutError extends Error {\n\tpublic request: Request;\n\n\tconstructor(request: Request) {\n\t\tsuper('Request timed out');\n\t\tthis.name = 'TimeoutError';\n\t\tthis.request = request;\n\t}\n}\n","// eslint-disable-next-line @typescript-eslint/ban-types\nexport const isObject = (value: unknown): value is object => value !== null && typeof value === 'object';\n","import type {KyHeadersInit, Options} from '../types/options.js';\nimport {isObject} from './is.js';\n\nexport const validateAndMerge = (...sources: Array<Partial<Options> | undefined>): Partial<Options> => {\n\tfor (const source of sources) {\n\t\tif ((!isObject(source) || Array.isArray(source)) && source !== undefined) {\n\t\t\tthrow new TypeError('The `options` argument must be an object');\n\t\t}\n\t}\n\n\treturn deepMerge({}, ...sources);\n};\n\nexport const mergeHeaders = (source1: KyHeadersInit = {}, source2: KyHeadersInit = {}) => {\n\tconst result = new globalThis.Headers(source1 as HeadersInit);\n\tconst isHeadersInstance = source2 instanceof globalThis.Headers;\n\tconst source = new globalThis.Headers(source2 as HeadersInit);\n\n\tfor (const [key, value] of source.entries()) {\n\t\tif ((isHeadersInstance && value === 'undefined') || value === undefined) {\n\t\t\tresult.delete(key);\n\t\t} else {\n\t\t\tresult.set(key, value);\n\t\t}\n\t}\n\n\treturn result;\n};\n\n// TODO: Make this strongly-typed (no `any`).\nexport const deepMerge = <T>(...sources: Array<Partial<T> | undefined>): T => {\n\tlet returnValue: any = {};\n\tlet headers = {};\n\n\tfor (const source of sources) {\n\t\tif (Array.isArray(source)) {\n\t\t\tif (!Array.isArray(returnValue)) {\n\t\t\t\treturnValue = [];\n\t\t\t}\n\n\t\t\treturnValue = [...returnValue, ...source];\n\t\t} else if (isObject(source)) {\n\t\t\tfor (let [key, value] of Object.entries(source)) {\n\t\t\t\tif (isObject(value) && key in returnValue) {\n\t\t\t\t\tvalue = deepMerge(returnValue[key], value);\n\t\t\t\t}\n\n\t\t\t\treturnValue = {...returnValue, [key]: value};\n\t\t\t}\n\n\t\t\tif (isObject((source as any).headers)) {\n\t\t\t\theaders = mergeHeaders(headers, (source as any).headers);\n\t\t\t\treturnValue.headers = headers;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn returnValue;\n};\n","import type {Expect, Equal} from '@type-challenges/utils';\nimport {type HttpMethod, type KyOptionsRegistry} from '../types/options.js';\nimport {type RequestInitRegistry} from '../types/request.js';\n\nexport const supportsRequestStreams = (() => {\n\tlet duplexAccessed = false;\n\tlet hasContentType = false;\n\tconst supportsReadableStream = typeof globalThis.ReadableStream === 'function';\n\tconst supportsRequest = typeof globalThis.Request === 'function';\n\n\tif (supportsReadableStream && supportsRequest) {\n\t\thasContentType = new globalThis.Request('https://empty.invalid', {\n\t\t\tbody: new globalThis.ReadableStream(),\n\t\t\tmethod: 'POST',\n\t\t\t// @ts-expect-error - Types are outdated.\n\t\t\tget duplex() {\n\t\t\t\tduplexAccessed = true;\n\t\t\t\treturn 'half';\n\t\t\t},\n\t\t}).headers.has('Content-Type');\n\t}\n\n\treturn duplexAccessed && !hasContentType;\n})();\n\nexport const supportsAbortController = typeof globalThis.AbortController === 'function';\nexport const supportsResponseStreams = typeof globalThis.ReadableStream === 'function';\nexport const supportsFormData = typeof globalThis.FormData === 'function';\n\nexport const requestMethods = ['get', 'post', 'put', 'patch', 'head', 'delete'] as const;\n\nconst validate = <T extends Array<true>>() => undefined as unknown as T;\nvalidate<[\n\tExpect<Equal<typeof requestMethods[number], HttpMethod>>,\n]>();\n\nexport const responseTypes = {\n\tjson: 'application/json',\n\ttext: 'text/*',\n\tformData: 'multipart/form-data',\n\tarrayBuffer: '*/*',\n\tblob: '*/*',\n} as const;\n\n// The maximum value of a 32bit int (see issue #117)\nexport const maxSafeTimeout = 2_147_483_647;\n\nexport const stop = Symbol('stop');\n\nexport const kyOptionKeys: KyOptionsRegistry = {\n\tjson: true,\n\tparseJson: true,\n\tsearchParams: true,\n\tprefixUrl: true,\n\tretry: true,\n\ttimeout: true,\n\thooks: true,\n\tthrowHttpErrors: true,\n\tonDownloadProgress: true,\n\tfetch: true,\n};\n\nexport const requestOptionsRegistry: RequestInitRegistry = {\n\tmethod: true,\n\theaders: true,\n\tbody: true,\n\tmode: true,\n\tcredentials: true,\n\tcache: true,\n\tredirect: true,\n\treferrer: true,\n\treferrerPolicy: true,\n\tintegrity: true,\n\tkeepalive: true,\n\tsignal: true,\n\twindow: true,\n\tdispatcher: true,\n\tduplex: true,\n};\n","import {requestMethods} from '../core/constants.js';\nimport type {HttpMethod} from '../types/options.js';\nimport type {RetryOptions} from '../types/retry.js';\n\nexport const normalizeRequestMethod = (input: string): string =>\n\trequestMethods.includes(input as HttpMethod) ? input.toUpperCase() : input;\n\nconst retryMethods = ['get', 'put', 'head', 'delete', 'options', 'trace'];\n\nconst retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];\n\nconst retryAfterStatusCodes = [413, 429, 503];\n\nconst defaultRetryOptions: Required<RetryOptions> = {\n\tlimit: 2,\n\tmethods: retryMethods,\n\tstatusCodes: retryStatusCodes,\n\tafterStatusCodes: retryAfterStatusCodes,\n\tmaxRetryAfter: Number.POSITIVE_INFINITY,\n\tbackoffLimit: Number.POSITIVE_INFINITY,\n\tdelay: attemptCount => 0.3 * (2 ** (attemptCount - 1)) * 1000,\n};\n\nexport const normalizeRetryOptions = (retry: number | RetryOptions = {}): Required<RetryOptions> => {\n\tif (typeof retry === 'number') {\n\t\treturn {\n\t\t\t...defaultRetryOptions,\n\t\t\tlimit: retry,\n\t\t};\n\t}\n\n\tif (retry.methods && !Array.isArray(retry.methods)) {\n\t\tthrow new Error('retry.methods must be an array');\n\t}\n\n\tif (retry.statusCodes && !Array.isArray(retry.statusCodes)) {\n\t\tthrow new Error('retry.statusCodes must be an array');\n\t}\n\n\treturn {\n\t\t...defaultRetryOptions,\n\t\t...retry,\n\t\tafterStatusCodes: retryAfterStatusCodes,\n\t};\n};\n","import {TimeoutError} from '../errors/TimeoutError.js';\n\nexport type TimeoutOptions = {\n\ttimeout: number;\n\tfetch: typeof fetch;\n};\n\n// `Promise.race()` workaround (#91)\nexport default async function timeout(\n\trequest: Request,\n\tinit: RequestInit,\n\tabortController: AbortController | undefined,\n\toptions: TimeoutOptions,\n): Promise<Response> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tif (abortController) {\n\t\t\t\tabortController.abort();\n\t\t\t}\n\n\t\t\treject(new TimeoutError(request));\n\t\t}, options.timeout);\n\n\t\tvoid options\n\t\t\t.fetch(request, init)\n\t\t\t.then(resolve)\n\t\t\t.catch(reject)\n\t\t\t.then(() => {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t});\n\t});\n}\n","// https://github.com/sindresorhus/delay/tree/ab98ae8dfcb38e1593286c94d934e70d14a4e111\n\nimport {type InternalOptions} from '../types/options.js';\n\nexport type DelayOptions = {\n\tsignal?: InternalOptions['signal'];\n};\n\nexport default async function delay(\n\tms: number,\n\t{signal}: DelayOptions,\n): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal) {\n\t\t\tsignal.throwIfAborted();\n\t\t\tsignal.addEventListener('abort', abortHandler, {once: true});\n\t\t}\n\n\t\tfunction abortHandler() {\n\t\t\tclearTimeout(timeoutId);\n\t\t\treject(signal!.reason);\n\t\t}\n\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tsignal?.removeEventListener('abort', abortHandler);\n\t\t\tresolve();\n\t\t}, ms);\n\t});\n}\n","import {kyOptionKeys, requestOptionsRegistry} from '../core/constants.js';\n\nexport const findUnknownOptions = (\n\trequest: Request,\n\toptions: Record<string, unknown>,\n): Record<string, unknown> => {\n\tconst unknownOptions: Record<string, unknown> = {};\n\n\tfor (const key in options) {\n\t\tif (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && !(key in request)) {\n\t\t\tunknownOptions[key] = options[key];\n\t\t}\n\t}\n\n\treturn unknownOptions;\n};\n","import {HTTPError} from '../errors/HTTPError.js';\nimport {TimeoutError} from '../errors/TimeoutError.js';\nimport type {Hooks} from '../types/hooks.js';\nimport type {Input, InternalOptions, NormalizedOptions, Options, SearchParamsInit} from '../types/options.js';\nimport {type ResponsePromise} from '../types/ResponsePromise.js';\nimport {deepMerge, mergeHeaders} from '../utils/merge.js';\nimport {normalizeRequestMethod, normalizeRetryOptions} from '../utils/normalize.js';\nimport timeout, {type TimeoutOptions} from '../utils/timeout.js';\nimport delay from '../utils/delay.js';\nimport {type ObjectEntries} from '../utils/types.js';\nimport {findUnknownOptions} from '../utils/options.js';\nimport {\n\tmaxSafeTimeout,\n\tresponseTypes,\n\tstop,\n\tsupportsAbortController,\n\tsupportsFormData,\n\tsupportsResponseStreams,\n\tsupportsRequestStreams,\n} from './constants.js';\n\nexport class Ky {\n\tstatic create(input: Input, options: Options): ResponsePromise {\n\t\tconst ky = new Ky(input, options);\n\n\t\tconst fn = async (): Promise<Response> => {\n\t\t\tif (typeof ky._options.timeout === 'number' && ky._options.timeout > maxSafeTimeout) {\n\t\t\t\tthrow new RangeError(`The \\`timeout\\` option cannot be greater than ${maxSafeTimeout}`);\n\t\t\t}\n\n\t\t\t// Delay the fetch so that body method shortcuts can set the Accept header\n\t\t\tawait Promise.resolve();\n\t\t\tlet response = await ky._fetch();\n\n\t\t\tfor (const hook of ky._options.hooks.afterResponse) {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\tconst modifiedResponse = await hook(\n\t\t\t\t\tky.request,\n\t\t\t\t\tky._options as NormalizedOptions,\n\t\t\t\t\tky._decorateResponse(response.clone()),\n\t\t\t\t);\n\n\t\t\t\tif (modifiedResponse instanceof globalThis.Response) {\n\t\t\t\t\tresponse = modifiedResponse;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tky._decorateResponse(response);\n\n\t\t\tif (!response.ok && ky._options.throwHttpErrors) {\n\t\t\t\tlet error = new HTTPError(response, ky.request, (ky._options as unknown) as NormalizedOptions);\n\n\t\t\t\tfor (const hook of ky._options.hooks.beforeError) {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\terror = await hook(error);\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\t// If `onDownloadProgress` is passed, it uses the stream API internally\n\t\t\t/* istanbul ignore next */\n\t\t\tif (ky._options.onDownloadProgress) {\n\t\t\t\tif (typeof ky._options.onDownloadProgress !== 'function') {\n\t\t\t\t\tthrow new TypeError('The `onDownloadProgress` option must be a function');\n\t\t\t\t}\n\n\t\t\t\tif (!supportsResponseStreams) {\n\t\t\t\t\tthrow new Error('Streams are not supported in your environment. `ReadableStream` is missing.');\n\t\t\t\t}\n\n\t\t\t\treturn ky._stream(response.clone(), ky._options.onDownloadProgress);\n\t\t\t}\n\n\t\t\treturn response;\n\t\t};\n\n\t\tconst isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase());\n\t\tconst result = (isRetriableMethod ? ky._retry(fn) : fn()) as ResponsePromise;\n\n\t\tfor (const [type, mimeType] of Object.entries(responseTypes) as ObjectEntries<typeof responseTypes>) {\n\t\t\tresult[type] = async () => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\t\tky.request.headers.set('accept', ky.request.headers.get('accept') || mimeType);\n\n\t\t\t\tconst awaitedResult = await result;\n\t\t\t\tconst response = awaitedResult.clone();\n\n\t\t\t\tif (type === 'json') {\n\t\t\t\t\tif (response.status === 204) {\n\t\t\t\t\t\treturn '';\n\t\t\t\t\t}\n\n\t\t\t\t\tconst arrayBuffer = await response.clone().arrayBuffer();\n\t\t\t\t\tconst responseSize = arrayBuffer.byteLength;\n\t\t\t\t\tif (responseSize === 0) {\n\t\t\t\t\t\treturn '';\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.parseJson) {\n\t\t\t\t\t\treturn options.parseJson(await response.text());\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn response[type]();\n\t\t\t};\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tpublic request: Request;\n\tprotected abortController?: AbortController;\n\tprotected _retryCount = 0;\n\tprotected _input: Input;\n\tprotected _options: InternalOptions;\n\n\t// eslint-disable-next-line complexity\n\tconstructor(input: Input, options: Options = {}) {\n\t\tthis._input = input;\n\t\tthis._options = {\n\t\t\t// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208\n\t\t\tcredentials: (this._input as Request).credentials || 'same-origin',\n\t\t\t...options,\n\t\t\theaders: mergeHeaders((this._input as Request).headers, options.headers),\n\t\t\thooks: deepMerge<Required<Hooks>>(\n\t\t\t\t{\n\t\t\t\t\tbeforeRequest: [],\n\t\t\t\t\tbeforeRetry: [],\n\t\t\t\t\tbeforeError: [],\n\t\t\t\t\tafterResponse: [],\n\t\t\t\t},\n\t\t\t\toptions.hooks,\n\t\t\t),\n\t\t\tmethod: normalizeRequestMethod(options.method ?? (this._input as Request).method),\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\tprefixUrl: String(options.prefixUrl || ''),\n\t\t\tretry: normalizeRetryOptions(options.retry),\n\t\t\tthrowHttpErrors: options.throwHttpErrors !== false,\n\t\t\ttimeout: options.timeout ?? 10_000,\n\t\t\tfetch: options.fetch ?? globalThis.fetch.bind(globalThis),\n\t\t};\n\n\t\tif (typeof this._input !== 'string' && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {\n\t\t\tthrow new TypeError('`input` must be a string, URL, or Request');\n\t\t}\n\n\t\tif (this._options.prefixUrl && typeof this._input === 'string') {\n\t\t\tif (this._input.startsWith('/')) {\n\t\t\t\tthrow new Error('`input` must not begin with a slash when using `prefixUrl`');\n\t\t\t}\n\n\t\t\tif (!this._options.prefixUrl.endsWith('/')) {\n\t\t\t\tthis._options.prefixUrl += '/';\n\t\t\t}\n\n\t\t\tthis._input = this._options.prefixUrl + this._input;\n\t\t}\n\n\t\tif (supportsAbortController) {\n\t\t\tthis.abortController = new globalThis.AbortController();\n\t\t\tif (this._options.signal) {\n\t\t\t\tconst originalSignal = this._options.signal;\n\n\t\t\t\tthis._options.signal.addEventListener('abort', () => {\n\t\t\t\t\tthis.abortController!.abort(originalSignal.reason);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tthis._options.signal = this.abortController.signal;\n\t\t}\n\n\t\tif (supportsRequestStreams) {\n\t\t\t// @ts-expect-error - Types are outdated.\n\t\t\tthis._options.duplex = 'half';\n\t\t}\n\n\t\tthis.request = new globalThis.Request(this._input as RequestInfo, this._options as RequestInit);\n\n\t\tif (this._options.searchParams) {\n\t\t\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\t\t\tconst textSearchParams = typeof this._options.searchParams === 'string'\n\t\t\t\t? this._options.searchParams.replace(/^\\?/, '')\n\t\t\t\t: new URLSearchParams(this._options.searchParams as unknown as SearchParamsInit).toString();\n\t\t\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\t\t\tconst searchParams = '?' + textSearchParams;\n\t\t\tconst url = this.request.url.replace(/(?:\\?.*?)?(?=#|$)/, searchParams);\n\n\t\t\t// To provide correct form boundary, Content-Type header should be deleted each time when new Request instantiated from another one\n\t\t\tif (\n\t\t\t\t((supportsFormData && this._options.body instanceof globalThis.FormData)\n\t\t\t\t\t|| this._options.body instanceof URLSearchParams) && !(this._options.headers && (this._options.headers as Record<string, string>)['content-type'])\n\t\t\t) {\n\t\t\t\tthis.request.headers.delete('content-type');\n\t\t\t}\n\n\t\t\t// The spread of `this.request` is required as otherwise it misses the `duplex` option for some reason and throws.\n\t\t\tthis.request = new globalThis.Request(new globalThis.Request(url, {...this.request}), this._options as RequestInit);\n\t\t}\n\n\t\tif (this._options.json !== undefined) {\n\t\t\tthis._options.body = JSON.stringify(this._options.json);\n\t\t\tthis.request.headers.set('content-type', this._options.headers.get('content-type') ?? 'application/json');\n\t\t\tthis.request = new globalThis.Request(this.request, {body: this._options.body});\n\t\t}\n\t}\n\n\tprotected _calculateRetryDelay(error: unknown) {\n\t\tthis._retryCount++;\n\n\t\tif (this._retryCount < this._options.retry.limit && !(error instanceof TimeoutError)) {\n\t\t\tif (error instanceof HTTPError) {\n\t\t\t\tif (!this._options.retry.statusCodes.includes(error.response.status)) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\n\t\t\t\tconst retryAfter = error.response.headers.get('Retry-After');\n\t\t\t\tif (retryAfter && this._options.retry.afterStatusCodes.includes(error.response.status)) {\n\t\t\t\t\tlet after = Number(retryAfter);\n\t\t\t\t\tif (Number.isNaN(after)) {\n\t\t\t\t\t\tafter = Date.parse(retryAfter) - Date.now();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tafter *= 1000;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._options.retry.maxRetryAfter !== undefined && after > this._options.retry.maxRetryAfter) {\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn after;\n\t\t\t\t}\n\n\t\t\t\tif (error.response.status === 413) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst retryDelay = this._options.retry.delay(this._retryCount);\n\t\t\treturn Math.min(this._options.retry.backoffLimit, retryDelay);\n\t\t}\n\n\t\treturn 0;\n\t}\n\n\tprotected _decorateResponse(response: Response): Response {\n\t\tif (this._options.parseJson) {\n\t\t\tresponse.json = async () => this._options.parseJson!(await response.text());\n\t\t}\n\n\t\treturn response;\n\t}\n\n\tprotected async _retry<T extends (...args: any) => Promise<any>>(fn: T): Promise<ReturnType<T> | void> {\n\t\ttry {\n\t\t\treturn await fn();\n\t\t} catch (error) {\n\t\t\tconst ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);\n\t\t\tif (ms !== 0 && this._retryCount > 0) {\n\t\t\t\tawait delay(ms, {signal: this._options.signal});\n\n\t\t\t\tfor (const hook of this._options.hooks.beforeRetry) {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\tconst hookResult = await hook({\n\t\t\t\t\t\trequest: this.request,\n\t\t\t\t\t\toptions: (this._options as unknown) as NormalizedOptions,\n\t\t\t\t\t\terror: error as Error,\n\t\t\t\t\t\tretryCount: this._retryCount,\n\t\t\t\t\t});\n\n\t\t\t\t\t// If `stop` is returned from the hook, the retry process is stopped\n\t\t\t\t\tif (hookResult === stop) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn this._retry(fn);\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprotected async _fetch(): Promise<Response> {\n\t\tfor (const hook of this._options.hooks.beforeRequest) {\n\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\tconst result = await hook(this.request, (this._options as unknown) as NormalizedOptions);\n\n\t\t\tif (result instanceof Request) {\n\t\t\t\tthis.request = result;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (result instanceof Response) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\n\t\tconst nonRequestOptions = findUnknownOptions(this.request, this._options);\n\n\t\tif (this._options.timeout === false) {\n\t\t\treturn this._options.fetch(this.request.clone(), nonRequestOptions);\n\t\t}\n\n\t\treturn timeout(this.request.clone(), nonRequestOptions, this.abortController, this._options as TimeoutOptions);\n\t}\n\n\t/* istanbul ignore next */\n\tprotected _stream(response: Response, onDownloadProgress: Options['onDownloadProgress']) {\n\t\tconst totalBytes = Number(response.headers.get('content-length')) || 0;\n\t\tlet transferredBytes = 0;\n\n\t\tif (response.status === 204) {\n\t\t\tif (onDownloadProgress) {\n\t\t\t\tonDownloadProgress({percent: 1, totalBytes, transferredBytes}, new Uint8Array());\n\t\t\t}\n\n\t\t\treturn new globalThis.Response(\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\tstatus: response.status,\n\t\t\t\t\tstatusText: response.statusText,\n\t\t\t\t\theaders: response.headers,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\treturn new globalThis.Response(\n\t\t\tnew globalThis.ReadableStream({\n\t\t\t\tasync start(controller) {\n\t\t\t\t\tconst reader = response.body!.getReader();\n\n\t\t\t\t\tif (onDownloadProgress) {\n\t\t\t\t\t\tonDownloadProgress({percent: 0, transferredBytes: 0, totalBytes}, new Uint8Array());\n\t\t\t\t\t}\n\n\t\t\t\t\tasync function read() {\n\t\t\t\t\t\tconst {done, value} = await reader.read();\n\t\t\t\t\t\tif (done) {\n\t\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (onDownloadProgress) {\n\t\t\t\t\t\t\ttransferredBytes += value.byteLength;\n\t\t\t\t\t\t\tconst percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;\n\t\t\t\t\t\t\tonDownloadProgress({percent, transferredBytes, totalBytes}, value);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontroller.enqueue(value);\n\t\t\t\t\t\tawait read();\n\t\t\t\t\t}\n\n\t\t\t\t\tawait read();\n\t\t\t\t},\n\t\t\t}),\n\t\t\t{\n\t\t\t\tstatus: response.status,\n\t\t\t\tstatusText: response.statusText,\n\t\t\t\theaders: response.headers,\n\t\t\t},\n\t\t);\n\t}\n}\n","/*! MIT License © Sindre Sorhus */\n\nimport {Ky} from './core/Ky.js';\nimport {requestMethods, stop} from './core/constants.js';\nimport type {KyInstance} from './types/ky.js';\nimport type {Input, Options} from './types/options.js';\nimport {validateAndMerge} from './utils/merge.js';\nimport {type Mutable} from './utils/types.js';\n\nconst createInstance = (defaults?: Partial<Options>): KyInstance => {\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\tconst ky: Partial<Mutable<KyInstance>> = (input: Input, options?: Options) => Ky.create(input, validateAndMerge(defaults, options));\n\n\tfor (const method of requestMethods) {\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\tky[method] = (input: Input, options?: Options) => Ky.create(input, validateAndMerge(defaults, options, {method}));\n\t}\n\n\tky.create = (newDefaults?: Partial<Options>) => createInstance(validateAndMerge(newDefaults));\n\tky.extend = (newDefaults?: Partial<Options>) => createInstance(validateAndMerge(defaults, newDefaults));\n\tky.stop = stop;\n\n\treturn ky as KyInstance;\n};\n\nconst ky = createInstance();\n\nexport default ky;\n\nexport type {KyInstance} from './types/ky.js';\n\nexport type {\n\tOptions,\n\tNormalizedOptions,\n\tRetryOptions,\n\tSearchParamsOption,\n\tDownloadProgress,\n} from './types/options.js';\n\nexport type {\n\tHooks,\n\tBeforeRequestHook,\n\tBeforeRetryHook,\n\tBeforeRetryState,\n\tBeforeErrorHook,\n\tAfterResponseHook,\n} from './types/hooks.js';\n\nexport type {ResponsePromise} from './types/ResponsePromise.js';\nexport type {KyResponse} from './types/response.js';\nexport {HTTPError} from './errors/HTTPError.js';\nexport {TimeoutError} from './errors/TimeoutError.js';\n","{\n \"name\": \"bannerify-js\",\n \"version\": \"0.0.20\",\n \"description\": \"\",\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"scripts\": {\n \"test\": \"bun test\",\n \"play\": \"tsx playground/test.ts\",\n \"openapi\": \"openapi-typescript https://api-beta.bannerify.co/openapi -o ./src/openapi.d.ts\",\n \"openapi-local\": \"openapi-typescript http://127.0.0.1:5173/api/openapi -o ./src/openapi.d.ts\",\n \"build:watch\": \"tsup --watch\",\n \"build\": \"tsup\"\n },\n \"keywords\": [],\n \"files\": [\n \"dist\"\n ],\n \"author\": \"Duc An <an@bannerify.co>\",\n \"license\": \"ISC\",\n \"devDependencies\": {\n \"@faker-js/faker\": \"^8.4.1\",\n \"@types/node\": \"18.15.3\",\n \"bun-types\": \"^1.0.20\",\n \"chart.js\": \"^4.4.1\",\n \"ky\": \"^1.1.3\",\n \"openapi-typescript\": \"^6.7.3\",\n \"tsup\": \"^8.0.1\",\n \"tsx\": \"^4.7.0\",\n \"typescript\": \"5.2.2\"\n }\n}\n","import { version } from '../package.json'\n\nexport type Telemetry = {\n sdkVersions: string[];\n platform?: string;\n runtime?: string;\n};\n\nexport function getTelemetry(): Telemetry | null {\n let platform: string | undefined\n let runtime: string | undefined\n const sdkVersions = [`bannerify-js@${version}`]\n\n try {\n if (process?.env?.UNKEY_DISABLE_TELEMETRY) {\n return null\n }\n platform = process.env.VERCEL ? 'vercel' : process.env.AWS_REGION ? 'aws' : undefined\n\n // @ts-ignore\n if (typeof EdgeRuntime !== 'undefined') {\n runtime = 'edge-light'\n } else if (typeof caches !== 'undefined') {\n runtime = 'cloudflare'\n } else if (process?.version) {\n runtime = `node@${process.version}`\n } else {\n runtime = 'fetch-compatible'\n }\n\n } catch (_error) {\n }\n\n return { platform, runtime, sdkVersions }\n}","import { paths } from './openapi'\n\ntype codes = '400' | '401' | '403' | '404' | '500';\n\nexport type ErrorResponse =\n paths['/v1/liveness']['get']['responses'][codes]['content']['application/json'];\n\nexport const timeoutError = {\n error: {\n // @ts-ignore\n code: 'TIMEOUT_ERROR',\n message: 'No response',\n docs: '',\n requestId: 'N/A',\n },\n}\n\nexport type Result<R> =\n | {\n result: R;\n error?: never;\n}\n | {\n result?: never;\n error: ErrorResponse['error'] | typeof timeoutError;\n};","import ky, { HTTPError, TimeoutError } from 'ky'\nimport { getTelemetry } from './telemetry'\nimport { Modification } from './interface'\nimport { ErrorResponse, Result, timeoutError } from './types'\n\ninterface Options {\n fetch?: typeof fetch\n baseUrl?: string\n // default 10s\n timeout?: number\n}\n\ntype CreateOptions = {\n modifications?: Modification[]\n // template?: Modification\n // @default: png\n nocache?: boolean\n format?: 'svg' | 'png'\n}\n\nexport function createClient(apiKey: string, opts?: Options) {\n return new Bannerify(apiKey, opts)\n}\n\nexport class Bannerify {\n private readonly client: typeof ky\n\n private readonly baseUrl: string\n\n constructor(\n private readonly apiKey: string,\n private readonly opts?: Options\n ) {\n const telemetry = getTelemetry()\n this.baseUrl = opts?.baseUrl || 'https://api-beta.bannerify.co/v1'\n this.client = ky.create({\n fetch: opts?.fetch || globalThis.fetch,\n prefixUrl: this.baseUrl,\n headers: {\n Authorization: `Bearer ${apiKey}`,\n 'X-SDK-Version': `${telemetry?.sdkVersions}`,\n 'X-Platform': telemetry?.platform,\n 'X-Runtime': telemetry?.runtime,\n },\n timeout: opts?.timeout ?? 10e3,\n })\n }\n\n async createImage(\n templateId: string,\n options?: CreateOptions,\n ): Promise<Result<ArrayBuffer | string>> {\n try {\n const res = await this.client.post('templates/createImage', {\n json: {\n modifications: options?.modifications ?? [],\n // template: JSON.stringify(options?.template ?? {}),\n templateId,\n apiKey: this.apiKey,\n format: options?.format as string,\n },\n })\n if (options?.format === 'svg') {\n return { result: await res.text() }\n }\n return { result: await res.arrayBuffer() }\n } catch (e: any) {\n if (e instanceof HTTPError) {\n return await e.response.json() as ErrorResponse\n }\n if (e instanceof TimeoutError) {\n return timeoutError as ErrorResponse\n }\n throw e\n }\n }\n\n async createPdf(\n templateId: string,\n options?: CreateOptions,\n ) {\n throw new Error('Not yet implemented')\n }\n\n async createPermanentImage() {\n throw new Error('Not yet implemented')\n }\n\n #hashText = async (text: string) => {\n const myText = new TextEncoder().encode(text)\n const myDigest = await crypto.subtle.digest({ name: 'SHA-256' }, myText)\n const hashArray = Array.from(new Uint8Array(myDigest))\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')\n return hashHex\n }\n\n async generateImageSignedUrl(\n templateId: string,\n options?: CreateOptions,\n ) {\n const apiKeyAsMd5 = await this.#hashText(this.apiKey)\n const searchParams = new URLSearchParams()\n searchParams.set('apiKeyMd5', apiKeyAsMd5)\n if (options?.format === 'svg') {\n searchParams.set('format', 'svg')\n }\n if (options?.modifications) {\n searchParams.set('modifications', JSON.stringify(options?.modifications))\n }\n if (options?.nocache) {\n searchParams.set('nocache', 'true')\n }\n searchParams.set('templateId', templateId)\n searchParams.sort()\n // TODO update to this.opts.apiKey\n searchParams.set('sign', await this.#hashText(searchParams.toString() + searchParams.get('apiKeyMd5')))\n return `${this.baseUrl}/templates/signedurl?${searchParams.toString()}`\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGM,IAAO,YAAP,cAAyB,MAAK;EAKnC,YAAY,UAAoB,SAAkB,SAA0B;AAC3E,UAAM,OAAQ,SAAS,UAAU,SAAS,WAAW,IAAK,SAAS,SAAS;AAC5E,UAAM,QAAQ,SAAS,cAAc;AACrC,UAAM,SAAS,GAAG,IAAI,IAAI,KAAK,GAAG,KAAI;AACtC,UAAM,SAAS,SAAS,eAAe,MAAM,KAAK;AAElD,UAAM,uBAAuB,MAAM,EAAE;AAV/B,WAAA,eAAA,MAAA,YAAA;;;;;;AACA,WAAA,eAAA,MAAA,WAAA;;;;;;AACA,WAAA,eAAA,MAAA,WAAA;;;;;;AAUN,SAAK,OAAO;AACZ,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,UAAU;EAChB;;;;ACpBK,IAAO,eAAP,cAA4B,MAAK;EAGtC,YAAY,SAAgB;AAC3B,UAAM,mBAAmB;AAHnB,WAAA,eAAA,MAAA,WAAA;;;;;;AAIN,SAAK,OAAO;AACZ,SAAK,UAAU;EAChB;;;;ACNM,IAAM,WAAW,CAAC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AM,uBACJ,YACA,SACA;AACA,UAAM,cAAc,MAAM,KAAK,UAAU,KAAK,MAAM;AACpD,UAAM,eAAe,IAAI,gBAAgB;AACzC,iBAAa,IAAI,aAAa,WAAW;AACzC,QAAI,SAAS,WAAW,OAAO;AAC7B,mBAAa,IAAI,UAAU,KAAK;AAAA,IAClC;AACA,QAAI,SAAS,eAAe;AAC1B,mBAAa,IAAI,iBAAiB,KAAK,UAAU,SAAS,aAAa,CAAC;AAAA,IAC1E;AACA,QAAI,SAAS,SAAS;AACpB,mBAAa,IAAI,WAAW,MAAM;AAAA,IACpC;AACA,iBAAa,IAAI,cAAc,UAAU;AACzC,iBAAa,KAAK;AAElB,iBAAa,IAAI,QAAQ,MAAM,KAAK,UAAU,aAAa,SAAS,IAAI,aAAa,IAAI,WAAW,CAAC,CAAC;AACtG,WAAO,GAAG,KAAK,OAAO,wBAAwB,aAAa,SAAS,CAAC;AAAA,EACvE;AACF;","names":["ky","ky"]}
package/dist/index.d.cts CHANGED
@@ -454,13 +454,13 @@ type Result<R> = {
454
454
  };
455
455
 
456
456
  interface Options {
457
- apiKey: string;
458
457
  fetch?: typeof fetch;
459
458
  baseUrl?: string;
460
459
  timeout?: number;
461
460
  }
462
461
  type CreateOptions = {
463
462
  modifications?: Modification[];
463
+ nocache?: boolean;
464
464
  format?: 'svg' | 'png';
465
465
  };
466
466
  declare function createClient(apiKey: string, opts?: Options): Bannerify;
package/dist/index.d.ts CHANGED
@@ -454,13 +454,13 @@ type Result<R> = {
454
454
  };
455
455
 
456
456
  interface Options {
457
- apiKey: string;
458
457
  fetch?: typeof fetch;
459
458
  baseUrl?: string;
460
459
  timeout?: number;
461
460
  }
462
461
  type CreateOptions = {
463
462
  modifications?: Modification[];
463
+ nocache?: boolean;
464
464
  format?: 'svg' | 'png';
465
465
  };
466
466
  declare function createClient(apiKey: string, opts?: Options): Bannerify;
package/dist/index.js CHANGED
@@ -525,7 +525,7 @@ var ky = createInstance();
525
525
  var distribution_default = ky;
526
526
 
527
527
  // package.json
528
- var version = "0.0.16";
528
+ var version = "0.0.20";
529
529
 
530
530
  // src/telemetry.ts
531
531
  function getTelemetry() {
@@ -573,7 +573,7 @@ var Bannerify = class {
573
573
  const telemetry = getTelemetry();
574
574
  this.baseUrl = opts?.baseUrl || "https://api-beta.bannerify.co/v1";
575
575
  this.client = distribution_default.create({
576
- fetch: opts?.fetch || fetch,
576
+ fetch: opts?.fetch || globalThis.fetch,
577
577
  prefixUrl: this.baseUrl,
578
578
  headers: {
579
579
  Authorization: `Bearer ${apiKey}`,
@@ -588,7 +588,7 @@ var Bannerify = class {
588
588
  baseUrl;
589
589
  async createImage(templateId, options) {
590
590
  try {
591
- const res = this.client.get("templates/createImage", {
591
+ const res = await this.client.post("templates/createImage", {
592
592
  json: {
593
593
  modifications: options?.modifications ?? [],
594
594
  // template: JSON.stringify(options?.template ?? {}),
@@ -634,6 +634,9 @@ var Bannerify = class {
634
634
  if (options?.modifications) {
635
635
  searchParams.set("modifications", JSON.stringify(options?.modifications));
636
636
  }
637
+ if (options?.nocache) {
638
+ searchParams.set("nocache", "true");
639
+ }
637
640
  searchParams.set("templateId", templateId);
638
641
  searchParams.sort();
639
642
  searchParams.set("sign", await this.#hashText(searchParams.toString() + searchParams.get("apiKeyMd5")));
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/errors/HTTPError.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/errors/TimeoutError.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/is.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/merge.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/core/constants.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/normalize.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/timeout.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/delay.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/options.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/core/Ky.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/index.ts","../package.json","../src/telemetry.ts","../src/types.ts","../src/client.ts"],"sourcesContent":["import type {NormalizedOptions} from '../types/options.js';\n\n// eslint-lint-disable-next-line @typescript-eslint/naming-convention\nexport class HTTPError extends Error {\n\tpublic response: Response;\n\tpublic request: Request;\n\tpublic options: NormalizedOptions;\n\n\tconstructor(response: Response, request: Request, options: NormalizedOptions) {\n\t\tconst code = (response.status || response.status === 0) ? response.status : '';\n\t\tconst title = response.statusText || '';\n\t\tconst status = `${code} ${title}`.trim();\n\t\tconst reason = status ? `status code ${status}` : 'an unknown error';\n\n\t\tsuper(`Request failed with ${reason}`);\n\n\t\tthis.name = 'HTTPError';\n\t\tthis.response = response;\n\t\tthis.request = request;\n\t\tthis.options = options;\n\t}\n}\n","export class TimeoutError extends Error {\n\tpublic request: Request;\n\n\tconstructor(request: Request) {\n\t\tsuper('Request timed out');\n\t\tthis.name = 'TimeoutError';\n\t\tthis.request = request;\n\t}\n}\n","// eslint-disable-next-line @typescript-eslint/ban-types\nexport const isObject = (value: unknown): value is object => value !== null && typeof value === 'object';\n","import type {KyHeadersInit, Options} from '../types/options.js';\nimport {isObject} from './is.js';\n\nexport const validateAndMerge = (...sources: Array<Partial<Options> | undefined>): Partial<Options> => {\n\tfor (const source of sources) {\n\t\tif ((!isObject(source) || Array.isArray(source)) && source !== undefined) {\n\t\t\tthrow new TypeError('The `options` argument must be an object');\n\t\t}\n\t}\n\n\treturn deepMerge({}, ...sources);\n};\n\nexport const mergeHeaders = (source1: KyHeadersInit = {}, source2: KyHeadersInit = {}) => {\n\tconst result = new globalThis.Headers(source1 as HeadersInit);\n\tconst isHeadersInstance = source2 instanceof globalThis.Headers;\n\tconst source = new globalThis.Headers(source2 as HeadersInit);\n\n\tfor (const [key, value] of source.entries()) {\n\t\tif ((isHeadersInstance && value === 'undefined') || value === undefined) {\n\t\t\tresult.delete(key);\n\t\t} else {\n\t\t\tresult.set(key, value);\n\t\t}\n\t}\n\n\treturn result;\n};\n\n// TODO: Make this strongly-typed (no `any`).\nexport const deepMerge = <T>(...sources: Array<Partial<T> | undefined>): T => {\n\tlet returnValue: any = {};\n\tlet headers = {};\n\n\tfor (const source of sources) {\n\t\tif (Array.isArray(source)) {\n\t\t\tif (!Array.isArray(returnValue)) {\n\t\t\t\treturnValue = [];\n\t\t\t}\n\n\t\t\treturnValue = [...returnValue, ...source];\n\t\t} else if (isObject(source)) {\n\t\t\tfor (let [key, value] of Object.entries(source)) {\n\t\t\t\tif (isObject(value) && key in returnValue) {\n\t\t\t\t\tvalue = deepMerge(returnValue[key], value);\n\t\t\t\t}\n\n\t\t\t\treturnValue = {...returnValue, [key]: value};\n\t\t\t}\n\n\t\t\tif (isObject((source as any).headers)) {\n\t\t\t\theaders = mergeHeaders(headers, (source as any).headers);\n\t\t\t\treturnValue.headers = headers;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn returnValue;\n};\n","import type {Expect, Equal} from '@type-challenges/utils';\nimport {type HttpMethod, type KyOptionsRegistry} from '../types/options.js';\nimport {type RequestInitRegistry} from '../types/request.js';\n\nexport const supportsRequestStreams = (() => {\n\tlet duplexAccessed = false;\n\tlet hasContentType = false;\n\tconst supportsReadableStream = typeof globalThis.ReadableStream === 'function';\n\tconst supportsRequest = typeof globalThis.Request === 'function';\n\n\tif (supportsReadableStream && supportsRequest) {\n\t\thasContentType = new globalThis.Request('https://empty.invalid', {\n\t\t\tbody: new globalThis.ReadableStream(),\n\t\t\tmethod: 'POST',\n\t\t\t// @ts-expect-error - Types are outdated.\n\t\t\tget duplex() {\n\t\t\t\tduplexAccessed = true;\n\t\t\t\treturn 'half';\n\t\t\t},\n\t\t}).headers.has('Content-Type');\n\t}\n\n\treturn duplexAccessed && !hasContentType;\n})();\n\nexport const supportsAbortController = typeof globalThis.AbortController === 'function';\nexport const supportsResponseStreams = typeof globalThis.ReadableStream === 'function';\nexport const supportsFormData = typeof globalThis.FormData === 'function';\n\nexport const requestMethods = ['get', 'post', 'put', 'patch', 'head', 'delete'] as const;\n\nconst validate = <T extends Array<true>>() => undefined as unknown as T;\nvalidate<[\n\tExpect<Equal<typeof requestMethods[number], HttpMethod>>,\n]>();\n\nexport const responseTypes = {\n\tjson: 'application/json',\n\ttext: 'text/*',\n\tformData: 'multipart/form-data',\n\tarrayBuffer: '*/*',\n\tblob: '*/*',\n} as const;\n\n// The maximum value of a 32bit int (see issue #117)\nexport const maxSafeTimeout = 2_147_483_647;\n\nexport const stop = Symbol('stop');\n\nexport const kyOptionKeys: KyOptionsRegistry = {\n\tjson: true,\n\tparseJson: true,\n\tsearchParams: true,\n\tprefixUrl: true,\n\tretry: true,\n\ttimeout: true,\n\thooks: true,\n\tthrowHttpErrors: true,\n\tonDownloadProgress: true,\n\tfetch: true,\n};\n\nexport const requestOptionsRegistry: RequestInitRegistry = {\n\tmethod: true,\n\theaders: true,\n\tbody: true,\n\tmode: true,\n\tcredentials: true,\n\tcache: true,\n\tredirect: true,\n\treferrer: true,\n\treferrerPolicy: true,\n\tintegrity: true,\n\tkeepalive: true,\n\tsignal: true,\n\twindow: true,\n\tdispatcher: true,\n\tduplex: true,\n};\n","import {requestMethods} from '../core/constants.js';\nimport type {HttpMethod} from '../types/options.js';\nimport type {RetryOptions} from '../types/retry.js';\n\nexport const normalizeRequestMethod = (input: string): string =>\n\trequestMethods.includes(input as HttpMethod) ? input.toUpperCase() : input;\n\nconst retryMethods = ['get', 'put', 'head', 'delete', 'options', 'trace'];\n\nconst retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];\n\nconst retryAfterStatusCodes = [413, 429, 503];\n\nconst defaultRetryOptions: Required<RetryOptions> = {\n\tlimit: 2,\n\tmethods: retryMethods,\n\tstatusCodes: retryStatusCodes,\n\tafterStatusCodes: retryAfterStatusCodes,\n\tmaxRetryAfter: Number.POSITIVE_INFINITY,\n\tbackoffLimit: Number.POSITIVE_INFINITY,\n\tdelay: attemptCount => 0.3 * (2 ** (attemptCount - 1)) * 1000,\n};\n\nexport const normalizeRetryOptions = (retry: number | RetryOptions = {}): Required<RetryOptions> => {\n\tif (typeof retry === 'number') {\n\t\treturn {\n\t\t\t...defaultRetryOptions,\n\t\t\tlimit: retry,\n\t\t};\n\t}\n\n\tif (retry.methods && !Array.isArray(retry.methods)) {\n\t\tthrow new Error('retry.methods must be an array');\n\t}\n\n\tif (retry.statusCodes && !Array.isArray(retry.statusCodes)) {\n\t\tthrow new Error('retry.statusCodes must be an array');\n\t}\n\n\treturn {\n\t\t...defaultRetryOptions,\n\t\t...retry,\n\t\tafterStatusCodes: retryAfterStatusCodes,\n\t};\n};\n","import {TimeoutError} from '../errors/TimeoutError.js';\n\nexport type TimeoutOptions = {\n\ttimeout: number;\n\tfetch: typeof fetch;\n};\n\n// `Promise.race()` workaround (#91)\nexport default async function timeout(\n\trequest: Request,\n\tinit: RequestInit,\n\tabortController: AbortController | undefined,\n\toptions: TimeoutOptions,\n): Promise<Response> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tif (abortController) {\n\t\t\t\tabortController.abort();\n\t\t\t}\n\n\t\t\treject(new TimeoutError(request));\n\t\t}, options.timeout);\n\n\t\tvoid options\n\t\t\t.fetch(request, init)\n\t\t\t.then(resolve)\n\t\t\t.catch(reject)\n\t\t\t.then(() => {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t});\n\t});\n}\n","// https://github.com/sindresorhus/delay/tree/ab98ae8dfcb38e1593286c94d934e70d14a4e111\n\nimport {type InternalOptions} from '../types/options.js';\n\nexport type DelayOptions = {\n\tsignal?: InternalOptions['signal'];\n};\n\nexport default async function delay(\n\tms: number,\n\t{signal}: DelayOptions,\n): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal) {\n\t\t\tsignal.throwIfAborted();\n\t\t\tsignal.addEventListener('abort', abortHandler, {once: true});\n\t\t}\n\n\t\tfunction abortHandler() {\n\t\t\tclearTimeout(timeoutId);\n\t\t\treject(signal!.reason);\n\t\t}\n\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tsignal?.removeEventListener('abort', abortHandler);\n\t\t\tresolve();\n\t\t}, ms);\n\t});\n}\n","import {kyOptionKeys, requestOptionsRegistry} from '../core/constants.js';\n\nexport const findUnknownOptions = (\n\trequest: Request,\n\toptions: Record<string, unknown>,\n): Record<string, unknown> => {\n\tconst unknownOptions: Record<string, unknown> = {};\n\n\tfor (const key in options) {\n\t\tif (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && !(key in request)) {\n\t\t\tunknownOptions[key] = options[key];\n\t\t}\n\t}\n\n\treturn unknownOptions;\n};\n","import {HTTPError} from '../errors/HTTPError.js';\nimport {TimeoutError} from '../errors/TimeoutError.js';\nimport type {Hooks} from '../types/hooks.js';\nimport type {Input, InternalOptions, NormalizedOptions, Options, SearchParamsInit} from '../types/options.js';\nimport {type ResponsePromise} from '../types/ResponsePromise.js';\nimport {deepMerge, mergeHeaders} from '../utils/merge.js';\nimport {normalizeRequestMethod, normalizeRetryOptions} from '../utils/normalize.js';\nimport timeout, {type TimeoutOptions} from '../utils/timeout.js';\nimport delay from '../utils/delay.js';\nimport {type ObjectEntries} from '../utils/types.js';\nimport {findUnknownOptions} from '../utils/options.js';\nimport {\n\tmaxSafeTimeout,\n\tresponseTypes,\n\tstop,\n\tsupportsAbortController,\n\tsupportsFormData,\n\tsupportsResponseStreams,\n\tsupportsRequestStreams,\n} from './constants.js';\n\nexport class Ky {\n\tstatic create(input: Input, options: Options): ResponsePromise {\n\t\tconst ky = new Ky(input, options);\n\n\t\tconst fn = async (): Promise<Response> => {\n\t\t\tif (typeof ky._options.timeout === 'number' && ky._options.timeout > maxSafeTimeout) {\n\t\t\t\tthrow new RangeError(`The \\`timeout\\` option cannot be greater than ${maxSafeTimeout}`);\n\t\t\t}\n\n\t\t\t// Delay the fetch so that body method shortcuts can set the Accept header\n\t\t\tawait Promise.resolve();\n\t\t\tlet response = await ky._fetch();\n\n\t\t\tfor (const hook of ky._options.hooks.afterResponse) {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\tconst modifiedResponse = await hook(\n\t\t\t\t\tky.request,\n\t\t\t\t\tky._options as NormalizedOptions,\n\t\t\t\t\tky._decorateResponse(response.clone()),\n\t\t\t\t);\n\n\t\t\t\tif (modifiedResponse instanceof globalThis.Response) {\n\t\t\t\t\tresponse = modifiedResponse;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tky._decorateResponse(response);\n\n\t\t\tif (!response.ok && ky._options.throwHttpErrors) {\n\t\t\t\tlet error = new HTTPError(response, ky.request, (ky._options as unknown) as NormalizedOptions);\n\n\t\t\t\tfor (const hook of ky._options.hooks.beforeError) {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\terror = await hook(error);\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\t// If `onDownloadProgress` is passed, it uses the stream API internally\n\t\t\t/* istanbul ignore next */\n\t\t\tif (ky._options.onDownloadProgress) {\n\t\t\t\tif (typeof ky._options.onDownloadProgress !== 'function') {\n\t\t\t\t\tthrow new TypeError('The `onDownloadProgress` option must be a function');\n\t\t\t\t}\n\n\t\t\t\tif (!supportsResponseStreams) {\n\t\t\t\t\tthrow new Error('Streams are not supported in your environment. `ReadableStream` is missing.');\n\t\t\t\t}\n\n\t\t\t\treturn ky._stream(response.clone(), ky._options.onDownloadProgress);\n\t\t\t}\n\n\t\t\treturn response;\n\t\t};\n\n\t\tconst isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase());\n\t\tconst result = (isRetriableMethod ? ky._retry(fn) : fn()) as ResponsePromise;\n\n\t\tfor (const [type, mimeType] of Object.entries(responseTypes) as ObjectEntries<typeof responseTypes>) {\n\t\t\tresult[type] = async () => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\t\tky.request.headers.set('accept', ky.request.headers.get('accept') || mimeType);\n\n\t\t\t\tconst awaitedResult = await result;\n\t\t\t\tconst response = awaitedResult.clone();\n\n\t\t\t\tif (type === 'json') {\n\t\t\t\t\tif (response.status === 204) {\n\t\t\t\t\t\treturn '';\n\t\t\t\t\t}\n\n\t\t\t\t\tconst arrayBuffer = await response.clone().arrayBuffer();\n\t\t\t\t\tconst responseSize = arrayBuffer.byteLength;\n\t\t\t\t\tif (responseSize === 0) {\n\t\t\t\t\t\treturn '';\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.parseJson) {\n\t\t\t\t\t\treturn options.parseJson(await response.text());\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn response[type]();\n\t\t\t};\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tpublic request: Request;\n\tprotected abortController?: AbortController;\n\tprotected _retryCount = 0;\n\tprotected _input: Input;\n\tprotected _options: InternalOptions;\n\n\t// eslint-disable-next-line complexity\n\tconstructor(input: Input, options: Options = {}) {\n\t\tthis._input = input;\n\t\tthis._options = {\n\t\t\t// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208\n\t\t\tcredentials: (this._input as Request).credentials || 'same-origin',\n\t\t\t...options,\n\t\t\theaders: mergeHeaders((this._input as Request).headers, options.headers),\n\t\t\thooks: deepMerge<Required<Hooks>>(\n\t\t\t\t{\n\t\t\t\t\tbeforeRequest: [],\n\t\t\t\t\tbeforeRetry: [],\n\t\t\t\t\tbeforeError: [],\n\t\t\t\t\tafterResponse: [],\n\t\t\t\t},\n\t\t\t\toptions.hooks,\n\t\t\t),\n\t\t\tmethod: normalizeRequestMethod(options.method ?? (this._input as Request).method),\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\tprefixUrl: String(options.prefixUrl || ''),\n\t\t\tretry: normalizeRetryOptions(options.retry),\n\t\t\tthrowHttpErrors: options.throwHttpErrors !== false,\n\t\t\ttimeout: options.timeout ?? 10_000,\n\t\t\tfetch: options.fetch ?? globalThis.fetch.bind(globalThis),\n\t\t};\n\n\t\tif (typeof this._input !== 'string' && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {\n\t\t\tthrow new TypeError('`input` must be a string, URL, or Request');\n\t\t}\n\n\t\tif (this._options.prefixUrl && typeof this._input === 'string') {\n\t\t\tif (this._input.startsWith('/')) {\n\t\t\t\tthrow new Error('`input` must not begin with a slash when using `prefixUrl`');\n\t\t\t}\n\n\t\t\tif (!this._options.prefixUrl.endsWith('/')) {\n\t\t\t\tthis._options.prefixUrl += '/';\n\t\t\t}\n\n\t\t\tthis._input = this._options.prefixUrl + this._input;\n\t\t}\n\n\t\tif (supportsAbortController) {\n\t\t\tthis.abortController = new globalThis.AbortController();\n\t\t\tif (this._options.signal) {\n\t\t\t\tconst originalSignal = this._options.signal;\n\n\t\t\t\tthis._options.signal.addEventListener('abort', () => {\n\t\t\t\t\tthis.abortController!.abort(originalSignal.reason);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tthis._options.signal = this.abortController.signal;\n\t\t}\n\n\t\tif (supportsRequestStreams) {\n\t\t\t// @ts-expect-error - Types are outdated.\n\t\t\tthis._options.duplex = 'half';\n\t\t}\n\n\t\tthis.request = new globalThis.Request(this._input as RequestInfo, this._options as RequestInit);\n\n\t\tif (this._options.searchParams) {\n\t\t\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\t\t\tconst textSearchParams = typeof this._options.searchParams === 'string'\n\t\t\t\t? this._options.searchParams.replace(/^\\?/, '')\n\t\t\t\t: new URLSearchParams(this._options.searchParams as unknown as SearchParamsInit).toString();\n\t\t\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\t\t\tconst searchParams = '?' + textSearchParams;\n\t\t\tconst url = this.request.url.replace(/(?:\\?.*?)?(?=#|$)/, searchParams);\n\n\t\t\t// To provide correct form boundary, Content-Type header should be deleted each time when new Request instantiated from another one\n\t\t\tif (\n\t\t\t\t((supportsFormData && this._options.body instanceof globalThis.FormData)\n\t\t\t\t\t|| this._options.body instanceof URLSearchParams) && !(this._options.headers && (this._options.headers as Record<string, string>)['content-type'])\n\t\t\t) {\n\t\t\t\tthis.request.headers.delete('content-type');\n\t\t\t}\n\n\t\t\t// The spread of `this.request` is required as otherwise it misses the `duplex` option for some reason and throws.\n\t\t\tthis.request = new globalThis.Request(new globalThis.Request(url, {...this.request}), this._options as RequestInit);\n\t\t}\n\n\t\tif (this._options.json !== undefined) {\n\t\t\tthis._options.body = JSON.stringify(this._options.json);\n\t\t\tthis.request.headers.set('content-type', this._options.headers.get('content-type') ?? 'application/json');\n\t\t\tthis.request = new globalThis.Request(this.request, {body: this._options.body});\n\t\t}\n\t}\n\n\tprotected _calculateRetryDelay(error: unknown) {\n\t\tthis._retryCount++;\n\n\t\tif (this._retryCount < this._options.retry.limit && !(error instanceof TimeoutError)) {\n\t\t\tif (error instanceof HTTPError) {\n\t\t\t\tif (!this._options.retry.statusCodes.includes(error.response.status)) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\n\t\t\t\tconst retryAfter = error.response.headers.get('Retry-After');\n\t\t\t\tif (retryAfter && this._options.retry.afterStatusCodes.includes(error.response.status)) {\n\t\t\t\t\tlet after = Number(retryAfter);\n\t\t\t\t\tif (Number.isNaN(after)) {\n\t\t\t\t\t\tafter = Date.parse(retryAfter) - Date.now();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tafter *= 1000;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._options.retry.maxRetryAfter !== undefined && after > this._options.retry.maxRetryAfter) {\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn after;\n\t\t\t\t}\n\n\t\t\t\tif (error.response.status === 413) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst retryDelay = this._options.retry.delay(this._retryCount);\n\t\t\treturn Math.min(this._options.retry.backoffLimit, retryDelay);\n\t\t}\n\n\t\treturn 0;\n\t}\n\n\tprotected _decorateResponse(response: Response): Response {\n\t\tif (this._options.parseJson) {\n\t\t\tresponse.json = async () => this._options.parseJson!(await response.text());\n\t\t}\n\n\t\treturn response;\n\t}\n\n\tprotected async _retry<T extends (...args: any) => Promise<any>>(fn: T): Promise<ReturnType<T> | void> {\n\t\ttry {\n\t\t\treturn await fn();\n\t\t} catch (error) {\n\t\t\tconst ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);\n\t\t\tif (ms !== 0 && this._retryCount > 0) {\n\t\t\t\tawait delay(ms, {signal: this._options.signal});\n\n\t\t\t\tfor (const hook of this._options.hooks.beforeRetry) {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\tconst hookResult = await hook({\n\t\t\t\t\t\trequest: this.request,\n\t\t\t\t\t\toptions: (this._options as unknown) as NormalizedOptions,\n\t\t\t\t\t\terror: error as Error,\n\t\t\t\t\t\tretryCount: this._retryCount,\n\t\t\t\t\t});\n\n\t\t\t\t\t// If `stop` is returned from the hook, the retry process is stopped\n\t\t\t\t\tif (hookResult === stop) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn this._retry(fn);\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprotected async _fetch(): Promise<Response> {\n\t\tfor (const hook of this._options.hooks.beforeRequest) {\n\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\tconst result = await hook(this.request, (this._options as unknown) as NormalizedOptions);\n\n\t\t\tif (result instanceof Request) {\n\t\t\t\tthis.request = result;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (result instanceof Response) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\n\t\tconst nonRequestOptions = findUnknownOptions(this.request, this._options);\n\n\t\tif (this._options.timeout === false) {\n\t\t\treturn this._options.fetch(this.request.clone(), nonRequestOptions);\n\t\t}\n\n\t\treturn timeout(this.request.clone(), nonRequestOptions, this.abortController, this._options as TimeoutOptions);\n\t}\n\n\t/* istanbul ignore next */\n\tprotected _stream(response: Response, onDownloadProgress: Options['onDownloadProgress']) {\n\t\tconst totalBytes = Number(response.headers.get('content-length')) || 0;\n\t\tlet transferredBytes = 0;\n\n\t\tif (response.status === 204) {\n\t\t\tif (onDownloadProgress) {\n\t\t\t\tonDownloadProgress({percent: 1, totalBytes, transferredBytes}, new Uint8Array());\n\t\t\t}\n\n\t\t\treturn new globalThis.Response(\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\tstatus: response.status,\n\t\t\t\t\tstatusText: response.statusText,\n\t\t\t\t\theaders: response.headers,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\treturn new globalThis.Response(\n\t\t\tnew globalThis.ReadableStream({\n\t\t\t\tasync start(controller) {\n\t\t\t\t\tconst reader = response.body!.getReader();\n\n\t\t\t\t\tif (onDownloadProgress) {\n\t\t\t\t\t\tonDownloadProgress({percent: 0, transferredBytes: 0, totalBytes}, new Uint8Array());\n\t\t\t\t\t}\n\n\t\t\t\t\tasync function read() {\n\t\t\t\t\t\tconst {done, value} = await reader.read();\n\t\t\t\t\t\tif (done) {\n\t\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (onDownloadProgress) {\n\t\t\t\t\t\t\ttransferredBytes += value.byteLength;\n\t\t\t\t\t\t\tconst percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;\n\t\t\t\t\t\t\tonDownloadProgress({percent, transferredBytes, totalBytes}, value);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontroller.enqueue(value);\n\t\t\t\t\t\tawait read();\n\t\t\t\t\t}\n\n\t\t\t\t\tawait read();\n\t\t\t\t},\n\t\t\t}),\n\t\t\t{\n\t\t\t\tstatus: response.status,\n\t\t\t\tstatusText: response.statusText,\n\t\t\t\theaders: response.headers,\n\t\t\t},\n\t\t);\n\t}\n}\n","/*! MIT License © Sindre Sorhus */\n\nimport {Ky} from './core/Ky.js';\nimport {requestMethods, stop} from './core/constants.js';\nimport type {KyInstance} from './types/ky.js';\nimport type {Input, Options} from './types/options.js';\nimport {validateAndMerge} from './utils/merge.js';\nimport {type Mutable} from './utils/types.js';\n\nconst createInstance = (defaults?: Partial<Options>): KyInstance => {\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\tconst ky: Partial<Mutable<KyInstance>> = (input: Input, options?: Options) => Ky.create(input, validateAndMerge(defaults, options));\n\n\tfor (const method of requestMethods) {\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\tky[method] = (input: Input, options?: Options) => Ky.create(input, validateAndMerge(defaults, options, {method}));\n\t}\n\n\tky.create = (newDefaults?: Partial<Options>) => createInstance(validateAndMerge(newDefaults));\n\tky.extend = (newDefaults?: Partial<Options>) => createInstance(validateAndMerge(defaults, newDefaults));\n\tky.stop = stop;\n\n\treturn ky as KyInstance;\n};\n\nconst ky = createInstance();\n\nexport default ky;\n\nexport type {KyInstance} from './types/ky.js';\n\nexport type {\n\tOptions,\n\tNormalizedOptions,\n\tRetryOptions,\n\tSearchParamsOption,\n\tDownloadProgress,\n} from './types/options.js';\n\nexport type {\n\tHooks,\n\tBeforeRequestHook,\n\tBeforeRetryHook,\n\tBeforeRetryState,\n\tBeforeErrorHook,\n\tAfterResponseHook,\n} from './types/hooks.js';\n\nexport type {ResponsePromise} from './types/ResponsePromise.js';\nexport type {KyResponse} from './types/response.js';\nexport {HTTPError} from './errors/HTTPError.js';\nexport {TimeoutError} from './errors/TimeoutError.js';\n","{\n \"name\": \"bannerify-js\",\n \"version\": \"0.0.16\",\n \"description\": \"\",\n \"type\": \"module\",\n \"main\": \"dist/index.js\",\n \"module\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"scripts\": {\n \"test\": \"bun test\",\n \"play\": \"tsx playground/test.ts\",\n \"openapi\": \"openapi-typescript https://api-beta.bannerify.co/openapi -o ./src/openapi.d.ts\",\n \"openapi-local\": \"openapi-typescript http://127.0.0.1:5173/api/openapi -o ./src/openapi.d.ts\",\n \"build:watch\": \"tsup --watch\",\n \"build\": \"tsup\"\n },\n \"exports\": {\n \".\": {\n \"require\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"keywords\": [],\n \"files\": [\n \"dist\"\n ],\n \"author\": \"Duc An <an@bannerify.co>\",\n \"license\": \"ISC\",\n \"devDependencies\": {\n \"@faker-js/faker\": \"^8.4.1\",\n \"@types/node\": \"18.15.3\",\n \"bun-types\": \"^1.0.20\",\n \"chart.js\": \"^4.4.1\",\n \"ky\": \"^1.1.3\",\n \"openapi-typescript\": \"^6.7.3\",\n \"tsup\": \"^8.0.1\",\n \"tsx\": \"^4.7.0\",\n \"typescript\": \"5.2.2\"\n }\n}\n","import { version } from '../package.json'\n\nexport type Telemetry = {\n sdkVersions: string[];\n platform?: string;\n runtime?: string;\n};\n\nexport function getTelemetry(): Telemetry | null {\n let platform: string | undefined\n let runtime: string | undefined\n const sdkVersions = [`bannerify-js@${version}`]\n\n try {\n if (process?.env?.UNKEY_DISABLE_TELEMETRY) {\n return null\n }\n platform = process.env.VERCEL ? 'vercel' : process.env.AWS_REGION ? 'aws' : undefined\n\n // @ts-ignore\n if (typeof EdgeRuntime !== 'undefined') {\n runtime = 'edge-light'\n } else if (typeof caches !== 'undefined') {\n runtime = 'cloudflare'\n } else if (process?.version) {\n runtime = `node@${process.version}`\n } else {\n runtime = 'fetch-compatible'\n }\n\n } catch (_error) {\n }\n\n return { platform, runtime, sdkVersions }\n}","import { paths } from './openapi'\n\ntype codes = '400' | '401' | '403' | '404' | '500';\n\nexport type ErrorResponse =\n paths['/v1/liveness']['get']['responses'][codes]['content']['application/json'];\n\nexport const timeoutError = {\n error: {\n // @ts-ignore\n code: 'TIMEOUT_ERROR',\n message: 'No response',\n docs: '',\n requestId: 'N/A',\n },\n}\n\nexport type Result<R> =\n | {\n result: R;\n error?: never;\n}\n | {\n result?: never;\n error: ErrorResponse['error'] | typeof timeoutError;\n};","import ky, { HTTPError, TimeoutError } from 'ky'\nimport { getTelemetry } from './telemetry'\nimport { Modification } from './interface'\nimport { ErrorResponse, Result, timeoutError } from './types'\n\ninterface Options {\n apiKey: string\n fetch?: typeof fetch\n baseUrl?: string\n // default 10s\n timeout?: number\n}\n\ntype CreateOptions = {\n modifications?: Modification[]\n // template?: Modification\n // @default: png\n format?: 'svg' | 'png'\n}\n\nexport function createClient(apiKey: string, opts?: Options) {\n return new Bannerify(apiKey, opts)\n}\n\nexport class Bannerify {\n private readonly client: typeof ky\n\n private readonly baseUrl: string\n\n constructor(\n private readonly apiKey: string,\n private readonly opts?: Options\n ) {\n const telemetry = getTelemetry()\n this.baseUrl = opts?.baseUrl || 'https://api-beta.bannerify.co/v1'\n this.client = ky.create({\n fetch: opts?.fetch || fetch,\n prefixUrl: this.baseUrl,\n headers: {\n Authorization: `Bearer ${apiKey}`,\n 'X-SDK-Version': `${telemetry?.sdkVersions}`,\n 'X-Platform': telemetry?.platform,\n 'X-Runtime': telemetry?.runtime,\n },\n timeout: opts?.timeout ?? 10e3,\n })\n }\n\n async createImage(\n templateId: string,\n options?: CreateOptions,\n ): Promise<Result<ArrayBuffer | string>> {\n try {\n const res = this.client.get('templates/createImage', {\n json: {\n modifications: options?.modifications ?? [],\n // template: JSON.stringify(options?.template ?? {}),\n templateId,\n apiKey: this.apiKey,\n format: options?.format as string,\n },\n })\n if (options?.format === 'svg') {\n return { result: await res.text() }\n }\n return { result: await res.arrayBuffer() }\n } catch (e: any) {\n if (e instanceof HTTPError) {\n return await e.response.json() as ErrorResponse\n }\n if (e instanceof TimeoutError) {\n return timeoutError as ErrorResponse\n }\n throw e\n }\n }\n\n async createPdf(\n templateId: string,\n options?: CreateOptions,\n ) {\n throw new Error('Not yet implemented')\n }\n\n async createPermanentImage() {\n throw new Error('Not yet implemented')\n }\n\n #hashText = async (text: string) => {\n const myText = new TextEncoder().encode(text)\n const myDigest = await crypto.subtle.digest({ name: 'SHA-256' }, myText)\n const hashArray = Array.from(new Uint8Array(myDigest))\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')\n return hashHex\n }\n\n async generateImageSignedUrl(\n templateId: string,\n options?: CreateOptions,\n ) {\n const apiKeyAsMd5 = await this.#hashText(this.apiKey)\n const searchParams = new URLSearchParams()\n searchParams.set('apiKeyMd5', apiKeyAsMd5)\n if (options?.format === 'svg') {\n searchParams.set('format', 'svg')\n }\n if (options?.modifications) {\n searchParams.set('modifications', JSON.stringify(options?.modifications))\n }\n searchParams.set('templateId', templateId)\n searchParams.sort()\n // TODO update to this.opts.apiKey\n searchParams.set('sign', await this.#hashText(searchParams.toString() + searchParams.get('apiKeyMd5')))\n return `${this.baseUrl}/templates/signedurl?${searchParams.toString()}`\n }\n}"],"mappings":";AAGM,IAAO,YAAP,cAAyB,MAAK;EAKnC,YAAY,UAAoB,SAAkB,SAA0B;AAC3E,UAAM,OAAQ,SAAS,UAAU,SAAS,WAAW,IAAK,SAAS,SAAS;AAC5E,UAAM,QAAQ,SAAS,cAAc;AACrC,UAAM,SAAS,GAAG,IAAI,IAAI,KAAK,GAAG,KAAI;AACtC,UAAM,SAAS,SAAS,eAAe,MAAM,KAAK;AAElD,UAAM,uBAAuB,MAAM,EAAE;AAV/B,WAAA,eAAA,MAAA,YAAA;;;;;;AACA,WAAA,eAAA,MAAA,WAAA;;;;;;AACA,WAAA,eAAA,MAAA,WAAA;;;;;;AAUN,SAAK,OAAO;AACZ,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,UAAU;EAChB;;;;ACpBK,IAAO,eAAP,cAA4B,MAAK;EAGtC,YAAY,SAAgB;AAC3B,UAAM,mBAAmB;AAHnB,WAAA,eAAA,MAAA,WAAA;;;;;;AAIN,SAAK,OAAO;AACZ,SAAK,UAAU;EAChB;;;;ACNM,IAAM,WAAW,CAAC,UAA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A;AACA,UAAM,cAAc,MAAM,KAAK,UAAU,KAAK,MAAM;AACpD,UAAM,eAAe,IAAI,gBAAgB;AACzC,iBAAa,IAAI,aAAa,WAAW;AACzC,QAAI,SAAS,WAAW,OAAO;AAC7B,mBAAa,IAAI,UAAU,KAAK;AAAA,IAClC;AACA,QAAI,SAAS,eAAe;AAC1B,mBAAa,IAAI,iBAAiB,KAAK,UAAU,SAAS,aAAa,CAAC;AAAA,IAC1E;AACA,iBAAa,IAAI,cAAc,UAAU;AACzC,iBAAa,KAAK;AAElB,iBAAa,IAAI,QAAQ,MAAM,KAAK,UAAU,aAAa,SAAS,IAAI,aAAa,IAAI,WAAW,CAAC,CAAC;AACtG,WAAO,GAAG,KAAK,OAAO,wBAAwB,aAAa,SAAS,CAAC;AAAA,EACvE;AACF;","names":["ky","ky"]}
1
+ {"version":3,"sources":["../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/errors/HTTPError.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/errors/TimeoutError.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/is.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/merge.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/core/constants.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/normalize.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/timeout.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/delay.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/options.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/core/Ky.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/index.ts","../package.json","../src/telemetry.ts","../src/types.ts","../src/client.ts"],"sourcesContent":["import type {NormalizedOptions} from '../types/options.js';\n\n// eslint-lint-disable-next-line @typescript-eslint/naming-convention\nexport class HTTPError extends Error {\n\tpublic response: Response;\n\tpublic request: Request;\n\tpublic options: NormalizedOptions;\n\n\tconstructor(response: Response, request: Request, options: NormalizedOptions) {\n\t\tconst code = (response.status || response.status === 0) ? response.status : '';\n\t\tconst title = response.statusText || '';\n\t\tconst status = `${code} ${title}`.trim();\n\t\tconst reason = status ? `status code ${status}` : 'an unknown error';\n\n\t\tsuper(`Request failed with ${reason}`);\n\n\t\tthis.name = 'HTTPError';\n\t\tthis.response = response;\n\t\tthis.request = request;\n\t\tthis.options = options;\n\t}\n}\n","export class TimeoutError extends Error {\n\tpublic request: Request;\n\n\tconstructor(request: Request) {\n\t\tsuper('Request timed out');\n\t\tthis.name = 'TimeoutError';\n\t\tthis.request = request;\n\t}\n}\n","// eslint-disable-next-line @typescript-eslint/ban-types\nexport const isObject = (value: unknown): value is object => value !== null && typeof value === 'object';\n","import type {KyHeadersInit, Options} from '../types/options.js';\nimport {isObject} from './is.js';\n\nexport const validateAndMerge = (...sources: Array<Partial<Options> | undefined>): Partial<Options> => {\n\tfor (const source of sources) {\n\t\tif ((!isObject(source) || Array.isArray(source)) && source !== undefined) {\n\t\t\tthrow new TypeError('The `options` argument must be an object');\n\t\t}\n\t}\n\n\treturn deepMerge({}, ...sources);\n};\n\nexport const mergeHeaders = (source1: KyHeadersInit = {}, source2: KyHeadersInit = {}) => {\n\tconst result = new globalThis.Headers(source1 as HeadersInit);\n\tconst isHeadersInstance = source2 instanceof globalThis.Headers;\n\tconst source = new globalThis.Headers(source2 as HeadersInit);\n\n\tfor (const [key, value] of source.entries()) {\n\t\tif ((isHeadersInstance && value === 'undefined') || value === undefined) {\n\t\t\tresult.delete(key);\n\t\t} else {\n\t\t\tresult.set(key, value);\n\t\t}\n\t}\n\n\treturn result;\n};\n\n// TODO: Make this strongly-typed (no `any`).\nexport const deepMerge = <T>(...sources: Array<Partial<T> | undefined>): T => {\n\tlet returnValue: any = {};\n\tlet headers = {};\n\n\tfor (const source of sources) {\n\t\tif (Array.isArray(source)) {\n\t\t\tif (!Array.isArray(returnValue)) {\n\t\t\t\treturnValue = [];\n\t\t\t}\n\n\t\t\treturnValue = [...returnValue, ...source];\n\t\t} else if (isObject(source)) {\n\t\t\tfor (let [key, value] of Object.entries(source)) {\n\t\t\t\tif (isObject(value) && key in returnValue) {\n\t\t\t\t\tvalue = deepMerge(returnValue[key], value);\n\t\t\t\t}\n\n\t\t\t\treturnValue = {...returnValue, [key]: value};\n\t\t\t}\n\n\t\t\tif (isObject((source as any).headers)) {\n\t\t\t\theaders = mergeHeaders(headers, (source as any).headers);\n\t\t\t\treturnValue.headers = headers;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn returnValue;\n};\n","import type {Expect, Equal} from '@type-challenges/utils';\nimport {type HttpMethod, type KyOptionsRegistry} from '../types/options.js';\nimport {type RequestInitRegistry} from '../types/request.js';\n\nexport const supportsRequestStreams = (() => {\n\tlet duplexAccessed = false;\n\tlet hasContentType = false;\n\tconst supportsReadableStream = typeof globalThis.ReadableStream === 'function';\n\tconst supportsRequest = typeof globalThis.Request === 'function';\n\n\tif (supportsReadableStream && supportsRequest) {\n\t\thasContentType = new globalThis.Request('https://empty.invalid', {\n\t\t\tbody: new globalThis.ReadableStream(),\n\t\t\tmethod: 'POST',\n\t\t\t// @ts-expect-error - Types are outdated.\n\t\t\tget duplex() {\n\t\t\t\tduplexAccessed = true;\n\t\t\t\treturn 'half';\n\t\t\t},\n\t\t}).headers.has('Content-Type');\n\t}\n\n\treturn duplexAccessed && !hasContentType;\n})();\n\nexport const supportsAbortController = typeof globalThis.AbortController === 'function';\nexport const supportsResponseStreams = typeof globalThis.ReadableStream === 'function';\nexport const supportsFormData = typeof globalThis.FormData === 'function';\n\nexport const requestMethods = ['get', 'post', 'put', 'patch', 'head', 'delete'] as const;\n\nconst validate = <T extends Array<true>>() => undefined as unknown as T;\nvalidate<[\n\tExpect<Equal<typeof requestMethods[number], HttpMethod>>,\n]>();\n\nexport const responseTypes = {\n\tjson: 'application/json',\n\ttext: 'text/*',\n\tformData: 'multipart/form-data',\n\tarrayBuffer: '*/*',\n\tblob: '*/*',\n} as const;\n\n// The maximum value of a 32bit int (see issue #117)\nexport const maxSafeTimeout = 2_147_483_647;\n\nexport const stop = Symbol('stop');\n\nexport const kyOptionKeys: KyOptionsRegistry = {\n\tjson: true,\n\tparseJson: true,\n\tsearchParams: true,\n\tprefixUrl: true,\n\tretry: true,\n\ttimeout: true,\n\thooks: true,\n\tthrowHttpErrors: true,\n\tonDownloadProgress: true,\n\tfetch: true,\n};\n\nexport const requestOptionsRegistry: RequestInitRegistry = {\n\tmethod: true,\n\theaders: true,\n\tbody: true,\n\tmode: true,\n\tcredentials: true,\n\tcache: true,\n\tredirect: true,\n\treferrer: true,\n\treferrerPolicy: true,\n\tintegrity: true,\n\tkeepalive: true,\n\tsignal: true,\n\twindow: true,\n\tdispatcher: true,\n\tduplex: true,\n};\n","import {requestMethods} from '../core/constants.js';\nimport type {HttpMethod} from '../types/options.js';\nimport type {RetryOptions} from '../types/retry.js';\n\nexport const normalizeRequestMethod = (input: string): string =>\n\trequestMethods.includes(input as HttpMethod) ? input.toUpperCase() : input;\n\nconst retryMethods = ['get', 'put', 'head', 'delete', 'options', 'trace'];\n\nconst retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];\n\nconst retryAfterStatusCodes = [413, 429, 503];\n\nconst defaultRetryOptions: Required<RetryOptions> = {\n\tlimit: 2,\n\tmethods: retryMethods,\n\tstatusCodes: retryStatusCodes,\n\tafterStatusCodes: retryAfterStatusCodes,\n\tmaxRetryAfter: Number.POSITIVE_INFINITY,\n\tbackoffLimit: Number.POSITIVE_INFINITY,\n\tdelay: attemptCount => 0.3 * (2 ** (attemptCount - 1)) * 1000,\n};\n\nexport const normalizeRetryOptions = (retry: number | RetryOptions = {}): Required<RetryOptions> => {\n\tif (typeof retry === 'number') {\n\t\treturn {\n\t\t\t...defaultRetryOptions,\n\t\t\tlimit: retry,\n\t\t};\n\t}\n\n\tif (retry.methods && !Array.isArray(retry.methods)) {\n\t\tthrow new Error('retry.methods must be an array');\n\t}\n\n\tif (retry.statusCodes && !Array.isArray(retry.statusCodes)) {\n\t\tthrow new Error('retry.statusCodes must be an array');\n\t}\n\n\treturn {\n\t\t...defaultRetryOptions,\n\t\t...retry,\n\t\tafterStatusCodes: retryAfterStatusCodes,\n\t};\n};\n","import {TimeoutError} from '../errors/TimeoutError.js';\n\nexport type TimeoutOptions = {\n\ttimeout: number;\n\tfetch: typeof fetch;\n};\n\n// `Promise.race()` workaround (#91)\nexport default async function timeout(\n\trequest: Request,\n\tinit: RequestInit,\n\tabortController: AbortController | undefined,\n\toptions: TimeoutOptions,\n): Promise<Response> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tif (abortController) {\n\t\t\t\tabortController.abort();\n\t\t\t}\n\n\t\t\treject(new TimeoutError(request));\n\t\t}, options.timeout);\n\n\t\tvoid options\n\t\t\t.fetch(request, init)\n\t\t\t.then(resolve)\n\t\t\t.catch(reject)\n\t\t\t.then(() => {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t});\n\t});\n}\n","// https://github.com/sindresorhus/delay/tree/ab98ae8dfcb38e1593286c94d934e70d14a4e111\n\nimport {type InternalOptions} from '../types/options.js';\n\nexport type DelayOptions = {\n\tsignal?: InternalOptions['signal'];\n};\n\nexport default async function delay(\n\tms: number,\n\t{signal}: DelayOptions,\n): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal) {\n\t\t\tsignal.throwIfAborted();\n\t\t\tsignal.addEventListener('abort', abortHandler, {once: true});\n\t\t}\n\n\t\tfunction abortHandler() {\n\t\t\tclearTimeout(timeoutId);\n\t\t\treject(signal!.reason);\n\t\t}\n\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tsignal?.removeEventListener('abort', abortHandler);\n\t\t\tresolve();\n\t\t}, ms);\n\t});\n}\n","import {kyOptionKeys, requestOptionsRegistry} from '../core/constants.js';\n\nexport const findUnknownOptions = (\n\trequest: Request,\n\toptions: Record<string, unknown>,\n): Record<string, unknown> => {\n\tconst unknownOptions: Record<string, unknown> = {};\n\n\tfor (const key in options) {\n\t\tif (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && !(key in request)) {\n\t\t\tunknownOptions[key] = options[key];\n\t\t}\n\t}\n\n\treturn unknownOptions;\n};\n","import {HTTPError} from '../errors/HTTPError.js';\nimport {TimeoutError} from '../errors/TimeoutError.js';\nimport type {Hooks} from '../types/hooks.js';\nimport type {Input, InternalOptions, NormalizedOptions, Options, SearchParamsInit} from '../types/options.js';\nimport {type ResponsePromise} from '../types/ResponsePromise.js';\nimport {deepMerge, mergeHeaders} from '../utils/merge.js';\nimport {normalizeRequestMethod, normalizeRetryOptions} from '../utils/normalize.js';\nimport timeout, {type TimeoutOptions} from '../utils/timeout.js';\nimport delay from '../utils/delay.js';\nimport {type ObjectEntries} from '../utils/types.js';\nimport {findUnknownOptions} from '../utils/options.js';\nimport {\n\tmaxSafeTimeout,\n\tresponseTypes,\n\tstop,\n\tsupportsAbortController,\n\tsupportsFormData,\n\tsupportsResponseStreams,\n\tsupportsRequestStreams,\n} from './constants.js';\n\nexport class Ky {\n\tstatic create(input: Input, options: Options): ResponsePromise {\n\t\tconst ky = new Ky(input, options);\n\n\t\tconst fn = async (): Promise<Response> => {\n\t\t\tif (typeof ky._options.timeout === 'number' && ky._options.timeout > maxSafeTimeout) {\n\t\t\t\tthrow new RangeError(`The \\`timeout\\` option cannot be greater than ${maxSafeTimeout}`);\n\t\t\t}\n\n\t\t\t// Delay the fetch so that body method shortcuts can set the Accept header\n\t\t\tawait Promise.resolve();\n\t\t\tlet response = await ky._fetch();\n\n\t\t\tfor (const hook of ky._options.hooks.afterResponse) {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\tconst modifiedResponse = await hook(\n\t\t\t\t\tky.request,\n\t\t\t\t\tky._options as NormalizedOptions,\n\t\t\t\t\tky._decorateResponse(response.clone()),\n\t\t\t\t);\n\n\t\t\t\tif (modifiedResponse instanceof globalThis.Response) {\n\t\t\t\t\tresponse = modifiedResponse;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tky._decorateResponse(response);\n\n\t\t\tif (!response.ok && ky._options.throwHttpErrors) {\n\t\t\t\tlet error = new HTTPError(response, ky.request, (ky._options as unknown) as NormalizedOptions);\n\n\t\t\t\tfor (const hook of ky._options.hooks.beforeError) {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\terror = await hook(error);\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\t// If `onDownloadProgress` is passed, it uses the stream API internally\n\t\t\t/* istanbul ignore next */\n\t\t\tif (ky._options.onDownloadProgress) {\n\t\t\t\tif (typeof ky._options.onDownloadProgress !== 'function') {\n\t\t\t\t\tthrow new TypeError('The `onDownloadProgress` option must be a function');\n\t\t\t\t}\n\n\t\t\t\tif (!supportsResponseStreams) {\n\t\t\t\t\tthrow new Error('Streams are not supported in your environment. `ReadableStream` is missing.');\n\t\t\t\t}\n\n\t\t\t\treturn ky._stream(response.clone(), ky._options.onDownloadProgress);\n\t\t\t}\n\n\t\t\treturn response;\n\t\t};\n\n\t\tconst isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase());\n\t\tconst result = (isRetriableMethod ? ky._retry(fn) : fn()) as ResponsePromise;\n\n\t\tfor (const [type, mimeType] of Object.entries(responseTypes) as ObjectEntries<typeof responseTypes>) {\n\t\t\tresult[type] = async () => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\t\tky.request.headers.set('accept', ky.request.headers.get('accept') || mimeType);\n\n\t\t\t\tconst awaitedResult = await result;\n\t\t\t\tconst response = awaitedResult.clone();\n\n\t\t\t\tif (type === 'json') {\n\t\t\t\t\tif (response.status === 204) {\n\t\t\t\t\t\treturn '';\n\t\t\t\t\t}\n\n\t\t\t\t\tconst arrayBuffer = await response.clone().arrayBuffer();\n\t\t\t\t\tconst responseSize = arrayBuffer.byteLength;\n\t\t\t\t\tif (responseSize === 0) {\n\t\t\t\t\t\treturn '';\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.parseJson) {\n\t\t\t\t\t\treturn options.parseJson(await response.text());\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn response[type]();\n\t\t\t};\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tpublic request: Request;\n\tprotected abortController?: AbortController;\n\tprotected _retryCount = 0;\n\tprotected _input: Input;\n\tprotected _options: InternalOptions;\n\n\t// eslint-disable-next-line complexity\n\tconstructor(input: Input, options: Options = {}) {\n\t\tthis._input = input;\n\t\tthis._options = {\n\t\t\t// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208\n\t\t\tcredentials: (this._input as Request).credentials || 'same-origin',\n\t\t\t...options,\n\t\t\theaders: mergeHeaders((this._input as Request).headers, options.headers),\n\t\t\thooks: deepMerge<Required<Hooks>>(\n\t\t\t\t{\n\t\t\t\t\tbeforeRequest: [],\n\t\t\t\t\tbeforeRetry: [],\n\t\t\t\t\tbeforeError: [],\n\t\t\t\t\tafterResponse: [],\n\t\t\t\t},\n\t\t\t\toptions.hooks,\n\t\t\t),\n\t\t\tmethod: normalizeRequestMethod(options.method ?? (this._input as Request).method),\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\tprefixUrl: String(options.prefixUrl || ''),\n\t\t\tretry: normalizeRetryOptions(options.retry),\n\t\t\tthrowHttpErrors: options.throwHttpErrors !== false,\n\t\t\ttimeout: options.timeout ?? 10_000,\n\t\t\tfetch: options.fetch ?? globalThis.fetch.bind(globalThis),\n\t\t};\n\n\t\tif (typeof this._input !== 'string' && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {\n\t\t\tthrow new TypeError('`input` must be a string, URL, or Request');\n\t\t}\n\n\t\tif (this._options.prefixUrl && typeof this._input === 'string') {\n\t\t\tif (this._input.startsWith('/')) {\n\t\t\t\tthrow new Error('`input` must not begin with a slash when using `prefixUrl`');\n\t\t\t}\n\n\t\t\tif (!this._options.prefixUrl.endsWith('/')) {\n\t\t\t\tthis._options.prefixUrl += '/';\n\t\t\t}\n\n\t\t\tthis._input = this._options.prefixUrl + this._input;\n\t\t}\n\n\t\tif (supportsAbortController) {\n\t\t\tthis.abortController = new globalThis.AbortController();\n\t\t\tif (this._options.signal) {\n\t\t\t\tconst originalSignal = this._options.signal;\n\n\t\t\t\tthis._options.signal.addEventListener('abort', () => {\n\t\t\t\t\tthis.abortController!.abort(originalSignal.reason);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tthis._options.signal = this.abortController.signal;\n\t\t}\n\n\t\tif (supportsRequestStreams) {\n\t\t\t// @ts-expect-error - Types are outdated.\n\t\t\tthis._options.duplex = 'half';\n\t\t}\n\n\t\tthis.request = new globalThis.Request(this._input as RequestInfo, this._options as RequestInit);\n\n\t\tif (this._options.searchParams) {\n\t\t\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\t\t\tconst textSearchParams = typeof this._options.searchParams === 'string'\n\t\t\t\t? this._options.searchParams.replace(/^\\?/, '')\n\t\t\t\t: new URLSearchParams(this._options.searchParams as unknown as SearchParamsInit).toString();\n\t\t\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\t\t\tconst searchParams = '?' + textSearchParams;\n\t\t\tconst url = this.request.url.replace(/(?:\\?.*?)?(?=#|$)/, searchParams);\n\n\t\t\t// To provide correct form boundary, Content-Type header should be deleted each time when new Request instantiated from another one\n\t\t\tif (\n\t\t\t\t((supportsFormData && this._options.body instanceof globalThis.FormData)\n\t\t\t\t\t|| this._options.body instanceof URLSearchParams) && !(this._options.headers && (this._options.headers as Record<string, string>)['content-type'])\n\t\t\t) {\n\t\t\t\tthis.request.headers.delete('content-type');\n\t\t\t}\n\n\t\t\t// The spread of `this.request` is required as otherwise it misses the `duplex` option for some reason and throws.\n\t\t\tthis.request = new globalThis.Request(new globalThis.Request(url, {...this.request}), this._options as RequestInit);\n\t\t}\n\n\t\tif (this._options.json !== undefined) {\n\t\t\tthis._options.body = JSON.stringify(this._options.json);\n\t\t\tthis.request.headers.set('content-type', this._options.headers.get('content-type') ?? 'application/json');\n\t\t\tthis.request = new globalThis.Request(this.request, {body: this._options.body});\n\t\t}\n\t}\n\n\tprotected _calculateRetryDelay(error: unknown) {\n\t\tthis._retryCount++;\n\n\t\tif (this._retryCount < this._options.retry.limit && !(error instanceof TimeoutError)) {\n\t\t\tif (error instanceof HTTPError) {\n\t\t\t\tif (!this._options.retry.statusCodes.includes(error.response.status)) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\n\t\t\t\tconst retryAfter = error.response.headers.get('Retry-After');\n\t\t\t\tif (retryAfter && this._options.retry.afterStatusCodes.includes(error.response.status)) {\n\t\t\t\t\tlet after = Number(retryAfter);\n\t\t\t\t\tif (Number.isNaN(after)) {\n\t\t\t\t\t\tafter = Date.parse(retryAfter) - Date.now();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tafter *= 1000;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._options.retry.maxRetryAfter !== undefined && after > this._options.retry.maxRetryAfter) {\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn after;\n\t\t\t\t}\n\n\t\t\t\tif (error.response.status === 413) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst retryDelay = this._options.retry.delay(this._retryCount);\n\t\t\treturn Math.min(this._options.retry.backoffLimit, retryDelay);\n\t\t}\n\n\t\treturn 0;\n\t}\n\n\tprotected _decorateResponse(response: Response): Response {\n\t\tif (this._options.parseJson) {\n\t\t\tresponse.json = async () => this._options.parseJson!(await response.text());\n\t\t}\n\n\t\treturn response;\n\t}\n\n\tprotected async _retry<T extends (...args: any) => Promise<any>>(fn: T): Promise<ReturnType<T> | void> {\n\t\ttry {\n\t\t\treturn await fn();\n\t\t} catch (error) {\n\t\t\tconst ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);\n\t\t\tif (ms !== 0 && this._retryCount > 0) {\n\t\t\t\tawait delay(ms, {signal: this._options.signal});\n\n\t\t\t\tfor (const hook of this._options.hooks.beforeRetry) {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\tconst hookResult = await hook({\n\t\t\t\t\t\trequest: this.request,\n\t\t\t\t\t\toptions: (this._options as unknown) as NormalizedOptions,\n\t\t\t\t\t\terror: error as Error,\n\t\t\t\t\t\tretryCount: this._retryCount,\n\t\t\t\t\t});\n\n\t\t\t\t\t// If `stop` is returned from the hook, the retry process is stopped\n\t\t\t\t\tif (hookResult === stop) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn this._retry(fn);\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprotected async _fetch(): Promise<Response> {\n\t\tfor (const hook of this._options.hooks.beforeRequest) {\n\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\tconst result = await hook(this.request, (this._options as unknown) as NormalizedOptions);\n\n\t\t\tif (result instanceof Request) {\n\t\t\t\tthis.request = result;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (result instanceof Response) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\n\t\tconst nonRequestOptions = findUnknownOptions(this.request, this._options);\n\n\t\tif (this._options.timeout === false) {\n\t\t\treturn this._options.fetch(this.request.clone(), nonRequestOptions);\n\t\t}\n\n\t\treturn timeout(this.request.clone(), nonRequestOptions, this.abortController, this._options as TimeoutOptions);\n\t}\n\n\t/* istanbul ignore next */\n\tprotected _stream(response: Response, onDownloadProgress: Options['onDownloadProgress']) {\n\t\tconst totalBytes = Number(response.headers.get('content-length')) || 0;\n\t\tlet transferredBytes = 0;\n\n\t\tif (response.status === 204) {\n\t\t\tif (onDownloadProgress) {\n\t\t\t\tonDownloadProgress({percent: 1, totalBytes, transferredBytes}, new Uint8Array());\n\t\t\t}\n\n\t\t\treturn new globalThis.Response(\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\tstatus: response.status,\n\t\t\t\t\tstatusText: response.statusText,\n\t\t\t\t\theaders: response.headers,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\treturn new globalThis.Response(\n\t\t\tnew globalThis.ReadableStream({\n\t\t\t\tasync start(controller) {\n\t\t\t\t\tconst reader = response.body!.getReader();\n\n\t\t\t\t\tif (onDownloadProgress) {\n\t\t\t\t\t\tonDownloadProgress({percent: 0, transferredBytes: 0, totalBytes}, new Uint8Array());\n\t\t\t\t\t}\n\n\t\t\t\t\tasync function read() {\n\t\t\t\t\t\tconst {done, value} = await reader.read();\n\t\t\t\t\t\tif (done) {\n\t\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (onDownloadProgress) {\n\t\t\t\t\t\t\ttransferredBytes += value.byteLength;\n\t\t\t\t\t\t\tconst percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;\n\t\t\t\t\t\t\tonDownloadProgress({percent, transferredBytes, totalBytes}, value);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontroller.enqueue(value);\n\t\t\t\t\t\tawait read();\n\t\t\t\t\t}\n\n\t\t\t\t\tawait read();\n\t\t\t\t},\n\t\t\t}),\n\t\t\t{\n\t\t\t\tstatus: response.status,\n\t\t\t\tstatusText: response.statusText,\n\t\t\t\theaders: response.headers,\n\t\t\t},\n\t\t);\n\t}\n}\n","/*! MIT License © Sindre Sorhus */\n\nimport {Ky} from './core/Ky.js';\nimport {requestMethods, stop} from './core/constants.js';\nimport type {KyInstance} from './types/ky.js';\nimport type {Input, Options} from './types/options.js';\nimport {validateAndMerge} from './utils/merge.js';\nimport {type Mutable} from './utils/types.js';\n\nconst createInstance = (defaults?: Partial<Options>): KyInstance => {\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\tconst ky: Partial<Mutable<KyInstance>> = (input: Input, options?: Options) => Ky.create(input, validateAndMerge(defaults, options));\n\n\tfor (const method of requestMethods) {\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\tky[method] = (input: Input, options?: Options) => Ky.create(input, validateAndMerge(defaults, options, {method}));\n\t}\n\n\tky.create = (newDefaults?: Partial<Options>) => createInstance(validateAndMerge(newDefaults));\n\tky.extend = (newDefaults?: Partial<Options>) => createInstance(validateAndMerge(defaults, newDefaults));\n\tky.stop = stop;\n\n\treturn ky as KyInstance;\n};\n\nconst ky = createInstance();\n\nexport default ky;\n\nexport type {KyInstance} from './types/ky.js';\n\nexport type {\n\tOptions,\n\tNormalizedOptions,\n\tRetryOptions,\n\tSearchParamsOption,\n\tDownloadProgress,\n} from './types/options.js';\n\nexport type {\n\tHooks,\n\tBeforeRequestHook,\n\tBeforeRetryHook,\n\tBeforeRetryState,\n\tBeforeErrorHook,\n\tAfterResponseHook,\n} from './types/hooks.js';\n\nexport type {ResponsePromise} from './types/ResponsePromise.js';\nexport type {KyResponse} from './types/response.js';\nexport {HTTPError} from './errors/HTTPError.js';\nexport {TimeoutError} from './errors/TimeoutError.js';\n","{\n \"name\": \"bannerify-js\",\n \"version\": \"0.0.20\",\n \"description\": \"\",\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"scripts\": {\n \"test\": \"bun test\",\n \"play\": \"tsx playground/test.ts\",\n \"openapi\": \"openapi-typescript https://api-beta.bannerify.co/openapi -o ./src/openapi.d.ts\",\n \"openapi-local\": \"openapi-typescript http://127.0.0.1:5173/api/openapi -o ./src/openapi.d.ts\",\n \"build:watch\": \"tsup --watch\",\n \"build\": \"tsup\"\n },\n \"keywords\": [],\n \"files\": [\n \"dist\"\n ],\n \"author\": \"Duc An <an@bannerify.co>\",\n \"license\": \"ISC\",\n \"devDependencies\": {\n \"@faker-js/faker\": \"^8.4.1\",\n \"@types/node\": \"18.15.3\",\n \"bun-types\": \"^1.0.20\",\n \"chart.js\": \"^4.4.1\",\n \"ky\": \"^1.1.3\",\n \"openapi-typescript\": \"^6.7.3\",\n \"tsup\": \"^8.0.1\",\n \"tsx\": \"^4.7.0\",\n \"typescript\": \"5.2.2\"\n }\n}\n","import { version } from '../package.json'\n\nexport type Telemetry = {\n sdkVersions: string[];\n platform?: string;\n runtime?: string;\n};\n\nexport function getTelemetry(): Telemetry | null {\n let platform: string | undefined\n let runtime: string | undefined\n const sdkVersions = [`bannerify-js@${version}`]\n\n try {\n if (process?.env?.UNKEY_DISABLE_TELEMETRY) {\n return null\n }\n platform = process.env.VERCEL ? 'vercel' : process.env.AWS_REGION ? 'aws' : undefined\n\n // @ts-ignore\n if (typeof EdgeRuntime !== 'undefined') {\n runtime = 'edge-light'\n } else if (typeof caches !== 'undefined') {\n runtime = 'cloudflare'\n } else if (process?.version) {\n runtime = `node@${process.version}`\n } else {\n runtime = 'fetch-compatible'\n }\n\n } catch (_error) {\n }\n\n return { platform, runtime, sdkVersions }\n}","import { paths } from './openapi'\n\ntype codes = '400' | '401' | '403' | '404' | '500';\n\nexport type ErrorResponse =\n paths['/v1/liveness']['get']['responses'][codes]['content']['application/json'];\n\nexport const timeoutError = {\n error: {\n // @ts-ignore\n code: 'TIMEOUT_ERROR',\n message: 'No response',\n docs: '',\n requestId: 'N/A',\n },\n}\n\nexport type Result<R> =\n | {\n result: R;\n error?: never;\n}\n | {\n result?: never;\n error: ErrorResponse['error'] | typeof timeoutError;\n};","import ky, { HTTPError, TimeoutError } from 'ky'\nimport { getTelemetry } from './telemetry'\nimport { Modification } from './interface'\nimport { ErrorResponse, Result, timeoutError } from './types'\n\ninterface Options {\n fetch?: typeof fetch\n baseUrl?: string\n // default 10s\n timeout?: number\n}\n\ntype CreateOptions = {\n modifications?: Modification[]\n // template?: Modification\n // @default: png\n nocache?: boolean\n format?: 'svg' | 'png'\n}\n\nexport function createClient(apiKey: string, opts?: Options) {\n return new Bannerify(apiKey, opts)\n}\n\nexport class Bannerify {\n private readonly client: typeof ky\n\n private readonly baseUrl: string\n\n constructor(\n private readonly apiKey: string,\n private readonly opts?: Options\n ) {\n const telemetry = getTelemetry()\n this.baseUrl = opts?.baseUrl || 'https://api-beta.bannerify.co/v1'\n this.client = ky.create({\n fetch: opts?.fetch || globalThis.fetch,\n prefixUrl: this.baseUrl,\n headers: {\n Authorization: `Bearer ${apiKey}`,\n 'X-SDK-Version': `${telemetry?.sdkVersions}`,\n 'X-Platform': telemetry?.platform,\n 'X-Runtime': telemetry?.runtime,\n },\n timeout: opts?.timeout ?? 10e3,\n })\n }\n\n async createImage(\n templateId: string,\n options?: CreateOptions,\n ): Promise<Result<ArrayBuffer | string>> {\n try {\n const res = await this.client.post('templates/createImage', {\n json: {\n modifications: options?.modifications ?? [],\n // template: JSON.stringify(options?.template ?? {}),\n templateId,\n apiKey: this.apiKey,\n format: options?.format as string,\n },\n })\n if (options?.format === 'svg') {\n return { result: await res.text() }\n }\n return { result: await res.arrayBuffer() }\n } catch (e: any) {\n if (e instanceof HTTPError) {\n return await e.response.json() as ErrorResponse\n }\n if (e instanceof TimeoutError) {\n return timeoutError as ErrorResponse\n }\n throw e\n }\n }\n\n async createPdf(\n templateId: string,\n options?: CreateOptions,\n ) {\n throw new Error('Not yet implemented')\n }\n\n async createPermanentImage() {\n throw new Error('Not yet implemented')\n }\n\n #hashText = async (text: string) => {\n const myText = new TextEncoder().encode(text)\n const myDigest = await crypto.subtle.digest({ name: 'SHA-256' }, myText)\n const hashArray = Array.from(new Uint8Array(myDigest))\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')\n return hashHex\n }\n\n async generateImageSignedUrl(\n templateId: string,\n options?: CreateOptions,\n ) {\n const apiKeyAsMd5 = await this.#hashText(this.apiKey)\n const searchParams = new URLSearchParams()\n searchParams.set('apiKeyMd5', apiKeyAsMd5)\n if (options?.format === 'svg') {\n searchParams.set('format', 'svg')\n }\n if (options?.modifications) {\n searchParams.set('modifications', JSON.stringify(options?.modifications))\n }\n if (options?.nocache) {\n searchParams.set('nocache', 'true')\n }\n searchParams.set('templateId', templateId)\n searchParams.sort()\n // TODO update to this.opts.apiKey\n searchParams.set('sign', await this.#hashText(searchParams.toString() + searchParams.get('apiKeyMd5')))\n return `${this.baseUrl}/templates/signedurl?${searchParams.toString()}`\n }\n}"],"mappings":";AAGM,IAAO,YAAP,cAAyB,MAAK;EAKnC,YAAY,UAAoB,SAAkB,SAA0B;AAC3E,UAAM,OAAQ,SAAS,UAAU,SAAS,WAAW,IAAK,SAAS,SAAS;AAC5E,UAAM,QAAQ,SAAS,cAAc;AACrC,UAAM,SAAS,GAAG,IAAI,IAAI,KAAK,GAAG,KAAI;AACtC,UAAM,SAAS,SAAS,eAAe,MAAM,KAAK;AAElD,UAAM,uBAAuB,MAAM,EAAE;AAV/B,WAAA,eAAA,MAAA,YAAA;;;;;;AACA,WAAA,eAAA,MAAA,WAAA;;;;;;AACA,WAAA,eAAA,MAAA,WAAA;;;;;;AAUN,SAAK,OAAO;AACZ,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,UAAU;EAChB;;;;ACpBK,IAAO,eAAP,cAA4B,MAAK;EAGtC,YAAY,SAAgB;AAC3B,UAAM,mBAAmB;AAHnB,WAAA,eAAA,MAAA,WAAA;;;;;;AAIN,SAAK,OAAO;AACZ,SAAK,UAAU;EAChB;;;;ACNM,IAAM,WAAW,CAAC,UAAoC,UAAU,QAAQ,OAAO,UAAU;;;ACEzF,IAAM,mBAAmB,IAAI,YAAkE;AACrG,aAAW,UAAU,SAAS;AAC7B,SAAK,CAAC,SAAS,MAAM,KAAK,MAAM,QAAQ,MAAM,MAAM,WAAW,QAAW;AACzE,YAAM,IAAI,UAAU,0CAA0C;;;AAIhE,SAAO,UAAU,CAAA,GAAI,GAAG,OAAO;AAChC;AAEO,IAAM,eAAe,CAAC,UAAyB,CAAA,GAAI,UAAyB,CAAA,MAAM;AACxF,QAAM,SAAS,IAAI,WAAW,QAAQ,OAA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AA,IACpC;AACA,iBAAa,IAAI,cAAc,UAAU;AACzC,iBAAa,KAAK;AAElB,iBAAa,IAAI,QAAQ,MAAM,KAAK,UAAU,aAAa,SAAS,IAAI,aAAa,IAAI,WAAW,CAAC,CAAC;AACtG,WAAO,GAAG,KAAK,OAAO,wBAAwB,aAAa,SAAS,CAAC;AAAA,EACvE;AACF;","names":["ky","ky"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bannerify-js",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",