sandcms 0.5.2 → 0.6.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 (151) hide show
  1. package/README.md +6 -4
  2. package/dist/admin/Account.svelte +4 -1
  3. package/dist/admin/ApiKeys.svelte +159 -0
  4. package/dist/admin/ApiKeys.svelte.d.ts +3 -0
  5. package/dist/admin/AssetAttachment.svelte +6 -4
  6. package/dist/admin/BlueprintFields.svelte +86 -0
  7. package/dist/admin/BlueprintFields.svelte.d.ts +15 -0
  8. package/dist/admin/Collection.svelte +40 -7
  9. package/dist/admin/Editor.svelte +57 -17
  10. package/dist/admin/Fields.svelte +217 -144
  11. package/dist/admin/Fields.svelte.d.ts +1 -0
  12. package/dist/admin/FocusPicker.svelte +136 -0
  13. package/dist/admin/FocusPicker.svelte.d.ts +11 -0
  14. package/dist/admin/Gallery.svelte +40 -34
  15. package/dist/admin/GlobalSearch.svelte +56 -0
  16. package/dist/admin/GlobalSearch.svelte.d.ts +3 -0
  17. package/dist/admin/Inbox.svelte +8 -5
  18. package/dist/admin/LinkField.svelte +116 -0
  19. package/dist/admin/LinkField.svelte.d.ts +17 -0
  20. package/dist/admin/MediaLibrary.svelte +41 -14
  21. package/dist/admin/MediaPicker.svelte +12 -2
  22. package/dist/admin/Navigation.svelte +62 -0
  23. package/dist/admin/Navigation.svelte.d.ts +7 -0
  24. package/dist/admin/NotificationSettings.svelte +2 -2
  25. package/dist/admin/SearchList.svelte +55 -0
  26. package/dist/admin/SearchList.svelte.d.ts +42 -0
  27. package/dist/admin/SelectField.svelte +3 -1
  28. package/dist/admin/SelectField.svelte.d.ts +1 -0
  29. package/dist/admin/Shell.svelte +16 -24
  30. package/dist/admin/UnsavedChanges.svelte +1 -1
  31. package/dist/admin/Users.svelte +11 -5
  32. package/dist/admin/client.js +2 -1
  33. package/dist/admin/generated/admin.css +145 -0
  34. package/dist/admin/navigation.d.ts +7 -0
  35. package/dist/admin/navigation.js +25 -0
  36. package/dist/admin/types.d.ts +5 -1
  37. package/dist/admin/uploads.js +27 -6
  38. package/dist/blueprints/conditions.d.ts +2 -0
  39. package/dist/blueprints/conditions.js +4 -0
  40. package/dist/blueprints/extends.d.ts +5 -0
  41. package/dist/blueprints/extends.js +76 -0
  42. package/dist/blueprints/files.d.ts +3 -1
  43. package/dist/blueprints/files.js +35 -2
  44. package/dist/blueprints/layout.d.ts +4 -0
  45. package/dist/blueprints/layout.js +12 -0
  46. package/dist/blueprints/load.d.ts +1 -1
  47. package/dist/blueprints/load.js +127 -12
  48. package/dist/blueprints/types.d.ts +38 -1
  49. package/dist/blueprints/validate.js +30 -6
  50. package/dist/cli/cloudflare.js +15 -3
  51. package/dist/cli/doctor.js +6 -3
  52. package/dist/cli/files.js +1 -1
  53. package/dist/cli/scaffold.js +8 -6
  54. package/dist/cli/setup.js +9 -2
  55. package/dist/cli/upgrade.js +2 -1
  56. package/dist/email-failure.d.ts +17 -0
  57. package/dist/email-failure.js +22 -0
  58. package/dist/index.d.ts +2 -1
  59. package/dist/index.js +1 -0
  60. package/dist/link.d.ts +17 -0
  61. package/dist/link.js +44 -0
  62. package/dist/notification-fields.js +1 -1
  63. package/dist/search.d.ts +8 -0
  64. package/dist/search.js +1 -0
  65. package/dist/server/access.d.ts +2 -0
  66. package/dist/server/access.js +59 -23
  67. package/dist/server/admin-load.d.ts +29 -2
  68. package/dist/server/admin-load.js +4 -2
  69. package/dist/server/api-access.d.ts +31 -0
  70. package/dist/server/api-access.js +52 -0
  71. package/dist/server/api-pagination.d.ts +34 -0
  72. package/dist/server/api-pagination.js +87 -0
  73. package/dist/server/api.js +224 -32
  74. package/dist/server/auth.d.ts +1150 -0
  75. package/dist/server/auth.js +11 -1
  76. package/dist/server/cms.d.ts +1208 -4
  77. package/dist/server/cms.js +2 -0
  78. package/dist/server/content.d.ts +17 -2
  79. package/dist/server/content.js +89 -14
  80. package/dist/server/db/migration-data.js +24 -0
  81. package/dist/server/db/migrations/0001_independent_password_resets.sql +3 -0
  82. package/dist/server/db/migrations/0002_email_failure_reason.sql +1 -0
  83. package/dist/server/db/migrations/0003_direct_r2_uploads.sql +10 -0
  84. package/dist/server/db/migrations/0004_agent_api_keys.sql +38 -0
  85. package/dist/server/db/migrations/0005_api_retention_and_pagination.sql +3 -0
  86. package/dist/server/db/migrations/0006_durable_media_deletion.sql +7 -0
  87. package/dist/server/db/migrations/meta/0001_snapshot.json +1197 -0
  88. package/dist/server/db/migrations/meta/0002_snapshot.json +1204 -0
  89. package/dist/server/db/migrations/meta/0003_snapshot.json +1281 -0
  90. package/dist/server/db/migrations/meta/0004_snapshot.json +1546 -0
  91. package/dist/server/db/migrations/meta/0005_snapshot.json +1572 -0
  92. package/dist/server/db/migrations/meta/0006_snapshot.json +1627 -0
  93. package/dist/server/db/migrations/meta/_journal.json +42 -0
  94. package/dist/server/db/schema.d.ts +742 -2
  95. package/dist/server/db/schema.js +77 -5
  96. package/dist/server/email/index.d.ts +11 -1
  97. package/dist/server/email/index.js +69 -6
  98. package/dist/server/forms.js +12 -2
  99. package/dist/server/hooks.d.ts +1 -1
  100. package/dist/server/hooks.js +37 -14
  101. package/dist/server/index.d.ts +1 -1
  102. package/dist/server/index.js +1 -1
  103. package/dist/server/links.d.ts +5 -0
  104. package/dist/server/links.js +44 -0
  105. package/dist/server/media/deletions.d.ts +2 -0
  106. package/dist/server/media/deletions.js +58 -0
  107. package/dist/server/media/presets.d.ts +10 -2
  108. package/dist/server/media/presets.js +14 -2
  109. package/dist/server/media/runner.d.ts +1 -1
  110. package/dist/server/media/runner.js +105 -8
  111. package/dist/server/media/service.d.ts +41 -3
  112. package/dist/server/media/service.js +146 -33
  113. package/dist/server/notifications.d.ts +1 -0
  114. package/dist/server/notifications.js +4 -2
  115. package/dist/server/request.d.ts +2 -0
  116. package/dist/server/request.js +5 -0
  117. package/dist/server/search.d.ts +13 -0
  118. package/dist/server/search.js +97 -0
  119. package/dist/worker/index.d.ts +3 -3
  120. package/dist/worker/index.js +205 -64
  121. package/dist/worker/local.d.ts +5 -0
  122. package/dist/worker/local.js +57 -0
  123. package/dist/worker/source.d.ts +1 -1
  124. package/dist/worker/source.js +2 -2
  125. package/dist/worker/uploads.d.ts +22 -0
  126. package/dist/worker/uploads.js +46 -0
  127. package/docs/acceptance.md +1 -1
  128. package/docs/api.md +73 -0
  129. package/docs/cloudflare.md +35 -8
  130. package/docs/content.md +181 -5
  131. package/docs/deployment.md +29 -4
  132. package/docs/email.md +14 -10
  133. package/docs/forms.md +3 -1
  134. package/docs/media.md +34 -5
  135. package/docs/package.md +7 -5
  136. package/docs/releases.md +56 -1
  137. package/docs/upgrades.md +59 -3
  138. package/package.json +19 -10
  139. package/templates/hooks.server.ts +3 -3
  140. package/templates/integration.ts +2 -2
  141. package/templates/routes/admin/+page.server.ts +2 -2
  142. package/templates/routes/admin/+page.svelte +1 -1
  143. package/templates/routes/api/+server.ts +2 -2
  144. package/templates/sandcms/blueprints/collections/projects.yaml +16 -8
  145. package/templates/sandcms/blueprints/fields/seo.yaml +5 -0
  146. package/templates/sandcms/blueprints/files/image.yaml +1 -0
  147. package/templates/sandcms/blueprints/pages/home.yaml +3 -0
  148. package/templates/sandcms/config.yaml +1 -0
  149. package/templates/sandcms/worker/index.ts +1 -1
  150. package/templates/sandcms/worker/local.ts +1 -0
  151. package/templates/sandcms/worker/wrangler.jsonc +1 -2
