sandcms 0.5.3 → 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 +5 -3
- 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/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 +4 -2
- 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 +109 -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 +123 -12
- package/dist/blueprints/types.d.ts +35 -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 +11 -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/api.md +73 -0
- package/docs/cloudflare.md +35 -8
- package/docs/content.md +162 -4
- package/docs/deployment.md +29 -4
- package/docs/email.md +11 -7
- package/docs/forms.md +3 -1
- package/docs/media.md +33 -4
- package/docs/package.md +6 -4
- package/docs/releases.md +46 -1
- package/docs/upgrades.md +55 -3
- package/package.json +19 -10
- package/templates/hooks.server.ts +2 -2
- package/templates/integration.ts +1 -1
- package/templates/routes/admin/+page.server.ts +1 -1
- package/templates/routes/api/+server.ts +1 -1
- 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 +1 -0
- package/templates/sandcms/config.yaml +1 -0
- package/templates/sandcms/worker/local.ts +1 -0
- package/templates/sandcms/worker/wrangler.jsonc +1 -2
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,
|
|
@@ -83,18 +151,53 @@ const blueprint = z
|
|
|
83
151
|
.string()
|
|
84
152
|
.regex(/^\/(?!\/)[^?#]*$/)
|
|
85
153
|
.optional(),
|
|
86
|
-
fields:
|
|
154
|
+
fields: fieldMap(),
|
|
155
|
+
tabs: tabs.optional(),
|
|
87
156
|
columns: z.array(key).optional(),
|
|
88
157
|
export: z.array(key).optional()
|
|
89
158
|
})
|
|
90
|
-
.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
|
+
});
|
|
91
194
|
const fileBlueprint = z
|
|
92
195
|
.object({
|
|
93
196
|
id: key,
|
|
94
197
|
kind: z.literal('file'),
|
|
95
198
|
label: z.string().min(1),
|
|
96
199
|
accept: z.array(z.string()).nonempty().default(imageMimeTypes),
|
|
97
|
-
fields:
|
|
200
|
+
fields: fieldMap()
|
|
98
201
|
})
|
|
99
202
|
.strict();
|
|
100
203
|
const anyBlueprint = z.discriminatedUnion('kind', [blueprint, fileBlueprint]);
|
|
@@ -110,6 +213,7 @@ const config = z
|
|
|
110
213
|
presets: z
|
|
111
214
|
.record(z.string().regex(/^[a-z][a-z0-9_-]*$/, 'Use a lowercase media preset key'), z
|
|
112
215
|
.object({
|
|
216
|
+
aspectRatio: z.number().min(0.01).max(100).optional(),
|
|
113
217
|
sizes: z.array(z.number().int().min(1).max(8192)).min(1).max(12),
|
|
114
218
|
formats: z
|
|
115
219
|
.object({
|
|
@@ -126,12 +230,12 @@ const config = z
|
|
|
126
230
|
.strict()
|
|
127
231
|
})
|
|
128
232
|
.strict();
|
|
129
|
-
export function yamlFile(path, schema) {
|
|
233
|
+
export function yamlFile(path, schema, transform = (value) => value) {
|
|
130
234
|
const lines = new LineCounter();
|
|
131
235
|
const doc = parseDocument(readFileSync(path, 'utf8'), { lineCounter: lines, uniqueKeys: true });
|
|
132
236
|
if (doc.errors.length)
|
|
133
237
|
throw new Error(`${path}: ${doc.errors.map((e) => e.message).join('; ')}`);
|
|
134
|
-
const result = schema.safeParse(doc.toJS({ maxAliasCount: 20 }));
|
|
238
|
+
const result = schema.safeParse(transform(doc.toJS({ maxAliasCount: 20 })));
|
|
135
239
|
if (!result.success)
|
|
136
240
|
throw new Error(result.error.issues
|
|
137
241
|
.map((i) => {
|
|
@@ -146,9 +250,16 @@ function files(dir) {
|
|
|
146
250
|
}
|
|
147
251
|
export function loadDefinition(root = 'sandcms') {
|
|
148
252
|
const settings = yamlFile(join(root, 'config.yaml'), config);
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
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)));
|
|
152
263
|
const content = definitions.filter((b) => b.kind !== 'file');
|
|
153
264
|
validateDefinitions(content);
|
|
154
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[];
|
|
@@ -30,6 +57,7 @@ export interface Blueprint {
|
|
|
30
57
|
description?: string;
|
|
31
58
|
preview?: string;
|
|
32
59
|
fields: Record<string, Field>;
|
|
60
|
+
tabs?: Record<string, BlueprintTab>;
|
|
33
61
|
columns?: string[];
|
|
34
62
|
export?: string[];
|
|
35
63
|
}
|
|
@@ -40,7 +68,13 @@ export interface FileBlueprint {
|
|
|
40
68
|
accept: string[];
|
|
41
69
|
fields: Record<string, Field>;
|
|
42
70
|
}
|
|
71
|
+
export interface FocusPoint {
|
|
72
|
+
x: number;
|
|
73
|
+
y: number;
|
|
74
|
+
}
|
|
43
75
|
export interface ImagePreset {
|
|
76
|
+
/** Width divided by height; omitted to preserve the whole image. */
|
|
77
|
+
aspectRatio?: number;
|
|
44
78
|
sizes: number[];
|
|
45
79
|
formats: Partial<Record<'webp' | 'avif' | 'jpeg', number>>;
|
|
46
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
|
}
|
package/dist/cli/setup.js
CHANGED
|
@@ -25,9 +25,11 @@ export async function setup(options) {
|
|
|
25
25
|
if (fresh)
|
|
26
26
|
assertFreshDirectory(root);
|
|
27
27
|
const notes = [
|
|
28
|
+
'SvelteKit 3 is required. Migrate developer-owned Vite configuration, package imports, and tsconfig before applying generated integrations; see docs/upgrades.md#sveltekit-3.',
|
|
28
29
|
'Public website routes remain developer-owned.',
|
|
29
30
|
'Run sandcms user bootstrap against the production database after deployment.',
|
|
30
|
-
'Existing adapters are preserved. Configure
|
|
31
|
+
'Existing adapters are preserved. Configure @sveltejs/adapter-bun as shown in docs/deployment.md.',
|
|
32
|
+
'Setup adds commented proxy settings to .env.local. For Dokploy + Cloudflare, secure origin ingress, then set SANDCMS_TRUSTED_PROXY_HEADER=cf-connecting-ip and ADDRESS_HEADER=cf-connecting-ip in Dokploy runtime variables; see docs/deployment.md#client-ip-behind-dokploy-and-cloudflare.',
|
|
31
33
|
'Existing Vite configuration is preserved. Include @better-auth/core in ssr.noExternal to retain native async request storage in Bun production builds. See docs/deployment.md#server-build-configuration.',
|
|
32
34
|
'If .dockerignore is customized, merge the template exclusions before building: environment files, credentials, data/, and local Worker state must stay outside the image.'
|
|
33
35
|
];
|
|
@@ -60,7 +62,7 @@ export async function setup(options) {
|
|
|
60
62
|
const env = join(root, '.env.local'), previous = existsSync(env) ? readFileSync(env, 'utf8') : '';
|
|
61
63
|
const previousSettings = parseEnv(previous);
|
|
62
64
|
const settings = {
|
|
63
|
-
BODY_SIZE_LIMIT: '
|
|
65
|
+
BODY_SIZE_LIMIT: '1M',
|
|
64
66
|
SANDCMS_DATABASE: options.database ?? './data/sandcms.sqlite',
|
|
65
67
|
SANDCMS_ORIGIN: 'http://localhost:5410',
|
|
66
68
|
SANDCMS_SECRET: crypto.randomUUID() + crypto.randomUUID()
|
|
@@ -68,6 +70,11 @@ export async function setup(options) {
|
|
|
68
70
|
const additions = Object.entries(settings)
|
|
69
71
|
.filter(([key]) => !previousSettings[key])
|
|
70
72
|
.map(([key, v]) => `${key}=${v}`);
|
|
73
|
+
const proxyExamples = ['SANDCMS_TRUSTED_PROXY_HEADER', 'ADDRESS_HEADER']
|
|
74
|
+
.filter((key) => !new RegExp(`^\\s*#?\\s*${key}\\s*=`, 'm').test(previous))
|
|
75
|
+
.map((key) => `# ${key}=cf-connecting-ip`);
|
|
76
|
+
if (proxyExamples.length)
|
|
77
|
+
additions.push('# Dokploy + Cloudflare: enable both settings in Dokploy runtime variables only after', '# restricting website ingress to Cloudflare and keeping the container port private.', '# See docs/deployment.md#client-ip-behind-dokploy-and-cloudflare.', ...proxyExamples);
|
|
71
78
|
appendFileSync(env, '\n' + additions.join('\n') + '\n', { mode: 0o600 });
|
|
72
79
|
chmodSync(env, 0o600);
|
|
73
80
|
if (!options.skipInstall) {
|
package/dist/cli/upgrade.js
CHANGED
|
@@ -10,10 +10,11 @@ export async function upgrade(root, check = false, database) {
|
|
|
10
10
|
if (routeConflicts(root).length)
|
|
11
11
|
throw new Error('Unowned routes conflict with /admin or /api/cms. Move them before upgrading.');
|
|
12
12
|
const notes = [
|
|
13
|
+
'SvelteKit 3 is required. Migrate developer-owned Vite configuration, package imports, and tsconfig before applying generated integrations; see docs/upgrades.md#sveltekit-3.',
|
|
13
14
|
`Installed integration: ${manifest.version}. Blueprints are valid.`,
|
|
14
15
|
'Include @better-auth/core in ssr.noExternal in your Vite configuration, then rebuild and restart the website to fix concurrent image preview failures. Developer-owned configuration is preserved. See docs/deployment.md#server-build-configuration.',
|
|
15
16
|
'From 0.5.0, database changes use incremental migrations. Back up with the installed package before updating, then run sandcms migrate. Changed pre-0.5.0 baselines still require a fresh database. See docs/upgrades.md.',
|
|
16
|
-
'Worker compatibility range: protocol 3. Deploy with sandcms worker update before upgrading website processes; expect temporary media downtime.
|
|
17
|
+
'Worker compatibility range: protocol 5 (Worker also accepts protocols 3 and 4 for existing website processes). Deploy with sandcms worker update before upgrading website processes; expect temporary media downtime. Configure Worker R2 signing credentials, bucket CORS and staging lifecycle rules for direct uploads; run the incremental database migration; metadata inspection and encoding use remote transformations; verify both in staging. Purge old /media/* caches and keep R2 public access disabled. See docs/media.md.'
|
|
17
18
|
];
|
|
18
19
|
if (database)
|
|
19
20
|
notes.push('Pending DB migrations: ' +
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Safe failure categories shared by the server and admin. Never store provider text. */
|
|
2
|
+
export declare const emailFailureMessages: {
|
|
3
|
+
readonly timeout: "SMTP operation timed out; check host, port, and outbound firewall.";
|
|
4
|
+
readonly dns: "SMTP host could not be resolved; check the hostname and DNS.";
|
|
5
|
+
readonly connection: "SMTP connection failed; check host, port, and outbound firewall.";
|
|
6
|
+
readonly authentication: "SMTP authentication failed; check the configured credentials.";
|
|
7
|
+
readonly tls: "SMTP TLS negotiation failed; check port, TLS settings, and certificate.";
|
|
8
|
+
readonly recipient_rejected: "The mail server rejected the recipient; check the recipient address and provider policy.";
|
|
9
|
+
readonly message_rejected: "The mail server rejected the message; check sender permissions and provider policy.";
|
|
10
|
+
readonly not_configured: "Email is not configured.";
|
|
11
|
+
readonly configuration: "Email configuration is invalid.";
|
|
12
|
+
readonly invalid_message: "Email recipient, subject, body, or reply-to is invalid.";
|
|
13
|
+
readonly unknown: "Email could not be sent; check the mail provider and configuration.";
|
|
14
|
+
};
|
|
15
|
+
export type EmailFailureReason = keyof typeof emailFailureMessages;
|
|
16
|
+
export declare function safeEmailFailureReason(value: unknown): EmailFailureReason;
|
|
17
|
+
export declare function emailFailureMessage(reason: unknown): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Safe failure categories shared by the server and admin. Never store provider text. */
|
|
2
|
+
export const emailFailureMessages = {
|
|
3
|
+
timeout: 'SMTP operation timed out; check host, port, and outbound firewall.',
|
|
4
|
+
dns: 'SMTP host could not be resolved; check the hostname and DNS.',
|
|
5
|
+
connection: 'SMTP connection failed; check host, port, and outbound firewall.',
|
|
6
|
+
authentication: 'SMTP authentication failed; check the configured credentials.',
|
|
7
|
+
tls: 'SMTP TLS negotiation failed; check port, TLS settings, and certificate.',
|
|
8
|
+
recipient_rejected: 'The mail server rejected the recipient; check the recipient address and provider policy.',
|
|
9
|
+
message_rejected: 'The mail server rejected the message; check sender permissions and provider policy.',
|
|
10
|
+
not_configured: 'Email is not configured.',
|
|
11
|
+
configuration: 'Email configuration is invalid.',
|
|
12
|
+
invalid_message: 'Email recipient, subject, body, or reply-to is invalid.',
|
|
13
|
+
unknown: 'Email could not be sent; check the mail provider and configuration.'
|
|
14
|
+
};
|
|
15
|
+
export function safeEmailFailureReason(value) {
|
|
16
|
+
return typeof value === 'string' && Object.hasOwn(emailFailureMessages, value)
|
|
17
|
+
? value
|
|
18
|
+
: 'unknown';
|
|
19
|
+
}
|
|
20
|
+
export function emailFailureMessage(reason) {
|
|
21
|
+
return emailFailureMessages[safeEmailFailureReason(reason)];
|
|
22
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export type { Blueprint, FileBlueprint, Field, Json, Payload, SiteConfig, SiteDefinition } from './blueprints/types.js';
|
|
1
|
+
export type { Blueprint, BlueprintTab, BlueprintColumn, BlueprintSection, FieldWidth, FileBlueprint, Field, Json, Payload, SiteConfig, SiteDefinition } from './blueprints/types.js';
|
|
2
2
|
export { renderRichText } from './richtext.js';
|
|
3
3
|
export { imageSources, type PublicMedia, type PublicMediaVariant } from './media.js';
|
|
4
4
|
export { default as Image, type ImageProps } from './Image.svelte';
|
|
5
5
|
export { default as Seo, type SeoProps } from './Seo.svelte';
|
|
6
|
+
export { linkHref, isLinkValue, type LinkValue, type LinkType, type ResolvedLink } from './link.js';
|
package/dist/index.js
CHANGED
package/dist/link.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Link destinations stay structured so entry URLs can follow published slug changes. */
|
|
2
|
+
export declare const linkTypes: readonly ["url", "entry", "file", "email", "phone"];
|
|
3
|
+
export type LinkType = (typeof linkTypes)[number];
|
|
4
|
+
export type LinkValue = {
|
|
5
|
+
type: LinkType;
|
|
6
|
+
value: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
newTab?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export interface ResolvedLink {
|
|
11
|
+
href: string;
|
|
12
|
+
label: string;
|
|
13
|
+
target?: '_blank';
|
|
14
|
+
rel?: 'noopener noreferrer';
|
|
15
|
+
}
|
|
16
|
+
export declare function linkHref(type: LinkType, value: string): string | null;
|
|
17
|
+
export declare function isLinkValue(value: unknown): value is LinkValue;
|