@glw907/cairn-cms 0.56.2 → 0.57.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.
- package/CHANGELOG.md +134 -0
- package/dist/components/AdminLayout.svelte +3 -0
- package/dist/components/CairnAdmin.svelte +8 -1
- package/dist/components/CairnAdmin.svelte.d.ts +2 -0
- package/dist/components/CairnMediaLibrary.svelte +949 -0
- package/dist/components/CairnMediaLibrary.svelte.d.ts +37 -0
- package/dist/components/EditPage.svelte +348 -7
- package/dist/components/EditPage.svelte.d.ts +2 -0
- package/dist/components/MarkdownEditor.svelte +283 -1
- package/dist/components/MarkdownEditor.svelte.d.ts +37 -1
- package/dist/components/MediaCaptureCard.svelte +135 -0
- package/dist/components/MediaCaptureCard.svelte.d.ts +40 -0
- package/dist/components/MediaFigureControl.svelte +247 -0
- package/dist/components/MediaFigureControl.svelte.d.ts +40 -0
- package/dist/components/MediaHeroField.svelte +578 -0
- package/dist/components/MediaHeroField.svelte.d.ts +75 -0
- package/dist/components/MediaInsertPopover.svelte +449 -0
- package/dist/components/MediaInsertPopover.svelte.d.ts +58 -0
- package/dist/components/MediaPicker.svelte +257 -0
- package/dist/components/MediaPicker.svelte.d.ts +41 -0
- package/dist/components/admin-icons.d.ts +12 -0
- package/dist/components/admin-icons.js +12 -0
- package/dist/components/cairn-admin.css +901 -9
- package/dist/components/client-ingest.d.ts +142 -0
- package/dist/components/client-ingest.js +297 -0
- package/dist/components/editor-media.d.ts +11 -0
- package/dist/components/editor-media.js +206 -0
- package/dist/components/editor-placeholder.d.ts +26 -0
- package/dist/components/editor-placeholder.js +166 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/markdown-directives.d.ts +12 -0
- package/dist/components/markdown-directives.js +42 -0
- package/dist/components/markdown-format.d.ts +89 -0
- package/dist/components/markdown-format.js +255 -0
- package/dist/components/media-upload-outcome.d.ts +52 -0
- package/dist/components/media-upload-outcome.js +48 -0
- package/dist/content/compose.js +3 -0
- package/dist/content/frontmatter.js +22 -0
- package/dist/content/manifest.d.ts +4 -0
- package/dist/content/manifest.js +41 -1
- package/dist/content/media-refs.d.ts +7 -0
- package/dist/content/media-refs.js +52 -0
- package/dist/content/schema.d.ts +5 -2
- package/dist/content/schema.js +17 -0
- package/dist/content/types.d.ts +64 -11
- package/dist/content/validate.js +31 -0
- package/dist/delivery/public-routes.d.ts +16 -0
- package/dist/delivery/public-routes.js +46 -3
- package/dist/delivery/seo-fields.js +7 -1
- package/dist/delivery/seo.d.ts +2 -0
- package/dist/delivery/seo.js +3 -0
- package/dist/doctor/checks-local.d.ts +1 -0
- package/dist/doctor/checks-local.js +21 -0
- package/dist/doctor/index.d.ts +3 -1
- package/dist/doctor/index.js +11 -2
- package/dist/doctor/types.d.ts +3 -0
- package/dist/doctor/wrangler-config.d.ts +3 -0
- package/dist/doctor/wrangler-config.js +20 -0
- package/dist/env.d.ts +19 -0
- package/dist/env.js +26 -0
- package/dist/index.d.ts +1 -1
- package/dist/log/events.d.ts +1 -1
- package/dist/media/config.d.ts +24 -0
- package/dist/media/config.js +69 -0
- package/dist/media/delivery-bucket.d.ts +34 -0
- package/dist/media/delivery-bucket.js +10 -0
- package/dist/media/index.d.ts +6 -0
- package/dist/media/index.js +13 -0
- package/dist/media/library-entry.d.ts +30 -0
- package/dist/media/library-entry.js +17 -0
- package/dist/media/manifest.d.ts +44 -0
- package/dist/media/manifest.js +105 -0
- package/dist/media/naming.d.ts +18 -0
- package/dist/media/naming.js +112 -0
- package/dist/media/reconcile.d.ts +36 -0
- package/dist/media/reconcile.js +45 -0
- package/dist/media/reference.d.ts +12 -0
- package/dist/media/reference.js +33 -0
- package/dist/media/sniff.d.ts +18 -0
- package/dist/media/sniff.js +106 -0
- package/dist/media/store.d.ts +25 -0
- package/dist/media/store.js +16 -0
- package/dist/media/transform-url.d.ts +26 -0
- package/dist/media/transform-url.js +38 -0
- package/dist/media/usage.d.ts +48 -0
- package/dist/media/usage.js +90 -0
- package/dist/render/pipeline.d.ts +2 -0
- package/dist/render/pipeline.js +13 -2
- package/dist/render/registry.js +3 -0
- package/dist/render/remark-figure.d.ts +4 -0
- package/dist/render/remark-figure.js +103 -0
- package/dist/render/resolve-media.d.ts +34 -0
- package/dist/render/resolve-media.js +78 -0
- package/dist/render/sanitize-schema.d.ts +4 -2
- package/dist/render/sanitize-schema.js +5 -3
- package/dist/sveltekit/admin-dispatch.d.ts +2 -0
- package/dist/sveltekit/admin-dispatch.js +5 -0
- package/dist/sveltekit/cairn-admin.d.ts +8 -1
- package/dist/sveltekit/cairn-admin.js +10 -2
- package/dist/sveltekit/content-routes.d.ts +77 -2
- package/dist/sveltekit/content-routes.js +470 -10
- package/dist/sveltekit/csrf.d.ts +16 -0
- package/dist/sveltekit/csrf.js +18 -0
- package/dist/sveltekit/guard.js +10 -3
- package/dist/sveltekit/index.d.ts +2 -1
- package/dist/sveltekit/index.js +1 -0
- package/dist/sveltekit/media-route.d.ts +12 -0
- package/dist/sveltekit/media-route.js +137 -0
- package/dist/vite/index.d.ts +3 -0
- package/dist/vite/index.js +7 -2
- package/package.json +7 -1
- package/src/lib/components/AdminLayout.svelte +3 -0
- package/src/lib/components/CairnAdmin.svelte +8 -1
- package/src/lib/components/CairnMediaLibrary.svelte +949 -0
- package/src/lib/components/EditPage.svelte +348 -7
- package/src/lib/components/MarkdownEditor.svelte +283 -1
- package/src/lib/components/MediaCaptureCard.svelte +135 -0
- package/src/lib/components/MediaFigureControl.svelte +247 -0
- package/src/lib/components/MediaHeroField.svelte +578 -0
- package/src/lib/components/MediaInsertPopover.svelte +449 -0
- package/src/lib/components/MediaPicker.svelte +257 -0
- package/src/lib/components/admin-icons.ts +12 -0
- package/src/lib/components/cairn-admin.css +37 -0
- package/src/lib/components/client-ingest.ts +380 -0
- package/src/lib/components/editor-media.ts +248 -0
- package/src/lib/components/editor-placeholder.ts +213 -0
- package/src/lib/components/index.ts +1 -0
- package/src/lib/components/markdown-directives.ts +46 -0
- package/src/lib/components/markdown-format.ts +307 -1
- package/src/lib/components/media-upload-outcome.ts +83 -0
- package/src/lib/content/compose.ts +3 -0
- package/src/lib/content/frontmatter.ts +20 -1
- package/src/lib/content/manifest.ts +44 -1
- package/src/lib/content/media-refs.ts +58 -0
- package/src/lib/content/schema.ts +31 -7
- package/src/lib/content/types.ts +80 -13
- package/src/lib/content/validate.ts +29 -1
- package/src/lib/delivery/public-routes.ts +52 -3
- package/src/lib/delivery/seo-fields.ts +6 -1
- package/src/lib/delivery/seo.ts +5 -0
- package/src/lib/doctor/checks-local.ts +22 -0
- package/src/lib/doctor/index.ts +21 -3
- package/src/lib/doctor/types.ts +3 -0
- package/src/lib/doctor/wrangler-config.ts +23 -0
- package/src/lib/env.ts +28 -0
- package/src/lib/index.ts +2 -0
- package/src/lib/log/events.ts +8 -1
- package/src/lib/media/config.ts +103 -0
- package/src/lib/media/delivery-bucket.ts +41 -0
- package/src/lib/media/index.ts +22 -0
- package/src/lib/media/library-entry.ts +58 -0
- package/src/lib/media/manifest.ts +122 -0
- package/src/lib/media/naming.ts +130 -0
- package/src/lib/media/reconcile.ts +79 -0
- package/src/lib/media/reference.ts +40 -0
- package/src/lib/media/sniff.ts +114 -0
- package/src/lib/media/store.ts +57 -0
- package/src/lib/media/transform-url.ts +58 -0
- package/src/lib/media/usage.ts +152 -0
- package/src/lib/render/pipeline.ts +17 -3
- package/src/lib/render/registry.ts +5 -0
- package/src/lib/render/remark-figure.ts +132 -0
- package/src/lib/render/resolve-media.ts +96 -0
- package/src/lib/render/sanitize-schema.ts +5 -3
- package/src/lib/sveltekit/admin-dispatch.ts +6 -1
- package/src/lib/sveltekit/cairn-admin.ts +13 -3
- package/src/lib/sveltekit/content-routes.ts +589 -12
- package/src/lib/sveltekit/csrf.ts +18 -0
- package/src/lib/sveltekit/guard.ts +12 -3
- package/src/lib/sveltekit/index.ts +6 -0
- package/src/lib/sveltekit/media-route.ts +158 -0
- package/src/lib/vite/index.ts +9 -2
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { fail } from '@sveltejs/kit';
|
|
2
2
|
import { type GithubKeyEnv } from '../github/credentials.js';
|
|
3
3
|
import { type LinkTarget, type InboundLink } from '../content/manifest.js';
|
|
4
|
+
import type { MediaEntry } from '../media/manifest.js';
|
|
5
|
+
import type { MediaLibrary, MediaLibraryEntry } from '../media/library-entry.js';
|
|
6
|
+
import type { UsageEntry } from '../media/usage.js';
|
|
4
7
|
import type { CookieJar, EventBase } from './types.js';
|
|
5
8
|
import type { CairnRuntime, FrontmatterField, ResolvedPreview } from '../content/types.js';
|
|
6
9
|
import type { Role } from '../auth/types.js';
|
|
@@ -83,6 +86,18 @@ export interface EditData {
|
|
|
83
86
|
slug: string;
|
|
84
87
|
/** The site's link targets, for the preview resolver and the link picker; from the committed manifest. */
|
|
85
88
|
linkTargets: LinkTarget[];
|
|
89
|
+
/** The minimal media-resolver input the edit page builds its preview `resolveMedia` from, keyed by
|
|
90
|
+
* the 16-hex content hash and parallel to `linkTargets`. Empty when media is off or the read fails. */
|
|
91
|
+
mediaTargets: Record<string, {
|
|
92
|
+
slug: string;
|
|
93
|
+
ext: string;
|
|
94
|
+
contentType: string;
|
|
95
|
+
}>;
|
|
96
|
+
/** The picker's human layer for each stored asset, keyed by the 16-hex content hash and projected
|
|
97
|
+
* from the same committed media manifest read that populates `mediaTargets`. The `hash` field
|
|
98
|
+
* duplicates the key, so the picker can iterate `Object.values`. Empty when media is off or the
|
|
99
|
+
* read fails (the same degradation path as `mediaTargets`). */
|
|
100
|
+
mediaLibrary: MediaLibrary;
|
|
86
101
|
/** The entries that link to this one, for the delete guard. Empty when nothing links here. */
|
|
87
102
|
inboundLinks: InboundLink[];
|
|
88
103
|
/** True when the entry has a pending branch, so the body above came from that branch. */
|
|
@@ -98,6 +113,32 @@ export interface EditData {
|
|
|
98
113
|
* leaves the frame rendering unstyled markup behind a hint. */
|
|
99
114
|
preview: ResolvedPreview | null;
|
|
100
115
|
}
|
|
116
|
+
/** One asset's where-used overlay, kept separate from MediaLibraryEntry so the picker's shared
|
|
117
|
+
* projection stays decoupled from the Library-only usage facts. */
|
|
118
|
+
export interface MediaUsageInfo {
|
|
119
|
+
/** Distinct content entries that reference the asset (count by distinct concept+id). */
|
|
120
|
+
count: number;
|
|
121
|
+
/** Every where-used row (published and edit-branch origins), for the detail's grouped list. */
|
|
122
|
+
entries: UsageEntry[];
|
|
123
|
+
}
|
|
124
|
+
/** The Media Library screen's data: the unioned assets, the per-hash usage overlay, and the
|
|
125
|
+
* degraded-load error. The usage overlay is keyed by content hash; an asset with no references
|
|
126
|
+
* simply has no key, which the screen renders as "no references found". */
|
|
127
|
+
export interface MediaLibraryData {
|
|
128
|
+
assets: MediaLibraryEntry[];
|
|
129
|
+
/** Per-hash usage overlay, kept separate from MediaLibraryEntry so the popover stays decoupled. */
|
|
130
|
+
usage: Record<string, MediaUsageInfo>;
|
|
131
|
+
/** The degraded-load error: a failed token mint or media read. This slot is the failure of THIS
|
|
132
|
+
* load, distinct from a prior action's conflict error (see `flashError`), so a read failure and a
|
|
133
|
+
* redirected commit conflict never overwrite each other. */
|
|
134
|
+
error: string | null;
|
|
135
|
+
/** The success flash a redirected action carries: `deleted` from `?deleted=1`, `updated` from
|
|
136
|
+
* `?updated=1`, null otherwise. The component renders a polite success strip for each. */
|
|
137
|
+
flash: 'deleted' | 'updated' | null;
|
|
138
|
+
/** A redirected action's conflict error read from `?error=` (a commit-conflict bounce). Kept in
|
|
139
|
+
* its own slot rather than the degraded-load `error` above, so the two never collide. */
|
|
140
|
+
flashError: string | null;
|
|
141
|
+
}
|
|
101
142
|
/** The structural event the content routes read; a real SvelteKit RequestEvent satisfies it. */
|
|
102
143
|
export interface ContentEvent extends EventBase<GithubKeyEnv> {
|
|
103
144
|
params: Record<string, string>;
|
|
@@ -134,14 +175,45 @@ export interface RenameFailure {
|
|
|
134
175
|
/** The one-line human summary every content action failure carries. */
|
|
135
176
|
error: string;
|
|
136
177
|
}
|
|
178
|
+
/** A refused media delete: `fail(404)` for an asset not committed on the default branch, or
|
|
179
|
+
* `fail(409)` when a fresh usage read finds the asset still in use and the typed-slug override
|
|
180
|
+
* was not given. `fail(503)` covers media-off or a missing bucket binding. */
|
|
181
|
+
export interface MediaDeleteRefusal {
|
|
182
|
+
/** The one-line human summary every action failure carries. */
|
|
183
|
+
error: string;
|
|
184
|
+
/** The refused asset's content hash, so the dialog marks the right asset. */
|
|
185
|
+
hash: string;
|
|
186
|
+
/** The where-used rows (published first, then by branch) the in-use face lists; empty otherwise. */
|
|
187
|
+
usage: UsageEntry[];
|
|
188
|
+
/** The distinct-entry count behind the refusal; zero when the asset is uncommitted. */
|
|
189
|
+
foundIn: number;
|
|
190
|
+
}
|
|
191
|
+
/** A refused media metadata edit: `fail(404)` for an asset not committed on the default branch, or
|
|
192
|
+
* `fail(400)` for an invalid slug. */
|
|
193
|
+
export interface MediaUpdateFailure {
|
|
194
|
+
/** The one-line human summary every action failure carries. */
|
|
195
|
+
error: string;
|
|
196
|
+
}
|
|
137
197
|
/** What a route's single `form` export presents to a view component: whichever content action
|
|
138
198
|
* last failed, merged with every field optional. `error` is always set on a failure; the richer
|
|
139
|
-
* keys identify which guard refused.
|
|
140
|
-
|
|
199
|
+
* keys identify which guard refused. The media refusals ride here too, so the Media Library's one
|
|
200
|
+
* `form` prop carries a `?/mediaDelete` or `?/mediaUpdate` refusal without a second type. */
|
|
201
|
+
export type ContentFormFailure = Partial<SaveFailure & DeleteRefusal & RenameFailure & MediaDeleteRefusal & MediaUpdateFailure>;
|
|
202
|
+
/** The successful upload's response (`uploadAction`). The server-owned `record` rides the editor's
|
|
203
|
+
* optimistic client state and commits with the entry at Save (the upload itself commits nothing).
|
|
204
|
+
* `reused` is true when identical bytes were already stored, so the second upload did no second put;
|
|
205
|
+
* `mismatch` flags an existing object whose stored content type differs from this sniff. */
|
|
206
|
+
export interface UploadResult {
|
|
207
|
+
reference: string;
|
|
208
|
+
record: MediaEntry;
|
|
209
|
+
reused: boolean;
|
|
210
|
+
mismatch: boolean;
|
|
211
|
+
}
|
|
141
212
|
export declare function createContentRoutes(runtime: CairnRuntime, deps?: ContentRoutesDeps): {
|
|
142
213
|
layoutLoad: (event: ContentEvent) => Promise<LayoutData>;
|
|
143
214
|
indexRedirect: () => never;
|
|
144
215
|
listLoad: (event: ContentEvent) => Promise<ListData>;
|
|
216
|
+
mediaLibraryLoad: (event: ContentEvent) => Promise<MediaLibraryData>;
|
|
145
217
|
createAction: (event: ContentEvent) => Promise<never>;
|
|
146
218
|
editLoad: (event: ContentEvent) => Promise<EditData>;
|
|
147
219
|
saveAction: (event: ContentEvent) => Promise<ReturnType<typeof fail> | never>;
|
|
@@ -151,5 +223,8 @@ export declare function createContentRoutes(runtime: CairnRuntime, deps?: Conten
|
|
|
151
223
|
deleteAction: (event: ContentEvent) => Promise<ReturnType<typeof fail> | never>;
|
|
152
224
|
listDeleteAction: (event: ContentEvent) => Promise<ReturnType<typeof fail> | never>;
|
|
153
225
|
renameAction: (event: ContentEvent) => Promise<ReturnType<typeof fail> | never>;
|
|
226
|
+
uploadAction: (event: ContentEvent) => Promise<ReturnType<typeof fail> | UploadResult>;
|
|
227
|
+
mediaDeleteAction: (event: ContentEvent) => Promise<ReturnType<typeof fail> | never>;
|
|
228
|
+
mediaUpdateAction: (event: ContentEvent) => Promise<ReturnType<typeof fail> | never>;
|
|
154
229
|
mintToken: (env: GithubKeyEnv) => string | Promise<string>;
|
|
155
230
|
};
|