@@ -0,0 +1,42 @@
1
+ import type { Snippet } from 'svelte';
2
+ declare function $$render<T extends {
3
+ id: string;
4
+ }>(): {
5
+ props: {
6
+ path: string;
7
+ initial: T[];
8
+ label: string;
9
+ children: Snippet<[T[]]>;
10
+ empty?: string;
11
+ refreshKey?: string;
12
+ };
13
+ exports: {};
14
+ bindings: "";
15
+ slots: {};
16
+ events: {};
17
+ };
18
+ declare class __sveltets_Render<T extends {
19
+ id: string;
20
+ }> {
21
+ props(): ReturnType<typeof $$render<T>>['props'];
22
+ events(): ReturnType<typeof $$render<T>>['events'];
23
+ slots(): ReturnType<typeof $$render<T>>['slots'];
24
+ bindings(): "";
25
+ exports(): {};
26
+ }
27
+ interface $$IsomorphicComponent {
28
+ new <T extends {
29
+ id: string;
30
+ }>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
31
+ $$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
32
+ } & ReturnType<__sveltets_Render<T>['exports']>;
33
+ <T extends {
34
+ id: string;
35
+ }>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
36
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
37
+ }
38
+ declare const SearchList: $$IsomorphicComponent;
39
+ type SearchList<T extends {
40
+ id: string;
41
+ }> = InstanceType<typeof SearchList<T>>;
42
+ export default SearchList;
@@ -7,6 +7,7 @@
7
7
  placeholder = 'Select…',
