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.
- package/README.md +6 -4
- package/dist/admin/Account.svelte +4 -1
- package/dist/admin/ApiKeys.svelte +159 -0
- package/dist/admin/ApiKeys.svelte.d.ts +3 -0
- package/dist/admin/AssetAttachment.svelte +6 -4
- package/dist/admin/BlueprintFields.svelte +86 -0
- package/dist/admin/BlueprintFields.svelte.d.ts +15 -0
- package/dist/admin/Collection.svelte +40 -7
- package/dist/admin/Editor.svelte +57 -17
- package/dist/admin/Fields.svelte +217 -144
- package/dist/admin/Fields.svelte.d.ts +1 -0
- package/dist/admin/FocusPicker.svelte +136 -0
- package/dist/admin/FocusPicker.svelte.d.ts +11 -0
- package/dist/admin/Gallery.svelte +40 -34
- package/dist/admin/GlobalSearch.svelte +56 -0
- package/dist/admin/GlobalSearch.svelte.d.ts +3 -0
- package/dist/admin/Inbox.svelte +8 -5
- package/dist/admin/LinkField.svelte +116 -0
- package/dist/admin/LinkField.svelte.d.ts +17 -0
- package/dist/admin/MediaLibrary.svelte +41 -14
- package/dist/admin/MediaPicker.svelte +12 -2
- package/dist/admin/Navigation.svelte +62 -0
- package/dist/admin/Navigation.svelte.d.ts +7 -0
- package/dist/admin/NotificationSettings.svelte +2 -2
- package/dist/admin/SearchList.svelte +55 -0
- package/dist/admin/SearchList.svelte.d.ts +42 -0
- package/dist/admin/SelectField.svelte +3 -1
- package/dist/admin/SelectField.svelte.d.ts +1 -0
- package/dist/admin/Shell.svelte +16 -24
- package/dist/admin/UnsavedChanges.svelte +1 -1
- package/dist/admin/Users.svelte +11 -5
- package/dist/admin/client.js +2 -1
- package/dist/admin/generated/admin.css +145 -0
- package/dist/admin/navigation.d.ts +7 -0
- package/dist/admin/navigation.js +25 -0
- package/dist/admin/types.d.ts +5 -1
- package/dist/admin/uploads.js +27 -6
- package/dist/blueprints/conditions.d.ts +2 -0
- package/dist/blueprints/conditions.js +4 -0
- package/dist/blueprints/extends.d.ts +5 -0
- package/dist/blueprints/extends.js +76 -0
- package/dist/blueprints/files.d.ts +3 -1
- package/dist/blueprints/files.js +35 -2
- package/dist/blueprints/layout.d.ts +4 -0
- package/dist/blueprints/layout.js +12 -0
- package/dist/blueprints/load.d.ts +1 -1
- package/dist/blueprints/load.js +127 -12
- package/dist/blueprints/types.d.ts +38 -1
- package/dist/blueprints/validate.js +30 -6
- package/dist/cli/cloudflare.js +15 -3
- package/dist/cli/doctor.js +6 -3
- package/dist/cli/files.js +1 -1
- package/dist/cli/scaffold.js +8 -6
- package/dist/cli/setup.js +9 -2
- package/dist/cli/upgrade.js +2 -1
- package/dist/email-failure.d.ts +17 -0
- package/dist/email-failure.js +22 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/link.d.ts +17 -0
- package/dist/link.js +44 -0
- package/dist/notification-fields.js +1 -1
- package/dist/search.d.ts +8 -0
- package/dist/search.js +1 -0
- package/dist/server/access.d.ts +2 -0
- package/dist/server/access.js +59 -23
- package/dist/server/admin-load.d.ts +29 -2
- package/dist/server/admin-load.js +4 -2
- package/dist/server/api-access.d.ts +31 -0
- package/dist/server/api-access.js +52 -0
- package/dist/server/api-pagination.d.ts +34 -0
- package/dist/server/api-pagination.js +87 -0
- package/dist/server/api.js +224 -32
- package/dist/server/auth.d.ts +1150 -0
- package/dist/server/auth.js +11 -1
- package/dist/server/cms.d.ts +1208 -4
- package/dist/server/cms.js +2 -0
- package/dist/server/content.d.ts +17 -2
- package/dist/server/content.js +89 -14
- package/dist/server/db/migration-data.js +24 -0
- package/dist/server/db/migrations/0001_independent_password_resets.sql +3 -0
- package/dist/server/db/migrations/0002_email_failure_reason.sql +1 -0
- package/dist/server/db/migrations/0003_direct_r2_uploads.sql +10 -0
- package/dist/server/db/migrations/0004_agent_api_keys.sql +38 -0
- package/dist/server/db/migrations/0005_api_retention_and_pagination.sql +3 -0
- package/dist/server/db/migrations/0006_durable_media_deletion.sql +7 -0
- package/dist/server/db/migrations/meta/0001_snapshot.json +1197 -0
- package/dist/server/db/migrations/meta/0002_snapshot.json +1204 -0
- package/dist/server/db/migrations/meta/0003_snapshot.json +1281 -0
- package/dist/server/db/migrations/meta/0004_snapshot.json +1546 -0
- package/dist/server/db/migrations/meta/0005_snapshot.json +1572 -0
- package/dist/server/db/migrations/meta/0006_snapshot.json +1627 -0
- package/dist/server/db/migrations/meta/_journal.json +42 -0
- package/dist/server/db/schema.d.ts +742 -2
- package/dist/server/db/schema.js +77 -5
- package/dist/server/email/index.d.ts +11 -1
- package/dist/server/email/index.js +69 -6
- package/dist/server/forms.js +12 -2
- package/dist/server/hooks.d.ts +1 -1
- package/dist/server/hooks.js +37 -14
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/links.d.ts +5 -0
- package/dist/server/links.js +44 -0
- package/dist/server/media/deletions.d.ts +2 -0
- package/dist/server/media/deletions.js +58 -0
- package/dist/server/media/presets.d.ts +10 -2
- package/dist/server/media/presets.js +14 -2
- package/dist/server/media/runner.d.ts +1 -1
- package/dist/server/media/runner.js +105 -8
- package/dist/server/media/service.d.ts +41 -3
- package/dist/server/media/service.js +146 -33
- package/dist/server/notifications.d.ts +1 -0
- package/dist/server/notifications.js +4 -2
- package/dist/server/request.d.ts +2 -0
- package/dist/server/request.js +5 -0
- package/dist/server/search.d.ts +13 -0
- package/dist/server/search.js +97 -0
- package/dist/worker/index.d.ts +3 -3
- package/dist/worker/index.js +205 -64
- package/dist/worker/local.d.ts +5 -0
- package/dist/worker/local.js +57 -0
- package/dist/worker/source.d.ts +1 -1
- package/dist/worker/source.js +2 -2
- package/dist/worker/uploads.d.ts +22 -0
- package/dist/worker/uploads.js +46 -0
- package/docs/acceptance.md +1 -1
- package/docs/api.md +73 -0
- package/docs/cloudflare.md +35 -8
- package/docs/content.md +181 -5
- package/docs/deployment.md +29 -4
- package/docs/email.md +14 -10
- package/docs/forms.md +3 -1
- package/docs/media.md +34 -5
- package/docs/package.md +7 -5
- package/docs/releases.md +56 -1
- package/docs/upgrades.md +59 -3
- package/package.json +19 -10
- package/templates/hooks.server.ts +3 -3
- package/templates/integration.ts +2 -2
- package/templates/routes/admin/+page.server.ts +2 -2
- package/templates/routes/admin/+page.svelte +1 -1
- package/templates/routes/api/+server.ts +2 -2
- package/templates/sandcms/blueprints/collections/projects.yaml +16 -8
- package/templates/sandcms/blueprints/fields/seo.yaml +5 -0
- package/templates/sandcms/blueprints/files/image.yaml +1 -0
- package/templates/sandcms/blueprints/pages/home.yaml +3 -0
- package/templates/sandcms/config.yaml +1 -0
- package/templates/sandcms/worker/index.ts +1 -1
- package/templates/sandcms/worker/local.ts +1 -0
- package/templates/sandcms/worker/wrangler.jsonc +1 -2
package/dist/blueprints/files.js
CHANGED
|
@@ -64,6 +64,8 @@ export function publicMetadata(fields, values) {
|
|
|
64
64
|
return result;
|
|
65
65
|
}
|
|
66
66
|
export function configureFileFields(definition) {
|
|
67
|
+
if (definition.config.media.presets['sandcms-preview'])
|
|
68
|
+
throw new Error('sandcms-preview is reserved for the focal point picker');
|
|
67
69
|
const blueprints = fileBlueprints(definition);
|
|
68
70
|
const ids = new Set();
|
|
69
71
|
for (const blueprint of blueprints) {
|
|
@@ -74,15 +76,25 @@ export function configureFileFields(definition) {
|
|
|
74
76
|
throw new Error(`${blueprint.id}: only supported image MIME types can be accepted for now`);
|
|
75
77
|
if (blueprint.fields.image)
|
|
76
78
|
throw new Error(`${blueprint.id}: image is reserved for gallery references`);
|
|
77
|
-
|
|
79
|
+
if (Object.values(blueprint.fields).filter((f) => f.type === 'focus').length > 1)
|
|
80
|
+
throw new Error(`${blueprint.id}: only one focus field is supported`);
|
|
81
|
+
const check = (fields, nested = false) => {
|
|
78
82
|
for (const field of Object.values(fields)) {
|
|
83
|
+
if (nested && field.type === 'focus')
|
|
84
|
+
throw new Error(`${blueprint.id}: focus must be a top-level file field`);
|
|
79
85
|
if (['media', 'media-list', 'gallery'].includes(field.type))
|
|
80
86
|
throw new Error(`${blueprint.id}: file metadata cannot contain media fields`);
|
|
81
87
|
if (field.type === 'relation' &&
|
|
82
88
|
!definition.blueprints.some((b) => b.kind === 'collection' && b.id === field.collection))
|
|
83
89
|
throw new Error(`${blueprint.id}: unknown relation collection ${field.collection}`);
|
|
90
|
+
if (field.type === 'link' &&
|
|
91
|
+
field.collection &&
|
|
92
|
+
!definition.blueprints.some((b) => b.kind === 'collection' && b.id === field.collection))
|
|
93
|
+
throw new Error(`${blueprint.id}: unknown relation collection ${field.collection}`);
|
|
94
|
+
if (field.type === 'link' && field.fileBlueprint)
|
|
95
|
+
getFileBlueprint(definition, field.fileBlueprint);
|
|
84
96
|
if (field.fields)
|
|
85
|
-
check(field.fields);
|
|
97
|
+
check(field.fields, true);
|
|
86
98
|
}
|
|
87
99
|
};
|
|
88
100
|
check(blueprint.fields);
|
|
@@ -91,6 +103,8 @@ export function configureFileFields(definition) {
|
|
|
91
103
|
getFileBlueprint(definition);
|
|
92
104
|
const visit = (fields) => {
|
|
93
105
|
for (const field of Object.values(fields)) {
|
|
106
|
+
if (field.type === 'focus')
|
|
107
|
+
throw new Error('Focus requires a file blueprint');
|
|
94
108
|
if (['media', 'media-list', 'gallery'].includes(field.type)) {
|
|
95
109
|
const file = getFileBlueprint(definition, field.fileBlueprint);
|
|
96
110
|
field.fileBlueprint = file.id;
|
|
@@ -99,10 +113,14 @@ export function configureFileFields(definition) {
|
|
|
99
113
|
for (const key of field.overrides ?? []) {
|
|
100
114
|
if (!file.fields[key])
|
|
101
115
|
throw new Error(`Unknown override ${key} in file blueprint ${file.id}`);
|
|
116
|
+
if (file.fields[key].type === 'focus')
|
|
117
|
+
throw new Error('Focus is shared file metadata and cannot be overridden');
|
|
102
118
|
field.fields[key] = { ...file.fields[key], required: false };
|
|
103
119
|
}
|
|
104
120
|
}
|
|
105
121
|
}
|
|
122
|
+
if (field.type === 'link' && field.fileBlueprint)
|
|
123
|
+
getFileBlueprint(definition, field.fileBlueprint);
|
|
106
124
|
if (field.fields)
|
|
107
125
|
visit(field.fields);
|
|
108
126
|
}
|
|
@@ -110,3 +128,18 @@ export function configureFileFields(definition) {
|
|
|
110
128
|
definition.blueprints.forEach((blueprint) => visit(blueprint.fields));
|
|
111
129
|
return definition;
|
|
112
130
|
}
|
|
131
|
+
export function isFocusPoint(value) {
|
|
132
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
133
|
+
return false;
|
|
134
|
+
const point = value;
|
|
135
|
+
return (Object.keys(point).length === 2 &&
|
|
136
|
+
['x', 'y'].every((key) => typeof point[key] === 'number' &&
|
|
137
|
+
Number.isFinite(point[key]) &&
|
|
138
|
+
point[key] >= 0 &&
|
|
139
|
+
point[key] <= 1));
|
|
140
|
+
}
|
|
141
|
+
export function fileFocus(blueprint, metadata) {
|
|
142
|
+
const key = Object.keys(blueprint.fields).find((key) => blueprint.fields[key].type === 'focus');
|
|
143
|
+
const value = key ? metadata[key] : undefined;
|
|
144
|
+
return isFocusPoint(value) ? { x: value.x, y: value.y } : undefined;
|
|
145
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BlueprintTab, FieldWidth } from './types.js';
|
|
2
|
+
export declare function widthSpan(width?: FieldWidth): number;
|
|
3
|
+
export declare function tabFields(tab: BlueprintTab): string[];
|
|
4
|
+
export declare function tabErrorCount(tab: BlueprintTab, errors: Record<string, string>): number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function widthSpan(width = '1/1') {
|
|
2
|
+
const [numerator, denominator] = width.split('/').map(Number);
|
|
3
|
+
return (12 * numerator) / denominator;
|
|
4
|
+
}
|
|
5
|
+
export function tabFields(tab) {
|
|
6
|
+
return (tab.fields ??
|
|
7
|
+
tab.columns.flatMap((column) => Object.values(column.sections).flatMap((section) => section.fields)));
|
|
8
|
+
}
|
|
9
|
+
export function tabErrorCount(tab, errors) {
|
|
10
|
+
const fields = new Set(tabFields(tab));
|
|
11
|
+
return Object.keys(errors).filter((path) => fields.has(path.split('.')[0])).length;
|
|
12
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { Blueprint, Field, SiteDefinition } from './types.js';
|
|
3
|
-
export declare function yamlFile<T>(path: string, schema: z.ZodType<T
|
|
3
|
+
export declare function yamlFile<T>(path: string, schema: z.ZodType<T>, transform?: (value: unknown) => unknown): T;
|
|
4
4
|
export declare function loadDefinition(root?: string): SiteDefinition;
|
|
5
5
|
export declare function visitFields(fields: Record<string, Field>, visit: (field: Field, key: string) => void): void;
|
|
6
6
|
export declare function validateDefinitions(defs: Blueprint[]): void;
|
package/dist/blueprints/load.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { configureFileFields, imageMimeTypes } from './files.js';
|
|
2
2
|
import { readFileSync, readdirSync } from 'node:fs';
|
|
3
|
-
import { join } from 'node:path';
|
|
3
|
+
import { join, relative } from 'node:path';
|
|
4
|
+
import { createFieldResolver } from './extends.js';
|
|
4
5
|
import { parseDocument, LineCounter } from 'yaml';
|
|
5
6
|
import { z } from 'zod';
|
|
6
7
|
import { isBlueprintIcon } from '../server/blueprint-icons.js';
|
|
@@ -8,9 +9,11 @@ const key = z
|
|
|
8
9
|
.string()
|
|
9
10
|
.regex(/^[a-z][a-zA-Z0-9_-]*$/, 'Use a stable machine key starting with a lowercase letter')
|
|
10
11
|
.refine((v) => !['__proto__', 'constructor', 'prototype'].includes(v), 'Reserved machine key');
|
|
12
|
+
const width = z.enum(['1/1', '1/2', '1/3', '2/3', '1/4', '3/4']);
|
|
11
13
|
const field = z.lazy(() => z
|
|
12
14
|
.object({
|
|
13
15
|
type: z.enum([
|
|
16
|
+
'focus',
|
|
14
17
|
'text',
|
|
15
18
|
'slug',
|
|
16
19
|
'textarea',
|
|
@@ -19,6 +22,7 @@ const field = z.lazy(() => z
|
|
|
19
22
|
'boolean',
|
|
20
23
|
'select',
|
|
21
24
|
'multiselect',
|
|
25
|
+
'link',
|
|
22
26
|
'richtext',
|
|
23
27
|
'media',
|
|
24
28
|
'media-list',
|
|
@@ -27,9 +31,21 @@ const field = z.lazy(() => z
|
|
|
27
31
|
'group',
|
|
28
32
|
'repeatable'
|
|
29
33
|
]),
|
|
34
|
+
width: width.optional(),
|
|
30
35
|
label: z.string().optional(),
|
|
31
36
|
description: z.string().optional(),
|
|
37
|
+
help: z.string().optional(),
|
|
38
|
+
placeholder: z.string().optional(),
|
|
39
|
+
before: z.string().optional(),
|
|
40
|
+
after: z.string().optional(),
|
|
41
|
+
counter: z.boolean().optional(),
|
|
42
|
+
minLength: z.number().int().nonnegative().optional(),
|
|
43
|
+
maxLength: z.number().int().nonnegative().optional(),
|
|
32
44
|
required: z.boolean().optional(),
|
|
45
|
+
when: z
|
|
46
|
+
.record(key, z.union([z.string(), z.number(), z.boolean(), z.null()]))
|
|
47
|
+
.refine((v) => Object.keys(v).length > 0, 'Define at least one condition')
|
|
48
|
+
.optional(),
|
|
33
49
|
from: key.optional(),
|
|
34
50
|
fileBlueprint: key.optional(),
|
|
35
51
|
overrides: z
|
|
@@ -38,12 +54,35 @@ const field = z.lazy(() => z
|
|
|
38
54
|
.optional(),
|
|
39
55
|
collection: key.optional(),
|
|
40
56
|
options: z.array(z.string()).nonempty().optional(),
|
|
41
|
-
fields:
|
|
57
|
+
fields: fieldMap().optional(),
|
|
42
58
|
min: z.number().optional(),
|
|
43
59
|
max: z.number().optional()
|
|
44
60
|
})
|
|
45
61
|
.strict()
|
|
46
62
|
.superRefine((v, ctx) => {
|
|
63
|
+
const text = ['text', 'slug', 'textarea'].includes(v.type);
|
|
64
|
+
if (!text &&
|
|
65
|
+
(v.counter !== undefined || v.minLength !== undefined || v.maxLength !== undefined))
|
|
66
|
+
ctx.addIssue({
|
|
67
|
+
code: 'custom',
|
|
68
|
+
message: 'counter and length limits require text, slug, or textarea'
|
|
69
|
+
});
|
|
70
|
+
if (v.minLength !== undefined && v.maxLength !== undefined && v.minLength > v.maxLength)
|
|
71
|
+
ctx.addIssue({
|
|
72
|
+
code: 'custom',
|
|
73
|
+
path: ['maxLength'],
|
|
74
|
+
message: 'maxLength must be at least minLength'
|
|
75
|
+
});
|
|
76
|
+
if ((v.before !== undefined || v.after !== undefined) &&
|
|
77
|
+
!['text', 'slug', 'number'].includes(v.type))
|
|
78
|
+
ctx.addIssue({ code: 'custom', message: 'before and after require text, slug, or number' });
|
|
79
|
+
if (v.placeholder !== undefined &&
|
|
80
|
+
!['text', 'slug', 'textarea', 'number', 'select', 'relation'].includes(v.type))
|
|
81
|
+
ctx.addIssue({
|
|
82
|
+
code: 'custom',
|
|
83
|
+
path: ['placeholder'],
|
|
84
|
+
message: 'This field type does not support placeholder'
|
|
85
|
+
});
|
|
47
86
|
if (['group', 'repeatable'].includes(v.type) && !v.fields)
|
|
48
87
|
ctx.addIssue({ code: 'custom', message: 'Nested fields are required' });
|
|
49
88
|
if (v.type === 'gallery' && v.fields)
|
|
@@ -53,10 +92,10 @@ const field = z.lazy(() => z
|
|
|
53
92
|
});
|
|
54
93
|
if (v.overrides && v.type !== 'gallery')
|
|
55
94
|
ctx.addIssue({ code: 'custom', message: 'Only galleries support overrides' });
|
|
56
|
-
if (v.fileBlueprint && !['media', 'media-list', 'gallery'].includes(v.type))
|
|
95
|
+
if (v.fileBlueprint && !['media', 'media-list', 'gallery', 'link'].includes(v.type))
|
|
57
96
|
ctx.addIssue({
|
|
58
97
|
code: 'custom',
|
|
59
|
-
message: 'fileBlueprint requires a media or
|
|
98
|
+
message: 'fileBlueprint requires a media, gallery or link field'
|
|
60
99
|
});
|
|
61
100
|
if (v.type === 'gallery' && v.collection)
|
|
62
101
|
ctx.addIssue({ code: 'custom', message: 'Define gallery relations in a file blueprint' });
|
|
@@ -65,6 +104,35 @@ const field = z.lazy(() => z
|
|
|
65
104
|
if (['select', 'multiselect'].includes(v.type) && !v.options)
|
|
66
105
|
ctx.addIssue({ code: 'custom', message: 'Select options are required' });
|
|
67
106
|
}));
|
|
107
|
+
function fieldMap() {
|
|
108
|
+
return z.record(key, field).superRefine((fields, ctx) => {
|
|
109
|
+
for (const [name, definition] of Object.entries(fields)) {
|
|
110
|
+
for (const dependency of Object.keys(definition.when ?? {})) {
|
|
111
|
+
if (!Object.hasOwn(fields, dependency) || dependency === name)
|
|
112
|
+
ctx.addIssue({
|
|
113
|
+
code: 'custom',
|
|
114
|
+
path: [name, 'when', dependency],
|
|
115
|
+
message: 'Conditions must reference another sibling field'
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
const fieldKeys = z.array(key).nonempty();
|
|
122
|
+
const sections = z
|
|
123
|
+
.record(key, z.object({ label: z.string().min(1).optional(), fields: fieldKeys }).strict())
|
|
124
|
+
.refine((v) => Object.keys(v).length > 0, 'Define at least one section');
|
|
125
|
+
const tabs = z
|
|
126
|
+
.record(key, z.union([
|
|
127
|
+
z.object({ label: z.string().min(1).optional(), fields: fieldKeys }).strict(),
|
|
128
|
+
z
|
|
129
|
+
.object({
|
|
130
|
+
label: z.string().min(1).optional(),
|
|
131
|
+
columns: z.array(z.object({ width: width.optional(), sections }).strict()).nonempty()
|
|
132
|
+
})
|
|
133
|
+
.strict()
|
|
134
|
+
]))
|
|
135
|
+
.refine((v) => Object.keys(v).length > 0, 'Define at least one tab');
|
|
68
136
|
const blueprint = z
|
|
69
137
|
.object({
|
|
70
138
|
id: key,
|
|
@@ -74,23 +142,62 @@ const blueprint = z
|
|
|
74
142
|
.string()
|
|
75
143
|
.refine(isBlueprintIcon, 'Unknown Lucide icon; use a lowercase kebab-case name from lucide.dev/icons')
|
|
76
144
|
.optional(),
|
|
145
|
+
navigation: z
|
|
146
|
+
.object({ group: z.union([z.string().trim().min(1), z.literal(false)]) })
|
|
147
|
+
.strict()
|
|
148
|
+
.optional(),
|
|
77
149
|
description: z.string().optional(),
|
|
78
150
|
preview: z
|
|
79
151
|
.string()
|
|
80
152
|
.regex(/^\/(?!\/)[^?#]*$/)
|
|
81
153
|
.optional(),
|
|
82
|
-
fields:
|
|
154
|
+
fields: fieldMap(),
|
|
155
|
+
tabs: tabs.optional(),
|
|
83
156
|
columns: z.array(key).optional(),
|
|
84
157
|
export: z.array(key).optional()
|
|
85
158
|
})
|
|
86
|
-
.strict()
|
|
159
|
+
.strict()
|
|
160
|
+
.superRefine((v, ctx) => {
|
|
161
|
+
if (!v.tabs)
|
|
162
|
+
return;
|
|
163
|
+
const seen = new Set();
|
|
164
|
+
const check = (keys, path) => {
|
|
165
|
+
keys.forEach((name, i) => {
|
|
166
|
+
if (!Object.hasOwn(v.fields, name))
|
|
167
|
+
ctx.addIssue({
|
|
168
|
+
code: 'custom',
|
|
169
|
+
path: [...path, i],
|
|
170
|
+
message: `Unknown layout field: ${name}`
|
|
171
|
+
});
|
|
172
|
+
if (seen.has(name))
|
|
173
|
+
ctx.addIssue({
|
|
174
|
+
code: 'custom',
|
|
175
|
+
path: [...path, i],
|
|
176
|
+
message: `Duplicate layout field: ${name}`
|
|
177
|
+
});
|
|
178
|
+
seen.add(name);
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
for (const [id, tab] of Object.entries(v.tabs)) {
|
|
182
|
+
if ('fields' in tab)
|
|
183
|
+
check(tab.fields, ['tabs', id, 'fields']);
|
|
184
|
+
else
|
|
185
|
+
tab.columns.forEach((column, i) => {
|
|
186
|
+
for (const [section, value] of Object.entries(column.sections))
|
|
187
|
+
check(value.fields, ['tabs', id, 'columns', i, 'sections', section, 'fields']);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
for (const name of Object.keys(v.fields))
|
|
191
|
+
if (!seen.has(name))
|
|
192
|
+
ctx.addIssue({ code: 'custom', path: ['tabs'], message: `Missing layout field: ${name}` });
|
|
193
|
+
});
|
|
87
194
|
const fileBlueprint = z
|
|
88
195
|
.object({
|
|
89
196
|
id: key,
|
|
90
197
|
kind: z.literal('file'),
|
|
91
198
|
label: z.string().min(1),
|
|
92
199
|
accept: z.array(z.string()).nonempty().default(imageMimeTypes),
|
|
93
|
-
fields:
|
|
200
|
+
fields: fieldMap()
|
|
94
201
|
})
|
|
95
202
|
.strict();
|
|
96
203
|
const anyBlueprint = z.discriminatedUnion('kind', [blueprint, fileBlueprint]);
|
|
@@ -106,6 +213,7 @@ const config = z
|
|
|
106
213
|
presets: z
|
|
107
214
|
.record(z.string().regex(/^[a-z][a-z0-9_-]*$/, 'Use a lowercase media preset key'), z
|
|
108
215
|
.object({
|
|
216
|
+
aspectRatio: z.number().min(0.01).max(100).optional(),
|
|
109
217
|
sizes: z.array(z.number().int().min(1).max(8192)).min(1).max(12),
|
|
110
218
|
formats: z
|
|
111
219
|
.object({
|
|
@@ -122,12 +230,12 @@ const config = z
|
|
|
122
230
|
.strict()
|
|
123
231
|
})
|
|
124
232
|
.strict();
|
|
125
|
-
export function yamlFile(path, schema) {
|
|
233
|
+
export function yamlFile(path, schema, transform = (value) => value) {
|
|
126
234
|
const lines = new LineCounter();
|
|
127
235
|
const doc = parseDocument(readFileSync(path, 'utf8'), { lineCounter: lines, uniqueKeys: true });
|
|
128
236
|
if (doc.errors.length)
|
|
129
237
|
throw new Error(`${path}: ${doc.errors.map((e) => e.message).join('; ')}`);
|
|
130
|
-
const result = schema.safeParse(doc.toJS({ maxAliasCount: 20 }));
|
|
238
|
+
const result = schema.safeParse(transform(doc.toJS({ maxAliasCount: 20 })));
|
|
131
239
|
if (!result.success)
|
|
132
240
|
throw new Error(result.error.issues
|
|
133
241
|
.map((i) => {
|
|
@@ -142,9 +250,16 @@ function files(dir) {
|
|
|
142
250
|
}
|
|
143
251
|
export function loadDefinition(root = 'sandcms') {
|
|
144
252
|
const settings = yamlFile(join(root, 'config.yaml'), config);
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
253
|
+
const directory = join(root, 'blueprints');
|
|
254
|
+
const resolver = createFieldResolver(directory, (path, transform) => yamlFile(path, field, transform));
|
|
255
|
+
const paths = files(directory).sort();
|
|
256
|
+
const isShared = (path) => relative(directory, path).split(/[\\/]/)[0] === 'fields';
|
|
257
|
+
// Validate unused shared definitions too, so configuration mistakes fail at startup.
|
|
258
|
+
for (const path of paths.filter(isShared))
|
|
259
|
+
resolver.shared(path);
|
|
260
|
+
const definitions = paths
|
|
261
|
+
.filter((path) => !isShared(path))
|
|
262
|
+
.map((p) => yamlFile(p, anyBlueprint, (value) => resolver.blueprint(value, p)));
|
|
148
263
|
const content = definitions.filter((b) => b.kind !== 'file');
|
|
149
264
|
validateDefinitions(content);
|
|
150
265
|
if (settings.media.photographerCollection &&
|
|
@@ -4,12 +4,39 @@ export type Json = null | boolean | number | string | Json[] | {
|
|
|
4
4
|
export type Payload = {
|
|
5
5
|
[key: string]: Json;
|
|
6
6
|
};
|
|
7
|
-
export type FieldType = 'text' | 'slug' | 'textarea' | 'number' | 'date' | 'boolean' | 'select' | 'multiselect' | 'richtext' | 'media' | 'media-list' | 'gallery' | 'relation' | 'group' | 'repeatable';
|
|
7
|
+
export type FieldType = 'focus' | 'text' | 'slug' | 'textarea' | 'number' | 'date' | 'boolean' | 'select' | 'multiselect' | 'link' | 'richtext' | 'media' | 'media-list' | 'gallery' | 'relation' | 'group' | 'repeatable';
|
|
8
|
+
export type FieldWidth = '1/1' | '1/2' | '1/3' | '2/3' | '1/4' | '3/4';
|
|
9
|
+
export interface BlueprintSection {
|
|
10
|
+
label?: string;
|
|
11
|
+
fields: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface BlueprintColumn {
|
|
14
|
+
width?: FieldWidth;
|
|
15
|
+
sections: Record<string, BlueprintSection>;
|
|
16
|
+
}
|
|
17
|
+
export type BlueprintTab = {
|
|
18
|
+
label?: string;
|
|
19
|
+
} & ({
|
|
20
|
+
fields: string[];
|
|
21
|
+
columns?: never;
|
|
22
|
+
} | {
|
|
23
|
+
columns: BlueprintColumn[];
|
|
24
|
+
fields?: never;
|
|
25
|
+
});
|
|
8
26
|
export interface Field {
|
|
9
27
|
type: FieldType;
|
|
28
|
+
width?: FieldWidth;
|
|
10
29
|
label?: string;
|
|
11
30
|
description?: string;
|
|
31
|
+
help?: string;
|
|
32
|
+
placeholder?: string;
|
|
33
|
+
before?: string;
|
|
34
|
+
after?: string;
|
|
35
|
+
counter?: boolean;
|
|
36
|
+
minLength?: number;
|
|
37
|
+
maxLength?: number;
|
|
12
38
|
required?: boolean;
|
|
39
|
+
when?: Record<string, string | number | boolean | null>;
|
|
13
40
|
from?: string;
|
|
14
41
|
collection?: string;
|
|
15
42
|
options?: string[];
|
|
@@ -24,9 +51,13 @@ export interface Blueprint {
|
|
|
24
51
|
label: string;
|
|
25
52
|
kind: 'page' | 'site' | 'collection' | 'form';
|
|
26
53
|
icon?: string;
|
|
54
|
+
navigation?: {
|
|
55
|
+
group: string | false;
|
|
56
|
+
};
|
|
27
57
|
description?: string;
|
|
28
58
|
preview?: string;
|
|
29
59
|
fields: Record<string, Field>;
|
|
60
|
+
tabs?: Record<string, BlueprintTab>;
|
|
30
61
|
columns?: string[];
|
|
31
62
|
export?: string[];
|
|
32
63
|
}
|
|
@@ -37,7 +68,13 @@ export interface FileBlueprint {
|
|
|
37
68
|
accept: string[];
|
|
38
69
|
fields: Record<string, Field>;
|
|
39
70
|
}
|
|
71
|
+
export interface FocusPoint {
|
|
72
|
+
x: number;
|
|
73
|
+
y: number;
|
|
74
|
+
}
|
|
40
75
|
export interface ImagePreset {
|
|
76
|
+
/** Width divided by height; omitted to preserve the whole image. */
|
|
77
|
+
aspectRatio?: number;
|
|
41
78
|
sizes: number[];
|
|
42
79
|
formats: Partial<Record<'webp' | 'avif' | 'jpeg', number>>;
|
|
43
80
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { isFocusPoint } from './files.js';
|
|
2
|
+
import { isLinkValue } from '../link.js';
|
|
1
3
|
import { galleryFields } from './gallery.js';
|
|
4
|
+
import { fieldVisible } from './conditions.js';
|
|
2
5
|
import { validateRichText } from '../richtext.js';
|
|
3
6
|
const hasText = (node) => Boolean(node.text?.trim()) || Boolean(node.content?.some(hasText));
|
|
4
7
|
export class ValidationError extends Error {
|
|
@@ -43,15 +46,23 @@ export function jsonPayload(value, maxBytes = 1_000_000) {
|
|
|
43
46
|
}
|
|
44
47
|
export function validatePayload(fields, value, publish = false) {
|
|
45
48
|
const data = jsonPayload(value), errors = {};
|
|
46
|
-
const check = (defs, values, prefix = '') => {
|
|
49
|
+
const check = (defs, values, prefix = '', visible = true) => {
|
|
47
50
|
for (const [key, f] of Object.entries(defs)) {
|
|
48
|
-
const path = prefix + key, v = values[key], empty = v === undefined ||
|
|
51
|
+
const path = prefix + key, required = publish && visible && fieldVisible(f, values) && f.required, v = values[key], empty = v === undefined ||
|
|
52
|
+
v === null ||
|
|
53
|
+
(v === '' &&
|
|
54
|
+
['text', 'textarea', 'slug', 'date', 'media', 'relation', 'select'].includes(f.type)) ||
|
|
55
|
+
(Array.isArray(v) &&
|
|
56
|
+
!v.length &&
|
|
57
|
+
['media-list', 'multiselect', 'repeatable', 'gallery'].includes(f.type));
|
|
49
58
|
if (empty) {
|
|
50
|
-
if (
|
|
59
|
+
if (required)
|
|
51
60
|
errors[path] = 'This field is required';
|
|
52
61
|
continue;
|
|
53
62
|
}
|
|
54
63
|
let valid = true;
|
|
64
|
+
if (f.type === 'focus')
|
|
65
|
+
valid = isFocusPoint(v);
|
|
55
66
|
if (['text', 'textarea', 'slug', 'date', 'media', 'relation', 'select'].includes(f.type))
|
|
56
67
|
valid = typeof v === 'string';
|
|
57
68
|
if (f.type === 'slug')
|
|
@@ -75,10 +86,15 @@ export function validatePayload(fields, value, publish = false) {
|
|
|
75
86
|
valid =
|
|
76
87
|
Array.isArray(v) &&
|
|
77
88
|
v.every((x) => typeof x === 'string' && (f.type !== 'multiselect' || f.options?.includes(x)));
|
|
89
|
+
if (f.type === 'link') {
|
|
90
|
+
valid = isLinkValue(v);
|
|
91
|
+
if (valid && required && !v.value)
|
|
92
|
+
errors[path] = 'This field is required';
|
|
93
|
+
}
|
|
78
94
|
if (f.type === 'richtext') {
|
|
79
95
|
try {
|
|
80
96
|
const root = validateRichText(v);
|
|
81
|
-
if (
|
|
97
|
+
if (required && !hasText(root))
|
|
82
98
|
errors[path] = 'This field is required';
|
|
83
99
|
}
|
|
84
100
|
catch (e) {
|
|
@@ -88,12 +104,18 @@ export function validatePayload(fields, value, publish = false) {
|
|
|
88
104
|
if (f.type === 'group') {
|
|
89
105
|
valid = !!v && typeof v === 'object' && !Array.isArray(v);
|
|
90
106
|
if (valid)
|
|
91
|
-
check(f.fields, v, path + '.');
|
|
107
|
+
check(f.fields, v, path + '.', visible && fieldVisible(f, values));
|
|
92
108
|
}
|
|
93
109
|
if (f.type === 'repeatable' || f.type === 'gallery') {
|
|
94
110
|
valid = Array.isArray(v) && v.every((x) => x && typeof x === 'object' && !Array.isArray(x));
|
|
95
111
|
if (valid)
|
|
96
|
-
v.forEach((x, i) => check(f.type === 'gallery' ? galleryFields(f) : f.fields, x, `${path}.${i}
|
|
112
|
+
v.forEach((x, i) => check(f.type === 'gallery' ? galleryFields(f) : f.fields, x, `${path}.${i}.`, visible && fieldVisible(f, values)));
|
|
113
|
+
}
|
|
114
|
+
if (valid && typeof v === 'string' && ['text', 'slug', 'textarea'].includes(f.type)) {
|
|
115
|
+
if (f.minLength !== undefined && v.length < f.minLength)
|
|
116
|
+
errors[path] = `Use at least ${f.minLength} characters`;
|
|
117
|
+
if (f.maxLength !== undefined && v.length > f.maxLength)
|
|
118
|
+
errors[path] = `Use at most ${f.maxLength} characters`;
|
|
97
119
|
}
|
|
98
120
|
if (!valid)
|
|
99
121
|
errors[path] = `Invalid ${f.type} value`;
|
|
@@ -119,6 +141,8 @@ export function walkValues(fields, payload, visit) {
|
|
|
119
141
|
for (const [key, field] of Object.entries(f.fields ?? {})) {
|
|
120
142
|
if (field.type === 'relation' && x[key] && row[key] === null)
|
|
121
143
|
row[key] = '';
|
|
144
|
+
if (field.type === 'link' && x[key] && row[key] === null)
|
|
145
|
+
row[key] = { type: 'url', value: '' };
|
|
122
146
|
}
|
|
123
147
|
}
|
|
124
148
|
return row;
|
package/dist/cli/cloudflare.js
CHANGED
|
@@ -84,8 +84,7 @@ export async function configureWorker(root, name) {
|
|
|
84
84
|
account_id: accountId,
|
|
85
85
|
main: 'index.ts',
|
|
86
86
|
compatibility_date: '2026-09-25',
|
|
87
|
-
r2_buckets: [{ binding: 'MEDIA', bucket_name: bucket }]
|
|
88
|
-
images: { binding: 'IMAGES' }
|
|
87
|
+
r2_buckets: [{ binding: 'MEDIA', bucket_name: bucket }]
|
|
89
88
|
}, null, 2) + '\n');
|
|
90
89
|
// Setup already installed the package Worker entry; leave any developer customization intact.
|
|
91
90
|
await run([...wrangler, 'r2', 'bucket', 'create', bucket, '--config', file], root);
|
|
@@ -102,6 +101,19 @@ export async function configureWorker(root, name) {
|
|
|
102
101
|
const deployed = await capture(['deploy', '--config', file]);
|
|
103
102
|
console.log(deployed);
|
|
104
103
|
await run([...wrangler, 'secret', 'put', 'CMS_TOKEN', '--config', file], root, secret + '\n');
|
|
104
|
+
await run([...wrangler, 'secret', 'put', 'R2_ACCOUNT_ID', '--config', file], root, accountId + '\n');
|
|
105
|
+
await run([...wrangler, 'secret', 'put', 'R2_BUCKET_NAME', '--config', file], root, bucket + '\n');
|
|
106
|
+
console.log(`Create an R2 API token with Object Read & Write access restricted to ${bucket}: https://dash.cloudflare.com/?to=/:account/r2/api-tokens`);
|
|
107
|
+
const accessKey = answer(await p.password({
|
|
108
|
+
message: 'R2 Access Key ID',
|
|
109
|
+
validate: (v) => (v?.trim() ? undefined : 'Required for direct uploads')
|
|
110
|
+
}));
|
|
111
|
+
const secretKey = answer(await p.password({
|
|
112
|
+
message: 'R2 Secret Access Key',
|
|
113
|
+
validate: (v) => (v?.trim() ? undefined : 'Required for direct uploads')
|
|
114
|
+
}));
|
|
115
|
+
await run([...wrangler, 'secret', 'put', 'R2_ACCESS_KEY_ID', '--config', file], root, accessKey.trim() + '\n');
|
|
116
|
+
await run([...wrangler, 'secret', 'put', 'R2_SECRET_ACCESS_KEY', '--config', file], root, secretKey.trim() + '\n');
|
|
105
117
|
const url = deployed.match(/https:\/\/[a-z0-9.-]+\.workers\.dev/i)?.[0];
|
|
106
118
|
if (!url)
|
|
107
119
|
throw new Error('Worker deployed; copy its URL into config.yaml before marking provisioning ready.');
|
|
@@ -110,7 +122,7 @@ export async function configureWorker(root, name) {
|
|
|
110
122
|
write(configFile, config.toString());
|
|
111
123
|
manifest.cloudflare = { accountId, worker, bucket, phase: 'ready' };
|
|
112
124
|
write(join(root, 'sandcms/install.json'), JSON.stringify(manifest, null, 2) + '\n');
|
|
113
|
-
console.log('Set SANDCMS_WORKER_TOKEN in production using
|
|
125
|
+
console.log('Set SANDCMS_WORKER_TOKEN in production using ignored .env.local. Before uploading, configure R2 PUT CORS for your website origin and a one-day incoming/ lifecycle rule; see docs/cloudflare.md. R2 signing credentials are stored only as Worker secrets.');
|
|
114
126
|
}
|
|
115
127
|
export async function updateWorker(root) {
|
|
116
128
|
const owned = readManifest(root).cloudflare;
|
package/dist/cli/doctor.js
CHANGED
|
@@ -14,7 +14,7 @@ export async function doctor(root, database) {
|
|
|
14
14
|
const pkg = JSON.parse(source('package.json') || '{}');
|
|
15
15
|
check(pkg.packageManager === `bun@${Bun.version}`, 'packageManager pins the running Bun version');
|
|
16
16
|
check(Boolean(source('railpack.json')), 'Railpack configuration exists');
|
|
17
|
-
check(
|
|
17
|
+
check(/@sveltejs\/adapter-bun/.test(source('vite.config.ts') + source('vite.config.js')), 'SvelteKit uses the Bun adapter');
|
|
18
18
|
check(/bun\s+.*build\/index\.js/.test(pkg.scripts?.start ?? ''), 'Production start command runs the Bun adapter output');
|
|
19
19
|
for (const file of [
|
|
20
20
|
'src/routes/(sandcms)/admin/[...path]/+page.server.ts',
|
|
@@ -27,6 +27,9 @@ export async function doctor(root, database) {
|
|
|
27
27
|
console.log(`Blueprints: ${definition.blueprints.length} valid; project: ${definition.config.name}`);
|
|
28
28
|
check((process.env.SANDCMS_SECRET?.length ?? 0) >= 32, 'SANDCMS_SECRET contains at least 32 characters');
|
|
29
29
|
check(Boolean(process.env.SANDCMS_ORIGIN), 'SANDCMS_ORIGIN is configured');
|
|
30
|
+
if (/^https:/i.test(process.env.SANDCMS_ORIGIN ?? '') &&
|
|
31
|
+
!process.env.SANDCMS_TRUSTED_PROXY_HEADER?.trim())
|
|
32
|
+
console.warn('WARN: HTTPS origin without SANDCMS_TRUSTED_PROXY_HEADER. Behind a proxy, visitors may share form and login rate limits. Configure a trusted header and the adapter ADDRESS_HEADER after securing the proxy boundary; see docs/deployment.md#client-ip-behind-dokploy-and-cloudflare.');
|
|
30
33
|
check(existsSync(database), 'SQLite database exists');
|
|
31
34
|
if (existsSync(database)) {
|
|
32
35
|
accessSync(database, constants.R_OK | constants.W_OK);
|
|
@@ -46,9 +49,9 @@ export async function doctor(root, database) {
|
|
|
46
49
|
workerUrl: process.env.SANDCMS_WORKER_URL
|
|
47
50
|
});
|
|
48
51
|
try {
|
|
49
|
-
if ((await cms.media.health()).protocol !==
|
|
52
|
+
if ((await cms.media.health()).protocol !== 5)
|
|
50
53
|
throw new Error('Worker protocol is incompatible');
|
|
51
|
-
console.log('OK: Worker protocol
|
|
54
|
+
console.log('OK: Worker protocol 5 is reachable');
|
|
52
55
|
}
|
|
53
56
|
finally {
|
|
54
57
|
cms.close();
|
package/dist/cli/files.js
CHANGED
|
@@ -109,6 +109,6 @@ export function migrationReport(plan, notes = []) {
|
|
|
109
109
|
notes.map((n) => '- ' + n).join('\n') +
|
|
110
110
|
'\n\n' +
|
|
111
111
|
(plan.some((p) => /src\/hooks\.server\.[jt]s$/.test(p.path) && p.status === 'conflict')
|
|
112
|
-
? `## Compose the existing server hook\n\nPreserve the current handle, rename its export to siteHandle,
|
|
112
|
+
? `## Compose the existing server hook\n\nPreserve the current handle, rename its export to siteHandle, and annotate it with Handle from @sveltejs/kit/hooks (use JSDoc in JavaScript). Then add:\n\n\`\`\`ts\nimport { sequence } from '@sveltejs/kit/hooks';\nimport { building } from '$app/env';\nimport { cmsHandle } from '${PACKAGE_NAME}/server';\nimport { getCMS } from '#lib/server/sandcms/index.js';\nexport const handle = sequence(cmsHandle(getCMS, building), siteHandle);\n\`\`\`\n`
|
|
113
113
|
: ''));
|
|
114
114
|
}
|
package/dist/cli/scaffold.js
CHANGED
|
@@ -21,6 +21,7 @@ export function scaffold(root, name, packageSource) {
|
|
|
21
21
|
version: '0.0.1',
|
|
22
22
|
private: true,
|
|
23
23
|
type: 'module',
|
|
24
|
+
imports: { '#lib': './src/lib/index.ts', '#lib/*': './src/lib/*' },
|
|
24
25
|
packageManager: 'bun@1.4.0',
|
|
25
26
|
scripts: {
|
|
26
27
|
dev: 'bun --bun vite dev --host 0.0.0.0 --port 5410 --strictPort',
|
|
@@ -30,24 +31,25 @@ export function scaffold(root, name, packageSource) {
|
|
|
30
31
|
},
|
|
31
32
|
dependencies: { [PACKAGE_NAME]: packageSource ?? PACKAGE_VERSION },
|
|
32
33
|
devDependencies: {
|
|
33
|
-
'@sveltejs/kit': '
|
|
34
|
+
'@sveltejs/kit': '3.0.0',
|
|
34
35
|
'@sveltejs/vite-plugin-svelte': '7.3.1',
|
|
35
36
|
svelte: '5.57.1',
|
|
36
37
|
vite: '8.3.1',
|
|
37
38
|
typescript: '6.0.3',
|
|
38
|
-
'
|
|
39
|
+
'@sveltejs/adapter-bun': '1.0.0',
|
|
39
40
|
'svelte-check': '4.7.6',
|
|
40
41
|
'@types/bun': '1.4.2'
|
|
41
42
|
}
|
|
42
43
|
}, null, 2) + '\n');
|
|
43
|
-
write(join(root, '
|
|
44
|
-
write(join(root, 'vite.config.ts'), "import { sveltekit } from '@sveltejs/kit/vite';\nimport { defineConfig } from 'vite';\n// Keep Better Auth on native async storage when the Bun adapter bundles the server.\nexport default defineConfig({plugins:[sveltekit()],ssr:{external:['bun:sqlite'],noExternal:['@better-auth/core']}});\n");
|
|
44
|
+
write(join(root, 'vite.config.ts'), "import adapter from '@sveltejs/adapter-bun';\nimport { vitePreprocess } from '@sveltejs/vite-plugin-svelte';\nimport { sveltekit } from '@sveltejs/kit/vite';\nimport { defineConfig } from 'vite';\n// Keep Better Auth on native async storage when the Bun adapter bundles the server.\nexport default defineConfig({plugins:[sveltekit({adapter:adapter(),paths:{origin:process.env.SANDCMS_ORIGIN},preprocess:vitePreprocess()})],ssr:{external:['bun:sqlite'],noExternal:['@better-auth/core']}});\n");
|
|
45
45
|
write(join(root, 'tsconfig.json'), JSON.stringify({
|
|
46
|
-
extends: '
|
|
46
|
+
extends: '$app/tsconfig',
|
|
47
|
+
include: ['src', 'test', '*'],
|
|
48
|
+
exclude: ['src/service-worker'],
|
|
47
49
|
compilerOptions: {
|
|
48
50
|
strict: true,
|
|
49
51
|
skipLibCheck: true,
|
|
50
|
-
types: ['bun'],
|
|
52
|
+
types: ['bun', '$app/types'],
|
|
51
53
|
moduleResolution: 'bundler',
|
|
52
54
|
module: 'esnext'
|
|
53
55
|
}
|