@fanvue/builder-sdk 0.3.0 → 0.4.0

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.
Files changed (34) hide show
  1. package/README.md +77 -1
  2. package/dist/bridge/index.d.ts +2 -0
  3. package/dist/bridge/index.js +3 -0
  4. package/dist/bridge-CGVtI3hr.js +336 -0
  5. package/dist/bridge-CGVtI3hr.js.map +1 -0
  6. package/dist/core/index.d.ts +1 -1
  7. package/dist/core/index.js +2 -1
  8. package/dist/core-BqdYUMrJ.js +1653 -0
  9. package/dist/core-BqdYUMrJ.js.map +1 -0
  10. package/dist/index-BRDYLBlc.d.ts +223 -0
  11. package/dist/index-BRDYLBlc.d.ts.map +1 -0
  12. package/dist/{index-CweVyIKX.d.ts → index-C4ewLil3.d.ts} +2 -2
  13. package/dist/{index-CweVyIKX.d.ts.map → index-C4ewLil3.d.ts.map} +1 -1
  14. package/dist/index-ClbZoV_Z.d.ts +420 -0
  15. package/dist/index-ClbZoV_Z.d.ts.map +1 -0
  16. package/dist/{index-pS9wR5yg.d.ts → index-Dr-mZ0qP.d.ts} +500 -901
  17. package/dist/index-Dr-mZ0qP.d.ts.map +1 -0
  18. package/dist/nextjs/embedded-app/index.d.ts +2 -2
  19. package/dist/nextjs/embedded-app/index.js +3 -2
  20. package/dist/nextjs/embedded-app/index.js.map +1 -1
  21. package/dist/nextjs/off-platform/index.d.ts +2 -2
  22. package/dist/nextjs/off-platform/index.js +3 -2
  23. package/dist/nextjs/off-platform/index.js.map +1 -1
  24. package/dist/{nextjs-CESI_EiU.js → nextjs-B5Tqgt_n.js} +2 -2
  25. package/dist/{nextjs-CESI_EiU.js.map → nextjs-B5Tqgt_n.js.map} +1 -1
  26. package/dist/react/index.d.ts +37 -2
  27. package/dist/react/index.d.ts.map +1 -1
  28. package/dist/react/index.js +61 -2
  29. package/dist/react/index.js.map +1 -1
  30. package/dist/{core-CvVOMyqr.js → schemas-DbyHF7Xi.js} +261 -1662
  31. package/dist/schemas-DbyHF7Xi.js.map +1 -0
  32. package/package.json +20 -16
  33. package/dist/core-CvVOMyqr.js.map +0 -1
  34. package/dist/index-pS9wR5yg.d.ts.map +0 -1
@@ -1,837 +1,187 @@
1
- //#region src/core/constants.d.ts
2
- /** The `Bearer ` token prefix (includes trailing space). */
3
- declare const BEARER_PREFIX: "Bearer ";
4
- /** Response header carrying a refreshed session JWT back to the client. */
5
- declare const HEADER_UPDATED_SESSION: "X-Updated-Session";
6
- //#endregion
7
- //#region src/core/defaults.d.ts
8
- /** Default OAuth scopes requested during authorization. */
9
- declare const DEFAULT_SCOPES: "openid offline_access offline";
10
- /** Default OAuth issuer URL for Fanvue authentication. */
11
- declare const DEFAULT_ISSUER_URL: "https://auth.fanvue.com";
12
- /** Default base URL for the Fanvue API. */
13
- declare const DEFAULT_API_BASE_URL: "https://api.fanvue.com";
14
- /** Default base URL for the Fanvue platform (embedded authorize-on-behalf). */
15
- declare const DEFAULT_PLATFORM_URL: "https://www.fanvue.com";
16
- /** The Fanvue API version header value sent with every request. */
17
- declare const API_VERSION: "2025-06-26";
18
- /**
19
- * Validates that a URL belongs to the `fanvue.com` domain.
20
- *
21
- * @param url - The URL string to validate.
22
- * @throws If the URL is malformed or its hostname is not `fanvue.com`
23
- * (or a subdomain of it).
24
- */
25
- declare function assertFanvueDomain(url: string): void;
1
+ //#region node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema.d.cts
2
+ type _JSONSchema = boolean | JSONSchema;
3
+ type JSONSchema = {
4
+ [k: string]: unknown;
5
+ $schema?: "https://json-schema.org/draft/2020-12/schema" | "http://json-schema.org/draft-07/schema#" | "http://json-schema.org/draft-04/schema#";
6
+ $id?: string;
7
+ $anchor?: string;
8
+ $ref?: string;
9
+ $dynamicRef?: string;
10
+ $dynamicAnchor?: string;
11
+ $vocabulary?: Record<string, boolean>;
12
+ $comment?: string;
13
+ $defs?: Record<string, JSONSchema>;
14
+ type?: "object" | "array" | "string" | "number" | "boolean" | "null" | "integer";
15
+ additionalItems?: _JSONSchema;
16
+ unevaluatedItems?: _JSONSchema;
17
+ prefixItems?: _JSONSchema[];
18
+ items?: _JSONSchema | _JSONSchema[];
19
+ contains?: _JSONSchema;
20
+ additionalProperties?: _JSONSchema;
21
+ unevaluatedProperties?: _JSONSchema;
22
+ properties?: Record<string, _JSONSchema>;
23
+ patternProperties?: Record<string, _JSONSchema>;
24
+ dependentSchemas?: Record<string, _JSONSchema>;
25
+ propertyNames?: _JSONSchema;
26
+ if?: _JSONSchema;
27
+ then?: _JSONSchema;
28
+ else?: _JSONSchema;
29
+ allOf?: JSONSchema[];
30
+ anyOf?: JSONSchema[];
31
+ oneOf?: JSONSchema[];
32
+ not?: _JSONSchema;
33
+ multipleOf?: number;
34
+ maximum?: number;
35
+ exclusiveMaximum?: number | boolean;
36
+ minimum?: number;
37
+ exclusiveMinimum?: number | boolean;
38
+ maxLength?: number;
39
+ minLength?: number;
40
+ pattern?: string;
41
+ maxItems?: number;
42
+ minItems?: number;
43
+ uniqueItems?: boolean;
44
+ maxContains?: number;
45
+ minContains?: number;
46
+ maxProperties?: number;
47
+ minProperties?: number;
48
+ required?: string[];
49
+ dependentRequired?: Record<string, string[]>;
50
+ enum?: Array<string | number | boolean | null>;
51
+ const?: string | number | boolean | null;
52
+ id?: string;
53
+ title?: string;
54
+ description?: string;
55
+ default?: unknown;
56
+ deprecated?: boolean;
57
+ readOnly?: boolean;
58
+ writeOnly?: boolean;
59
+ nullable?: boolean;
60
+ examples?: unknown[];
61
+ format?: string;
62
+ contentMediaType?: string;
63
+ contentEncoding?: string;
64
+ contentSchema?: JSONSchema;
65
+ _prefault?: unknown;
66
+ };
67
+ type BaseSchema = JSONSchema;
26
68
  //#endregion