8
8
  clearable = true,
9
9
  invalid = false,
10
+ describedBy,
10
11
  onchange
11
12
  }: {
12
13
  id: string;
@@ -15,6 +16,7 @@
15
16
  placeholder?: string;
16
17
  clearable?: boolean;
17
18
  invalid?: boolean;
19
+ describedBy?: string;
18
20
  onchange?: (value: string) => void;
19
21
  } = $props();
20
22
  const label = $derived(options.find((option) => option.value === value)?.label ?? placeholder);
@@ -29,7 +31,7 @@
29
31
  onchange?.(next);
30
32
  }}
31
33
  >
32
- <Select.Trigger {id} class="w-full" aria-invalid={invalid}
34
+ <Select.Trigger {id} class="w-full" aria-invalid={invalid} aria-describedby={describedBy}
33
35
  ><span data-slot="select-value">{label}</span></Select.Trigger
34
36
  >
35
37
  <Select.Content portalProps={{ disabled: true }}>
@@ -8,6 +8,7 @@ type $$ComponentProps = {
8
8
  placeholder?: string;
9
9
  clearable?: boolean;
10
10
  invalid?: boolean;
11
+ describedBy?: string;
11
12
  onchange?: (value: string) => void;
12
13
  };
13
14
  declare const SelectField: import("svelte").Component<$$ComponentProps, {}, "value">;
@@ -6,7 +6,8 @@
6
6
  import { authClient } from './client.js';
7
7
  import { Button } from './components/ui/button/index.js';
8
8
  import * as Avatar from './components/ui/avatar/index.js';
9
- import { Icon } from '@lucide/svelte';
9
+ import Navigation from './Navigation.svelte';
10
+ import GlobalSearch from './GlobalSearch.svelte';
10
11
  import Layers from '@lucide/svelte/icons/layers';
11
12
  import LayoutDashboard from '@lucide/svelte/icons/layout-dashboard';
12
13
  import Image from '@lucide/svelte/icons/image';
@@ -17,14 +18,17 @@
17
18
  let open = $state(false);
18
19
  afterNavigate(() => (open = false));
19
20
  const selected = (href: string) =>
20
- href === '/admin' ? String(page.url.pathname) === '/admin' : page.url.pathname.startsWith(href);
21
+ href === '/admin'
22
+ ? String(page.url.pathname) === '/admin'
23
+ : page.url.pathname === href || page.url.pathname.startsWith(href + '/');
21
24
  async function logout() {
22
25
  const result = await authClient.signOut();
23
26
  if (!result.error) window.location.assign('/admin/login');
24
27
  }
25
28
  </script>
26
29
 
27
- <div class="cms-shell">
30
+ <!-- Singleton editor loads create drafts, so wait for navigation before loading data. -->
31
+ <div class="cms-shell" data-sveltekit-preload-data={false}>
28
32
  <aside class:cms-open={open} class="cms-sidebar">
29
33
  <a href="/admin" class="cms-wordmark"
30
34
  ><Layers size={23} /> SandCMS <span class="cms-version">V1</span></a
