astro 4.12.3 → 4.13.1

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.
Files changed (71) hide show
  1. package/dist/@types/astro.d.ts +21 -104
  2. package/dist/actions/runtime/middleware.d.ts +1 -0
  3. package/dist/actions/runtime/middleware.js +35 -24
  4. package/dist/actions/runtime/route.js +4 -4
  5. package/dist/actions/runtime/utils.d.ts +2 -0
  6. package/dist/actions/runtime/virtual/client.d.ts +0 -1
  7. package/dist/actions/runtime/virtual/client.js +0 -4
  8. package/dist/actions/runtime/virtual/server.d.ts +1 -4
  9. package/dist/actions/runtime/virtual/server.js +20 -13
  10. package/dist/actions/utils.d.ts +1 -0
  11. package/dist/actions/utils.js +12 -0
  12. package/dist/cli/add/index.d.ts +0 -7
  13. package/dist/cli/add/index.js +1 -2
  14. package/dist/cli/install-package.d.ts +0 -1
  15. package/dist/cli/install-package.js +1 -2
  16. package/dist/container/index.js +0 -1
  17. package/dist/content/runtime-assets.d.ts +2 -2
  18. package/dist/content/types-generator.js +5 -3
  19. package/dist/content/utils.d.ts +2 -11
  20. package/dist/content/utils.js +0 -8
  21. package/dist/core/app/types.d.ts +0 -1
  22. package/dist/core/build/generate.d.ts +0 -4
  23. package/dist/core/build/generate.js +10 -24
  24. package/dist/core/build/index.js +1 -1
  25. package/dist/core/build/internal.d.ts +0 -18
  26. package/dist/core/build/internal.js +0 -17
  27. package/dist/core/build/page-data.d.ts +1 -1
  28. package/dist/core/build/page-data.js +1 -18
  29. package/dist/core/build/plugins/plugin-analyzer.js +0 -4
  30. package/dist/core/build/plugins/plugin-internals.js +0 -7
  31. package/dist/core/build/plugins/plugin-manifest.d.ts +0 -10
  32. package/dist/core/build/plugins/plugin-manifest.js +0 -3
  33. package/dist/core/build/plugins/plugin-ssr.js +0 -1
  34. package/dist/core/build/types.d.ts +1 -8
  35. package/dist/core/compile/index.d.ts +0 -1
  36. package/dist/core/compile/types.d.ts +0 -7
  37. package/dist/core/config/schema.d.ts +0 -34
  38. package/dist/core/config/schema.js +0 -4
  39. package/dist/core/constants.js +1 -1
  40. package/dist/core/dev/dev.js +1 -1
  41. package/dist/core/dev/restart.d.ts +0 -2
  42. package/dist/core/dev/restart.js +1 -3
  43. package/dist/core/errors/dev/vite.d.ts +0 -13
  44. package/dist/core/errors/dev/vite.js +1 -2
  45. package/dist/core/errors/errors-data.d.ts +18 -6
  46. package/dist/core/errors/errors-data.js +13 -6
  47. package/dist/core/fs/index.d.ts +0 -2
  48. package/dist/core/fs/index.js +0 -5
  49. package/dist/core/logger/core.d.ts +0 -1
  50. package/dist/core/logger/core.js +0 -18
  51. package/dist/core/messages.d.ts +0 -1
  52. package/dist/core/messages.js +2 -3
  53. package/dist/core/middleware/callMiddleware.d.ts +1 -2
  54. package/dist/core/middleware/callMiddleware.js +2 -12
  55. package/dist/core/middleware/index.js +3 -2
  56. package/dist/core/render/ssr-element.d.ts +0 -1
  57. package/dist/core/render/ssr-element.js +0 -6
  58. package/dist/core/render-context.d.ts +1 -1
  59. package/dist/core/render-context.js +15 -39
  60. package/dist/core/util.d.ts +0 -2
  61. package/dist/core/util.js +0 -14
  62. package/dist/preferences/index.d.ts +0 -1
  63. package/dist/preferences/index.js +0 -1
  64. package/dist/runtime/server/render/component.d.ts +0 -3
  65. package/dist/vite-plugin-astro-server/controller.d.ts +0 -4
  66. package/dist/vite-plugin-astro-server/controller.js +0 -2
  67. package/dist/vite-plugin-astro-server/plugin.js +0 -1
  68. package/package.json +19 -25
  69. package/templates/actions.mjs +8 -5
  70. package/dist/actions/runtime/store.d.ts +0 -5
  71. package/dist/actions/runtime/store.js +0 -18