27
- //#region src/core/types.d.ts
28
- /**
29
- * Configuration for the OAuth client.
30
- *
31
- * @property clientId - The OAuth client ID.
32
- * @property clientSecret - The OAuth client secret.
33
- * @property redirectUri - The URI to redirect to after authentication.
34
- * @property issuerUrl - The OAuth issuer URL, or `null` to use the default.
35
- * @property apiBaseUrl - The Fanvue API base URL, or `null` to use the default.
36
- * @property scopes - Additional OAuth scopes to request beyond the defaults, or `null` for defaults only.
37
- * @property responseMode - The OAuth response mode (e.g., `fragment`), or `null` to omit.
38
- * @property prompt - The OAuth prompt parameter (e.g., `consent`), or `null` to omit.
39
- */
40
- interface OAuthConfig {
41
- clientId: string;
42
- clientSecret: string;
43
- redirectUri: string;
44
- issuerUrl: string | null;
45
- apiBaseUrl: string | null;
46
- scopes: string | null;
47
- responseMode: string | null;
48
- prompt: string | null;
69
+ //#region node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/standard-schema.d.cts
70
+ /** The Standard interface. */
71
+ interface StandardTypedV1<Input = unknown, Output = Input> {
72
+ /** The Standard properties. */
73
+ readonly "~standard": StandardTypedV1.Props<Input, Output>;
49
74
  }
50
- /**
51
- * The raw token response returned by the OAuth token endpoint.
52
- *
53
- * @property access_token - The access token issued by the authorization server.
54
- * @property refresh_token - The refresh token, or `null` if not provided.
55
- * @property expires_in - The lifetime in seconds of the access token.
56
- * @property token_type - The type of the token (e.g., `Bearer`).
57
- * @property scope - The scope of the access token, or `null` if not provided.
58
- * @property id_token - The ID token, or `null` if not provided.
59
- */
60
- interface TokenResponse {
61
- access_token: string;
62
- refresh_token: string | null;
63
- expires_in: number;
64
- token_type: string;
65
- scope: string | null;
66
- id_token: string | null;
75
+ declare namespace StandardTypedV1 {
76
+ /** The Standard properties interface. */
77
+ interface Props<Input = unknown, Output = Input> {
78
+ /** The version number of the standard. */
79
+ readonly version: 1;
80
+ /** The vendor name of the schema library. */
81
+ readonly vendor: string;
82
+ /** Inferred types associated with the schema. */
83
+ readonly types?: Types<Input, Output> | undefined;
84
+ }
85
+ /** The Standard types interface. */
86
+ interface Types<Input = unknown, Output = Input> {
87
+ /** The input type of the schema. */
88
+ readonly input: Input;
89
+ /** The output type of the schema. */
90
+ readonly output: Output;
91
+ }
92
+ /** Infers the input type of a Standard. */
93
+ type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
94
+ /** Infers the output type of a Standard. */
95
+ type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
67
96
  }
68
- /**
69
- * The payload stored inside the encrypted session JWT.
70
- *
71
- * @property accessToken - The OAuth access token.
72
- * @property refreshToken - The OAuth refresh token, or `null` if unavailable.
73
- * @property expiresAt - The timestamp (in milliseconds) when the access token expires.
74
- * @property tokenType - The type of the token (e.g., `Bearer`), or `null` if unavailable.
75
- * @property scope - The granted scope, or `null` if unavailable.
76
- * @property idToken - The ID token, or `null` if unavailable.
77
- * @property userUuid - The unique identifier of the authenticated user.
78
- * @property handle - The user's handle/username.
79
- * @property displayName - The user's display name.
80
- * @property isCreator - Whether the user is a creator.
81
- * @property avatarUrl - The URL of the user's avatar, or `null` if not set.
82
- */
83
- interface SessionPayload {
84
- accessToken: string;
85
- refreshToken: string | null;
86
- expiresAt: number;
87
- tokenType: string | null;
88
- scope: string | null;
89
- idToken: string | null;
90
- userUuid: string;
91
- handle: string;
92
- displayName: string;
93
- isCreator: boolean;
94
- avatarUrl: string | null;
97
+ /** The Standard Schema interface. */
98
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
99
+ /** The Standard Schema properties. */
100
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
95
101
  }
96
- /**
97
- * A Fanvue user profile as returned by the API.
98
- *
99
- * @property uuid - The unique identifier of the user.
100
- * @property email - The user's email address.
101
- * @property handle - The user's handle/username.
102
- * @property displayName - The user's display name.
103
- * @property isCreator - Whether the user is a creator.
104
- * @property avatarUrl - The URL of the user's avatar, or `null` if not set.
105
- * @property bannerUrl - The URL of the user's banner, or `null` if not set.
106
- * @property createdAt - The ISO 8601 timestamp of when the user was created.
107
- * @property updatedAt - The ISO 8601 timestamp of when the user was last updated, or `null`.
108
- */
109
- interface FanvueUser {
110
- uuid: string;
111
- email: string;
112
- handle: string;
113
- displayName: string;
114
- isCreator: boolean;
115
- avatarUrl: string | null;
116
- bannerUrl: string | null;
117
- createdAt: string;
118
- updatedAt: string | null;
102
+ declare namespace StandardSchemaV1 {
103
+ /** The Standard Schema properties interface. */
104
+ interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
105
+ /** Validates unknown input values. */
106
+ readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
107
+ }
108
+ /** The result interface of the validate function. */
109
+ type Result<Output> = SuccessResult<Output> | FailureResult;
110
+ /** The result interface if validation succeeds. */
111
+ interface SuccessResult<Output> {
112
+ /** The typed output value. */
113
+ readonly value: Output;
114
+ /** The absence of issues indicates success. */
115
+ readonly issues?: undefined;
116
+ }
117
+ interface Options {
118
+ /** Implicit support for additional vendor-specific parameters, if needed. */
119
+ readonly libraryOptions?: Record<string, unknown> | undefined;
120
+ }
121
+ /** The result interface if validation fails. */
122
+ interface FailureResult {
123
+ /** The issues of failed validation. */
124
+ readonly issues: ReadonlyArray<Issue>;
125
+ }
126
+ /** The issue interface of the failure output. */
127
+ interface Issue {
128
+ /** The error message of the issue. */
129
+ readonly message: string;
130
+ /** The path of the issue, if any. */
131
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
132
+ }
133
+ /** The path segment interface of the issue. */
134
+ interface PathSegment {
135
+ /** The key representing a path segment. */
136
+ readonly key: PropertyKey;
137
+ }
138
+ /** The Standard types interface. */
139
+ interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
140
+ /** Infers the input type of a Standard. */
141
+ type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
142
+ /** Infers the output type of a Standard. */
143
+ type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
119
144
  }
120
- /**
121
- * Configuration for the embedded-app (delegated authorize-on-behalf) flow.
122
- *
123
- * Extends {@link OAuthConfig} with the Fanvue platform base URL that hosts
124
- * the `authorize-on-behalf` endpoint.
125
- *
126
- * @property platformUrl - The Fanvue platform base URL, or `null` to use the default.
127
- */
128
- interface EmbeddedAuthConfig extends OAuthConfig {
129
- platformUrl: string | null;
130
- }
131
- /** Error type for JSON parsing failures. */
132
- type JsonParseError = {
133
- code: 'JSON_PARSE_ERROR';
134
- rawText: string;
135
- message: string;
136
- };
137
- /** Error type for OAuth operations (token exchange, refresh). */
138
- type OAuthError = {
139
- code: 'TOKEN_EXCHANGE_FAILED';
140
- statusCode: number;
141
- message: string;
142
- } | {
143
- code: 'TOKEN_REFRESH_FAILED';
144
- statusCode: number;
145
- message: string;
146
- } | {
147
- code: 'OAUTH_JSON_PARSE_ERROR';
148
- rawText: string;
149
- message: string;
150
- } | {
151
- code: 'OAUTH_VALIDATION_ERROR';
152
- message: string;
153
- };
154
- /** Error type for Fanvue API requests. */
155
- type ApiError = {
156
- code: 'API_REQUEST_FAILED';
157
- statusCode: number;
158
- message: string;
159
- } | {
160
- code: 'API_JSON_PARSE_ERROR';
161
- rawText: string;
162
- message: string;
163
- } | {
164
- code: 'API_VALIDATION_ERROR';
165
- message: string;
166
- };
167
- /** Error type for session JWT verification. */
168
- type SessionVerifyError = {
169
- code: 'JWT_VERIFY_FAILED';
170
- message: string;
171
- } | {
172
- code: 'SESSION_VALIDATION_ERROR';
173
- message: string;
174
- };
175
- /**
176
- * Error type for the embedded authorize-on-behalf step.
177
- *
178
- * - `SESSION_TOKEN_REJECTED` — the platform rejected the session token
179
- * (missing, malformed, or expired — they live ~60 seconds). The user must
180
- * reopen the embedded surface to receive a fresh one.
181
- * - `CONSENT_REQUIRED` — the creator has not approved (or has revoked) the
182
- * in-platform consent for this app. Consent is granted in the Fanvue UI;
183
- * the app cannot create it.
184
- * - `AUTHORIZE_ON_BEHALF_FAILED` — any other failure (network error,
185
- * unexpected status). `statusCode` is `0` for network errors.
186
- * - `AUTHORIZE_STATE_MISMATCH` — the returned `state` did not match the one
187
- * sent; the response must not be trusted.
188
- */
189
- type EmbeddedAuthError = {
190
- code: 'SESSION_TOKEN_REJECTED';
191
- statusCode: number;
192
- message: string;
193
- } | {
194
- code: 'CONSENT_REQUIRED';
195
- statusCode: number;
196
- message: string;
197
- } | {
198
- code: 'AUTHORIZE_ON_BEHALF_FAILED';
199
- statusCode: number;
200
- message: string;
201
- } | {
202
- code: 'AUTHORIZE_STATE_MISMATCH';
203
- message: string;
204
- } | {
205
- code: 'EMBEDDED_JSON_PARSE_ERROR';
206
- rawText: string;
207
- message: string;
208
- } | {
209
- code: 'EMBEDDED_VALIDATION_ERROR';
210
- message: string;
211
- };
212
- //#endregion
213
- //#region node_modules/.pnpm/neverthrow@8.2.0/node_modules/neverthrow/dist/index.d.ts
214
- interface ErrorConfig {
215
- withStackTrace: boolean;
145
+ /** The Standard JSON Schema interface. */
146
+ interface StandardJSONSchemaV1<Input = unknown, Output = Input> {
147
+ /** The Standard JSON Schema properties. */
148
+ readonly "~standard": StandardJSONSchemaV1.Props<Input, Output>;
216
149
  }
217
- declare class ResultAsync<T, E> implements PromiseLike<Result$1<T, E>> {
218
- private _promise;
219
- constructor(res: Promise<Result$1<T, E>>);
220
- static fromSafePromise<T, E = never>(promise: PromiseLike<T>): ResultAsync<T, E>;
221
- static fromPromise<T, E>(promise: PromiseLike<T>, errorFn: (e: unknown) => E): ResultAsync<T, E>;
222
- static fromThrowable<A extends readonly any[], R, E>(fn: (...args: A) => Promise<R>, errorFn?: (err: unknown) => E): (...args: A) => ResultAsync<R, E>;
223
- static combine<T extends readonly [ResultAsync<unknown, unknown>, ...ResultAsync<unknown, unknown>[]]>(asyncResultList: T): CombineResultAsyncs<T>;
224
- static combine<T extends readonly ResultAsync<unknown, unknown>[]>(asyncResultList: T): CombineResultAsyncs<T>;
225
- static combineWithAllErrors<T extends readonly [ResultAsync<unknown, unknown>, ...ResultAsync<unknown, unknown>[]]>(asyncResultList: T): CombineResultsWithAllErrorsArrayAsync<T>;
226
- static combineWithAllErrors<T extends readonly ResultAsync<unknown, unknown>[]>(asyncResultList: T): CombineResultsWithAllErrorsArrayAsync<T>;
227
- map<A>(f: (t: T) => A | Promise<A>): ResultAsync<A, E>;
228
- andThrough<F>(f: (t: T) => Result$1<unknown, F> | ResultAsync<unknown, F>): ResultAsync<T, E | F>;
229
- andTee(f: (t: T) => unknown): ResultAsync<T, E>;
230
- orTee(f: (t: E) => unknown): ResultAsync<T, E>;
231
- mapErr<U>(f: (e: E) => U | Promise<U>): ResultAsync<T, U>;
232
- andThen<R extends Result$1<unknown, unknown>>(f: (t: T) => R): ResultAsync<InferOkTypes<R>, InferErrTypes<R> | E>;
233
- andThen<R extends ResultAsync<unknown, unknown>>(f: (t: T) => R): ResultAsync<InferAsyncOkTypes<R>, InferAsyncErrTypes<R> | E>;
234
- andThen<U, F>(f: (t: T) => Result$1<U, F> | ResultAsync<U, F>): ResultAsync<U, E | F>;
235
- orElse<R extends Result$1<unknown, unknown>>(f: (e: E) => R): ResultAsync<InferOkTypes<R> | T, InferErrTypes<R>>;
236
- orElse<R extends ResultAsync<unknown, unknown>>(f: (e: E) => R): ResultAsync<InferAsyncOkTypes<R> | T, InferAsyncErrTypes<R>>;
237
- orElse<U, A>(f: (e: E) => Result$1<U, A> | ResultAsync<U, A>): ResultAsync<U | T, A>;
238
- match<A, B = A>(ok: (t: T) => A, _err: (e: E) => B): Promise<A | B>;
239
- unwrapOr<A>(t: A): Promise<T | A>;
240
- /**
241
- * @deprecated will be removed in 9.0.0.
242
- *
243
- * You can use `safeTry` without this method.
244
- * @example
245
- * ```typescript
246
- * safeTry(async function* () {
247
- * const okValue = yield* yourResult
248
- * })
249
- * ```
250
- * Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
150
+ declare namespace StandardJSONSchemaV1 {
151
+ /** The Standard JSON Schema properties interface. */
152
+ interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
153
+ /** Methods for generating the input/output JSON Schema. */
154
+ readonly jsonSchema: Converter;
155
+ }
156
+ /** The Standard JSON Schema converter interface. */
157
+ interface Converter {
158
+ /** Converts the input type to JSON Schema. May throw if conversion is not supported. */
159
+ readonly input: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
160
+ /** Converts the output type to JSON Schema. May throw if conversion is not supported. */
161
+ readonly output: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
162
+ }
163
+ /** The target version of the generated JSON Schema.
164
+ *
165
+ * It is *strongly recommended* that implementers support `"draft-2020-12"` and `"draft-07"`, as they are both in wide use.
166
+ *
167
+ * The `"openapi-3.0"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `"draft-04"`.
168
+ *
169
+ * All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target.
251
170
  */
252
- safeUnwrap(): AsyncGenerator<Err<never, E>, T>;
253
- then<A, B>(successCallback?: (res: Result$1<T, E>) => A | PromiseLike<A>, failureCallback?: (reason: unknown) => B | PromiseLike<B>): PromiseLike<A | B>;
254
- [Symbol.asyncIterator](): AsyncGenerator<Err<never, E>, T>;
255
- }
256
- declare type CombineResultAsyncs<T extends readonly ResultAsync<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseAsync<UnwrapAsync<T>> : ResultAsync<ExtractOkAsyncTypes<T>, ExtractErrAsyncTypes<T>[number]>;
257
- declare type CombineResultsWithAllErrorsArrayAsync<T extends readonly ResultAsync<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseWithAllErrorsAsync<UnwrapAsync<T>> : ResultAsync<ExtractOkAsyncTypes<T>, ExtractErrAsyncTypes<T>[number][]>;
258
- declare type UnwrapAsync<T> = IsLiteralArray<T> extends 1 ? Writable<T> extends [infer H, ...infer Rest] ? H extends PromiseLike<infer HI> ? HI extends Result$1<unknown, unknown> ? [Dedup<HI>, ...UnwrapAsync<Rest>] : never : never : [] : T extends Array<infer A> ? A extends PromiseLike<infer HI> ? HI extends Result$1<infer L, infer R> ? Ok<L, R>[] : never : never : never;
259
- declare type TraverseAsync<T, Depth extends number = 5> = IsLiteralArray<T> extends 1 ? Combine<T, Depth> extends [infer Oks, infer Errs] ? ResultAsync<EmptyArrayToNever<Oks>, MembersToUnion<Errs>> : never : T extends Array<infer I> ? Combine<MemberListOf<I>, Depth> extends [infer Oks, infer Errs] ? Oks extends unknown[] ? Errs extends unknown[] ? ResultAsync<EmptyArrayToNever<Oks[number][]>, MembersToUnion<Errs[number][]>> : ResultAsync<EmptyArrayToNever<Oks[number][]>, Errs> : Errs extends unknown[] ? ResultAsync<Oks, MembersToUnion<Errs[number][]>> : ResultAsync<Oks, Errs> : never : never;
260
- declare type TraverseWithAllErrorsAsync<T, Depth extends number = 5> = TraverseAsync<T, Depth> extends ResultAsync<infer Oks, infer Errs> ? ResultAsync<Oks, Errs[]> : never;
261
- declare type Writable<T> = T extends ReadonlyArray<unknown> ? [...T] : T;
262
- declare type ExtractOkTypes<T extends readonly Result$1<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends Result$1<infer U, unknown> ? U : never };
263
- declare type ExtractOkAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends ResultAsync<infer U, unknown> ? U : never };
264
- declare type ExtractErrTypes<T extends readonly Result$1<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends Result$1<unknown, infer E> ? E : never };
265
- declare type ExtractErrAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends ResultAsync<unknown, infer E> ? E : never };
266
- declare type InferOkTypes<R> = R extends Result$1<infer T, unknown> ? T : never;
267
- declare type InferErrTypes<R> = R extends Result$1<unknown, infer E> ? E : never;
268
- declare type InferAsyncOkTypes<R> = R extends ResultAsync<infer T, unknown> ? T : never;
269
- declare type InferAsyncErrTypes<R> = R extends ResultAsync<unknown, infer E> ? E : never;
270
- declare namespace Result$1 {
271
- /**
272
- * Wraps a function with a try catch, creating a new function with the same
273
- * arguments but returning `Ok` if successful, `Err` if the function throws
274
- *
275
- * @param fn function to wrap with ok on success or err on failure
276
- * @param errorFn when an error is thrown, this will wrap the error result if provided
277
- */
278
- function fromThrowable<Fn extends (...args: readonly any[]) => any, E>(fn: Fn, errorFn?: (e: unknown) => E): (...args: Parameters<Fn>) => Result$1<ReturnType<Fn>, E>;
279
- function combine<T extends readonly [Result$1<unknown, unknown>, ...Result$1<unknown, unknown>[]]>(resultList: T): CombineResults<T>;
280
- function combine<T extends readonly Result$1<unknown, unknown>[]>(resultList: T): CombineResults<T>;
281
- function combineWithAllErrors<T extends readonly [Result$1<unknown, unknown>, ...Result$1<unknown, unknown>[]]>(resultList: T): CombineResultsWithAllErrorsArray<T>;
282
- function combineWithAllErrors<T extends readonly Result$1<unknown, unknown>[]>(resultList: T): CombineResultsWithAllErrorsArray<T>;
283
- }
284
- declare type Result$1<T, E> = Ok<T, E> | Err<T, E>;
285
- interface IResult<T, E> {
286
- /**
287
- * Used to check if a `Result` is an `OK`
288
- *
289
- * @returns `true` if the result is an `OK` variant of Result
290
- */
291
- isOk(): this is Ok<T, E>;
292
- /**
293
- * Used to check if a `Result` is an `Err`
294
- *
295
- * @returns `true` if the result is an `Err` variant of Result
296
- */
297
- isErr(): this is Err<T, E>;
298
- /**
299
- * Maps a `Result<T, E>` to `Result<U, E>`
300
- * by applying a function to a contained `Ok` value, leaving an `Err` value
301
- * untouched.
302
- *
303
- * @param f The function to apply an `OK` value
304
- * @returns the result of applying `f` or an `Err` untouched
305
- */
306
- map<A>(f: (t: T) => A): Result$1<A, E>;
307
- /**
308
- * Maps a `Result<T, E>` to `Result<T, F>` by applying a function to a
309
- * contained `Err` value, leaving an `Ok` value untouched.
310
- *
311
- * This function can be used to pass through a successful result while
312
- * handling an error.
313
- *
314
- * @param f a function to apply to the error `Err` value
315
- */
316
- mapErr<U>(f: (e: E) => U): Result$1<T, U>;
317
- /**
318
- * Similar to `map` Except you must return a new `Result`.
319
- *
320
- * This is useful for when you need to do a subsequent computation using the
321
- * inner `T` value, but that computation might fail.
322
- * Additionally, `andThen` is really useful as a tool to flatten a
323
- * `Result<Result<A, E2>, E1>` into a `Result<A, E2>` (see example below).
324
- *
325
- * @param f The function to apply to the current value
326
- */
327
- andThen<R extends Result$1<unknown, unknown>>(f: (t: T) => R): Result$1<InferOkTypes<R>, InferErrTypes<R> | E>;
328
- andThen<U, F>(f: (t: T) => Result$1<U, F>): Result$1<U, E | F>;
329
- /**
330
- * This "tee"s the current value to an passed-in computation such as side
331
- * effect functions but still returns the same current value as the result.
332
- *
333
- * This is useful when you want to pass the current result to your side-track
334
- * work such as logging but want to continue main-track work after that.
335
- * This method does not care about the result of the passed in computation.
336
- *
337
- * @param f The function to apply to the current value
338
- */
339
- andTee(f: (t: T) => unknown): Result$1<T, E>;
340
- /**
341
- * This "tee"s the current `Err` value to an passed-in computation such as side
342
- * effect functions but still returns the same `Err` value as the result.
343
- *
344
- * This is useful when you want to pass the current `Err` value to your side-track
345
- * work such as logging but want to continue error-track work after that.
346
- * This method does not care about the result of the passed in computation.
347
- *
348
- * @param f The function to apply to the current `Err` value
349
- */
350
- orTee(f: (t: E) => unknown): Result$1<T, E>;
351
- /**
352
- * Similar to `andTee` except error result of the computation will be passed
353
- * to the downstream in case of an error.
354
- *
355
- * This version is useful when you want to make side-effects but in case of an
356
- * error, you want to pass the error to the downstream.
357
- *
358
- * @param f The function to apply to the current value
359
- */
360
- andThrough<R extends Result$1<unknown, unknown>>(f: (t: T) => R): Result$1<T, InferErrTypes<R> | E>;
361
- andThrough<F>(f: (t: T) => Result$1<unknown, F>): Result$1<T, E | F>;
362
- /**
363
- * Takes an `Err` value and maps it to a `Result<T, SomeNewType>`.
364
- *
365
- * This is useful for error recovery.
366
- *
367
- *
368
- * @param f A function to apply to an `Err` value, leaving `Ok` values
369
- * untouched.
370
- */
371
- orElse<R extends Result$1<unknown, unknown>>(f: (e: E) => R): Result$1<InferOkTypes<R> | T, InferErrTypes<R>>;
372
- orElse<U, A>(f: (e: E) => Result$1<U, A>): Result$1<U | T, A>;
373
- /**
374
- * Similar to `map` Except you must return a new `Result`.
375
- *
376
- * This is useful for when you need to do a subsequent async computation using
377
- * the inner `T` value, but that computation might fail. Must return a ResultAsync
378
- *
379
- * @param f The function that returns a `ResultAsync` to apply to the current
380
- * value
381
- */
382
- asyncAndThen<U, F>(f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
383
- /**
384
- * Maps a `Result<T, E>` to `ResultAsync<U, E>`
385
- * by applying an async function to a contained `Ok` value, leaving an `Err`
386
- * value untouched.
387
- *
388
- * @param f An async function to apply an `OK` value
389
- */
390
- asyncMap<U>(f: (t: T) => Promise<U>): ResultAsync<U, E>;
391
- /**
392
- * Unwrap the `Ok` value, or return the default if there is an `Err`
393
- *
394
- * @param v the default value to return if there is an `Err`
395
- */
396
- unwrapOr<A>(v: A): T | A;
397
- /**
398
- *
399
- * Given 2 functions (one for the `Ok` variant and one for the `Err` variant)
400
- * execute the function that matches the `Result` variant.
401
- *
402
- * Match callbacks do not necessitate to return a `Result`, however you can
403
- * return a `Result` if you want to.
404
- *
405
- * `match` is like chaining `map` and `mapErr`, with the distinction that
406
- * with `match` both functions must have the same return type.
407
- *
408
- * @param ok
409
- * @param err
410
- */
411
- match<A, B = A>(ok: (t: T) => A, err: (e: E) => B): A | B;
412
- /**
413
- * @deprecated will be removed in 9.0.0.
414
- *
415
- * You can use `safeTry` without this method.
416
- * @example
417
- * ```typescript
418
- * safeTry(function* () {
419
- * const okValue = yield* yourResult
420
- * })
421
- * ```
422
- * Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
423
- */
424
- safeUnwrap(): Generator<Err<never, E>, T>;
425
- /**
426
- * **This method is unsafe, and should only be used in a test environments**
427
- *
428
- * Takes a `Result<T, E>` and returns a `T` when the result is an `Ok`, otherwise it throws a custom object.
429
- *
430
- * @param config
431
- */
432
- _unsafeUnwrap(config?: ErrorConfig): T;
433
- /**
434
- * **This method is unsafe, and should only be used in a test environments**
435
- *
436
- * takes a `Result<T, E>` and returns a `E` when the result is an `Err`,
437
- * otherwise it throws a custom object.
438
- *
439
- * @param config
440
- */
441
- _unsafeUnwrapErr(config?: ErrorConfig): E;
442
- }
443
- declare class Ok<T, E> implements IResult<T, E> {
444
- readonly value: T;
445
- constructor(value: T);
446
- isOk(): this is Ok<T, E>;
447
- isErr(): this is Err<T, E>;
448
- map<A>(f: (t: T) => A): Result$1<A, E>;
449
- mapErr<U>(_f: (e: E) => U): Result$1<T, U>;
450
- andThen<R extends Result$1<unknown, unknown>>(f: (t: T) => R): Result$1<InferOkTypes<R>, InferErrTypes<R> | E>;
451
- andThen<U, F>(f: (t: T) => Result$1<U, F>): Result$1<U, E | F>;
452
- andThrough<R extends Result$1<unknown, unknown>>(f: (t: T) => R): Result$1<T, InferErrTypes<R> | E>;
453
- andThrough<F>(f: (t: T) => Result$1<unknown, F>): Result$1<T, E | F>;
454
- andTee(f: (t: T) => unknown): Result$1<T, E>;
455
- orTee(_f: (t: E) => unknown): Result$1<T, E>;
456
- orElse<R extends Result$1<unknown, unknown>>(_f: (e: E) => R): Result$1<InferOkTypes<R> | T, InferErrTypes<R>>;
457
- orElse<U, A>(_f: (e: E) => Result$1<U, A>): Result$1<U | T, A>;
458
- asyncAndThen<U, F>(f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
459
- asyncAndThrough<R extends ResultAsync<unknown, unknown>>(f: (t: T) => R): ResultAsync<T, InferAsyncErrTypes<R> | E>;
460
- asyncAndThrough<F>(f: (t: T) => ResultAsync<unknown, F>): ResultAsync<T, E | F>;
461
- asyncMap<U>(f: (t: T) => Promise<U>): ResultAsync<U, E>;
462
- unwrapOr<A>(_v: A): T | A;
463
- match<A, B = A>(ok: (t: T) => A, _err: (e: E) => B): A | B;
464
- safeUnwrap(): Generator<Err<never, E>, T>;
465
- _unsafeUnwrap(_?: ErrorConfig): T;
466
- _unsafeUnwrapErr(config?: ErrorConfig): E;
467
- [Symbol.iterator](): Generator<Err<never, E>, T>;
468
- }
469
- declare class Err<T, E> implements IResult<T, E> {
470
- readonly error: E;
471
- constructor(error: E);
472
- isOk(): this is Ok<T, E>;
473
- isErr(): this is Err<T, E>;
474
- map<A>(_f: (t: T) => A): Result$1<A, E>;
475
- mapErr<U>(f: (e: E) => U): Result$1<T, U>;
476
- andThrough<F>(_f: (t: T) => Result$1<unknown, F>): Result$1<T, E | F>;
477
- andTee(_f: (t: T) => unknown): Result$1<T, E>;
478
- orTee(f: (t: E) => unknown): Result$1<T, E>;
479
- andThen<R extends Result$1<unknown, unknown>>(_f: (t: T) => R): Result$1<InferOkTypes<R>, InferErrTypes<R> | E>;
480
- andThen<U, F>(_f: (t: T) => Result$1<U, F>): Result$1<U, E | F>;
481
- orElse<R extends Result$1<unknown, unknown>>(f: (e: E) => R): Result$1<InferOkTypes<R> | T, InferErrTypes<R>>;
482
- orElse<U, A>(f: (e: E) => Result$1<U, A>): Result$1<U | T, A>;
483
- asyncAndThen<U, F>(_f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
484
- asyncAndThrough<F>(_f: (t: T) => ResultAsync<unknown, F>): ResultAsync<T, E | F>;
485
- asyncMap<U>(_f: (t: T) => Promise<U>): ResultAsync<U, E>;
486
- unwrapOr<A>(v: A): T | A;
487
- match<A, B = A>(_ok: (t: T) => A, err: (e: E) => B): A | B;
488
- safeUnwrap(): Generator<Err<never, E>, T>;
489
- _unsafeUnwrap(config?: ErrorConfig): T;
490
- _unsafeUnwrapErr(_?: ErrorConfig): E;
491
- [Symbol.iterator](): Generator<Err<never, E>, T>;
492
- }
493
- declare type Prev = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, ...0[]];
494
- declare type CollectResults<T, Collected extends unknown[] = [], Depth extends number = 50> = [Depth] extends [never] ? [] : T extends [infer H, ...infer Rest] ? H extends Result$1<infer L, infer R> ? CollectResults<Rest, [...Collected, [L, R]], Prev[Depth]> : never : Collected;
495
- declare type Transpose<A, Transposed extends unknown[][] = [], Depth extends number = 10> = A extends [infer T, ...infer Rest] ? T extends [infer L, infer R] ? Transposed extends [infer PL, infer PR] ? PL extends unknown[] ? PR extends unknown[] ? Transpose<Rest, [[...PL, L], [...PR, R]], Prev[Depth]> : never : never : Transpose<Rest, [[L], [R]], Prev[Depth]> : Transposed : Transposed;
496
- declare type Combine<T, Depth extends number = 5> = Transpose<CollectResults<T>, [], Depth> extends [infer L, infer R] ? [UnknownMembersToNever<L>, UnknownMembersToNever<R>] : Transpose<CollectResults<T>, [], Depth> extends [] ? [[], []] : never;
497
- declare type Dedup<T> = T extends Result$1<infer RL, infer RR> ? [unknown] extends [RL] ? Err<RL, RR> : Ok<RL, RR> : T;
498
- declare type MemberListOf<T> = ((T extends unknown ? (t: T) => T : never) extends infer U ? (U extends unknown ? (u: U) => unknown : never) extends ((v: infer V) => unknown) ? V : never : never) extends ((_: unknown) => infer W) ? [...MemberListOf<Exclude<T, W>>, W] : [];
499
- declare type EmptyArrayToNever<T, NeverArrayToNever extends number = 0> = T extends [] ? never : NeverArrayToNever extends 1 ? T extends [never, ...infer Rest] ? [EmptyArrayToNever<Rest>] extends [never] ? never : T : T : T;
500
- declare type UnknownMembersToNever<T> = T extends [infer H, ...infer R] ? [[unknown] extends [H] ? never : H, ...UnknownMembersToNever<R>] : T;
501
- declare type MembersToUnion<T> = T extends unknown[] ? T[number] : never;
502
- declare type IsLiteralArray<T> = T extends {
503
- length: infer L;
504
- } ? L extends number ? number extends L ? 0 : 1 : 0 : 0;
505
- declare type Traverse<T, Depth extends number = 5> = Combine<T, Depth> extends [infer Oks, infer Errs] ? Result$1<EmptyArrayToNever<Oks, 1>, MembersToUnion<Errs>> : never;
506
- declare type TraverseWithAllErrors<T, Depth extends number = 5> = Traverse<T, Depth> extends Result$1<infer Oks, infer Errs> ? Result$1<Oks, Errs[]> : never;
507
- declare type CombineResults<T extends readonly Result$1<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? Traverse<T> : Result$1<ExtractOkTypes<T>, ExtractErrTypes<T>[number]>;
508
- declare type CombineResultsWithAllErrorsArray<T extends readonly Result$1<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseWithAllErrors<T> : Result$1<ExtractOkTypes<T>, ExtractErrTypes<T>[number][]>;
509
- //#endregion
510
- //#region src/core/oauth.d.ts
511
- /**
512
- * Builds an OAuth 2.0 authorization URL with PKCE parameters.
513
- *
514
- * @param config - The OAuth configuration.
515
- * @param opts - Optional overrides. Pass `state` to use a deterministic state value.
516
- * @returns The authorization URL, the PKCE code verifier, and the state parameter.
517
- */
518
- declare function createAuthorizationUrl(config: OAuthConfig, opts?: {
519
- state: string | null;
520
- } | null): Promise<{
521
- url: URL;
522
- codeVerifier: string;
523
- state: string;
524
- }>;
525
- /**
526
- * Exchanges an authorization code for tokens using the OAuth token endpoint.
527
- *
528
- * @param config - The OAuth configuration.
529
- * @param opts - The authorization code, PKCE code verifier, and optional redirect URI override.
530
- * @returns A `Result` containing `TokenResponse` on success or `OAuthError` on failure.
531
- */
532
- declare function exchangeCodeForToken(config: OAuthConfig, opts: {
533
- code: string;
534
- codeVerifier: string;
535
- redirectUri: string | null;
536
- }): Promise<Result$1<TokenResponse, OAuthError>>;
537
- /**
538
- * Refreshes an access token using a refresh token.
539
- *
540
- * @param config - The OAuth configuration.
541
- * @param refreshToken - The refresh token to use.
542
- * @returns A `Result` containing `TokenResponse` on success or `OAuthError` on failure.
543
- */
544
- declare function refreshAccessToken(config: OAuthConfig, refreshToken: string): Promise<Result$1<TokenResponse, OAuthError>>;
545
- //#endregion
546
- //#region src/core/session.d.ts
547
- /**
548
- * Creates a signed JWT containing the given session payload.
549
- *
550
- * @param secret - The secret key used to sign the JWT.
551
- * @param payload - The session data to embed in the token.
552
- * @param expiresIn - How long until the token expires (e.g., `"30d"`), or `null` for the default (`"30d"`).
553
- * @returns The signed JWT string.
554
- */
555
- declare function createSessionJwt(secret: string, payload: SessionPayload, expiresIn?: string | null): Promise<string>;
556
- /**
557
- * Verifies a session JWT and returns the validated session payload.
558
- *
559
- * @param secret - The secret key used to verify the JWT signature.
560
- * @param token - The JWT string to verify.
561
- * @returns A {@link Result} containing the validated {@link SessionPayload}, or a {@link SessionVerifyError}.
562
- */
563
- declare function verifySessionJwt(secret: string, token: string): Promise<Result$1<SessionPayload, SessionVerifyError>>;
564
- //#endregion
565
- //#region src/core/embedded.d.ts
566
- /**
567
- * The creator's active colour scheme, as resolved by Fanvue.
568
- *
569
- * Fanvue resolves a creator's "system" preference to the scheme actually being
570
- * rendered, so this is always a definite value — never `'system'`.
571
- */
572
- type FanvueTheme = 'light' | 'dark';
573
- /**
574
- * Extracts the embedded session token from a URL.
575
- *
576
- * When Fanvue opens an embedded app, it loads the app's embed URL with a
577
- * short-lived session token appended as a `?token=` query parameter.
578
- *
579
- * @param url - The URL to read the token from (e.g. `window.location.href`).
580
- * @returns The session token, or `null` when absent or the URL is malformed.
581
- */
582
- declare function getSessionTokenFromUrl(url: string | URL): string | null;
583
- /**
584
- * Extracts the creator's active colour scheme from a URL.
585
- *
586
- * When Fanvue opens an embedded app, it appends the creator's resolved colour
587
- * scheme as a `?theme=` query parameter (`light` or `dark`), letting the app
588
- * theme-match Fanvue.
589
- *
590
- * @param url - The URL to read the theme from (e.g. `window.location.href`).
591
- * @returns The {@link FanvueTheme}, or `null` when absent, unrecognised, or the
592
- * URL is malformed (e.g. the app was opened outside Fanvue).
593
- */
594
- declare function getThemeFromUrl(url: string | URL): FanvueTheme | null;
595
- /**
596
- * Requests an authorization code from the Fanvue platform on behalf of the
597
- * creator currently using the embedded app.
598
- *
599
- * This is the "authorize" half of the delegated flow: the platform verifies
600
- * the session token, runs the OAuth authorize as the creator, and returns the
601
- * resulting authorization code. The PKCE verifier and client secret never
602
- * leave the caller — only the challenge is sent.
603
- *
604
- * Most apps should use {@link exchangeSessionToken}, which composes this with
605
- * the code exchange.
606
- *
607
- * @param config - The embedded auth configuration.
608
- * @param sessionToken - The short-lived session token received in the iframe.
609
- * @param opts - The PKCE code challenge and state to bind the code to.
610
- * @returns A `Result` containing the authorization code on success or
611
- * {@link EmbeddedAuthError} on failure.
612
- */
613
- declare function requestAuthorizationCodeOnBehalf(config: EmbeddedAuthConfig, sessionToken: string, opts: {
614
- codeChallenge: string;
615
- state: string;
616
- }): Promise<Result$1<{
617
- code: string;
618
- }, EmbeddedAuthError>>;
619
- /**
620
- * Exchanges an embedded session token for OAuth access and refresh tokens.
621
- *
622
- * Runs the complete delegated authorize-on-behalf flow:
623
- *
624
- * 1. Generates a PKCE verifier/challenge pair and a random `state`.
625
- * 2. Asks the Fanvue platform to authorize as the creator
626
- * ({@link requestAuthorizationCodeOnBehalf}).
627
- * 3. Exchanges the returned code at the token endpoint using the client
628
- * secret and PKCE verifier.
629
- *
630
- * Must run server-side: it uses the client secret. The session token should
631
- * be used promptly — it expires after ~60 seconds.
632
- *
633
- * @param config - The embedded auth configuration. `redirectUri` must be a
634
- * redirect URI registered on the OAuth client (it is never visited; it only
635
- * binds the authorization code).
636
- * @param sessionToken - The short-lived session token received in the iframe.
637
- * @returns A `Result` containing {@link TokenResponse} on success or an
638
- * {@link EmbeddedAuthError} / {@link OAuthError} on failure.
639
- */
640
- declare function exchangeSessionToken(config: EmbeddedAuthConfig, sessionToken: string): Promise<Result$1<TokenResponse, EmbeddedAuthError | OAuthError>>;
641
- //#endregion
642
- //#region src/core/json.d.ts
643
- /**
644
- * Safely parses a JSON string, returning a `Result` instead of throwing.
645
- *
646
- * @param text - The raw text to parse as JSON.
647
- * @returns `ok(parsed)` on success, or `err({ code, rawText, message })` on failure.
648
- */
649
- declare function safeJsonParse(text: string): Result$1<unknown, JsonParseError>;
650
- //#endregion
651
- //#region node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema.d.cts
652
- type _JSONSchema = boolean | JSONSchema;
653
- type JSONSchema = {
654
- [k: string]: unknown;
655
- $schema?: "https://json-schema.org/draft/2020-12/schema" | "http://json-schema.org/draft-07/schema#" | "http://json-schema.org/draft-04/schema#";
656
- $id?: string;
657
- $anchor?: string;
658
- $ref?: string;
659
- $dynamicRef?: string;
660
- $dynamicAnchor?: string;
661
- $vocabulary?: Record<string, boolean>;
662
- $comment?: string;
663
- $defs?: Record<string, JSONSchema>;
664
- type?: "object" | "array" | "string" | "number" | "boolean" | "null" | "integer";
665
- additionalItems?: _JSONSchema;
666
- unevaluatedItems?: _JSONSchema;
667
- prefixItems?: _JSONSchema[];
668
- items?: _JSONSchema | _JSONSchema[];
669
- contains?: _JSONSchema;
670
- additionalProperties?: _JSONSchema;
671
- unevaluatedProperties?: _JSONSchema;
672
- properties?: Record<string, _JSONSchema>;
673
- patternProperties?: Record<string, _JSONSchema>;
674
- dependentSchemas?: Record<string, _JSONSchema>;
675
- propertyNames?: _JSONSchema;
676
- if?: _JSONSchema;
677
- then?: _JSONSchema;
678
- else?: _JSONSchema;
679
- allOf?: JSONSchema[];
680
- anyOf?: JSONSchema[];
681
- oneOf?: JSONSchema[];
682
- not?: _JSONSchema;
683
- multipleOf?: number;
684
- maximum?: number;
685
- exclusiveMaximum?: number | boolean;
686
- minimum?: number;
687
- exclusiveMinimum?: number | boolean;
688
- maxLength?: number;
689
- minLength?: number;
690
- pattern?: string;
691
- maxItems?: number;
692
- minItems?: number;
693
- uniqueItems?: boolean;
694
- maxContains?: number;
695
- minContains?: number;
696
- maxProperties?: number;
697
- minProperties?: number;
698
- required?: string[];
699
- dependentRequired?: Record<string, string[]>;
700
- enum?: Array<string | number | boolean | null>;
701
- const?: string | number | boolean | null;
702
- id?: string;
703
- title?: string;
704
- description?: string;
705
- default?: unknown;
706
- deprecated?: boolean;
707
- readOnly?: boolean;
708
- writeOnly?: boolean;
709
- nullable?: boolean;
710
- examples?: unknown[];
711
- format?: string;
712
- contentMediaType?: string;
713
- contentEncoding?: string;
714
- contentSchema?: JSONSchema;
715
- _prefault?: unknown;
716
- };
717
- type BaseSchema = JSONSchema;
718
- //#endregion
719
- //#region node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/standard-schema.d.cts
720
- /** The Standard interface. */
721
- interface StandardTypedV1<Input = unknown, Output = Input> {
722
- /** The Standard properties. */
723
- readonly "~standard": StandardTypedV1.Props<Input, Output>;
724
- }
725
- declare namespace StandardTypedV1 {
726
- /** The Standard properties interface. */
727
- interface Props<Input = unknown, Output = Input> {
728
- /** The version number of the standard. */
729
- readonly version: 1;
730
- /** The vendor name of the schema library. */
731
- readonly vendor: string;
732
- /** Inferred types associated with the schema. */
733
- readonly types?: Types<Input, Output> | undefined;
734
- }
735
- /** The Standard types interface. */
736
- interface Types<Input = unknown, Output = Input> {
737
- /** The input type of the schema. */
738
- readonly input: Input;
739
- /** The output type of the schema. */
740
- readonly output: Output;
741
- }
742
- /** Infers the input type of a Standard. */
743
- type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
744
- /** Infers the output type of a Standard. */
745
- type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
746
- }
747
- /** The Standard Schema interface. */
748
- interface StandardSchemaV1<Input = unknown, Output = Input> {
749
- /** The Standard Schema properties. */
750
- readonly "~standard": StandardSchemaV1.Props<Input, Output>;
751
- }
752
- declare namespace StandardSchemaV1 {
753
- /** The Standard Schema properties interface. */
754
- interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
755
- /** Validates unknown input values. */
756
- readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
757
- }
758
- /** The result interface of the validate function. */
759
- type Result<Output> = SuccessResult<Output> | FailureResult;
760
- /** The result interface if validation succeeds. */
761
- interface SuccessResult<Output> {
762
- /** The typed output value. */
763
- readonly value: Output;
764
- /** The absence of issues indicates success. */
765
- readonly issues?: undefined;
766
- }
767
- interface Options {
768
- /** Implicit support for additional vendor-specific parameters, if needed. */
769
- readonly libraryOptions?: Record<string, unknown> | undefined;
770
- }
771
- /** The result interface if validation fails. */
772
- interface FailureResult {
773
- /** The issues of failed validation. */
774
- readonly issues: ReadonlyArray<Issue>;
775
- }
776
- /** The issue interface of the failure output. */
777
- interface Issue {
778
- /** The error message of the issue. */
779
- readonly message: string;
780
- /** The path of the issue, if any. */
781
- readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
782
- }
783
- /** The path segment interface of the issue. */
784
- interface PathSegment {
785
- /** The key representing a path segment. */
786
- readonly key: PropertyKey;
787
- }
788
- /** The Standard types interface. */
789
- interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
790
- /** Infers the input type of a Standard. */
791
- type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
792
- /** Infers the output type of a Standard. */
793
- type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
794
- }
795
- /** The Standard JSON Schema interface. */
796
- interface StandardJSONSchemaV1<Input = unknown, Output = Input> {
797
- /** The Standard JSON Schema properties. */
798
- readonly "~standard": StandardJSONSchemaV1.Props<Input, Output>;
799
- }
800
- declare namespace StandardJSONSchemaV1 {
801
- /** The Standard JSON Schema properties interface. */
802
- interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
803
- /** Methods for generating the input/output JSON Schema. */
804
- readonly jsonSchema: Converter;
805
- }
806
- /** The Standard JSON Schema converter interface. */
807
- interface Converter {
808
- /** Converts the input type to JSON Schema. May throw if conversion is not supported. */
809
- readonly input: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
810
- /** Converts the output type to JSON Schema. May throw if conversion is not supported. */
811
- readonly output: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
812
- }
813
- /** The target version of the generated JSON Schema.
814
- *
815
- * It is *strongly recommended* that implementers support `"draft-2020-12"` and `"draft-07"`, as they are both in wide use.
816
- *
817
- * The `"openapi-3.0"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `"draft-04"`.
818
- *
819
- * All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target.
820
- */
821
- type Target = "draft-2020-12" | "draft-07" | "openapi-3.0" | ({} & string);
822
- /** The options for the input/output methods. */
823
- interface Options {
824
- /** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */
825
- readonly target: Target;
826
- /** Implicit support for additional vendor-specific parameters, if needed. */
827
- readonly libraryOptions?: Record<string, unknown> | undefined;
828
- }
829
- /** The Standard types interface. */
830
- interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
831
- /** Infers the input type of a Standard. */
832
- type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
833
- /** Infers the output type of a Standard. */
834
- type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
171
+ type Target = "draft-2020-12" | "draft-07" | "openapi-3.0" | ({} & string);
172
+ /** The options for the input/output methods. */
173
+ interface Options {
174
+ /** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */
175
+ readonly target: Target;
176
+ /** Implicit support for additional vendor-specific parameters, if needed. */
177
+ readonly libraryOptions?: Record<string, unknown> | undefined;
178
+ }
179
+ /** The Standard types interface. */
180
+ interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
181
+ /** Infers the input type of a Standard. */
182
+ type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
183
+ /** Infers the output type of a Standard. */
184
+ type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
835
185
  }
