better-call 1.1.5 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +35 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  3. package/dist/adapters/node/request.cjs +125 -0
  4. package/dist/adapters/node/request.cjs.map +1 -0
  5. package/dist/{node.d.ts → adapters/node/request.d.cts} +2 -6
  6. package/dist/adapters/node/request.d.mts +16 -0
  7. package/dist/{node.js → adapters/node/request.mjs} +2 -13
  8. package/dist/adapters/node/request.mjs.map +1 -0
  9. package/dist/client.cjs +8 -1
  10. package/dist/client.cjs.map +1 -1
  11. package/dist/client.d.cts +12 -13
  12. package/dist/client.d.mts +53 -0
  13. package/dist/client.mjs +14 -0
  14. package/dist/client.mjs.map +1 -0
  15. package/dist/context.cjs +102 -0
  16. package/dist/context.cjs.map +1 -0
  17. package/dist/context.d.cts +340 -0
  18. package/dist/context.d.mts +340 -0
  19. package/dist/context.mjs +102 -0
  20. package/dist/context.mjs.map +1 -0
  21. package/dist/cookies.cjs +87 -0
  22. package/dist/cookies.cjs.map +1 -0
  23. package/dist/cookies.d.cts +103 -0
  24. package/dist/cookies.d.mts +103 -0
  25. package/dist/cookies.mjs +84 -0
  26. package/dist/cookies.mjs.map +1 -0
  27. package/dist/crypto.cjs +39 -0
  28. package/dist/crypto.cjs.map +1 -0
  29. package/dist/crypto.mjs +36 -0
  30. package/dist/crypto.mjs.map +1 -0
  31. package/dist/endpoint.cjs +70 -0
  32. package/dist/endpoint.cjs.map +1 -0
  33. package/dist/endpoint.d.cts +428 -0
  34. package/dist/endpoint.d.mts +428 -0
  35. package/dist/endpoint.mjs +70 -0
  36. package/dist/endpoint.mjs.map +1 -0
  37. package/dist/error.cjs +141 -0
  38. package/dist/error.cjs.map +1 -0
  39. package/dist/error.d.cts +103 -0
  40. package/dist/error.d.mts +103 -0
  41. package/dist/error.mjs +135 -0
  42. package/dist/error.mjs.map +1 -0
  43. package/dist/helper.d.cts +12 -0
  44. package/dist/helper.d.mts +12 -0
  45. package/dist/index.cjs +26 -968
  46. package/dist/index.d.cts +11 -14
  47. package/dist/index.d.mts +11 -0
  48. package/dist/index.mjs +10 -0
  49. package/dist/middleware.cjs +39 -0
  50. package/dist/middleware.cjs.map +1 -0
  51. package/dist/middleware.d.cts +123 -0
  52. package/dist/middleware.d.mts +123 -0
  53. package/dist/middleware.mjs +39 -0
  54. package/dist/middleware.mjs.map +1 -0
  55. package/dist/node.cjs +4 -151
  56. package/dist/node.cjs.map +1 -1
  57. package/dist/node.d.cts +2 -13
  58. package/dist/node.d.mts +9 -0
  59. package/dist/node.mjs +15 -0
  60. package/dist/node.mjs.map +1 -0
  61. package/dist/openapi.cjs +191 -0
  62. package/dist/openapi.cjs.map +1 -0
  63. package/dist/openapi.d.cts +113 -0
  64. package/dist/openapi.d.mts +113 -0
  65. package/dist/openapi.mjs +189 -0
  66. package/dist/openapi.mjs.map +1 -0
  67. package/dist/router.cjs +117 -0
  68. package/dist/router.cjs.map +1 -0
  69. package/dist/router.d.cts +4 -1242
  70. package/dist/router.d.mts +97 -0
  71. package/dist/router.mjs +116 -0
  72. package/dist/router.mjs.map +1 -0
  73. package/dist/standard-schema.d.cts +59 -0
  74. package/dist/standard-schema.d.mts +59 -0
  75. package/dist/to-response.cjs +96 -0
  76. package/dist/to-response.cjs.map +1 -0
  77. package/dist/to-response.d.cts +12 -0
  78. package/dist/to-response.d.mts +12 -0
  79. package/dist/to-response.mjs +96 -0
  80. package/dist/to-response.mjs.map +1 -0
  81. package/dist/utils.cjs +77 -0
  82. package/dist/utils.cjs.map +1 -0
  83. package/dist/utils.mjs +74 -0
  84. package/dist/utils.mjs.map +1 -0
  85. package/dist/validator.cjs +58 -0
  86. package/dist/validator.cjs.map +1 -0
  87. package/dist/validator.mjs +57 -0
  88. package/dist/validator.mjs.map +1 -0
  89. package/package.json +23 -13
  90. package/dist/client.d.ts +0 -54
  91. package/dist/client.js +0 -13
  92. package/dist/client.js.map +0 -1
  93. package/dist/index.cjs.map +0 -1
  94. package/dist/index.d.ts +0 -14
  95. package/dist/index.js +0 -951
  96. package/dist/index.js.map +0 -1
  97. package/dist/node.js.map +0 -1
  98. package/dist/router.d.ts +0 -1335
