@vrplatform/api 1.3.1-stage.1707 → 1.3.1-stage.1713

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.
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","sourceRoot":"src/","sources":["cache.ts"],"names":[],"mappings":";;AAUA,4BA6CC;AA7CD,SAAgB,QAAQ,CACtB,OAA+B,EAC/B,YAAoB;IAEpB,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;IAClD,MAAM,aAAa,GAAG,IAAI,GAAG,EAAsB,CAAC;IAEpD,MAAM,cAAc,GAAG,KAAK,EAAE,GAAM,EAAc,EAAE;QAClD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEvB,yCAAyC;QACzC,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC3C,IAAI,WAAW,IAAI,GAAG,IAAI,WAAW,CAAC,SAAS,EAAE,CAAC;YAChD,OAAO,WAAW,CAAC,KAAK,CAAC;QAC3B,CAAC;QAED,0EAA0E;QAC1E,MAAM,eAAe,GAAG,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACpD,IAAI,eAAe;YAAE,OAAO,eAAe,CAAC;QAE5C,kBAAkB;QAClB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;YAC7B,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAErC,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC;YACjC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE;gBACrB,KAAK,EAAE,UAAU;gBACjB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,YAAY;aACrC,CAAC,CAAC;YAEH,OAAO,UAAU,CAAC;QACpB,CAAC;gBAAS,CAAC;YACT,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,UAAU,EAAE,GAAG,EAAE;YACf,QAAQ,CAAC,KAAK,EAAE,CAAC;YACjB,aAAa,CAAC,KAAK,EAAE,CAAC;QACxB,CAAC;QACD,OAAO,EAAE,cAAc;KACxB,CAAC;AACJ,CAAC","sourcesContent":["type CacheEntry<T> = {\n value: T;\n expiresAt: number;\n};\n\ntype CacheResult<T, A> = {\n current: (arg: A) => Promise<T>;\n invalidate: () => void;\n};\n\nexport function useCache<T, A>(\n fetchFn: (arg: A) => Promise<T>,\n expiryTimeMs: number\n): CacheResult<T, A> {\n const cacheMap = new Map<string, CacheEntry<T>>();\n const fetchPromises = new Map<string, Promise<T>>();\n\n const getCachedValue = async (arg: A): Promise<T> => {\n const cacheKey = JSON.stringify(arg);\n const now = Date.now();\n\n // If cache is valid, return cached value\n const cachedEntry = cacheMap.get(cacheKey);\n if (cachedEntry && now <= cachedEntry.expiresAt) {\n return cachedEntry.value;\n }\n\n // If there's already a fetch in progress for this key, return its promise\n const existingPromise = fetchPromises.get(cacheKey);\n if (existingPromise) return existingPromise;\n\n // Start new fetch\n try {\n const promise = fetchFn(arg);\n fetchPromises.set(cacheKey, promise);\n\n const freshValue = await promise;\n cacheMap.set(cacheKey, {\n value: freshValue,\n expiresAt: Date.now() + expiryTimeMs,\n });\n\n return freshValue;\n } finally {\n fetchPromises.delete(cacheKey);\n }\n };\n\n return {\n invalidate: () => {\n cacheMap.clear();\n fetchPromises.clear();\n },\n current: getCachedValue,\n };\n}\n"]}
1
+ {"version":3,"file":"cache.js","sourceRoot":"src/","sources":["cache.ts"],"names":[],"mappings":";;;AAUA,kBACE,OAA+B,EAC/B,YAAoB,EACD;IACnB,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;IAClD,MAAM,aAAa,GAAG,IAAI,GAAG,EAAsB,CAAC;IA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>;\n invalidate: () => void;\n};\n\nexport function useCache<T, A>(\n fetchFn: (arg: A) => Promise<T>,\n expiryTimeMs: number\n): CacheResult<T, A> {\n const cacheMap = new Map<string, CacheEntry<T>>();\n const fetchPromises = new Map<string, Promise<T>>();\n\n const getCachedValue = async (arg: A): Promise<T> => {\n const cacheKey = JSON.stringify(arg);\n const now = Date.now();\n\n // If cache is valid, return cached value\n const cachedEntry = cacheMap.get(cacheKey);\n if (cachedEntry && now <= cachedEntry.expiresAt) {\n return cachedEntry.value;\n }\n\n // If there's already a fetch in progress for this key, return its promise\n const existingPromise = fetchPromises.get(cacheKey);\n if (existingPromise) return existingPromise;\n\n // Start new fetch\n try {\n const promise = fetchFn(arg);\n fetchPromises.set(cacheKey, promise);\n\n const freshValue = await promise;\n cacheMap.set(cacheKey, {\n value: freshValue,\n expiresAt: Date.now() + expiryTimeMs,\n });\n\n return freshValue;\n } finally {\n fetchPromises.delete(cacheKey);\n }\n };\n\n return {\n invalidate: () => {\n cacheMap.clear();\n fetchPromises.clear();\n },\n current: getCachedValue,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"src/","sources":["client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,oCAuFC;AAlGD,qDAAuC;AACvC,6CAG2B;AAC3B,kEAAyC;AACzC,mCAAmC;AAEnC,+BAA0C;AAG1C,SAAgB,YAAY,CAAC,EAC3B,OAAO,EAAE,IAAI,EACb,KAAK,EACL,IAAI,EACJ,SAAS,EAAE,GAAG;AACd,cAAc;AACd,OAAO,EACP,OAAO,EAAE,CAAC,EACV,GAAG,oBAAoB,EAYD;IACtB,MAAM,OAAO,GACX,CAAC,KAAK;QACJ,CAAC,CAAC,oBAAoB,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE;QAChE,CAAC,CAAC,IAAI,CAAC,IAAI,4BAA4B,CA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,GAAc,MAAa,CAAC;IAC/C,aAAa,CAAC,SAAS,GAAG,SAAS,CAAC;IACpC,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import * as Sentry from '@sentry/core';\nimport {\n type RetryableFetchParams,\n useRetryableFetch,\n} from '@vrplatform/utils';\nimport createClient from 'openapi-fetch';\nimport { useCache } from './cache';\nimport type { paths } from './generated/v1';\nimport { generateApiKeySec } from './sec';\nimport type { ApiClient, ApiClientAuth } from './types';\n\nexport function useApiClient({\n baseUrl: base,\n local,\n auth,\n sessionId: sid,\n // headers: h,\n testing,\n headers: h,\n ...retryableFetchParams\n}: {\n attempts?: number;\n auth?: ApiClientAuth | (() => ApiClientAuth);\n baseUrl?: string;\n sessionId?: string;\n local?: boolean | number;\n headers?: Record<string, string> | (() => Record<string, string>);\n testing?: {\n overwriteUri?: string;\n getOverwriteTimestamp?: () => number | undefined;\n };\n} & RetryableFetchParams) {\n const baseUrl =\n (local\n ? `http://localhost:${typeof local === 'number' ? local : 8877}`\n : base) || 'https://api.vrplatform.app';\n\n const sessionId = sid || crypto.randomUUID();\n // cache the sec key for 1 minute (its valid for 5 minutes on the API)\n const cache = useCache(\n async (v: string) =>\n generateApiKeySec(v, testing?.getOverwriteTimestamp?.()),\n 60_000\n );\n\n const retryableFetch = useRetryableFetch({\n ...retryableFetchParams,\n onRetry(arg) {\n cache.invalidate();\n if (retryableFetchParams.onRetry) retryableFetchParams.onRetry(arg);\n },\n });\n\n const trace = Sentry.getTraceData();\n const client = createClient<paths>({\n baseUrl,\n querySerializer: {\n array: {\n explode: false,\n style: 'form',\n },\n },\n fetch(req) {\n return retryableFetch(async () => {\n let clone: any = req.clone() as any;\n if (testing?.overwriteUri)\n clone = new Request(testing.overwriteUri, clone);\n\n const a = (typeof auth === 'function' ? auth() : auth) || {};\n if (sessionId) clone.headers.set('X-Session-Id', sessionId);\n if (a.sec)\n clone.headers.set('X-Api-Key', `Sec ${await cache.current(a.sec)}`);\n if (a.apiKey) clone.headers.set('X-Api-Key', a.apiKey);\n if (a.tenantId) clone.headers.set('X-Team-Id', a.tenantId);\n if (a.accessToken)\n clone.headers.set(\n 'Authorization',\n a.accessToken.startsWith('Bearer ')\n ? a.accessToken\n : `Bearer ${a.accessToken}`\n );\n const additionalHeaders = h ? (typeof h === 'function' ? h() : h) : {};\n for (const key in additionalHeaders) {\n clone.headers.set(key, additionalHeaders[key]);\n }\n\n if (trace['sentry-trace'])\n clone.headers.set('sentry-trace', trace['sentry-trace']);\n if (trace.baggage) clone.headers.set('baggage', trace.baggage);\n\n return clone;\n });\n },\n });\n\n const sessionClient: ApiClient = client as any;\n sessionClient.sessionId = sessionId;\n return sessionClient;\n}\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"src/","sources":["client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,MAAM,yCAAqB;AACvC,6CAG2B;AAC3B,kEAAyC;AACzC,mCAAmC;AAEnC,+BAA0C;AAG1C,sBAA6B,EAC3B,OAAO,EAAE,IAAI,EACb,KAAK,EACL,IAAI,EACJ,SAAS,EAAE,GAAG;AACd,cAAc;AACd,OAAO,EACP,OAAO,EAAE,CAAC,EACV,GAAG,oBAAoB,EAYD,EAAE;IACxB,MAAM,OAAO,GACX,CAAC,KAAK;QACJ,CAAC,CAAC,oBAAoB,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE;QAChE,CAAC,CAAC,IAAI,CAAC,IAAI,4BAA4B,CAAC;IAE5C,MAAM,SAAS,GAAG,GAAG,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;IAC7C,sEAAsE;IACtE,MAAM,KAAK,GAAG,IAAA,gBAAQ,EACpB,KAAK,EAAE,CAAS,EAAE,EAAE,CAClB,IAAA,uBAAiB,EAAC,CAAC,EAAE,OAAO,EAAE,qBAAqB,EAAE,EAAE,CAAC,EAC1D,KAAM,CACP,CAAC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oBAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;gBAC3D,IAAI,CAAC,CAAC,WAAW;oBACf,KAAK,CAAC,OAAO,CAAC,GAAG,CACf,eAAe,EACf,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC;wBACjC,CAAC,CAAC,CAAC,CAAC,WAAW;wBACf,CAAC,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAC9B,CAAC;gBACJ,MAAM,iBAAiB,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvE,KAAK,MAAM,GAAG,IAAI,iBAAiB,EAAE,CAAC;oBACpC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC;gBACjD,CAAC;gBAED,IAAI,KAAK,CAAC,cAAc,CAAC;oBACvB,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;gBAC3D,IAAI,KAAK,CAAC,OAAO;oBAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;gBAE/D,OAAO,KAAK,CAAC;YAAA,CACd,CAAC,CAAC;QAAA,CACJ;KACF,CAAC,CAAC;IAEH,MAAM,aAAa,GAAc,MAAa,CAAC;IAC/C,aAAa,CAAC,SAAS,GAAG,SAAS,CAAC;IACpC,OAAO,aAAa,CAAC;AAAA,CACtB","sourcesContent":["import * as Sentry from '@sentry/core';\nimport {\n type RetryableFetchParams,\n useRetryableFetch,\n} from '@vrplatform/utils';\nimport createClient from 'openapi-fetch';\nimport { useCache } from './cache';\nimport type { paths } from './generated/v1';\nimport { generateApiKeySec } from './sec';\nimport type { ApiClient, ApiClientAuth } from './types';\n\nexport function useApiClient({\n baseUrl: base,\n local,\n auth,\n sessionId: sid,\n // headers: h,\n testing,\n headers: h,\n ...retryableFetchParams\n}: {\n attempts?: number;\n auth?: ApiClientAuth | (() => ApiClientAuth);\n baseUrl?: string;\n sessionId?: string;\n local?: boolean | number;\n headers?: Record<string, string> | (() => Record<string, string>);\n testing?: {\n overwriteUri?: string;\n getOverwriteTimestamp?: () => number | undefined;\n };\n} & RetryableFetchParams) {\n const baseUrl =\n (local\n ? `http://localhost:${typeof local === 'number' ? local : 8877}`\n : base) || 'https://api.vrplatform.app';\n\n const sessionId = sid || crypto.randomUUID();\n // cache the sec key for 1 minute (its valid for 5 minutes on the API)\n const cache = useCache(\n async (v: string) =>\n generateApiKeySec(v, testing?.getOverwriteTimestamp?.()),\n 60_000\n );\n\n const retryableFetch = useRetryableFetch({\n ...retryableFetchParams,\n onRetry(arg) {\n cache.invalidate();\n if (retryableFetchParams.onRetry) retryableFetchParams.onRetry(arg);\n },\n });\n\n const trace = Sentry.getTraceData();\n const client = createClient<paths>({\n baseUrl,\n querySerializer: {\n array: {\n explode: false,\n style: 'form',\n },\n },\n fetch(req) {\n return retryableFetch(async () => {\n let clone: any = req.clone() as any;\n if (testing?.overwriteUri)\n clone = new Request(testing.overwriteUri, clone);\n\n const a = (typeof auth === 'function' ? auth() : auth) || {};\n if (sessionId) clone.headers.set('X-Session-Id', sessionId);\n if (a.sec)\n clone.headers.set('X-Api-Key', `Sec ${await cache.current(a.sec)}`);\n if (a.apiKey) clone.headers.set('X-Api-Key', a.apiKey);\n if (a.tenantId) clone.headers.set('X-Team-Id', a.tenantId);\n if (a.accessToken)\n clone.headers.set(\n 'Authorization',\n a.accessToken.startsWith('Bearer ')\n ? a.accessToken\n : `Bearer ${a.accessToken}`\n );\n const additionalHeaders = h ? (typeof h === 'function' ? h() : h) : {};\n for (const key in additionalHeaders) {\n clone.headers.set(key, additionalHeaders[key]);\n }\n\n if (trace['sentry-trace'])\n clone.headers.set('sentry-trace', trace['sentry-trace']);\n if (trace.baggage) clone.headers.set('baggage', trace.baggage);\n\n return clone;\n });\n },\n });\n\n const sessionClient: ApiClient = client as any;\n sessionClient.sessionId = sessionId;\n return sessionClient;\n}\n"]}
@@ -4,6 +4,10 @@ exports.ApiClientError = void 0;
4
4
  exports.throwIfError = throwIfError;
5
5
  const utils_1 = require("@vrplatform/utils");
6
6
  class ApiClientError extends Error {
7
+ error;
8
+ code;
9
+ issues;
10
+ context;
7
11
  constructor(error) {
8
12
  const message = error.message ||
9
13
  [
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"src/","sources":["error.ts"],"names":[],"mappings":";;;AA+CA,oCAuBC;AAtED,6CAA6C;AAY7C,MAAa,cAAe,SAAQ,KAAK;IAMvC,YAAmB,KAAQ;QACzB,MAAM,OAAO,GACX,KAAK,CAAC,OAAO;YACb;gBACE,KAAK,CAAC,IAAI;gBACV,KAAK,CAAC,MAAM;oBACV,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACV,CAAC,CAAC,CAAC,OAAO,EAAG,CAAS,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;qBACrC,MAAM,CAAC,gBAAQ,CAAC;qBAChB,IAAI,CAAC,MAAM,CAAC,CAChB;qBACA,IAAI,CAAC,IAAI,CAAC;aACd;iBACE,MAAM,CAAC,gBAAQ,CAAC;iBAChB,IAAI,CAAC,IAAI,CAAC,CAAC;QAChB,KAAK,CAAC,OAAO,CAAC,CAAC;QAfE,UAAK,GAAL,KAAK,CAAG;QAiBzB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;QACnC,IAAI,KAAK,CAAC,KAAK;YAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAC5C,CAAC;CACF;AA5BD,wCA4BC;AAOD,SAAgB,YAAY,CAC1B,QAAwB;IAExB,IAAI,QAAQ,YAAY,OAAO,EAAE,CAAC;QAChC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;YAChC,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBACrC,MAAM,IAAI,cAAc,CAAC;oBACvB,IAAI,EAAE,qBAAqB;oBAC3B,OAAO,EAAE,4BAA4B;iBACtC,CAAC,CAAC;YACL,CAAC;YAED,MAAM,KAAK,GAAM,QAAQ,CAAC,KAAK,CAAC;YAEhC,IAAI,KAAK;gBAAE,MAAM,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;YAC3C,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,KAAK,GAAM,QAAQ,CAAC,KAAK,CAAC;IAEhC,IAAI,KAAK;QAAE,MAAM,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC","sourcesContent":["import { hasValue } from '@vrplatform/utils';\nimport type { FetchResponse } from './generated/openapi-fetch';\n\ntype E = {\n code: string;\n message: string;\n issues?: {\n message: string;\n }[];\n context?: any;\n stack?: any;\n};\nexport class ApiClientError extends Error {\n code: string;\n issues: {\n message: string;\n }[];\n context: any;\n constructor(public error: E) {\n const message =\n error.message ||\n [\n error.code,\n error.issues\n ?.map((x) =>\n [x.message, (x as any).path?.join('->')]\n .filter(hasValue)\n .join(' on ')\n )\n .join(', '),\n ]\n .filter(hasValue)\n .join(': ');\n super(message);\n\n this.code = error.code;\n this.issues = error.issues || [];\n this.context = error.context || {};\n if (error.stack) this.stack = error.stack;\n }\n}\nexport function throwIfError<T extends FetchResponse<any, any, any>>(\n response: T\n): NonNullable<T['data']>;\nexport function throwIfError<T extends FetchResponse<any, any, any>>(\n response: Promise<T>\n): Promise<NonNullable<T['data']>>;\nexport function throwIfError<T extends FetchResponse<any, any, any>>(\n response: Promise<T> | T\n): Promise<NonNullable<T['data']>> | NonNullable<T['data']> {\n if (response instanceof Promise) {\n return response.then((response) => {\n if (response.response.status === 503) {\n throw new ApiClientError({\n code: 'SERVICE_UNAVAILABLE',\n message: 'Worker resources exceeded.',\n });\n }\n\n const error: E = response.error;\n\n if (error) throw new ApiClientError(error);\n return response.data;\n });\n }\n\n const error: E = response.error;\n\n if (error) throw new ApiClientError(error);\n return response.data;\n}\n"]}
1
+ {"version":3,"file":"error.js","sourceRoot":"src/","sources":["error.ts"],"names":[],"mappings":";;;;AAAA,6CAA6C;AAY7C,oBAA4B,SAAQ,KAAK;IAMpB,KAAK;IALxB,IAAI,CAAS;IACb,MAAM,CAEF;IACJ,OAAO,CAAM;IACb,YAAmB,KAAQ,EAAE;QAC3B,MAAM,OAAO,GACX,KAAK,CAAC,OAAO;YACb;gBACE,KAAK,CAAC,IAAI;gBACV,KAAK,CAAC,MAAM;oBACV,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACV,CAAC,CAAC,CAAC,OAAO,EAAG,CAAS,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;qBACrC,MAAM,CAAC,gBAAQ,CAAC;qBAChB,IAAI,CAAC,MAAM,CAAC,CAChB;qBACA,IAAI,CAAC,IAAI,CAAC;aACd;iBACE,MAAM,CAAC,gBAAQ,CAAC;iBAChB,IAAI,CAAC,IAAI,CAAC,CAAC;QAChB,KAAK,CAAC,OAAO,CAAC,CAAC;qBAfE,KAAK;QAiBtB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;QACnC,IAAI,KAAK,CAAC,KAAK;YAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAAA,CAC3C;CACF;;AAOD,sBACE,QAAwB,EACkC;IAC1D,IAAI,QAAQ,YAAY,OAAO,EAAE,CAAC;QAChC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC;YACjC,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBACrC,MAAM,IAAI,cAAc,CAAC;oBACvB,IAAI,EAAE,qBAAqB;oBAC3B,OAAO,EAAE,4BAA4B;iBACtC,CAAC,CAAC;YACL,CAAC;YAED,MAAM,KAAK,GAAM,QAAQ,CAAC,KAAK,CAAC;YAEhC,IAAI,KAAK;gBAAE,MAAM,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;YAC3C,OAAO,QAAQ,CAAC,IAAI,CAAC;QAAA,CACtB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,KAAK,GAAM,QAAQ,CAAC,KAAK,CAAC;IAEhC,IAAI,KAAK;QAAE,MAAM,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,QAAQ,CAAC,IAAI,CAAC;AAAA,CACtB","sourcesContent":["import { hasValue } from '@vrplatform/utils';\nimport type { FetchResponse } from './generated/openapi-fetch';\n\ntype E = {\n code: string;\n message: string;\n issues?: {\n message: string;\n }[];\n context?: any;\n stack?: any;\n};\nexport class ApiClientError extends Error {\n code: string;\n issues: {\n message: string;\n }[];\n context: any;\n constructor(public error: E) {\n const message =\n error.message ||\n [\n error.code,\n error.issues\n ?.map((x) =>\n [x.message, (x as any).path?.join('->')]\n .filter(hasValue)\n .join(' on ')\n )\n .join(', '),\n ]\n .filter(hasValue)\n .join(': ');\n super(message);\n\n this.code = error.code;\n this.issues = error.issues || [];\n this.context = error.context || {};\n if (error.stack) this.stack = error.stack;\n }\n}\nexport function throwIfError<T extends FetchResponse<any, any, any>>(\n response: T\n): NonNullable<T['data']>;\nexport function throwIfError<T extends FetchResponse<any, any, any>>(\n response: Promise<T>\n): Promise<NonNullable<T['data']>>;\nexport function throwIfError<T extends FetchResponse<any, any, any>>(\n response: Promise<T> | T\n): Promise<NonNullable<T['data']>> | NonNullable<T['data']> {\n if (response instanceof Promise) {\n return response.then((response) => {\n if (response.response.status === 503) {\n throw new ApiClientError({\n code: 'SERVICE_UNAVAILABLE',\n message: 'Worker resources exceeded.',\n });\n }\n\n const error: E = response.error;\n\n if (error) throw new ApiClientError(error);\n return response.data;\n });\n }\n\n const error: E = response.error;\n\n if (error) throw new ApiClientError(error);\n return response.data;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"openapi-fetch.js","sourceRoot":"src/","sources":["generated/openapi-fetch.ts"],"names":[],"mappings":";;AA2YE,wCAAc;AACd,sDAAqB;AACrB,sDAAqB;AACrB,sDAAqB;AACrB,sDAAqB;AACrB,oCAAY;AACZ,kDAAmB;AACnB,kDAAmB;AACnB,oDAAoB;AACpB,0DAAuB;AACvB,sDAAqB","sourcesContent":["import type {\n ErrorResponse,\n FilterKeys,\n HttpMethod,\n IsOperationRequestBodyOptional,\n MediaType,\n OperationRequestBodyContent,\n PathsWithMethod,\n RequiredKeysOf,\n ResponseObjectMap,\n SuccessResponse,\n} from 'openapi-typescript-helpers';\n\n/** Options for each client instance */\ninterface ClientOptions extends Omit<RequestInit, 'headers'> {\n /** set the common root URL for all API requests */\n baseUrl?: string;\n /** custom fetch (defaults to globalThis.fetch) */\n fetch?: (input: Request) => Promise<Response>;\n /** custom Request (defaults to globalThis.Request) */\n Request?: typeof Request;\n /** global querySerializer */\n querySerializer?: QuerySerializer<unknown> | QuerySerializerOptions;\n /** global bodySerializer */\n bodySerializer?: BodySerializer<unknown>;\n headers?: HeadersOptions;\n /** RequestInit extension object to pass as 2nd argument to fetch when supported (defaults to undefined) */\n requestInitExt?: Record<string, unknown>;\n}\n\ntype HeadersOptions =\n | Required<RequestInit>['headers']\n | Record<\n string,\n | string\n | number\n | boolean\n | (string | number | boolean)[]\n | null\n | undefined\n >;\n\ntype QuerySerializer<T> = (\n query: T extends { parameters: any }\n ? NonNullable<T['parameters']['query']>\n : Record<string, unknown>\n) => string;\n\n/** @see https://swagger.io/docs/specification/serialization/#query */\ntype QuerySerializerOptions = {\n /** Set serialization for arrays. @see https://swagger.io/docs/specification/serialization/#query */\n array?: {\n /** default: \"form\" */\n style: 'form' | 'spaceDelimited' | 'pipeDelimited';\n /** default: true */\n explode: boolean;\n };\n /** Set serialization for objects. @see https://swagger.io/docs/specification/serialization/#query */\n object?: {\n /** default: \"deepObject\" */\n style: 'form' | 'deepObject';\n /** default: true */\n explode: boolean;\n };\n /**\n * The `allowReserved` keyword specifies whether the reserved characters\n * `:/?#[]@!$&'()*+,;=` in parameter values are allowed to be sent as they\n * are, or should be percent-encoded. By default, allowReserved is `false`,\n * and reserved characters are percent-encoded.\n * @see https://swagger.io/docs/specification/serialization/#query\n */\n allowReserved?: boolean;\n};\n\ntype BodySerializer<T> = (body: OperationRequestBodyContent<T>) => any;\n\ntype BodyType<T = unknown> = {\n json: T;\n text: Awaited<ReturnType<Response['text']>>;\n blob: Awaited<ReturnType<Response['blob']>>;\n arrayBuffer: Awaited<ReturnType<Response['arrayBuffer']>>;\n stream: Response['body'];\n};\ntype ParseAs = keyof BodyType;\ntype ParseAsResponse<T, Options> = Options extends {\n parseAs: ParseAs;\n}\n ? BodyType<T>[Options['parseAs']]\n : T;\n\ninterface DefaultParamsOption {\n params?: {\n query?: Record<string, unknown>;\n };\n}\n\ntype ParamsOption<T> = T extends {\n parameters: any;\n}\n ? RequiredKeysOf<T['parameters']> extends never\n ? { params?: T['parameters'] }\n : { params: T['parameters'] }\n : DefaultParamsOption;\n\ntype RequestBodyOption<T> = OperationRequestBodyContent<T> extends never\n ? { body?: never }\n : IsOperationRequestBodyOptional<T> extends true\n ? { body?: OperationRequestBodyContent<T> }\n : { body: OperationRequestBodyContent<T> };\n\ntype FetchOptions<T> = RequestOptions<T> &\n Omit<RequestInit, 'body' | 'headers'>;\n\ntype FetchResponse<\n T extends Record<string | number, any>,\n Options,\n Media extends MediaType,\n> =\n | {\n data: ParseAsResponse<\n SuccessResponse<ResponseObjectMap<T>, Media>,\n Options\n >;\n error?: never;\n response: Response;\n }\n | {\n data?: never;\n error: ErrorResponse<ResponseObjectMap<T>, Media>;\n response: Response;\n };\n\ntype RequestOptions<T> = ParamsOption<T> &\n RequestBodyOption<T> & {\n baseUrl?: string;\n querySerializer?: QuerySerializer<T> | QuerySerializerOptions;\n bodySerializer?: BodySerializer<T>;\n parseAs?: ParseAs;\n fetch?: ClientOptions['fetch'];\n headers?: HeadersOptions;\n };\n\ntype MergedOptions<T = unknown> = {\n baseUrl: string;\n parseAs: ParseAs;\n querySerializer: QuerySerializer<T>;\n bodySerializer: BodySerializer<T>;\n fetch: typeof globalThis.fetch;\n};\n\ninterface MiddlewareCallbackParams {\n /** Current Request object */\n request: Request;\n /** The original OpenAPI schema path (including curly braces) */\n readonly schemaPath: string;\n /** OpenAPI parameters as provided from openapi-fetch */\n readonly params: {\n query?: Record<string, unknown>;\n header?: Record<string, unknown>;\n path?: Record<string, unknown>;\n cookie?: Record<string, unknown>;\n };\n /** Unique ID for this request */\n readonly id: string;\n /** createClient options (read-only) */\n readonly options: MergedOptions;\n}\n\ntype MiddlewareOnRequest = (options: MiddlewareCallbackParams) =>\n | void\n | Request\n | Response\n | undefined\n // biome-ignore lint/suspicious/noConfusingVoidType: N\n | Promise<Request | Response | undefined | void>;\ntype MiddlewareOnResponse = (\n options: MiddlewareCallbackParams & { response: Response }\n // biome-ignore lint/suspicious/noConfusingVoidType: N\n) => void | Response | undefined | Promise<Response | undefined | void>;\ntype MiddlewareOnError = (\n options: MiddlewareCallbackParams & { error: unknown }\n // biome-ignore lint/suspicious/noConfusingVoidType: N\n) => void | Response | Error | Promise<void | Response | Error>;\n\ntype Middleware =\n | {\n onRequest: MiddlewareOnRequest;\n onResponse?: MiddlewareOnResponse;\n onError?: MiddlewareOnError;\n }\n | {\n onRequest?: MiddlewareOnRequest;\n onResponse: MiddlewareOnResponse;\n onError?: MiddlewareOnError;\n }\n | {\n onRequest?: MiddlewareOnRequest;\n onResponse?: MiddlewareOnResponse;\n onError: MiddlewareOnError;\n };\n\n/** This type helper makes the 2nd function param required if params/requestBody are required; otherwise, optional */\ntype MaybeOptionalInit<Params, Location extends keyof Params> = RequiredKeysOf<\n FetchOptions<FilterKeys<Params, Location>>\n> extends never\n ? FetchOptions<FilterKeys<Params, Location>> | undefined\n : FetchOptions<FilterKeys<Params, Location>>;\n\n// The final init param to accept.\n// - Determines if the param is optional or not.\n// - Performs arbitrary [key: string] addition.\n// Note: the addition MUST happen after all the inference happens (otherwise TS can’t infer if init is required or not).\ntype InitParam<Init> = RequiredKeysOf<Init> extends never\n ? [(Init & { [key: string]: unknown })?]\n : [Init & { [key: string]: unknown }];\n\ntype ClientMethod<\n // biome-ignore lint/complexity/noBannedTypes: N\n Paths extends Record<string, Record<HttpMethod, {}>>,\n Method extends HttpMethod,\n Media extends MediaType,\n> = <\n Path extends PathsWithMethod<Paths, Method>,\n Init extends MaybeOptionalInit<Paths[Path], Method>,\n>(\n url: Path,\n ...init: InitParam<Init>\n) => Promise<FetchResponse<Paths[Path][Method], Init, Media>>;\n\ntype ClientRequestMethod<\n // biome-ignore lint/complexity/noBannedTypes: N\n Paths extends Record<string, Record<HttpMethod, {}>>,\n Media extends MediaType,\n> = <\n Method extends HttpMethod,\n Path extends PathsWithMethod<Paths, Method>,\n Init extends MaybeOptionalInit<Paths[Path], Method>,\n>(\n method: Method,\n url: Path,\n ...init: InitParam<Init>\n) => Promise<FetchResponse<Paths[Path][Method], Init, Media>>;\n\ntype ClientForPath<\n PathInfo extends Record<string | number, any>,\n Media extends MediaType,\n> = {\n [Method in keyof PathInfo as Uppercase<string & Method>]: <\n Init extends MaybeOptionalInit<PathInfo, Method>,\n >(\n ...init: InitParam<Init>\n ) => Promise<FetchResponse<PathInfo[Method], Init, Media>>;\n};\n\ninterface Client<Paths extends {}, Media extends MediaType = MediaType> {\n request: ClientRequestMethod<Paths, Media>;\n /** Call a GET endpoint */\n GET: ClientMethod<Paths, 'get', Media>;\n /** Call a PUT endpoint */\n PUT: ClientMethod<Paths, 'put', Media>;\n /** Call a POST endpoint */\n POST: ClientMethod<Paths, 'post', Media>;\n /** Call a DELETE endpoint */\n DELETE: ClientMethod<Paths, 'delete', Media>;\n /** Call a OPTIONS endpoint */\n OPTIONS: ClientMethod<Paths, 'options', Media>;\n /** Call a HEAD endpoint */\n HEAD: ClientMethod<Paths, 'head', Media>;\n /** Call a PATCH endpoint */\n PATCH: ClientMethod<Paths, 'patch', Media>;\n /** Call a TRACE endpoint */\n TRACE: ClientMethod<Paths, 'trace', Media>;\n /** Register middleware */\n use(...middleware: Middleware[]): void;\n /** Unregister middleware */\n eject(...middleware: Middleware[]): void;\n}\n\ntype ClientPathsWithMethod<\n CreatedClient extends Client<any, any>,\n Method extends HttpMethod,\n> = CreatedClient extends Client<infer Paths, infer _Media>\n ? PathsWithMethod<Paths, Method>\n : never;\n\ntype MethodResponse<\n CreatedClient extends Client<any, any>,\n Method extends HttpMethod,\n Path extends ClientPathsWithMethod<CreatedClient, Method>,\n // biome-ignore lint/complexity/noBannedTypes: Bla\n Options = {},\n> = CreatedClient extends Client<\n infer Paths extends { [key: string]: any },\n infer Media extends MediaType\n>\n ? NonNullable<FetchResponse<Paths[Path][Method], Options, Media>['data']>\n : never;\n\ndeclare function createClient<\n Paths extends {},\n Media extends MediaType = MediaType,\n>(clientOptions?: ClientOptions): Client<Paths, Media>;\n\ntype PathBasedClient<\n Paths extends Record<string | number, any>,\n Media extends MediaType = MediaType,\n> = {\n [Path in keyof Paths]: ClientForPath<Paths[Path], Media>;\n};\n\ndeclare function wrapAsPathBasedClient<\n Paths extends {},\n Media extends MediaType = MediaType,\n>(client: Client<Paths, Media>): PathBasedClient<Paths, Media>;\n\ndeclare function createPathBasedClient<\n Paths extends {},\n Media extends MediaType = MediaType,\n>(clientOptions?: ClientOptions): PathBasedClient<Paths, Media>;\n\n/** Serialize primitive params to string */\ndeclare function serializePrimitiveParam(\n name: string,\n value: string,\n options?: { allowReserved?: boolean }\n): string;\n\n/** Serialize object param to string */\ndeclare function serializeObjectParam(\n name: string,\n value: Record<string, unknown>,\n options: {\n style: 'simple' | 'label' | 'matrix' | 'form' | 'deepObject';\n explode: boolean;\n allowReserved?: boolean;\n }\n): string;\n\n/** Serialize array param to string */\ndeclare function serializeArrayParam(\n name: string,\n value: unknown[],\n options: {\n style:\n | 'simple'\n | 'label'\n | 'matrix'\n | 'form'\n | 'spaceDelimited'\n | 'pipeDelimited';\n explode: boolean;\n allowReserved?: boolean;\n }\n): string;\n\n/** Serialize query params to string */\ndeclare function createQuerySerializer<T = unknown>(\n options?: QuerySerializerOptions\n): (queryParams: T) => string;\n\n/**\n * Handle different OpenAPI 3.x serialization styles\n * @type {import(\"openapi-fetch\").defaultPathSerializer}\n * @see https://swagger.io/docs/specification/serialization/#path\n */\ndeclare function defaultPathSerializer(\n pathname: string,\n pathParams: Record<string, unknown>\n): string;\n\n/** Serialize body object to string */\ndeclare function defaultBodySerializer<T>(body: T): string;\n\n/** Construct URL string from baseUrl and handle path and query params */\ndeclare function createFinalURL<O>(\n pathname: string,\n options: {\n baseUrl: string;\n params: {\n query?: Record<string, unknown>;\n path?: Record<string, unknown>;\n };\n querySerializer: QuerySerializer<O>;\n }\n): string;\n\n/** Merge headers a and b, with b taking priority */\ndeclare function mergeHeaders(\n ...allHeaders: (HeadersOptions | undefined)[]\n): Headers;\n\n/** Remove trailing slash from url */\ndeclare function removeTrailingSlash(url: string): string;\n\nexport {\n createFinalURL,\n createPathBasedClient,\n createQuerySerializer,\n defaultBodySerializer,\n defaultPathSerializer,\n mergeHeaders,\n removeTrailingSlash,\n serializeArrayParam,\n serializeObjectParam,\n serializePrimitiveParam,\n wrapAsPathBasedClient,\n};\nexport type {\n BodySerializer,\n Client,\n ClientForPath,\n ClientMethod,\n ClientOptions,\n ClientPathsWithMethod,\n ClientRequestMethod,\n DefaultParamsOption,\n FetchOptions,\n FetchResponse,\n HeadersOptions,\n MaybeOptionalInit,\n MergedOptions,\n MethodResponse,\n Middleware,\n MiddlewareCallbackParams,\n ParamsOption,\n ParseAs,\n ParseAsResponse,\n PathBasedClient,\n QuerySerializer,\n QuerySerializerOptions,\n RequestBodyOption,\n RequestOptions,\n};\n"]}
1
+ {"version":3,"file":"openapi-fetch.js","sourceRoot":"src/","sources":["generated/openapi-fetch.ts"],"names":[],"mappings":";;QA2YE,cAAc;QACd,qBAAqB;QACrB,qBAAqB;QACrB,qBAAqB;QACrB,qBAAqB;QACrB,YAAY;QACZ,mBAAmB;QACnB,mBAAmB;QACnB,oBAAoB;QACpB,uBAAuB;QACvB,qBAAqB","sourcesContent":["import type {\n ErrorResponse,\n FilterKeys,\n HttpMethod,\n IsOperationRequestBodyOptional,\n MediaType,\n OperationRequestBodyContent,\n PathsWithMethod,\n RequiredKeysOf,\n ResponseObjectMap,\n SuccessResponse,\n} from 'openapi-typescript-helpers';\n\n/** Options for each client instance */\ninterface ClientOptions extends Omit<RequestInit, 'headers'> {\n /** set the common root URL for all API requests */\n baseUrl?: string;\n /** custom fetch (defaults to globalThis.fetch) */\n fetch?: (input: Request) => Promise<Response>;\n /** custom Request (defaults to globalThis.Request) */\n Request?: typeof Request;\n /** global querySerializer */\n querySerializer?: QuerySerializer<unknown> | QuerySerializerOptions;\n /** global bodySerializer */\n bodySerializer?: BodySerializer<unknown>;\n headers?: HeadersOptions;\n /** RequestInit extension object to pass as 2nd argument to fetch when supported (defaults to undefined) */\n requestInitExt?: Record<string, unknown>;\n}\n\ntype HeadersOptions =\n | Required<RequestInit>['headers']\n | Record<\n string,\n | string\n | number\n | boolean\n | (string | number | boolean)[]\n | null\n | undefined\n >;\n\ntype QuerySerializer<T> = (\n query: T extends { parameters: any }\n ? NonNullable<T['parameters']['query']>\n : Record<string, unknown>\n) => string;\n\n/** @see https://swagger.io/docs/specification/serialization/#query */\ntype QuerySerializerOptions = {\n /** Set serialization for arrays. @see https://swagger.io/docs/specification/serialization/#query */\n array?: {\n /** default: \"form\" */\n style: 'form' | 'spaceDelimited' | 'pipeDelimited';\n /** default: true */\n explode: boolean;\n };\n /** Set serialization for objects. @see https://swagger.io/docs/specification/serialization/#query */\n object?: {\n /** default: \"deepObject\" */\n style: 'form' | 'deepObject';\n /** default: true */\n explode: boolean;\n };\n /**\n * The `allowReserved` keyword specifies whether the reserved characters\n * `:/?#[]@!$&'()*+,;=` in parameter values are allowed to be sent as they\n * are, or should be percent-encoded. By default, allowReserved is `false`,\n * and reserved characters are percent-encoded.\n * @see https://swagger.io/docs/specification/serialization/#query\n */\n allowReserved?: boolean;\n};\n\ntype BodySerializer<T> = (body: OperationRequestBodyContent<T>) => any;\n\ntype BodyType<T = unknown> = {\n json: T;\n text: Awaited<ReturnType<Response['text']>>;\n blob: Awaited<ReturnType<Response['blob']>>;\n arrayBuffer: Awaited<ReturnType<Response['arrayBuffer']>>;\n stream: Response['body'];\n};\ntype ParseAs = keyof BodyType;\ntype ParseAsResponse<T, Options> = Options extends {\n parseAs: ParseAs;\n}\n ? BodyType<T>[Options['parseAs']]\n : T;\n\ninterface DefaultParamsOption {\n params?: {\n query?: Record<string, unknown>;\n };\n}\n\ntype ParamsOption<T> = T extends {\n parameters: any;\n}\n ? RequiredKeysOf<T['parameters']> extends never\n ? { params?: T['parameters'] }\n : { params: T['parameters'] }\n : DefaultParamsOption;\n\ntype RequestBodyOption<T> = OperationRequestBodyContent<T> extends never\n ? { body?: never }\n : IsOperationRequestBodyOptional<T> extends true\n ? { body?: OperationRequestBodyContent<T> }\n : { body: OperationRequestBodyContent<T> };\n\ntype FetchOptions<T> = RequestOptions<T> &\n Omit<RequestInit, 'body' | 'headers'>;\n\ntype FetchResponse<\n T extends Record<string | number, any>,\n Options,\n Media extends MediaType,\n> =\n | {\n data: ParseAsResponse<\n SuccessResponse<ResponseObjectMap<T>, Media>,\n Options\n >;\n error?: never;\n response: Response;\n }\n | {\n data?: never;\n error: ErrorResponse<ResponseObjectMap<T>, Media>;\n response: Response;\n };\n\ntype RequestOptions<T> = ParamsOption<T> &\n RequestBodyOption<T> & {\n baseUrl?: string;\n querySerializer?: QuerySerializer<T> | QuerySerializerOptions;\n bodySerializer?: BodySerializer<T>;\n parseAs?: ParseAs;\n fetch?: ClientOptions['fetch'];\n headers?: HeadersOptions;\n };\n\ntype MergedOptions<T = unknown> = {\n baseUrl: string;\n parseAs: ParseAs;\n querySerializer: QuerySerializer<T>;\n bodySerializer: BodySerializer<T>;\n fetch: typeof globalThis.fetch;\n};\n\ninterface MiddlewareCallbackParams {\n /** Current Request object */\n request: Request;\n /** The original OpenAPI schema path (including curly braces) */\n readonly schemaPath: string;\n /** OpenAPI parameters as provided from openapi-fetch */\n readonly params: {\n query?: Record<string, unknown>;\n header?: Record<string, unknown>;\n path?: Record<string, unknown>;\n cookie?: Record<string, unknown>;\n };\n /** Unique ID for this request */\n readonly id: string;\n /** createClient options (read-only) */\n readonly options: MergedOptions;\n}\n\ntype MiddlewareOnRequest = (options: MiddlewareCallbackParams) =>\n | void\n | Request\n | Response\n | undefined\n // biome-ignore lint/suspicious/noConfusingVoidType: N\n | Promise<Request | Response | undefined | void>;\ntype MiddlewareOnResponse = (\n options: MiddlewareCallbackParams & { response: Response }\n // biome-ignore lint/suspicious/noConfusingVoidType: N\n) => void | Response | undefined | Promise<Response | undefined | void>;\ntype MiddlewareOnError = (\n options: MiddlewareCallbackParams & { error: unknown }\n // biome-ignore lint/suspicious/noConfusingVoidType: N\n) => void | Response | Error | Promise<void | Response | Error>;\n\ntype Middleware =\n | {\n onRequest: MiddlewareOnRequest;\n onResponse?: MiddlewareOnResponse;\n onError?: MiddlewareOnError;\n }\n | {\n onRequest?: MiddlewareOnRequest;\n onResponse: MiddlewareOnResponse;\n onError?: MiddlewareOnError;\n }\n | {\n onRequest?: MiddlewareOnRequest;\n onResponse?: MiddlewareOnResponse;\n onError: MiddlewareOnError;\n };\n\n/** This type helper makes the 2nd function param required if params/requestBody are required; otherwise, optional */\ntype MaybeOptionalInit<Params, Location extends keyof Params> = RequiredKeysOf<\n FetchOptions<FilterKeys<Params, Location>>\n> extends never\n ? FetchOptions<FilterKeys<Params, Location>> | undefined\n : FetchOptions<FilterKeys<Params, Location>>;\n\n// The final init param to accept.\n// - Determines if the param is optional or not.\n// - Performs arbitrary [key: string] addition.\n// Note: the addition MUST happen after all the inference happens (otherwise TS can’t infer if init is required or not).\ntype InitParam<Init> = RequiredKeysOf<Init> extends never\n ? [(Init & { [key: string]: unknown })?]\n : [Init & { [key: string]: unknown }];\n\ntype ClientMethod<\n // biome-ignore lint/complexity/noBannedTypes: N\n Paths extends Record<string, Record<HttpMethod, {}>>,\n Method extends HttpMethod,\n Media extends MediaType,\n> = <\n Path extends PathsWithMethod<Paths, Method>,\n Init extends MaybeOptionalInit<Paths[Path], Method>,\n>(\n url: Path,\n ...init: InitParam<Init>\n) => Promise<FetchResponse<Paths[Path][Method], Init, Media>>;\n\ntype ClientRequestMethod<\n // biome-ignore lint/complexity/noBannedTypes: N\n Paths extends Record<string, Record<HttpMethod, {}>>,\n Media extends MediaType,\n> = <\n Method extends HttpMethod,\n Path extends PathsWithMethod<Paths, Method>,\n Init extends MaybeOptionalInit<Paths[Path], Method>,\n>(\n method: Method,\n url: Path,\n ...init: InitParam<Init>\n) => Promise<FetchResponse<Paths[Path][Method], Init, Media>>;\n\ntype ClientForPath<\n PathInfo extends Record<string | number, any>,\n Media extends MediaType,\n> = {\n [Method in keyof PathInfo as Uppercase<string & Method>]: <\n Init extends MaybeOptionalInit<PathInfo, Method>,\n >(\n ...init: InitParam<Init>\n ) => Promise<FetchResponse<PathInfo[Method], Init, Media>>;\n};\n\ninterface Client<Paths extends {}, Media extends MediaType = MediaType> {\n request: ClientRequestMethod<Paths, Media>;\n /** Call a GET endpoint */\n GET: ClientMethod<Paths, 'get', Media>;\n /** Call a PUT endpoint */\n PUT: ClientMethod<Paths, 'put', Media>;\n /** Call a POST endpoint */\n POST: ClientMethod<Paths, 'post', Media>;\n /** Call a DELETE endpoint */\n DELETE: ClientMethod<Paths, 'delete', Media>;\n /** Call a OPTIONS endpoint */\n OPTIONS: ClientMethod<Paths, 'options', Media>;\n /** Call a HEAD endpoint */\n HEAD: ClientMethod<Paths, 'head', Media>;\n /** Call a PATCH endpoint */\n PATCH: ClientMethod<Paths, 'patch', Media>;\n /** Call a TRACE endpoint */\n TRACE: ClientMethod<Paths, 'trace', Media>;\n /** Register middleware */\n use(...middleware: Middleware[]): void;\n /** Unregister middleware */\n eject(...middleware: Middleware[]): void;\n}\n\ntype ClientPathsWithMethod<\n CreatedClient extends Client<any, any>,\n Method extends HttpMethod,\n> = CreatedClient extends Client<infer Paths, infer _Media>\n ? PathsWithMethod<Paths, Method>\n : never;\n\ntype MethodResponse<\n CreatedClient extends Client<any, any>,\n Method extends HttpMethod,\n Path extends ClientPathsWithMethod<CreatedClient, Method>,\n // biome-ignore lint/complexity/noBannedTypes: Bla\n Options = {},\n> = CreatedClient extends Client<\n infer Paths extends { [key: string]: any },\n infer Media extends MediaType\n>\n ? NonNullable<FetchResponse<Paths[Path][Method], Options, Media>['data']>\n : never;\n\ndeclare function createClient<\n Paths extends {},\n Media extends MediaType = MediaType,\n>(clientOptions?: ClientOptions): Client<Paths, Media>;\n\ntype PathBasedClient<\n Paths extends Record<string | number, any>,\n Media extends MediaType = MediaType,\n> = {\n [Path in keyof Paths]: ClientForPath<Paths[Path], Media>;\n};\n\ndeclare function wrapAsPathBasedClient<\n Paths extends {},\n Media extends MediaType = MediaType,\n>(client: Client<Paths, Media>): PathBasedClient<Paths, Media>;\n\ndeclare function createPathBasedClient<\n Paths extends {},\n Media extends MediaType = MediaType,\n>(clientOptions?: ClientOptions): PathBasedClient<Paths, Media>;\n\n/** Serialize primitive params to string */\ndeclare function serializePrimitiveParam(\n name: string,\n value: string,\n options?: { allowReserved?: boolean }\n): string;\n\n/** Serialize object param to string */\ndeclare function serializeObjectParam(\n name: string,\n value: Record<string, unknown>,\n options: {\n style: 'simple' | 'label' | 'matrix' | 'form' | 'deepObject';\n explode: boolean;\n allowReserved?: boolean;\n }\n): string;\n\n/** Serialize array param to string */\ndeclare function serializeArrayParam(\n name: string,\n value: unknown[],\n options: {\n style:\n | 'simple'\n | 'label'\n | 'matrix'\n | 'form'\n | 'spaceDelimited'\n | 'pipeDelimited';\n explode: boolean;\n allowReserved?: boolean;\n }\n): string;\n\n/** Serialize query params to string */\ndeclare function createQuerySerializer<T = unknown>(\n options?: QuerySerializerOptions\n): (queryParams: T) => string;\n\n/**\n * Handle different OpenAPI 3.x serialization styles\n * @type {import(\"openapi-fetch\").defaultPathSerializer}\n * @see https://swagger.io/docs/specification/serialization/#path\n */\ndeclare function defaultPathSerializer(\n pathname: string,\n pathParams: Record<string, unknown>\n): string;\n\n/** Serialize body object to string */\ndeclare function defaultBodySerializer<T>(body: T): string;\n\n/** Construct URL string from baseUrl and handle path and query params */\ndeclare function createFinalURL<O>(\n pathname: string,\n options: {\n baseUrl: string;\n params: {\n query?: Record<string, unknown>;\n path?: Record<string, unknown>;\n };\n querySerializer: QuerySerializer<O>;\n }\n): string;\n\n/** Merge headers a and b, with b taking priority */\ndeclare function mergeHeaders(\n ...allHeaders: (HeadersOptions | undefined)[]\n): Headers;\n\n/** Remove trailing slash from url */\ndeclare function removeTrailingSlash(url: string): string;\n\nexport {\n createFinalURL,\n createPathBasedClient,\n createQuerySerializer,\n defaultBodySerializer,\n defaultPathSerializer,\n mergeHeaders,\n removeTrailingSlash,\n serializeArrayParam,\n serializeObjectParam,\n serializePrimitiveParam,\n wrapAsPathBasedClient,\n};\nexport type {\n BodySerializer,\n Client,\n ClientForPath,\n ClientMethod,\n ClientOptions,\n ClientPathsWithMethod,\n ClientRequestMethod,\n DefaultParamsOption,\n FetchOptions,\n FetchResponse,\n HeadersOptions,\n MaybeOptionalInit,\n MergedOptions,\n MethodResponse,\n Middleware,\n MiddlewareCallbackParams,\n ParamsOption,\n ParseAs,\n ParseAsResponse,\n PathBasedClient,\n QuerySerializer,\n QuerySerializerOptions,\n RequestBodyOption,\n RequestOptions,\n};\n"]}
@@ -6479,7 +6479,7 @@ export interface operations {
6479
6479
  parameters: {
6480
6480
  query?: {
6481
6481
  search?: string;
6482
- status?: ("active" | "inactive") | "pending";
6482
+ status?: "active" | "inactive" | "pending";
6483
6483
  type?: "owner" | "vendor";
6484
6484
  companyType?: "c_corporation" | "limited_liability_company" | "partnership" | "s_corporation" | "trust_estate";
6485
6485
  isIndividual?: boolean;
@@ -6523,7 +6523,8 @@ export interface operations {
6523
6523
  companyType?: ("c_corporation" | "limited_liability_company" | "partnership" | "s_corporation" | "trust_estate") | null;
6524
6524
  taxIdentifier?: string | null;
6525
6525
  uniqueRef?: string | null;
6526
- status: ("active" | "inactive") | "pending";
6526
+ /** @enum {string} */
6527
+ status: "active" | "inactive" | "pending";
6527
6528
  payoutAccountId?: string | null;
6528
6529
  /** Format: uuid */
6529
6530
  id: string;
@@ -6708,7 +6709,8 @@ export interface operations {
6708
6709
  companyType?: ("c_corporation" | "limited_liability_company" | "partnership" | "s_corporation" | "trust_estate") | null;
6709
6710
  taxIdentifier?: string | null;
6710
6711
  uniqueRef?: string | null;
6711
- status: ("active" | "inactive") | "pending";
6712
+ /** @enum {string} */
6713
+ status: "active" | "inactive" | "pending";
6712
6714
  payoutAccountId?: string | null;
6713
6715
  /** Format: uuid */
6714
6716
  id: string;
@@ -6969,7 +6971,7 @@ export interface operations {
6969
6971
  parameters: {
6970
6972
  query?: {
6971
6973
  search?: string;
6972
- status?: ("active" | "inactive") | "pending";
6974
+ status?: "active" | "inactive" | "pending";
6973
6975
  type?: "owner" | "vendor";
6974
6976
  companyType?: "c_corporation" | "limited_liability_company" | "partnership" | "s_corporation" | "trust_estate";
6975
6977
  isIndividual?: boolean;
@@ -7114,7 +7116,8 @@ export interface operations {
7114
7116
  companyType?: ("c_corporation" | "limited_liability_company" | "partnership" | "s_corporation" | "trust_estate") | null;
7115
7117
  taxIdentifier?: string | null;
7116
7118
  uniqueRef?: string | null;
7117
- status: ("active" | "inactive") | "pending";
7119
+ /** @enum {string} */
7120
+ status: "active" | "inactive" | "pending";
7118
7121
  payoutAccountId?: string | null;
7119
7122
  /** Format: uuid */
7120
7123
  id: string;
@@ -7290,7 +7293,8 @@ export interface operations {
7290
7293
  companyType?: ("c_corporation" | "limited_liability_company" | "partnership" | "s_corporation" | "trust_estate") | null;
7291
7294
  taxIdentifier?: string | null;
7292
7295
  uniqueRef?: string | null;
7293
- status: ("active" | "inactive") | "pending";
7296
+ /** @enum {string} */
7297
+ status: "active" | "inactive" | "pending";
7294
7298
  payoutAccountId?: string | null;
7295
7299
  /** Format: uuid */
7296
7300
  id: string;