@aklinker1/zeta 2.1.3 → 2.2.1
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 +6 -1
- package/dist/adapters/zod-schema-adapter.d.mts +1 -1
- package/dist/app-C2QYhuOT.mjs +1228 -0
- package/dist/client.d.mts +2 -2
- package/dist/client.mjs +4 -10
- package/dist/index.d.mts +7 -6
- package/dist/index.mjs +2 -1235
- package/dist/schema.d.mts +1 -1
- package/dist/testing.d.mts +1 -1
- package/dist/transports/bun-transport.d.mts +44 -4
- package/dist/transports/bun-transport.mjs +46 -2
- package/dist/transports/deno-transport.d.mts +45 -3
- package/dist/transports/deno-transport.mjs +50 -6
- package/dist/transports/fetch-transport.d.mts +6 -0
- package/dist/transports/fetch-transport.mjs +25 -0
- package/dist/{types-D9oRVe1E.d.mts → types-BvjPE9EM.d.mts} +24 -10
- package/dist/types.d.mts +2 -2
- package/package.json +45 -26
- /package/dist/{schema-IKHh0I39.d.mts → schema-DKqL09oQ.d.mts} +0 -0
- /package/dist/{serialization-C8e7ECQ2.mjs → serialization-0dai2wUm.mjs} +0 -0
package/dist/client.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as ErrorResponse } from "./schema-
|
|
2
|
-
import {
|
|
1
|
+
import { t as ErrorResponse } from "./schema-DKqL09oQ.mjs";
|
|
2
|
+
import { T as GetResponseOutput, a as App, c as ApplyAppPrefix, f as BaseRoutes, s as ApplyAppDataPrefix, v as GetAppRoutes, y as GetRequestParamsInput } from "./types-BvjPE9EM.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/client.d.ts
|
|
5
5
|
/**
|
package/dist/client.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as smartSerialize, t as smartDeserialize } from "./serialization-
|
|
1
|
+
import { n as smartSerialize, t as smartDeserialize } from "./serialization-0dai2wUm.mjs";
|
|
2
2
|
//#region src/client.ts
|
|
3
3
|
/**
|
|
4
4
|
* Creates a type-safe client based on the server-side app. This is only useful
|
|
@@ -24,15 +24,13 @@ import { n as smartSerialize, t as smartDeserialize } from "./serialization-C8e7
|
|
|
24
24
|
*/
|
|
25
25
|
function createAppClient(options) {
|
|
26
26
|
const { baseUrl = location.origin, fetch = globalThis.fetch, headers = {} } = options ?? {};
|
|
27
|
-
const buildSearchParams = (query) => {
|
|
28
|
-
return new URLSearchParams(Object.entries(query).filter(([, value]) => value != null).map(([key, value]) => [key, String(value)])).toString();
|
|
29
|
-
};
|
|
30
27
|
const buildPath = (route, params) => {
|
|
31
28
|
return Object.entries(params).reduce((path, [key, value]) => path.replace(key === "**" ? key : new RegExp(`\\*{2}:${key}|:${key}`), encodeURIComponent(String(value))), route);
|
|
32
29
|
};
|
|
33
30
|
return { async fetch(method, route, inputs) {
|
|
34
|
-
const
|
|
35
|
-
const url =
|
|
31
|
+
const pathname = inputs.params ? buildPath(route, inputs.params) : route;
|
|
32
|
+
const url = new URL(pathname, baseUrl);
|
|
33
|
+
if (inputs.query) for (const [key, value] of Object.entries(inputs.query)) url.searchParams.set(key, String(value));
|
|
36
34
|
const init = {
|
|
37
35
|
body: void 0,
|
|
38
36
|
method: method.toUpperCase(),
|
|
@@ -65,9 +63,5 @@ var RequestError = class extends Error {
|
|
|
65
63
|
this.name = "RequestError";
|
|
66
64
|
}
|
|
67
65
|
};
|
|
68
|
-
/** Join string together using `/` without double slashes. */
|
|
69
|
-
function join(...paths) {
|
|
70
|
-
return paths.map((path) => path.replace(/^\/+|\/+$/g, "")).filter(Boolean).join("/");
|
|
71
|
-
}
|
|
72
66
|
//#endregion
|
|
73
67
|
export { RequestError, createAppClient };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as NoResponse, l as HttpStatus, s as ZetaSchema, t as ErrorResponse, u as getHttpStatusName } from "./schema-
|
|
2
|
-
import {
|
|
1
|
+
import { i as NoResponse, l as HttpStatus, s as ZetaSchema, t as ErrorResponse, u as getHttpStatusName } from "./schema-DKqL09oQ.mjs";
|
|
2
|
+
import { a as App, d as BasePrefix, i as AnyTransport, st as Transport, tt as SchemaAdapter, u as BasePath } from "./types-BvjPE9EM.mjs";
|
|
3
3
|
import { OpenAPI, OpenAPIV3_1 } from "openapi-types";
|
|
4
4
|
|
|
5
5
|
//#region src/app.d.ts
|
|
@@ -25,21 +25,22 @@ import { OpenAPI, OpenAPIV3_1 } from "openapi-types";
|
|
|
25
25
|
* // Or serve the app yourself
|
|
26
26
|
* const fetch = app.build();
|
|
27
27
|
* Bun.serve({ fetch, ... });
|
|
28
|
-
* Deno.serve({
|
|
28
|
+
* Deno.serve({ ... }, fetch);
|
|
29
29
|
* ```
|
|
30
30
|
*
|
|
31
31
|
* @param options Configure application behavior.
|
|
32
32
|
*/
|
|
33
|
-
declare function createApp<TPrefix extends BasePrefix = "">(options?: CreateAppOptions<TPrefix>): App<{
|
|
33
|
+
declare function createApp<TPrefix extends BasePrefix = "", TTransport extends AnyTransport = Transport>(options?: CreateAppOptions<TPrefix, TTransport>): App<{
|
|
34
34
|
ctx: {};
|
|
35
35
|
exported: false;
|
|
36
36
|
prefix: TPrefix;
|
|
37
37
|
routes: {};
|
|
38
|
+
transport: TTransport;
|
|
38
39
|
}>;
|
|
39
40
|
/**
|
|
40
41
|
* Configure how the app is created.
|
|
41
42
|
*/
|
|
42
|
-
type CreateAppOptions<TPrefix extends BasePrefix = ""> = {
|
|
43
|
+
type CreateAppOptions<TPrefix extends BasePrefix = "", TTransport extends AnyTransport = Transport> = {
|
|
43
44
|
/**
|
|
44
45
|
* The origin to use when constructing URLs.
|
|
45
46
|
* @default "http://localhost"
|
|
@@ -81,7 +82,7 @@ type CreateAppOptions<TPrefix extends BasePrefix = ""> = {
|
|
|
81
82
|
* });
|
|
82
83
|
* ```
|
|
83
84
|
*/
|
|
84
|
-
transport?:
|
|
85
|
+
transport?: TTransport;
|
|
85
86
|
/**
|
|
86
87
|
* Where the OpenAPI JSON docs is hosted.
|
|
87
88
|
* @default "/openapi.json"
|