@gnosticdev/hono-actions 1.0.17 → 1.0.19
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.js +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +25 -7
- package/package.json +5 -5
package/dist/actions.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ import * as astro from 'astro';
|
|
|
2
2
|
import { z } from 'astro/zod';
|
|
3
3
|
|
|
4
4
|
declare const optionsSchema: z.ZodOptional<z.ZodObject<{
|
|
5
|
+
/**
|
|
6
|
+
* The base path for the API routes
|
|
7
|
+
*
|
|
8
|
+
* @default '/api'
|
|
9
|
+
*/
|
|
5
10
|
basePath: z.ZodOptional<z.ZodString>;
|
|
6
11
|
actionsPath: z.ZodOptional<z.ZodString>;
|
|
7
12
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -18,6 +23,10 @@ type IntegrationOptions = z.infer<typeof optionsSchema>;
|
|
|
18
23
|
* This integration automatically discovers action files in your project,
|
|
19
24
|
* generates type-safe client code, and sets up API routes.
|
|
20
25
|
*
|
|
26
|
+
* Supprted Adapters:
|
|
27
|
+
* - Cloudflare
|
|
28
|
+
* - (more to come)
|
|
29
|
+
*
|
|
21
30
|
* @param options - Configuration options for the integration
|
|
22
31
|
* @param options.basePath - Base path for API routes (default: '/api')
|
|
23
32
|
* @param options.actionsPath - Custom path to actions file (optional, auto-discovered by default)
|
package/dist/index.js
CHANGED
|
@@ -1542,7 +1542,7 @@ var require_picomatch2 = __commonJS({
|
|
|
1542
1542
|
}
|
|
1543
1543
|
});
|
|
1544
1544
|
|
|
1545
|
-
// src/
|
|
1545
|
+
// src/integration.ts
|
|
1546
1546
|
import {
|
|
1547
1547
|
addVirtualImports,
|
|
1548
1548
|
createResolver,
|
|
@@ -2282,7 +2282,7 @@ async function glob(patternsOrOptions, options) {
|
|
|
2282
2282
|
// src/integration-files.ts
|
|
2283
2283
|
function generateRouter(opts) {
|
|
2284
2284
|
const { basePath, relativeActionsPath } = opts;
|
|
2285
|
-
return `import type { HonoEnv } from '@gnosticdev/hono-actions'
|
|
2285
|
+
return `import type { HonoEnv } from '@gnosticdev/hono-actions/actions'
|
|
2286
2286
|
import { Hono } from 'hono'
|
|
2287
2287
|
import { cors } from 'hono/cors'
|
|
2288
2288
|
import { showRoutes } from 'hono/dev'
|
|
@@ -2360,10 +2360,24 @@ export const honoClient = hc<HonoRouter>(getBaseUrl())
|
|
|
2360
2360
|
// src/lib/utils.ts
|
|
2361
2361
|
var reservedRoutes = ["_astro", "_actions", "_server_islands"];
|
|
2362
2362
|
|
|
2363
|
-
// src/
|
|
2363
|
+
// src/integration.ts
|
|
2364
2364
|
var optionsSchema = z.object({
|
|
2365
|
+
/**
|
|
2366
|
+
* The base path for the API routes
|
|
2367
|
+
*
|
|
2368
|
+
* @default '/api'
|
|
2369
|
+
*/
|
|
2365
2370
|
basePath: z.string().optional(),
|
|
2366
2371
|
actionsPath: z.string().optional()
|
|
2372
|
+
/**
|
|
2373
|
+
* The path to the actions file. If not provided, the integration will automatically discover the actions file by searching for one of the following patterns:
|
|
2374
|
+
* - `src/server/actions.ts`
|
|
2375
|
+
* - `src/hono/actions.ts`
|
|
2376
|
+
* - `src/hono/index.ts`
|
|
2377
|
+
* - `src/hono.ts`
|
|
2378
|
+
*
|
|
2379
|
+
* @default 'src/server/actions.ts'
|
|
2380
|
+
*/
|
|
2367
2381
|
}).optional();
|
|
2368
2382
|
var VIRTUAL_MODULE_ID_CLIENT = "@gnosticdev/hono-actions/client";
|
|
2369
2383
|
var VIRTUAL_MODULE_ID_ROUTER = "virtual:hono-actions/router";
|
|
@@ -2373,7 +2387,7 @@ var ACTION_PATTERNS = [
|
|
|
2373
2387
|
"src/hono/index.ts",
|
|
2374
2388
|
"src/hono.ts"
|
|
2375
2389
|
];
|
|
2376
|
-
var
|
|
2390
|
+
var integration_default = defineIntegration({
|
|
2377
2391
|
name: "@gnosticdev/hono-actions",
|
|
2378
2392
|
optionsSchema,
|
|
2379
2393
|
setup: ({ options = {}, name }) => {
|
|
@@ -2383,7 +2397,7 @@ var src_default = defineIntegration({
|
|
|
2383
2397
|
`Base path ${basePath} is reserved by Astro; pick another (e.g. /api2).`
|
|
2384
2398
|
);
|
|
2385
2399
|
}
|
|
2386
|
-
createResolver(import.meta.url);
|
|
2400
|
+
const baseResolver = createResolver(import.meta.url);
|
|
2387
2401
|
return {
|
|
2388
2402
|
name,
|
|
2389
2403
|
hooks: {
|
|
@@ -2397,12 +2411,13 @@ var src_default = defineIntegration({
|
|
|
2397
2411
|
});
|
|
2398
2412
|
const actionsPath = options.actionsPath ?? files[0];
|
|
2399
2413
|
if (!actionsPath) {
|
|
2400
|
-
|
|
2414
|
+
logger.warn(
|
|
2401
2415
|
`No actions found. Create one of:
|
|
2402
2416
|
${ACTION_PATTERNS.map((p) => ` - ${p}`).join("\n")}`
|
|
2403
2417
|
);
|
|
2418
|
+
return;
|
|
2404
2419
|
}
|
|
2405
|
-
const resolvedActionsPath =
|
|
2420
|
+
const resolvedActionsPath = baseResolver.resolve(actionsPath);
|
|
2406
2421
|
params.addWatchFile(resolvedActionsPath);
|
|
2407
2422
|
logger.info(
|
|
2408
2423
|
`Found actions: ${path2.relative(root, resolvedActionsPath)}`
|
|
@@ -2485,6 +2500,9 @@ ${ACTION_PATTERNS.map((p) => ` - ${p}`).join("\n")}`
|
|
|
2485
2500
|
};
|
|
2486
2501
|
}
|
|
2487
2502
|
});
|
|
2503
|
+
|
|
2504
|
+
// src/index.ts
|
|
2505
|
+
var src_default = integration_default;
|
|
2488
2506
|
export {
|
|
2489
2507
|
src_default as default
|
|
2490
2508
|
};
|
package/package.json
CHANGED
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
},
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
24
|
},
|
|
25
25
|
"./*": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
26
|
+
"types": "./dist/*.d.ts",
|
|
27
|
+
"default": "./dist/*.js"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
},
|
|
55
55
|
"type": "module",
|
|
56
56
|
"types": "./dist/index.d.ts",
|
|
57
|
-
"version": "1.0.
|
|
57
|
+
"version": "1.0.19"
|
|
58
58
|
}
|