@shware/http 1.0.5 → 1.0.6

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.
@@ -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
@@ -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,uBAA2B;AAC3B,qBAA6B;AAC7B,yBAA4B;AAC5B,wBAA2B;","names":[]}
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":[]}
@@ -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';
@@ -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';
@@ -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
@@ -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,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;","names":[]}
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":[]}
@@ -20,9 +20,12 @@ 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");
28
+ var import_v4 = require("zod/v4");
26
29
  var import_validator = require("hono/validator");
27
30
  var import_status = require("../status.cjs");
28
31
  var import_detail = require("../detail.cjs");
@@ -37,8 +40,26 @@ function zValidator(target, schema) {
37
40
  throw import_status.Status.invalidArgument().error(details);
38
41
  });
39
42
  }
43
+ var bigintId = (0, import_v4_mini.pipe)(
44
+ (0, import_v4_mini.string)(),
45
+ (0, import_v4_mini.transform)((input, ctx) => {
46
+ if (!/^(0|[1-9]\d{0,19})$/.test(input)) {
47
+ const message = `Invalid bigint id: ${input}`;
48
+ ctx.issues.push({ code: "custom", input, message });
49
+ return import_v4.NEVER;
50
+ }
51
+ try {
52
+ return BigInt(input);
53
+ } catch (_) {
54
+ const message = `Parse bigint id: ${input} failed`;
55
+ ctx.issues.push({ code: "custom", input, message });
56
+ return import_v4.NEVER;
57
+ }
58
+ })
59
+ );
40
60
  // Annotate the CommonJS export names for ESM import in node:
41
61
  0 && (module.exports = {
62
+ bigintId,
42
63
  zValidator
43
64
  });
44
65
  //# sourceMappingURL=validator.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hono/validator.ts"],"sourcesContent":["import type { output as outputV4, ZodType } from 'zod/v4';\nimport type { output as outputMini, ZodMiniType } from 'zod/v4-mini';\nimport type { ValidationTargets } from 'hono';\nimport { validator } from 'hono/validator';\nimport { Status } from '../status';\nimport { Details } from '../detail';\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAA0B;AAC1B,oBAAuB;AACvB,oBAAwB;AAGjB,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;","names":[]}
1
+ {"version":3,"sources":["../../src/hono/validator.ts"],"sourcesContent":["import { transform, pipe, string } from 'zod/v4-mini';\nimport { NEVER } from 'zod/v4';\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,qBAAwC;AACxC,gBAAsB;AACtB,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 };
@@ -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 };
@@ -1,4 +1,6 @@
1
1
  // src/hono/validator.ts
2
+ import { transform, pipe, string } from "zod/v4-mini";
3
+ import { NEVER } from "zod/v4";
2
4
  import { validator } from "hono/validator";
3
5
  import { Status } from "../status.mjs";
4
6
  import { Details } from "../detail.mjs";
@@ -13,7 +15,25 @@ function zValidator(target, schema) {
13
15
  throw Status.invalidArgument().error(details);
14
16
  });
15
17
  }
18
+ var bigintId = pipe(
19
+ string(),
20
+ transform((input, ctx) => {
21
+ if (!/^(0|[1-9]\d{0,19})$/.test(input)) {
22
+ const message = `Invalid bigint id: ${input}`;
23
+ ctx.issues.push({ code: "custom", input, message });
24
+ return NEVER;
25
+ }
26
+ try {
27
+ return BigInt(input);
28
+ } catch (_) {
29
+ const message = `Parse bigint id: ${input} failed`;
30
+ ctx.issues.push({ code: "custom", input, message });
31
+ return NEVER;
32
+ }
33
+ })
34
+ );
16
35
  export {
36
+ bigintId,
17
37
  zValidator
18
38
  };
19
39
  //# sourceMappingURL=validator.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hono/validator.ts"],"sourcesContent":["import type { output as outputV4, ZodType } from 'zod/v4';\nimport type { output as outputMini, ZodMiniType } from 'zod/v4-mini';\nimport type { ValidationTargets } from 'hono';\nimport { validator } from 'hono/validator';\nimport { Status } from '../status';\nimport { Details } from '../detail';\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"],"mappings":";AAGA,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,eAAe;AAGjB,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;","names":[]}
1
+ {"version":3,"sources":["../../src/hono/validator.ts"],"sourcesContent":["import { transform, pipe, string } from 'zod/v4-mini';\nimport { NEVER } from 'zod/v4';\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,cAAc;AACxC,SAAS,aAAa;AACtB,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.5",
3
+ "version": "1.0.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {