@open-norantec/utilities 2.10.1 → 2.11.0-beta.128.3

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.
@@ -1,6 +1,6 @@
1
1
  import { Context, ExecutionContext, Hono } from 'hono';
2
2
  import { z } from './zod';
3
- import { Bindings as BindingsType } from 'hono/types';
3
+ import { Bindings as BindingsType, Variables } from 'hono/types';
4
4
  import { Constructor, PartialDeep } from 'type-fest';
5
5
  import { ContentfulStatusCode } from 'hono/utils/http-status';
6
6
  import { OpenAPIObject } from 'openapi3-ts/oas31';
@@ -14,7 +14,7 @@ export declare class StatusError extends Error {
14
14
  }
15
15
  type BaseContext<Bindings extends BindingsType, SS extends z.ZodObject> = {
16
16
  env: Bindings;
17
- executionCtx: ExecutionContext;
17
+ executionCtx: ExecutionContext | null;
18
18
  headers: Record<string, string>;
19
19
  storage: z.infer<SS>;
20
20
  queries: Context['req']['queries'];
@@ -66,8 +66,11 @@ export declare class HonoUtil {
66
66
  authenticationTypes?: A;
67
67
  operationId?: string;
68
68
  }, handler: (context: HandlerContext<IS, Bindings, SS, A, HWR, GC>) => Promise<z.infer<OS>>) => void;
69
- getApp: () => Hono<{
69
+ getApp: <V extends Variables = object>({ version }: {
70
+ version?: string;
71
+ }) => Hono<{
70
72
  Bindings: Bindings;
73
+ Variables: V;
71
74
  }, import("hono/types").BlankSchema, "/">;
72
75
  };
73
76
  }