836
186
  interface StandardSchemaWithJSONProps<Input = unknown, Output = Input> extends StandardSchemaV1.Props<Input, Output>, StandardJSONSchemaV1.Props<Input, Output> {}
837
187
  //#endregion
@@ -2598,6 +1948,8 @@ declare const ZodNumber: $constructor<ZodNumber>;
2598
1948
  interface _ZodBoolean<T extends $ZodBooleanInternals = $ZodBooleanInternals> extends _ZodType<T> {}
2599
1949
  interface ZodBoolean extends _ZodBoolean<$ZodBooleanInternals<boolean>> {}
2600
1950
  declare const ZodBoolean: $constructor<ZodBoolean>;
1951
+ interface ZodUnknown extends _ZodType<$ZodUnknownInternals> {}
1952
+ declare const ZodUnknown: $constructor<ZodUnknown>;
2601
1953
  interface ZodArray<T extends SomeType = $ZodType> extends _ZodType<$ZodArrayInternals<T>>, $ZodArray<T> {
2602
1954
  element: T;
2603
1955
  min(minLength: number, params?: string | $ZodCheckMinLengthParams): this;
@@ -2646,6 +1998,12 @@ interface ZodIntersection<A extends SomeType = $ZodType, B extends SomeType = $Z
2646
1998
  "~standard": ZodStandardSchemaWithJSON<this>;
2647
1999
  }
