@open-norantec/utilities 2.6.1 → 2.7.0
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.
|
@@ -26,7 +26,7 @@ type AuthenticationMethodMap<Bindings extends BindingsType, SS extends z.ZodObje
|
|
|
26
26
|
type AuthKey<AMM extends AuthenticationMethodMap<{}, z.ZodObject>> = Extract<keyof AMM, string>;
|
|
27
27
|
type HandlerContext<IS extends HTTPBodyType, Bindings extends BindingsType, SS extends z.ZodObject, A extends Array<keyof AuthenticationMethodMap<Bindings, SS>>> = BaseContext<Bindings, SS> & {
|
|
28
28
|
authentication: A extends [] ? null : A[number];
|
|
29
|
-
|
|
29
|
+
identifier: string;
|
|
30
30
|
input: IS extends string ? ReadableStreamDefaultReader<Uint8Array> : z.infer<IS>;
|
|
31
31
|
};
|
|
32
32
|
interface HookContext {
|
|
@@ -42,7 +42,12 @@ export declare class HonoUtil {
|
|
|
42
42
|
onAfterSetRoutes?: (context: HookContext) => void;
|
|
43
43
|
onBeforeSetRoutes?: (context: HookContext) => void;
|
|
44
44
|
}) => {
|
|
45
|
-
register: <IS extends HTTPBodyType, OS extends HTTPBodyType, const A extends Array<AuthKey<AMM>>>(pathname: string,
|
|
45
|
+
register: <IS extends HTTPBodyType, OS extends HTTPBodyType, const A extends Array<AuthKey<AMM>>>(pathname: string, options: {
|
|
46
|
+
inputSchema: IS;
|
|
47
|
+
outputSchema: OS;
|
|
48
|
+
authenticationTypes?: A;
|
|
49
|
+
operatorId?: string;
|
|
50
|
+
}, handler: (context: HandlerContext<IS, Bindings, SS, A>) => Promise<z.infer<OS>>) => void;
|
|
46
51
|
getApp: () => Hono<{
|
|
47
52
|
Bindings: Bindings;
|
|
48
53
|
}, import("hono/types").BlankSchema, "/">;
|
package/dist/hono-util.class.js
CHANGED
|
@@ -60,13 +60,8 @@ class HonoUtil {
|
|
|
60
60
|
return function ({ storageSchema, openAPIObject = {}, openAPIPath = '/openapi', openAPIPrefix = '', authenticationMethods, onAfterSetRoutes, onBeforeSetRoutes, }) {
|
|
61
61
|
const config = {};
|
|
62
62
|
return {
|
|
63
|
-
register: function (pathname,
|
|
64
|
-
config[pathname] = {
|
|
65
|
-
inputSchema,
|
|
66
|
-
outputSchema,
|
|
67
|
-
authenticationTypes,
|
|
68
|
-
handler,
|
|
69
|
-
};
|
|
63
|
+
register: function (pathname, options, handler) {
|
|
64
|
+
config[pathname] = Object.assign(Object.assign({}, options), { handler, authenticationTypes: Array.isArray(options === null || options === void 0 ? void 0 : options.authenticationTypes) ? options.authenticationTypes : [] });
|
|
70
65
|
},
|
|
71
66
|
getApp: function () {
|
|
72
67
|
const app = new hono_1.Hono();
|
|
@@ -155,7 +150,7 @@ class HonoUtil {
|
|
|
155
150
|
return c.json({ error: authenticateResult.message }, authenticateResult instanceof StatusError ? authenticateResult.status : 400);
|
|
156
151
|
}
|
|
157
152
|
const { authentication, authenticationValue } = authenticateResult;
|
|
158
|
-
const rawOutput = yield attempt_util_class_1.AttemptUtil.execPromise(handler(Object.assign({ input, authentication: authentication, authenticationValue }, baseContext)));
|
|
153
|
+
const rawOutput = yield attempt_util_class_1.AttemptUtil.execPromise(handler(Object.assign({ input, authentication: authentication, identifier: authenticationValue }, baseContext)));
|
|
159
154
|
if (rawOutput instanceof Error) {
|
|
160
155
|
console.log('Handler error', rawOutput, rawOutput === null || rawOutput === void 0 ? void 0 : rawOutput.message, rawOutput === null || rawOutput === void 0 ? void 0 : rawOutput.stack);
|
|
161
156
|
return c.json({ error: rawOutput.message }, rawOutput instanceof StatusError ? rawOutput.status : 400);
|