@@ -63,14 +63,14 @@ class HonoUtil {
63
63
  register: function (pathname, options, handler) {
64
64
  config[pathname] = Object.assign(Object.assign({}, options), { handler, authenticationTypes: Array.isArray(options === null || options === void 0 ? void 0 : options.authenticationTypes) ? options.authenticationTypes : [] });
65
65
  },
66
- getApp: function () {
66
+ getApp: function ({ version }) {
67
67
  const app = new hono_1.Hono();
68
68
  const hookContext = { use: app.use.bind(app) };
69
69
  const openAPIDocument = _.merge({
70
70
  openapi: '3.1.0',
71
71
  info: {
72
72
  title: 'API Documentation',
73
- version: '1.0.0',
73
+ version: version || '1.0.0',
74
74
  },
75
75
  paths: {},
76
76
  }, _.omit(openAPIObject, ['paths']));
@@ -115,15 +115,18 @@ class HonoUtil {
115
115
  const input = typeof inputSchema === 'string' ? c.req.raw.body.getReader() : inputSchema.parse(yield c.req.json());
116
116
  const headers = c.req.header();
117
117
  const baseContext = {
118
- headers,
119
118
  env: c.env,
120
- executionCtx: c.executionCtx,
119
+ executionCtx: (() => {
120
+ const executionCtx = _.attempt(() => c.executionCtx);
121
+ return executionCtx instanceof Error ? null : executionCtx;
122
+ })(),
123
+ headers,
124
+ queries: c.req.queries.bind(c.req),
125
+ query: c.req.query.bind(c.req),
121
126
  storage: storageSchema.parse(Object.keys(storageSchema.shape).reduce((result, key) => {
122
127
  result[key] = c.get(key);
123
128
  return result;
124
129
  }, {})),
125
- query: c.req.query.bind(c.req),
126
- queries: c.req.queries.bind(c.req),
127
130
  };
128
131
  const authenticateResult = yield attempt_util_class_1.AttemptUtil.execPromise((() => __awaiter(this, void 0, void 0, function* () {
129
132
  let authenticationValue = null;
package/package.json CHANGED
@@ -1,71 +1,71 @@
1
1
  {
2
- "name": "@open-norantec/utilities",
3
- "version": "2.10.1",
4
- "description": "NoranTec Utilities",
5
- "main": "dist/index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1",
8
- "build:cjs": "rimraf dist && tsc -b",
9
- "build": "npm run build:cjs",
10
- "setup:exec": "node bin/nttc.js setup",
11
- "setup": "npm run build && node bin/nttc.js setup"
2
+ "name": "@open-norantec/utilities",
3
+ "version": "2.11.0-beta.128.3",
4
+ "description": "NoranTec Utilities",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "build:cjs": "rimraf dist && tsc -b",
9
+ "build": "npm run build:cjs",
10
+ "setup:exec": "node bin/nttc.js setup",
11
+ "setup": "npm run build && node bin/nttc.js setup"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+ssh://git@github.com/norantec/utilities.git"
16
+ },
17
+ "author": "lenconda <i@lenconda.top>",
18
+ "bugs": {
19
+ "url": "https://github.com/norantec/utilities/issues"
20
+ },
21
+ "files": [
22
+ "bin",
23
+ "dist",
24
+ "LICENSE",
25
+ "README.md"
26
+ ],
27
+ "type": "commonjs",
28
+ "publishConfig": {
29
+ "access": "public",
30
+ "registry": "https://registry.npmjs.org"
31
+ },
32
+ "homepage": "https://github.com/norantec/utilities#readme",
33
+ "devDependencies": {
34
+ "@types/colors": "^1.1.3",
35
+ "@types/lodash": "^4.17.25",
36
+ "@types/node": "18.11.18",
37
+ "cross-env": "^7.0.3",
38
+ "eslint": "^10.3.0",
39
+ "hono": "^4.13.2",
40
+ "octokit": "^5.0.5",
41
+ "rimraf": "^6.0.1",
42
+ "ts-node": "^10.0.0",
43
+ "type-fest": "^4.37.0",
44
+ "typescript": "^6.0.3"
45
+ },
46
+ "dependencies": {
47
+ "@stylistic/eslint-plugin": "5.10.0",
48
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
49
+ "@typescript-eslint/parser": "^8.0.0",
50
+ "colors": "^1.4.0",
51
+ "eslint-config-prettier": "^10.0.0",
52
+ "eslint-plugin-prettier": "^5.0.0",
53
+ "lodash": "^4.18.1",
54
+ "openapi3-ts": "^4.6.1",
55
+ "prettier": "^3.0.0",
56
+ "uuid": "^11.1.0",
57
+ "zod": "^4.4.3"
58
+ },
59
+ "peerDependencies": {
60
+ "octokit": ">=5.0.0",
61
+ "hono": ">=4.0.0"
62
+ },
63
+ "peerDependenciesMeta": {
64
+ "octokit": {
65
+ "optional": true
12
66
  },
13
- "repository": {
14
- "type": "git",
15
- "url": "git+ssh://git@github.com/norantec/utilities.git"
16
- },
17
- "author": "lenconda <i@lenconda.top>",
18
- "bugs": {
19
- "url": "https://github.com/norantec/utilities/issues"
20
- },
21
- "files": [
22
- "bin",
23
- "dist",
24
- "LICENSE",
25
- "README.md"
26
- ],
27
- "type": "commonjs",
28
- "publishConfig": {
29
- "access": "public",
30
- "registry": "https://registry.npmjs.org"
31
- },
32
- "homepage": "https://github.com/norantec/utilities#readme",
33
- "devDependencies": {
34
- "@types/colors": "^1.1.3",
35
- "@types/lodash": "^4.17.25",
36
- "@types/node": "18.11.18",
37
- "cross-env": "^7.0.3",
38
- "eslint": "^10.3.0",
39
- "hono": "^4.13.2",
40
- "octokit": "^5.0.5",
41
- "rimraf": "^6.0.1",
42
- "ts-node": "^10.0.0",
43
- "type-fest": "^4.37.0",
44
- "typescript": "^6.0.3"
45
- },
46
- "dependencies": {
47
- "@stylistic/eslint-plugin": "5.10.0",
48
- "@typescript-eslint/eslint-plugin": "^8.0.0",
49
- "@typescript-eslint/parser": "^8.0.0",
50
- "colors": "^1.4.0",
51
- "eslint-config-prettier": "^10.0.0",
52
- "eslint-plugin-prettier": "^5.0.0",
53
- "lodash": "^4.18.1",
54
- "openapi3-ts": "^4.6.1",
55
- "prettier": "^3.0.0",
56
- "uuid": "^11.1.0",
57
- "zod": "^4.4.3"
58
- },
59
- "peerDependencies": {
60
- "octokit": ">=5.0.0",
61
- "hono": ">=4.0.0"
62
- },
63
- "peerDependenciesMeta": {
64
- "octokit": {
65
- "optional": true
66
- },
67
- "hono": {
68
- "optional": true
69
- }
67
+ "hono": {
68
+ "optional": true
70
69
  }
70
+ }
71
71
  }