@gnosticdev/hono-actions 1.0.4 → 1.0.10
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/README.md +17 -3
- package/dist/actions.d.ts +138 -0
- package/dist/actions.js +88 -0
- package/dist/index.d.ts +19 -133
- package/dist/index.js +2287 -105
- package/package.json +16 -27
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ All other dependencies (`hono`, `valibot`, `@hono/valibot-validator`, etc.) are
|
|
|
27
27
|
```typescript
|
|
28
28
|
// astro.config.ts
|
|
29
29
|
import { defineConfig } from 'astro/config'
|
|
30
|
-
import honoActions from '@gnosticdev/hono-actions'
|
|
30
|
+
import honoActions from '@gnosticdev/hono-actions/integration'
|
|
31
31
|
|
|
32
32
|
export default defineConfig({
|
|
33
33
|
integrations: [
|
|
@@ -52,7 +52,7 @@ Create a file at one of these locations (the integration will auto-discover):
|
|
|
52
52
|
|
|
53
53
|
```typescript
|
|
54
54
|
// src/server/actions.ts
|
|
55
|
-
import { defineHonoAction,
|
|
55
|
+
import { defineHonoAction, HonoActionError } from '@gnosticdev/hono-actions'
|
|
56
56
|
import * as v from 'valibot'
|
|
57
57
|
|
|
58
58
|
// Define a simple action
|
|
@@ -88,7 +88,10 @@ export const errorAction = defineHonoAction({
|
|
|
88
88
|
path: '/error',
|
|
89
89
|
handler: async (input, ctx) => {
|
|
90
90
|
if (someCondition) {
|
|
91
|
-
throw new
|
|
91
|
+
throw new HonoActionError({
|
|
92
|
+
message: 'Custom error message',
|
|
93
|
+
code: 'EXTERNAL_API_ERROR'
|
|
94
|
+
})
|
|
92
95
|
}
|
|
93
96
|
return { success: true }
|
|
94
97
|
}
|
|
@@ -151,6 +154,17 @@ const handleSubmit = async (formData: FormData) => {
|
|
|
151
154
|
}
|
|
152
155
|
```
|
|
153
156
|
|
|
157
|
+
## Package Structure
|
|
158
|
+
|
|
159
|
+
This package provides two main entry points:
|
|
160
|
+
|
|
161
|
+
- **`@gnosticdev/hono-actions`** (default): Action definition utilities (`defineHonoAction`, `HonoActionError`, types)
|
|
162
|
+
- Safe for browser environments
|
|
163
|
+
- Used in your action files and client-side code
|
|
164
|
+
- **`@gnosticdev/hono-actions/integration`**: Astro integration
|
|
165
|
+
- Uses Node.js built-ins (fs, path)
|
|
166
|
+
- Only used in `astro.config.ts`
|
|
167
|
+
|
|
154
168
|
## Configuration Options
|
|
155
169
|
|
|
156
170
|
The integration accepts the following options:
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import * as hono_hono_base from 'hono/hono-base';
|
|
2
|
+
import * as hono_utils_types from 'hono/utils/types';
|
|
3
|
+
import * as hono_types from 'hono/types';
|
|
4
|
+
import { Context } from 'hono';
|
|
5
|
+
import * as v from 'valibot';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Standard error codes for actions
|
|
9
|
+
*/
|
|
10
|
+
type ActionErrorCode = 'INPUT_VALIDATION_ERROR' | 'EXTERNAL_API_ERROR' | 'INTERNAL_SERVER_ERROR' | 'UNKNOWN_ERROR' | 'LOCATION_NOT_FOUND' | 'SESSION_NOT_FOUND';
|
|
11
|
+
declare class HonoActionError<TSchema extends v.ObjectSchema<v.ObjectEntries, v.ErrorMessage<v.ObjectIssue> | undefined>, TMessage extends string, TCode extends ActionErrorCode, TIssue extends v.InferIssue<TSchema>> extends Error {
|
|
12
|
+
code: TCode;
|
|
13
|
+
issue?: TIssue;
|
|
14
|
+
constructor({ message, code, issue, }: {
|
|
15
|
+
message: TMessage;
|
|
16
|
+
code: TCode;
|
|
17
|
+
issue?: TIssue;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface Bindings {
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* HonoEnv is passed to the Hono context to provide types on `ctx.env`.
|
|
25
|
+
*
|
|
26
|
+
* We are using `HonoEnv` to avoid confusion with the Cloudflare types on `Env` -> which cooresponds to `Bindings`
|
|
27
|
+
*/
|
|
28
|
+
interface HonoEnv {
|
|
29
|
+
Bindings: Bindings;
|
|
30
|
+
Variables: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
type HonoActionSchema = v.ObjectSchema<v.ObjectEntries, v.ErrorMessage<v.ObjectIssue> | undefined> | v.NeverSchema<undefined>;
|
|
33
|
+
interface HonoActionContext<TEnv extends HonoEnv, TPath extends string, TSchema extends HonoActionSchema> extends Context<TEnv, TPath, {
|
|
34
|
+
input: v.InferInput<TSchema>;
|
|
35
|
+
output: v.InferOutput<TSchema>;
|
|
36
|
+
outputFormat: 'json';
|
|
37
|
+
}> {
|
|
38
|
+
env: TEnv['Bindings'];
|
|
39
|
+
}
|
|
40
|
+
type HonoActionParams<TPath extends string, TSchema extends HonoActionSchema, TReturn, TEnv extends HonoEnv = HonoEnv> = {
|
|
41
|
+
path: TPath;
|
|
42
|
+
schema?: TSchema;
|
|
43
|
+
handler: (params: v.InferOutput<TSchema>, context: HonoActionContext<TEnv, TPath, TSchema>) => Promise<TReturn>;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Defines a type-safe Hono action using Valibot for input validation.
|
|
47
|
+
*
|
|
48
|
+
* @param path - The path of the action.
|
|
49
|
+
* @param schema - The object schema for Valibot validation.
|
|
50
|
+
* @default never
|
|
51
|
+
* @param handler - The handler function for the action.
|
|
52
|
+
* @returns A Hono app instance with the defined route
|
|
53
|
+
*/
|
|
54
|
+
declare function defineHonoAction<TPath extends string, TSchema extends HonoActionSchema, TReturn, TEnv extends HonoEnv = HonoEnv>({ path, schema, handler }: HonoActionParams<TPath, TSchema, TReturn, TEnv>): hono_hono_base.HonoBase<TEnv, { [K in hono_types.MergePath<"/", TPath>]: {
|
|
55
|
+
$post: {
|
|
56
|
+
input: hono_types.AddParam<unknown extends ((undefined extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? true : false) extends true ? {
|
|
57
|
+
json?: (v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> extends infer T_1 ? T_1 extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? T_1 extends any ? T_1 : { [K2 in keyof T_1]?: any; } : never : never) | undefined;
|
|
58
|
+
} : {
|
|
59
|
+
json: v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> extends infer T_2 ? T_2 extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? T_2 extends any ? T_2 : { [K2_1 in keyof T_2]: any; } : never : never;
|
|
60
|
+
}) ? {} : (undefined extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? true : false) extends true ? {
|
|
61
|
+
json?: (v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> extends infer T_3 ? T_3 extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? T_3 extends any ? T_3 : { [K2_2 in keyof T_3]?: any; } : never : never) | undefined;
|
|
62
|
+
} : {
|
|
63
|
+
json: v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> extends infer T_4 ? T_4 extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? T_4 extends any ? T_4 : { [K2_3 in keyof T_4]: any; } : never : never;
|
|
64
|
+
}, hono_types.MergePath<"/", TPath>>;
|
|
65
|
+
output: unknown extends ({
|
|
66
|
+
data: Awaited<TReturn>;
|
|
67
|
+
error: null;
|
|
68
|
+
} extends hono_utils_types.JSONValue ? { [K_2 in keyof {
|
|
69
|
+
data: Awaited<TReturn>;
|
|
70
|
+
error: null;
|
|
71
|
+
} as ({
|
|
72
|
+
data: Awaited<TReturn>;
|
|
73
|
+
error: null;
|
|
74
|
+
}[K_2] extends infer T_5 ? T_5 extends {
|
|
75
|
+
data: Awaited<TReturn>;
|
|
76
|
+
error: null;
|
|
77
|
+
}[K_2] ? T_5 extends hono_utils_types.InvalidJSONValue ? true : false : never : never) extends true ? never : K_2]: boolean extends ({
|
|
78
|
+
data: Awaited<TReturn>;
|
|
79
|
+
error: null;
|
|
80
|
+
}[K_2] extends infer T_6 ? T_6 extends {
|
|
81
|
+
data: Awaited<TReturn>;
|
|
82
|
+
error: null;
|
|
83
|
+
}[K_2] ? T_6 extends hono_utils_types.InvalidJSONValue ? true : false : never : never) ? hono_utils_types.JSONParsed<{
|
|
84
|
+
data: Awaited<TReturn>;
|
|
85
|
+
error: null;
|
|
86
|
+
}[K_2]> | undefined : hono_utils_types.JSONParsed<{
|
|
87
|
+
data: Awaited<TReturn>;
|
|
88
|
+
error: null;
|
|
89
|
+
}[K_2]>; } : never) ? {} : {
|
|
90
|
+
data: Awaited<TReturn>;
|
|
91
|
+
error: null;
|
|
92
|
+
} extends hono_utils_types.JSONValue ? { [K_2 in keyof {
|
|
93
|
+
data: Awaited<TReturn>;
|
|
94
|
+
error: null;
|
|
95
|
+
} as ({
|
|
96
|
+
data: Awaited<TReturn>;
|
|
97
|
+
error: null;
|
|
98
|
+
}[K_2] extends infer T_5 ? T_5 extends {
|
|
99
|
+
data: Awaited<TReturn>;
|
|
100
|
+
error: null;
|
|
101
|
+
}[K_2] ? T_5 extends hono_utils_types.InvalidJSONValue ? true : false : never : never) extends true ? never : K_2]: boolean extends ({
|
|
102
|
+
data: Awaited<TReturn>;
|
|
103
|
+
error: null;
|
|
104
|
+
}[K_2] extends infer T_6 ? T_6 extends {
|
|
105
|
+
data: Awaited<TReturn>;
|
|
106
|
+
error: null;
|
|
107
|
+
}[K_2] ? T_6 extends hono_utils_types.InvalidJSONValue ? true : false : never : never) ? hono_utils_types.JSONParsed<{
|
|
108
|
+
data: Awaited<TReturn>;
|
|
109
|
+
error: null;
|
|
110
|
+
}[K_2]> | undefined : hono_utils_types.JSONParsed<{
|
|
111
|
+
data: Awaited<TReturn>;
|
|
112
|
+
error: null;
|
|
113
|
+
}[K_2]>; } : never;
|
|
114
|
+
outputFormat: "json";
|
|
115
|
+
status: 200;
|
|
116
|
+
} | {
|
|
117
|
+
input: hono_types.AddParam<unknown extends ((undefined extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? true : false) extends true ? {
|
|
118
|
+
json?: (v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> extends infer T_5 ? T_5 extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? T_5 extends any ? T_5 : { [K2_4 in keyof T_5]?: any; } : never : never) | undefined;
|
|
119
|
+
} : {
|
|
120
|
+
json: v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> extends infer T_6 ? T_6 extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? T_6 extends any ? T_6 : { [K2_5 in keyof T_6]: any; } : never : never;
|
|
121
|
+
}) ? {} : (undefined extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? true : false) extends true ? {
|
|
122
|
+
json?: (v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> extends infer T_7 ? T_7 extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? T_7 extends any ? T_7 : { [K2_6 in keyof T_7]?: any; } : never : never) | undefined;
|
|
123
|
+
} : {
|
|
124
|
+
json: v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> extends infer T_8 ? T_8 extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? T_8 extends any ? T_8 : { [K2_7 in keyof T_8]: any; } : never : never;
|
|
125
|
+
}, hono_types.MergePath<"/", TPath>>;
|
|
126
|
+
output: {
|
|
127
|
+
data: null;
|
|
128
|
+
error: {
|
|
129
|
+
message: string;
|
|
130
|
+
code: string;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
outputFormat: "json";
|
|
134
|
+
status: 500;
|
|
135
|
+
};
|
|
136
|
+
}; } extends infer T ? { [KeyType in keyof T]: T[KeyType]; } : never, "/">;
|
|
137
|
+
|
|
138
|
+
export { type Bindings, HonoActionError, type HonoEnv, defineHonoAction };
|
package/dist/actions.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// src/actions.ts
|
|
2
|
+
import { vValidator } from "@hono/valibot-validator";
|
|
3
|
+
import { createFactory } from "hono/factory";
|
|
4
|
+
import * as v from "valibot";
|
|
5
|
+
|
|
6
|
+
// src/error.ts
|
|
7
|
+
var HonoActionError = class extends Error {
|
|
8
|
+
code;
|
|
9
|
+
issue;
|
|
10
|
+
constructor({
|
|
11
|
+
message,
|
|
12
|
+
code,
|
|
13
|
+
issue
|
|
14
|
+
}) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = "HonoActionError";
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.issue = issue;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// src/actions.ts
|
|
23
|
+
function defineHonoAction({ path, schema, handler }) {
|
|
24
|
+
const factory = createFactory();
|
|
25
|
+
const app = factory.createApp();
|
|
26
|
+
const route = app.post(
|
|
27
|
+
path,
|
|
28
|
+
vValidator(
|
|
29
|
+
"json",
|
|
30
|
+
schema ?? v.union([v.never(), v.object({})]),
|
|
31
|
+
async (result, c) => {
|
|
32
|
+
if (!result.success) {
|
|
33
|
+
console.error(result.issues);
|
|
34
|
+
return c.json(
|
|
35
|
+
{
|
|
36
|
+
data: null,
|
|
37
|
+
error: new HonoActionError({
|
|
38
|
+
message: result.issues[0].message,
|
|
39
|
+
code: "INPUT_VALIDATION_ERROR",
|
|
40
|
+
issue: result.issues[0]
|
|
41
|
+
})
|
|
42
|
+
},
|
|
43
|
+
400
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
async (c) => {
|
|
49
|
+
try {
|
|
50
|
+
const json = c.req.valid("json");
|
|
51
|
+
const result = await handler(
|
|
52
|
+
json,
|
|
53
|
+
c
|
|
54
|
+
);
|
|
55
|
+
return c.json(
|
|
56
|
+
{
|
|
57
|
+
data: result,
|
|
58
|
+
error: null
|
|
59
|
+
},
|
|
60
|
+
200
|
|
61
|
+
);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error(error);
|
|
64
|
+
let errorMessage = "Internal server error";
|
|
65
|
+
let errorCode = "INTERNAL_SERVER_ERROR";
|
|
66
|
+
if (error instanceof HonoActionError) {
|
|
67
|
+
errorMessage = error.message;
|
|
68
|
+
errorCode = error.code;
|
|
69
|
+
}
|
|
70
|
+
return c.json(
|
|
71
|
+
{
|
|
72
|
+
data: null,
|
|
73
|
+
error: {
|
|
74
|
+
message: errorMessage,
|
|
75
|
+
code: errorCode
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
500
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
return route;
|
|
84
|
+
}
|
|
85
|
+
export {
|
|
86
|
+
HonoActionError,
|
|
87
|
+
defineHonoAction
|
|
88
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,144 +1,30 @@
|
|
|
1
|
-
import * as hono_hono_base from 'hono/hono-base';
|
|
2
|
-
import * as hono_utils_types from 'hono/utils/types';
|
|
3
|
-
import * as hono_types from 'hono/types';
|
|
4
|
-
import { Context } from 'hono';
|
|
5
|
-
import * as v from 'valibot';
|
|
6
1
|
import * as astro from 'astro';
|
|
2
|
+
import { z } from 'astro/zod';
|
|
7
3
|
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
declare const optionsSchema: z.ZodOptional<z.ZodObject<{
|
|
5
|
+
basePath: z.ZodOptional<z.ZodString>;
|
|
6
|
+
actionsPath: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
basePath?: string | undefined;
|
|
9
|
+
actionsPath?: string | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
basePath?: string | undefined;
|
|
12
|
+
actionsPath?: string | undefined;
|
|
13
|
+
}>>;
|
|
14
|
+
type IntegrationOptions = z.infer<typeof optionsSchema>;
|
|
10
15
|
/**
|
|
11
|
-
*
|
|
16
|
+
* Astro integration for Hono Actions
|
|
12
17
|
*
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
interface HonoEnv {
|
|
16
|
-
Bindings: Bindings;
|
|
17
|
-
Variables: Record<string, any>;
|
|
18
|
-
}
|
|
19
|
-
type HonoActionSchema = v.ObjectSchema<v.ObjectEntries, v.ErrorMessage<v.ObjectIssue> | undefined> | v.NeverSchema<undefined>;
|
|
20
|
-
interface HonoActionContext<TEnv extends HonoEnv, TPath extends string, TSchema extends HonoActionSchema> extends Context<TEnv, TPath, {
|
|
21
|
-
input: v.InferInput<TSchema>;
|
|
22
|
-
output: v.InferOutput<TSchema>;
|
|
23
|
-
outputFormat: 'json';
|
|
24
|
-
}> {
|
|
25
|
-
env: TEnv['Bindings'];
|
|
26
|
-
}
|
|
27
|
-
type HonoActionParams<TPath extends string, TSchema extends HonoActionSchema, TReturn, TEnv extends HonoEnv = HonoEnv> = {
|
|
28
|
-
path: TPath;
|
|
29
|
-
schema?: TSchema;
|
|
30
|
-
handler: (params: v.InferOutput<TSchema>, context: HonoActionContext<TEnv, TPath, TSchema>) => Promise<TReturn>;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Defines a type-safe Hono action using Valibot for input validation.
|
|
18
|
+
* This integration automatically discovers action files in your project,
|
|
19
|
+
* generates type-safe client code, and sets up API routes.
|
|
34
20
|
*
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
37
|
-
* @default
|
|
38
|
-
* @param handler - The handler function for the action.
|
|
39
|
-
* @returns A Hono app instance with the defined route
|
|
21
|
+
* @param options - Configuration options for the integration
|
|
22
|
+
* @param options.basePath - Base path for API routes (default: '/api')
|
|
23
|
+
* @param options.actionsPath - Custom path to actions file (optional, auto-discovered by default)
|
|
40
24
|
*/
|
|
41
|
-
declare function defineHonoAction<TPath extends string, TSchema extends HonoActionSchema, TReturn, TEnv extends HonoEnv = HonoEnv>({ path, schema, handler }: HonoActionParams<TPath, TSchema, TReturn, TEnv>): hono_hono_base.HonoBase<TEnv, { [K in hono_types.MergePath<"/", TPath>]: {
|
|
42
|
-
$post: {
|
|
43
|
-
input: hono_types.AddParam<unknown extends ((undefined extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? true : false) extends true ? {
|
|
44
|
-
json?: (v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> extends infer T_1 ? T_1 extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? T_1 extends any ? T_1 : { [K2 in keyof T_1]?: any; } : never : never) | undefined;
|
|
45
|
-
} : {
|
|
46
|
-
json: v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> extends infer T_2 ? T_2 extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? T_2 extends any ? T_2 : { [K2_1 in keyof T_2]: any; } : never : never;
|
|
47
|
-
}) ? {} : (undefined extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? true : false) extends true ? {
|
|
48
|
-
json?: (v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> extends infer T_3 ? T_3 extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? T_3 extends any ? T_3 : { [K2_2 in keyof T_3]?: any; } : never : never) | undefined;
|
|
49
|
-
} : {
|
|
50
|
-
json: v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> extends infer T_4 ? T_4 extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? T_4 extends any ? T_4 : { [K2_3 in keyof T_4]: any; } : never : never;
|
|
51
|
-
}, hono_types.MergePath<"/", TPath>>;
|
|
52
|
-
output: unknown extends ({
|
|
53
|
-
data: Awaited<TReturn>;
|
|
54
|
-
error: null;
|
|
55
|
-
} extends hono_utils_types.JSONValue ? { [K_2 in keyof {
|
|
56
|
-
data: Awaited<TReturn>;
|
|
57
|
-
error: null;
|
|
58
|
-
} as ({
|
|
59
|
-
data: Awaited<TReturn>;
|
|
60
|
-
error: null;
|
|
61
|
-
}[K_2] extends infer T_5 ? T_5 extends {
|
|
62
|
-
data: Awaited<TReturn>;
|
|
63
|
-
error: null;
|
|
64
|
-
}[K_2] ? T_5 extends hono_utils_types.InvalidJSONValue ? true : false : never : never) extends true ? never : K_2]: boolean extends ({
|
|
65
|
-
data: Awaited<TReturn>;
|
|
66
|
-
error: null;
|
|
67
|
-
}[K_2] extends infer T_6 ? T_6 extends {
|
|
68
|
-
data: Awaited<TReturn>;
|
|
69
|
-
error: null;
|
|
70
|
-
}[K_2] ? T_6 extends hono_utils_types.InvalidJSONValue ? true : false : never : never) ? hono_utils_types.JSONParsed<{
|
|
71
|
-
data: Awaited<TReturn>;
|
|
72
|
-
error: null;
|
|
73
|
-
}[K_2]> | undefined : hono_utils_types.JSONParsed<{
|
|
74
|
-
data: Awaited<TReturn>;
|
|
75
|
-
error: null;
|
|
76
|
-
}[K_2]>; } : never) ? {} : {
|
|
77
|
-
data: Awaited<TReturn>;
|
|
78
|
-
error: null;
|
|
79
|
-
} extends hono_utils_types.JSONValue ? { [K_2 in keyof {
|
|
80
|
-
data: Awaited<TReturn>;
|
|
81
|
-
error: null;
|
|
82
|
-
} as ({
|
|
83
|
-
data: Awaited<TReturn>;
|
|
84
|
-
error: null;
|
|
85
|
-
}[K_2] extends infer T_5 ? T_5 extends {
|
|
86
|
-
data: Awaited<TReturn>;
|
|
87
|
-
error: null;
|
|
88
|
-
}[K_2] ? T_5 extends hono_utils_types.InvalidJSONValue ? true : false : never : never) extends true ? never : K_2]: boolean extends ({
|
|
89
|
-
data: Awaited<TReturn>;
|
|
90
|
-
error: null;
|
|
91
|
-
}[K_2] extends infer T_6 ? T_6 extends {
|
|
92
|
-
data: Awaited<TReturn>;
|
|
93
|
-
error: null;
|
|
94
|
-
}[K_2] ? T_6 extends hono_utils_types.InvalidJSONValue ? true : false : never : never) ? hono_utils_types.JSONParsed<{
|
|
95
|
-
data: Awaited<TReturn>;
|
|
96
|
-
error: null;
|
|
97
|
-
}[K_2]> | undefined : hono_utils_types.JSONParsed<{
|
|
98
|
-
data: Awaited<TReturn>;
|
|
99
|
-
error: null;
|
|
100
|
-
}[K_2]>; } : never;
|
|
101
|
-
outputFormat: "json";
|
|
102
|
-
status: 200;
|
|
103
|
-
} | {
|
|
104
|
-
input: hono_types.AddParam<unknown extends ((undefined extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? true : false) extends true ? {
|
|
105
|
-
json?: (v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> extends infer T_5 ? T_5 extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? T_5 extends any ? T_5 : { [K2_4 in keyof T_5]?: any; } : never : never) | undefined;
|
|
106
|
-
} : {
|
|
107
|
-
json: v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> extends infer T_6 ? T_6 extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? T_6 extends any ? T_6 : { [K2_5 in keyof T_6]: any; } : never : never;
|
|
108
|
-
}) ? {} : (undefined extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? true : false) extends true ? {
|
|
109
|
-
json?: (v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> extends infer T_7 ? T_7 extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? T_7 extends any ? T_7 : { [K2_6 in keyof T_7]?: any; } : never : never) | undefined;
|
|
110
|
-
} : {
|
|
111
|
-
json: v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> extends infer T_8 ? T_8 extends v.InferInput<TSchema | v.UnionSchema<[v.NeverSchema<undefined>, v.ObjectSchema<{}, undefined>], undefined>> ? T_8 extends any ? T_8 : { [K2_7 in keyof T_8]: any; } : never : never;
|
|
112
|
-
}, hono_types.MergePath<"/", TPath>>;
|
|
113
|
-
output: {
|
|
114
|
-
data: null;
|
|
115
|
-
error: {
|
|
116
|
-
message: string;
|
|
117
|
-
code: string;
|
|
118
|
-
};
|
|
119
|
-
};
|
|
120
|
-
outputFormat: "json";
|
|
121
|
-
status: 500;
|
|
122
|
-
};
|
|
123
|
-
}; } extends infer T ? { [KeyType in keyof T]: T[KeyType]; } : never, "/">;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Standard error codes for actions
|
|
127
|
-
*/
|
|
128
|
-
type ActionErrorCode = 'INPUT_VALIDATION_ERROR' | 'EXTERNAL_API_ERROR' | 'INTERNAL_SERVER_ERROR' | 'UNKNOWN_ERROR' | 'LOCATION_NOT_FOUND' | 'SESSION_NOT_FOUND';
|
|
129
|
-
declare class HonoActionError<TSchema extends v.ObjectSchema<v.ObjectEntries, v.ErrorMessage<v.ObjectIssue> | undefined>, TMessage extends string, TCode extends ActionErrorCode, TIssue extends v.InferIssue<TSchema>> extends Error {
|
|
130
|
-
code: TCode;
|
|
131
|
-
issue?: TIssue;
|
|
132
|
-
constructor({ message, code, issue, }: {
|
|
133
|
-
message: TMessage;
|
|
134
|
-
code: TCode;
|
|
135
|
-
issue?: TIssue;
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
25
|
declare const _default: (options?: {
|
|
140
26
|
basePath?: string | undefined;
|
|
141
27
|
actionsPath?: string | undefined;
|
|
142
28
|
} | undefined) => astro.AstroIntegration & {};
|
|
143
29
|
|
|
144
|
-
export { type
|
|
30
|
+
export { type IntegrationOptions, _default as default };
|