@@ -36,30 +40,18 @@
36
40
  <nav aria-label="Admin navigation">
37
41
  <a href="/admin" class:active={selected('/admin')}><LayoutDashboard size={17} /> Overview</a>
38
42
  <p class="cms-nav-label">CONTENT</p>
39
- {#each data.blueprints?.filter((b) => b.kind === 'page') ?? [] as b}<a
40
- href={'/admin/content/' + b.id}
41
- class:active={selected('/admin/content/' + b.id)}
42
- ><Icon icon={b.navigationIcon} size={17} />{b.label}</a
43
- >{/each}
44
- {#each data.blueprints?.filter((b) => b.kind === 'collection') ?? [] as b}<a
45
- href={'/admin/content/' + b.id}
46
- class:active={selected('/admin/content/' + b.id)}
47
- ><Icon icon={b.navigationIcon} size={17} />{b.label}</a
48
- >{/each}
43
+ <Navigation
44
+ blueprints={(data.blueprints ?? []).filter(
45
+ (b) => b.kind === 'page' || b.kind === 'collection'
46
+ )}
47
+ />
49
48
  <a href="/admin/media" class:active={selected('/admin/media')}
50
49
  ><Image size={17} /> Media library</a
51
50
  >
52
51
  <p class="cms-nav-label">WORKSPACE</p>
53
- {#each data.blueprints?.filter((b) => b.kind === 'form') ?? [] as b}<a
54
- href={'/admin/forms/' + b.id}
55
- class:active={selected('/admin/forms/' + b.id)}
56
- ><Icon icon={b.navigationIcon} size={17} />{b.label}</a
57
- >{/each}
58
- {#each data.blueprints?.filter((b) => b.kind === 'site') ?? [] as b}<a
59
- href={'/admin/content/' + b.id}
60
- class:active={selected('/admin/content/' + b.id)}
61
- ><Icon icon={b.navigationIcon} size={17} />{b.label}</a
62
- >{/each}
52
+ <Navigation
53
+ blueprints={(data.blueprints ?? []).filter((b) => b.kind === 'form' || b.kind === 'site')}
54
+ />
63
55
  {#if data.user?.role === 'admin'}<a
64
56
  href="/admin/users"
65
57
  class:active={selected('/admin/users')}><Users size={17} /> Users</a
@@ -97,7 +89,7 @@
97
89
  }[data.screen] ??
98
90
  'Overview'}</strong
99
91
  ></span
100
- ><a href="/" target="_blank" rel="noreferrer" class="cms-live"
92
+ >{#if !data.user?.mustChangePassword}<GlobalSearch />{/if}<a href="/" target="_blank" rel="noreferrer" class="cms-live"
101
93
  ><span></span> View website <ArrowUpRight size={14} /></a
102
94
  >
103
95
  </header>
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { beforeNavigate, goto } from '$app/navigation';
3
- import type { BeforeNavigate } from '@sveltejs/kit';
3
+ import type { BeforeNavigate } from '$app/navigation';
4
4
  import * as AlertDialog from './components/ui/alert-dialog/index.js';
5
5
  let { dirty }: { dirty: boolean } = $props();
6
6
  let open = $state(false);
@@ -1,7 +1,8 @@
1
1
  <script lang="ts">
2
+ import { emailFailureMessage } from '../email-failure.js';
2
3
  import * as Table from './components/ui/table/index.js';
3
4
  import * as Card from './components/ui/card/index.js';
4
- import { invalidateAll } from '$app/navigation';
5
+ import { refreshAll } from '$app/navigation';
5
6
  import type { AdminData } from './types.js';
6
7
  import { api, message } from './client.js';
7
8
  import { Button } from './components/ui/button/index.js';
@@ -16,7 +17,7 @@
16
17
  error = '';
17
18
  try {
18
19
  await api(path, { id });
19
- await invalidateAll();
20
+ await refreshAll();
20
21
  } catch (e) {
21
22
  error = message(e);
22
23
  } finally {
@@ -39,7 +40,7 @@
39
40
  password = '';
40
41
  name = '';
41
42
  email = '';
42
- await invalidateAll();
43
+ await refreshAll();
43
44
  } catch (e) {
44
45
  error = message(e);
45
46
  } finally {
@@ -92,7 +93,7 @@
92
93
  {#if data.invitations?.length}
93
94
  <h2>Pending invitations</h2>
94
95
  <p class="cms-muted">
95
- Accepted means the email provider accepted the message. It does not confirm inbox delivery.
96
+ Mail server acceptance does not confirm inbox delivery or invitation acceptance.
96
97
  </p>
97
98
  {#each data.invitations as invitation}
98
99
  <Card.Root
@@ -104,8 +105,13 @@
104
105
  : 'Expires ' + new Date(invitation.expiresAt).toLocaleString()} · Email: {invitation.status ===
105
106
  'sending'
106
107
  ? 'Sending or outcome unknown'
107
- : invitation.status}
108
+ : invitation.status === 'accepted'
109
+ ? 'Accepted by mail server'
110
+ : 'Failed'}
108
111
  </p>
112
+ {#if invitation.status === 'failed'}<p class="cms-error">
113
+ {emailFailureMessage(invitation.failureReason)}
114
+ </p>{/if}
109
115
  <div class="flex gap-2">
110
116
  <Button
111
117
  variant="outline"
@@ -24,6 +24,7 @@ export async function api(path, body) {
24
24
  }
25
25
  export const message = (e) => e instanceof Error ? e.message : 'Something went wrong. Please try again.';
26
26
  export function assetUrl(asset, _workerUrl) {
27
- return asset.variants[0] ? '/api/cms/media/' + asset.variants[0].key : '';
27
+ const preview = asset.variants.find((v) => v.preset === 'sandcms-preview') ?? asset.variants[0];
28
+ return preview ? '/api/cms/media/' + preview.key : '';
28
29
  }
29
30
  export const date = (timestamp) => new Intl.DateTimeFormat('en', { month: 'short', day: 'numeric', year: 'numeric' }).format(timestamp);
@@ -824,6 +824,9 @@
824
824
  .max-h-\(--bits-select-content-available-height\) {
825
825
  max-height: var(--bits-select-content-available-height);
826
826
  }
827
+ .max-h-\[80vh\] {
828
+ max-height: 80vh;
829
+ }
827
830
  .max-h-\[85vh\] {
828
831
  max-height: 85vh;
829
832
  }
@@ -943,6 +946,9 @@
943
946
  .cursor-default {
944
947
  cursor: default;
945
948
  }
949
+ .resize {
950
+ resize: both;
951
+ }
946
952
  .snap-x {
947
953
  scroll-snap-type: x var(--sandcms-tw-scroll-snap-strictness);
948
954
  }
@@ -2436,6 +2442,42 @@
2436
2442
  gap: 10px;
2437
2443
  padding: 16px 8px 6px;
2438
2444
  }
2445
+ .cms-nav-group {
2446
+ display: flex;
2447
+ width: 100%;
2448
+ align-items: center;
2449
+ gap: 11px;
2450
+ padding: 9px 10px;
2451
+ margin: 3px 0;
2452
+ color: var(--sandcms-muted-foreground);
2453
+ font-size: 12px;
2454
+ text-align: left;
2455
+ cursor: pointer;
2456
+ }
2457
+ .cms-nav-group:hover {
2458
+ background: var(--sandcms-accent);
2459
+ color: var(--sandcms-foreground);
2460
+ }
2461
+ .cms-nav-group:focus-visible {
2462
+ outline: 2px solid var(--sandcms-ring);
2463
+ outline-offset: -2px;
2464
+ }
2465
+ .cms-nav-group-active {
2466
+ color: var(--sandcms-primary);
2467
+ font-weight: 550;
2468
+ }
2469
+ .cms-nav-chevron {
2470
+ margin-left: auto;
2471
+ flex-shrink: 0;
2472
+ }
2473
+ .cms-nav-chevron-open {
2474
+ transform: rotate(90deg);
2475
+ }
2476
+ .cms-nav-children {
2477
+ margin-left: 18px;
2478
+ border-left: 1px solid var(--sandcms-border);
2479
+ padding-left: 5px;
2480
+ }
2439
2481
  .cms-main {
2440
2482
  margin-left: 244px;
2441
2483
  flex: 1;
@@ -2642,6 +2684,37 @@
2642
2684
  display: flex;
2643
2685
  gap: 8px;
2644
2686
  }
2687
+ .cms-input-control {
2688
+ display: flex;
2689
+ flex: 1;
2690
+ min-width: 0;
2691
+ align-items: center;
2692
+ }
2693
+ .cms-input-affix {
2694
+ display: flex;
2695
+ align-items: center;
2696
+ align-self: stretch;
2697
+ border: 1px solid var(--sandcms-input);
2698
+ background: var(--sandcms-muted);
2699
+ padding: 0 10px;
2700
+ font-size: 12px;
2701
+ overflow-wrap: anywhere;
2702
+ }
2703
+ .cms-field-helpers {
2704
+ display: flex;
2705
+ flex-wrap: wrap;
2706
+ gap: 4px 12px;
2707
+ font-size: 11px;
2708
+ color: var(--sandcms-muted-foreground);
2709
+ }
2710
+ .cms-field-help {
2711
+ flex: 1;
2712
+ min-width: 0;
2713
+ overflow-wrap: anywhere;
2714
+ }
2715
+ .cms-field-counter {
2716
+ margin-left: auto;
2717
+ }
2645
2718
  .cms-checkbox {
2646
2719
  display: flex;
2647
2720
  gap: 8px;
@@ -2743,6 +2816,57 @@
2743
2816
  font-size: 12px;
2744
2817
  overflow-wrap: anywhere;
2745
2818
  }
2819
+ .cms-editor-fields {
2820
+ container-type: inline-size;
2821
+ min-width: 0;
2822
+ }
2823
+ .cms-fields, .cms-blueprint-columns {
2824
+ display: grid;
2825
+ grid-template-columns: repeat(12, minmax(0, 1fr));
2826
+ gap: 22px;
2827
+ align-items: start;
2828
+ }
2829
+ .cms-fields > .cms-field, .cms-blueprint-column {
2830
+ grid-column: span var(--sandcms-cms-span, 12);
2831
+ }
2832
+ .cms-blueprint-column, .cms-blueprint-section {
2833
+ display: grid;
2834
+ gap: 22px;
2835
+ min-width: 0;
2836
+ }
2837
+ .cms-blueprint-section h2 {
2838
+ font-size: 16px;
2839
+ font-weight: 550;
2840
+ }
2841
+ .cms-blueprint-tabs {
2842
+ display: flex;
2843
+ flex-wrap: wrap;
2844
+ gap: 8px;
2845
+ border-bottom: 1px solid var(--sandcms-border);
2846
+ margin-bottom: 22px;
2847
+ }
2848
+ .cms-blueprint-tab {
2849
+ padding: 10px 12px;
2850
+ border-bottom: 2px solid transparent;
2851
+ cursor: pointer;
2852
+ }
2853
+ .cms-blueprint-tab[data-state='active'] {
2854
+ border-bottom-color: var(--sandcms-foreground);
2855
+ }
2856
+ .cms-blueprint-tab:focus-visible {
2857
+ outline: 2px solid var(--sandcms-ring);
2858
+ outline-offset: -2px;
2859
+ }
2860
+ @container (max-width: 560px) {
2861
+ .cms-fields > .cms-field, .cms-blueprint-column {
2862
+ grid-column: span 12;
2863
+ }
2864
+ }
2865
+ @media (max-width: 640px) {
2866
+ .cms-fields > .cms-field, .cms-blueprint-column {
2867
+ grid-column: span 12;
2868
+ }
2869
+ }
2746
2870
  .cms-media-grid {
2747
2871
  display: grid;
2748
2872
  grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
@@ -2916,6 +3040,19 @@
2916
3040
  transition: none;
2917
3041
  }
2918
3042
  }
3043
+ .cms-search-result {
3044
+ display: flex;
3045
+ flex-direction: column;
3046
+ gap: 0.25rem;
3047
+ padding: 0.75rem;
3048
+ border: 1px solid var(--sandcms-border);
3049
+ border-radius: 0.5rem;
3050
+ overflow-wrap: anywhere;
3051
+ }
3052
+ .cms-search-result:focus-visible {
3053
+ outline: 2px solid currentColor;
3054
+ outline-offset: 2px;
3055
+ }
2919
3056
  .cms-account-grid {
2920
3057
  display: grid;
2921
3058
  grid-template-columns: repeat(2, minmax(0, 1fr));
@@ -3105,6 +3242,14 @@ a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible
3105
3242
  height: 130px;
3106
3243
  }
3107
3244
  }
3245
+ @media (max-width: 640px) {
3246
+ .cms-search-trigger {
3247
+ padding: 0.5rem;
3248
+ }
3249
+ .cms-search-trigger span, .cms-search-trigger kbd {
3250
+ display: none;
3251
+ }
3252
+ }
3108
3253
  :scope {
3109
3254
  --sandcms-background: oklch(1 0 0);
3110
3255
  --sandcms-foreground: oklch(0.147 0.004 49.25);
@@ -0,0 +1,7 @@
1
+ import type { Blueprint } from '../blueprints/types.js';
2
+ export declare function navigationGroups<T extends Blueprint>(blueprints: T[]): {
3
+ group: string | false;
4
+ blueprints: T[];
5
+ }[];
6
+ export declare const blueprintHref: (blueprint: Blueprint) => string;
7
+ export declare const navigationSelected: (pathname: string, href: string) => boolean;
@@ -0,0 +1,25 @@
1
+ export function navigationGroups(blueprints) {
2
+ const items = [];
3
+ const groups = new Map();
4
+ // Preserve the existing kind order, then blueprint order within each kind.
5
+ for (const kind of ['page', 'collection', 'form', 'site']) {
6
+ for (const blueprint of blueprints.filter((b) => b.kind === kind)) {
7
+ const group = blueprint.navigation?.group ?? (kind === 'page' ? 'Pages' : false);
8
+ if (group === false) {
9
+ items.push({ group, blueprints: [blueprint] });
10
+ }
11
+ else {
12
+ let item = groups.get(group);
13
+ if (!item) {
14
+ item = { group, blueprints: [] };
15
+ groups.set(group, item);
16
+ items.push(item);
17
+ }
18
+ item.blueprints.push(blueprint);
19
+ }
20
+ }
21
+ }
22
+ return items;
23
+ }
24
+ export const blueprintHref = (blueprint) => `/admin/${blueprint.kind === 'form' ? 'forms' : 'content'}/${blueprint.id}`;
25
+ export const navigationSelected = (pathname, href) => pathname === href || pathname.startsWith(href + '/');
@@ -1,9 +1,12 @@
1
+ import type { EmailFailureReason } from '../email-failure.js';
1
2
  import type { Blueprint, FileBlueprint } from '../blueprints/types.js';
2
3
  import type { LucideIconData } from '@lucide/svelte';
3
4
  import type { documents, media, submissions, NotificationSettings } from '../server/db/schema.js';
4
5
  import type { CmsUser } from '../server/auth.js';
5
6
  export type Entry = typeof documents.$inferSelect;
6
- export type Asset = typeof media.$inferSelect;
7
+ export type Asset = typeof media.$inferSelect & {
8
+ expectedVersion?: string;
9
+ };
7
10
  export type Submission = typeof submissions.$inferSelect;
8
11
  export type Relations = Record<string, {
9
12
  id: string;
@@ -19,6 +22,7 @@ export interface AdminData {
19
22
  role: string;
20
23
  expiresAt: number;
21
24
  status: string;
25
+ failureReason?: EmailFailureReason | null;
22
26
  }[];
23
27
  notificationSettings?: NotificationSettings;
24
28
  notificationsEnabled?: boolean;
@@ -2,15 +2,36 @@ import { api, message } from './client.js';
2
2
  export async function uploadImages(files, onAsset, onProgress, blueprint, onState) {
3
3
  const failures = [];
4
4
  onProgress(0, files.length, 0);
5
- // One bounded request at a time keeps large batches within the server's per-file limit.
5
+ // Transfer one file at a time directly to private R2 staging.
6
6
  for (const [index, file] of files.entries()) {
7
7
  onState?.(index, 'uploading');
8
8
  try {
9
- const form = new FormData();
10
- form.set('file', file);
11
- if (blueprint)
12
- form.set('blueprint', blueprint);
13
- onAsset(await api('media/upload', form));
9
+ const signed = await api('media/upload', {
10
+ name: file.name,
11
+ type: file.type,
12
+ size: file.size,
13
+ blueprint
14
+ });
15
+ const response = await fetch(signed.url, {
16
+ method: 'PUT',
17
+ headers: signed.headers,
18
+ body: file
19
+ });
20
+ if (!response.ok)
21
+ throw new Error('Upload failed. Please try again.');
22
+ // Completion is idempotent; retry a lost response without transferring the file again.
23
+ let asset;
24
+ for (let attempt = 0; attempt < 3; attempt++) {
25
+ try {
26
+ asset = await api('media/upload/complete', { id: signed.id });
27
+ break;
28
+ }
29
+ catch (error) {
30
+ if (attempt === 2)
31
+ throw error;
32
+ }
33
+ }
34
+ onAsset(asset);
14
35
  onState?.(index, 'done');
15
36
  }
16
37
  catch (error) {
@@ -0,0 +1,2 @@
1
+ import type { Field, Payload } from './types.js';
2
+ export declare function fieldVisible(field: Field, values: Payload): boolean;
@@ -0,0 +1,4 @@
1
+ // Conditions always read sibling data, independent of field order or visibility.
2
+ export function fieldVisible(field, values) {
3
+ return Object.entries(field.when ?? {}).every(([key, expected]) => Object.hasOwn(values, key) && values[key] === expected);
4
+ }
@@ -0,0 +1,5 @@
1
+ import type { Field } from './types.js';
2
+ export declare function createFieldResolver(directory: string, read: (path: string, transform: (value: unknown) => unknown) => Field): {
3
+ shared: (path: string) => Field;
4
+ blueprint(value: unknown, path: string): unknown;
5
+ };
@@ -0,0 +1,76 @@
1
+ import { existsSync, realpathSync } from 'node:fs';
2
+ import { isAbsolute, join, relative, resolve } from 'node:path';
3
+ const mapping = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
4
+ // Arrays and scalar settings replace defaults; mappings retain inherited keys and order.
5
+ function merge(base, local) {
6
+ return Object.fromEntries([...new Set([...Object.keys(base), ...Object.keys(local)])].map((key) => [
7
+ key,
8
+ Object.hasOwn(local, key)
9
+ ? mapping(base[key]) && mapping(local[key])
10
+ ? merge(base[key], local[key])
11
+ : local[key]
12
+ : base[key]
13
+ ]));
14
+ }
15
+ export function createFieldResolver(directory, read) {
16
+ const sharedDirectory = resolve(directory, 'fields');
17
+ const cache = new Map();
18
+ const active = [];
19
+ function shared(path) {
20
+ const canonical = realpathSync(path);
21
+ const within = relative(realpathSync(sharedDirectory), canonical);
22
+ if (within.startsWith('..') || isAbsolute(within))
23
+ throw new Error(`${path}: shared fields must stay inside ${sharedDirectory}`);
24
+ if (active.includes(canonical))
25
+ throw new Error(`Circular field extends: ${[...active, canonical].join(' -> ')}`);
26
+ const cached = cache.get(canonical);
27
+ if (cached)
28
+ return structuredClone(cached);
29
+ active.push(canonical);
30
+ try {
31
+ const value = read(path, (value) => field(value, path));
32
+ cache.set(canonical, value);
33
+ return structuredClone(value);
34
+ }
35
+ finally {
36
+ active.pop();
37
+ }
38
+ }
39
+ function field(value, location) {
40
+ if (!mapping(value))
41
+ return value;
42
+ let result = value;
43
+ if (Object.hasOwn(value, 'extends')) {
44
+ const reference = value.extends;
45
+ if (typeof reference !== 'string' ||
46
+ !/^fields\/[a-zA-Z0-9_-]+(?:\/[a-zA-Z0-9_-]+)*$/.test(reference))
47
+ throw new Error(`${location}.extends: Use a reference such as fields/seo without an extension`);
48
+ const candidates = ['.yaml', '.yml'].map((extension) => join(directory, reference + extension));
49
+ const matches = candidates.filter(existsSync);
50
+ if (matches.length !== 1)
51
+ throw new Error(`${location}.extends: ${matches.length ? 'Ambiguous' : 'Unknown'} shared field ${reference}`);
52
+ const base = shared(matches[0]);
53
+ const local = Object.fromEntries(Object.entries(value).filter(([key]) => key !== 'extends'));
54
+ // Resolve explicit nested references before merging, so their defaults override
55
+ // the corresponding field in the inherited parent definition.
56
+ result = merge({ ...base }, nested(local, location));
57
+ }
58
+ return nested(result, location);
59
+ }
60
+ function nested(value, location) {
61
+ return mapping(value.fields)
62
+ ? { ...value, fields: fields(value.fields, `${location}.fields`) }
63
+ : value;
64
+ }
65
+ function fields(value, location) {
66
+ return Object.fromEntries(Object.entries(value).map(([key, value]) => [key, field(value, `${location}.${key}`)]));
67
+ }
68
+ return {
69
+ shared,
70
+ blueprint(value, path) {
71
+ return mapping(value) && mapping(value.fields)
72
+ ? { ...value, fields: fields(value.fields, `${path}: fields`) }
73
+ : value;
74
+ }
75
+ };
76
+ }
@@ -1,7 +1,9 @@
1
- import type { Field, FileBlueprint, Payload, SiteDefinition } from './types.js';
1
+ import type { Field, FileBlueprint, FocusPoint, Payload, SiteDefinition } from './types.js';
2
2
  export declare const imageMimeTypes: string[];
3
3
  export declare function fileBlueprints(definition: SiteDefinition): FileBlueprint[];
4
4
  export declare function getFileBlueprint(definition: SiteDefinition, id?: string | null): FileBlueprint;
5
5
  export declare function effectiveMetadata(defaults: Payload, overrides: Payload, fields: Record<string, Field>): Payload;
6
6
  export declare function publicMetadata(fields: Record<string, Field>, values: Payload): Payload;
7
7
  export declare function configureFileFields(definition: SiteDefinition): SiteDefinition;
8
+ export declare function isFocusPoint(value: unknown): value is FocusPoint;
9
+ export declare function fileFocus(blueprint: FileBlueprint, metadata: Payload): FocusPoint | undefined;