@aklinker1/zeta 2.2.0 → 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
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# Zeta
|
|
2
2
|
|
|
3
|
-
[](https://jsr.io/@aklinker1/zeta)
|
|
3
|
+
[](https://jsr.io/@aklinker1/zeta)
|
|
4
|
+
[](https://www.npmjs.com/package/@aklinker1/zeta)
|
|
5
|
+
[](https://zeta.aklinker1.io)
|
|
6
|
+
[](https://jsr.io/@aklinker1/zeta/doc)
|
|
7
|
+
[](https://github.com/aklinker1/zeta/blob/main/LICENSE)
|
|
8
|
+
[](https://github.com/aklinker1/zeta/blob/main/CHANGELOG.md)
|
|
4
9
|
|
|
5
10
|
Composable, fast, testable, OpenAPI-first backend framework with validation built-in.
|
|
6
11
|
|
|
@@ -472,8 +472,8 @@ const validateOutputSchema = createHttpSchemaValidator(HttpStatus.UnprocessableE
|
|
|
472
472
|
function getRawPathname(request) {
|
|
473
473
|
const start = request.url.indexOf("/", 8);
|
|
474
474
|
if (start === -1) return "/";
|
|
475
|
-
for (let i = start + 1; i < request.url.length; i++) if (request.url[i] === "?" || request.url[i] === "#") return request.url.slice(start, i);
|
|
476
|
-
return request.url.slice(start);
|
|
475
|
+
for (let i = start + 1; i < request.url.length; i++) if (request.url[i] === "?" || request.url[i] === "#") return decodeUrlString(request.url.slice(start, i));
|
|
476
|
+
return decodeUrlString(request.url.slice(start));
|
|
477
477
|
}
|
|
478
478
|
function getRawQuery(request) {
|
|
479
479
|
let index = request.url.indexOf("?");
|
|
@@ -485,7 +485,7 @@ function getRawQuery(request) {
|
|
|
485
485
|
for (let i = start; i < len; i++) if (str[i] === "&" || i === len - 1) {
|
|
486
486
|
const end = i === len - 1 ? len : i;
|
|
487
487
|
const eqIndex = str.indexOf("=", start);
|
|
488
|
-
if (eqIndex !== -1 && eqIndex < end) res[str.slice(start, eqIndex)] = str.slice(eqIndex + 1, end);
|
|
488
|
+
if (eqIndex !== -1 && eqIndex < end) res[str.slice(start, eqIndex)] = decodeUrlString(str.slice(eqIndex + 1, end));
|
|
489
489
|
start = i + 1;
|
|
490
490
|
}
|
|
491
491
|
return res;
|
|
@@ -531,6 +531,9 @@ const IsStatusResult = Symbol("IsStatusResult");
|
|
|
531
531
|
function cleanupCompiledWhitespace(code) {
|
|
532
532
|
return code.replace(/^ +$/gm, "").replace(/\n\n+/gm, "\n\n").replaceAll("{\n\n", "{\n");
|
|
533
533
|
}
|
|
534
|
+
function decodeUrlString(text) {
|
|
535
|
+
return decodeURIComponent(text.replaceAll("+", " "));
|
|
536
|
+
}
|
|
534
537
|
//#endregion
|
|
535
538
|
//#region src/internal/context.ts
|
|
536
539
|
var Context = class {
|
package/dist/client.mjs
CHANGED
|
@@ -24,15 +24,13 @@ import { n as smartSerialize, t as smartDeserialize } from "./serialization-0dai
|
|
|
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.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as RangeNotSatisfiableHttpError, B as UpgradeRequiredHttpError, C as NotExtendedHttpError, D as PreconditionFailedHttpError, E as PaymentRequiredHttpError, F as TooManyRequestsHttpError, H as VariantAlsoNegotiatesHttpError, I as UnauthorizedHttpError, L as UnavailableForLegalReasonsHttpError, M as RequestTimeoutHttpError, N as ServiceUnavailableHttpError, O as PreconditionRequiredHttpError, P as TooEarlyHttpError, R as UnprocessableEntityHttpError, S as NotAcceptableHttpError, T as NotImplementedHttpError, U as HttpStatus, V as UriTooLongHttpError, W as getHttpStatusName, _ as LockedHttpError, a as ContentTooLargeHttpError, b as MisdirectedRequestHttpError, c as ForbiddenHttpError, d as HttpError, f as HttpVersionNotSupportedHttpError, g as LengthRequiredHttpError, h as InternalServerErrorHttpError, i as ConflictHttpError, j as RequestHeaderFieldsTooLargeHttpError, k as ProxyAuthenticationRequiredHttpError, l as GatewayTimeoutHttpError, m as InsufficientStorageHttpError, n as BadGatewayHttpError, o as ExpectationFailedHttpError, p as ImATeapotHttpError, r as BadRequestHttpError, s as FailedDependencyHttpError, t as createApp, u as GoneHttpError, v as LoopDetectedHttpError, w as NotFoundHttpError, x as NetworkAuthenticationRequiredHttpError, y as MethodNotAllowedHttpError, z as UnsupportedMediaTypeHttpError } from "./app-
|
|
1
|
+
import { A as RangeNotSatisfiableHttpError, B as UpgradeRequiredHttpError, C as NotExtendedHttpError, D as PreconditionFailedHttpError, E as PaymentRequiredHttpError, F as TooManyRequestsHttpError, H as VariantAlsoNegotiatesHttpError, I as UnauthorizedHttpError, L as UnavailableForLegalReasonsHttpError, M as RequestTimeoutHttpError, N as ServiceUnavailableHttpError, O as PreconditionRequiredHttpError, P as TooEarlyHttpError, R as UnprocessableEntityHttpError, S as NotAcceptableHttpError, T as NotImplementedHttpError, U as HttpStatus, V as UriTooLongHttpError, W as getHttpStatusName, _ as LockedHttpError, a as ContentTooLargeHttpError, b as MisdirectedRequestHttpError, c as ForbiddenHttpError, d as HttpError, f as HttpVersionNotSupportedHttpError, g as LengthRequiredHttpError, h as InternalServerErrorHttpError, i as ConflictHttpError, j as RequestHeaderFieldsTooLargeHttpError, k as ProxyAuthenticationRequiredHttpError, l as GatewayTimeoutHttpError, m as InsufficientStorageHttpError, n as BadGatewayHttpError, o as ExpectationFailedHttpError, p as ImATeapotHttpError, r as BadRequestHttpError, s as FailedDependencyHttpError, t as createApp, u as GoneHttpError, v as LoopDetectedHttpError, w as NotFoundHttpError, x as NetworkAuthenticationRequiredHttpError, y as MethodNotAllowedHttpError, z as UnsupportedMediaTypeHttpError } from "./app-C2QYhuOT.mjs";
|
|
2
2
|
import { ErrorResponse, NoResponse } from "./schema.mjs";
|
|
3
3
|
export { BadGatewayHttpError, BadRequestHttpError, ConflictHttpError, ContentTooLargeHttpError, ErrorResponse, ExpectationFailedHttpError, FailedDependencyHttpError, ForbiddenHttpError, GatewayTimeoutHttpError, GoneHttpError, HttpError, HttpStatus, HttpVersionNotSupportedHttpError, ImATeapotHttpError, InsufficientStorageHttpError, InternalServerErrorHttpError, LengthRequiredHttpError, LockedHttpError, LoopDetectedHttpError, MethodNotAllowedHttpError, MisdirectedRequestHttpError, NetworkAuthenticationRequiredHttpError, NoResponse, NotAcceptableHttpError, NotExtendedHttpError, NotFoundHttpError, NotImplementedHttpError, PaymentRequiredHttpError, PreconditionFailedHttpError, PreconditionRequiredHttpError, ProxyAuthenticationRequiredHttpError, RangeNotSatisfiableHttpError, RequestHeaderFieldsTooLargeHttpError, RequestTimeoutHttpError, ServiceUnavailableHttpError, TooEarlyHttpError, TooManyRequestsHttpError, UnauthorizedHttpError, UnavailableForLegalReasonsHttpError, UnprocessableEntityHttpError, UnsupportedMediaTypeHttpError, UpgradeRequiredHttpError, UriTooLongHttpError, VariantAlsoNegotiatesHttpError, createApp, getHttpStatusName };
|
package/package.json
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aklinker1/zeta",
|
|
3
|
+
"version": "2.2.1",
|
|
3
4
|
"description": "Composable, testable, OpenAPI-first backend framework with validation built-in",
|
|
4
|
-
"
|
|
5
|
-
|
|
5
|
+
"keywords": [
|
|
6
|
+
"backend",
|
|
7
|
+
"openapi",
|
|
8
|
+
"server",
|
|
9
|
+
"validation"
|
|
10
|
+
],
|
|
6
11
|
"license": "MIT",
|
|
7
|
-
"
|
|
12
|
+
"repository": {
|
|
13
|
+
"url": "https://github.com/aklinker1/zeta"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/*"
|
|
17
|
+
],
|
|
18
|
+
"type": "module",
|
|
8
19
|
"module": "dist/index.mjs",
|
|
9
20
|
"types": "dist/index.d.mts",
|
|
10
21
|
"exports": {
|
|
@@ -45,40 +56,30 @@
|
|
|
45
56
|
"default": "./dist/transports/deno-transport.mjs"
|
|
46
57
|
}
|
|
47
58
|
},
|
|
48
|
-
"files": [
|
|
49
|
-
"dist/*"
|
|
50
|
-
],
|
|
51
59
|
"publishConfig": {
|
|
52
60
|
"access": "public"
|
|
53
61
|
},
|
|
54
|
-
"repository": {
|
|
55
|
-
"url": "https://github.com/aklinker1/zeta"
|
|
56
|
-
},
|
|
57
|
-
"keywords": [
|
|
58
|
-
"backend",
|
|
59
|
-
"server",
|
|
60
|
-
"validation",
|
|
61
|
-
"openapi"
|
|
62
|
-
],
|
|
63
62
|
"scripts": {
|
|
64
|
-
"dev": "bun test --watch",
|
|
65
|
-
"build": "tsdown src/{index,types,client,testing,schema,adapters/zod-schema-adapter,transports/bun-transport,transports/fetch-transport,transports/deno-transport}.ts",
|
|
66
63
|
"bench": "bun run --sequential build 'bench:*'",
|
|
67
64
|
"bench:overhead": "bun run benchmarks/overhead.ts",
|
|
65
|
+
"build": "tsdown src/{index,types,client,testing,schema,adapters/zod-schema-adapter,transports/bun-transport,transports/fetch-transport,transports/deno-transport}.ts",
|
|
66
|
+
"dev": "bun test --watch",
|
|
67
|
+
"docs:build": "vitepress build docs",
|
|
68
|
+
"docs:dev": "zola -r docs serve",
|
|
69
|
+
"docs:preview": "vitepress preview docs",
|
|
68
70
|
"example": "bun --watch run example.ts",
|
|
69
71
|
"example:prod": "NODE_ENV=production bun run example",
|
|
70
|
-
"
|
|
71
|
-
"docs:build": "vitepress build docs",
|
|
72
|
-
"docs:preview": "vitepress preview docs"
|
|
72
|
+
"postinstall": "simple-git-hooks"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@standard-schema/spec": "^1.0.0",
|
|
76
76
|
"openapi-types": "^12.1.3",
|
|
77
77
|
"rou3": "^0.7.12",
|
|
78
|
-
"scule": "^1.3.0"
|
|
78
|
+
"scule": "^1.3.0",
|
|
79
|
+
"simple-git-hooks": "^2.13.1"
|
|
79
80
|
},
|
|
80
81
|
"devDependencies": {
|
|
81
|
-
"@aklinker1/check": "^2.
|
|
82
|
+
"@aklinker1/check": "^2.3.0",
|
|
82
83
|
"@opentelemetry/api": "^1.9.0",
|
|
83
84
|
"@opentelemetry/resources": "^2.5.0",
|
|
84
85
|
"@opentelemetry/sdk-node": "^0.211.0",
|
|
@@ -95,8 +96,9 @@
|
|
|
95
96
|
"hono": "^4.11.2",
|
|
96
97
|
"jsr": "^0.13.5",
|
|
97
98
|
"mermaid": "^11.12.0",
|
|
98
|
-
"
|
|
99
|
-
"
|
|
99
|
+
"nano-staged": "^0.9.0",
|
|
100
|
+
"oxfmt": "^0.40.0",
|
|
101
|
+
"oxlint": "^1.55.0",
|
|
100
102
|
"publint": "^0.3.12",
|
|
101
103
|
"tinybench": "^4.0.1",
|
|
102
104
|
"tsdown": "^0.21.2",
|
|
@@ -115,5 +117,12 @@
|
|
|
115
117
|
"@types/deno": {
|
|
116
118
|
"optional": true
|
|
117
119
|
}
|
|
118
|
-
}
|
|
120
|
+
},
|
|
121
|
+
"simple-git-hooks": {
|
|
122
|
+
"pre-commit": "./node_modules/.bin/nano-staged"
|
|
123
|
+
},
|
|
124
|
+
"nano-staged": {
|
|
125
|
+
"*": "oxfmt --no-error-on-unmatched-pattern"
|
|
126
|
+
},
|
|
127
|
+
"packageManager": "bun@1.3.10"
|
|
119
128
|
}
|