autumn-js 1.2.12 → 1.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend/adapters/express.js +91 -4
- package/dist/backend/adapters/express.mjs +6 -6
- package/dist/backend/adapters/fetch.js +91 -4
- package/dist/backend/adapters/fetch.mjs +6 -6
- package/dist/backend/adapters/hono.js +91 -4
- package/dist/backend/adapters/hono.mjs +6 -6
- package/dist/backend/adapters/index.js +91 -4
- package/dist/backend/adapters/index.mjs +9 -9
- package/dist/backend/adapters/next.js +91 -4
- package/dist/backend/adapters/next.mjs +6 -6
- package/dist/backend/{chunk-JQX5WYYY.mjs → chunk-7BVATYGA.mjs} +1 -1
- package/dist/backend/{chunk-7Q77N2K2.mjs → chunk-DNNJOZAT.mjs} +1 -1
- package/dist/backend/{chunk-N53PKNZ6.mjs → chunk-EJGHP7KT.mjs} +2 -2
- package/dist/backend/{chunk-X4LPDDOP.mjs → chunk-MANTLPDT.mjs} +4 -0
- package/dist/backend/{chunk-4Q54RXI2.mjs → chunk-OUDB34Y7.mjs} +1 -1
- package/dist/backend/{chunk-SE5CK5NY.mjs → chunk-RPH5L44S.mjs} +1 -1
- package/dist/backend/{chunk-UEYDU64U.mjs → chunk-T42RZEUZ.mjs} +87 -4
- package/dist/backend/{chunk-ITXMMCSD.mjs → chunk-YSQQKZBU.mjs} +2 -2
- package/dist/backend/core/handlers/coreHandler.d.mts +1 -1
- package/dist/backend/core/handlers/coreHandler.d.ts +1 -1
- package/dist/backend/core/handlers/coreHandler.js +91 -4
- package/dist/backend/core/handlers/coreHandler.mjs +4 -4
- package/dist/backend/core/handlers/executeRoute.d.mts +1 -1
- package/dist/backend/core/handlers/executeRoute.d.ts +1 -1
- package/dist/backend/core/handlers/executeRoute.mjs +1 -1
- package/dist/backend/core/handlers/handleRouteByName.js +91 -4
- package/dist/backend/core/handlers/handleRouteByName.mjs +4 -4
- package/dist/backend/core/handlers/index.d.mts +1 -1
- package/dist/backend/core/handlers/index.d.ts +1 -1
- package/dist/backend/core/handlers/index.js +91 -4
- package/dist/backend/core/handlers/index.mjs +5 -5
- package/dist/backend/core/index.d.mts +1 -1
- package/dist/backend/core/index.d.ts +1 -1
- package/dist/backend/core/index.js +91 -4
- package/dist/backend/core/index.mjs +7 -7
- package/dist/backend/core/routes/index.d.mts +1 -1
- package/dist/backend/core/routes/index.d.ts +1 -1
- package/dist/backend/core/routes/index.js +4 -0
- package/dist/backend/core/routes/index.mjs +2 -2
- package/dist/backend/core/routes/routeBuilder.d.mts +1 -1
- package/dist/backend/core/routes/routeBuilder.d.ts +1 -1
- package/dist/backend/core/routes/routeConfigs.d.mts +1 -1
- package/dist/backend/core/routes/routeConfigs.d.ts +1 -1
- package/dist/backend/core/routes/routeConfigs.js +4 -0
- package/dist/backend/core/routes/routeConfigs.mjs +2 -2
- package/dist/backend/core/types/handlerTypes.d.mts +1 -1
- package/dist/backend/core/types/handlerTypes.d.ts +1 -1
- package/dist/backend/core/types/index.d.mts +1 -1
- package/dist/backend/core/types/index.d.ts +1 -1
- package/dist/backend/core/types/routeTypes.d.mts +1 -1
- package/dist/backend/core/types/routeTypes.d.ts +1 -1
- package/dist/backend/core/utils/index.mjs +3 -3
- package/dist/backend/index.d.mts +2 -2
- package/dist/backend/index.d.ts +2 -2
- package/dist/backend/index.js +91 -4
- package/dist/backend/index.mjs +7 -7
- package/dist/backend/{routeTypes-D0ag5-Tb.d.ts → routeTypes-B94_Mq2J.d.ts} +93 -0
- package/dist/backend/{routeTypes-Cu-XQy7A.d.mts → routeTypes-DVwngaBn.d.mts} +93 -0
- package/dist/better-auth/{chunk-TEP6CVHR.mjs → chunk-4OWECHZC.mjs} +1 -1
- package/dist/better-auth/{chunk-GKUK5UGW.mjs → chunk-JIFD4TSN.mjs} +4 -0
- package/dist/better-auth/{chunk-XFATOIZD.mjs → chunk-ZZGFPTHO.mjs} +88 -5
- package/dist/better-auth/client.d.mts +3 -7
- package/dist/better-auth/client.d.ts +3 -7
- package/dist/better-auth/createAutumnEndpoint-CvXRCg-M.d.mts +43 -0
- package/dist/better-auth/createAutumnEndpoint-CvXRCg-M.d.ts +43 -0
- package/dist/better-auth/index.d.mts +3 -7
- package/dist/better-auth/index.d.ts +3 -7
- package/dist/better-auth/index.js +91 -4
- package/dist/better-auth/index.mjs +3 -3
- package/dist/better-auth/utils/createAutumnEndpoint.d.mts +3 -7
- package/dist/better-auth/utils/createAutumnEndpoint.d.ts +3 -7
- package/dist/better-auth/utils/createAutumnEndpoint.js +4 -0
- package/dist/better-auth/utils/createAutumnEndpoint.mjs +2 -2
- package/dist/better-auth/utils/handleBetterAuthRoute.d.mts +3 -7
- package/dist/better-auth/utils/handleBetterAuthRoute.d.ts +3 -7
- package/dist/better-auth/utils/handleBetterAuthRoute.js +91 -4
- package/dist/better-auth/utils/handleBetterAuthRoute.mjs +2 -2
- package/dist/better-auth/utils/index.d.mts +3 -8
- package/dist/better-auth/utils/index.d.ts +3 -8
- package/dist/better-auth/utils/index.js +91 -4
- package/dist/better-auth/utils/index.mjs +3 -3
- package/dist/react/AutumnContext.d.mts +3 -3
- package/dist/react/AutumnContext.d.ts +3 -3
- package/dist/react/AutumnProvider.js +15 -15
- package/dist/react/AutumnProvider.mjs +2 -2
- package/dist/react/{chunk-26CKSAPZ.mjs → chunk-7IDH4OMG.mjs} +1 -1
- package/dist/react/{chunk-HSQUB3BZ.mjs → chunk-BDG6JHEW.mjs} +1 -1
- package/dist/react/{chunk-KB72KQKN.mjs → chunk-DEZBJQEG.mjs} +1 -1
- package/dist/react/{chunk-XJZH5NMZ.mjs → chunk-E5ZHOMZ4.mjs} +23 -23
- package/dist/react/{chunk-OXQG65ZT.mjs → chunk-FWWIAOPU.mjs} +1 -1
- package/dist/react/{chunk-ZGPE4R6H.mjs → chunk-HVBDZARN.mjs} +2 -2
- package/dist/react/{chunk-MC2YYATT.mjs → chunk-J6SLKTKE.mjs} +1 -1
- package/dist/react/{chunk-CHU7CIWP.mjs → chunk-NSFHAUTD.mjs} +1 -1
- package/dist/react/{chunk-G7FTQLT7.mjs → chunk-YQFYWH7J.mjs} +1 -1
- package/dist/react/client/AutumnClient.d.mts +3 -3
- package/dist/react/client/AutumnClient.d.ts +3 -3
- package/dist/react/client/IAutumnClient.d.mts +16 -3
- package/dist/react/client/IAutumnClient.d.ts +16 -3
- package/dist/react/client/index.d.mts +3 -3
- package/dist/react/client/index.d.ts +3 -3
- package/dist/react/{customer-CbcVyRCQ.d.ts → customer-CaGJEN5J.d.ts} +1 -1
- package/dist/react/{customer-BYYt9N1h.d.mts → customer-DB8vL_m7.d.mts} +1 -1
- package/dist/react/hooks/index.d.mts +3 -3
- package/dist/react/hooks/index.d.ts +3 -3
- package/dist/react/hooks/index.js +16 -16
- package/dist/react/hooks/index.mjs +8 -8
- package/dist/react/hooks/internal/check/balanceToAllowed.d.mts +2 -2
- package/dist/react/hooks/internal/check/balanceToAllowed.d.ts +2 -2
- package/dist/react/hooks/internal/check/customerToFeatures.d.mts +2 -2
- package/dist/react/hooks/internal/check/customerToFeatures.d.ts +2 -2
- package/dist/react/hooks/internal/check/findCreditSystemsByFeature.d.mts +2 -2
- package/dist/react/hooks/internal/check/findCreditSystemsByFeature.d.ts +2 -2
- package/dist/react/hooks/internal/check/getCreditCost.d.mts +2 -2
- package/dist/react/hooks/internal/check/getCreditCost.d.ts +2 -2
- package/dist/react/hooks/internal/getLocalCheckResponse.d.mts +3 -3
- package/dist/react/hooks/internal/getLocalCheckResponse.d.ts +3 -3
- package/dist/react/hooks/internal/useCustomerActions.d.mts +3 -3
- package/dist/react/hooks/internal/useCustomerActions.d.ts +3 -3
- package/dist/react/hooks/internal/useCustomerActions.js +1 -1
- package/dist/react/hooks/internal/useCustomerActions.mjs +2 -2
- package/dist/react/hooks/useAggregateEvents.d.mts +2 -2
- package/dist/react/hooks/useAggregateEvents.d.ts +2 -2
- package/dist/react/hooks/useAggregateEvents.js +16 -16
- package/dist/react/hooks/useAggregateEvents.mjs +2 -2
- package/dist/react/hooks/useCustomer.d.mts +3 -3
- package/dist/react/hooks/useCustomer.d.ts +3 -3
- package/dist/react/hooks/useCustomer.js +16 -16
- package/dist/react/hooks/useCustomer.mjs +3 -3
- package/dist/react/hooks/useEntity.d.mts +2 -2
- package/dist/react/hooks/useEntity.d.ts +2 -2
- package/dist/react/hooks/useEntity.js +16 -16
- package/dist/react/hooks/useEntity.mjs +2 -2
- package/dist/react/hooks/useListEvents.d.mts +2 -2
- package/dist/react/hooks/useListEvents.d.ts +2 -2
- package/dist/react/hooks/useListEvents.js +16 -16
- package/dist/react/hooks/useListEvents.mjs +2 -2
- package/dist/react/hooks/useListPlans.d.mts +2 -2
- package/dist/react/hooks/useListPlans.d.ts +2 -2
- package/dist/react/hooks/useListPlans.js +16 -16
- package/dist/react/hooks/useListPlans.mjs +2 -2
- package/dist/react/hooks/useReferrals.d.mts +2 -2
- package/dist/react/hooks/useReferrals.d.ts +2 -2
- package/dist/react/hooks/useReferrals.js +16 -16
- package/dist/react/hooks/useReferrals.mjs +2 -2
- package/dist/react/index.d.mts +3 -3
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +22 -22
- package/dist/react/index.mjs +9 -9
- package/dist/react/{params-By0MIRsJ.d.ts → params-B5l9vHfZ.d.ts} +1 -1
- package/dist/react/{params-CUb0ZlUG.d.mts → params-BVglT8vT.d.mts} +1 -1
- package/dist/react/{plan-CqxFGNk2.d.mts → plan-DSTBzzTY.d.mts} +13 -0
- package/dist/react/{plan-CqxFGNk2.d.ts → plan-DSTBzzTY.d.ts} +13 -0
- package/dist/sdk/index.d.mts +125 -1
- package/dist/sdk/index.d.ts +125 -1
- package/dist/sdk/index.js +146 -4
- package/dist/sdk/index.mjs +133 -5
- package/package.json +1 -1
- package/dist/better-auth/createAutumnEndpoint-D9Plymvy.d.mts +0 -309
- package/dist/better-auth/createAutumnEndpoint-D9Plymvy.d.ts +0 -309
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
import { StandardSchemaV1 } from './standard-schema.mjs';
|
|
2
|
-
import { APIError } from './error.mjs';
|
|
3
|
-
import { InputContext } from './context.mjs';
|
|
4
|
-
import { Middleware } from './middleware.mjs';
|
|
5
|
-
import { OpenAPIParameter, OpenAPISchemaType } from './openapi.mjs';
|
|
6
|
-
import * as zod from 'zod';
|
|
7
|
-
import * as z from 'zod/v4/core';
|
|
8
|
-
|
|
9
|
-
/** All supported route names as const for type safety */
|
|
10
|
-
declare const ROUTE_NAMES: {
|
|
11
|
-
readonly getOrCreateCustomer: "getOrCreateCustomer";
|
|
12
|
-
readonly getEntity: "getEntity";
|
|
13
|
-
readonly attach: "attach";
|
|
14
|
-
readonly previewAttach: "previewAttach";
|
|
15
|
-
readonly updateSubscription: "updateSubscription";
|
|
16
|
-
readonly previewUpdateSubscription: "previewUpdateSubscription";
|
|
17
|
-
readonly openCustomerPortal: "openCustomerPortal";
|
|
18
|
-
readonly createReferralCode: "createReferralCode";
|
|
19
|
-
readonly redeemReferralCode: "redeemReferralCode";
|
|
20
|
-
readonly listPlans: "listPlans";
|
|
21
|
-
readonly listEvents: "listEvents";
|
|
22
|
-
readonly aggregateEvents: "aggregateEvents";
|
|
23
|
-
readonly multiAttach: "multiAttach";
|
|
24
|
-
readonly previewMultiAttach: "previewMultiAttach";
|
|
25
|
-
readonly setupPayment: "setupPayment";
|
|
26
|
-
};
|
|
27
|
-
/** Union of all route names */
|
|
28
|
-
type RouteName = keyof typeof ROUTE_NAMES;
|
|
29
|
-
|
|
30
|
-
//#region src/endpoint.d.ts
|
|
31
|
-
interface EndpointBaseOptions {
|
|
32
|
-
/**
|
|
33
|
-
* Query Schema
|
|
34
|
-
*/
|
|
35
|
-
query?: StandardSchemaV1;
|
|
36
|
-
/**
|
|
37
|
-
* Error Schema
|
|
38
|
-
*/
|
|
39
|
-
error?: StandardSchemaV1;
|
|
40
|
-
/**
|
|
41
|
-
* If true headers will be required to be passed in the context
|
|
42
|
-
*/
|
|
43
|
-
requireHeaders?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* If true request object will be required
|
|
46
|
-
*/
|
|
47
|
-
requireRequest?: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Clone the request object from the router
|
|
50
|
-
*/
|
|
51
|
-
cloneRequest?: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* If true the body will be undefined
|
|
54
|
-
*/
|
|
55
|
-
disableBody?: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Endpoint metadata
|
|
58
|
-
*/
|
|
59
|
-
metadata?: {
|
|
60
|
-
/**
|
|
61
|
-
* Open API definition
|
|
62
|
-
*/
|
|
63
|
-
openapi?: {
|
|
64
|
-
summary?: string;
|
|
65
|
-
description?: string;
|
|
66
|
-
tags?: string[];
|
|
67
|
-
operationId?: string;
|
|
68
|
-
parameters?: OpenAPIParameter[];
|
|
69
|
-
requestBody?: {
|
|
70
|
-
content: {
|
|
71
|
-
"application/json": {
|
|
72
|
-
schema: {
|
|
73
|
-
type?: OpenAPISchemaType;
|
|
74
|
-
properties?: Record<string, any>;
|
|
75
|
-
required?: string[];
|
|
76
|
-
$ref?: string;
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
responses?: {
|
|
82
|
-
[status: string]: {
|
|
83
|
-
description: string;
|
|
84
|
-
content?: {
|
|
85
|
-
"application/json"?: {
|
|
86
|
-
schema: {
|
|
87
|
-
type?: OpenAPISchemaType;
|
|
88
|
-
properties?: Record<string, any>;
|
|
89
|
-
required?: string[];
|
|
90
|
-
$ref?: string;
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
"text/plain"?: {
|
|
94
|
-
schema?: {
|
|
95
|
-
type?: OpenAPISchemaType;
|
|
96
|
-
properties?: Record<string, any>;
|
|
97
|
-
required?: string[];
|
|
98
|
-
$ref?: string;
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
"text/html"?: {
|
|
102
|
-
schema?: {
|
|
103
|
-
type?: OpenAPISchemaType;
|
|
104
|
-
properties?: Record<string, any>;
|
|
105
|
-
required?: string[];
|
|
106
|
-
$ref?: string;
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
/**
|
|
114
|
-
* Infer body and query type from ts interface
|
|
115
|
-
*
|
|
116
|
-
* useful for generic and dynamic types
|
|
117
|
-
*
|
|
118
|
-
* @example
|
|
119
|
-
* ```ts
|
|
120
|
-
* const endpoint = createEndpoint("/path", {
|
|
121
|
-
* method: "POST",
|
|
122
|
-
* body: z.record(z.string()),
|
|
123
|
-
* $Infer: {
|
|
124
|
-
* body: {} as {
|
|
125
|
-
* type: InferTypeFromOptions<Option> // custom type inference
|
|
126
|
-
* }
|
|
127
|
-
* }
|
|
128
|
-
* }, async(ctx)=>{
|
|
129
|
-
* const body = ctx.body
|
|
130
|
-
* })
|
|
131
|
-
* ```
|
|
132
|
-
*/
|
|
133
|
-
$Infer?: {
|
|
134
|
-
/**
|
|
135
|
-
* Body
|
|
136
|
-
*/
|
|
137
|
-
body?: any;
|
|
138
|
-
/**
|
|
139
|
-
* Query
|
|
140
|
-
*/
|
|
141
|
-
query?: Record<string, any>;
|
|
142
|
-
};
|
|
143
|
-
/**
|
|
144
|
-
* If enabled, endpoint won't be exposed over a router
|
|
145
|
-
* @deprecated Use path-less endpoints instead
|
|
146
|
-
*/
|
|
147
|
-
SERVER_ONLY?: boolean;
|
|
148
|
-
/**
|
|
149
|
-
* If enabled, endpoint won't be exposed as an action to the client
|
|
150
|
-
* @deprecated Use path-less endpoints instead
|
|
151
|
-
*/
|
|
152
|
-
isAction?: boolean;
|
|
153
|
-
/**
|
|
154
|
-
* Defines the places where the endpoint will be available
|
|
155
|
-
*
|
|
156
|
-
* Possible options:
|
|
157
|
-
* - `rpc` - the endpoint is exposed to the router, can be invoked directly and is available to the client
|
|
158
|
-
* - `server` - the endpoint is exposed to the router, can be invoked directly, but is not available to the client
|
|
159
|
-
* - `http` - the endpoint is only exposed to the router
|
|
160
|
-
* @default "rpc"
|
|
161
|
-
*/
|
|
162
|
-
scope?: "rpc" | "server" | "http";
|
|
163
|
-
/**
|
|
164
|
-
* List of allowed media types (MIME types) for the endpoint
|
|
165
|
-
*
|
|
166
|
-
* if provided, only the media types in the list will be allowed to be passed in the body
|
|
167
|
-
*
|
|
168
|
-
* @example
|
|
169
|
-
* ```ts
|
|
170
|
-
* const endpoint = createEndpoint("/path", {
|
|
171
|
-
* method: "POST",
|
|
172
|
-
* allowedMediaTypes: ["application/json", "application/x-www-form-urlencoded"],
|
|
173
|
-
* }, async(ctx)=>{
|
|
174
|
-
* const body = ctx.body
|
|
175
|
-
* })
|
|
176
|
-
* ```
|
|
177
|
-
*/
|
|
178
|
-
allowedMediaTypes?: string[];
|
|
179
|
-
/**
|
|
180
|
-
* Extra metadata
|
|
181
|
-
*/
|
|
182
|
-
[key: string]: any;
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* List of middlewares to use
|
|
186
|
-
*/
|
|
187
|
-
use?: Middleware[];
|
|
188
|
-
/**
|
|
189
|
-
* A callback to run before any API error is throw or returned
|
|
190
|
-
*
|
|
191
|
-
* @param e - The API error
|
|
192
|
-
* @returns - The response to return
|
|
193
|
-
*/
|
|
194
|
-
onAPIError?: (e: APIError) => void | Promise<void>;
|
|
195
|
-
/**
|
|
196
|
-
* A callback to run before a validation error is thrown
|
|
197
|
-
* You can customize the validation error message by throwing your own APIError
|
|
198
|
-
*/
|
|
199
|
-
onValidationError?: ({
|
|
200
|
-
issues,
|
|
201
|
-
message
|
|
202
|
-
}: {
|
|
203
|
-
message: string;
|
|
204
|
-
issues: readonly StandardSchemaV1.Issue[];
|
|
205
|
-
}) => void | Promise<void>;
|
|
206
|
-
}
|
|
207
|
-
type EndpointBodyMethodOptions = {
|
|
208
|
-
/**
|
|
209
|
-
* Request Method
|
|
210
|
-
*/
|
|
211
|
-
method: "POST" | "PUT" | "DELETE" | "PATCH" | ("POST" | "PUT" | "DELETE" | "PATCH")[];
|
|
212
|
-
/**
|
|
213
|
-
* Body Schema
|
|
214
|
-
*/
|
|
215
|
-
body?: StandardSchemaV1;
|
|
216
|
-
} | {
|
|
217
|
-
/**
|
|
218
|
-
* Request Method
|
|
219
|
-
*/
|
|
220
|
-
method: "GET" | "HEAD" | ("GET" | "HEAD")[];
|
|
221
|
-
/**
|
|
222
|
-
* Body Schema
|
|
223
|
-
*/
|
|
224
|
-
body?: never;
|
|
225
|
-
} | {
|
|
226
|
-
/**
|
|
227
|
-
* Request Method
|
|
228
|
-
*/
|
|
229
|
-
method: "*";
|
|
230
|
-
/**
|
|
231
|
-
* Body Schema
|
|
232
|
-
*/
|
|
233
|
-
body?: StandardSchemaV1;
|
|
234
|
-
} | {
|
|
235
|
-
/**
|
|
236
|
-
* Request Method
|
|
237
|
-
*/
|
|
238
|
-
method: ("POST" | "PUT" | "DELETE" | "PATCH" | "GET" | "HEAD")[];
|
|
239
|
-
/**
|
|
240
|
-
* Body Schema
|
|
241
|
-
*/
|
|
242
|
-
body?: StandardSchemaV1;
|
|
243
|
-
};
|
|
244
|
-
type EndpointOptions = EndpointBaseOptions & EndpointBodyMethodOptions;
|
|
245
|
-
type StrictEndpoint<Path extends string, Options extends EndpointOptions, R = any> = {
|
|
246
|
-
(context: InputContext<Path, Options> & {
|
|
247
|
-
asResponse: true;
|
|
248
|
-
}): Promise<Response>;
|
|
249
|
-
(context: InputContext<Path, Options> & {
|
|
250
|
-
returnHeaders: true;
|
|
251
|
-
returnStatus: true;
|
|
252
|
-
}): Promise<{
|
|
253
|
-
headers: Headers;
|
|
254
|
-
status: number;
|
|
255
|
-
response: Awaited<R>;
|
|
256
|
-
}>;
|
|
257
|
-
(context: InputContext<Path, Options> & {
|
|
258
|
-
returnHeaders: true;
|
|
259
|
-
returnStatus: false;
|
|
260
|
-
}): Promise<{
|
|
261
|
-
headers: Headers;
|
|
262
|
-
response: Awaited<R>;
|
|
263
|
-
}>;
|
|
264
|
-
(context: InputContext<Path, Options> & {
|
|
265
|
-
returnHeaders: false;
|
|
266
|
-
returnStatus: true;
|
|
267
|
-
}): Promise<{
|
|
268
|
-
status: number;
|
|
269
|
-
response: Awaited<R>;
|
|
270
|
-
}>;
|
|
271
|
-
(context: InputContext<Path, Options> & {
|
|
272
|
-
returnHeaders: false;
|
|
273
|
-
returnStatus: false;
|
|
274
|
-
}): Promise<R>;
|
|
275
|
-
(context: InputContext<Path, Options> & {
|
|
276
|
-
returnHeaders: true;
|
|
277
|
-
}): Promise<{
|
|
278
|
-
headers: Headers;
|
|
279
|
-
response: Awaited<R>;
|
|
280
|
-
}>;
|
|
281
|
-
(context: InputContext<Path, Options> & {
|
|
282
|
-
returnStatus: true;
|
|
283
|
-
}): Promise<{
|
|
284
|
-
status: number;
|
|
285
|
-
response: Awaited<R>;
|
|
286
|
-
}>;
|
|
287
|
-
(context?: InputContext<Path, Options>): Promise<R>;
|
|
288
|
-
options: Options;
|
|
289
|
-
path: Path;
|
|
290
|
-
};//# sourceMappingURL=endpoint.d.mts.map
|
|
291
|
-
|
|
292
|
-
/** Type for the handleRoute function used by better-auth endpoints */
|
|
293
|
-
type HandleBetterAuthRouteFn = (args: {
|
|
294
|
-
ctx: unknown;
|
|
295
|
-
routeName: RouteName;
|
|
296
|
-
}) => Promise<{
|
|
297
|
-
status: number;
|
|
298
|
-
body: unknown;
|
|
299
|
-
}>;
|
|
300
|
-
/**
|
|
301
|
-
* Creates a better-auth endpoint for a given route name.
|
|
302
|
-
* Each route needs its own call to preserve TypeScript literal types for the path.
|
|
303
|
-
*/
|
|
304
|
-
declare const createAutumnEndpoint: <T extends RouteName>(routeName: T, handleRoute: HandleBetterAuthRouteFn) => StrictEndpoint<`/autumn/${T}`, {
|
|
305
|
-
method: "POST";
|
|
306
|
-
body: zod.ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>> | undefined;
|
|
307
|
-
}, Record<string, unknown> | null>;
|
|
308
|
-
|
|
309
|
-
export { type HandleBetterAuthRouteFn as H, type RouteName as R, createAutumnEndpoint as c };
|
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
import { StandardSchemaV1 } from './standard-schema.mjs';
|
|
2
|
-
import { APIError } from './error.mjs';
|
|
3
|
-
import { InputContext } from './context.mjs';
|
|
4
|
-
import { Middleware } from './middleware.mjs';
|
|
5
|
-
import { OpenAPIParameter, OpenAPISchemaType } from './openapi.mjs';
|
|
6
|
-
import * as zod from 'zod';
|
|
7
|
-
import * as z from 'zod/v4/core';
|
|
8
|
-
|
|
9
|
-
/** All supported route names as const for type safety */
|
|
10
|
-
declare const ROUTE_NAMES: {
|
|
11
|
-
readonly getOrCreateCustomer: "getOrCreateCustomer";
|
|
12
|
-
readonly getEntity: "getEntity";
|
|
13
|
-
readonly attach: "attach";
|
|
14
|
-
readonly previewAttach: "previewAttach";
|
|
15
|
-
readonly updateSubscription: "updateSubscription";
|
|
16
|
-
readonly previewUpdateSubscription: "previewUpdateSubscription";
|
|
17
|
-
readonly openCustomerPortal: "openCustomerPortal";
|
|
18
|
-
readonly createReferralCode: "createReferralCode";
|
|
19
|
-
readonly redeemReferralCode: "redeemReferralCode";
|
|
20
|
-
readonly listPlans: "listPlans";
|
|
21
|
-
readonly listEvents: "listEvents";
|
|
22
|
-
readonly aggregateEvents: "aggregateEvents";
|
|
23
|
-
readonly multiAttach: "multiAttach";
|
|
24
|
-
readonly previewMultiAttach: "previewMultiAttach";
|
|
25
|
-
readonly setupPayment: "setupPayment";
|
|
26
|
-
};
|
|
27
|
-
/** Union of all route names */
|
|
28
|
-
type RouteName = keyof typeof ROUTE_NAMES;
|
|
29
|
-
|
|
30
|
-
//#region src/endpoint.d.ts
|
|
31
|
-
interface EndpointBaseOptions {
|
|
32
|
-
/**
|
|
33
|
-
* Query Schema
|
|
34
|
-
*/
|
|
35
|
-
query?: StandardSchemaV1;
|
|
36
|
-
/**
|
|
37
|
-
* Error Schema
|
|
38
|
-
*/
|
|
39
|
-
error?: StandardSchemaV1;
|
|
40
|
-
/**
|
|
41
|
-
* If true headers will be required to be passed in the context
|
|
42
|
-
*/
|
|
43
|
-
requireHeaders?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* If true request object will be required
|
|
46
|
-
*/
|
|
47
|
-
requireRequest?: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Clone the request object from the router
|
|
50
|
-
*/
|
|
51
|
-
cloneRequest?: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* If true the body will be undefined
|
|
54
|
-
*/
|
|
55
|
-
disableBody?: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Endpoint metadata
|
|
58
|
-
*/
|
|
59
|
-
metadata?: {
|
|
60
|
-
/**
|
|
61
|
-
* Open API definition
|
|
62
|
-
*/
|
|
63
|
-
openapi?: {
|
|
64
|
-
summary?: string;
|
|
65
|
-
description?: string;
|
|
66
|
-
tags?: string[];
|
|
67
|
-
operationId?: string;
|
|
68
|
-
parameters?: OpenAPIParameter[];
|
|
69
|
-
requestBody?: {
|
|
70
|
-
content: {
|
|
71
|
-
"application/json": {
|
|
72
|
-
schema: {
|
|
73
|
-
type?: OpenAPISchemaType;
|
|
74
|
-
properties?: Record<string, any>;
|
|
75
|
-
required?: string[];
|
|
76
|
-
$ref?: string;
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
responses?: {
|
|
82
|
-
[status: string]: {
|
|
83
|
-
description: string;
|
|
84
|
-
content?: {
|
|
85
|
-
"application/json"?: {
|
|
86
|
-
schema: {
|
|
87
|
-
type?: OpenAPISchemaType;
|
|
88
|
-
properties?: Record<string, any>;
|
|
89
|
-
required?: string[];
|
|
90
|
-
$ref?: string;
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
"text/plain"?: {
|
|
94
|
-
schema?: {
|
|
95
|
-
type?: OpenAPISchemaType;
|
|
96
|
-
properties?: Record<string, any>;
|
|
97
|
-
required?: string[];
|
|
98
|
-
$ref?: string;
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
"text/html"?: {
|
|
102
|
-
schema?: {
|
|
103
|
-
type?: OpenAPISchemaType;
|
|
104
|
-
properties?: Record<string, any>;
|
|
105
|
-
required?: string[];
|
|
106
|
-
$ref?: string;
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
/**
|
|
114
|
-
* Infer body and query type from ts interface
|
|
115
|
-
*
|
|
116
|
-
* useful for generic and dynamic types
|
|
117
|
-
*
|
|
118
|
-
* @example
|
|
119
|
-
* ```ts
|
|
120
|
-
* const endpoint = createEndpoint("/path", {
|
|
121
|
-
* method: "POST",
|
|
122
|
-
* body: z.record(z.string()),
|
|
123
|
-
* $Infer: {
|
|
124
|
-
* body: {} as {
|
|
125
|
-
* type: InferTypeFromOptions<Option> // custom type inference
|
|
126
|
-
* }
|
|
127
|
-
* }
|
|
128
|
-
* }, async(ctx)=>{
|
|
129
|
-
* const body = ctx.body
|
|
130
|
-
* })
|
|
131
|
-
* ```
|
|
132
|
-
*/
|
|
133
|
-
$Infer?: {
|
|
134
|
-
/**
|
|
135
|
-
* Body
|
|
136
|
-
*/
|
|
137
|
-
body?: any;
|
|
138
|
-
/**
|
|
139
|
-
* Query
|
|
140
|
-
*/
|
|
141
|
-
query?: Record<string, any>;
|
|
142
|
-
};
|
|
143
|
-
/**
|
|
144
|
-
* If enabled, endpoint won't be exposed over a router
|
|
145
|
-
* @deprecated Use path-less endpoints instead
|
|
146
|
-
*/
|
|
147
|
-
SERVER_ONLY?: boolean;
|
|
148
|
-
/**
|
|
149
|
-
* If enabled, endpoint won't be exposed as an action to the client
|
|
150
|
-
* @deprecated Use path-less endpoints instead
|
|
151
|
-
*/
|
|
152
|
-
isAction?: boolean;
|
|
153
|
-
/**
|
|
154
|
-
* Defines the places where the endpoint will be available
|
|
155
|
-
*
|
|
156
|
-
* Possible options:
|
|
157
|
-
* - `rpc` - the endpoint is exposed to the router, can be invoked directly and is available to the client
|
|
158
|
-
* - `server` - the endpoint is exposed to the router, can be invoked directly, but is not available to the client
|
|
159
|
-
* - `http` - the endpoint is only exposed to the router
|
|
160
|
-
* @default "rpc"
|
|
161
|
-
*/
|
|
162
|
-
scope?: "rpc" | "server" | "http";
|
|
163
|
-
/**
|
|
164
|
-
* List of allowed media types (MIME types) for the endpoint
|
|
165
|
-
*
|
|
166
|
-
* if provided, only the media types in the list will be allowed to be passed in the body
|
|
167
|
-
*
|
|
168
|
-
* @example
|
|
169
|
-
* ```ts
|
|
170
|
-
* const endpoint = createEndpoint("/path", {
|
|
171
|
-
* method: "POST",
|
|
172
|
-
* allowedMediaTypes: ["application/json", "application/x-www-form-urlencoded"],
|
|
173
|
-
* }, async(ctx)=>{
|
|
174
|
-
* const body = ctx.body
|
|
175
|
-
* })
|
|
176
|
-
* ```
|
|
177
|
-
*/
|
|
178
|
-
allowedMediaTypes?: string[];
|
|
179
|
-
/**
|
|
180
|
-
* Extra metadata
|
|
181
|
-
*/
|
|
182
|
-
[key: string]: any;
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* List of middlewares to use
|
|
186
|
-
*/
|
|
187
|
-
use?: Middleware[];
|
|
188
|
-
/**
|
|
189
|
-
* A callback to run before any API error is throw or returned
|
|
190
|
-
*
|
|
191
|
-
* @param e - The API error
|
|
192
|
-
* @returns - The response to return
|
|
193
|
-
*/
|
|
194
|
-
onAPIError?: (e: APIError) => void | Promise<void>;
|
|
195
|
-
/**
|
|
196
|
-
* A callback to run before a validation error is thrown
|
|
197
|
-
* You can customize the validation error message by throwing your own APIError
|
|
198
|
-
*/
|
|
199
|
-
onValidationError?: ({
|
|
200
|
-
issues,
|
|
201
|
-
message
|
|
202
|
-
}: {
|
|
203
|
-
message: string;
|
|
204
|
-
issues: readonly StandardSchemaV1.Issue[];
|
|
205
|
-
}) => void | Promise<void>;
|
|
206
|
-
}
|
|
207
|
-
type EndpointBodyMethodOptions = {
|
|
208
|
-
/**
|
|
209
|
-
* Request Method
|
|
210
|
-
*/
|
|
211
|
-
method: "POST" | "PUT" | "DELETE" | "PATCH" | ("POST" | "PUT" | "DELETE" | "PATCH")[];
|
|
212
|
-
/**
|
|
213
|
-
* Body Schema
|
|
214
|
-
*/
|
|
215
|
-
body?: StandardSchemaV1;
|
|
216
|
-
} | {
|
|
217
|
-
/**
|
|
218
|
-
* Request Method
|
|
219
|
-
*/
|
|
220
|
-
method: "GET" | "HEAD" | ("GET" | "HEAD")[];
|
|
221
|
-
/**
|
|
222
|
-
* Body Schema
|
|
223
|
-
*/
|
|
224
|
-
body?: never;
|
|
225
|
-
} | {
|
|
226
|
-
/**
|
|
227
|
-
* Request Method
|
|
228
|
-
*/
|
|
229
|
-
method: "*";
|
|
230
|
-
/**
|
|
231
|
-
* Body Schema
|
|
232
|
-
*/
|
|
233
|
-
body?: StandardSchemaV1;
|
|
234
|
-
} | {
|
|
235
|
-
/**
|
|
236
|
-
* Request Method
|
|
237
|
-
*/
|
|
238
|
-
method: ("POST" | "PUT" | "DELETE" | "PATCH" | "GET" | "HEAD")[];
|
|
239
|
-
/**
|
|
240
|
-
* Body Schema
|
|
241
|
-
*/
|
|
242
|
-
body?: StandardSchemaV1;
|
|
243
|
-
};
|
|
244
|
-
type EndpointOptions = EndpointBaseOptions & EndpointBodyMethodOptions;
|
|
245
|
-
type StrictEndpoint<Path extends string, Options extends EndpointOptions, R = any> = {
|
|
246
|
-
(context: InputContext<Path, Options> & {
|
|
247
|
-
asResponse: true;
|
|
248
|
-
}): Promise<Response>;
|
|
249
|
-
(context: InputContext<Path, Options> & {
|
|
250
|
-
returnHeaders: true;
|
|
251
|
-
returnStatus: true;
|
|
252
|
-
}): Promise<{
|
|
253
|
-
headers: Headers;
|
|
254
|
-
status: number;
|
|
255
|
-
response: Awaited<R>;
|
|
256
|
-
}>;
|
|
257
|
-
(context: InputContext<Path, Options> & {
|
|
258
|
-
returnHeaders: true;
|
|
259
|
-
returnStatus: false;
|
|
260
|
-
}): Promise<{
|
|
261
|
-
headers: Headers;
|
|
262
|
-
response: Awaited<R>;
|
|
263
|
-
}>;
|
|
264
|
-
(context: InputContext<Path, Options> & {
|
|
265
|
-
returnHeaders: false;
|
|
266
|
-
returnStatus: true;
|
|
267
|
-
}): Promise<{
|
|
268
|
-
status: number;
|
|
269
|
-
response: Awaited<R>;
|
|
270
|
-
}>;
|
|
271
|
-
(context: InputContext<Path, Options> & {
|
|
272
|
-
returnHeaders: false;
|
|
273
|
-
returnStatus: false;
|
|
274
|
-
}): Promise<R>;
|
|
275
|
-
(context: InputContext<Path, Options> & {
|
|
276
|
-
returnHeaders: true;
|
|
277
|
-
}): Promise<{
|
|
278
|
-
headers: Headers;
|
|
279
|
-
response: Awaited<R>;
|
|
280
|
-
}>;
|
|
281
|
-
(context: InputContext<Path, Options> & {
|
|
282
|
-
returnStatus: true;
|
|
283
|
-
}): Promise<{
|
|
284
|
-
status: number;
|
|
285
|
-
response: Awaited<R>;
|
|
286
|
-
}>;
|
|
287
|
-
(context?: InputContext<Path, Options>): Promise<R>;
|
|
288
|
-
options: Options;
|
|
289
|
-
path: Path;
|
|
290
|
-
};//# sourceMappingURL=endpoint.d.mts.map
|
|
291
|
-
|
|
292
|
-
/** Type for the handleRoute function used by better-auth endpoints */
|
|
293
|
-
type HandleBetterAuthRouteFn = (args: {
|
|
294
|
-
ctx: unknown;
|
|
295
|
-
routeName: RouteName;
|
|
296
|
-
}) => Promise<{
|
|
297
|
-
status: number;
|
|
298
|
-
body: unknown;
|
|
299
|
-
}>;
|
|
300
|
-
/**
|
|
301
|
-
* Creates a better-auth endpoint for a given route name.
|
|
302
|
-
* Each route needs its own call to preserve TypeScript literal types for the path.
|
|
303
|
-
*/
|
|
304
|
-
declare const createAutumnEndpoint: <T extends RouteName>(routeName: T, handleRoute: HandleBetterAuthRouteFn) => StrictEndpoint<`/autumn/${T}`, {
|
|
305
|
-
method: "POST";
|
|
306
|
-
body: zod.ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>> | undefined;
|
|
307
|
-
}, Record<string, unknown> | null>;
|
|
308
|
-
|
|
309
|
-
export { type HandleBetterAuthRouteFn as H, type RouteName as R, createAutumnEndpoint as c };
|