@rexeus/typeweaver-core 0.1.2 → 0.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/dist/index.d.ts +14 -5
- package/dist/index.js +17 -0
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { ZodType, ZodObject, ZodString, ZodStringFormat, ZodLiteral, ZodEnum, ZodOptional, ZodArray } from 'zod';
|
|
1
|
+
import { ZodType, ZodObject, ZodString, ZodStringFormat, ZodLiteral, ZodEnum, ZodOptional, ZodArray, ZodRecord } from 'zod';
|
|
2
2
|
import { $ZodIssue } from 'zod/v4/core';
|
|
3
3
|
|
|
4
4
|
type IHttpBody = any | undefined;
|
|
5
5
|
type HttpBodySchema = ZodType;
|
|
6
6
|
|
|
7
7
|
type IHttpHeader = Record<string, string | string[]> | undefined;
|
|
8
|
-
type
|
|
9
|
-
type
|
|
8
|
+
type ZodStringType$1 = ZodString | ZodStringFormat | ZodLiteral<string> | ZodEnum<Record<string, string>>;
|
|
9
|
+
type HttpHeaderValue = ZodStringType$1 | ZodOptional<ZodStringType$1> | ZodArray<ZodStringType$1> | ZodOptional<ZodArray<ZodStringType$1>>;
|
|
10
|
+
type HttpHeaderObject = ZodObject<Record<string, HttpHeaderValue>> | ZodRecord<ZodStringType$1, HttpHeaderValue>;
|
|
10
11
|
type HttpHeaderSchema = HttpHeaderObject | ZodOptional<HttpHeaderObject>;
|
|
11
12
|
|
|
12
13
|
declare enum HttpMethod {
|
|
@@ -24,8 +25,9 @@ type HttpParamValue = ZodString | ZodStringFormat | ZodLiteral<string> | ZodEnum
|
|
|
24
25
|
type HttpParamSchema = ZodObject<Record<string, HttpParamValue>>;
|
|
25
26
|
|
|
26
27
|
type IHttpQuery = Record<string, string | string[]> | undefined;
|
|
27
|
-
type
|
|
28
|
-
type
|
|
28
|
+
type ZodStringType = ZodString | ZodStringFormat | ZodLiteral<string> | ZodEnum<Record<string, string>>;
|
|
29
|
+
type HttpQueryValue = ZodStringType | ZodOptional<ZodStringType> | ZodArray<ZodStringType> | ZodOptional<ZodArray<ZodStringType>>;
|
|
30
|
+
type HttpQueryObject = ZodObject<Record<string, HttpQueryValue>> | ZodRecord<ZodStringType, HttpQueryValue>;
|
|
29
31
|
type HttpQuerySchema = HttpQueryObject | ZodOptional<HttpQueryObject>;
|
|
30
32
|
|
|
31
33
|
type IHttpRequest<Header extends IHttpHeader = IHttpHeader, Param extends IHttpParam = IHttpParam, Query extends IHttpQuery = IHttpQuery, Body extends IHttpBody = IHttpBody> = {
|
|
@@ -47,6 +49,13 @@ declare enum HttpStatusCode {
|
|
|
47
49
|
MULTI_STATUS = 207,
|
|
48
50
|
ALREADY_REPORTED = 208,
|
|
49
51
|
IM_USED = 226,
|
|
52
|
+
MULTIPLE_CHOICES = 300,
|
|
53
|
+
MOVED_PERMANENTLY = 301,
|
|
54
|
+
FOUND = 302,
|
|
55
|
+
SEE_OTHER = 303,
|
|
56
|
+
NOT_MODIFIED = 304,
|
|
57
|
+
TEMPORARY_REDIRECT = 307,
|
|
58
|
+
PERMANENT_REDIRECT = 308,
|
|
50
59
|
BAD_REQUEST = 400,
|
|
51
60
|
UNAUTHORIZED = 401,
|
|
52
61
|
PAYMENT_REQUIRED = 402,
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,13 @@ var HttpStatusCode = /* @__PURE__ */ ((HttpStatusCode2) => {
|
|
|
10
10
|
HttpStatusCode2[HttpStatusCode2["MULTI_STATUS"] = 207] = "MULTI_STATUS";
|
|
11
11
|
HttpStatusCode2[HttpStatusCode2["ALREADY_REPORTED"] = 208] = "ALREADY_REPORTED";
|
|
12
12
|
HttpStatusCode2[HttpStatusCode2["IM_USED"] = 226] = "IM_USED";
|
|
13
|
+
HttpStatusCode2[HttpStatusCode2["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
|
|
14
|
+
HttpStatusCode2[HttpStatusCode2["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
15
|
+
HttpStatusCode2[HttpStatusCode2["FOUND"] = 302] = "FOUND";
|
|
16
|
+
HttpStatusCode2[HttpStatusCode2["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
17
|
+
HttpStatusCode2[HttpStatusCode2["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
18
|
+
HttpStatusCode2[HttpStatusCode2["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
19
|
+
HttpStatusCode2[HttpStatusCode2["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
13
20
|
HttpStatusCode2[HttpStatusCode2["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
14
21
|
HttpStatusCode2[HttpStatusCode2["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
15
22
|
HttpStatusCode2[HttpStatusCode2["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
@@ -61,6 +68,13 @@ const HttpStatusCodeNameMap = {
|
|
|
61
68
|
[207 /* MULTI_STATUS */]: "MultiStatus",
|
|
62
69
|
[208 /* ALREADY_REPORTED */]: "AlreadyReported",
|
|
63
70
|
[226 /* IM_USED */]: "ImUsed",
|
|
71
|
+
[300 /* MULTIPLE_CHOICES */]: "MultipleChoices",
|
|
72
|
+
[301 /* MOVED_PERMANENTLY */]: "MovedPermanently",
|
|
73
|
+
[302 /* FOUND */]: "Found",
|
|
74
|
+
[303 /* SEE_OTHER */]: "SeeOther",
|
|
75
|
+
[304 /* NOT_MODIFIED */]: "NotModified",
|
|
76
|
+
[307 /* TEMPORARY_REDIRECT */]: "TemporaryRedirect",
|
|
77
|
+
[308 /* PERMANENT_REDIRECT */]: "PermanentRedirect",
|
|
64
78
|
[400 /* BAD_REQUEST */]: "BadRequest",
|
|
65
79
|
[401 /* UNAUTHORIZED */]: "Unauthorized",
|
|
66
80
|
[402 /* PAYMENT_REQUIRED */]: "PaymentRequired",
|
|
@@ -167,6 +181,9 @@ class HttpResponseDefinition {
|
|
|
167
181
|
body;
|
|
168
182
|
extend(definition) {
|
|
169
183
|
const mergedHeader = (() => {
|
|
184
|
+
if (this.header instanceof z.ZodRecord || definition.header instanceof z.ZodRecord || this.header instanceof z.ZodOptional && this.header.unwrap() instanceof z.ZodRecord || definition.header instanceof z.ZodOptional && definition.header.unwrap() instanceof z.ZodRecord) {
|
|
185
|
+
throw new Error("Cannot merge ZodRecord headers");
|
|
186
|
+
}
|
|
170
187
|
if (!this.header && !definition.header) return void 0;
|
|
171
188
|
if (!this.header) return definition.header;
|
|
172
189
|
if (!definition.header) return this.header;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexeus/typeweaver-core",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Runtime utilities and shared types to drive type-safe API definitions. Powered by Typeweaver 🧵✨",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
},
|
|
40
40
|
"homepage": "https://github.com/rexeus/typeweaver#readme",
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"zod": "^4.1.
|
|
42
|
+
"zod": "^4.1.11"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"zod": "^4.1.
|
|
45
|
+
"zod": "^4.1.11"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"typecheck": "tsc --noEmit",
|