astronaut-cms 0.0.1 → 1.0.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.
Files changed (119) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +84 -3
  3. package/dist/admin/THIRD_PARTY_LICENSES.md +7598 -0
  4. package/dist/admin/assets/assistant-DkS355co.js +201 -0
  5. package/dist/admin/assets/badge-BXsOvOPX.js +1 -0
  6. package/dist/admin/assets/changes-Ba0G_GN1.js +1 -0
  7. package/dist/admin/assets/client-VKp75fDU.js +5 -0
  8. package/dist/admin/assets/clsx-DB0hHKMi.js +1 -0
  9. package/dist/admin/assets/collapsible-B6P_J0Bg.js +1 -0
  10. package/dist/admin/assets/collapsible-item-UaoJaaPw.js +1 -0
  11. package/dist/admin/assets/collections._collection-BE1enDCq.js +1 -0
  12. package/dist/admin/assets/collections._collection._entry-D3UksnCo.js +52 -0
  13. package/dist/admin/assets/collections._collection.index-BN5d8UIY.js +1 -0
  14. package/dist/admin/assets/component-lookup-CUCiK8Xh.js +4 -0
  15. package/dist/admin/assets/config-Pm_BHLNT.js +1 -0
  16. package/dist/admin/assets/copy-DezZzPMV.js +1 -0
  17. package/dist/admin/assets/css-BGIxQoYs.js +1 -0
  18. package/dist/admin/assets/css-DgaLhXQH.js +1 -0
  19. package/dist/admin/assets/diff-woXpYk--.js +1 -0
  20. package/dist/admin/assets/dist-DzkcSBZl.js +1 -0
  21. package/dist/admin/assets/dist-UbA1s2kM.js +1 -0
  22. package/dist/admin/assets/docx-BctAmX91.js +56 -0
  23. package/dist/admin/assets/editor-FGqMznBK.js +2 -0
  24. package/dist/admin/assets/empty-DSBYiI_7.js +1 -0
  25. package/dist/admin/assets/entry-link-CQLN2Zpf.js +158 -0
  26. package/dist/admin/assets/error-banner-yskeRXe8.js +159 -0
  27. package/dist/admin/assets/errors-DkJ5E_ak.js +1 -0
  28. package/dist/admin/assets/field-BDK5tt3J.js +41 -0
  29. package/dist/admin/assets/field-schema-CacrjSYw.js +1 -0
  30. package/dist/admin/assets/file-text-BzBif8ui.js +1 -0
  31. package/dist/admin/assets/github-dark-C-LZuMrd.js +1 -0
  32. package/dist/admin/assets/github-light-EUqPIrTm.js +1 -0
  33. package/dist/admin/assets/highlighted-body-JLMTFACH-CIQujGv2.js +1 -0
  34. package/dist/admin/assets/html-CvFb5cGI.js +1 -0
  35. package/dist/admin/assets/javascript-BzbQS41l.js +1 -0
  36. package/dist/admin/assets/javascript-CpIGwZ_Y.js +1 -0
  37. package/dist/admin/assets/json-qhed-kSA.js +1 -0
  38. package/dist/admin/assets/jsx-Bz0zcwM4.js +1 -0
  39. package/dist/admin/assets/lib-CMURo-7A.js +21 -0
  40. package/dist/admin/assets/library-Cr3f75Es.js +1 -0
  41. package/dist/admin/assets/list-skeleton-BdTNfVXs.js +1 -0
  42. package/dist/admin/assets/markdown-BYOwaDjH.js +1 -0
  43. package/dist/admin/assets/matchContext-Bq5Es9aD.js +2 -0
  44. package/dist/admin/assets/media-browser-9-CPTCks.js +1 -0
  45. package/dist/admin/assets/media._library-BfFaEZLR.js +1 -0
  46. package/dist/admin/assets/mermaid-WFAXDIZX-CJ3hhA0i.js +1 -0
  47. package/dist/admin/assets/page-header-B4nvAsVA.js +1 -0
  48. package/dist/admin/assets/pdf-DgessaF0.js +106 -0
  49. package/dist/admin/assets/python-gzcpVVnB.js +1 -0
  50. package/dist/admin/assets/react-kbcsfQYH.js +1 -0
  51. package/dist/admin/assets/rolldown-runtime-BWaJ3C7D.js +1 -0
  52. package/dist/admin/assets/routes-CBt04sNR.js +1 -0
  53. package/dist/admin/assets/routes-D7tEdYGV.js +1 -0
  54. package/dist/admin/assets/save-actions-Cz0TkpcP.js +32 -0
  55. package/dist/admin/assets/select-Bv2EoLhN.js +1 -0
  56. package/dist/admin/assets/separator-DlYj_PoQ.js +3 -0
  57. package/dist/admin/assets/shell-DBEiq06l.js +1 -0
  58. package/dist/admin/assets/shellscript-CLZ0U2zV.js +1 -0
  59. package/dist/admin/assets/skeleton-CKiqTaRh.js +1 -0
  60. package/dist/admin/assets/sql-CEbI0hMM.js +1 -0
  61. package/dist/admin/assets/syntax-BAXqRKRO.js +8 -0
  62. package/dist/admin/assets/toggle-Y2UpJZyU.js +1 -0
  63. package/dist/admin/assets/toml-BPTmHmyx.js +1 -0
  64. package/dist/admin/assets/tsx-udAQXfEw.js +1 -0
  65. package/dist/admin/assets/typescript-bsJCZSQ-.js +1 -0
  66. package/dist/admin/assets/ui.module.css-WaO_77ml.js +56 -0
  67. package/dist/admin/assets/use-entries-B2lsaiK9.js +1 -0
  68. package/dist/admin/assets/useSelector-CWr3iU9K.js +1 -0
  69. package/dist/admin/assets/yaml-rwi0_p6S.js +1 -0
  70. package/dist/admin/assets/zwitch-Wwuax-dJ.js +1 -0
  71. package/dist/admin/bootstrap.d.ts +1 -0
  72. package/dist/admin/bootstrap.js +1 -0
  73. package/dist/admin/editor.d.ts +57 -0
  74. package/dist/admin/editor.js +1 -0
  75. package/dist/server/assets.d.ts +2 -0
  76. package/dist/server/assets.js +30 -0
  77. package/dist/server/chunks/anchors-DuZ1fokt.js +86 -0
  78. package/dist/server/chunks/auth-DJP9ryVd.js +44 -0
  79. package/dist/server/chunks/cms-markers-CUqrOnfA.js +78 -0
  80. package/dist/server/chunks/component-lookup-DAFg_Qg8.js +128 -0
  81. package/dist/server/chunks/config-WQqG4mNH.d.ts +193 -0
  82. package/dist/server/chunks/digest-BYzWNJea.js +753 -0
  83. package/dist/server/chunks/entry-checks-CKMag1G4.js +608 -0
  84. package/dist/server/chunks/field-schema-CfdN75jT.js +48 -0
  85. package/dist/server/chunks/http-BnsNh57m.d.ts +35 -0
  86. package/dist/server/chunks/i18n-BPmx7ESy.d.ts +15 -0
  87. package/dist/server/chunks/index-CYbkNvu5.d.ts +22 -0
  88. package/dist/server/chunks/media-BhqUVVYY.js +223 -0
  89. package/dist/server/chunks/paths-CEW9fvg8.js +17 -0
  90. package/dist/server/chunks/paths-Dztx2eUw.js +13 -0
  91. package/dist/server/chunks/types-DOR5XaJO.js +397 -0
  92. package/dist/server/chunks/types-Dkx4Xovf.d.ts +359 -0
  93. package/dist/server/chunks/types-DwA-C6Br.d.ts +266 -0
  94. package/dist/server/chunks/user-config-DoypbpQf.js +283 -0
  95. package/dist/server/chunks/xml-D8qPILJU.js +81 -0
  96. package/dist/server/config.d.ts +3 -0
  97. package/dist/server/config.js +18 -0
  98. package/dist/server/content.d.ts +48 -0
  99. package/dist/server/content.js +89 -0
  100. package/dist/server/endpoint.d.ts +11 -0
  101. package/dist/server/endpoint.js +2712 -0
  102. package/dist/server/integration.d.ts +7 -0
  103. package/dist/server/integration.js +1174 -0
  104. package/dist/server/internal.d.ts +65 -0
  105. package/dist/server/internal.js +30 -0
  106. package/dist/server/server-local.d.ts +453 -0
  107. package/dist/server/server-local.js +336 -0
  108. package/dist/styles/THIRD_PARTY_LICENSES.md +193 -0
  109. package/dist/styles/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  110. package/dist/styles/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  111. package/dist/styles/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  112. package/dist/styles/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  113. package/dist/styles/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  114. package/dist/styles/styles.css +3 -0
  115. package/package.json +151 -5
  116. package/src/astro/Image.astro +28 -0
  117. package/src/astro/Video.astro +44 -0
  118. package/src/astro/admin.astro +137 -0
  119. package/src/astro/licenses.ts +5 -0