package/dist/node.mjs ADDED
@@ -0,0 +1,15 @@
1
+ import { getRequest, setResponse } from "./adapters/node/request.mjs";
2
+
3
+ //#region src/adapters/node/index.ts
4
+ function toNodeHandler(handler) {
5
+ return async (req, res) => {
6
+ return setResponse(res, await handler(getRequest({
7
+ base: `${req.headers["x-forwarded-proto"] || (req.socket.encrypted ? "https" : "http")}://${req.headers[":authority"] || req.headers.host}`,
8
+ request: req
9
+ })));
10
+ };
11
+ }
12
+
13
+ //#endregion
14
+ export { getRequest, setResponse, toNodeHandler };
15
+ //# sourceMappingURL=node.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.mjs","names":[],"sources":["../src/adapters/node/index.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { getRequest, setResponse } from \"./request\";\nimport type { Router } from \"../../router.js\";\n\nexport function toNodeHandler(handler: Router[\"handler\"]) {\n\treturn async (req: IncomingMessage, res: ServerResponse) => {\n\t\tconst protocol =\n\t\t\treq.headers[\"x-forwarded-proto\"] || ((req.socket as any).encrypted ? \"https\" : \"http\");\n\t\tconst base = `${protocol}://${req.headers[\":authority\"] || req.headers.host}`;\n\t\tconst response = await handler(getRequest({ base, request: req }));\n\t\treturn setResponse(res, response);\n\t};\n}\n\nexport { getRequest, setResponse };\n"],"mappings":";;;AAKA,SAAgB,cAAc,SAA4B;AACzD,QAAO,OAAO,KAAsB,QAAwB;AAK3D,SAAO,YAAY,KADF,MAAM,QAAQ,WAAW;GAAE,MAD/B,GADZ,IAAI,QAAQ,yBAA0B,IAAI,OAAe,YAAY,UAAU,QACvD,KAAK,IAAI,QAAQ,iBAAiB,IAAI,QAAQ;GACrB,SAAS;GAAK,CAAC,CAAC,CACjC"}
@@ -0,0 +1,191 @@
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let zod = require("zod");
3
+
4
+ //#region src/openapi.ts
5
+ const paths = {};
6
+ function getTypeFromZodType(zodType) {
7
+ switch (zodType.constructor.name) {
8
+ case "ZodString": return "string";
9
+ case "ZodNumber": return "number";
10
+ case "ZodBoolean": return "boolean";
11
+ case "ZodObject": return "object";
12
+ case "ZodArray": return "array";
13
+ default: return "string";
14
+ }
15
+ }
16
+ function getParameters(options) {
17
+ const parameters = [];
18
+ if (options.metadata?.openapi?.parameters) {
19
+ parameters.push(...options.metadata.openapi.parameters);
20
+ return parameters;
21
+ }
22
+ if (options.query instanceof zod.ZodObject) Object.entries(options.query.shape).forEach(([key, value]) => {
23
+ if (value instanceof zod.ZodObject) parameters.push({
24
+ name: key,
25
+ in: "query",
26
+ schema: {
27
+ type: getTypeFromZodType(value),
28
+ ..."minLength" in value && value.minLength ? { minLength: value.minLength } : {},
29
+ description: value.description
30
+ }
31
+ });
32
+ });
33
+ return parameters;
34
+ }
35
+ function getRequestBody(options) {
36
+ if (options.metadata?.openapi?.requestBody) return options.metadata.openapi.requestBody;
37
+ if (!options.body) return void 0;
38
+ if (options.body instanceof zod.ZodObject || options.body instanceof zod.ZodOptional) {
39
+ const shape = options.body.shape;
40
+ if (!shape) return void 0;
41
+ const properties = {};
42
+ const required = [];
43
+ Object.entries(shape).forEach(([key, value]) => {
44
+ if (value instanceof zod.ZodObject) {
45
+ properties[key] = {
46
+ type: getTypeFromZodType(value),
47
+ description: value.description
48
+ };
49
+ if (!(value instanceof zod.ZodOptional)) required.push(key);
50
+ }
51
+ });
52
+ return {
53
+ required: options.body instanceof zod.ZodOptional ? false : options.body ? true : false,
54
+ content: { "application/json": { schema: {
55
+ type: "object",
56
+ properties,
57
+ required
58
+ } } }
59
+ };
60
+ }
61
+ }
62
+ function getResponse(responses) {
63
+ return {
64
+ "400": {
65
+ content: { "application/json": { schema: {
66
+ type: "object",
67
+ properties: { message: { type: "string" } },
68
+ required: ["message"]
69
+ } } },
70
+ description: "Bad Request. Usually due to missing parameters, or invalid parameters."
71
+ },
72
+ "401": {
73
+ content: { "application/json": { schema: {
74
+ type: "object",
75
+ properties: { message: { type: "string" } },
76
+ required: ["message"]
77
+ } } },
78
+ description: "Unauthorized. Due to missing or invalid authentication."
79
+ },
80
+ "403": {
81
+ content: { "application/json": { schema: {
82
+ type: "object",
83
+ properties: { message: { type: "string" } }
84
+ } } },
85
+ description: "Forbidden. You do not have permission to access this resource or to perform this action."
86
+ },
87
+ "404": {
88
+ content: { "application/json": { schema: {
89
+ type: "object",
90
+ properties: { message: { type: "string" } }
91
+ } } },
92
+ description: "Not Found. The requested resource was not found."
93
+ },
94
+ "429": {
95
+ content: { "application/json": { schema: {
96
+ type: "object",
97
+ properties: { message: { type: "string" } }
98
+ } } },
99
+ description: "Too Many Requests. You have exceeded the rate limit. Try again later."
100
+ },
101
+ "500": {
102
+ content: { "application/json": { schema: {
103
+ type: "object",
104
+ properties: { message: { type: "string" } }
105
+ } } },
106
+ description: "Internal Server Error. This is a problem with the server that you cannot fix."
107
+ },
108
+ ...responses
109
+ };
110
+ }
111
+ async function generator(endpoints, config) {
112
+ const components = { schemas: {} };
113
+ Object.entries(endpoints).forEach(([_, value]) => {
114
+ const options = value.options;
115
+ if (!value.path || options.metadata?.SERVER_ONLY) return;
116
+ if (options.method === "GET") paths[value.path] = { get: {
117
+ tags: ["Default", ...options.metadata?.openapi?.tags || []],
118
+ description: options.metadata?.openapi?.description,
119
+ operationId: options.metadata?.openapi?.operationId,
120
+ security: [{ bearerAuth: [] }],
121
+ parameters: getParameters(options),
122
+ responses: getResponse(options.metadata?.openapi?.responses)
123
+ } };
124
+ if (options.method === "POST") {
125
+ const body = getRequestBody(options);
126
+ paths[value.path] = { post: {
127
+ tags: ["Default", ...options.metadata?.openapi?.tags || []],
128
+ description: options.metadata?.openapi?.description,
129
+ operationId: options.metadata?.openapi?.operationId,
130
+ security: [{ bearerAuth: [] }],
131
+ parameters: getParameters(options),
132
+ ...body ? { requestBody: body } : { requestBody: { content: { "application/json": { schema: {
133
+ type: "object",
134
+ properties: {}
135
+ } } } } },
136
+ responses: getResponse(options.metadata?.openapi?.responses)
137
+ } };
138
+ }
139
+ });
140
+ return {
141
+ openapi: "3.1.1",
142
+ info: {
143
+ title: "Better Auth",
144
+ description: "API Reference for your Better Auth Instance",
145
+ version: "1.1.0"
146
+ },
147
+ components,
148
+ security: [{ apiKeyCookie: [] }],
149
+ servers: [{ url: config?.url }],
150
+ tags: [{
151
+ name: "Default",
152
+ description: "Default endpoints that are included with Better Auth by default. These endpoints are not part of any plugin."
153
+ }],
154
+ paths
155
+ };
156
+ }
157
+ const getHTML = (apiReference, config) => `<!doctype html>
158
+ <html>
159
+ <head>
160
+ <title>Scalar API Reference</title>
161
+ <meta charset="utf-8" />
162
+ <meta
163
+ name="viewport"
164
+ content="width=device-width, initial-scale=1" />
165
+ </head>
166
+ <body>
167
+ <script
168
+ id="api-reference"
169
+ type="application/json">
170
+ ${JSON.stringify(apiReference)}
171
+ <\/script>
172
+ <script>
173
+ var configuration = {
174
+ favicon: ${config?.logo ? `data:image/svg+xml;utf8,${encodeURIComponent(config.logo)}` : void 0} ,
175
+ theme: ${config?.theme || "saturn"},
176
+ metaData: {
177
+ title: ${config?.title || "Open API Reference"},
178
+ description: ${config?.description || "Better Call Open API"},
179
+ }
180
+ }
181
+ document.getElementById('api-reference').dataset.configuration =
182
+ JSON.stringify(configuration)
183
+ <\/script>
184
+ <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"><\/script>
185
+ </body>
186
+ </html>`;
187
+
188
+ //#endregion
189
+ exports.generator = generator;
190
+ exports.getHTML = getHTML;
191
+ //# sourceMappingURL=openapi.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi.cjs","names":["paths: Record<string, Path>","parameters: OpenAPIParameter[]","ZodObject","ZodOptional","properties: Record<string, any>","required: string[]"],"sources":["../src/openapi.ts"],"sourcesContent":["import { ZodObject, ZodOptional, ZodType } from \"zod\";\nimport type { Endpoint, EndpointOptions } from \"./endpoint\";\n\nexport type OpenAPISchemaType = \"string\" | \"number\" | \"integer\" | \"boolean\" | \"array\" | \"object\";\n\nexport interface OpenAPIParameter {\n\tin: \"query\" | \"path\" | \"header\" | \"cookie\";\n\tname?: string;\n\tdescription?: string;\n\trequired?: boolean;\n\tschema?: {\n\t\ttype: OpenAPISchemaType;\n\t\tformat?: string;\n\t\titems?: {\n\t\t\ttype: OpenAPISchemaType;\n\t\t};\n\t\tenum?: string[];\n\t\tminLength?: number;\n\t\tdescription?: string;\n\t\tdefault?: string;\n\t\texample?: string;\n\t};\n}\n\nexport interface Path {\n\tget?: {\n\t\ttags?: string[];\n\t\toperationId?: string;\n\t\tdescription?: string;\n\t\tsecurity?: [{ bearerAuth: string[] }];\n\t\tparameters?: OpenAPIParameter[];\n\t\tresponses?: {\n\t\t\t[key in string]: {\n\t\t\t\tdescription?: string;\n\t\t\t\tcontent: {\n\t\t\t\t\t\"application/json\": {\n\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\ttype?: OpenAPISchemaType;\n\t\t\t\t\t\t\tproperties?: Record<string, any>;\n\t\t\t\t\t\t\trequired?: string[];\n\t\t\t\t\t\t\t$ref?: string;\n\t\t\t\t\t\t};\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t};\n\t};\n\tpost?: {\n\t\ttags?: string[];\n\t\toperationId?: string;\n\t\tdescription?: string;\n\t\tsecurity?: [{ bearerAuth: string[] }];\n\t\tparameters?: OpenAPIParameter[];\n\t\trequestBody?: {\n\t\t\tcontent: {\n\t\t\t\t\"application/json\": {\n\t\t\t\t\tschema: {\n\t\t\t\t\t\ttype?: OpenAPISchemaType;\n\t\t\t\t\t\tproperties?: Record<string, any>;\n\t\t\t\t\t\trequired?: string[];\n\t\t\t\t\t\t$ref?: string;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t};\n\t\tresponses?: {\n\t\t\t[key in string]: {\n\t\t\t\tdescription?: string;\n\t\t\t\tcontent: {\n\t\t\t\t\t\"application/json\": {\n\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\ttype?: OpenAPISchemaType;\n\t\t\t\t\t\t\tproperties?: Record<string, any>;\n\t\t\t\t\t\t\trequired?: string[];\n\t\t\t\t\t\t\t$ref?: string;\n\t\t\t\t\t\t};\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t};\n\t};\n}\nconst paths: Record<string, Path> = {};\n\nfunction getTypeFromZodType(zodType: ZodType<any>) {\n\tswitch (zodType.constructor.name) {\n\t\tcase \"ZodString\":\n\t\t\treturn \"string\";\n\t\tcase \"ZodNumber\":\n\t\t\treturn \"number\";\n\t\tcase \"ZodBoolean\":\n\t\t\treturn \"boolean\";\n\t\tcase \"ZodObject\":\n\t\t\treturn \"object\";\n\t\tcase \"ZodArray\":\n\t\t\treturn \"array\";\n\t\tdefault:\n\t\t\treturn \"string\";\n\t}\n}\n\nfunction getParameters(options: EndpointOptions) {\n\tconst parameters: OpenAPIParameter[] = [];\n\tif (options.metadata?.openapi?.parameters) {\n\t\tparameters.push(...options.metadata.openapi.parameters);\n\t\treturn parameters;\n\t}\n\tif (options.query instanceof ZodObject) {\n\t\tObject.entries(options.query.shape).forEach(([key, value]) => {\n\t\t\tif (value instanceof ZodObject) {\n\t\t\t\tparameters.push({\n\t\t\t\t\tname: key,\n\t\t\t\t\tin: \"query\",\n\t\t\t\t\tschema: {\n\t\t\t\t\t\ttype: getTypeFromZodType(value),\n\t\t\t\t\t\t...(\"minLength\" in value && value.minLength\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tminLength: value.minLength as number,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\tdescription: value.description,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\treturn parameters;\n}\n\nfunction getRequestBody(options: EndpointOptions): any {\n\tif (options.metadata?.openapi?.requestBody) {\n\t\treturn options.metadata.openapi.requestBody;\n\t}\n\tif (!options.body) return undefined;\n\tif (options.body instanceof ZodObject || options.body instanceof ZodOptional) {\n\t\t// @ts-ignore\n\t\tconst shape = options.body.shape;\n\t\tif (!shape) return undefined;\n\t\tconst properties: Record<string, any> = {};\n\t\tconst required: string[] = [];\n\t\tObject.entries(shape).forEach(([key, value]) => {\n\t\t\tif (value instanceof ZodObject) {\n\t\t\t\tproperties[key] = {\n\t\t\t\t\ttype: getTypeFromZodType(value),\n\t\t\t\t\tdescription: value.description,\n\t\t\t\t};\n\t\t\t\tif (!(value instanceof ZodOptional)) {\n\t\t\t\t\trequired.push(key);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn {\n\t\t\trequired: options.body instanceof ZodOptional ? false : options.body ? true : false,\n\t\t\tcontent: {\n\t\t\t\t\"application/json\": {\n\t\t\t\t\tschema: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties,\n\t\t\t\t\t\trequired,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\treturn undefined;\n}\n\nfunction getResponse(responses?: Record<string, any>) {\n\treturn {\n\t\t\"400\": {\n\t\t\tcontent: {\n\t\t\t\t\"application/json\": {\n\t\t\t\t\tschema: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tmessage: {\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"message\"],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tdescription: \"Bad Request. Usually due to missing parameters, or invalid parameters.\",\n\t\t},\n\t\t\"401\": {\n\t\t\tcontent: {\n\t\t\t\t\"application/json\": {\n\t\t\t\t\tschema: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tmessage: {\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"message\"],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tdescription: \"Unauthorized. Due to missing or invalid authentication.\",\n\t\t},\n\t\t\"403\": {\n\t\t\tcontent: {\n\t\t\t\t\"application/json\": {\n\t\t\t\t\tschema: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tmessage: {\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tdescription:\n\t\t\t\t\"Forbidden. You do not have permission to access this resource or to perform this action.\",\n\t\t},\n\t\t\"404\": {\n\t\t\tcontent: {\n\t\t\t\t\"application/json\": {\n\t\t\t\t\tschema: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tmessage: {\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tdescription: \"Not Found. The requested resource was not found.\",\n\t\t},\n\t\t\"429\": {\n\t\t\tcontent: {\n\t\t\t\t\"application/json\": {\n\t\t\t\t\tschema: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tmessage: {\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tdescription: \"Too Many Requests. You have exceeded the rate limit. Try again later.\",\n\t\t},\n\t\t\"500\": {\n\t\t\tcontent: {\n\t\t\t\t\"application/json\": {\n\t\t\t\t\tschema: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tmessage: {\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tdescription:\n\t\t\t\t\"Internal Server Error. This is a problem with the server that you cannot fix.\",\n\t\t},\n\t\t...responses,\n\t} as any;\n}\n\nexport async function generator(\n\tendpoints: Record<string, Endpoint>,\n\tconfig?: {\n\t\turl: string;\n\t},\n) {\n\tconst components = {\n\t\tschemas: {},\n\t};\n\n\tObject.entries(endpoints).forEach(([_, value]) => {\n\t\tconst options = value.options as EndpointOptions;\n\t\tif (!value.path || options.metadata?.SERVER_ONLY) return;\n\t\tif (options.method === \"GET\") {\n\t\t\tpaths[value.path] = {\n\t\t\t\tget: {\n\t\t\t\t\ttags: [\"Default\", ...(options.metadata?.openapi?.tags || [])],\n\t\t\t\t\tdescription: options.metadata?.openapi?.description,\n\t\t\t\t\toperationId: options.metadata?.openapi?.operationId,\n\t\t\t\t\tsecurity: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tbearerAuth: [],\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tparameters: getParameters(options),\n\t\t\t\t\tresponses: getResponse(options.metadata?.openapi?.responses),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tif (options.method === \"POST\") {\n\t\t\tconst body = getRequestBody(options);\n\t\t\tpaths[value.path] = {\n\t\t\t\tpost: {\n\t\t\t\t\ttags: [\"Default\", ...(options.metadata?.openapi?.tags || [])],\n\t\t\t\t\tdescription: options.metadata?.openapi?.description,\n\t\t\t\t\toperationId: options.metadata?.openapi?.operationId,\n\t\t\t\t\tsecurity: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tbearerAuth: [],\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tparameters: getParameters(options),\n\t\t\t\t\t...(body\n\t\t\t\t\t\t? { requestBody: body }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\trequestBody: {\n\t\t\t\t\t\t\t\t\t//set body none\n\t\t\t\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\t\t\t\"application/json\": {\n\t\t\t\t\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\t\t\t\t\t\t\tproperties: {},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}),\n\t\t\t\t\tresponses: getResponse(options.metadata?.openapi?.responses),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t});\n\n\tconst res = {\n\t\topenapi: \"3.1.1\",\n\t\tinfo: {\n\t\t\ttitle: \"Better Auth\",\n\t\t\tdescription: \"API Reference for your Better Auth Instance\",\n\t\t\tversion: \"1.1.0\",\n\t\t},\n\t\tcomponents,\n\t\tsecurity: [\n\t\t\t{\n\t\t\t\tapiKeyCookie: [],\n\t\t\t},\n\t\t],\n\t\tservers: [\n\t\t\t{\n\t\t\t\turl: config?.url,\n\t\t\t},\n\t\t],\n\t\ttags: [\n\t\t\t{\n\t\t\t\tname: \"Default\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Default endpoints that are included with Better Auth by default. These endpoints are not part of any plugin.\",\n\t\t\t},\n\t\t],\n\t\tpaths,\n\t};\n\treturn res;\n}\n\nexport const getHTML = (\n\tapiReference: Record<string, any>,\n\tconfig?: {\n\t\tlogo?: string;\n\t\ttheme?: string;\n\t\ttitle?: string;\n\t\tdescription?: string;\n\t},\n) => `<!doctype html>\n<html>\n <head>\n <title>Scalar API Reference</title>\n <meta charset=\"utf-8\" />\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1\" />\n </head>\n <body>\n <script\n id=\"api-reference\"\n type=\"application/json\">\n ${JSON.stringify(apiReference)}\n </script>\n\t <script>\n var configuration = {\n\t \tfavicon: ${config?.logo ? `data:image/svg+xml;utf8,${encodeURIComponent(config.logo)}` : undefined} ,\n\t \ttheme: ${config?.theme || \"saturn\"},\n metaData: {\n\t\t\ttitle: ${config?.title || \"Open API Reference\"},\n\t\t\tdescription: ${config?.description || \"Better Call Open API\"},\n\t\t}\n }\n document.getElementById('api-reference').dataset.configuration =\n JSON.stringify(configuration)\n </script>\n\t <script src=\"https://cdn.jsdelivr.net/npm/@scalar/api-reference\"></script>\n </body>\n</html>`;\n"],"mappings":"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"}
@@ -0,0 +1,113 @@
1
+ import { Endpoint } from "./endpoint.cjs";
2
+
3
+ //#region src/openapi.d.ts
4
+ type OpenAPISchemaType = "string" | "number" | "integer" | "boolean" | "array" | "object";
5
+ interface OpenAPIParameter {
6
+ in: "query" | "path" | "header" | "cookie";
7
+ name?: string;
8
+ description?: string;
9
+ required?: boolean;
10
+ schema?: {
11
+ type: OpenAPISchemaType;
12
+ format?: string;
13
+ items?: {
14
+ type: OpenAPISchemaType;
15
+ };
16
+ enum?: string[];
17
+ minLength?: number;
18
+ description?: string;
19
+ default?: string;
20
+ example?: string;
21
+ };
22
+ }
23
+ interface Path {
24
+ get?: {
25
+ tags?: string[];
26
+ operationId?: string;
27
+ description?: string;
28
+ security?: [{
29
+ bearerAuth: string[];
30
+ }];
31
+ parameters?: OpenAPIParameter[];
32
+ responses?: { [key in string]: {
33
+ description?: string;
34
+ content: {
35
+ "application/json": {
36
+ schema: {
37
+ type?: OpenAPISchemaType;
38
+ properties?: Record<string, any>;
39
+ required?: string[];
40
+ $ref?: string;
41
+ };
42
+ };
43
+ };
44
+ } };
45
+ };
46
+ post?: {
47
+ tags?: string[];
48
+ operationId?: string;
49
+ description?: string;
50
+ security?: [{
51
+ bearerAuth: string[];
52
+ }];
53
+ parameters?: OpenAPIParameter[];
54
+ requestBody?: {
55
+ content: {
56
+ "application/json": {
57
+ schema: {
58
+ type?: OpenAPISchemaType;
59
+ properties?: Record<string, any>;
60
+ required?: string[];
61
+ $ref?: string;
62
+ };
63
+ };
64
+ };
65
+ };
66
+ responses?: { [key in string]: {
67
+ description?: string;
68
+ content: {
69
+ "application/json": {
70
+ schema: {
71
+ type?: OpenAPISchemaType;
72
+ properties?: Record<string, any>;
73
+ required?: string[];
74
+ $ref?: string;
75
+ };
76
+ };
77
+ };
78
+ } };
79
+ };
80
+ }
81
+ declare function generator(endpoints: Record<string, Endpoint>, config?: {
82
+ url: string;
83
+ }): Promise<{
84
+ openapi: string;
85
+ info: {
86
+ title: string;
87
+ description: string;
88
+ version: string;
89
+ };
90
+ components: {
91
+ schemas: {};
92
+ };
93
+ security: {
94
+ apiKeyCookie: never[];
95
+ }[];
96
+ servers: {
97
+ url: string | undefined;
98
+ }[];
99
+ tags: {
100
+ name: string;
101
+ description: string;
102
+ }[];
103
+ paths: Record<string, Path>;
104
+ }>;
105
+ declare const getHTML: (apiReference: Record<string, any>, config?: {
106
+ logo?: string;
107
+ theme?: string;
108
+ title?: string;
109
+ description?: string;
110
+ }) => string;
111
+ //#endregion
112
+ export { OpenAPIParameter, OpenAPISchemaType, Path, generator, getHTML };
113
+ //# sourceMappingURL=openapi.d.cts.map
@@ -0,0 +1,113 @@
1
+ import { Endpoint } from "./endpoint.mjs";
2
+
3
+ //#region src/openapi.d.ts
4
+ type OpenAPISchemaType = "string" | "number" | "integer" | "boolean" | "array" | "object";
5
+ interface OpenAPIParameter {
6
+ in: "query" | "path" | "header" | "cookie";
7
+ name?: string;
8
+ description?: string;
9
+ required?: boolean;
10
+ schema?: {
11
+ type: OpenAPISchemaType;
12
+ format?: string;
13
+ items?: {
14
+ type: OpenAPISchemaType;
15
+ };
16
+ enum?: string[];
17
+ minLength?: number;
18
+ description?: string;
19
+ default?: string;
20
+ example?: string;
21
+ };
22
+ }
23
+ interface Path {
24
+ get?: {
25
+ tags?: string[];
26
+ operationId?: string;
27
+ description?: string;
28
+ security?: [{
29
+ bearerAuth: string[];
30
+ }];
31
+ parameters?: OpenAPIParameter[];
32
+ responses?: { [key in string]: {
33
+ description?: string;
34
+ content: {
35
+ "application/json": {
36
+ schema: {
37
+ type?: OpenAPISchemaType;
38
+ properties?: Record<string, any>;
39
+ required?: string[];
40
+ $ref?: string;
41
+ };
42
+ };
43
+ };
44
+ } };
45
+ };
46
+ post?: {
47
+ tags?: string[];
48
+ operationId?: string;
49
+ description?: string;
50
+ security?: [{
51
+ bearerAuth: string[];
52
+ }];
53
+ parameters?: OpenAPIParameter[];
54
+ requestBody?: {
55
+ content: {
56
+ "application/json": {
57
+ schema: {
58
+ type?: OpenAPISchemaType;
59
+ properties?: Record<string, any>;
60
+ required?: string[];
61
+ $ref?: string;
62
+ };
63
+ };
64
+ };
65
+ };
66
+ responses?: { [key in string]: {
67
+ description?: string;
68
+ content: {
69
+ "application/json": {
70
+ schema: {
71
+ type?: OpenAPISchemaType;
72
+ properties?: Record<string, any>;
73
+ required?: string[];
74
+ $ref?: string;
75
+ };
76
+ };
77
+ };
78
+ } };
79
+ };
80
+ }
81
+ declare function generator(endpoints: Record<string, Endpoint>, config?: {
82
+ url: string;
83
+ }): Promise<{
84
+ openapi: string;
85
+ info: {
86
+ title: string;
87
+ description: string;
88
+ version: string;
89
+ };
90
+ components: {
91
+ schemas: {};
92
+ };
93
+ security: {
94
+ apiKeyCookie: never[];
95
+ }[];
96
+ servers: {
97
+ url: string | undefined;
98
+ }[];
99
+ tags: {
100
+ name: string;
101
+ description: string;
102
+ }[];
103
+ paths: Record<string, Path>;
104
+ }>;
105
+ declare const getHTML: (apiReference: Record<string, any>, config?: {
106
+ logo?: string;
107
+ theme?: string;
108
+ title?: string;
109
+ description?: string;
110
+ }) => string;
111
+ //#endregion
112
+ export { OpenAPIParameter, OpenAPISchemaType, Path, generator, getHTML };
113
+ //# sourceMappingURL=openapi.d.mts.map
@@ -0,0 +1,189 @@
1
+ import { ZodObject, ZodOptional } from "zod";
2
+
3
+ //#region src/openapi.ts
4
+ const paths = {};
5
+ function getTypeFromZodType(zodType) {
6
+ switch (zodType.constructor.name) {
7
+ case "ZodString": return "string";
8
+ case "ZodNumber": return "number";
9
+ case "ZodBoolean": return "boolean";
10
+ case "ZodObject": return "object";
11
+ case "ZodArray": return "array";
12
+ default: return "string";
13
+ }
14
+ }
15
+ function getParameters(options) {
16
+ const parameters = [];
17
+ if (options.metadata?.openapi?.parameters) {
18
+ parameters.push(...options.metadata.openapi.parameters);
19
+ return parameters;
20
+ }
21
+ if (options.query instanceof ZodObject) Object.entries(options.query.shape).forEach(([key, value]) => {
22
+ if (value instanceof ZodObject) parameters.push({
23
+ name: key,
24
+ in: "query",
25
+ schema: {
26
+ type: getTypeFromZodType(value),
27
+ ..."minLength" in value && value.minLength ? { minLength: value.minLength } : {},
28
+ description: value.description
29
+ }
30
+ });
31
+ });
32
+ return parameters;
33
+ }
34
+ function getRequestBody(options) {
35
+ if (options.metadata?.openapi?.requestBody) return options.metadata.openapi.requestBody;
36
+ if (!options.body) return void 0;
37
+ if (options.body instanceof ZodObject || options.body instanceof ZodOptional) {
38
+ const shape = options.body.shape;
39
+ if (!shape) return void 0;
40
+ const properties = {};
41
+ const required = [];
42
+ Object.entries(shape).forEach(([key, value]) => {
43
+ if (value instanceof ZodObject) {
44
+ properties[key] = {
45
+ type: getTypeFromZodType(value),
46
+ description: value.description
47
+ };
48
+ if (!(value instanceof ZodOptional)) required.push(key);
49
+ }
50
+ });
51
+ return {
52
+ required: options.body instanceof ZodOptional ? false : options.body ? true : false,
53
+ content: { "application/json": { schema: {
54
+ type: "object",
55
+ properties,
56
+ required
57
+ } } }
58
+ };
59
+ }
60
+ }
61
+ function getResponse(responses) {
62
+ return {
63
+ "400": {
64
+ content: { "application/json": { schema: {
65
+ type: "object",
66
+ properties: { message: { type: "string" } },
67
+ required: ["message"]
68
+ } } },
69
+ description: "Bad Request. Usually due to missing parameters, or invalid parameters."
70
+ },
71
+ "401": {
72
+ content: { "application/json": { schema: {
73
+ type: "object",
74
+ properties: { message: { type: "string" } },
75
+ required: ["message"]
76
+ } } },
77
+ description: "Unauthorized. Due to missing or invalid authentication."
78
+ },
79
+ "403": {
80
+ content: { "application/json": { schema: {
81
+ type: "object",
82
+ properties: { message: { type: "string" } }
83
+ } } },
84
+ description: "Forbidden. You do not have permission to access this resource or to perform this action."
85
+ },
86
+ "404": {
87
+ content: { "application/json": { schema: {
88
+ type: "object",
89
+ properties: { message: { type: "string" } }
90
+ } } },
91
+ description: "Not Found. The requested resource was not found."
92
+ },
93
+ "429": {
94
+ content: { "application/json": { schema: {
95
+ type: "object",
96
+ properties: { message: { type: "string" } }
97
+ } } },
98
+ description: "Too Many Requests. You have exceeded the rate limit. Try again later."
99
+ },
100
+ "500": {
101
+ content: { "application/json": { schema: {
102
+ type: "object",
103
+ properties: { message: { type: "string" } }
104
+ } } },
105
+ description: "Internal Server Error. This is a problem with the server that you cannot fix."
106
+ },
107
+ ...responses
108
+ };
109
+ }
110
+ async function generator(endpoints, config) {
111
+ const components = { schemas: {} };
112
+ Object.entries(endpoints).forEach(([_, value]) => {
113
+ const options = value.options;
114
+ if (!value.path || options.metadata?.SERVER_ONLY) return;
115
+ if (options.method === "GET") paths[value.path] = { get: {
116
+ tags: ["Default", ...options.metadata?.openapi?.tags || []],
117
+ description: options.metadata?.openapi?.description,
118
+ operationId: options.metadata?.openapi?.operationId,
119
+ security: [{ bearerAuth: [] }],
120
+ parameters: getParameters(options),
121
+ responses: getResponse(options.metadata?.openapi?.responses)
122
+ } };
123
+ if (options.method === "POST") {
124
+ const body = getRequestBody(options);
125
+ paths[value.path] = { post: {
126
+ tags: ["Default", ...options.metadata?.openapi?.tags || []],
127
+ description: options.metadata?.openapi?.description,
128
+ operationId: options.metadata?.openapi?.operationId,
129
+ security: [{ bearerAuth: [] }],
130
+ parameters: getParameters(options),
131
+ ...body ? { requestBody: body } : { requestBody: { content: { "application/json": { schema: {
132
+ type: "object",
133
+ properties: {}
134
+ } } } } },
135
+ responses: getResponse(options.metadata?.openapi?.responses)
136
+ } };
137
+ }
138
+ });
139
+ return {
140
+ openapi: "3.1.1",
141
+ info: {
142
+ title: "Better Auth",
143
+ description: "API Reference for your Better Auth Instance",
144
+ version: "1.1.0"
145
+ },
146
+ components,
147
+ security: [{ apiKeyCookie: [] }],
148
+ servers: [{ url: config?.url }],
149
+ tags: [{
150
+ name: "Default",
151
+ description: "Default endpoints that are included with Better Auth by default. These endpoints are not part of any plugin."
152
+ }],
153
+ paths
154
+ };
155
+ }
156
+ const getHTML = (apiReference, config) => `<!doctype html>
157
+ <html>
158
+ <head>
159
+ <title>Scalar API Reference</title>
160
+ <meta charset="utf-8" />
161
+ <meta
162
+ name="viewport"
163
+ content="width=device-width, initial-scale=1" />
164
+ </head>
165
+ <body>
166
+ <script
167
+ id="api-reference"
168
+ type="application/json">
169
+ ${JSON.stringify(apiReference)}
170
+ <\/script>
171
+ <script>
172
+ var configuration = {
173
+ favicon: ${config?.logo ? `data:image/svg+xml;utf8,${encodeURIComponent(config.logo)}` : void 0} ,
174
+ theme: ${config?.theme || "saturn"},
175
+ metaData: {
176
+ title: ${config?.title || "Open API Reference"},
177
+ description: ${config?.description || "Better Call Open API"},
178
+ }
179
+ }
180
+ document.getElementById('api-reference').dataset.configuration =
181
+ JSON.stringify(configuration)
182
+ <\/script>
183
+ <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"><\/script>
184
+ </body>
185
+ </html>`;
186
+
187
+ //#endregion
188
+ export { generator, getHTML };
189
+ //# sourceMappingURL=openapi.mjs.map