2648
2000
  declare const ZodIntersection: $constructor<ZodIntersection>;
2001
+ interface ZodRecord<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends _ZodType<$ZodRecordInternals<Key, Value>>, $ZodRecord<Key, Value> {
2002
+ "~standard": ZodStandardSchemaWithJSON<this>;
2003
+ keyType: Key;
2004
+ valueType: Value;
2005
+ }
2006
+ declare const ZodRecord: $constructor<ZodRecord>;
2649
2007
  interface ZodEnum< /** @ts-ignore Cast variance */out T extends EnumLike = EnumLike> extends _ZodType<$ZodEnumInternals<T>>, $ZodEnum<T> {
2650
2008
  "~standard": ZodStandardSchemaWithJSON<this>;
2651
2009
  enum: T;
@@ -2654,6 +2012,13 @@ interface ZodEnum< /** @ts-ignore Cast variance */out T extends EnumLike = EnumL
2654
2012
  exclude<const U extends readonly (keyof T)[]>(values: U, params?: string | $ZodEnumParams): ZodEnum<Flatten<Omit<T, U[number]>>>;
2655
2013
  }
2656
2014
  declare const ZodEnum: $constructor<ZodEnum>;
2015
+ interface ZodLiteral<T extends Literal = Literal> extends _ZodType<$ZodLiteralInternals<T>>, $ZodLiteral<T> {
2016
+ "~standard": ZodStandardSchemaWithJSON<this>;
2017
+ values: Set<T>;
2018
+ /** @legacy Use `.values` instead. Accessing this property will throw an error if the literal accepts multiple values. */
2019
+ value: T;
2020
+ }
2021
+ declare const ZodLiteral: $constructor<ZodLiteral>;
2657
2022
  interface ZodTransform<O = unknown, I = unknown> extends _ZodType<$ZodTransformInternals<O, I>>, $ZodTransform<O, I> {
2658
2023
  "~standard": ZodStandardSchemaWithJSON<this>;
2659
2024
  }