@@ -0,0 +1,359 @@
1
+ /**
2
+ * Where the credential the assistant spends comes from.
3
+ *
4
+ * - `relay`: the deployment's, held on the server. Every model call is proxied,
5
+ * so the deployment enforces the model allowlist, the output ceiling and the
6
+ * per-editor rate, and pays for the invocation it is held open for.
7
+ * - `byok`: the editor's own, kept in their browser and sent straight to the
8
+ * gateway. No relay, no invocation, no shared budget to drain. The deployment
9
+ * enforces nothing, because nothing of the deployment's is being spent.
10
+ *
11
+ * The deployment's own key is never a candidate for the browser. Handing it out
12
+ * would make a shared, non-expiring, unscoped credential readable by any script
13
+ * on the admin origin, and would bypass every limit the relay exists to apply.
14
+ */
15
+ type AiCredentials = "relay" | "byok";
16
+ /**
17
+ * Which gateway to reach, and where its credential comes from.
18
+ *
19
+ * - `netlify` / `vercel`: the platform injects both the base URL and the key, so
20
+ * a bare `{ type }` is enough on those hosts.
21
+ * - `cloudflare`: provide `accountId` (and optionally `gatewayId`). A Cloudflare
22
+ * API token with AI Gateway permission comes from the `CLOUDFLARE_API_TOKEN`
23
+ * environment variable.
24
+ * - `custom`: any OpenAI-compatible gateway via `baseUrl`. The key comes from the
25
+ * {@link AI_API_KEY_ENV} environment variable.
26
+ */
27
+ type AiGateway = {
28
+ type: "netlify";
29
+ } | {
30
+ type: "vercel";
31
+ } | {
32
+ type: "cloudflare";
33
+ accountId: string;
34
+ gatewayId?: string;
35
+ } | {
36
+ type: "custom";
37
+ baseUrl: string;
38
+ };
39
+ interface CmsConfig {
40
+ /** Path to the CMS config file, relative to the project root (default: auto-discovered from src/cms.config.{ts,tsx,mts,js,jsx,mjs}) */
41
+ config?: string;
42
+ /** Mount point for the admin panel (default: "/admin") */
43
+ mountPoint?: string;
44
+ /** Ship the admin and its API in `astro build`, `astro dev` always serves them (default: true for a Git backend, false for local storage) */
45
+ admin?: boolean;
46
+ /** Storage backend configuration */
47
+ storage?: StorageConfig;
48
+ /** Substitute the local filesystem backend during `astro dev`, even when a remote storage is configured (default: true) */
49
+ localStorageInDev?: boolean;
50
+ /** The media libraries, see {@link MediaConfig}. */
51
+ media?: MediaConfig;
52
+ /** Admin panel language, and the default for its language switcher (default: "en") */
53
+ locale?: SupportedLocale;
54
+ /**
55
+ * Multilingual content. Defaults to the site's own `i18n` setting in
56
+ * `astro.config`, so a site that already declares `locales` and `defaultLocale`
57
+ * needs nothing here.
58
+ *
59
+ * With it in effect, a collection whose entries all sit in locale directories
60
+ * (`src/content/posts/en/…`, `src/content/posts/de/…`, the layout Astro's
61
+ * i18n recipe recommends) is edited language by language, with missing translations
62
+ * surfaced in the listing. Pass `false` to keep the admin locale-agnostic and
63
+ * treat those directories as ordinary folders.
64
+ */
65
+ i18n?: {
66
+ locales?: string[];
67
+ defaultLocale?: string;
68
+ } | false;
69
+ /**
70
+ * URL pattern for branch previews from your hosting provider. Supports two
71
+ * placeholders: `{branch}` (raw branch, e.g. `cms/alice`) and `{slug}`
72
+ * (lowercased with non-alphanumerics replaced by `-`, e.g. `cms-alice`).
73
+ *
74
+ * Examples:
75
+ * - Netlify: `https://{slug}--my-site.netlify.app`
76
+ * - Cloudflare: `https://{slug}-my-worker.my-account.workers.dev`
77
+ * - Vercel: `https://my-site-git-{slug}-team.vercel.app`
78
+ */
79
+ previewUrl?: string;
80
+ /** Agentic AI assistant configuration */
81
+ ai?: AiConfig;
82
+ /** Expose the CMS to agents running in the editor's browser. See {@link WebmcpConfig}. */
83
+ webmcp?: WebmcpConfig;
84
+ }
85
+ /**
86
+ * WebMCP: the admin hands an agent running in the editor's own browser the same
87
+ * tools the built-in assistant uses, through `document.modelContext`, instead of
88
+ * a page to scrape. The agent is the editor's, either the browser's own or one
89
+ * they installed, so it spends no credential of this deployment's and reaches
90
+ * the CMS through the editor's session and nothing else.
91
+ *
92
+ * Everything that bounds the built-in assistant bounds it too: each tool is one
93
+ * operation on the CMS server, nothing publishes, a write joins the pending
94
+ * changeset for a human to review, and the server refuses to remove or move a
95
+ * file content still references. What is genuinely new is that the agent is not
96
+ * one this project wrote, which is why it is off unless you turn it on.
97
+ */
98
+ interface WebmcpConfig {
99
+ /** Expose the tools to agents in the browser (default: false). */
100
+ enabled?: boolean;
101
+ /**
102
+ * Chrome origin trial token for this deployment's origin, served as the
103
+ * `Origin-Trial` header on the admin page.
104
+ *
105
+ * WebMCP is an origin trial through Chrome 156, so without a token the API is
106
+ * simply absent and nothing is exposed. Register the origin at
107
+ * https://developer.chrome.com/origintrials; for local development enable
108
+ * `chrome://flags/#enable-webmcp-testing` instead. Drop this once the API
109
+ * ships unflagged.
110
+ */
111
+ originTrialToken?: string;
112
+ }
113
+ /**
114
+ * Agentic AI assistant. The browser runs the agent loop, but every tool it calls
115
+ * is one operation on the CMS server, so the model reaches exactly what the UI
116
+ * reaches and no further. Only raw model inference is proxied, through a
117
+ * stateless relay that adds the gateway credential. One request per model call,
118
+ * so no serverless duration limit can cut a turn in half.
119
+ */
120
+ interface AiConfig {
121
+ /** Enable the assistant and inject the relay route (default: false). */
122
+ enabled?: boolean;
123
+ /** AI gateway. Its credential comes from the environment, see {@link AiGateway}. */
124
+ gateway: AiGateway;
125
+ /**
126
+ * Whose credential the assistant spends (default: `"relay"`).
127
+ *
128
+ * `"byok"` asks each editor for their own key, which stays in their browser
129
+ * and goes straight to the gateway: no relay route, no function invocations
130
+ * for inference, and no shared budget anyone can drain. In exchange the
131
+ * deployment enforces none of {@link AiLimits} or the model allowlist, because
132
+ * nothing of the deployment's is at stake. Needs a gateway a browser can
133
+ * address, so `cloudflare` or `custom` rather than the platform-injected ones.
134
+ *
135
+ * See {@link AiCredentials}.
136
+ */
137
+ credentials?: AiCredentials;
138
+ /**
139
+ * Gateway-qualified model ids the assistant may use (e.g.
140
+ * `"anthropic/claude-opus-4.7"`). The first entry is the default; the relay
141
+ * rejects any model not in this list.
142
+ */
143
+ models: string[];
144
+ /** Maximum model/tool round-trips per turn (default: 24). */
145
+ maxSteps?: number;
146
+ /** Abuse controls applied by the relay. See {@link AiLimits}. */
147
+ limits?: AiLimits;
148
+ }
149
+ /**
150
+ * How large one request through the relay may be. The relay holds the gateway
151
+ * credential, so without these an editor's session is a licence to bill the
152
+ * site's account through one enormous request or one unbounded completion.
153
+ *
154
+ * How *often* an editor may call is not here: a turn is up to `maxSteps` relay
155
+ * requests, so the rate ceiling is derived from that rather than configured
156
+ * beside it (see `ai/handler.ts`). Both bind one warm instance rather than the
157
+ * deployment (see `RateLimiter`), so treat them as a brake rather than a budget
158
+ * and set a spending cap at the gateway as well.
159
+ */
160
+ interface AiLimits {
161
+ /** Largest request body the relay forwards, in bytes (default: 1 MiB). */
162
+ maxRequestBytes?: number;
163
+ /** Ceiling clamped onto the request's `max_tokens` (default: 8192). */
164
+ maxOutputTokens?: number;
165
+ }
166
+ type SupportedLocale = "en" | "de";
167
+ type PublishMode = "direct" | "pull-request";
168
+ type StorageConfig = {
169
+ type: "local";
170
+ } | {
171
+ /**
172
+ * A GitHub App, which is the only GitHub authentication the CMS accepts.
173
+ * Register one, install it on the repository with Contents and Pull
174
+ * requests write permission, and set its client id here and its client
175
+ * secret in `ASTRONAUT_CMS_GITHUB_CLIENT_SECRET`.
176
+ *
177
+ * A classic OAuth App is deliberately unsupported: the token it issues is
178
+ * coarse, covers every repository the editor can reach, and never expires,
179
+ * which is a poor thing for a deployment to hold on an editor's behalf.
180
+ * A GitHub App issues a token limited to the installation that expires in
181
+ * hours and refreshes itself.
182
+ */
183
+ type: "github";
184
+ repo: string;
185
+ branch?: string;
186
+ clientId: string;
187
+ publishMode?: PublishMode;
188
+ } | {
189
+ type: "gitlab";
190
+ project: string;
191
+ branch?: string;
192
+ clientId: string;
193
+ instanceUrl?: string;
194
+ /**
195
+ * OAuth scopes (default: `["api"]`). Note that GitLab's API-based writes
196
+ * (commits, merge requests) require `api`; the narrower `write_repository`
197
+ * scope only covers Git-over-HTTP and is insufficient here.
198
+ */
199
+ scopes?: string[];
200
+ publishMode?: PublishMode;
201
+ };
202
+ /**
203
+ * The media libraries. The repository library is always there, and an object
204
+ * store can be configured beside it, each with its own entry in the admin's
205
+ * sidebar. Each one decides for itself what it takes: extensions and size bounds
206
+ * say what an editor may upload where, e.g. SVG logos into the repository and
207
+ * photos into the store. Bounds may overlap, since the editor picks the library
208
+ * and the bounds only refuse what does not belong there.
209
+ */
210
+ interface MediaConfig {
211
+ /** The library in the repository, which content and media publish together from. */
212
+ repo?: RepoMediaConfig;
213
+ /** An object store beside it. See {@link S3MediaConfig}. */
214
+ s3?: S3MediaConfig;
215
+ }
216
+ /** What every library takes. */
217
+ interface MediaLibraryConfig {
218
+ /** The library's name in the admin, overriding the translated default. */
219
+ label?: string;
220
+ /** Restricts the library to these extensions (e.g. `[".svg", ".png"]`). Any file is accepted when unset. */
221
+ allowedExtensions?: string[];
222
+ /**
223
+ * How the browser reshapes an image before it is uploaded here. Enabled with
224
+ * the defaults of {@link ImageOptimizationConfig}; pass `false` to upload
225
+ * every original untouched.
226
+ */
227
+ optimizeImages?: ImageOptimizationConfig | false;
228
+ /**
229
+ * Smallest file the library accepts, in bytes. Checked against the upload as
230
+ * it is sent, so after image optimization where that is enabled.
231
+ */
232
+ minFileSize?: number;
233
+ /** Largest file the library accepts, in bytes, checked like {@link minFileSize}. */
234
+ maxFileSize?: number;
235
+ }
236
+ /**
237
+ * The repository library. Uploads join the pending changeset and publish with
238
+ * it, and astro's asset pipeline optimizes and bundles what content references.
239
+ *
240
+ * Its uploads pass through the CMS route, which holds each one in memory before
241
+ * committing it, so `maxFileSize` is also that route's body limit. Keep it
242
+ * within the host's own request limit (e.g. 4.5 MB on Vercel).
243
+ */
244
+ interface RepoMediaConfig extends MediaLibraryConfig {
245
+ /** Repository directory holding the library (default: "src/assets"). */
246
+ directory?: string;
247
+ /**
248
+ * Whether a build deletes the library files no delivered page, stylesheet or
249
+ * script names, where their source is known. By default it keeps the library
250
+ * when on-demand code can reach content or library media, since that code may
251
+ * link any file at request time. `true` prunes regardless.
252
+ */
253
+ prune?: boolean;
254
+ }
255
+ /** The formats a browser canvas can encode to, and therefore convert into. */
256
+ type ImageOutputFormat = "jpeg" | "png" | "webp" | "avif";
257
+ /**
258
+ * Client-side image processing, applied to every upload the browser can decode
259
+ * (JPEG, PNG, WebP, AVIF). SVG, GIF and non-images are never touched, and an
260
+ * image already inside every limit is passed through as its original bytes
261
+ * rather than re-encoded.
262
+ *
263
+ * It is a guard against the 12 MP phone original, not a substitute for astro's
264
+ * asset pipeline: the library keeps one sensible master, and the build still
265
+ * derives the per-breakpoint variants a page actually serves.
266
+ */
267
+ interface ImageOptimizationConfig {
268
+ /** Widest an upload may be, in pixels. Wider ones are scaled down, aspect ratio intact (default: 2048). */
269
+ maxWidth?: number;
270
+ /** Tallest an upload may be, in pixels (default: 2048). */
271
+ maxHeight?: number;
272
+ /**
273
+ * Size in bytes above which an image is re-encoded even when its dimensions
274
+ * already fit (default: 8 MiB). Quality steps down from `quality` towards
275
+ * `minQuality` until the result fits, so this is a threshold rather than a
276
+ * guarantee: an image that will not compress that far is uploaded at
277
+ * `minQuality`. Lossless PNG output ignores it entirely.
278
+ */
279
+ maxFileSize?: number;
280
+ /**
281
+ * Convert every upload into this format, e.g. `"webp"` to keep the library in
282
+ * one modern format. Omitted, each image keeps the format it arrived in.
283
+ * `"avif"` falls back to the original in browsers that cannot encode it.
284
+ */
285
+ format?: ImageOutputFormat;
286
+ /** Encoder quality for lossy formats, between 0 and 1 (default: 0.92). */
287
+ quality?: number;
288
+ /** Lowest quality the `maxFileSize` ladder descends to (default: 0.5). */
289
+ minQuality?: number;
290
+ }
291
+ /** {@link ImageOptimizationConfig} with every default filled in. */
292
+ type ResolvedImageOptimization = Required<Omit<ImageOptimizationConfig, "format">> & {
293
+ /** Null when uploads keep their own format. */
294
+ format: ImageOutputFormat | null;
295
+ };
296
+ /**
297
+ * An object store, addressed through its S3 API. Uploads go straight from the
298
+ * browser to the bucket and take effect immediately rather than joining the
299
+ * changeset. Content stores each file's public URL, which astro optimizes as a
300
+ * remote image at build time (the integration authorizes `publicUrl` for it),
301
+ * so visitors are served the optimized variants rather than the originals.
302
+ *
303
+ * It needs the injected media route, and therefore an SSR adapter, because no
304
+ * bucket credential may ever reach the browser. Credentials come exclusively
305
+ * from that route's environment: `ASTRONAUT_CMS_S3_ACCESS_KEY_ID`,
306
+ * `ASTRONAUT_CMS_S3_SECRET_ACCESS_KEY` and optionally
307
+ * `ASTRONAUT_CMS_S3_SESSION_TOKEN`.
308
+ */
309
+ type S3MediaConfig = S3EndpointMediaConfig | R2MediaConfig;
310
+ interface ObjectStoreConfig extends MediaLibraryConfig {
311
+ /** Bucket holding the library. */
312
+ bucket: string;
313
+ /** Key prefix the library is rooted at, e.g. "media" (default: the bucket root). */
314
+ prefix?: string;
315
+ /**
316
+ * Public base URL the library's keys are served under, e.g.
317
+ * `https://cdn.example.com`. It must serve the same `prefix` root, since a
318
+ * key is appended to it verbatim.
319
+ *
320
+ * A CDN that holds the bucket credential itself (CloudFront with an origin
321
+ * access control, an R2 custom domain) is a public base as far as this is
322
+ * concerned: set it to the CDN and the bucket stays closed.
323
+ */
324
+ publicUrl: string;
325
+ /**
326
+ * Where `astro dev` keeps the library instead of the bucket, relative to the
327
+ * project root (default: ".astronaut-cms/s3"). Without it, editing in dev
328
+ * uploads to, and deletes from, the same bucket the deployed site serves.
329
+ * Pass `false` to edit the bucket from dev anyway.
330
+ *
331
+ * Only the bytes move: a reference is still written as the store's URL, so an
332
+ * entry edited in dev builds unchanged. Needs local storage, since the files
333
+ * are reached through the dev server's own file API.
334
+ */
335
+ devDirectory?: string | false;
336
+ }
337
+ /** Any S3-compatible object store (AWS S3, MinIO, Backblaze B2, Hetzner, ...). */
338
+ interface S3EndpointMediaConfig extends ObjectStoreConfig {
339
+ provider?: "s3";
340
+ /** API endpoint, e.g. `https://s3.eu-central-1.amazonaws.com`. */
341
+ endpoint: string;
342
+ /** Signing region (default: inferred from `endpoint` on AWS, R2 and B2, falling back to "us-east-1"). */
343
+ region?: string;
344
+ /** Address objects as `<endpoint>/<bucket>/<key>` rather than by virtual host. */
345
+ forcePathStyle?: boolean;
346
+ }
347
+ /**
348
+ * Cloudflare R2 through its S3 API. Renames and deletions are copies inside
349
+ * R2, so file size is bounded by R2 alone.
350
+ *
351
+ * Public serving needs a custom domain on the bucket: the `*.r2.dev` hostname is
352
+ * rate-limited and not meant for production traffic.
353
+ */
354
+ interface R2MediaConfig extends ObjectStoreConfig {
355
+ provider: "r2";
356
+ /** Cloudflare account id, for the S3 API endpoint. */
357
+ accountId: string;
358
+ }
359
+ export { ResolvedImageOptimization as a, StorageConfig as c, RepoMediaConfig as i, SupportedLocale as l, MediaConfig as n, S3EndpointMediaConfig as o, R2MediaConfig as r, S3MediaConfig as s, CmsConfig as t };
@@ -0,0 +1,266 @@
1
+ /**
2
+ * Serializable form-field description shared between the Node integration and
3
+ * the browser admin. Zod schemas are introspected once (in Node for content
4
+ * collections, in the browser for CMS component props) and lowered into this
5
+ * plain, JSON-serializable shape via `zodToFieldSchema` (see `zod-to-field.ts`).
6
+ * The admin form renderer consumes `FieldSchema` exclusively, so no live Zod
7
+ * instance ever has to cross the Node/browser boundary.
8
+ *
9
+ * This module is the pure contract: types plus the marker keys, free of any Zod
10
+ * import so it stays trivially usable from both Node and the browser.
11
+ */
12
+ interface FieldMods {
13
+ /** Field may be absent from its parent object (Zod `.optional()`). */
14
+ optional?: boolean;
15
+ /** Field accepts an explicit `null` (Zod `.nullable()`). */
16
+ nullable?: boolean;
17
+ /** Default value from Zod `.default()`, used when the value is missing. */
18
+ default?: unknown;
19
+ /**
20
+ * Set by Zod `.catch()`: the field accepts anything, because the real schema
21
+ * repairs what it cannot parse rather than rejecting it. Only that fact is
22
+ * recorded. The CMS never reads the fallback value, and reading it would mean
23
+ * running the author's catch handler against a fabricated parse failure.
24
+ */
25
+ catch?: true;
26
+ }
27
+ /** How the form presents a field, read from Zod `.meta()`. */
28
+ interface FieldMeta {
29
+ /** `.meta({ title })`, shown in place of the humanized key. */
30
+ label?: string;
31
+ /** `.meta({ description })` or `.describe()`, shown below the label. */
32
+ description?: string;
33
+ /** `.meta({ group })`, the collapsible section the field is listed in. */
34
+ group?: string;
35
+ /** `.meta({ multiline: true })`, a text field edited in a textarea. */
36
+ multiline?: true;
37
+ /** `.meta({ labels })`, what an enum shows for each option, keyed by the option. */
38
+ labels?: Record<string, string>;
39
+ }
40
+ type FieldSchema = FieldMods & FieldMeta & ({
41
+ type: "string";
42
+ /**
43
+ * `url` is `z.url()`, `link` the CMS `link()` helper, which also takes a
44
+ * relative URL, and `anchor` its `anchor()`, an element id a link may target.
45
+ */
46
+ format?: "email" | "url" | "link" | "anchor";
47
+ minLength?: number;
48
+ maxLength?: number;
49
+ pattern?: string;
50
+ } | {
51
+ type: "number";
52
+ integer?: boolean;
53
+ min?: number;
54
+ max?: number;
55
+ exclusiveMin?: number;
56
+ exclusiveMax?: number;
57
+ multipleOf?: number;
58
+ } | {
59
+ type: "boolean";
60
+ } | {
61
+ type: "date";
62
+ } | {
63
+ type: "enum";
64
+ options: Array<string | number | boolean | null>;
65
+ } | {
66
+ type: "literal";
67
+ value: string | number | boolean | null;
68
+ } | {
69
+ type: "image";
70
+ /**
71
+ * Only repository files: astro's own collection `image()`, which types its
72
+ * value as imported `ImageMetadata`. `libraryImage(image)` and a
73
+ * component's `image()` take either library.
74
+ */
75
+ repoOnly?: true;
76
+ } | {
77
+ type: "file";
78
+ } | {
79
+ type: "reference";
80
+ collection: string;
81
+ } | {
82
+ type: "array";
83
+ element: FieldSchema;
84
+ minItems?: number;
85
+ maxItems?: number;
86
+ } | {
87
+ type: "tuple";
88
+ items: FieldSchema[];
89
+ } | {
90
+ type: "object";
91
+ shape: Record<string, FieldSchema>;
92
+ /** Whether a key outside `shape` is refused, as by `z.strictObject`. */
93
+ strict?: true;
94
+ /** A `localized()` value, one field per content language, edited in tabs. */
95
+ localized?: true;
96
+ } | {
97
+ type: "record";
98
+ value: FieldSchema;
99
+ } | {
100
+ type: "union";
101
+ discriminator?: string;
102
+ variants: FieldSchema[];
103
+ } | {
104
+ type: "unknown";
105
+ });
106
+ /**
107
+ * The serializable half of a CMS component definition: its lowered prop schema
108
+ * and what may nest inside it. `cms.config`'s live definitions add the admin's
109
+ * React refs (`icon`, `editor`) on top of this, which is why the shared MDX walk
110
+ * and the build take this narrower shape and never the admin's.
111
+ */
112
+ interface ComponentSchema {
113
+ props: FieldSchema;
114
+ children?: "markdown" | Record<string, this>;
115
+ }
116
+ type ComponentSchemaMap = Record<string, ComponentSchema>;
117
+ /** A component as the admin presents it to an editor, and the tool catalog to an agent. */
118
+ interface DescribedComponent extends ComponentSchema {
119
+ /** `text` is written within a line of text, `flow` on lines of its own. */
120
+ kind: "flow" | "text";
121
+ label: string;
122
+ description: string | null;
123
+ /** The prop that names an instance, such as its title. */
124
+ summary: string | null;
125
+ /** The collections whose entries the component renders. */
126
+ collections: string[];
127
+ }
128
+ declare const ALL_FORMATS: readonly ["md", "mdx", "mdoc", "json", "yaml", "yml", "toml"];
129
+ /** Compiles only when `T` is `never`: the drift checks against astro and the editor. */
130
+ type AssertNever<_T extends never> = void;
131
+ type EntryFormat = (typeof ALL_FORMATS)[number];
132
+ type CollectionType = "content" | "data";
133
+ type FileEntryLayout = "array" | "object";
134
+ type LoaderType = "glob" | "file";
135
+ /**
136
+ * How a collection's entries are ordered, for the site (see
137
+ * `astronaut-cms/content`) and in the admin alike.
138
+ *
139
+ * - `id`: by id, as astro's content store returns them.
140
+ * - `natural`: by id, with digit runs compared as numbers (`2` before `10`).
141
+ * - `file`: in the order the file of a `file()` collection holds them, which the
142
+ * admin then lets editors change.
143
+ */
144
+ type CollectionSort = "id" | "natural" | "file";
145
+ /**
146
+ * Fully-resolved description of one content collection, extracted from the
147
+ * user's `content.config.ts` in Node and serialized into the admin bundle.
148
+ */
149
+ interface CollectionManifestEntry {
150
+ name: string;
151
+ type: CollectionType;
152
+ schema: FieldSchema | null;
153
+ loaderType: LoaderType;
154
+ loaderPattern: string | string[] | null;
155
+ /** Where a `glob()` loader reads from, `""` for the project root, null for any other loader. */
156
+ loaderBase: string | null;
157
+ loaderFileName: string | null;
158
+ sort: CollectionSort;
159
+ /** The files of a singleton, see {@link findSingleton}, null for any other collection. */
160
+ singleton: Singleton | null;
161
+ label?: string;
162
+ description?: string;
163
+ }
164
+ type CollectionManifest = Record<string, CollectionManifestEntry>;
165
+ /** A file a glob collection's loader loads, under the id astro gives it. */
166
+ interface GlobEntry {
167
+ id: string;
168
+ format: EntryFormat;
169
+ /** Project-relative path of the file. */
170
+ path: string;
171
+ }
172
+ /** The files of a singleton collection, see {@link findSingleton}. */
173
+ interface Singleton {
174
+ /** Its one file, or the default language's, which the site cannot do without. */
175
+ main: GlobEntry;
176
+ /** The other languages' files of a localized singleton, which fall back to `main`. */
177
+ translations: GlobEntry[];
178
+ }
179
+ interface EntryMeta {
180
+ id: string;
181
+ collection: string;
182
+ format: EntryFormat;
183
+ /** Project-relative path of the file holding the entry. */
184
+ path: string;
185
+ }
186
+ /** A file collection's container, as the admin needs to know it. */
187
+ interface FileCollectionInfo {
188
+ layout: FileEntryLayout;
189
+ /**
190
+ * The container's version, which every entry in it shares. Reordering is a
191
+ * rewrite of the whole file, so this is what a reorder is based on.
192
+ */
193
+ version?: string;
194
+ }
195
+ interface EntryContent {
196
+ id: string;
197
+ /** Project-relative path of the file holding the entry. */
198
+ path: string;
199
+ data: Record<string, unknown>;
200
+ body: string;
201
+ format: EntryFormat;
202
+ /**
203
+ * What this read saw, as the backend names it. Opaque, and the only thing a
204
+ * caller may do with it is hand it back to the save that follows (see
205
+ * {@link SaveEntryRequest.expectedVersion}).
206
+ */
207
+ version?: string;
208
+ }
209
+ interface SaveEntryRequest {
210
+ data: Record<string, unknown>;
211
+ body: string;
212
+ format: EntryFormat;
213
+ /** Refuse the write if the entry already exists. */
214
+ createOnly?: boolean;
215
+ /**
216
+ * The {@link EntryContent.version} this edit was made against, so a write
217
+ * cannot silently discard one that landed while the editor was open. Absent
218
+ * means "whatever is there now", which is what a write with nothing to compare
219
+ * against can honestly claim.
220
+ *
221
+ * Deliberately opaque: it is compared, never dereferenced, so it stays a token
222
+ * the caller echoes back rather than the repository ref that the operation
223
+ * registry exists to keep out of a caller's hands.
224
+ */
225
+ expectedVersion?: string;
226
+ }
227
+ /** One file in the media library, addressed relative to the library root. */
228
+ interface MediaFile {
229
+ path: string;
230
+ size: number;
231
+ /**
232
+ * What this file's contents are, as the backend names them: the blob hash for
233
+ * a repository library. It makes the file's URL change when the bytes do,
234
+ * which is what lets the admin cache one forever instead of asking the server
235
+ * again for every thumbnail. Absent for a library whose backend has no such
236
+ * name, and then the URL is simply cached for minutes rather than for good.
237
+ */
238
+ version?: string;
239
+ }
240
+ /**
241
+ * A deletion that can still be undone. Only an object-store library has these: a
242
+ * repository library's deletions are a commit on the draft branch, which git
243
+ * keeps whether or not the CMS does.
244
+ */
245
+ interface TrashedFile {
246
+ /** Opaque to the caller, and what restoring or purging addresses. */
247
+ id: string;
248
+ /** Where restoring would put it back. */
249
+ path: string;
250
+ size: number;
251
+ /** Epoch milliseconds the file was deleted. */
252
+ deletedAt: number;
253
+ }
254
+ type ChangeKind = "added" | "modified" | "deleted" | "renamed";
255
+ /** One changed file in the pending changeset, with its unified diff when available. */
256
+ interface FileChange {
257
+ path: string;
258
+ kind: ChangeKind;
259
+ /** Previous path, for a rename. */
260
+ previousPath?: string;
261
+ /** Unified diff hunks, omitted for binary files and when no diff can be produced. */
262
+ patch?: string;
263
+ /** Identifies the file's new state when there is no patch to tell versions apart. */
264
+ version?: string;
265
+ }
266
+ export { EntryContent as a, FileChange as c, SaveEntryRequest as d, TrashedFile as f, CollectionSort as i, FileCollectionInfo as l, DescribedComponent as m, CollectionManifest as n, EntryFormat as o, ComponentSchemaMap as p, CollectionManifestEntry as r, EntryMeta as s, AssertNever as t, MediaFile as u };