sandcms 0.6.2 → 0.7.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.
- package/README.md +14 -10
- package/dist/admin/Account.svelte +286 -83
- package/dist/admin/Admin.svelte +14 -1
- package/dist/admin/ApiKeys.svelte +146 -79
- package/dist/admin/AssetAttachment.svelte +10 -12
- package/dist/admin/AssetAttachment.svelte.d.ts +0 -1
- package/dist/admin/BlueprintFields.svelte +20 -5
- package/dist/admin/BlueprintFields.svelte.d.ts +2 -1
- package/dist/admin/Collection.svelte +111 -54
- package/dist/admin/Dashboard.svelte +3 -37
- package/dist/admin/DateField.svelte +75 -0
- package/dist/admin/DateField.svelte.d.ts +11 -0
- package/dist/admin/Editor.svelte +70 -65
- package/dist/admin/Fields.svelte +24 -23
- package/dist/admin/Fields.svelte.d.ts +0 -1
- package/dist/admin/FocusPicker.svelte +1 -2
- package/dist/admin/Gallery.svelte +2 -7
- package/dist/admin/Gallery.svelte.d.ts +0 -1
- package/dist/admin/GlobalSearch.svelte +54 -26
- package/dist/admin/HoverHint.svelte +37 -0
- package/dist/admin/HoverHint.svelte.d.ts +8 -0
- package/dist/admin/Inbox.svelte +6 -11
- package/dist/admin/LinkField.svelte +128 -66
- package/dist/admin/LinkField.svelte.d.ts +0 -1
- package/dist/admin/Login.svelte +0 -1
- package/dist/admin/MediaLibrary.svelte +70 -56
- package/dist/admin/MediaPicker.svelte +62 -55
- package/dist/admin/MediaPicker.svelte.d.ts +0 -1
- package/dist/admin/NotificationSettings.svelte +35 -27
- package/dist/admin/RichText.svelte +2 -2
- package/dist/admin/RowMenu.svelte +28 -0
- package/dist/admin/RowMenu.svelte.d.ts +10 -0
- package/dist/admin/SearchList.svelte +51 -14
- package/dist/admin/Shell.svelte +64 -29
- package/dist/admin/ThemePicker.svelte +72 -0
- package/dist/admin/ThemePicker.svelte.d.ts +18 -0
- package/dist/admin/UploadButton.svelte +2 -1
- package/dist/admin/UploadProgress.svelte +24 -0
- package/dist/admin/UploadProgress.svelte.d.ts +7 -0
- package/dist/admin/Users.svelte +106 -50
- package/dist/admin/client.d.ts +5 -670
- package/dist/admin/client.js +20 -1
- package/dist/admin/components/ui/alert/alert.svelte.d.ts +3 -13
- package/dist/admin/components/ui/attachment/attachment-media.svelte.d.ts +3 -13
- package/dist/admin/components/ui/attachment/attachment.svelte.d.ts +6 -26
- package/dist/admin/components/ui/badge/badge.svelte.d.ts +7 -25
- package/dist/admin/components/ui/button/button.svelte.d.ts +15 -53
- package/dist/admin/components/ui/calendar/calendar-caption.svelte +76 -0
- package/dist/admin/components/ui/calendar/calendar-caption.svelte.d.ts +19 -0
- package/dist/admin/components/ui/calendar/calendar-cell.svelte +19 -0
- package/dist/admin/components/ui/calendar/calendar-cell.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-day.svelte +33 -0
- package/dist/admin/components/ui/calendar/calendar-day.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-grid-body.svelte +12 -0
- package/dist/admin/components/ui/calendar/calendar-grid-body.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-grid-head.svelte +12 -0
- package/dist/admin/components/ui/calendar/calendar-grid-head.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-grid-row.svelte +12 -0
- package/dist/admin/components/ui/calendar/calendar-grid-row.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-grid.svelte +16 -0
- package/dist/admin/components/ui/calendar/calendar-grid.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-head-cell.svelte +19 -0
- package/dist/admin/components/ui/calendar/calendar-head-cell.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-header.svelte +19 -0
- package/dist/admin/components/ui/calendar/calendar-header.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-heading.svelte +16 -0
- package/dist/admin/components/ui/calendar/calendar-heading.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-month-select.svelte +48 -0
- package/dist/admin/components/ui/calendar/calendar-month-select.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-month.svelte +15 -0
- package/dist/admin/components/ui/calendar/calendar-month.svelte.d.ts +5 -0
- package/dist/admin/components/ui/calendar/calendar-months.svelte +19 -0
- package/dist/admin/components/ui/calendar/calendar-months.svelte.d.ts +5 -0
- package/dist/admin/components/ui/calendar/calendar-nav.svelte +19 -0
- package/dist/admin/components/ui/calendar/calendar-nav.svelte.d.ts +5 -0
- package/dist/admin/components/ui/calendar/calendar-next-button.svelte +37 -0
- package/dist/admin/components/ui/calendar/calendar-next-button.svelte.d.ts +8 -0
- package/dist/admin/components/ui/calendar/calendar-prev-button.svelte +37 -0
- package/dist/admin/components/ui/calendar/calendar-prev-button.svelte.d.ts +8 -0
- package/dist/admin/components/ui/calendar/calendar-year-select.svelte +47 -0
- package/dist/admin/components/ui/calendar/calendar-year-select.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar.svelte +115 -0
- package/dist/admin/components/ui/calendar/calendar.svelte.d.ts +21 -0
- package/dist/admin/components/ui/calendar/index.d.ts +19 -0
- package/dist/admin/components/ui/calendar/index.js +21 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-checkbox-group.svelte +16 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-checkbox-group.svelte.d.ts +4 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +46 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte.d.ts +9 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-content.svelte +31 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-content.svelte.d.ts +10 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-group-heading.svelte +22 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-group-heading.svelte.d.ts +8 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-group.svelte +7 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-group.svelte.d.ts +4 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-item.svelte +27 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-item.svelte.d.ts +8 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-label.svelte +24 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-label.svelte.d.ts +8 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-portal.svelte +7 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-portal.svelte.d.ts +3 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-radio-group.svelte +16 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-radio-group.svelte.d.ts +4 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte +36 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte.d.ts +4 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-separator.svelte +17 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-separator.svelte.d.ts +4 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-shortcut.svelte +23 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-shortcut.svelte.d.ts +5 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +31 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte.d.ts +10 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte +29 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte.d.ts +7 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub.svelte +7 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub.svelte.d.ts +3 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-trigger.svelte +7 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-trigger.svelte.d.ts +4 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu.svelte +7 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu.svelte.d.ts +3 -0
- package/dist/admin/components/ui/dropdown-menu/index.d.ts +18 -0
- package/dist/admin/components/ui/dropdown-menu/index.js +18 -0
- package/dist/admin/components/ui/input-otp/index.d.ts +5 -0
- package/dist/admin/components/ui/input-otp/index.js +5 -0
- package/dist/admin/components/ui/input-otp/input-otp-group.svelte +23 -0
- package/dist/admin/components/ui/input-otp/input-otp-group.svelte.d.ts +5 -0
- package/dist/admin/components/ui/input-otp/input-otp-separator.svelte +27 -0
- package/dist/admin/components/ui/input-otp/input-otp-separator.svelte.d.ts +5 -0
- package/dist/admin/components/ui/input-otp/input-otp-slot.svelte +29 -0
- package/dist/admin/components/ui/input-otp/input-otp-slot.svelte.d.ts +4 -0
- package/dist/admin/components/ui/input-otp/input-otp.svelte +24 -0
- package/dist/admin/components/ui/input-otp/input-otp.svelte.d.ts +4 -0
- package/dist/admin/components/ui/popover/index.d.ts +9 -0
- package/dist/admin/components/ui/popover/index.js +11 -0
- package/dist/admin/components/ui/popover/popover-close.svelte +7 -0
- package/dist/admin/components/ui/popover/popover-close.svelte.d.ts +4 -0
- package/dist/admin/components/ui/popover/popover-content.svelte +31 -0
- package/dist/admin/components/ui/popover/popover-content.svelte.d.ts +10 -0
- package/dist/admin/components/ui/popover/popover-description.svelte +20 -0
- package/dist/admin/components/ui/popover/popover-description.svelte.d.ts +5 -0
- package/dist/admin/components/ui/popover/popover-header.svelte +20 -0
- package/dist/admin/components/ui/popover/popover-header.svelte.d.ts +5 -0
- package/dist/admin/components/ui/popover/popover-portal.svelte +7 -0
- package/dist/admin/components/ui/popover/popover-portal.svelte.d.ts +3 -0
- package/dist/admin/components/ui/popover/popover-title.svelte +20 -0
- package/dist/admin/components/ui/popover/popover-title.svelte.d.ts +5 -0
- package/dist/admin/components/ui/popover/popover-trigger.svelte +17 -0
- package/dist/admin/components/ui/popover/popover-trigger.svelte.d.ts +4 -0
- package/dist/admin/components/ui/popover/popover.svelte +7 -0
- package/dist/admin/components/ui/popover/popover.svelte.d.ts +3 -0
- package/dist/admin/components/ui/switch/switch.svelte +2 -2
- package/dist/admin/components/ui/toggle/toggle.svelte.d.ts +6 -26
- package/dist/admin/components/ui/tooltip/index.d.ts +6 -0
- package/dist/admin/components/ui/tooltip/index.js +8 -0
- package/dist/admin/components/ui/tooltip/tooltip-content.svelte +48 -0
- package/dist/admin/components/ui/tooltip/tooltip-content.svelte.d.ts +11 -0
- package/dist/admin/components/ui/tooltip/tooltip-portal.svelte +7 -0
- package/dist/admin/components/ui/tooltip/tooltip-portal.svelte.d.ts +4 -0
- package/dist/admin/components/ui/tooltip/tooltip-provider.svelte +7 -0
- package/dist/admin/components/ui/tooltip/tooltip-provider.svelte.d.ts +4 -0
- package/dist/admin/components/ui/tooltip/tooltip-trigger.svelte +7 -0
- package/dist/admin/components/ui/tooltip/tooltip-trigger.svelte.d.ts +25 -0
- package/dist/admin/components/ui/tooltip/tooltip.svelte +7 -0
- package/dist/admin/components/ui/tooltip/tooltip.svelte.d.ts +25 -0
- package/dist/admin/generated/admin.css +1298 -234
- package/dist/admin/slug.d.ts +1 -0
- package/dist/admin/slug.js +6 -0
- package/dist/admin/theme-context.d.ts +7 -0
- package/dist/admin/theme-context.js +3 -0
- package/dist/admin/theme.d.ts +7 -0
- package/dist/admin/theme.js +14 -0
- package/dist/admin/types.d.ts +2 -1
- package/dist/admin/uploads.d.ts +8 -1
- package/dist/admin/uploads.js +94 -16
- package/dist/blueprints/files.js +1 -0
- package/dist/blueprints/load.js +7 -2
- package/dist/blueprints/types.d.ts +4 -1
- package/dist/cli/doctor.d.ts +3 -1
- package/dist/cli/doctor.js +85 -30
- package/dist/cli/files.d.ts +2 -6
- package/dist/cli/files.js +11 -2
- package/dist/cli/index.js +99 -31
- package/dist/cli/scaffold.js +8 -8
- package/dist/cli/setup.js +16 -26
- package/dist/cli/upgrade.js +21 -2
- package/dist/env.d.ts +32 -0
- package/dist/env.js +53 -3
- package/dist/server/admin-load.d.ts +13 -5
- package/dist/server/admin-load.js +8 -3
- package/dist/server/api-access.d.ts +4 -0
- package/dist/server/api-access.js +15 -2
- package/dist/server/api-pagination.d.ts +3 -0
- package/dist/server/api.js +11 -3
- package/dist/server/auth.d.ts +11 -9
- package/dist/server/auth.js +23 -0
- package/dist/server/cms.d.ts +65 -18
- package/dist/server/cms.js +62 -6
- package/dist/server/db/migration-data.js +4 -0
- package/dist/server/db/migrations/0009_local_media.sql +9 -0
- package/dist/server/db/migrations/meta/0009_snapshot.json +1763 -0
- package/dist/server/db/migrations/meta/_journal.json +7 -0
- package/dist/server/db/schema.d.ts +119 -2
- package/dist/server/db/schema.js +15 -3
- package/dist/server/hooks.js +155 -81
- package/dist/server/media/contracts.d.ts +115 -0
- package/dist/server/media/contracts.js +12 -0
- package/dist/server/media/deletions.d.ts +2 -1
- package/dist/server/media/deletions.js +3 -3
- package/dist/server/media/delivery.js +7 -11
- package/dist/server/media/import-r2.d.ts +56 -0
- package/dist/server/media/import-r2.js +342 -0
- package/dist/server/media/processor-child.d.ts +2 -0
- package/dist/server/media/processor-child.js +236 -0
- package/dist/server/media/processor.d.ts +51 -0
- package/dist/server/media/processor.js +135 -0
- package/dist/server/media/render-math.d.ts +24 -0
- package/dist/server/media/render-math.js +50 -0
- package/dist/server/media/runner.d.ts +30 -1
- package/dist/server/media/runner.js +418 -165
- package/dist/server/media/service.d.ts +56 -10
- package/dist/server/media/service.js +309 -98
- package/dist/server/media/storage.d.ts +5 -0
- package/dist/server/media/storage.js +279 -0
- package/dist/server/media/svg.d.ts +5 -0
- package/dist/server/media/svg.js +142 -0
- package/dist/server/media/upload-ticket.d.ts +12 -0
- package/dist/server/media/upload-ticket.js +35 -0
- package/dist/server/media/verify.d.ts +36 -0
- package/dist/server/media/verify.js +109 -0
- package/dist/server/platform/http.d.ts +27 -0
- package/dist/server/platform/http.js +77 -0
- package/dist/server/platform/index.d.ts +52 -0
- package/dist/server/platform/index.js +98 -0
- package/dist/server/platform/snapshots.d.ts +18 -0
- package/dist/server/platform/snapshots.js +110 -0
- package/dist/server/platform/volume.d.ts +20 -0
- package/dist/server/platform/volume.js +60 -0
- package/dist/worker/svg.d.ts +1 -5
- package/dist/worker/svg.js +2 -142
- package/docs/acceptance.md +6 -4
- package/docs/api.md +42 -4
- package/docs/cloudflare.md +48 -142
- package/docs/content.md +2 -2
- package/docs/deployment.md +159 -57
- package/docs/forms.md +1 -1
- package/docs/media.md +85 -21
- package/docs/package.md +21 -18
- package/docs/plans/0.7-self-hosted.md +264 -0
- package/docs/releases.md +27 -1
- package/docs/upgrades.md +44 -6
- package/package.json +38 -37
- package/templates/Dockerfile +28 -0
- package/templates/integration.ts +18 -2
- package/templates/railpack.json +1 -1
- package/templates/sandcms/blueprints/files/image.yaml +1 -1
- package/templates/sandcms/config.yaml +0 -1
- package/dist/cli/cloudflare.d.ts +0 -8
- package/dist/cli/cloudflare.js +0 -135
- package/templates/sandcms/worker/index.ts +0 -1
- package/templates/sandcms/worker/local.ts +0 -1
- package/templates/sandcms/worker/wrangler.jsonc +0 -6
|
@@ -31,6 +31,9 @@ export declare function mediaPage(cms: CMS, params: URLSearchParams): {
|
|
|
31
31
|
error: string | null;
|
|
32
32
|
createdAt: number;
|
|
33
33
|
searchText: string | null;
|
|
34
|
+
width: number | null;
|
|
35
|
+
height: number | null;
|
|
36
|
+
uploadAttempt: string | null;
|
|
34
37
|
}[];
|
|
35
38
|
nextCursor: string | null;
|
|
36
39
|
};
|
package/dist/server/api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { json, error } from '@sveltejs/kit';
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { rateLimit } from './forms.js';
|
|
4
|
-
import { createUser } from './auth.js';
|
|
4
|
+
import { createUser, deleteUser } from './auth.js';
|
|
5
5
|
import { boundedJson, clientAddress } from './request.js';
|
|
6
6
|
import { apiPrincipal } from './api-access.js';
|
|
7
7
|
import { apiRequests, audit, apikey, user } from './db/schema.js';
|
|
@@ -9,6 +9,7 @@ import { eq, lt, desc } from 'drizzle-orm';
|
|
|
9
9
|
import { contentPage, mediaPage } from './api-pagination.js';
|
|
10
10
|
import { globalSearch } from './search.js';
|
|
11
11
|
import { ValidationError } from '../blueprints/validate.js';
|
|
12
|
+
import { MediaRequestError } from './media/contracts.js';
|
|
12
13
|
const replayRetention = 48 * 60 * 60 * 1000;
|
|
13
14
|
const lastPruned = new WeakMap();
|
|
14
15
|
function orderedJson(value) {
|
|
@@ -269,9 +270,9 @@ export async function apiHandler(cms, event) {
|
|
|
269
270
|
name: body.name,
|
|
270
271
|
type: body.type,
|
|
271
272
|
size: body.size
|
|
272
|
-
}, blueprint || undefined));
|
|
273
|
+
}, blueprint || undefined, { userId: session.user.id }));
|
|
273
274
|
case 'media/upload/complete':
|
|
274
|
-
return json(cms.media.completeUpload(id));
|
|
275
|
+
return json(await cms.media.completeUpload(id));
|
|
275
276
|
case 'media/update':
|
|
276
277
|
cms.media.updateMetadata(id, body.metadata);
|
|
277
278
|
break;
|
|
@@ -310,6 +311,11 @@ export async function apiHandler(cms, event) {
|
|
|
310
311
|
else
|
|
311
312
|
cms.access.revoke(id, session.user.id);
|
|
312
313
|
break;
|
|
314
|
+
case 'users/delete':
|
|
315
|
+
if (session.user.role !== 'admin')
|
|
316
|
+
error(403, 'Only admins can remove users');
|
|
317
|
+
deleteUser(cms.store, id, session.user.id);
|
|
318
|
+
break;
|
|
313
319
|
case 'users/create':
|
|
314
320
|
if (session.user.role !== 'admin')
|
|
315
321
|
error(403, 'Only admins can create users');
|
|
@@ -326,6 +332,8 @@ export async function apiHandler(cms, event) {
|
|
|
326
332
|
return json({ ok: true });
|
|
327
333
|
}
|
|
328
334
|
catch (e) {
|
|
335
|
+
if (e instanceof MediaRequestError)
|
|
336
|
+
return json({ error: e.message }, { status: e.status });
|
|
329
337
|
if (e && typeof e === 'object' && 'status' in e)
|
|
330
338
|
throw e;
|
|
331
339
|
return json({
|
package/dist/server/auth.d.ts
CHANGED
|
@@ -56,21 +56,22 @@ export declare function createAuth(store: Store, options: AuthOptions): import("
|
|
|
56
56
|
plugins: [{
|
|
57
57
|
id: "two-factor";
|
|
58
58
|
version: string;
|
|
59
|
+
shouldRequireTwoFactor: (ctx: import("better-auth").GenericEndpointContext) => Promise<boolean>;
|
|
59
60
|
endpoints: {
|
|
60
61
|
enableTwoFactor: import("better-auth").StrictEndpoint<"/two-factor/enable", {
|
|
61
62
|
method: "POST";
|
|
62
63
|
body: import("better-auth").ZodObject<{
|
|
63
64
|
password: import("better-auth").ZodOptional<import("better-auth").ZodString>;
|
|
64
65
|
method: import("better-auth").ZodDefault<import("better-auth").ZodEnum<{
|
|
65
|
-
otp: "otp";
|
|
66
66
|
totp: "totp";
|
|
67
|
+
otp: "otp";
|
|
67
68
|
}>>;
|
|
68
69
|
issuer: import("better-auth").ZodOptional<import("better-auth").ZodString>;
|
|
69
70
|
}, import("zod/v4/core").$strip> | import("better-auth").ZodObject<{
|
|
70
71
|
password: import("better-auth").ZodString;
|
|
71
72
|
method: import("better-auth").ZodDefault<import("better-auth").ZodEnum<{
|
|
72
|
-
otp: "otp";
|
|
73
73
|
totp: "totp";
|
|
74
|
+
otp: "otp";
|
|
74
75
|
}>>;
|
|
75
76
|
issuer: import("better-auth").ZodOptional<import("better-auth").ZodString>;
|
|
76
77
|
}, import("zod/v4/core").$strip>;
|
|
@@ -298,7 +299,7 @@ export declare function createAuth(store: Store, options: AuthOptions): import("
|
|
|
298
299
|
};
|
|
299
300
|
}, {
|
|
300
301
|
token: string | undefined;
|
|
301
|
-
user: (
|
|
302
|
+
user: ({
|
|
302
303
|
id: string;
|
|
303
304
|
createdAt: Date;
|
|
304
305
|
updatedAt: Date;
|
|
@@ -306,7 +307,7 @@ export declare function createAuth(store: Store, options: AuthOptions): import("
|
|
|
306
307
|
emailVerified: boolean;
|
|
307
308
|
name: string;
|
|
308
309
|
image?: string | null | undefined;
|
|
309
|
-
}) | import("better-auth/plugins").UserWithTwoFactor;
|
|
310
|
+
} & Record<string, any>) | import("better-auth/plugins").UserWithTwoFactor;
|
|
310
311
|
}>;
|
|
311
312
|
generateBackupCodes: import("better-auth").StrictEndpoint<"/two-factor/generate-backup-codes", {
|
|
312
313
|
method: "POST";
|
|
@@ -493,7 +494,7 @@ export declare function createAuth(store: Store, options: AuthOptions): import("
|
|
|
493
494
|
user: import("better-auth/plugins").UserWithTwoFactor;
|
|
494
495
|
} | {
|
|
495
496
|
token: string;
|
|
496
|
-
user:
|
|
497
|
+
user: {
|
|
497
498
|
id: string;
|
|
498
499
|
createdAt: Date;
|
|
499
500
|
updatedAt: Date;
|
|
@@ -501,7 +502,7 @@ export declare function createAuth(store: Store, options: AuthOptions): import("
|
|
|
501
502
|
emailVerified: boolean;
|
|
502
503
|
name: string;
|
|
503
504
|
image?: string | null | undefined;
|
|
504
|
-
}
|
|
505
|
+
} & Record<string, any>;
|
|
505
506
|
}>;
|
|
506
507
|
generateTOTP: import("better-auth").StrictEndpoint<string, {
|
|
507
508
|
method: "POST";
|
|
@@ -624,7 +625,7 @@ export declare function createAuth(store: Store, options: AuthOptions): import("
|
|
|
624
625
|
user: import("better-auth/plugins").UserWithTwoFactor;
|
|
625
626
|
} | {
|
|
626
627
|
token: string;
|
|
627
|
-
user:
|
|
628
|
+
user: {
|
|
628
629
|
id: string;
|
|
629
630
|
createdAt: Date;
|
|
630
631
|
updatedAt: Date;
|
|
@@ -632,7 +633,7 @@ export declare function createAuth(store: Store, options: AuthOptions): import("
|
|
|
632
633
|
emailVerified: boolean;
|
|
633
634
|
name: string;
|
|
634
635
|
image?: string | null | undefined;
|
|
635
|
-
}
|
|
636
|
+
} & Record<string, any>;
|
|
636
637
|
}>;
|
|
637
638
|
};
|
|
638
639
|
options: NoInfer<{
|
|
@@ -859,7 +860,7 @@ export declare function createAuth(store: Store, options: AuthOptions): import("
|
|
|
859
860
|
} | null) => void;
|
|
860
861
|
socialProviders: import("better-auth").OAuthProvider[];
|
|
861
862
|
authCookies: import("better-auth").BetterAuthCookies;
|
|
862
|
-
logger: ReturnType<
|
|
863
|
+
logger: ReturnType<typeof import("better-auth").createLogger>;
|
|
863
864
|
rateLimit: {
|
|
864
865
|
enabled: boolean;
|
|
865
866
|
window: number;
|
|
@@ -1891,4 +1892,5 @@ export declare function createUser(store: Store, input: {
|
|
|
1891
1892
|
password: string;
|
|
1892
1893
|
role: 'admin' | 'editor';
|
|
1893
1894
|
}, actor?: string): Promise<`${string}-${string}-${string}-${string}-${string}`>;
|
|
1895
|
+
export declare function deleteUser(store: Store, id: string, actor: string): void;
|
|
1894
1896
|
export declare function recoverUser(store: Store, email: string, action: 'password' | '2fa', password?: string): Promise<void>;
|
package/dist/server/auth.js
CHANGED
|
@@ -108,6 +108,29 @@ export async function createUser(store, input, actor = 'operator') {
|
|
|
108
108
|
});
|
|
109
109
|
return id;
|
|
110
110
|
}
|
|
111
|
+
export function deleteUser(store, id, actor) {
|
|
112
|
+
if (id === actor)
|
|
113
|
+
throw new Error('You cannot remove your own account');
|
|
114
|
+
store.db.transaction((tx) => {
|
|
115
|
+
const target = tx.select().from(schema.user).where(eq(schema.user.id, id)).get();
|
|
116
|
+
if (!target)
|
|
117
|
+
throw new Error('User not found');
|
|
118
|
+
if (target.role === 'admin' &&
|
|
119
|
+
tx.select().from(schema.user).where(eq(schema.user.role, 'admin')).all().length <= 1)
|
|
120
|
+
throw new Error('Keep at least one admin');
|
|
121
|
+
// Sessions, credentials, two-factor secrets, and API keys cascade with the user row.
|
|
122
|
+
tx.delete(schema.user).where(eq(schema.user.id, id)).run();
|
|
123
|
+
tx.insert(schema.audit)
|
|
124
|
+
.values({
|
|
125
|
+
id: crypto.randomUUID(),
|
|
126
|
+
action: 'user.delete',
|
|
127
|
+
actor,
|
|
128
|
+
detail: { id, email: target.email, role: target.role },
|
|
129
|
+
createdAt: Date.now()
|
|
130
|
+
})
|
|
131
|
+
.run();
|
|
132
|
+
});
|
|
133
|
+
}
|
|
111
134
|
export async function recoverUser(store, email, action, password) {
|
|
112
135
|
const user = store.db
|
|
113
136
|
.select()
|
package/dist/server/cms.d.ts
CHANGED
|
@@ -8,7 +8,11 @@ export interface CmsOptions {
|
|
|
8
8
|
secret: string;
|
|
9
9
|
root?: string;
|
|
10
10
|
definition?: SiteDefinition;
|
|
11
|
+
/** Media root (originals, variants, upload staging). Defaults to `<dirname(database)>/media`. */
|
|
12
|
+
mediaDir?: string;
|
|
13
|
+
/** @deprecated 0.7.0: only read by `sandcms media import-r2`. */
|
|
11
14
|
workerToken?: string;
|
|
15
|
+
/** @deprecated 0.7.0: only read by `sandcms media import-r2`. */
|
|
12
16
|
workerUrl?: string;
|
|
13
17
|
trustedProxyHeader?: string;
|
|
14
18
|
migrate?: boolean;
|
|
@@ -16,6 +20,21 @@ export interface CmsOptions {
|
|
|
16
20
|
autoMigrate?: boolean;
|
|
17
21
|
email?: EmailOptions;
|
|
18
22
|
seo?: SeoOptions;
|
|
23
|
+
/**
|
|
24
|
+
* Set by the web-server integration. Before the database is opened, the CMS checks the site-id and refuses
|
|
25
|
+
* a new production database outside a mounted volume. CLI commands leave it unset. `autoMigrate` implies it.
|
|
26
|
+
*/
|
|
27
|
+
server?: boolean;
|
|
28
|
+
/** Directory holding the database, site-id and snapshots. Defaults to `dirname(database)`. */
|
|
29
|
+
dataDir?: string;
|
|
30
|
+
/** Largest request body outside the upload chunk route, in bytes (default 1 MiB). */
|
|
31
|
+
requestLimit?: number;
|
|
32
|
+
/** `false` sends noindex headers and a disallow-all robots.txt (preview sites). */
|
|
33
|
+
indexing?: boolean;
|
|
34
|
+
/** Redirect other hostnames to `origin` (default true in production). */
|
|
35
|
+
canonicalRedirect?: boolean;
|
|
36
|
+
/** Create this admin with a one-time password on first start when no users exist. */
|
|
37
|
+
bootstrapEmail?: string;
|
|
19
38
|
}
|
|
20
39
|
export declare function createCMS(options: CmsOptions): {
|
|
21
40
|
definition: SiteDefinition;
|
|
@@ -72,21 +91,22 @@ export declare function createCMS(options: CmsOptions): {
|
|
|
72
91
|
plugins: [{
|
|
73
92
|
id: "two-factor";
|
|
74
93
|
version: string;
|
|
94
|
+
shouldRequireTwoFactor: (ctx: import("better-auth").GenericEndpointContext) => Promise<boolean>;
|
|
75
95
|
endpoints: {
|
|
76
96
|
enableTwoFactor: import("better-auth").StrictEndpoint<"/two-factor/enable", {
|
|
77
97
|
method: "POST";
|
|
78
98
|
body: import("zod").ZodObject<{
|
|
79
99
|
password: import("zod").ZodOptional<import("zod").ZodString>;
|
|
80
100
|
method: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
81
|
-
otp: "otp";
|
|
82
101
|
totp: "totp";
|
|
102
|
+
otp: "otp";
|
|
83
103
|
}>>;
|
|
84
104
|
issuer: import("zod").ZodOptional<import("zod").ZodString>;
|
|
85
105
|
}, import("zod/v4/core").$strip> | import("zod").ZodObject<{
|
|
86
106
|
password: import("zod").ZodString;
|
|
87
107
|
method: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
88
|
-
otp: "otp";
|
|
89
108
|
totp: "totp";
|
|
109
|
+
otp: "otp";
|
|
90
110
|
}>>;
|
|
91
111
|
issuer: import("zod").ZodOptional<import("zod").ZodString>;
|
|
92
112
|
}, import("zod/v4/core").$strip>;
|
|
@@ -314,7 +334,7 @@ export declare function createCMS(options: CmsOptions): {
|
|
|
314
334
|
};
|
|
315
335
|
}, {
|
|
316
336
|
token: string | undefined;
|
|
317
|
-
user: (
|
|
337
|
+
user: ({
|
|
318
338
|
id: string;
|
|
319
339
|
createdAt: Date;
|
|
320
340
|
updatedAt: Date;
|
|
@@ -322,7 +342,7 @@ export declare function createCMS(options: CmsOptions): {
|
|
|
322
342
|
emailVerified: boolean;
|
|
323
343
|
name: string;
|
|
324
344
|
image?: string | null | undefined;
|
|
325
|
-
}) | import("better-auth/plugins").UserWithTwoFactor;
|
|
345
|
+
} & Record<string, any>) | import("better-auth/plugins").UserWithTwoFactor;
|
|
326
346
|
}>;
|
|
327
347
|
generateBackupCodes: import("better-auth").StrictEndpoint<"/two-factor/generate-backup-codes", {
|
|
328
348
|
method: "POST";
|
|
@@ -509,7 +529,7 @@ export declare function createCMS(options: CmsOptions): {
|
|
|
509
529
|
user: import("better-auth/plugins").UserWithTwoFactor;
|
|
510
530
|
} | {
|
|
511
531
|
token: string;
|
|
512
|
-
user:
|
|
532
|
+
user: {
|
|
513
533
|
id: string;
|
|
514
534
|
createdAt: Date;
|
|
515
535
|
updatedAt: Date;
|
|
@@ -517,7 +537,7 @@ export declare function createCMS(options: CmsOptions): {
|
|
|
517
537
|
emailVerified: boolean;
|
|
518
538
|
name: string;
|
|
519
539
|
image?: string | null | undefined;
|
|
520
|
-
}
|
|
540
|
+
} & Record<string, any>;
|
|
521
541
|
}>;
|
|
522
542
|
generateTOTP: import("better-auth").StrictEndpoint<string, {
|
|
523
543
|
method: "POST";
|
|
@@ -640,7 +660,7 @@ export declare function createCMS(options: CmsOptions): {
|
|
|
640
660
|
user: import("better-auth/plugins").UserWithTwoFactor;
|
|
641
661
|
} | {
|
|
642
662
|
token: string;
|
|
643
|
-
user:
|
|
663
|
+
user: {
|
|
644
664
|
id: string;
|
|
645
665
|
createdAt: Date;
|
|
646
666
|
updatedAt: Date;
|
|
@@ -648,7 +668,7 @@ export declare function createCMS(options: CmsOptions): {
|
|
|
648
668
|
emailVerified: boolean;
|
|
649
669
|
name: string;
|
|
650
670
|
image?: string | null | undefined;
|
|
651
|
-
}
|
|
671
|
+
} & Record<string, any>;
|
|
652
672
|
}>;
|
|
653
673
|
};
|
|
654
674
|
options: NoInfer<{
|
|
@@ -875,7 +895,7 @@ export declare function createCMS(options: CmsOptions): {
|
|
|
875
895
|
} | null) => void;
|
|
876
896
|
socialProviders: import("better-auth").OAuthProvider[];
|
|
877
897
|
authCookies: import("better-auth").BetterAuthCookies;
|
|
878
|
-
logger: ReturnType<
|
|
898
|
+
logger: ReturnType<typeof import("better-auth").createLogger>;
|
|
879
899
|
rateLimit: {
|
|
880
900
|
enabled: boolean;
|
|
881
901
|
window: number;
|
|
@@ -2086,6 +2106,9 @@ export declare function createCMS(options: CmsOptions): {
|
|
|
2086
2106
|
error: string | null;
|
|
2087
2107
|
createdAt: number;
|
|
2088
2108
|
searchText: string | null;
|
|
2109
|
+
width: number | null;
|
|
2110
|
+
height: number | null;
|
|
2111
|
+
uploadAttempt: string | null;
|
|
2089
2112
|
} | undefined;
|
|
2090
2113
|
upload: (file: File, blueprintId?: string) => Promise<{
|
|
2091
2114
|
blueprint: string;
|
|
@@ -2101,18 +2124,18 @@ export declare function createCMS(options: CmsOptions): {
|
|
|
2101
2124
|
error: string | null;
|
|
2102
2125
|
createdAt: number;
|
|
2103
2126
|
searchText: string | null;
|
|
2127
|
+
width: number | null;
|
|
2128
|
+
height: number | null;
|
|
2129
|
+
uploadAttempt: string | null;
|
|
2104
2130
|
}>;
|
|
2105
2131
|
initiateUpload: (input: {
|
|
2106
2132
|
name: string;
|
|
2107
2133
|
type: string;
|
|
2108
2134
|
size: number;
|
|
2109
|
-
}, blueprintId
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
id: `${string}-${string}-${string}-${string}-${string}`;
|
|
2114
|
-
}>;
|
|
2115
|
-
completeUpload: (id: string) => {
|
|
2135
|
+
}, blueprintId: string | undefined, principal: {
|
|
2136
|
+
userId: string;
|
|
2137
|
+
}) => Promise<import("./media/contracts.ts").UploadTicketResponse>;
|
|
2138
|
+
completeUpload: (id: string) => Promise<{
|
|
2116
2139
|
blueprint: string;
|
|
2117
2140
|
metadata: import("../blueprints/types.js").Payload;
|
|
2118
2141
|
id: string;
|
|
@@ -2126,9 +2149,20 @@ export declare function createCMS(options: CmsOptions): {
|
|
|
2126
2149
|
error: string | null;
|
|
2127
2150
|
createdAt: number;
|
|
2128
2151
|
searchText: string | null;
|
|
2129
|
-
|
|
2152
|
+
width: number | null;
|
|
2153
|
+
height: number | null;
|
|
2154
|
+
uploadAttempt: string | null;
|
|
2155
|
+
}>;
|
|
2130
2156
|
tick: () => Promise<boolean>;
|
|
2131
2157
|
drain: () => Promise<void>;
|
|
2158
|
+
receiveChunk: (id: string, index: number, body: ReadableStream<Uint8Array>, ticketToken: string | null, userId: string) => Promise<{
|
|
2159
|
+
received: number[];
|
|
2160
|
+
}>;
|
|
2161
|
+
uploadStatus: (id: string, ticketToken: string | null, userId: string) => Promise<{
|
|
2162
|
+
received: number[];
|
|
2163
|
+
chunkSize: number;
|
|
2164
|
+
complete: boolean;
|
|
2165
|
+
}>;
|
|
2132
2166
|
retry: (id: string) => void;
|
|
2133
2167
|
version: string;
|
|
2134
2168
|
versionForAsset: (asset: NonNullable<ReturnType<(id: string) => {
|
|
@@ -2145,7 +2179,11 @@ export declare function createCMS(options: CmsOptions): {
|
|
|
2145
2179
|
error: string | null;
|
|
2146
2180
|
createdAt: number;
|
|
2147
2181
|
searchText: string | null;
|
|
2182
|
+
width: number | null;
|
|
2183
|
+
height: number | null;
|
|
2184
|
+
uploadAttempt: string | null;
|
|
2148
2185
|
} | undefined>>) => string;
|
|
2186
|
+
storage: import("./media/contracts.ts").MediaStorage;
|
|
2149
2187
|
workerUrl: string;
|
|
2150
2188
|
list: () => {
|
|
2151
2189
|
blueprint: string;
|
|
@@ -2161,10 +2199,15 @@ export declare function createCMS(options: CmsOptions): {
|
|
|
2161
2199
|
error: string | null;
|
|
2162
2200
|
createdAt: number;
|
|
2163
2201
|
searchText: string | null;
|
|
2202
|
+
width: number | null;
|
|
2203
|
+
height: number | null;
|
|
2204
|
+
uploadAttempt: string | null;
|
|
2164
2205
|
}[];
|
|
2165
2206
|
updateMetadata: (id: string, input: unknown) => void;
|
|
2166
2207
|
health(): Promise<{
|
|
2167
|
-
|
|
2208
|
+
bytes: number;
|
|
2209
|
+
free: number;
|
|
2210
|
+
storage: "local";
|
|
2168
2211
|
}>;
|
|
2169
2212
|
rebuild: () => void;
|
|
2170
2213
|
remove(id: string): Promise<void>;
|
|
@@ -2181,6 +2224,7 @@ export declare function createCMS(options: CmsOptions): {
|
|
|
2181
2224
|
width: number;
|
|
2182
2225
|
height: number;
|
|
2183
2226
|
format: string;
|
|
2227
|
+
etag?: string;
|
|
2184
2228
|
}[];
|
|
2185
2229
|
photographer: {
|
|
2186
2230
|
id: string;
|
|
@@ -2200,6 +2244,7 @@ export declare function createCMS(options: CmsOptions): {
|
|
|
2200
2244
|
width: number;
|
|
2201
2245
|
height: number;
|
|
2202
2246
|
format: string;
|
|
2247
|
+
etag?: string;
|
|
2203
2248
|
}[];
|
|
2204
2249
|
photographer: {
|
|
2205
2250
|
id: string;
|
|
@@ -2223,6 +2268,7 @@ export declare function createCMS(options: CmsOptions): {
|
|
|
2223
2268
|
width: number;
|
|
2224
2269
|
height: number;
|
|
2225
2270
|
format: string;
|
|
2271
|
+
etag?: string;
|
|
2226
2272
|
}[];
|
|
2227
2273
|
photographer: {
|
|
2228
2274
|
id: string;
|
|
@@ -2246,6 +2292,7 @@ export declare function createCMS(options: CmsOptions): {
|
|
|
2246
2292
|
width: number;
|
|
2247
2293
|
height: number;
|
|
2248
2294
|
format: string;
|
|
2295
|
+
etag?: string;
|
|
2249
2296
|
}[];
|
|
2250
2297
|
photographer: {
|
|
2251
2298
|
id: string;
|
package/dist/server/cms.js
CHANGED
|
@@ -11,13 +11,49 @@ import { createNotifications } from './notifications.js';
|
|
|
11
11
|
import { createForms } from './forms.js';
|
|
12
12
|
import { createEmail } from './email/index.js';
|
|
13
13
|
import { createMedia } from './media/service.js';
|
|
14
|
+
import { preparePlatform, startPlatform } from './platform/index.js';
|
|
15
|
+
import { mkdtempSync } from 'node:fs';
|
|
16
|
+
import { tmpdir } from 'node:os';
|
|
17
|
+
import { dirname, join, resolve } from 'node:path';
|
|
14
18
|
import { error } from '@sveltejs/kit';
|
|
19
|
+
const previewHeaders = {
|
|
20
|
+
'cache-control': 'private, no-store',
|
|
21
|
+
'x-robots-tag': 'noindex, nofollow'
|
|
22
|
+
};
|
|
23
|
+
const previewHeaderEvents = new WeakSet();
|
|
24
|
+
/**
|
|
25
|
+
* A route may read several entries during one preview, and SvelteKit rejects repeated setHeaders calls
|
|
26
|
+
* for the same header. The hook still forces these headers onto the final preview response.
|
|
27
|
+
*/
|
|
28
|
+
function setPreviewHeaders(event) {
|
|
29
|
+
if (previewHeaderEvents.has(event))
|
|
30
|
+
return;
|
|
31
|
+
previewHeaderEvents.add(event);
|
|
32
|
+
for (const [name, value] of Object.entries(previewHeaders)) {
|
|
33
|
+
try {
|
|
34
|
+
event.setHeaders({ [name]: value });
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// Already set by the application; cmsHandle overrides it on preview responses.
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
15
41
|
export function createCMS(options) {
|
|
16
42
|
options = { ...options, origin: new URL(options.origin).origin };
|
|
17
43
|
// migrate would apply pending migrations before autoMigrate could take its snapshot.
|
|
18
44
|
if (options.migrate && options.autoMigrate)
|
|
19
45
|
throw new Error('Use either migrate or autoMigrate, not both.');
|
|
20
|
-
const definition = configureFileFields(options.definition ?? loadDefinition(options.root))
|
|
46
|
+
const definition = configureFileFields(options.definition ?? loadDefinition(options.root));
|
|
47
|
+
// Web servers check the volume before opening the database, so a foreign or unmounted volume fails before
|
|
48
|
+
// anything is migrated or written. Overlapping deploys (run new, then stop old) are fine: SQLite handles
|
|
49
|
+
// two processes on a local volume, and background work coordinates through database leases.
|
|
50
|
+
if ((options.server || options.autoMigrate) && options.database !== ':memory:')
|
|
51
|
+
preparePlatform(options.database, {
|
|
52
|
+
dataDir: options.dataDir,
|
|
53
|
+
project: definition.config.name
|
|
54
|
+
});
|
|
55
|
+
const store = openStore(options.database, { migrate: options.migrate });
|
|
56
|
+
let stopPlatform;
|
|
21
57
|
try {
|
|
22
58
|
if (options.autoMigrate) {
|
|
23
59
|
const result = autoMigrate(store);
|
|
@@ -28,7 +64,28 @@ export function createCMS(options) {
|
|
|
28
64
|
assertSchema(store);
|
|
29
65
|
// Blueprint labels and fields can change between deploys, so cached search text is rebuilt lazily.
|
|
30
66
|
store.sqlite.exec('UPDATE documents SET searchText = NULL WHERE searchText IS NOT NULL; UPDATE media SET searchText = NULL WHERE searchText IS NOT NULL;');
|
|
31
|
-
const email = createEmail(options.email), auth = createAuth(store, options), content = createContent(store, definition), notifications = createNotifications(store, definition, email, options.origin), forms = createForms(store, definition, notifications.send), media = createMedia(store, definition, content,
|
|
67
|
+
const email = createEmail(options.email), auth = createAuth(store, options), content = createContent(store, definition), notifications = createNotifications(store, definition, email, options.origin), forms = createForms(store, definition, notifications.send), media = createMedia(store, definition, content, {
|
|
68
|
+
secret: options.secret,
|
|
69
|
+
origin: options.origin,
|
|
70
|
+
mediaDir: options.mediaDir ??
|
|
71
|
+
(options.database === ':memory:'
|
|
72
|
+
? mkdtempSync(join(tmpdir(), 'sandcms-media-'))
|
|
73
|
+
: join(dirname(resolve(options.database)), 'media')),
|
|
74
|
+
workerUrl: options.workerUrl
|
|
75
|
+
});
|
|
76
|
+
const startMedia = media.start;
|
|
77
|
+
// Server integrations call media.start(); it also starts bootstrap and snapshots. Integrations without
|
|
78
|
+
// `server` (generated before 0.7.0) run the volume checks here instead.
|
|
79
|
+
media.start = () => {
|
|
80
|
+
if (options.database !== ':memory:')
|
|
81
|
+
stopPlatform ??= startPlatform({ store, definition }, { dataDir: options.dataDir, bootstrapEmail: options.bootstrapEmail });
|
|
82
|
+
const stopMedia = startMedia();
|
|
83
|
+
return () => {
|
|
84
|
+
stopMedia();
|
|
85
|
+
stopPlatform?.();
|
|
86
|
+
stopPlatform = undefined;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
32
89
|
return {
|
|
33
90
|
definition,
|
|
34
91
|
store,
|
|
@@ -51,21 +108,20 @@ export function createCMS(options) {
|
|
|
51
108
|
if (session.user.mustChangePassword)
|
|
52
109
|
error(403, 'Change your temporary password first');
|
|
53
110
|
requireUser(session.user);
|
|
54
|
-
event
|
|
55
|
-
'cache-control': 'private, no-store',
|
|
56
|
-
'x-robots-tag': 'noindex, nofollow'
|
|
57
|
-
});
|
|
111
|
+
setPreviewHeaders(event);
|
|
58
112
|
const doc = content.get(previewId);
|
|
59
113
|
return doc?.blueprint === blueprint ? { id: doc.id, data: doc.draft } : null;
|
|
60
114
|
}
|
|
61
115
|
return content.published(blueprint, slug, { limit: 1 })[0] ?? null;
|
|
62
116
|
},
|
|
63
117
|
close() {
|
|
118
|
+
stopPlatform?.();
|
|
64
119
|
store.close();
|
|
65
120
|
}
|
|
66
121
|
};
|
|
67
122
|
}
|
|
68
123
|
catch (cause) {
|
|
124
|
+
stopPlatform?.();
|
|
69
125
|
store.close();
|
|
70
126
|
throw cause;
|
|
71
127
|
}
|
|
@@ -35,5 +35,9 @@ export const migrationData = [
|
|
|
35
35
|
{
|
|
36
36
|
"name": "0008_search_text_cache.sql",
|
|
37
37
|
"sql": "CREATE TABLE `media_document_links` (\n\t`mediaId` text NOT NULL,\n\t`documentId` text NOT NULL,\n\tPRIMARY KEY(`mediaId`, `documentId`),\n\tFOREIGN KEY (`mediaId`) REFERENCES `media`(`id`) ON UPDATE no action ON DELETE cascade\n);\n--> statement-breakpoint\nCREATE INDEX `media_document_link_document` ON `media_document_links` (`documentId`);--> statement-breakpoint\nALTER TABLE `documents` ADD `searchText` text;--> statement-breakpoint\nALTER TABLE `media` ADD `searchText` text;--> statement-breakpoint\nINSERT OR IGNORE INTO `media_document_links` (`mediaId`, `documentId`)\nSELECT `media`.`id`, `documents`.`id` FROM `media`, json_tree(`media`.`metadata`) AS `node`\nJOIN `documents` ON `documents`.`id` = `node`.`value` WHERE `node`.`type` = 'text';--> statement-breakpoint\nCREATE TRIGGER `media_document_links_inserted` AFTER INSERT ON `media` BEGIN\n INSERT OR IGNORE INTO `media_document_links` (`mediaId`, `documentId`)\n SELECT NEW.`id`, `documents`.`id` FROM json_tree(NEW.`metadata`) AS `node`\n JOIN `documents` ON `documents`.`id` = `node`.`value` WHERE `node`.`type` = 'text';\nEND;--> statement-breakpoint\nCREATE TRIGGER `media_document_links_updated` AFTER UPDATE OF `metadata` ON `media` BEGIN\n DELETE FROM `media_document_links` WHERE `mediaId` = NEW.`id`;\n INSERT OR IGNORE INTO `media_document_links` (`mediaId`, `documentId`)\n SELECT NEW.`id`, `documents`.`id` FROM json_tree(NEW.`metadata`) AS `node`\n JOIN `documents` ON `documents`.`id` = `node`.`value` WHERE `node`.`type` = 'text';\nEND;--> statement-breakpoint\nCREATE TRIGGER `documents_search_text_stale` AFTER UPDATE OF `draft`, `blueprint` ON `documents` BEGIN\n UPDATE `documents` SET `searchText` = NULL WHERE `id` = NEW.`id`;\nEND;--> statement-breakpoint\nCREATE TRIGGER `documents_search_text_label` AFTER UPDATE OF `draft`, `blueprint` ON `documents`\nWHEN json_extract(OLD.`draft`, '$.title') IS NOT json_extract(NEW.`draft`, '$.title')\n OR json_extract(OLD.`draft`, '$.name') IS NOT json_extract(NEW.`draft`, '$.name')\n OR OLD.`blueprint` IS NOT NEW.`blueprint`\nBEGIN\n UPDATE `media` SET `searchText` = NULL WHERE `id` IN (\n SELECT `mediaId` FROM `media_document_links` WHERE `documentId` = NEW.`id`\n );\nEND;--> statement-breakpoint\nCREATE TRIGGER `documents_search_text_deleted` AFTER DELETE ON `documents` BEGIN\n UPDATE `media` SET `searchText` = NULL WHERE `id` IN (\n SELECT `mediaId` FROM `media_document_links` WHERE `documentId` = OLD.`id`\n );\n DELETE FROM `media_document_links` WHERE `documentId` = OLD.`id`;\nEND;--> statement-breakpoint\nCREATE TRIGGER `media_search_text_stale` AFTER UPDATE OF `metadata`, `filename`, `blueprint` ON `media` BEGIN\n UPDATE `media` SET `searchText` = NULL WHERE `id` = NEW.`id`;\nEND;\n"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "0009_local_media.sql",
|
|
41
|
+
"sql": "CREATE TABLE `leases` (\n\t`name` text PRIMARY KEY NOT NULL,\n\t`owner` text NOT NULL,\n\t`leaseUntil` integer NOT NULL\n);\n--> statement-breakpoint\nALTER TABLE `media` ADD `width` integer;--> statement-breakpoint\nALTER TABLE `media` ADD `height` integer;--> statement-breakpoint\nALTER TABLE `media` ADD `uploadAttempt` text;"
|
|
38
42
|
}
|
|
39
43
|
];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
CREATE TABLE `leases` (
|
|
2
|
+
`name` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`owner` text NOT NULL,
|
|
4
|
+
`leaseUntil` integer NOT NULL
|
|
5
|
+
);
|
|
6
|
+
--> statement-breakpoint
|
|
7
|
+
ALTER TABLE `media` ADD `width` integer;--> statement-breakpoint
|
|
8
|
+
ALTER TABLE `media` ADD `height` integer;--> statement-breakpoint
|
|
9
|
+
ALTER TABLE `media` ADD `uploadAttempt` text;
|