@gnosticdev/hono-actions 1.2.0 → 1.2.2
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/actions.d.ts +28 -41
- package/dist/actions.js +1 -1
- package/dist/index.js +117 -59
- package/package.json +5 -7
package/dist/actions.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ type HonoActionSchema = z.ZodTypeAny;
|
|
|
38
38
|
*
|
|
39
39
|
* Example:
|
|
40
40
|
* ```ts
|
|
41
|
-
*
|
|
41
|
+
* const honoActions: {
|
|
42
42
|
* myAction: Hono<HonoEnv, { '/': { $post: any } }, '/'>
|
|
43
43
|
* anotherAction: Hono<HonoEnv, { '/': { $post: any } }, '/'>
|
|
44
44
|
* }
|
|
@@ -53,16 +53,9 @@ type HonoActionSchema = z.ZodTypeAny;
|
|
|
53
53
|
type MergeActionKeyIntoPath<TActions extends Record<string, Hono<any, any, any>>> = {
|
|
54
54
|
[K in keyof TActions]: TActions[K] extends Hono<infer TEnv, infer TSchema, infer TBase> ? Hono<TEnv, MergeSchemaPath<TSchema, `/${Extract<K, string>}`>, TBase> : never;
|
|
55
55
|
};
|
|
56
|
-
|
|
57
|
-
input: z.input<TSchema>;
|
|
58
|
-
output: z.output<TSchema>;
|
|
59
|
-
outputFormat: 'json';
|
|
60
|
-
}> {
|
|
61
|
-
env: TEnv['Bindings'];
|
|
62
|
-
}
|
|
63
|
-
type HonoActionParams<TSchema extends HonoActionSchema, TReturn, TEnv extends HonoEnv = HonoEnv> = {
|
|
56
|
+
type HonoActionParams<TSchema extends HonoActionSchema, TReturn, TEnv extends HonoEnv, TContext extends Context<TEnv, any, any>> = {
|
|
64
57
|
schema?: TSchema;
|
|
65
|
-
handler: (params: z.output<TSchema>, context:
|
|
58
|
+
handler: (params: z.output<TSchema>, context: TContext extends infer Ctx ? Ctx : never) => Promise<TReturn>;
|
|
66
59
|
};
|
|
67
60
|
/**
|
|
68
61
|
* Defines a type-safe Hono action using Zod for input validation.
|
|
@@ -71,7 +64,7 @@ type HonoActionParams<TSchema extends HonoActionSchema, TReturn, TEnv extends Ho
|
|
|
71
64
|
* @param handler - The handler function for the action.
|
|
72
65
|
* @returns A Hono app instance with the defined route
|
|
73
66
|
*/
|
|
74
|
-
declare function defineHonoAction<TEnv extends HonoEnv, TSchema extends HonoActionSchema, TReturn
|
|
67
|
+
declare function defineHonoAction<TEnv extends HonoEnv, TSchema extends HonoActionSchema, TReturn, TContext extends Context<TEnv, any, any>>({ schema, handler }: HonoActionParams<TSchema, TReturn, TEnv, TContext>): hono_hono_base.HonoBase<TEnv, {
|
|
75
68
|
"/": {
|
|
76
69
|
$post: {
|
|
77
70
|
input: unknown extends ((undefined extends z.input<TSchema | z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>> ? true : false) extends true ? {
|
|
@@ -83,10 +76,26 @@ declare function defineHonoAction<TEnv extends HonoEnv, TSchema extends HonoActi
|
|
|
83
76
|
} : {
|
|
84
77
|
json: z.input<TSchema | z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
|
|
85
78
|
};
|
|
86
|
-
output:
|
|
87
|
-
data:
|
|
88
|
-
error:
|
|
89
|
-
|
|
79
|
+
output: {
|
|
80
|
+
data: null;
|
|
81
|
+
error: {
|
|
82
|
+
message: string;
|
|
83
|
+
code: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
outputFormat: "json";
|
|
87
|
+
status: 500;
|
|
88
|
+
} | {
|
|
89
|
+
input: unknown extends ((undefined extends z.input<TSchema | z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>> ? true : false) extends true ? {
|
|
90
|
+
json?: z.input<TSchema | z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>> | undefined;
|
|
91
|
+
} : {
|
|
92
|
+
json: z.input<TSchema | z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
|
|
93
|
+
}) ? {} : (undefined extends z.input<TSchema | z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>> ? true : false) extends true ? {
|
|
94
|
+
json?: z.input<TSchema | z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>> | undefined;
|
|
95
|
+
} : {
|
|
96
|
+
json: z.input<TSchema | z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
|
|
97
|
+
};
|
|
98
|
+
output: unknown extends (Awaited<TReturn> | null extends bigint | readonly bigint[] ? never : { [K in keyof {
|
|
90
99
|
data: Awaited<TReturn>;
|
|
91
100
|
error: null;
|
|
92
101
|
} as ({
|
|
@@ -104,13 +113,10 @@ declare function defineHonoAction<TEnv extends HonoEnv, TSchema extends HonoActi
|
|
|
104
113
|
}[K] ? T_1 extends hono_utils_types.InvalidJSONValue ? true : false : never : never) ? hono_utils_types.JSONParsed<{
|
|
105
114
|
data: Awaited<TReturn>;
|
|
106
115
|
error: null;
|
|
107
|
-
}[K]> | undefined : hono_utils_types.JSONParsed<{
|
|
116
|
+
}[K], bigint | readonly bigint[]> | undefined : hono_utils_types.JSONParsed<{
|
|
108
117
|
data: Awaited<TReturn>;
|
|
109
118
|
error: null;
|
|
110
|
-
}[K]>; }
|
|
111
|
-
data: Awaited<TReturn>;
|
|
112
|
-
error: null;
|
|
113
|
-
} extends hono_utils_types.JSONValue ? { [K in keyof {
|
|
119
|
+
}[K], bigint | readonly bigint[]>; }) ? {} : Awaited<TReturn> | null extends bigint | readonly bigint[] ? never : { [K in keyof {
|
|
114
120
|
data: Awaited<TReturn>;
|
|
115
121
|
error: null;
|
|
116
122
|
} as ({
|
|
@@ -128,31 +134,12 @@ declare function defineHonoAction<TEnv extends HonoEnv, TSchema extends HonoActi
|
|
|
128
134
|
}[K] ? T_1 extends hono_utils_types.InvalidJSONValue ? true : false : never : never) ? hono_utils_types.JSONParsed<{
|
|
129
135
|
data: Awaited<TReturn>;
|
|
130
136
|
error: null;
|
|
131
|
-
}[K]> | undefined : hono_utils_types.JSONParsed<{
|
|
137
|
+
}[K], bigint | readonly bigint[]> | undefined : hono_utils_types.JSONParsed<{
|
|
132
138
|
data: Awaited<TReturn>;
|
|
133
139
|
error: null;
|
|
134
|
-
}[K]>; }
|
|
140
|
+
}[K], bigint | readonly bigint[]>; };
|
|
135
141
|
outputFormat: "json";
|
|
136
142
|
status: 200;
|
|
137
|
-
} | {
|
|
138
|
-
input: unknown extends ((undefined extends z.input<TSchema | z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>> ? true : false) extends true ? {
|
|
139
|
-
json?: z.input<TSchema | z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>> | undefined;
|
|
140
|
-
} : {
|
|
141
|
-
json: z.input<TSchema | z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
|
|
142
|
-
}) ? {} : (undefined extends z.input<TSchema | z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>> ? true : false) extends true ? {
|
|
143
|
-
json?: z.input<TSchema | z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>> | undefined;
|
|
144
|
-
} : {
|
|
145
|
-
json: z.input<TSchema | z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
|
|
146
|
-
};
|
|
147
|
-
output: {
|
|
148
|
-
data: null;
|
|
149
|
-
error: {
|
|
150
|
-
message: string;
|
|
151
|
-
code: string;
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
outputFormat: "json";
|
|
155
|
-
status: 500;
|
|
156
143
|
};
|
|
157
144
|
};
|
|
158
145
|
}, "/">;
|
package/dist/actions.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1553,7 +1553,9 @@ import fs from "node:fs/promises";
|
|
|
1553
1553
|
import path2 from "node:path";
|
|
1554
1554
|
|
|
1555
1555
|
// ../node_modules/tinyglobby/dist/index.mjs
|
|
1556
|
+
import nativeFs2 from "fs";
|
|
1556
1557
|
import path, { posix } from "path";
|
|
1558
|
+
import { fileURLToPath } from "url";
|
|
1557
1559
|
|
|
1558
1560
|
// ../node_modules/fdir/dist/index.mjs
|
|
1559
1561
|
import { createRequire } from "module";
|
|
@@ -2066,34 +2068,37 @@ var Builder = class {
|
|
|
2066
2068
|
|
|
2067
2069
|
// ../node_modules/tinyglobby/dist/index.mjs
|
|
2068
2070
|
var import_picomatch = __toESM(require_picomatch2(), 1);
|
|
2071
|
+
var isReadonlyArray = Array.isArray;
|
|
2072
|
+
var isWin = process.platform === "win32";
|
|
2069
2073
|
var ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
|
|
2070
|
-
function getPartialMatcher(patterns, options) {
|
|
2074
|
+
function getPartialMatcher(patterns, options = {}) {
|
|
2071
2075
|
const patternsCount = patterns.length;
|
|
2072
2076
|
const patternsParts = Array(patternsCount);
|
|
2073
|
-
const
|
|
2077
|
+
const matchers = Array(patternsCount);
|
|
2078
|
+
const globstarEnabled = !options.noglobstar;
|
|
2074
2079
|
for (let i = 0; i < patternsCount; i++) {
|
|
2075
2080
|
const parts = splitPattern(patterns[i]);
|
|
2076
2081
|
patternsParts[i] = parts;
|
|
2077
2082
|
const partsCount = parts.length;
|
|
2078
|
-
const
|
|
2079
|
-
for (let j = 0; j < partsCount; j++)
|
|
2080
|
-
|
|
2083
|
+
const partMatchers = Array(partsCount);
|
|
2084
|
+
for (let j = 0; j < partsCount; j++) partMatchers[j] = (0, import_picomatch.default)(parts[j], options);
|
|
2085
|
+
matchers[i] = partMatchers;
|
|
2081
2086
|
}
|
|
2082
2087
|
return (input) => {
|
|
2083
2088
|
const inputParts = input.split("/");
|
|
2084
2089
|
if (inputParts[0] === ".." && ONLY_PARENT_DIRECTORIES.test(input)) return true;
|
|
2085
2090
|
for (let i = 0; i < patterns.length; i++) {
|
|
2086
2091
|
const patternParts = patternsParts[i];
|
|
2087
|
-
const
|
|
2092
|
+
const matcher = matchers[i];
|
|
2088
2093
|
const inputPatternCount = inputParts.length;
|
|
2089
2094
|
const minParts = Math.min(inputPatternCount, patternParts.length);
|
|
2090
2095
|
let j = 0;
|
|
2091
2096
|
while (j < minParts) {
|
|
2092
2097
|
const part = patternParts[j];
|
|
2093
2098
|
if (part.includes("/")) return true;
|
|
2094
|
-
const match =
|
|
2099
|
+
const match = matcher[j](inputParts[j]);
|
|
2095
2100
|
if (!match) break;
|
|
2096
|
-
if (part === "**") return true;
|
|
2101
|
+
if (globstarEnabled && part === "**") return true;
|
|
2097
2102
|
j++;
|
|
2098
2103
|
}
|
|
2099
2104
|
if (j === inputPatternCount) return true;
|
|
@@ -2101,13 +2106,42 @@ function getPartialMatcher(patterns, options) {
|
|
|
2101
2106
|
return false;
|
|
2102
2107
|
};
|
|
2103
2108
|
}
|
|
2109
|
+
var WIN32_ROOT_DIR = /^[A-Z]:\/$/i;
|
|
2110
|
+
var isRoot = isWin ? (p) => WIN32_ROOT_DIR.test(p) : (p) => p === "/";
|
|
2111
|
+
function buildFormat(cwd, root, absolute) {
|
|
2112
|
+
if (cwd === root || root.startsWith(`${cwd}/`)) {
|
|
2113
|
+
if (absolute) {
|
|
2114
|
+
const start = isRoot(cwd) ? cwd.length : cwd.length + 1;
|
|
2115
|
+
return (p, isDir) => p.slice(start, isDir ? -1 : void 0) || ".";
|
|
2116
|
+
}
|
|
2117
|
+
const prefix = root.slice(cwd.length + 1);
|
|
2118
|
+
if (prefix) return (p, isDir) => {
|
|
2119
|
+
if (p === ".") return prefix;
|
|
2120
|
+
const result = `${prefix}/${p}`;
|
|
2121
|
+
return isDir ? result.slice(0, -1) : result;
|
|
2122
|
+
};
|
|
2123
|
+
return (p, isDir) => isDir && p !== "." ? p.slice(0, -1) : p;
|
|
2124
|
+
}
|
|
2125
|
+
if (absolute) return (p) => posix.relative(cwd, p) || ".";
|
|
2126
|
+
return (p) => posix.relative(cwd, `${root}/${p}`) || ".";
|
|
2127
|
+
}
|
|
2128
|
+
function buildRelative(cwd, root) {
|
|
2129
|
+
if (root.startsWith(`${cwd}/`)) {
|
|
2130
|
+
const prefix = root.slice(cwd.length + 1);
|
|
2131
|
+
return (p) => `${prefix}/${p}`;
|
|
2132
|
+
}
|
|
2133
|
+
return (p) => {
|
|
2134
|
+
const result = posix.relative(cwd, `${root}/${p}`);
|
|
2135
|
+
if (p.endsWith("/") && result !== "") return `${result}/`;
|
|
2136
|
+
return result || ".";
|
|
2137
|
+
};
|
|
2138
|
+
}
|
|
2104
2139
|
var splitPatternOptions = { parts: true };
|
|
2105
2140
|
function splitPattern(path$1) {
|
|
2106
2141
|
var _result$parts;
|
|
2107
2142
|
const result = import_picomatch.default.scan(path$1, splitPatternOptions);
|
|
2108
2143
|
return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path$1];
|
|
2109
2144
|
}
|
|
2110
|
-
var isWin = process.platform === "win32";
|
|
2111
2145
|
var POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
|
|
2112
2146
|
var WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
|
|
2113
2147
|
var escapePosixPath = (path$1) => path$1.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
@@ -2163,13 +2197,12 @@ function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
|
|
|
2163
2197
|
}
|
|
2164
2198
|
props.depthOffset = newCommonPath.length;
|
|
2165
2199
|
props.commonPath = newCommonPath;
|
|
2166
|
-
props.root = newCommonPath.length > 0 ?
|
|
2200
|
+
props.root = newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd;
|
|
2167
2201
|
}
|
|
2168
2202
|
return result;
|
|
2169
2203
|
}
|
|
2170
|
-
function processPatterns({ patterns, ignore = [], expandDirectories = true }, cwd, props) {
|
|
2204
|
+
function processPatterns({ patterns = ["**/*"], ignore = [], expandDirectories = true }, cwd, props) {
|
|
2171
2205
|
if (typeof patterns === "string") patterns = [patterns];
|
|
2172
|
-
else if (!patterns) patterns = ["**/*"];
|
|
2173
2206
|
if (typeof ignore === "string") ignore = [ignore];
|
|
2174
2207
|
const matchPatterns = [];
|
|
2175
2208
|
const ignorePatterns = [];
|
|
@@ -2187,66 +2220,88 @@ function processPatterns({ patterns, ignore = [], expandDirectories = true }, cw
|
|
|
2187
2220
|
ignore: ignorePatterns
|
|
2188
2221
|
};
|
|
2189
2222
|
}
|
|
2190
|
-
function
|
|
2191
|
-
return posix.relative(cwd, `${root}/${path$1}`) || ".";
|
|
2192
|
-
}
|
|
2193
|
-
function processPath(path$1, cwd, root, isDirectory, absolute) {
|
|
2194
|
-
const relativePath = absolute ? path$1.slice(root === "/" ? 1 : root.length + 1) || "." : path$1;
|
|
2195
|
-
if (root === cwd) return isDirectory && relativePath !== "." ? relativePath.slice(0, -1) : relativePath;
|
|
2196
|
-
return getRelativePath(relativePath, cwd, root);
|
|
2197
|
-
}
|
|
2198
|
-
function formatPaths(paths, cwd, root) {
|
|
2223
|
+
function formatPaths(paths, relative2) {
|
|
2199
2224
|
for (let i = paths.length - 1; i >= 0; i--) {
|
|
2200
2225
|
const path$1 = paths[i];
|
|
2201
|
-
paths[i] =
|
|
2226
|
+
paths[i] = relative2(path$1);
|
|
2202
2227
|
}
|
|
2203
2228
|
return paths;
|
|
2204
2229
|
}
|
|
2205
|
-
function
|
|
2206
|
-
if (process.
|
|
2207
|
-
if (
|
|
2208
|
-
|
|
2230
|
+
function normalizeCwd(cwd) {
|
|
2231
|
+
if (!cwd) return process.cwd().replace(BACKSLASHES, "/");
|
|
2232
|
+
if (cwd instanceof URL) return fileURLToPath(cwd).replace(BACKSLASHES, "/");
|
|
2233
|
+
return path.resolve(cwd).replace(BACKSLASHES, "/");
|
|
2234
|
+
}
|
|
2235
|
+
function getCrawler(patterns, inputOptions = {}) {
|
|
2236
|
+
const options = process.env.TINYGLOBBY_DEBUG ? {
|
|
2237
|
+
...inputOptions,
|
|
2238
|
+
debug: true
|
|
2239
|
+
} : inputOptions;
|
|
2240
|
+
const cwd = normalizeCwd(options.cwd);
|
|
2241
|
+
if (options.debug) log("globbing with:", {
|
|
2242
|
+
patterns,
|
|
2243
|
+
options,
|
|
2244
|
+
cwd
|
|
2245
|
+
});
|
|
2246
|
+
if (Array.isArray(patterns) && patterns.length === 0) return [{
|
|
2247
|
+
sync: () => [],
|
|
2248
|
+
withPromise: async () => []
|
|
2249
|
+
}, false];
|
|
2209
2250
|
const props = {
|
|
2210
2251
|
root: cwd,
|
|
2211
2252
|
commonPath: null,
|
|
2212
2253
|
depthOffset: 0
|
|
2213
2254
|
};
|
|
2214
|
-
const processed = processPatterns(
|
|
2215
|
-
|
|
2255
|
+
const processed = processPatterns({
|
|
2256
|
+
...options,
|
|
2257
|
+
patterns
|
|
2258
|
+
}, cwd, props);
|
|
2216
2259
|
if (options.debug) log("internal processing patterns:", processed);
|
|
2217
|
-
const
|
|
2260
|
+
const matchOptions = {
|
|
2218
2261
|
dot: options.dot,
|
|
2219
|
-
|
|
2262
|
+
nobrace: options.braceExpansion === false,
|
|
2263
|
+
nocase: options.caseSensitiveMatch === false,
|
|
2264
|
+
noextglob: options.extglob === false,
|
|
2265
|
+
noglobstar: options.globstar === false,
|
|
2266
|
+
posix: true
|
|
2267
|
+
};
|
|
2268
|
+
const matcher = (0, import_picomatch.default)(processed.match, {
|
|
2269
|
+
...matchOptions,
|
|
2220
2270
|
ignore: processed.ignore
|
|
2221
2271
|
});
|
|
2222
|
-
const ignore = (0, import_picomatch.default)(processed.ignore,
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
const partialMatcher = getPartialMatcher(processed.match, {
|
|
2227
|
-
dot: options.dot,
|
|
2228
|
-
nocase
|
|
2229
|
-
});
|
|
2272
|
+
const ignore = (0, import_picomatch.default)(processed.ignore, matchOptions);
|
|
2273
|
+
const partialMatcher = getPartialMatcher(processed.match, matchOptions);
|
|
2274
|
+
const format = buildFormat(cwd, props.root, options.absolute);
|
|
2275
|
+
const formatExclude = options.absolute ? format : buildFormat(cwd, props.root, true);
|
|
2230
2276
|
const fdirOptions = {
|
|
2231
2277
|
filters: [options.debug ? (p, isDirectory) => {
|
|
2232
|
-
const path$1 =
|
|
2278
|
+
const path$1 = format(p, isDirectory);
|
|
2233
2279
|
const matches = matcher(path$1);
|
|
2234
2280
|
if (matches) log(`matched ${path$1}`);
|
|
2235
2281
|
return matches;
|
|
2236
|
-
} : (p, isDirectory) => matcher(
|
|
2282
|
+
} : (p, isDirectory) => matcher(format(p, isDirectory))],
|
|
2237
2283
|
exclude: options.debug ? (_, p) => {
|
|
2238
|
-
const relativePath =
|
|
2284
|
+
const relativePath = formatExclude(p, true);
|
|
2239
2285
|
const skipped = relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
|
2240
2286
|
if (skipped) log(`skipped ${p}`);
|
|
2241
2287
|
else log(`crawling ${p}`);
|
|
2242
2288
|
return skipped;
|
|
2243
2289
|
} : (_, p) => {
|
|
2244
|
-
const relativePath =
|
|
2290
|
+
const relativePath = formatExclude(p, true);
|
|
2245
2291
|
return relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
|
2246
2292
|
},
|
|
2293
|
+
fs: options.fs ? {
|
|
2294
|
+
readdir: options.fs.readdir || nativeFs2.readdir,
|
|
2295
|
+
readdirSync: options.fs.readdirSync || nativeFs2.readdirSync,
|
|
2296
|
+
realpath: options.fs.realpath || nativeFs2.realpath,
|
|
2297
|
+
realpathSync: options.fs.realpathSync || nativeFs2.realpathSync,
|
|
2298
|
+
stat: options.fs.stat || nativeFs2.stat,
|
|
2299
|
+
statSync: options.fs.statSync || nativeFs2.statSync
|
|
2300
|
+
} : void 0,
|
|
2247
2301
|
pathSeparator: "/",
|
|
2248
2302
|
relativePaths: true,
|
|
2249
|
-
resolveSymlinks: true
|
|
2303
|
+
resolveSymlinks: true,
|
|
2304
|
+
signal: options.signal
|
|
2250
2305
|
};
|
|
2251
2306
|
if (options.deep !== void 0) fdirOptions.maxDepth = Math.round(options.deep - props.depthOffset);
|
|
2252
2307
|
if (options.absolute) {
|
|
@@ -2265,18 +2320,17 @@ function crawl(options, cwd, sync2) {
|
|
|
2265
2320
|
props.root = props.root.replace(BACKSLASHES, "");
|
|
2266
2321
|
const root = props.root;
|
|
2267
2322
|
if (options.debug) log("internal properties:", props);
|
|
2268
|
-
const
|
|
2269
|
-
|
|
2270
|
-
return sync2 ? formatPaths(api.sync(), cwd, root) : api.withPromise().then((paths) => formatPaths(paths, cwd, root));
|
|
2323
|
+
const relative2 = cwd !== root && !options.absolute && buildRelative(cwd, props.root);
|
|
2324
|
+
return [new Builder(fdirOptions).crawl(root), relative2];
|
|
2271
2325
|
}
|
|
2272
2326
|
async function glob(patternsOrOptions, options) {
|
|
2273
2327
|
if (patternsOrOptions && (options === null || options === void 0 ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
|
|
2274
|
-
const
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
return
|
|
2328
|
+
const isModern = isReadonlyArray(patternsOrOptions) || typeof patternsOrOptions === "string";
|
|
2329
|
+
const opts = isModern ? options : patternsOrOptions;
|
|
2330
|
+
const patterns = isModern ? patternsOrOptions : patternsOrOptions.patterns;
|
|
2331
|
+
const [crawler, relative2] = getCrawler(patterns, opts);
|
|
2332
|
+
if (!relative2) return crawler.withPromise();
|
|
2333
|
+
return formatPaths(await crawler.withPromise(), relative2);
|
|
2280
2334
|
}
|
|
2281
2335
|
|
|
2282
2336
|
// src/integration-files.ts
|
|
@@ -2313,10 +2367,11 @@ showRoutes(app)
|
|
|
2313
2367
|
console.log('---------------------------')
|
|
2314
2368
|
export default app`;
|
|
2315
2369
|
}
|
|
2316
|
-
var
|
|
2370
|
+
var generateAstroHandler = (adapter) => {
|
|
2317
2371
|
switch (adapter) {
|
|
2318
2372
|
case "@astrojs/cloudflare":
|
|
2319
2373
|
return `
|
|
2374
|
+
/// <reference types="./types.d.ts" />
|
|
2320
2375
|
// Generated by Hono Actions Integration
|
|
2321
2376
|
import router from './router.js'
|
|
2322
2377
|
import type { APIContext, APIRoute } from 'astro'
|
|
@@ -2335,7 +2390,7 @@ export { handler as ALL }
|
|
|
2335
2390
|
throw new Error(`Unsupported adapter: ${adapter}`);
|
|
2336
2391
|
}
|
|
2337
2392
|
};
|
|
2338
|
-
var
|
|
2393
|
+
var generateHonoClient = (port) => `
|
|
2339
2394
|
// Generated by Hono Actions Integration
|
|
2340
2395
|
import type { HonoRouter } from './router.js'
|
|
2341
2396
|
import { hc, parseResponse } from 'hono/client'
|
|
@@ -2354,7 +2409,7 @@ function getBaseUrl() {
|
|
|
2354
2409
|
// server side (production) needs full url
|
|
2355
2410
|
return import.meta.env.SITE ?? ''
|
|
2356
2411
|
}
|
|
2357
|
-
export { parseResponse }
|
|
2412
|
+
export { parseResponse, hc }
|
|
2358
2413
|
export const honoClient = hc<HonoRouter>(getBaseUrl())
|
|
2359
2414
|
`;
|
|
2360
2415
|
|
|
@@ -2444,11 +2499,15 @@ ${ACTION_PATTERNS.map((p) => ` - ${p}`).join("\n")}`
|
|
|
2444
2499
|
);
|
|
2445
2500
|
const adapter = params.config.adapter?.name;
|
|
2446
2501
|
if (!adapter) {
|
|
2447
|
-
|
|
2502
|
+
logger.error(
|
|
2503
|
+
`No Astro adapter found. Add one of:
|
|
2504
|
+
- ${SUPPORTED_ADAPTERS.join("\n - ")} to your astro.config.mjs`
|
|
2505
|
+
);
|
|
2506
|
+
return;
|
|
2448
2507
|
}
|
|
2449
2508
|
let astroHandlerContent;
|
|
2450
2509
|
if (isSupportedAdapter(adapter)) {
|
|
2451
|
-
astroHandlerContent =
|
|
2510
|
+
astroHandlerContent = generateAstroHandler(adapter);
|
|
2452
2511
|
} else {
|
|
2453
2512
|
throw new Error(`Unsupported adapter: ${adapter}`, {
|
|
2454
2513
|
cause: `Only ${SUPPORTED_ADAPTERS.join(
|
|
@@ -2465,7 +2524,7 @@ ${ACTION_PATTERNS.map((p) => ` - ${p}`).join("\n")}`
|
|
|
2465
2524
|
codeGenDir.pathname,
|
|
2466
2525
|
"client.ts"
|
|
2467
2526
|
);
|
|
2468
|
-
const clientContent =
|
|
2527
|
+
const clientContent = generateHonoClient(config.server.port);
|
|
2469
2528
|
await fs.writeFile(clientPathAbs, clientContent, "utf-8");
|
|
2470
2529
|
addVirtualImports(params, {
|
|
2471
2530
|
name,
|
|
@@ -2503,7 +2562,6 @@ export {}
|
|
|
2503
2562
|
});
|
|
2504
2563
|
let clientTypes = `
|
|
2505
2564
|
// Generated by Hono Actions Integration
|
|
2506
|
-
// keeping separate from the main types.d.ts to avoid clobbering package exports
|
|
2507
2565
|
declare module '@gnosticdev/hono-actions/client' {
|
|
2508
2566
|
export const honoClient: typeof import('./client').honoClient
|
|
2509
2567
|
export const parseResponse: typeof import('./client').parseResponse
|
package/package.json
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": {
|
|
3
|
-
"email": "nynxaconsulting@gmail.com",
|
|
4
3
|
"name": "gnosticdev",
|
|
5
4
|
"url": "https://github.com/gnosticdev"
|
|
6
5
|
},
|
|
7
6
|
"dependencies": {
|
|
8
7
|
"@hono/zod-validator": "^0.2.2",
|
|
9
8
|
"astro-integration-kit": "^0.19.0",
|
|
10
|
-
"hono": "
|
|
11
|
-
"zod": "^3.23.8"
|
|
9
|
+
"hono": "catalog:"
|
|
12
10
|
},
|
|
13
11
|
"description": "Define server actions with built-in validation, error handling, and a pre-built hono client for calling the routes.",
|
|
14
12
|
"devDependencies": {
|
|
15
|
-
"@types/bun": "^1.2.21",
|
|
16
13
|
"tsup": "^8.5.0",
|
|
17
|
-
"typescript": "
|
|
14
|
+
"typescript": "catalog:",
|
|
15
|
+
"vitest": "catalog:"
|
|
18
16
|
},
|
|
19
17
|
"exports": {
|
|
20
18
|
".": {
|
|
@@ -41,7 +39,7 @@
|
|
|
41
39
|
"main": "./dist/index.js",
|
|
42
40
|
"name": "@gnosticdev/hono-actions",
|
|
43
41
|
"peerDependencies": {
|
|
44
|
-
"astro": "
|
|
42
|
+
"astro": "catalog:"
|
|
45
43
|
},
|
|
46
44
|
"publishConfig": {
|
|
47
45
|
"access": "public"
|
|
@@ -53,5 +51,5 @@
|
|
|
53
51
|
},
|
|
54
52
|
"type": "module",
|
|
55
53
|
"types": "./dist/index.d.ts",
|
|
56
|
-
"version": "1.2.
|
|
54
|
+
"version": "1.2.2"
|
|
57
55
|
}
|