@@ -4,7 +4,7 @@ import type { MarkdownHeading, MarkdownVFile, RehypePlugins, RemarkPlugins, Rema
4
4
  import type * as babel from '@babel/core';
5
5
  import type * as rollup from 'rollup';
6
6
  import type * as vite from 'vite';
7
- import type { ActionAccept, ActionClient, ActionInputSchema } from '../actions/runtime/virtual/server.js';
7
+ import type { ActionAccept, ActionClient, ActionInputSchema, ActionReturnType } from '../actions/runtime/virtual/server.js';
8
8
  import type { RemotePattern } from '../assets/utils/remotePattern.js';
9
9
  import type { AssetsPrefix, SSRManifest, SerializedSSRManifest } from '../core/app/types.js';
10
10
  import type { PageBuildData } from '../core/build/types.js';
@@ -182,6 +182,21 @@ export interface AstroGlobal<Props extends Record<string, any> = Record<string,
182
182
  * ```
183
183
  */
184
184
  getActionResult: AstroSharedContext['getActionResult'];
185
+ /**
186
+ * Call an Action directly from an Astro page or API endpoint.
187
+ * Expects the action function as the first parameter,
188
+ * and the type-safe action input as the second parameter.
189
+ * Returns a Promise with the action result.
190
+ *
191
+ * Example usage:
192
+ *
193
+ * ```typescript
194
+ * import { actions } from 'astro:actions';
195
+ *
196
+ * const result = await Astro.callAction(actions.getPost, { postId: 'test' });
197
+ * ```
198
+ */
199
+ callAction: AstroSharedContext['callAction'];
185
200
  /** Redirect to another page
186
201
  *
187
202
  * Example usage:
@@ -1755,53 +1770,6 @@ export interface AstroUserConfig {
1755
1770
  * ```
1756
1771
  */
1757
1772
  contentCollectionCache?: boolean;
1758
- /**
1759
- * @docs
1760
- * @name experimental.contentCollectionJsonSchema
1761
- * @type {boolean}
1762
- * @default `false`
1763
- * @version 4.5.0
1764
- * @description
1765
- * This feature will auto-generate a JSON schema for content collections of `type: 'data'` which can be used as the `$schema` value for TypeScript-style autocompletion/hints in tools like VSCode.
1766
- *
1767
- * To enable this feature, add the experimental flag:
1768
- *
1769
- * ```diff
1770
- * import { defineConfig } from 'astro/config';
1771
-
1772
- * export default defineConfig({
1773
- * experimental: {
1774
- * + contentCollectionJsonSchema: true
1775
- * }
1776
- * });
1777
- * ```
1778
- *
1779
- * This experimental implementation requires you to manually reference the schema in each data entry file of the collection:
1780
- *
1781
- * ```diff
1782
- * // src/content/test/entry.json
1783
- * {
1784
- * + "$schema": "../../../.astro/collections/test.schema.json",
1785
- * "test": "test"
1786
- * }
1787
- * ```
1788
- *
1789
- * Alternatively, you can set this in your [VSCode `json.schemas` settings](https://code.visualstudio.com/docs/languages/json#_json-schemas-and-settings):
1790
- *
1791
- * ```diff
1792
- * "json.schemas": [
1793
- * {
1794
- * "fileMatch": [
1795
- * "/src/content/test/**"
1796
- * ],
1797
- * "url": "./.astro/collections/test.schema.json"
1798
- * }
1799
- * ]
1800
- * ```
1801
- *
1802
- * Note that this initial implementation uses a library with [known issues for advanced Zod schemas](https://github.com/StefanTerdell/zod-to-json-schema#known-issues), so you may wish to consult these limitations before enabling the experimental flag.
1803
- */
1804
- contentCollectionJsonSchema?: boolean;
1805
1773
  /**
1806
1774
  * @docs
1807
1775
  * @name experimental.clientPrerender
@@ -1866,61 +1834,6 @@ export interface AstroUserConfig {
1866
1834
  * In the event of route collisions, where two routes of equal route priority attempt to build the same URL, Astro will log a warning identifying the conflicting routes.
1867
1835
  */
1868
1836
  globalRoutePriority?: boolean;
1869
- /**
1870
- * @docs
1871
- * @name experimental.rewriting
1872
- * @type {boolean}
1873
- * @default `false`
1874
- * @version 4.8.0
1875
- * @description
1876
- *
1877
- * Enables a routing feature for rewriting requests in Astro pages, endpoints and Astro middleware, giving you programmatic control over your routes.
1878
- *
1879
- * ```js
1880
- * {
1881
- * experimental: {
1882
- * rewriting: true,
1883
- * },
1884
- * }
1885
- * ```
1886
- *
1887
- * Use `Astro.rewrite` in your `.astro` files to reroute to a different page:
1888
- *
1889
- * ```astro "rewrite"
1890
- * ---
1891
- * // src/pages/dashboard.astro
1892
- * if (!Astro.props.allowed) {
1893
- * return Astro.rewrite("/")
1894
- * }
1895
- * ---
1896
- * ```
1897
- *
1898
- * Use `context.rewrite` in your endpoint files to reroute to a different page:
1899
- *
1900
- * ```js
1901
- * // src/pages/api.js
1902
- * export function GET(ctx) {
1903
- * if (!ctx.locals.allowed) {
1904
- * return ctx.rewrite("/")
1905
- * }
1906
- * }
1907
- * ```
1908
- *
1909
- * Use `next("/")` in your middleware file to reroute to a different page, and then call the next middleware function:
1910
- *
1911
- * ```js
1912
- * // src/middleware.js
1913
- * export function onRequest(ctx, next) {
1914
- * if (!ctx.cookies.get("allowed")) {
1915
- * return next("/") // new signature
1916
- * }
1917
- * return next();
1918
- * }
1919
- * ```
1920
- *
1921
- * For a complete overview, and to give feedback on this experimental API, see the [Rerouting RFC](https://github.com/withastro/roadmap/blob/feat/reroute/proposals/0047-rerouting.md).
1922
- */
1923
- rewriting?: boolean;
1924
1837
  /**
1925
1838
  * @docs
1926
1839
  * @name experimental.env
@@ -2593,7 +2506,11 @@ interface AstroSharedContext<Props extends Record<string, any> = Record<string,
2593
2506
  /**
2594
2507
  * Get action result on the server when using a form POST.
2595
2508
  */
2596
- getActionResult: <TAccept extends ActionAccept, TInputSchema extends ActionInputSchema<TAccept>, TAction extends ActionClient<unknown, TAccept, TInputSchema>>(action: TAction) => Awaited<ReturnType<TAction>> | undefined;
2509
+ getActionResult: <TAccept extends ActionAccept, TInputSchema extends ActionInputSchema<TAccept>, TAction extends ActionClient<unknown, TAccept, TInputSchema>>(action: TAction) => ActionReturnType<TAction> | undefined;
2510
+ /**
2511
+ * Call action handler from the server.
2512
+ */
2513
+ callAction: <TAccept extends ActionAccept, TInputSchema extends ActionInputSchema<TAccept>, TOutput, TAction extends ActionClient<TOutput, TAccept, TInputSchema> | ActionClient<TOutput, TAccept, TInputSchema>['orThrow']>(action: TAction, input: Parameters<TAction>[0]) => Promise<ActionReturnType<TAction>>;
2597
2514
  /**
2598
2515
  * Route parameters for this request if this is a dynamic route.
2599
2516
  */
@@ -2,6 +2,7 @@ import type { APIContext } from '../../@types/astro.js';
2
2
  export type Locals = {
3
3
  _actionsInternal: {
4
4
  getActionResult: APIContext['getActionResult'];
5
+ callAction: APIContext['callAction'];
5
6
  actionResult?: ReturnType<APIContext['getActionResult']>;
6
7
  };
7
8
  };
@@ -5,13 +5,15 @@ import {
5
5
  } from "../../core/errors/errors-data.js";
6
6
  import { AstroError } from "../../core/errors/errors.js";
7
7
  import { defineMiddleware } from "../../core/middleware/index.js";
8
- import { ApiContextStorage } from "./store.js";
9
8
  import { formContentTypes, getAction, hasContentType } from "./utils.js";
10
9
  import { getActionQueryString } from "./virtual/shared.js";
11
10
  const onRequest = defineMiddleware(async (context, next) => {
12
11
  const locals = context.locals;
13
12
  const { request } = context;
14
- if (locals._actionsInternal) return ApiContextStorage.run(context, () => next());
13
+ if (locals._actionsInternal) {
14
+ locals._actionsInternal.callAction = createCallAction(context);
15
+ return next();
16
+ }
15
17
  if (request.method === "POST" && request.body === null) {
16
18
  return nextWithStaticStub(next, context);
17
19
  }
@@ -36,8 +38,8 @@ async function handlePost({
36
38
  actionName
37
39
  }) {
38
40
  const { request } = context;
39
- const action = await getAction(actionName);
40
- if (!action) {
41
+ const baseAction = await getAction(actionName);
42
+ if (!baseAction) {
41
43
  throw new AstroError({
42
44
  ...ActionQueryStringInvalidError,
43
45
  message: ActionQueryStringInvalidError.message(actionName)
@@ -48,10 +50,11 @@ async function handlePost({
48
50
  if (contentType && hasContentType(contentType, formContentTypes)) {
49
51
  formData = await request.clone().formData();
50
52
  }
51
- const actionResult = await ApiContextStorage.run(context, () => action(formData));
53
+ const action = baseAction.bind(context);
54
+ const actionResult = await action(formData);
52
55
  return handleResult({ context, next, actionName, actionResult });
53
56
  }
54
- function handleResult({
57
+ async function handleResult({
55
58
  context,
56
59
  next,
57
60
  actionName,
@@ -64,21 +67,20 @@ function handleResult({
64
67
  }
65
68
  return actionResult;
66
69
  },
70
+ callAction: createCallAction(context),
67
71
  actionResult
68
72
  };
69
73
  const locals = context.locals;
70
74
  Object.defineProperty(locals, "_actionsInternal", { writable: false, value: actionsInternal });
71
- return ApiContextStorage.run(context, async () => {
72
- const response = await next();
73
- if (actionResult.error) {
74
- return new Response(response.body, {
75
- status: actionResult.error.status,
76
- statusText: actionResult.error.type,
77
- headers: response.headers
78
- });
79
- }
80
- return response;
81
- });
75
+ const response = await next();
76
+ if (actionResult.error) {
77
+ return new Response(response.body, {
78
+ status: actionResult.error.status,
79
+ statusText: actionResult.error.type,
80
+ headers: response.headers
81
+ });
82
+ }
83
+ return response;
82
84
  }
83
85
  async function handlePostLegacy({ context, next }) {
84
86
  const { request } = context;
@@ -91,14 +93,15 @@ async function handlePostLegacy({ context, next }) {
91
93
  if (!formData) return nextWithLocalsStub(next, context);
92
94
  const actionName = formData.get("_astroAction");
93
95
  if (!actionName) return nextWithLocalsStub(next, context);
94
- const action = await getAction(actionName);
95
- if (!action) {
96
+ const baseAction = await getAction(actionName);
97
+ if (!baseAction) {
96
98
  throw new AstroError({
97
99
  ...ActionQueryStringInvalidError,
98
100
  message: ActionQueryStringInvalidError.message(actionName)
99
101
  });
100
102
  }
101
- const actionResult = await ApiContextStorage.run(context, () => action(formData));
103
+ const action = baseAction.bind(context);
104
+ const actionResult = await action(formData);
102
105
  return handleResult({ context, next, actionName, actionResult });
103
106
  }
104
107
  function nextWithStaticStub(next, context) {
@@ -111,19 +114,27 @@ function nextWithStaticStub(next, context) {
111
114
  "`getActionResult()` should not be called on prerendered pages. Astro can only handle actions for pages rendered on-demand."
112
115
  );
113
116
  return void 0;
114
- }
117
+ },
118
+ callAction: createCallAction(context)
115
119
  }
116
120
  });
117
- return ApiContextStorage.run(context, () => next());
121
+ return next();
118
122
  }
119
123
  function nextWithLocalsStub(next, context) {
120
124
  Object.defineProperty(context.locals, "_actionsInternal", {
121
125
  writable: false,
122
126
  value: {
123
- getActionResult: () => void 0
127
+ getActionResult: () => void 0,
128
+ callAction: createCallAction(context)
124
129
  }
125
130
  });
126
- return ApiContextStorage.run(context, () => next());
131
+ return next();
132
+ }
133
+ function createCallAction(context) {
134
+ return (baseAction, input) => {
135
+ const action = baseAction.bind(context);
136
+ return action(input);
137
+ };
127
138
  }
128
139
  export {
129
140
  onRequest
@@ -1,9 +1,8 @@
1
- import { ApiContextStorage } from "./store.js";
2
1
  import { formContentTypes, getAction, hasContentType } from "./utils.js";
3
2
  const POST = async (context) => {
4
3
  const { request, url } = context;
5
- const action = await getAction(url.pathname);
6
- if (!action) {
4
+ const baseAction = await getAction(url.pathname);
5
+ if (!baseAction) {
7
6
  return new Response(null, { status: 404 });
8
7
  }
9
8
  const contentType = request.headers.get("Content-Type");
@@ -18,7 +17,8 @@ const POST = async (context) => {
18
17
  } else {
19
18
  return new Response(null, { status: 415 });
20
19
  }
21
- const result = await ApiContextStorage.run(context, () => action(args));
20
+ const action = baseAction.bind(context);
21
+ const result = await action(args);
22
22
  if (result.error) {
23
23
  return new Response(
24
24
  JSON.stringify({
@@ -1,7 +1,9 @@
1
1
  import type { ZodType } from 'zod';
2
+ import type { APIContext } from '../../@types/astro.js';
2
3
  import type { ActionAccept, ActionClient } from './virtual/server.js';
3
4
  export declare const formContentTypes: string[];
4
5
  export declare function hasContentType(contentType: string, expected: string[]): boolean;
6
+ export type ActionAPIContext = Omit<APIContext, 'getActionResult' | 'callAction' | 'props'>;
5
7
  export type MaybePromise<T> = T | Promise<T>;
6
8
  /**
7
9
  * Get server-side action based on the route path.
@@ -1,4 +1,3 @@
1
1
  export * from './shared.js';
2
2
  export declare function defineAction(): void;
3
- export declare function getApiContext(): void;
4
3
  export declare const z: {};
@@ -2,9 +2,6 @@ export * from "./shared.js";
2
2
  function defineAction() {
3
3
  throw new Error("[astro:action] `defineAction()` unexpectedly used on the client.");
4
4
  }
5
- function getApiContext() {
6
- throw new Error("[astro:action] `getApiContext()` unexpectedly used on the client.");
7
- }
8
5
  const z = new Proxy(
9
6
  {},
10
7
  {
@@ -15,6 +12,5 @@ const z = new Proxy(
15
12
  );
16
13
  export {
17
14
  defineAction,
18
- getApiContext,
19
15
  z
20
16
  };
@@ -1,11 +1,8 @@
1
1
  import { z } from 'zod';
2
- import { type ActionAPIContext, getApiContext as _getApiContext } from '../store.js';
3
- import type { ErrorInferenceObject, MaybePromise } from '../utils.js';
2
+ import type { ActionAPIContext, ErrorInferenceObject, MaybePromise } from '../utils.js';
4
3
  import { type SafeResult } from './shared.js';
5
4
  export * from './shared.js';
6
5
  export { z } from 'zod';
7
- /** @deprecated Access context from the second `handler()` parameter. */
8
- export declare const getApiContext: typeof _getApiContext;
9
6
  export type ActionAccept = 'form' | 'json';
10
7
  export type ActionInputSchema<T extends ActionAccept | undefined> = T extends 'form' ? z.AnyZodObject | z.ZodType<FormData> : z.ZodType;
11
8
  export type ActionHandler<TInputSchema, TOutput> = TInputSchema extends z.ZodType ? (input: z.infer<TInputSchema>, context: ActionAPIContext) => MaybePromise<TOutput> : (input: any, context: ActionAPIContext) => MaybePromise<TOutput>;
@@ -1,53 +1,61 @@
1
1
  import { z } from "zod";
2
- import { getApiContext as _getApiContext } from "../store.js";
2
+ import { ActionCalledFromServerError } from "../../../core/errors/errors-data.js";
3
+ import { AstroError } from "../../../core/errors/errors.js";
3
4
  import { ActionError, ActionInputError, callSafely } from "./shared.js";
4
5
  export * from "./shared.js";
5
6
  import { z as z2 } from "zod";
6
- const getApiContext = _getApiContext;
7
7
  function defineAction({
8
8
  accept,
9
9
  input: inputSchema,
10
10
  handler
11
11
  }) {
12
12
  const serverHandler = accept === "form" ? getFormServerHandler(handler, inputSchema) : getJsonServerHandler(handler, inputSchema);
13
- const safeServerHandler = async (unparsedInput) => {
14
- return callSafely(() => serverHandler(unparsedInput));
15
- };
13
+ async function safeServerHandler(unparsedInput) {
14
+ if (typeof this === "function") {
15
+ throw new AstroError(ActionCalledFromServerError);
16
+ }
17
+ return callSafely(() => serverHandler(unparsedInput, this));
18
+ }
16
19
  Object.assign(safeServerHandler, {
17
- orThrow: serverHandler
20
+ orThrow(unparsedInput) {
21
+ if (typeof this === "function") {
22
+ throw new AstroError(ActionCalledFromServerError);
23
+ }
24
+ return serverHandler(unparsedInput, this);
25
+ }
18
26
  });
19
27
  return safeServerHandler;
20
28
  }
21
29
  function getFormServerHandler(handler, inputSchema) {
22
- return async (unparsedInput) => {
30
+ return async (unparsedInput, context) => {
23
31
  if (!(unparsedInput instanceof FormData)) {
24
32
  throw new ActionError({
25
33
  code: "UNSUPPORTED_MEDIA_TYPE",
26
34
  message: "This action only accepts FormData."
27
35
  });
28
36
  }
29
- if (!(inputSchema instanceof z.ZodObject)) return await handler(unparsedInput, getApiContext());
37
+ if (!(inputSchema instanceof z.ZodObject)) return await handler(unparsedInput, context);
30
38
  const parsed = await inputSchema.safeParseAsync(formDataToObject(unparsedInput, inputSchema));
31
39
  if (!parsed.success) {
32
40
  throw new ActionInputError(parsed.error.issues);
33
41
  }
34
- return await handler(parsed.data, getApiContext());
42
+ return await handler(parsed.data, context);
35
43
  };
36
44
  }
37
45
  function getJsonServerHandler(handler, inputSchema) {
38
- return async (unparsedInput) => {
46
+ return async (unparsedInput, context) => {
39
47
  if (unparsedInput instanceof FormData) {
40
48
  throw new ActionError({
41
49
  code: "UNSUPPORTED_MEDIA_TYPE",
42
50
  message: "This action only accepts JSON."
43
51
  });
44
52
  }
45
- if (!inputSchema) return await handler(unparsedInput, getApiContext());
53
+ if (!inputSchema) return await handler(unparsedInput, context);
46
54
  const parsed = await inputSchema.safeParseAsync(unparsedInput);
47
55
  if (!parsed.success) {
48
56
  throw new ActionInputError(parsed.error.issues);
49
57
  }
50
- return await handler(parsed.data, getApiContext());
58
+ return await handler(parsed.data, context);
51
59
  };
52
60
  }
53
61
  function formDataToObject(formData, schema) {
@@ -87,6 +95,5 @@ function handleFormDataGet(key, formData, validator, baseValidator) {
87
95
  export {
88
96
  defineAction,
89
97
  formDataToObject,
90
- getApiContext,
91
98
  z2 as z
92
99
  };
@@ -2,3 +2,4 @@ import type { APIContext } from '../@types/astro.js';
2
2
  import type { Locals } from './runtime/middleware.js';
3
3
  export declare function hasActionsInternal(locals: APIContext['locals']): locals is Locals;
4
4
  export declare function createGetActionResult(locals: APIContext['locals']): APIContext['getActionResult'];
5
+ export declare function createCallAction(locals: APIContext['locals']): APIContext['callAction'];
@@ -13,7 +13,19 @@ function createGetActionResult(locals) {
13
13
  return locals._actionsInternal.getActionResult(actionFn);
14
14
  };
15
15
  }
16
+ function createCallAction(locals) {
17
+ return (actionFn, input) => {
18
+ if (!hasActionsInternal(locals))
19
+ throw new AstroError({
20
+ name: "AstroActionError",
21
+ message: "Experimental actions are not enabled in your project.",
22
+ hint: "See https://docs.astro.build/en/reference/configuration-reference/#experimental-flags"
23
+ });
24
+ return locals._actionsInternal.callAction(actionFn, input);
25
+ };
26
+ }
16
27
  export {
28
+ createCallAction,
17
29
  createGetActionResult,
18
30
  hasActionsInternal
19
31
  };
@@ -2,12 +2,5 @@ import type yargs from 'yargs-parser';
2
2
  interface AddOptions {
3
3
  flags: yargs.Arguments;
4
4
  }
5
- interface IntegrationInfo {
6
- id: string;
7
- packageName: string;
8
- dependencies: [name: string, version: string][];
9
- type: 'integration' | 'adapter';
10
- }
11
5
  export declare function add(names: string[], { flags }: AddOptions): Promise<void>;
12
- export declare function validateIntegrations(integrations: string[]): Promise<IntegrationInfo[]>;
13
6
  export {};
@@ -898,6 +898,5 @@ async function setupIntegrationConfig(opts) {
898
898
  }
899
899
  }
900
900
  export {
901
- add,
902
- validateIntegrations
901
+ add
903
902
  };
@@ -13,5 +13,4 @@ export declare function getPackage<T>(packageName: string, logger: Logger, optio
13
13
  export declare function getExecCommand(packageManager?: string): Promise<string>;
14
14
  export declare function fetchPackageJson(scope: string | undefined, name: string, tag: string): Promise<Record<string, any> | Error>;
15
15
  export declare function fetchPackageVersions(packageName: string): Promise<string[] | Error>;
16
- export declare function getRegistry(): Promise<string>;
17
16
  export {};
@@ -165,6 +165,5 @@ export {
165
165
  fetchPackageJson,
166
166
  fetchPackageVersions,
167
167
  getExecCommand,
168
- getPackage,
169
- getRegistry
168
+ getPackage
170
169
  };
@@ -15,7 +15,6 @@ function createManifest(manifest, renderers, middleware) {
15
15
  };
16
16
  return {
17
17
  hrefRoot: import.meta.url,
18
- rewritingEnabled: false,
19
18
  trailingSlash: manifest?.trailingSlash ?? ASTRO_CONFIG_DEFAULTS.trailingSlash,
20
19
  buildFormat: manifest?.buildFormat ?? ASTRO_CONFIG_DEFAULTS.build.format,
21
20
  compressHTML: manifest?.compressHTML ?? ASTRO_CONFIG_DEFAULTS.compressHTML,
@@ -2,10 +2,10 @@ import type { PluginContext } from 'rollup';
2
2
  import { z } from 'zod';
3
3
  export declare function createImage(pluginContext: PluginContext, shouldEmitFile: boolean, entryFilePath: string): () => z.ZodEffects<z.ZodString, z.ZodNever | {
4
4
  ASTRO_ASSET: string;
5
- format: import("../assets/types.js").ImageInputFormat;
6
5
  width: number;
7
6
  height: number;
7
+ format: import("../assets/types.js").ImageInputFormat;
8
8
  src: string;
9
9
  fsPath: string;
10
- orientation?: number;
10
+ orientation?: number | undefined;
11
11
  }, string>;
@@ -283,7 +283,7 @@ async function writeContentFiles({
283
283
  let contentTypesStr = "";
284
284
  let dataTypesStr = "";
285
285
  const collectionSchemasDir = new URL("./collections/", settings.dotAstroDir);
286
- if (settings.config.experimental.contentCollectionJsonSchema && !fs.existsSync(collectionSchemasDir)) {
286
+ if (!fs.existsSync(collectionSchemasDir)) {
287
287
  fs.mkdirSync(collectionSchemasDir, { recursive: true });
288
288
  }
289
289
  for (const [collection, config] of Object.entries(contentConfig?.collections ?? {})) {
@@ -376,7 +376,7 @@ async function writeContentFiles({
376
376
  dataTypesStr += `};
377
377
  `;
378
378
  }
379
- if (settings.config.experimental.contentCollectionJsonSchema && collectionConfig?.schema) {
379
+ if (collectionConfig?.schema) {
380
380
  let zodSchemaForJson = typeof collectionConfig.schema === "function" ? collectionConfig.schema({ image: () => z.string() }) : collectionConfig.schema;
381
381
  if (zodSchemaForJson instanceof z.ZodObject) {
382
382
  zodSchemaForJson = zodSchemaForJson.extend({
@@ -390,7 +390,9 @@ async function writeContentFiles({
390
390
  zodToJsonSchema(zodSchemaForJson, {
391
391
  name: collectionKey.replace(/"/g, ""),
392
392
  markdownDescription: true,
393
- errorMessages: true
393
+ errorMessages: true,
394
+ // Fix for https://github.com/StefanTerdell/zod-to-json-schema/issues/110
395
+ dateStrategy: ["format:date-time", "format:date", "integer"]
394
396
  }),
395
397
  null,
396
398
  2
@@ -19,7 +19,7 @@ export type ContentLookupMap = {
19
19
  };
20
20
  };
21
21
  };
22
- export declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
22
+ declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
23
23
  type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"content">>>;
24
24
  schema: z.ZodOptional<z.ZodAny>;
25
25
  }, "strip", z.ZodTypeAny, {
@@ -38,7 +38,7 @@ export declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
38
38
  type: "data";
39
39
  schema?: any;
40
40
  }>]>;
41
- export declare const contentConfigParser: z.ZodObject<{
41
+ declare const contentConfigParser: z.ZodObject<{
42
42
  collections: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
43
43
  type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"content">>>;
44
44
  schema: z.ZodOptional<z.ZodAny>;
@@ -81,9 +81,6 @@ type EntryInternal = {
81
81
  rawData: string | undefined;
82
82
  filePath: string;
83
83
  };
84
- export declare const msg: {
85
- collectionConfigMissing: (collection: string) => string;
86
- };
87
84
  export declare function parseEntrySlug({ id, collection, generatedSlug, frontmatterSlug, }: {
88
85
  id: string;
89
86
  collection: string;
@@ -124,7 +121,6 @@ export declare function getContentEntryIdAndSlug({ entry, contentDir, collection
124
121
  slug: string;
125
122
  };
126
123
  export declare function getEntryType(entryPath: string, paths: Pick<ContentPaths, 'config' | 'contentDir'>, contentFileExts: string[], dataFileExts: string[]): 'content' | 'data' | 'config' | 'ignored';
127
- export declare function hasUnderscoreBelowContentDirectoryPath(fileUrl: URL, contentDir: ContentPaths['contentDir']): boolean;
128
124
  export declare function safeParseFrontmatter(source: string, id?: string): matter.GrayMatterFile<string>;
129
125
  /**
130
126
  * The content config is loaded separately from other `src/` files.
@@ -134,11 +130,6 @@ export declare function safeParseFrontmatter(source: string, id?: string): matte
134
130
  export declare const globalContentConfigObserver: ContentObservable;
135
131
  export declare function hasAnyContentFlag(viteId: string): boolean;
136
132
  export declare function hasContentFlag(viteId: string, flag: (typeof CONTENT_FLAGS)[number]): boolean;
137
- export declare function loadContentConfig({ fs, settings, viteServer, }: {
138
- fs: typeof fsMod;
139
- settings: AstroSettings;
140
- viteServer: ViteDevServer;
141
- }): Promise<ContentConfig | undefined>;
142
133
  export declare function reloadContentConfigObserver({ observer, ...loadContentConfigOpts }: {
143
134
  fs: typeof fsMod;
144
135
  settings: AstroSettings;
@@ -22,9 +22,6 @@ const collectionConfigParser = z.union([
22
22
  const contentConfigParser = z.object({
23
23
  collections: z.record(collectionConfigParser)
24
24
  });
25
- const msg = {
26
- collectionConfigMissing: (collection) => `${collection} does not have a config. We suggest adding one for type safety!`
27
- };
28
25
  function parseEntrySlug({
29
26
  id,
30
27
  collection,
@@ -387,8 +384,6 @@ function hasAssetPropagationFlag(id) {
387
384
  }
388
385
  }
389
386
  export {
390
- collectionConfigParser,
391
- contentConfigParser,
392
387
  contentObservable,
393
388
  getContentEntryExts,
394
389
  getContentEntryIdAndSlug,
@@ -406,9 +401,6 @@ export {
406
401
  hasAnyContentFlag,
407
402
  hasAssetPropagationFlag,
408
403
  hasContentFlag,
409
- hasUnderscoreBelowContentDirectoryPath,
410
- loadContentConfig,
411
- msg,
412
404
  parseEntrySlug,
413
405
  reloadContentConfigObserver,
414
406
  reverseSymlink,
@@ -55,7 +55,6 @@ export type SSRManifest = {
55
55
  i18n: SSRManifestI18n | undefined;
56
56
  middleware: MiddlewareHandler;
57
57
  checkOrigin: boolean;
58
- rewritingEnabled: boolean;
59
58
  experimentalEnvGetSecretEnabled: boolean;
60
59
  };
61
60
  export type SSRManifestI18n = {
@@ -1,7 +1,3 @@
1
- import type { OutputAsset, OutputChunk } from 'rollup';
2
- import type { AstroSettings } from '../../@types/astro.js';
3
1
  import { type BuildInternals } from '../../core/build/internal.js';
4
2
  import type { StaticBuildOptions } from './types.js';
5
- export declare function rootRelativeFacadeId(facadeId: string, settings: AstroSettings): string;
6
- export declare function chunkIsPage(settings: AstroSettings, output: OutputAsset | OutputChunk, internals: BuildInternals): boolean;
7
3
  export declare function generatePages(options: StaticBuildOptions, internals: BuildInternals): Promise<void>;