@@ -2696,81 +2061,315 @@ interface ZodCatch<T extends SomeType = $ZodType> extends _ZodType<$ZodCatchInte
2696
2061
  /** @deprecated Use `.unwrap()` instead. */
2697
2062
  removeCatch(): T;
2698
2063
  }
2699
- declare const ZodCatch: $constructor<ZodCatch>;
2700
- interface ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends _ZodType<$ZodPipeInternals<A, B>>, $ZodPipe<A, B> {
2701
- "~standard": ZodStandardSchemaWithJSON<this>;
2702
- in: A;
2703
- out: B;
2064
+ declare const ZodCatch: $constructor<ZodCatch>;
2065
+ interface ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends _ZodType<$ZodPipeInternals<A, B>>, $ZodPipe<A, B> {
2066
+ "~standard": ZodStandardSchemaWithJSON<this>;
2067
+ in: A;
2068
+ out: B;
2069
+ }
2070
+ declare const ZodPipe: $constructor<ZodPipe>;
2071
+ interface ZodReadonly<T extends SomeType = $ZodType> extends _ZodType<$ZodReadonlyInternals<T>>, $ZodReadonly<T> {
2072
+ "~standard": ZodStandardSchemaWithJSON<this>;
2073
+ unwrap(): T;
2074
+ }
2075
+ declare const ZodReadonly: $constructor<ZodReadonly>;
2076
+ //#endregion
2077
+ //#region node_modules/.pnpm/neverthrow@8.2.0/node_modules/neverthrow/dist/index.d.ts
2078
+ interface ErrorConfig {
2079
+ withStackTrace: boolean;
2080
+ }
2081
+ declare class ResultAsync<T, E> implements PromiseLike<Result$1<T, E>> {
2082
+ private _promise;
2083
+ constructor(res: Promise<Result$1<T, E>>);
2084
+ static fromSafePromise<T, E = never>(promise: PromiseLike<T>): ResultAsync<T, E>;
2085
+ static fromPromise<T, E>(promise: PromiseLike<T>, errorFn: (e: unknown) => E): ResultAsync<T, E>;
2086
+ static fromThrowable<A extends readonly any[], R, E>(fn: (...args: A) => Promise<R>, errorFn?: (err: unknown) => E): (...args: A) => ResultAsync<R, E>;
2087
+ static combine<T extends readonly [ResultAsync<unknown, unknown>, ...ResultAsync<unknown, unknown>[]]>(asyncResultList: T): CombineResultAsyncs<T>;
2088
+ static combine<T extends readonly ResultAsync<unknown, unknown>[]>(asyncResultList: T): CombineResultAsyncs<T>;
2089
+ static combineWithAllErrors<T extends readonly [ResultAsync<unknown, unknown>, ...ResultAsync<unknown, unknown>[]]>(asyncResultList: T): CombineResultsWithAllErrorsArrayAsync<T>;
2090
+ static combineWithAllErrors<T extends readonly ResultAsync<unknown, unknown>[]>(asyncResultList: T): CombineResultsWithAllErrorsArrayAsync<T>;
2091
+ map<A>(f: (t: T) => A | Promise<A>): ResultAsync<A, E>;
2092
+ andThrough<F>(f: (t: T) => Result$1<unknown, F> | ResultAsync<unknown, F>): ResultAsync<T, E | F>;
2093
+ andTee(f: (t: T) => unknown): ResultAsync<T, E>;
2094
+ orTee(f: (t: E) => unknown): ResultAsync<T, E>;
2095
+ mapErr<U>(f: (e: E) => U | Promise<U>): ResultAsync<T, U>;
2096
+ andThen<R extends Result$1<unknown, unknown>>(f: (t: T) => R): ResultAsync<InferOkTypes<R>, InferErrTypes<R> | E>;
2097
+ andThen<R extends ResultAsync<unknown, unknown>>(f: (t: T) => R): ResultAsync<InferAsyncOkTypes<R>, InferAsyncErrTypes<R> | E>;
2098
+ andThen<U, F>(f: (t: T) => Result$1<U, F> | ResultAsync<U, F>): ResultAsync<U, E | F>;
2099
+ orElse<R extends Result$1<unknown, unknown>>(f: (e: E) => R): ResultAsync<InferOkTypes<R> | T, InferErrTypes<R>>;
2100
+ orElse<R extends ResultAsync<unknown, unknown>>(f: (e: E) => R): ResultAsync<InferAsyncOkTypes<R> | T, InferAsyncErrTypes<R>>;
2101
+ orElse<U, A>(f: (e: E) => Result$1<U, A> | ResultAsync<U, A>): ResultAsync<U | T, A>;
2102
+ match<A, B = A>(ok: (t: T) => A, _err: (e: E) => B): Promise<A | B>;
2103
+ unwrapOr<A>(t: A): Promise<T | A>;
2104
+ /**
2105
+ * @deprecated will be removed in 9.0.0.
2106
+ *
2107
+ * You can use `safeTry` without this method.
2108
+ * @example
2109
+ * ```typescript
2110
+ * safeTry(async function* () {
2111
+ * const okValue = yield* yourResult
2112
+ * })
2113
+ * ```
2114
+ * Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
2115
+ */
2116
+ safeUnwrap(): AsyncGenerator<Err<never, E>, T>;
2117
+ then<A, B>(successCallback?: (res: Result$1<T, E>) => A | PromiseLike<A>, failureCallback?: (reason: unknown) => B | PromiseLike<B>): PromiseLike<A | B>;
2118
+ [Symbol.asyncIterator](): AsyncGenerator<Err<never, E>, T>;
2119
+ }
2120
+ declare type CombineResultAsyncs<T extends readonly ResultAsync<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseAsync<UnwrapAsync<T>> : ResultAsync<ExtractOkAsyncTypes<T>, ExtractErrAsyncTypes<T>[number]>;
2121
+ declare type CombineResultsWithAllErrorsArrayAsync<T extends readonly ResultAsync<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseWithAllErrorsAsync<UnwrapAsync<T>> : ResultAsync<ExtractOkAsyncTypes<T>, ExtractErrAsyncTypes<T>[number][]>;
2122
+ declare type UnwrapAsync<T> = IsLiteralArray<T> extends 1 ? Writable<T> extends [infer H, ...infer Rest] ? H extends PromiseLike<infer HI> ? HI extends Result$1<unknown, unknown> ? [Dedup<HI>, ...UnwrapAsync<Rest>] : never : never : [] : T extends Array<infer A> ? A extends PromiseLike<infer HI> ? HI extends Result$1<infer L, infer R> ? Ok<L, R>[] : never : never : never;
2123
+ declare type TraverseAsync<T, Depth extends number = 5> = IsLiteralArray<T> extends 1 ? Combine<T, Depth> extends [infer Oks, infer Errs] ? ResultAsync<EmptyArrayToNever<Oks>, MembersToUnion<Errs>> : never : T extends Array<infer I> ? Combine<MemberListOf<I>, Depth> extends [infer Oks, infer Errs] ? Oks extends unknown[] ? Errs extends unknown[] ? ResultAsync<EmptyArrayToNever<Oks[number][]>, MembersToUnion<Errs[number][]>> : ResultAsync<EmptyArrayToNever<Oks[number][]>, Errs> : Errs extends unknown[] ? ResultAsync<Oks, MembersToUnion<Errs[number][]>> : ResultAsync<Oks, Errs> : never : never;
2124
+ declare type TraverseWithAllErrorsAsync<T, Depth extends number = 5> = TraverseAsync<T, Depth> extends ResultAsync<infer Oks, infer Errs> ? ResultAsync<Oks, Errs[]> : never;
2125
+ declare type Writable<T> = T extends ReadonlyArray<unknown> ? [...T] : T;
2126
+ declare type ExtractOkTypes<T extends readonly Result$1<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends Result$1<infer U, unknown> ? U : never };
2127
+ declare type ExtractOkAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends ResultAsync<infer U, unknown> ? U : never };
2128
+ declare type ExtractErrTypes<T extends readonly Result$1<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends Result$1<unknown, infer E> ? E : never };
2129
+ declare type ExtractErrAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends ResultAsync<unknown, infer E> ? E : never };
2130
+ declare type InferOkTypes<R> = R extends Result$1<infer T, unknown> ? T : never;
2131
+ declare type InferErrTypes<R> = R extends Result$1<unknown, infer E> ? E : never;
2132
+ declare type InferAsyncOkTypes<R> = R extends ResultAsync<infer T, unknown> ? T : never;
2133
+ declare type InferAsyncErrTypes<R> = R extends ResultAsync<unknown, infer E> ? E : never;
2134
+ declare namespace Result$1 {
2135
+ /**
2136
+ * Wraps a function with a try catch, creating a new function with the same
2137
+ * arguments but returning `Ok` if successful, `Err` if the function throws
2138
+ *
2139
+ * @param fn function to wrap with ok on success or err on failure
2140
+ * @param errorFn when an error is thrown, this will wrap the error result if provided
2141
+ */
2142
+ function fromThrowable<Fn extends (...args: readonly any[]) => any, E>(fn: Fn, errorFn?: (e: unknown) => E): (...args: Parameters<Fn>) => Result$1<ReturnType<Fn>, E>;
2143
+ function combine<T extends readonly [Result$1<unknown, unknown>, ...Result$1<unknown, unknown>[]]>(resultList: T): CombineResults<T>;
2144
+ function combine<T extends readonly Result$1<unknown, unknown>[]>(resultList: T): CombineResults<T>;
2145
+ function combineWithAllErrors<T extends readonly [Result$1<unknown, unknown>, ...Result$1<unknown, unknown>[]]>(resultList: T): CombineResultsWithAllErrorsArray<T>;
2146
+ function combineWithAllErrors<T extends readonly Result$1<unknown, unknown>[]>(resultList: T): CombineResultsWithAllErrorsArray<T>;
2147
+ }
2148
+ declare type Result$1<T, E> = Ok<T, E> | Err<T, E>;
2149
+ interface IResult<T, E> {
2150
+ /**
2151
+ * Used to check if a `Result` is an `OK`
2152
+ *
2153
+ * @returns `true` if the result is an `OK` variant of Result
2154
+ */
2155
+ isOk(): this is Ok<T, E>;
2156
+ /**
2157
+ * Used to check if a `Result` is an `Err`
2158
+ *
2159
+ * @returns `true` if the result is an `Err` variant of Result
2160
+ */
2161
+ isErr(): this is Err<T, E>;
2162
+ /**
2163
+ * Maps a `Result<T, E>` to `Result<U, E>`
2164
+ * by applying a function to a contained `Ok` value, leaving an `Err` value
2165
+ * untouched.
2166
+ *
2167
+ * @param f The function to apply an `OK` value
2168
+ * @returns the result of applying `f` or an `Err` untouched
2169
+ */
2170
+ map<A>(f: (t: T) => A): Result$1<A, E>;
2171
+ /**
2172
+ * Maps a `Result<T, E>` to `Result<T, F>` by applying a function to a
2173
+ * contained `Err` value, leaving an `Ok` value untouched.
2174
+ *
2175
+ * This function can be used to pass through a successful result while
2176
+ * handling an error.
2177
+ *
2178
+ * @param f a function to apply to the error `Err` value
2179
+ */
2180
+ mapErr<U>(f: (e: E) => U): Result$1<T, U>;
2181
+ /**
2182
+ * Similar to `map` Except you must return a new `Result`.
2183
+ *
2184
+ * This is useful for when you need to do a subsequent computation using the
2185
+ * inner `T` value, but that computation might fail.
2186
+ * Additionally, `andThen` is really useful as a tool to flatten a
2187
+ * `Result<Result<A, E2>, E1>` into a `Result<A, E2>` (see example below).
2188
+ *
2189
+ * @param f The function to apply to the current value
2190
+ */
2191
+ andThen<R extends Result$1<unknown, unknown>>(f: (t: T) => R): Result$1<InferOkTypes<R>, InferErrTypes<R> | E>;
2192
+ andThen<U, F>(f: (t: T) => Result$1<U, F>): Result$1<U, E | F>;
2193
+ /**
2194
+ * This "tee"s the current value to an passed-in computation such as side
2195
+ * effect functions but still returns the same current value as the result.
2196
+ *
2197
+ * This is useful when you want to pass the current result to your side-track
2198
+ * work such as logging but want to continue main-track work after that.
2199
+ * This method does not care about the result of the passed in computation.
2200
+ *
2201
+ * @param f The function to apply to the current value
2202
+ */
2203
+ andTee(f: (t: T) => unknown): Result$1<T, E>;
2204
+ /**
2205
+ * This "tee"s the current `Err` value to an passed-in computation such as side
2206
+ * effect functions but still returns the same `Err` value as the result.
2207
+ *
2208
+ * This is useful when you want to pass the current `Err` value to your side-track
2209
+ * work such as logging but want to continue error-track work after that.
2210
+ * This method does not care about the result of the passed in computation.
2211
+ *
2212
+ * @param f The function to apply to the current `Err` value
2213
+ */
2214
+ orTee(f: (t: E) => unknown): Result$1<T, E>;
2215
+ /**
2216
+ * Similar to `andTee` except error result of the computation will be passed
2217
+ * to the downstream in case of an error.
2218
+ *
2219
+ * This version is useful when you want to make side-effects but in case of an
2220
+ * error, you want to pass the error to the downstream.
2221
+ *
2222
+ * @param f The function to apply to the current value
2223
+ */
2224
+ andThrough<R extends Result$1<unknown, unknown>>(f: (t: T) => R): Result$1<T, InferErrTypes<R> | E>;
2225
+ andThrough<F>(f: (t: T) => Result$1<unknown, F>): Result$1<T, E | F>;
2226
+ /**
2227
+ * Takes an `Err` value and maps it to a `Result<T, SomeNewType>`.
2228
+ *
2229
+ * This is useful for error recovery.
2230
+ *
2231
+ *
2232
+ * @param f A function to apply to an `Err` value, leaving `Ok` values
2233
+ * untouched.
2234
+ */
2235
+ orElse<R extends Result$1<unknown, unknown>>(f: (e: E) => R): Result$1<InferOkTypes<R> | T, InferErrTypes<R>>;
2236
+ orElse<U, A>(f: (e: E) => Result$1<U, A>): Result$1<U | T, A>;
2237
+ /**
2238
+ * Similar to `map` Except you must return a new `Result`.
2239
+ *
2240
+ * This is useful for when you need to do a subsequent async computation using
2241
+ * the inner `T` value, but that computation might fail. Must return a ResultAsync
2242
+ *
2243
+ * @param f The function that returns a `ResultAsync` to apply to the current
2244
+ * value
2245
+ */
2246
+ asyncAndThen<U, F>(f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
2247
+ /**
2248
+ * Maps a `Result<T, E>` to `ResultAsync<U, E>`
2249
+ * by applying an async function to a contained `Ok` value, leaving an `Err`
2250
+ * value untouched.
2251
+ *
2252
+ * @param f An async function to apply an `OK` value
2253
+ */
2254
+ asyncMap<U>(f: (t: T) => Promise<U>): ResultAsync<U, E>;
2255
+ /**
2256
+ * Unwrap the `Ok` value, or return the default if there is an `Err`
2257
+ *
2258
+ * @param v the default value to return if there is an `Err`
2259
+ */
2260
+ unwrapOr<A>(v: A): T | A;
2261
+ /**
2262
+ *
2263
+ * Given 2 functions (one for the `Ok` variant and one for the `Err` variant)
2264
+ * execute the function that matches the `Result` variant.
2265
+ *
2266
+ * Match callbacks do not necessitate to return a `Result`, however you can
2267
+ * return a `Result` if you want to.
2268
+ *
2269
+ * `match` is like chaining `map` and `mapErr`, with the distinction that
2270
+ * with `match` both functions must have the same return type.
2271
+ *
2272
+ * @param ok
2273
+ * @param err
2274
+ */
2275
+ match<A, B = A>(ok: (t: T) => A, err: (e: E) => B): A | B;
2276
+ /**
2277
+ * @deprecated will be removed in 9.0.0.
2278
+ *
2279
+ * You can use `safeTry` without this method.
2280
+ * @example
2281
+ * ```typescript
2282
+ * safeTry(function* () {
2283
+ * const okValue = yield* yourResult
2284
+ * })
2285
+ * ```
2286
+ * Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
2287
+ */
2288
+ safeUnwrap(): Generator<Err<never, E>, T>;
2289
+ /**
2290
+ * **This method is unsafe, and should only be used in a test environments**
2291
+ *
2292
+ * Takes a `Result<T, E>` and returns a `T` when the result is an `Ok`, otherwise it throws a custom object.
2293
+ *
2294
+ * @param config
2295
+ */
2296
+ _unsafeUnwrap(config?: ErrorConfig): T;
2297
+ /**
2298
+ * **This method is unsafe, and should only be used in a test environments**
2299
+ *
2300
+ * takes a `Result<T, E>` and returns a `E` when the result is an `Err`,
2301
+ * otherwise it throws a custom object.
2302
+ *
2303
+ * @param config
2304
+ */
2305
+ _unsafeUnwrapErr(config?: ErrorConfig): E;
2704
2306
  }
2705
- declare const ZodPipe: $constructor<ZodPipe>;
2706
- interface ZodReadonly<T extends SomeType = $ZodType> extends _ZodType<$ZodReadonlyInternals<T>>, $ZodReadonly<T> {
2707
- "~standard": ZodStandardSchemaWithJSON<this>;
2708
- unwrap(): T;
2307
+ declare class Ok<T, E> implements IResult<T, E> {
2308
+ readonly value: T;
2309
+ constructor(value: T);
2310
+ isOk(): this is Ok<T, E>;
2311
+ isErr(): this is Err<T, E>;
2312
+ map<A>(f: (t: T) => A): Result$1<A, E>;
2313
+ mapErr<U>(_f: (e: E) => U): Result$1<T, U>;
2314
+ andThen<R extends Result$1<unknown, unknown>>(f: (t: T) => R): Result$1<InferOkTypes<R>, InferErrTypes<R> | E>;
2315
+ andThen<U, F>(f: (t: T) => Result$1<U, F>): Result$1<U, E | F>;
2316
+ andThrough<R extends Result$1<unknown, unknown>>(f: (t: T) => R): Result$1<T, InferErrTypes<R> | E>;
2317
+ andThrough<F>(f: (t: T) => Result$1<unknown, F>): Result$1<T, E | F>;
2318
+ andTee(f: (t: T) => unknown): Result$1<T, E>;
2319
+ orTee(_f: (t: E) => unknown): Result$1<T, E>;
2320
+ orElse<R extends Result$1<unknown, unknown>>(_f: (e: E) => R): Result$1<InferOkTypes<R> | T, InferErrTypes<R>>;
2321
+ orElse<U, A>(_f: (e: E) => Result$1<U, A>): Result$1<U | T, A>;
2322
+ asyncAndThen<U, F>(f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
2323
+ asyncAndThrough<R extends ResultAsync<unknown, unknown>>(f: (t: T) => R): ResultAsync<T, InferAsyncErrTypes<R> | E>;
2324
+ asyncAndThrough<F>(f: (t: T) => ResultAsync<unknown, F>): ResultAsync<T, E | F>;
2325
+ asyncMap<U>(f: (t: T) => Promise<U>): ResultAsync<U, E>;
2326
+ unwrapOr<A>(_v: A): T | A;
2327
+ match<A, B = A>(ok: (t: T) => A, _err: (e: E) => B): A | B;
2328
+ safeUnwrap(): Generator<Err<never, E>, T>;
2329
+ _unsafeUnwrap(_?: ErrorConfig): T;
2330
+ _unsafeUnwrapErr(config?: ErrorConfig): E;
2331
+ [Symbol.iterator](): Generator<Err<never, E>, T>;
2709
2332
  }
2710
- declare const ZodReadonly: $constructor<ZodReadonly>;
2711
- //#endregion
2712
- //#region src/core/schemas.d.ts
2713
- /** Zod schema for the raw token response from the OAuth token endpoint. */
2714
- declare const TokenResponseSchema: ZodObject<{
2715
- access_token: ZodString;
2716
- refresh_token: ZodDefault<ZodOptional<ZodNullable<ZodString>>>;
2717
- expires_in: ZodNumber;
2718
- token_type: ZodString;
2719
- scope: ZodDefault<ZodOptional<ZodNullable<ZodString>>>;
2720
- id_token: ZodDefault<ZodOptional<ZodNullable<ZodString>>>;
2721
- }, $strip>;
2722
- /** Zod schema for a Fanvue user profile. */
2723
- declare const FanvueUserSchema: ZodObject<{
2724
- uuid: ZodString;
2725
- email: ZodString;
2726
- handle: ZodString;
2727
- displayName: ZodString;
2728
- isCreator: ZodBoolean;
2729
- avatarUrl: ZodNullable<ZodString>;
2730
- bannerUrl: ZodNullable<ZodString>;
2731
- createdAt: ZodString;
2732
- updatedAt: ZodNullable<ZodString>;
2733
- }, $strip>;
2734
- /** Zod schema for the authorize-on-behalf response from the Fanvue platform. */
2735
- declare const AuthorizeOnBehalfResponseSchema: ZodObject<{
2736
- code: ZodString;
2737
- state: ZodString;
2738
- }, $strip>;
2739
- /** Zod schema for the session JWT payload. */
2740
- declare const SessionPayloadSchema: ZodObject<{
2741
- accessToken: ZodString;
2742
- refreshToken: ZodNullable<ZodString>;
2743
- expiresAt: ZodNumber;
2744
- tokenType: ZodNullable<ZodString>;
2745
- scope: ZodNullable<ZodString>;
2746
- idToken: ZodNullable<ZodString>;
2747
- userUuid: ZodString;
2748
- handle: ZodString;
2749
- displayName: ZodString;
2750
- isCreator: ZodBoolean;
2751
- avatarUrl: ZodNullable<ZodString>;
2752
- }, $loose>;
2753
- //#endregion
2754
- //#region src/core/client.d.ts
2755
- /**
2756
- * A client for making authenticated requests to the Fanvue API.
2757
- */
2758
- interface FanvueClient {
2759
- /**
2760
- * Fetches the currently authenticated user's profile.
2761
- *
2762
- * @returns A `Result` containing the {@link FanvueUser} on success or `ApiError` on failure.
2763
- */
2764
- getCurrentUser(): Promise<Result$1<FanvueUser, ApiError>>;
2333
+ declare class Err<T, E> implements IResult<T, E> {
2334
+ readonly error: E;
2335
+ constructor(error: E);
2336
+ isOk(): this is Ok<T, E>;
2337
+ isErr(): this is Err<T, E>;
2338
+ map<A>(_f: (t: T) => A): Result$1<A, E>;
2339
+ mapErr<U>(f: (e: E) => U): Result$1<T, U>;
2340
+ andThrough<F>(_f: (t: T) => Result$1<unknown, F>): Result$1<T, E | F>;
2341
+ andTee(_f: (t: T) => unknown): Result$1<T, E>;
2342
+ orTee(f: (t: E) => unknown): Result$1<T, E>;
2343
+ andThen<R extends Result$1<unknown, unknown>>(_f: (t: T) => R): Result$1<InferOkTypes<R>, InferErrTypes<R> | E>;
2344
+ andThen<U, F>(_f: (t: T) => Result$1<U, F>): Result$1<U, E | F>;
2345
+ orElse<R extends Result$1<unknown, unknown>>(f: (e: E) => R): Result$1<InferOkTypes<R> | T, InferErrTypes<R>>;
2346
+ orElse<U, A>(f: (e: E) => Result$1<U, A>): Result$1<U | T, A>;
2347
+ asyncAndThen<U, F>(_f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
2348
+ asyncAndThrough<F>(_f: (t: T) => ResultAsync<unknown, F>): ResultAsync<T, E | F>;
2349
+ asyncMap<U>(_f: (t: T) => Promise<U>): ResultAsync<U, E>;
2350
+ unwrapOr<A>(v: A): T | A;
2351
+ match<A, B = A>(_ok: (t: T) => A, err: (e: E) => B): A | B;
2352
+ safeUnwrap(): Generator<Err<never, E>, T>;
2353
+ _unsafeUnwrap(config?: ErrorConfig): T;
2354
+ _unsafeUnwrapErr(_?: ErrorConfig): E;
2355
+ [Symbol.iterator](): Generator<Err<never, E>, T>;
2765
2356
  }
2766
- /**
2767
- * Creates a new {@link FanvueClient} for making authenticated requests to the Fanvue API.
2768
- *
2769
- * @param accessToken - The OAuth access token to authenticate requests.
2770
- * @param apiBaseUrl - The base URL for the Fanvue API, or `null` to use the default.
2771
- * @returns A {@link FanvueClient} instance.
2772
- */
2773
- declare function createFanvueClient(accessToken: string, apiBaseUrl: string | null): FanvueClient;
2357
+ declare type Prev = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, ...0[]];
2358
+ declare type CollectResults<T, Collected extends unknown[] = [], Depth extends number = 50> = [Depth] extends [never] ? [] : T extends [infer H, ...infer Rest] ? H extends Result$1<infer L, infer R> ? CollectResults<Rest, [...Collected, [L, R]], Prev[Depth]> : never : Collected;
2359
+ declare type Transpose<A, Transposed extends unknown[][] = [], Depth extends number = 10> = A extends [infer T, ...infer Rest] ? T extends [infer L, infer R] ? Transposed extends [infer PL, infer PR] ? PL extends unknown[] ? PR extends unknown[] ? Transpose<Rest, [[...PL, L], [...PR, R]], Prev[Depth]> : never : never : Transpose<Rest, [[L], [R]], Prev[Depth]> : Transposed : Transposed;
2360
+ declare type Combine<T, Depth extends number = 5> = Transpose<CollectResults<T>, [], Depth> extends [infer L, infer R] ? [UnknownMembersToNever<L>, UnknownMembersToNever<R>] : Transpose<CollectResults<T>, [], Depth> extends [] ? [[], []] : never;
2361
+ declare type Dedup<T> = T extends Result$1<infer RL, infer RR> ? [unknown] extends [RL] ? Err<RL, RR> : Ok<RL, RR> : T;
2362
+ declare type MemberListOf<T> = ((T extends unknown ? (t: T) => T : never) extends infer U ? (U extends unknown ? (u: U) => unknown : never) extends ((v: infer V) => unknown) ? V : never : never) extends ((_: unknown) => infer W) ? [...MemberListOf<Exclude<T, W>>, W] : [];
2363
+ declare type EmptyArrayToNever<T, NeverArrayToNever extends number = 0> = T extends [] ? never : NeverArrayToNever extends 1 ? T extends [never, ...infer Rest] ? [EmptyArrayToNever<Rest>] extends [never] ? never : T : T : T;
2364
+ declare type UnknownMembersToNever<T> = T extends [infer H, ...infer R] ? [[unknown] extends [H] ? never : H, ...UnknownMembersToNever<R>] : T;
2365
+ declare type MembersToUnion<T> = T extends unknown[] ? T[number] : never;
2366
+ declare type IsLiteralArray<T> = T extends {
2367
+ length: infer L;
2368
+ } ? L extends number ? number extends L ? 0 : 1 : 0 : 0;
2369
+ declare type Traverse<T, Depth extends number = 5> = Combine<T, Depth> extends [infer Oks, infer Errs] ? Result$1<EmptyArrayToNever<Oks, 1>, MembersToUnion<Errs>> : never;
2370
+ declare type TraverseWithAllErrors<T, Depth extends number = 5> = Traverse<T, Depth> extends Result$1<infer Oks, infer Errs> ? Result$1<Oks, Errs[]> : never;
2371
+ declare type CombineResults<T extends readonly Result$1<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? Traverse<T> : Result$1<ExtractOkTypes<T>, ExtractErrTypes<T>[number]>;
2372
+ declare type CombineResultsWithAllErrorsArray<T extends readonly Result$1<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseWithAllErrors<T> : Result$1<ExtractOkTypes<T>, ExtractErrTypes<T>[number][]>;
2774
2373
  //#endregion
2775
- export { DEFAULT_ISSUER_URL as A, OAuthConfig as C, TokenResponse as D, SessionVerifyError as E, HEADER_UPDATED_SESSION as F, DEFAULT_SCOPES as M, assertFanvueDomain as N, API_VERSION as O, BEARER_PREFIX as P, JsonParseError as S, SessionPayload as T, refreshAccessToken as _, SessionPayloadSchema as a, EmbeddedAuthError as b, FanvueTheme as c, getThemeFromUrl as d, requestAuthorizationCodeOnBehalf as f, exchangeCodeForToken as g, createAuthorizationUrl as h, FanvueUserSchema as i, DEFAULT_PLATFORM_URL as j, DEFAULT_API_BASE_URL as k, exchangeSessionToken as l, verifySessionJwt as m, createFanvueClient as n, TokenResponseSchema as o, createSessionJwt as p, AuthorizeOnBehalfResponseSchema as r, safeJsonParse as s, FanvueClient as t, getSessionTokenFromUrl as u, ApiError as v, OAuthError as w, FanvueUser as x, EmbeddedAuthConfig as y };
2776
- //# sourceMappingURL=index-pS9wR5yg.d.ts.map
2374
+ export { $strip as _, ZodEnum as a, ZodNumber as c, ZodRecord as d, ZodString as f, $loose as g, output as h, ZodDefault as i, ZodObject as l, ZodUnknown as m, ZodArray as n, ZodLiteral as o, ZodUnion as p, ZodBoolean as r, ZodNullable as s, Result$1 as t, ZodOptional as u };
2375
+ //# sourceMappingURL=index-Dr-mZ0qP.d.ts.map