@fanvue/builder-sdk 0.3.0 → 0.5.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.
- package/README.md +361 -1
- package/dist/bridge/index.d.ts +2 -0
- package/dist/bridge/index.js +3 -0
- package/dist/bridge-QnF7P4Co.js +336 -0
- package/dist/bridge-QnF7P4Co.js.map +1 -0
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +3 -2
- package/dist/core-BhKiA55a.js +2962 -0
- package/dist/core-BhKiA55a.js.map +1 -0
- package/dist/index-C3CXrRiw.d.ts +1412 -0
- package/dist/index-C3CXrRiw.d.ts.map +1 -0
- package/dist/index-CEFYZtlb.d.ts +223 -0
- package/dist/index-CEFYZtlb.d.ts.map +1 -0
- package/dist/{index-pS9wR5yg.d.ts → index-cf3ZMnLJ.d.ts} +524 -901
- package/dist/index-cf3ZMnLJ.d.ts.map +1 -0
- package/dist/index-v_6Z4Q0u.d.ts +84 -0
- package/dist/index-v_6Z4Q0u.d.ts.map +1 -0
- package/dist/{core-CvVOMyqr.js → index.cjs-teGsk6HB.js} +1506 -2826
- package/dist/index.cjs-teGsk6HB.js.map +1 -0
- package/dist/nextjs/embedded-app/index.d.ts +2 -2
- package/dist/nextjs/embedded-app/index.js +3 -2
- package/dist/nextjs/embedded-app/index.js.map +1 -1
- package/dist/nextjs/off-platform/index.d.ts +3 -3
- package/dist/nextjs/off-platform/index.d.ts.map +1 -1
- package/dist/nextjs/off-platform/index.js +4 -3
- package/dist/nextjs/off-platform/index.js.map +1 -1
- package/dist/nextjs-CvVhtMdb.js +144 -0
- package/dist/nextjs-CvVhtMdb.js.map +1 -0
- package/dist/react/index.d.ts +37 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +61 -2
- package/dist/react/index.js.map +1 -1
- package/package.json +20 -16
- package/dist/core-CvVOMyqr.js.map +0 -1
- package/dist/index-CweVyIKX.d.ts +0 -48
- package/dist/index-CweVyIKX.d.ts.map +0 -1
- package/dist/index-pS9wR5yg.d.ts.map +0 -1
- package/dist/nextjs-CESI_EiU.js +0 -80
- package/dist/nextjs-CESI_EiU.js.map +0 -1
|
@@ -1,837 +1,187 @@
|
|
|
1
|
-
//#region
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
interface
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
*/
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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
|
|
@@ -1527,6 +877,18 @@ interface $ZodUnion<T extends readonly SomeType[] = readonly $ZodType[]> extends
|
|
|
1527
877
|
_zod: $ZodUnionInternals<T>;
|
|
1528
878
|
}
|
|
1529
879
|
declare const $ZodUnion: $constructor<$ZodUnion>;
|
|
880
|
+
interface $ZodDiscriminatedUnionDef<Options extends readonly SomeType[] = readonly $ZodType[], Disc extends string = string> extends $ZodUnionDef<Options> {
|
|
881
|
+
discriminator: Disc;
|
|
882
|
+
unionFallback?: boolean;
|
|
883
|
+
}
|
|
884
|
+
interface $ZodDiscriminatedUnionInternals<Options extends readonly SomeType[] = readonly $ZodType[], Disc extends string = string> extends $ZodUnionInternals<Options> {
|
|
885
|
+
def: $ZodDiscriminatedUnionDef<Options, Disc>;
|
|
886
|
+
propValues: PropValues;
|
|
887
|
+
}
|
|
888
|
+
interface $ZodDiscriminatedUnion<Options extends readonly SomeType[] = readonly $ZodType[], Disc extends string = string> extends $ZodType {
|
|
889
|
+
_zod: $ZodDiscriminatedUnionInternals<Options, Disc>;
|
|
890
|
+
}
|
|
891
|
+
declare const $ZodDiscriminatedUnion: $constructor<$ZodDiscriminatedUnion>;
|
|
1530
892
|
interface $ZodIntersectionDef<Left extends SomeType = $ZodType, Right extends SomeType = $ZodType> extends $ZodTypeDef {
|
|
1531
893
|
type: "intersection";
|
|
1532
894
|
left: Left;
|
|
@@ -2563,6 +1925,12 @@ interface ZodString extends _ZodString<$ZodStringInternals<string>> {
|
|
|
2563
1925
|
duration(params?: string | $ZodCheckISODurationParams): this;
|
|
2564
1926
|
}
|
|
2565
1927
|
declare const ZodString: $constructor<ZodString>;
|
|
1928
|
+
interface ZodStringFormat<Format extends string = string> extends _ZodString<$ZodStringFormatInternals<Format>> {}
|
|
1929
|
+
declare const ZodStringFormat: $constructor<ZodStringFormat>;
|
|
1930
|
+
interface ZodURL extends ZodStringFormat<"url"> {
|
|
1931
|
+
_zod: $ZodURLInternals;
|
|
1932
|
+
}
|
|
1933
|
+
declare const ZodURL: $constructor<ZodURL>;
|
|
2566
1934
|
interface _ZodNumber<Internals extends $ZodNumberInternals = $ZodNumberInternals> extends _ZodType<Internals> {
|
|
2567
1935
|
gt(value: number, params?: string | $ZodCheckGreaterThanParams): this;
|
|
2568
1936
|
/** Identical to .min() */
|
|
@@ -2598,6 +1966,8 @@ declare const ZodNumber: $constructor<ZodNumber>;
|
|
|
2598
1966
|
interface _ZodBoolean<T extends $ZodBooleanInternals = $ZodBooleanInternals> extends _ZodType<T> {}
|
|
2599
1967
|
interface ZodBoolean extends _ZodBoolean<$ZodBooleanInternals<boolean>> {}
|
|
2600
1968
|
declare const ZodBoolean: $constructor<ZodBoolean>;
|
|
1969
|
+
interface ZodUnknown extends _ZodType<$ZodUnknownInternals> {}
|
|
1970
|
+
declare const ZodUnknown: $constructor<ZodUnknown>;
|
|
2601
1971
|
interface ZodArray<T extends SomeType = $ZodType> extends _ZodType<$ZodArrayInternals<T>>, $ZodArray<T> {
|
|
2602
1972
|
element: T;
|
|
2603
1973
|
min(minLength: number, params?: string | $ZodCheckMinLengthParams): this;
|
|
@@ -2642,10 +2012,22 @@ interface ZodUnion<T extends readonly SomeType[] = readonly $ZodType[]> extends
|
|
|
2642
2012
|
options: T;
|
|
2643
2013
|
}
|
|
2644
2014
|
declare const ZodUnion: $constructor<ZodUnion>;
|
|
2015
|
+
interface ZodDiscriminatedUnion<Options extends readonly SomeType[] = readonly $ZodType[], Disc extends string = string> extends ZodUnion<Options>, $ZodDiscriminatedUnion<Options, Disc> {
|
|
2016
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
2017
|
+
_zod: $ZodDiscriminatedUnionInternals<Options, Disc>;
|
|
2018
|
+
def: $ZodDiscriminatedUnionDef<Options, Disc>;
|
|
2019
|
+
}
|
|
2020
|
+
declare const ZodDiscriminatedUnion: $constructor<ZodDiscriminatedUnion>;
|
|
2645
2021
|
interface ZodIntersection<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends _ZodType<$ZodIntersectionInternals<A, B>>, $ZodIntersection<A, B> {
|
|
2646
2022
|
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
2647
2023
|
}
|
|
2648
2024
|
declare const ZodIntersection: $constructor<ZodIntersection>;
|
|
2025
|
+
interface ZodRecord<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends _ZodType<$ZodRecordInternals<Key, Value>>, $ZodRecord<Key, Value> {
|
|
2026
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
2027
|
+
keyType: Key;
|
|
2028
|
+
valueType: Value;
|
|
2029
|
+
}
|
|
2030
|
+
declare const ZodRecord: $constructor<ZodRecord>;
|
|
2649
2031
|
interface ZodEnum< /** @ts-ignore Cast variance */out T extends EnumLike = EnumLike> extends _ZodType<$ZodEnumInternals<T>>, $ZodEnum<T> {
|
|
2650
2032
|
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
2651
2033
|
enum: T;
|
|
@@ -2654,6 +2036,13 @@ interface ZodEnum< /** @ts-ignore Cast variance */out T extends EnumLike = EnumL
|
|
|
2654
2036
|
exclude<const U extends readonly (keyof T)[]>(values: U, params?: string | $ZodEnumParams): ZodEnum<Flatten<Omit<T, U[number]>>>;
|
|
2655
2037
|
}
|
|
2656
2038
|
declare const ZodEnum: $constructor<ZodEnum>;
|
|
2039
|
+
interface ZodLiteral<T extends Literal = Literal> extends _ZodType<$ZodLiteralInternals<T>>, $ZodLiteral<T> {
|
|
2040
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
2041
|
+
values: Set<T>;
|
|
2042
|
+
/** @legacy Use `.values` instead. Accessing this property will throw an error if the literal accepts multiple values. */
|
|
2043
|
+
value: T;
|
|
2044
|
+
}
|
|
2045
|
+
declare const ZodLiteral: $constructor<ZodLiteral>;
|
|
2657
2046
|
interface ZodTransform<O = unknown, I = unknown> extends _ZodType<$ZodTransformInternals<O, I>>, $ZodTransform<O, I> {
|
|
2658
2047
|
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
2659
2048
|
}
|
|
@@ -2696,81 +2085,315 @@ interface ZodCatch<T extends SomeType = $ZodType> extends _ZodType<$ZodCatchInte
|
|
|
2696
2085
|
/** @deprecated Use `.unwrap()` instead. */
|
|
2697
2086
|
removeCatch(): T;
|
|
2698
2087
|
}
|
|
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;
|
|
2088
|
+
declare const ZodCatch: $constructor<ZodCatch>;
|
|
2089
|
+
interface ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends _ZodType<$ZodPipeInternals<A, B>>, $ZodPipe<A, B> {
|
|
2090
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
2091
|
+
in: A;
|
|
2092
|
+
out: B;
|
|
2093
|
+
}
|
|
2094
|
+
declare const ZodPipe: $constructor<ZodPipe>;
|
|
2095
|
+
interface ZodReadonly<T extends SomeType = $ZodType> extends _ZodType<$ZodReadonlyInternals<T>>, $ZodReadonly<T> {
|
|
2096
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
2097
|
+
unwrap(): T;
|
|
2098
|
+
}
|
|
2099
|
+
declare const ZodReadonly: $constructor<ZodReadonly>;
|
|
2100
|
+
//#endregion
|
|
2101
|
+
//#region node_modules/.pnpm/neverthrow@8.2.0/node_modules/neverthrow/dist/index.d.ts
|
|
2102
|
+
interface ErrorConfig {
|
|
2103
|
+
withStackTrace: boolean;
|
|
2104
|
+
}
|
|
2105
|
+
declare class ResultAsync<T, E> implements PromiseLike<Result$1<T, E>> {
|
|
2106
|
+
private _promise;
|
|
2107
|
+
constructor(res: Promise<Result$1<T, E>>);
|
|
2108
|
+
static fromSafePromise<T, E = never>(promise: PromiseLike<T>): ResultAsync<T, E>;
|
|
2109
|
+
static fromPromise<T, E>(promise: PromiseLike<T>, errorFn: (e: unknown) => E): ResultAsync<T, E>;
|
|
2110
|
+
static fromThrowable<A extends readonly any[], R, E>(fn: (...args: A) => Promise<R>, errorFn?: (err: unknown) => E): (...args: A) => ResultAsync<R, E>;
|
|
2111
|
+
static combine<T extends readonly [ResultAsync<unknown, unknown>, ...ResultAsync<unknown, unknown>[]]>(asyncResultList: T): CombineResultAsyncs<T>;
|
|
2112
|
+
static combine<T extends readonly ResultAsync<unknown, unknown>[]>(asyncResultList: T): CombineResultAsyncs<T>;
|
|
2113
|
+
static combineWithAllErrors<T extends readonly [ResultAsync<unknown, unknown>, ...ResultAsync<unknown, unknown>[]]>(asyncResultList: T): CombineResultsWithAllErrorsArrayAsync<T>;
|
|
2114
|
+
static combineWithAllErrors<T extends readonly ResultAsync<unknown, unknown>[]>(asyncResultList: T): CombineResultsWithAllErrorsArrayAsync<T>;
|
|
2115
|
+
map<A>(f: (t: T) => A | Promise<A>): ResultAsync<A, E>;
|
|
2116
|
+
andThrough<F>(f: (t: T) => Result$1<unknown, F> | ResultAsync<unknown, F>): ResultAsync<T, E | F>;
|
|
2117
|
+
andTee(f: (t: T) => unknown): ResultAsync<T, E>;
|
|
2118
|
+
orTee(f: (t: E) => unknown): ResultAsync<T, E>;
|
|
2119
|
+
mapErr<U>(f: (e: E) => U | Promise<U>): ResultAsync<T, U>;
|
|
2120
|
+
andThen<R extends Result$1<unknown, unknown>>(f: (t: T) => R): ResultAsync<InferOkTypes<R>, InferErrTypes<R> | E>;
|
|
2121
|
+
andThen<R extends ResultAsync<unknown, unknown>>(f: (t: T) => R): ResultAsync<InferAsyncOkTypes<R>, InferAsyncErrTypes<R> | E>;
|
|
2122
|
+
andThen<U, F>(f: (t: T) => Result$1<U, F> | ResultAsync<U, F>): ResultAsync<U, E | F>;
|
|
2123
|
+
orElse<R extends Result$1<unknown, unknown>>(f: (e: E) => R): ResultAsync<InferOkTypes<R> | T, InferErrTypes<R>>;
|
|
2124
|
+
orElse<R extends ResultAsync<unknown, unknown>>(f: (e: E) => R): ResultAsync<InferAsyncOkTypes<R> | T, InferAsyncErrTypes<R>>;
|
|
2125
|
+
orElse<U, A>(f: (e: E) => Result$1<U, A> | ResultAsync<U, A>): ResultAsync<U | T, A>;
|
|
2126
|
+
match<A, B = A>(ok: (t: T) => A, _err: (e: E) => B): Promise<A | B>;
|
|
2127
|
+
unwrapOr<A>(t: A): Promise<T | A>;
|
|
2128
|
+
/**
|
|
2129
|
+
* @deprecated will be removed in 9.0.0.
|
|
2130
|
+
*
|
|
2131
|
+
* You can use `safeTry` without this method.
|
|
2132
|
+
* @example
|
|
2133
|
+
* ```typescript
|
|
2134
|
+
* safeTry(async function* () {
|
|
2135
|
+
* const okValue = yield* yourResult
|
|
2136
|
+
* })
|
|
2137
|
+
* ```
|
|
2138
|
+
* Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
|
|
2139
|
+
*/
|
|
2140
|
+
safeUnwrap(): AsyncGenerator<Err<never, E>, T>;
|
|
2141
|
+
then<A, B>(successCallback?: (res: Result$1<T, E>) => A | PromiseLike<A>, failureCallback?: (reason: unknown) => B | PromiseLike<B>): PromiseLike<A | B>;
|
|
2142
|
+
[Symbol.asyncIterator](): AsyncGenerator<Err<never, E>, T>;
|
|
2143
|
+
}
|
|
2144
|
+
declare type CombineResultAsyncs<T extends readonly ResultAsync<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseAsync<UnwrapAsync<T>> : ResultAsync<ExtractOkAsyncTypes<T>, ExtractErrAsyncTypes<T>[number]>;
|
|
2145
|
+
declare type CombineResultsWithAllErrorsArrayAsync<T extends readonly ResultAsync<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseWithAllErrorsAsync<UnwrapAsync<T>> : ResultAsync<ExtractOkAsyncTypes<T>, ExtractErrAsyncTypes<T>[number][]>;
|
|
2146
|
+
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;
|
|
2147
|
+
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;
|
|
2148
|
+
declare type TraverseWithAllErrorsAsync<T, Depth extends number = 5> = TraverseAsync<T, Depth> extends ResultAsync<infer Oks, infer Errs> ? ResultAsync<Oks, Errs[]> : never;
|
|
2149
|
+
declare type Writable<T> = T extends ReadonlyArray<unknown> ? [...T] : T;
|
|
2150
|
+
declare type ExtractOkTypes<T extends readonly Result$1<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends Result$1<infer U, unknown> ? U : never };
|
|
2151
|
+
declare type ExtractOkAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends ResultAsync<infer U, unknown> ? U : never };
|
|
2152
|
+
declare type ExtractErrTypes<T extends readonly Result$1<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends Result$1<unknown, infer E> ? E : never };
|
|
2153
|
+
declare type ExtractErrAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends ResultAsync<unknown, infer E> ? E : never };
|
|
2154
|
+
declare type InferOkTypes<R> = R extends Result$1<infer T, unknown> ? T : never;
|
|
2155
|
+
declare type InferErrTypes<R> = R extends Result$1<unknown, infer E> ? E : never;
|
|
2156
|
+
declare type InferAsyncOkTypes<R> = R extends ResultAsync<infer T, unknown> ? T : never;
|
|
2157
|
+
declare type InferAsyncErrTypes<R> = R extends ResultAsync<unknown, infer E> ? E : never;
|
|
2158
|
+
declare namespace Result$1 {
|
|
2159
|
+
/**
|
|
2160
|
+
* Wraps a function with a try catch, creating a new function with the same
|
|
2161
|
+
* arguments but returning `Ok` if successful, `Err` if the function throws
|
|
2162
|
+
*
|
|
2163
|
+
* @param fn function to wrap with ok on success or err on failure
|
|
2164
|
+
* @param errorFn when an error is thrown, this will wrap the error result if provided
|
|
2165
|
+
*/
|
|
2166
|
+
function fromThrowable<Fn extends (...args: readonly any[]) => any, E>(fn: Fn, errorFn?: (e: unknown) => E): (...args: Parameters<Fn>) => Result$1<ReturnType<Fn>, E>;
|
|
2167
|
+
function combine<T extends readonly [Result$1<unknown, unknown>, ...Result$1<unknown, unknown>[]]>(resultList: T): CombineResults<T>;
|
|
2168
|
+
function combine<T extends readonly Result$1<unknown, unknown>[]>(resultList: T): CombineResults<T>;
|
|
2169
|
+
function combineWithAllErrors<T extends readonly [Result$1<unknown, unknown>, ...Result$1<unknown, unknown>[]]>(resultList: T): CombineResultsWithAllErrorsArray<T>;
|
|
2170
|
+
function combineWithAllErrors<T extends readonly Result$1<unknown, unknown>[]>(resultList: T): CombineResultsWithAllErrorsArray<T>;
|
|
2171
|
+
}
|
|
2172
|
+
declare type Result$1<T, E> = Ok<T, E> | Err<T, E>;
|
|
2173
|
+
interface IResult<T, E> {
|
|
2174
|
+
/**
|
|
2175
|
+
* Used to check if a `Result` is an `OK`
|
|
2176
|
+
*
|
|
2177
|
+
* @returns `true` if the result is an `OK` variant of Result
|
|
2178
|
+
*/
|
|
2179
|
+
isOk(): this is Ok<T, E>;
|
|
2180
|
+
/**
|
|
2181
|
+
* Used to check if a `Result` is an `Err`
|
|
2182
|
+
*
|
|
2183
|
+
* @returns `true` if the result is an `Err` variant of Result
|
|
2184
|
+
*/
|
|
2185
|
+
isErr(): this is Err<T, E>;
|
|
2186
|
+
/**
|
|
2187
|
+
* Maps a `Result<T, E>` to `Result<U, E>`
|
|
2188
|
+
* by applying a function to a contained `Ok` value, leaving an `Err` value
|
|
2189
|
+
* untouched.
|
|
2190
|
+
*
|
|
2191
|
+
* @param f The function to apply an `OK` value
|
|
2192
|
+
* @returns the result of applying `f` or an `Err` untouched
|
|
2193
|
+
*/
|
|
2194
|
+
map<A>(f: (t: T) => A): Result$1<A, E>;
|
|
2195
|
+
/**
|
|
2196
|
+
* Maps a `Result<T, E>` to `Result<T, F>` by applying a function to a
|
|
2197
|
+
* contained `Err` value, leaving an `Ok` value untouched.
|
|
2198
|
+
*
|
|
2199
|
+
* This function can be used to pass through a successful result while
|
|
2200
|
+
* handling an error.
|
|
2201
|
+
*
|
|
2202
|
+
* @param f a function to apply to the error `Err` value
|
|
2203
|
+
*/
|
|
2204
|
+
mapErr<U>(f: (e: E) => U): Result$1<T, U>;
|
|
2205
|
+
/**
|
|
2206
|
+
* Similar to `map` Except you must return a new `Result`.
|
|
2207
|
+
*
|
|
2208
|
+
* This is useful for when you need to do a subsequent computation using the
|
|
2209
|
+
* inner `T` value, but that computation might fail.
|
|
2210
|
+
* Additionally, `andThen` is really useful as a tool to flatten a
|
|
2211
|
+
* `Result<Result<A, E2>, E1>` into a `Result<A, E2>` (see example below).
|
|
2212
|
+
*
|
|
2213
|
+
* @param f The function to apply to the current value
|
|
2214
|
+
*/
|
|
2215
|
+
andThen<R extends Result$1<unknown, unknown>>(f: (t: T) => R): Result$1<InferOkTypes<R>, InferErrTypes<R> | E>;
|
|
2216
|
+
andThen<U, F>(f: (t: T) => Result$1<U, F>): Result$1<U, E | F>;
|
|
2217
|
+
/**
|
|
2218
|
+
* This "tee"s the current value to an passed-in computation such as side
|
|
2219
|
+
* effect functions but still returns the same current value as the result.
|
|
2220
|
+
*
|
|
2221
|
+
* This is useful when you want to pass the current result to your side-track
|
|
2222
|
+
* work such as logging but want to continue main-track work after that.
|
|
2223
|
+
* This method does not care about the result of the passed in computation.
|
|
2224
|
+
*
|
|
2225
|
+
* @param f The function to apply to the current value
|
|
2226
|
+
*/
|
|
2227
|
+
andTee(f: (t: T) => unknown): Result$1<T, E>;
|
|
2228
|
+
/**
|
|
2229
|
+
* This "tee"s the current `Err` value to an passed-in computation such as side
|
|
2230
|
+
* effect functions but still returns the same `Err` value as the result.
|
|
2231
|
+
*
|
|
2232
|
+
* This is useful when you want to pass the current `Err` value to your side-track
|
|
2233
|
+
* work such as logging but want to continue error-track work after that.
|
|
2234
|
+
* This method does not care about the result of the passed in computation.
|
|
2235
|
+
*
|
|
2236
|
+
* @param f The function to apply to the current `Err` value
|
|
2237
|
+
*/
|
|
2238
|
+
orTee(f: (t: E) => unknown): Result$1<T, E>;
|
|
2239
|
+
/**
|
|
2240
|
+
* Similar to `andTee` except error result of the computation will be passed
|
|
2241
|
+
* to the downstream in case of an error.
|
|
2242
|
+
*
|
|
2243
|
+
* This version is useful when you want to make side-effects but in case of an
|
|
2244
|
+
* error, you want to pass the error to the downstream.
|
|
2245
|
+
*
|
|
2246
|
+
* @param f The function to apply to the current value
|
|
2247
|
+
*/
|
|
2248
|
+
andThrough<R extends Result$1<unknown, unknown>>(f: (t: T) => R): Result$1<T, InferErrTypes<R> | E>;
|
|
2249
|
+
andThrough<F>(f: (t: T) => Result$1<unknown, F>): Result$1<T, E | F>;
|
|
2250
|
+
/**
|
|
2251
|
+
* Takes an `Err` value and maps it to a `Result<T, SomeNewType>`.
|
|
2252
|
+
*
|
|
2253
|
+
* This is useful for error recovery.
|
|
2254
|
+
*
|
|
2255
|
+
*
|
|
2256
|
+
* @param f A function to apply to an `Err` value, leaving `Ok` values
|
|
2257
|
+
* untouched.
|
|
2258
|
+
*/
|
|
2259
|
+
orElse<R extends Result$1<unknown, unknown>>(f: (e: E) => R): Result$1<InferOkTypes<R> | T, InferErrTypes<R>>;
|
|
2260
|
+
orElse<U, A>(f: (e: E) => Result$1<U, A>): Result$1<U | T, A>;
|
|
2261
|
+
/**
|
|
2262
|
+
* Similar to `map` Except you must return a new `Result`.
|
|
2263
|
+
*
|
|
2264
|
+
* This is useful for when you need to do a subsequent async computation using
|
|
2265
|
+
* the inner `T` value, but that computation might fail. Must return a ResultAsync
|
|
2266
|
+
*
|
|
2267
|
+
* @param f The function that returns a `ResultAsync` to apply to the current
|
|
2268
|
+
* value
|
|
2269
|
+
*/
|
|
2270
|
+
asyncAndThen<U, F>(f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
|
|
2271
|
+
/**
|
|
2272
|
+
* Maps a `Result<T, E>` to `ResultAsync<U, E>`
|
|
2273
|
+
* by applying an async function to a contained `Ok` value, leaving an `Err`
|
|
2274
|
+
* value untouched.
|
|
2275
|
+
*
|
|
2276
|
+
* @param f An async function to apply an `OK` value
|
|
2277
|
+
*/
|
|
2278
|
+
asyncMap<U>(f: (t: T) => Promise<U>): ResultAsync<U, E>;
|
|
2279
|
+
/**
|
|
2280
|
+
* Unwrap the `Ok` value, or return the default if there is an `Err`
|
|
2281
|
+
*
|
|
2282
|
+
* @param v the default value to return if there is an `Err`
|
|
2283
|
+
*/
|
|
2284
|
+
unwrapOr<A>(v: A): T | A;
|
|
2285
|
+
/**
|
|
2286
|
+
*
|
|
2287
|
+
* Given 2 functions (one for the `Ok` variant and one for the `Err` variant)
|
|
2288
|
+
* execute the function that matches the `Result` variant.
|
|
2289
|
+
*
|
|
2290
|
+
* Match callbacks do not necessitate to return a `Result`, however you can
|
|
2291
|
+
* return a `Result` if you want to.
|
|
2292
|
+
*
|
|
2293
|
+
* `match` is like chaining `map` and `mapErr`, with the distinction that
|
|
2294
|
+
* with `match` both functions must have the same return type.
|
|
2295
|
+
*
|
|
2296
|
+
* @param ok
|
|
2297
|
+
* @param err
|
|
2298
|
+
*/
|
|
2299
|
+
match<A, B = A>(ok: (t: T) => A, err: (e: E) => B): A | B;
|
|
2300
|
+
/**
|
|
2301
|
+
* @deprecated will be removed in 9.0.0.
|
|
2302
|
+
*
|
|
2303
|
+
* You can use `safeTry` without this method.
|
|
2304
|
+
* @example
|
|
2305
|
+
* ```typescript
|
|
2306
|
+
* safeTry(function* () {
|
|
2307
|
+
* const okValue = yield* yourResult
|
|
2308
|
+
* })
|
|
2309
|
+
* ```
|
|
2310
|
+
* Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
|
|
2311
|
+
*/
|
|
2312
|
+
safeUnwrap(): Generator<Err<never, E>, T>;
|
|
2313
|
+
/**
|
|
2314
|
+
* **This method is unsafe, and should only be used in a test environments**
|
|
2315
|
+
*
|
|
2316
|
+
* Takes a `Result<T, E>` and returns a `T` when the result is an `Ok`, otherwise it throws a custom object.
|
|
2317
|
+
*
|
|
2318
|
+
* @param config
|
|
2319
|
+
*/
|
|
2320
|
+
_unsafeUnwrap(config?: ErrorConfig): T;
|
|
2321
|
+
/**
|
|
2322
|
+
* **This method is unsafe, and should only be used in a test environments**
|
|
2323
|
+
*
|
|
2324
|
+
* takes a `Result<T, E>` and returns a `E` when the result is an `Err`,
|
|
2325
|
+
* otherwise it throws a custom object.
|
|
2326
|
+
*
|
|
2327
|
+
* @param config
|
|
2328
|
+
*/
|
|
2329
|
+
_unsafeUnwrapErr(config?: ErrorConfig): E;
|
|
2704
2330
|
}
|
|
2705
|
-
declare
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2331
|
+
declare class Ok<T, E> implements IResult<T, E> {
|
|
2332
|
+
readonly value: T;
|
|
2333
|
+
constructor(value: T);
|
|
2334
|
+
isOk(): this is Ok<T, E>;
|
|
2335
|
+
isErr(): this is Err<T, E>;
|
|
2336
|
+
map<A>(f: (t: T) => A): Result$1<A, E>;
|
|
2337
|
+
mapErr<U>(_f: (e: E) => U): Result$1<T, U>;
|
|
2338
|
+
andThen<R extends Result$1<unknown, unknown>>(f: (t: T) => R): Result$1<InferOkTypes<R>, InferErrTypes<R> | E>;
|
|
2339
|
+
andThen<U, F>(f: (t: T) => Result$1<U, F>): Result$1<U, E | F>;
|
|
2340
|
+
andThrough<R extends Result$1<unknown, unknown>>(f: (t: T) => R): Result$1<T, InferErrTypes<R> | E>;
|
|
2341
|
+
andThrough<F>(f: (t: T) => Result$1<unknown, F>): Result$1<T, E | F>;
|
|
2342
|
+
andTee(f: (t: T) => unknown): Result$1<T, E>;
|
|
2343
|
+
orTee(_f: (t: E) => unknown): Result$1<T, E>;
|
|
2344
|
+
orElse<R extends Result$1<unknown, unknown>>(_f: (e: E) => R): Result$1<InferOkTypes<R> | T, InferErrTypes<R>>;
|
|
2345
|
+
orElse<U, A>(_f: (e: E) => Result$1<U, A>): Result$1<U | T, A>;
|
|
2346
|
+
asyncAndThen<U, F>(f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
|
|
2347
|
+
asyncAndThrough<R extends ResultAsync<unknown, unknown>>(f: (t: T) => R): ResultAsync<T, InferAsyncErrTypes<R> | E>;
|
|
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(_?: ErrorConfig): T;
|
|
2354
|
+
_unsafeUnwrapErr(config?: ErrorConfig): E;
|
|
2355
|
+
[Symbol.iterator](): Generator<Err<never, E>, T>;
|
|
2709
2356
|
}
|
|
2710
|
-
declare
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
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>>;
|
|
2357
|
+
declare class Err<T, E> implements IResult<T, E> {
|
|
2358
|
+
readonly error: E;
|
|
2359
|
+
constructor(error: E);
|
|
2360
|
+
isOk(): this is Ok<T, E>;
|
|
2361
|
+
isErr(): this is Err<T, E>;
|
|
2362
|
+
map<A>(_f: (t: T) => A): Result$1<A, E>;
|
|
2363
|
+
mapErr<U>(f: (e: E) => U): Result$1<T, U>;
|
|
2364
|
+
andThrough<F>(_f: (t: T) => Result$1<unknown, F>): Result$1<T, E | F>;
|
|
2365
|
+
andTee(_f: (t: T) => unknown): Result$1<T, E>;
|
|
2366
|
+
orTee(f: (t: E) => unknown): Result$1<T, E>;
|
|
2367
|
+
andThen<R extends Result$1<unknown, unknown>>(_f: (t: T) => R): Result$1<InferOkTypes<R>, InferErrTypes<R> | E>;
|
|
2368
|
+
andThen<U, F>(_f: (t: T) => Result$1<U, F>): Result$1<U, E | F>;
|
|
2369
|
+
orElse<R extends Result$1<unknown, unknown>>(f: (e: E) => R): Result$1<InferOkTypes<R> | T, InferErrTypes<R>>;
|
|
2370
|
+
orElse<U, A>(f: (e: E) => Result$1<U, A>): Result$1<U | T, A>;
|
|
2371
|
+
asyncAndThen<U, F>(_f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
|
|
2372
|
+
asyncAndThrough<F>(_f: (t: T) => ResultAsync<unknown, F>): ResultAsync<T, E | F>;
|
|
2373
|
+
asyncMap<U>(_f: (t: T) => Promise<U>): ResultAsync<U, E>;
|
|
2374
|
+
unwrapOr<A>(v: A): T | A;
|
|
2375
|
+
match<A, B = A>(_ok: (t: T) => A, err: (e: E) => B): A | B;
|
|
2376
|
+
safeUnwrap(): Generator<Err<never, E>, T>;
|
|
2377
|
+
_unsafeUnwrap(config?: ErrorConfig): T;
|
|
2378
|
+
_unsafeUnwrapErr(_?: ErrorConfig): E;
|
|
2379
|
+
[Symbol.iterator](): Generator<Err<never, E>, T>;
|
|
2765
2380
|
}
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
declare
|
|
2381
|
+
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[]];
|
|
2382
|
+
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;
|
|
2383
|
+
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;
|
|
2384
|
+
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;
|
|
2385
|
+
declare type Dedup<T> = T extends Result$1<infer RL, infer RR> ? [unknown] extends [RL] ? Err<RL, RR> : Ok<RL, RR> : T;
|
|
2386
|
+
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] : [];
|
|
2387
|
+
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;
|
|
2388
|
+
declare type UnknownMembersToNever<T> = T extends [infer H, ...infer R] ? [[unknown] extends [H] ? never : H, ...UnknownMembersToNever<R>] : T;
|
|
2389
|
+
declare type MembersToUnion<T> = T extends unknown[] ? T[number] : never;
|
|
2390
|
+
declare type IsLiteralArray<T> = T extends {
|
|
2391
|
+
length: infer L;
|
|
2392
|
+
} ? L extends number ? number extends L ? 0 : 1 : 0 : 0;
|
|
2393
|
+
declare type Traverse<T, Depth extends number = 5> = Combine<T, Depth> extends [infer Oks, infer Errs] ? Result$1<EmptyArrayToNever<Oks, 1>, MembersToUnion<Errs>> : never;
|
|
2394
|
+
declare type TraverseWithAllErrors<T, Depth extends number = 5> = Traverse<T, Depth> extends Result$1<infer Oks, infer Errs> ? Result$1<Oks, Errs[]> : never;
|
|
2395
|
+
declare type CombineResults<T extends readonly Result$1<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? Traverse<T> : Result$1<ExtractOkTypes<T>, ExtractErrTypes<T>[number]>;
|
|
2396
|
+
declare type CombineResultsWithAllErrorsArray<T extends readonly Result$1<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseWithAllErrors<T> : Result$1<ExtractOkTypes<T>, ExtractErrTypes<T>[number][]>;
|
|
2774
2397
|
//#endregion
|
|
2775
|
-
export {
|
|
2776
|
-
//# sourceMappingURL=index-
|
|
2398
|
+
export { $strip as C, $loose as S, ZodType as _, ZodDefault as a, ZodUnknown as b, ZodLiteral as c, ZodObject as d, ZodOptional as f, ZodTransform as g, ZodString as h, ZodCatch as i, ZodNullable as l, ZodRecord as m, ZodArray as n, ZodDiscriminatedUnion as o, ZodPipe as p, ZodBoolean as r, ZodEnum as s, Result$1 as t, ZodNumber as u, ZodURL as v, output as x, ZodUnion as y };
|
|
2399
|
+
//# sourceMappingURL=index-cf3ZMnLJ.d.ts.map
|