@shware/http 1.0.5 → 1.0.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.
- package/dist/hono/index.cjs +2 -0
- package/dist/hono/index.cjs.map +1 -1
- package/dist/hono/index.d.cts +2 -2
- package/dist/hono/index.d.ts +2 -2
- package/dist/hono/index.mjs +2 -1
- package/dist/hono/index.mjs.map +1 -1
- package/dist/hono/validator.cjs +20 -0
- package/dist/hono/validator.cjs.map +1 -1
- package/dist/hono/validator.d.cts +4 -2
- package/dist/hono/validator.d.ts +4 -2
- package/dist/hono/validator.mjs +19 -0
- package/dist/hono/validator.mjs.map +1 -1
- package/package.json +5 -5
package/dist/hono/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var hono_exports = {};
|
|
22
22
|
__export(hono_exports, {
|
|
23
23
|
Authorizer: () => import_authorizer.Authorizer,
|
|
24
|
+
bigintId: () => import_validator.bigintId,
|
|
24
25
|
errorHandler: () => import_handler.errorHandler,
|
|
25
26
|
geolocation: () => import_geolocation.geolocation,
|
|
26
27
|
zValidator: () => import_validator.zValidator
|
|
@@ -33,6 +34,7 @@ var import_authorizer = require("./authorizer.cjs");
|
|
|
33
34
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
35
|
0 && (module.exports = {
|
|
35
36
|
Authorizer,
|
|
37
|
+
bigintId,
|
|
36
38
|
errorHandler,
|
|
37
39
|
geolocation,
|
|
38
40
|
zValidator
|
package/dist/hono/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hono/index.ts"],"sourcesContent":["export { zValidator } from './validator';\nexport { errorHandler } from './handler';\nexport { geolocation } from './geolocation';\nexport { Authorizer } from './authorizer';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/hono/index.ts"],"sourcesContent":["export { zValidator, bigintId } from './validator';\nexport { errorHandler } from './handler';\nexport { geolocation } from './geolocation';\nexport { Authorizer } from './authorizer';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAqC;AACrC,qBAA6B;AAC7B,yBAA4B;AAC5B,wBAA2B;","names":[]}
|
package/dist/hono/index.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { zValidator } from './validator.cjs';
|
|
1
|
+
export { bigintId, zValidator } from './validator.cjs';
|
|
2
2
|
export { errorHandler } from './handler.cjs';
|
|
3
3
|
export { geolocation } from './geolocation.cjs';
|
|
4
4
|
export { Authorizer } from './authorizer.cjs';
|
|
5
|
+
import 'zod/v4-mini';
|
|
5
6
|
import 'hono/utils/headers';
|
|
6
7
|
import 'hono/types';
|
|
7
8
|
import 'hono';
|
|
8
9
|
import 'zod/v4/core';
|
|
9
10
|
import 'zod/v4';
|
|
10
|
-
import 'zod/v4-mini';
|
|
11
11
|
import 'hono/request-id';
|
|
12
12
|
import 'axios';
|
package/dist/hono/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { zValidator } from './validator.js';
|
|
1
|
+
export { bigintId, zValidator } from './validator.js';
|
|
2
2
|
export { errorHandler } from './handler.js';
|
|
3
3
|
export { geolocation } from './geolocation.js';
|
|
4
4
|
export { Authorizer } from './authorizer.js';
|
|
5
|
+
import 'zod/v4-mini';
|
|
5
6
|
import 'hono/utils/headers';
|
|
6
7
|
import 'hono/types';
|
|
7
8
|
import 'hono';
|
|
8
9
|
import 'zod/v4/core';
|
|
9
10
|
import 'zod/v4';
|
|
10
|
-
import 'zod/v4-mini';
|
|
11
11
|
import 'hono/request-id';
|
|
12
12
|
import 'axios';
|
package/dist/hono/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// src/hono/index.ts
|
|
2
|
-
import { zValidator } from "./validator.mjs";
|
|
2
|
+
import { zValidator, bigintId } from "./validator.mjs";
|
|
3
3
|
import { errorHandler } from "./handler.mjs";
|
|
4
4
|
import { geolocation } from "./geolocation.mjs";
|
|
5
5
|
import { Authorizer } from "./authorizer.mjs";
|
|
6
6
|
export {
|
|
7
7
|
Authorizer,
|
|
8
|
+
bigintId,
|
|
8
9
|
errorHandler,
|
|
9
10
|
geolocation,
|
|
10
11
|
zValidator
|
package/dist/hono/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hono/index.ts"],"sourcesContent":["export { zValidator } from './validator';\nexport { errorHandler } from './handler';\nexport { geolocation } from './geolocation';\nexport { Authorizer } from './authorizer';\n"],"mappings":";AAAA,SAAS,
|
|
1
|
+
{"version":3,"sources":["../../src/hono/index.ts"],"sourcesContent":["export { zValidator, bigintId } from './validator';\nexport { errorHandler } from './handler';\nexport { geolocation } from './geolocation';\nexport { Authorizer } from './authorizer';\n"],"mappings":";AAAA,SAAS,YAAY,gBAAgB;AACrC,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;","names":[]}
|
package/dist/hono/validator.cjs
CHANGED
|
@@ -20,9 +20,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/hono/validator.ts
|
|
21
21
|
var validator_exports = {};
|
|
22
22
|
__export(validator_exports, {
|
|
23
|
+
bigintId: () => bigintId,
|
|
23
24
|
zValidator: () => zValidator
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(validator_exports);
|
|
27
|
+
var import_v4_mini = require("zod/v4-mini");
|
|
26
28
|
var import_validator = require("hono/validator");
|
|
27
29
|
var import_status = require("../status.cjs");
|
|
28
30
|
var import_detail = require("../detail.cjs");
|
|
@@ -37,8 +39,26 @@ function zValidator(target, schema) {
|
|
|
37
39
|
throw import_status.Status.invalidArgument().error(details);
|
|
38
40
|
});
|
|
39
41
|
}
|
|
42
|
+
var bigintId = (0, import_v4_mini.pipe)(
|
|
43
|
+
(0, import_v4_mini.string)(),
|
|
44
|
+
(0, import_v4_mini.transform)((input, ctx) => {
|
|
45
|
+
if (!/^(0|[1-9]\d{0,19})$/.test(input)) {
|
|
46
|
+
const message = `Invalid bigint id: ${input}`;
|
|
47
|
+
ctx.issues.push({ code: "custom", input, message });
|
|
48
|
+
return import_v4_mini.NEVER;
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
return BigInt(input);
|
|
52
|
+
} catch (_) {
|
|
53
|
+
const message = `Parse bigint id: ${input} failed`;
|
|
54
|
+
ctx.issues.push({ code: "custom", input, message });
|
|
55
|
+
return import_v4_mini.NEVER;
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
);
|
|
40
59
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41
60
|
0 && (module.exports = {
|
|
61
|
+
bigintId,
|
|
42
62
|
zValidator
|
|
43
63
|
});
|
|
44
64
|
//# sourceMappingURL=validator.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hono/validator.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../src/hono/validator.ts"],"sourcesContent":["import { transform, pipe, string, NEVER } from 'zod/v4-mini';\nimport { validator } from 'hono/validator';\nimport { Status } from '../status';\nimport { Details } from '../detail';\nimport type { ValidationTargets } from 'hono';\nimport type { output as outputV4, ZodType } from 'zod/v4';\nimport type { output as outputMini, ZodMiniType } from 'zod/v4-mini';\nimport type { BadRequest } from '../detail';\n\nexport function zValidator<S extends ZodType | ZodMiniType>(\n target: keyof ValidationTargets,\n schema: S\n) {\n return validator(target, async (value) => {\n const result = await schema.safeParseAsync(value);\n if (result.success) return result.data as S extends ZodType ? outputV4<S> : outputMini<S>;\n\n const fieldViolations: BadRequest['fieldViolations'] = result.error.issues.map(\n ({ path, message }) => ({ field: path.join('.'), description: message })\n );\n const details = Details.new().badRequest({ fieldViolations });\n throw Status.invalidArgument().error(details);\n });\n}\n\nexport const bigintId = pipe(\n string(),\n transform((input, ctx) => {\n if (!/^(0|[1-9]\\d{0,19})$/.test(input)) {\n const message = `Invalid bigint id: ${input}`;\n ctx.issues.push({ code: 'custom', input, message });\n return NEVER;\n }\n try {\n return BigInt(input);\n } catch (_) {\n const message = `Parse bigint id: ${input} failed`;\n ctx.issues.push({ code: 'custom', input, message });\n return NEVER;\n }\n })\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+C;AAC/C,uBAA0B;AAC1B,oBAAuB;AACvB,oBAAwB;AAMjB,SAAS,WACd,QACA,QACA;AACA,aAAO,4BAAU,QAAQ,OAAO,UAAU;AACxC,UAAM,SAAS,MAAM,OAAO,eAAe,KAAK;AAChD,QAAI,OAAO,QAAS,QAAO,OAAO;AAElC,UAAM,kBAAiD,OAAO,MAAM,OAAO;AAAA,MACzE,CAAC,EAAE,MAAM,QAAQ,OAAO,EAAE,OAAO,KAAK,KAAK,GAAG,GAAG,aAAa,QAAQ;AAAA,IACxE;AACA,UAAM,UAAU,sBAAQ,IAAI,EAAE,WAAW,EAAE,gBAAgB,CAAC;AAC5D,UAAM,qBAAO,gBAAgB,EAAE,MAAM,OAAO;AAAA,EAC9C,CAAC;AACH;AAEO,IAAM,eAAW;AAAA,MACtB,uBAAO;AAAA,MACP,0BAAU,CAAC,OAAO,QAAQ;AACxB,QAAI,CAAC,sBAAsB,KAAK,KAAK,GAAG;AACtC,YAAM,UAAU,sBAAsB,KAAK;AAC3C,UAAI,OAAO,KAAK,EAAE,MAAM,UAAU,OAAO,QAAQ,CAAC;AAClD,aAAO;AAAA,IACT;AACA,QAAI;AACF,aAAO,OAAO,KAAK;AAAA,IACrB,SAAS,GAAG;AACV,YAAM,UAAU,oBAAoB,KAAK;AACzC,UAAI,OAAO,KAAK,EAAE,MAAM,UAAU,OAAO,QAAQ,CAAC;AAClD,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import * as zod_v4_mini from 'zod/v4-mini';
|
|
2
|
+
import { ZodMiniType } from 'zod/v4-mini';
|
|
1
3
|
import * as hono_utils_headers from 'hono/utils/headers';
|
|
2
4
|
import * as hono_types from 'hono/types';
|
|
3
5
|
import * as hono from 'hono';
|
|
4
6
|
import { ValidationTargets } from 'hono';
|
|
5
7
|
import * as zod_v4_core from 'zod/v4/core';
|
|
6
8
|
import { ZodType, output } from 'zod/v4';
|
|
7
|
-
import { ZodMiniType } from 'zod/v4-mini';
|
|
8
9
|
|
|
9
10
|
declare function zValidator<S extends ZodType | ZodMiniType>(target: keyof ValidationTargets, schema: S): hono.MiddlewareHandler<any, string, {
|
|
10
11
|
in: {
|
|
@@ -24,5 +25,6 @@ declare function zValidator<S extends ZodType | ZodMiniType>(target: keyof Valid
|
|
|
24
25
|
cookie: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_16 ? T_16 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_16 extends Response & hono.TypedResponse<any> ? never : T_16 : never : never;
|
|
25
26
|
};
|
|
26
27
|
}>;
|
|
28
|
+
declare const bigintId: zod_v4_mini.ZodMiniPipe<zod_v4_mini.ZodMiniString<string>, zod_v4_mini.ZodMiniTransform<bigint, string>>;
|
|
27
29
|
|
|
28
|
-
export { zValidator };
|
|
30
|
+
export { bigintId, zValidator };
|
package/dist/hono/validator.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import * as zod_v4_mini from 'zod/v4-mini';
|
|
2
|
+
import { ZodMiniType } from 'zod/v4-mini';
|
|
1
3
|
import * as hono_utils_headers from 'hono/utils/headers';
|
|
2
4
|
import * as hono_types from 'hono/types';
|
|
3
5
|
import * as hono from 'hono';
|
|
4
6
|
import { ValidationTargets } from 'hono';
|
|
5
7
|
import * as zod_v4_core from 'zod/v4/core';
|
|
6
8
|
import { ZodType, output } from 'zod/v4';
|
|
7
|
-
import { ZodMiniType } from 'zod/v4-mini';
|
|
8
9
|
|
|
9
10
|
declare function zValidator<S extends ZodType | ZodMiniType>(target: keyof ValidationTargets, schema: S): hono.MiddlewareHandler<any, string, {
|
|
10
11
|
in: {
|
|
@@ -24,5 +25,6 @@ declare function zValidator<S extends ZodType | ZodMiniType>(target: keyof Valid
|
|
|
24
25
|
cookie: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_16 ? T_16 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_16 extends Response & hono.TypedResponse<any> ? never : T_16 : never : never;
|
|
25
26
|
};
|
|
26
27
|
}>;
|
|
28
|
+
declare const bigintId: zod_v4_mini.ZodMiniPipe<zod_v4_mini.ZodMiniString<string>, zod_v4_mini.ZodMiniTransform<bigint, string>>;
|
|
27
29
|
|
|
28
|
-
export { zValidator };
|
|
30
|
+
export { bigintId, zValidator };
|
package/dist/hono/validator.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/hono/validator.ts
|
|
2
|
+
import { transform, pipe, string, NEVER } from "zod/v4-mini";
|
|
2
3
|
import { validator } from "hono/validator";
|
|
3
4
|
import { Status } from "../status.mjs";
|
|
4
5
|
import { Details } from "../detail.mjs";
|
|
@@ -13,7 +14,25 @@ function zValidator(target, schema) {
|
|
|
13
14
|
throw Status.invalidArgument().error(details);
|
|
14
15
|
});
|
|
15
16
|
}
|
|
17
|
+
var bigintId = pipe(
|
|
18
|
+
string(),
|
|
19
|
+
transform((input, ctx) => {
|
|
20
|
+
if (!/^(0|[1-9]\d{0,19})$/.test(input)) {
|
|
21
|
+
const message = `Invalid bigint id: ${input}`;
|
|
22
|
+
ctx.issues.push({ code: "custom", input, message });
|
|
23
|
+
return NEVER;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
return BigInt(input);
|
|
27
|
+
} catch (_) {
|
|
28
|
+
const message = `Parse bigint id: ${input} failed`;
|
|
29
|
+
ctx.issues.push({ code: "custom", input, message });
|
|
30
|
+
return NEVER;
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
);
|
|
16
34
|
export {
|
|
35
|
+
bigintId,
|
|
17
36
|
zValidator
|
|
18
37
|
};
|
|
19
38
|
//# sourceMappingURL=validator.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hono/validator.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../src/hono/validator.ts"],"sourcesContent":["import { transform, pipe, string, NEVER } from 'zod/v4-mini';\nimport { validator } from 'hono/validator';\nimport { Status } from '../status';\nimport { Details } from '../detail';\nimport type { ValidationTargets } from 'hono';\nimport type { output as outputV4, ZodType } from 'zod/v4';\nimport type { output as outputMini, ZodMiniType } from 'zod/v4-mini';\nimport type { BadRequest } from '../detail';\n\nexport function zValidator<S extends ZodType | ZodMiniType>(\n target: keyof ValidationTargets,\n schema: S\n) {\n return validator(target, async (value) => {\n const result = await schema.safeParseAsync(value);\n if (result.success) return result.data as S extends ZodType ? outputV4<S> : outputMini<S>;\n\n const fieldViolations: BadRequest['fieldViolations'] = result.error.issues.map(\n ({ path, message }) => ({ field: path.join('.'), description: message })\n );\n const details = Details.new().badRequest({ fieldViolations });\n throw Status.invalidArgument().error(details);\n });\n}\n\nexport const bigintId = pipe(\n string(),\n transform((input, ctx) => {\n if (!/^(0|[1-9]\\d{0,19})$/.test(input)) {\n const message = `Invalid bigint id: ${input}`;\n ctx.issues.push({ code: 'custom', input, message });\n return NEVER;\n }\n try {\n return BigInt(input);\n } catch (_) {\n const message = `Parse bigint id: ${input} failed`;\n ctx.issues.push({ code: 'custom', input, message });\n return NEVER;\n }\n })\n);\n"],"mappings":";AAAA,SAAS,WAAW,MAAM,QAAQ,aAAa;AAC/C,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,eAAe;AAMjB,SAAS,WACd,QACA,QACA;AACA,SAAO,UAAU,QAAQ,OAAO,UAAU;AACxC,UAAM,SAAS,MAAM,OAAO,eAAe,KAAK;AAChD,QAAI,OAAO,QAAS,QAAO,OAAO;AAElC,UAAM,kBAAiD,OAAO,MAAM,OAAO;AAAA,MACzE,CAAC,EAAE,MAAM,QAAQ,OAAO,EAAE,OAAO,KAAK,KAAK,GAAG,GAAG,aAAa,QAAQ;AAAA,IACxE;AACA,UAAM,UAAU,QAAQ,IAAI,EAAE,WAAW,EAAE,gBAAgB,CAAC;AAC5D,UAAM,OAAO,gBAAgB,EAAE,MAAM,OAAO;AAAA,EAC9C,CAAC;AACH;AAEO,IAAM,WAAW;AAAA,EACtB,OAAO;AAAA,EACP,UAAU,CAAC,OAAO,QAAQ;AACxB,QAAI,CAAC,sBAAsB,KAAK,KAAK,GAAG;AACtC,YAAM,UAAU,sBAAsB,KAAK;AAC3C,UAAI,OAAO,KAAK,EAAE,MAAM,UAAU,OAAO,QAAQ,CAAC;AAClD,aAAO;AAAA,IACT;AACA,QAAI;AACF,aAAO,OAAO,KAAK;AAAA,IACrB,SAAS,GAAG;AACV,YAAM,UAAU,oBAAoB,KAAK;AACzC,UAAI,OAAO,KAAK,EAAE,MAAM,UAAU,OAAO,QAAQ,CAAC;AAClD,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shware/http",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
"dist"
|
|
44
44
|
],
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@types/jest": "^
|
|
47
|
-
"@types/node": "^24.0.
|
|
46
|
+
"@types/jest": "^30.0.0",
|
|
47
|
+
"@types/node": "^24.0.10",
|
|
48
48
|
"@types/react": "^19.1.8",
|
|
49
|
-
"jest": "^30.0.
|
|
49
|
+
"jest": "^30.0.4",
|
|
50
50
|
"ts-jest": "^29.4.0",
|
|
51
51
|
"typescript": "^5.8.3"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"zod": "^3.25.
|
|
54
|
+
"zod": "^3.25.71"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"axios": "^1.10.0",
|