@velocity-astro/cms-core 0.1.0-beta.1 → 0.1.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/access.d.ts +1 -1
  2. package/dist/access.d.ts.map +1 -1
  3. package/dist/access.js +1 -1
  4. package/dist/access.js.map +1 -1
  5. package/dist/cms.d.ts +7 -2
  6. package/dist/cms.d.ts.map +1 -1
  7. package/dist/cms.js +5 -2
  8. package/dist/cms.js.map +1 -1
  9. package/dist/events.d.ts +6 -1
  10. package/dist/events.d.ts.map +1 -1
  11. package/dist/events.js.map +1 -1
  12. package/dist/fields/blocks.d.ts +5 -0
  13. package/dist/fields/blocks.d.ts.map +1 -1
  14. package/dist/fields/blocks.js +12 -0
  15. package/dist/fields/blocks.js.map +1 -1
  16. package/dist/fields/index.d.ts +42 -0
  17. package/dist/fields/index.d.ts.map +1 -1
  18. package/dist/fields/index.js +57 -0
  19. package/dist/fields/index.js.map +1 -1
  20. package/dist/index.d.ts +8 -6
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +6 -4
  23. package/dist/index.js.map +1 -1
  24. package/dist/model.d.ts +108 -1
  25. package/dist/model.d.ts.map +1 -1
  26. package/dist/model.js.map +1 -1
  27. package/dist/page-address.d.ts +2 -0
  28. package/dist/page-address.d.ts.map +1 -1
  29. package/dist/page-address.js +2 -0
  30. package/dist/page-address.js.map +1 -1
  31. package/dist/plugin.d.ts.map +1 -1
  32. package/dist/plugin.js +5 -34
  33. package/dist/plugin.js.map +1 -1
  34. package/dist/ports.d.ts +69 -1
  35. package/dist/ports.d.ts.map +1 -1
  36. package/dist/seal.d.ts +22 -0
  37. package/dist/seal.d.ts.map +1 -0
  38. package/dist/seal.js +51 -0
  39. package/dist/seal.js.map +1 -0
  40. package/dist/services/media-service.d.ts +29 -4
  41. package/dist/services/media-service.d.ts.map +1 -1
  42. package/dist/services/media-service.js +88 -14
  43. package/dist/services/media-service.js.map +1 -1
  44. package/dist/services/pipeline-service.d.ts +4 -0
  45. package/dist/services/pipeline-service.d.ts.map +1 -1
  46. package/dist/services/pipeline-service.js +13 -1
  47. package/dist/services/pipeline-service.js.map +1 -1
  48. package/dist/services/schema-service.d.ts +4 -0
  49. package/dist/services/schema-service.d.ts.map +1 -1
  50. package/dist/services/schema-service.js +10 -1
  51. package/dist/services/schema-service.js.map +1 -1
  52. package/dist/services/settings-service.d.ts +157 -0
  53. package/dist/services/settings-service.d.ts.map +1 -0
  54. package/dist/services/settings-service.js +377 -0
  55. package/dist/services/settings-service.js.map +1 -0
  56. package/dist/testing/contracts.d.ts +3 -1
  57. package/dist/testing/contracts.d.ts.map +1 -1
  58. package/dist/testing/contracts.js +22 -1
  59. package/dist/testing/contracts.js.map +1 -1
  60. package/dist/testing/in-memory.d.ts +11 -1
  61. package/dist/testing/in-memory.d.ts.map +1 -1
  62. package/dist/testing/in-memory.js +18 -0
  63. package/dist/testing/in-memory.js.map +1 -1
  64. package/dist/testing/index.d.ts +2 -2
  65. package/dist/testing/index.d.ts.map +1 -1
  66. package/dist/testing/index.js +2 -2
  67. package/dist/testing/index.js.map +1 -1
  68. package/package.json +1 -1
@@ -0,0 +1,377 @@
1
+ import { ConflictError, ValidationError } from '../errors.js';
2
+ export const EMAIL_PROVIDERS = ['resend'];
3
+ export const MAX_EMAIL_FROM_LENGTH = 200;
4
+ export const MAX_EMAIL_KEY_LENGTH = 500;
5
+ export const MAX_STORAGE_FIELD_LENGTH = 300;
6
+ export const MAX_SITE_NAME_LENGTH = 80;
7
+ /**
8
+ * What a page of the settings says the site is called: the value of the field its type names
9
+ * (`siteNamePath`), as plain words on one line. `null` when the type names none, when the field
10
+ * is empty, and when what it holds could not be a name.
11
+ */
12
+ export function siteNameFrom(type, data) {
13
+ if (type.inSettings !== true || type.siteNamePath === undefined)
14
+ return null;
15
+ let value = data;
16
+ for (const id of type.siteNamePath)
17
+ value = typeof value === 'object' && value !== null ? value[id] : undefined;
18
+ if (typeof value !== 'string' || /[\p{Cc}<>]/u.test(value.trim()))
19
+ return null;
20
+ const name = value.trim().replace(/\s+/g, ' ').slice(0, MAX_SITE_NAME_LENGTH);
21
+ return name === '' ? null : name;
22
+ }
23
+ /** What the forms take from one address in ten minutes until an owner says otherwise. */
24
+ export const DEFAULT_FORM_POSTS_PER_ADDRESS = 8;
25
+ export const MAX_FORM_POSTS_PER_ADDRESS = 100;
26
+ export const MAX_CHALLENGE_KEY_LENGTH = 200;
27
+ const FORMS = 'forms';
28
+ /** A challenge's key as the service shows it: letters, digits and a few marks, nothing that could end an attribute or a line. */
29
+ const CHALLENGE_KEY = /^[A-Za-z0-9._-]{8,200}$/;
30
+ const isStoredForms = (value) => typeof value === 'object' && value !== null && typeof value.siteKey === 'string' && Number.isInteger(value.postsPerAddress);
31
+ const GENERAL = 'general';
32
+ const isStoredGeneral = (value) => typeof value === 'object' && value !== null && typeof value.siteName === 'string';
33
+ const EMAIL = 'email';
34
+ const STORAGE = 'storage';
35
+ const BUCKET = /^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/;
36
+ const REGION = /^[a-z0-9-]{1,40}$/;
37
+ /**
38
+ * A storage service's address as it is kept: `https`, a host by name and nothing after it but a
39
+ * path. `null` for anything else. A number instead of a name, this machine and an address that
40
+ * carries a name and password are refused: what an owner types must not be a way to reach a
41
+ * machine beside the site.
42
+ */
43
+ export function storageEndpointFrom(typed) {
44
+ const text = typed.trim();
45
+ if (text.length > MAX_STORAGE_FIELD_LENGTH || !URL.canParse(text))
46
+ return null;
47
+ const url = new URL(text);
48
+ const host = url.hostname.toLowerCase();
49
+ if (url.protocol !== 'https:' || url.username !== '' || url.password !== '' || url.search !== '' || url.hash !== '' || url.port !== '')
50
+ return null;
51
+ if (!/^[a-z0-9-]+(\.[a-z0-9-]+)+$/.test(host) || /^[0-9.]+$/.test(host) || host.endsWith('.local') || host.endsWith('.internal') || host.endsWith('.localhost'))
52
+ return null;
53
+ return `https://${host}${url.pathname.replace(/\/+$/, '')}`;
54
+ }
55
+ const isStoredStorage = (value) => typeof value === 'object' && value !== null && ['endpoint', 'bucket', 'region', 'accessKeyId'].every((key) => typeof value[key] === 'string');
56
+ const ADDRESS = /^[^\s@<>"]+@[^\s@<>"]+\.[^\s@<>"]+$/;
57
+ const NAMED = /^([^<>"\r\n]{1,100})<([^<>]+)>$/;
58
+ /** A sender as it is kept: `address`, or `Name <address>`. `null` when it is neither. */
59
+ export function senderFrom(typed) {
60
+ const text = typed.trim();
61
+ if (ADDRESS.test(text))
62
+ return text;
63
+ const named = NAMED.exec(text);
64
+ const name = named?.[1]?.trim();
65
+ const address = named?.[2]?.trim();
66
+ return name && address !== undefined && ADDRESS.test(address) ? `${name} <${address}>` : null;
67
+ }
68
+ const isStoredEmail = (value) => typeof value === 'object' && value !== null && typeof value.from === 'string' && EMAIL_PROVIDERS.includes(value.provider);
69
+ /**
70
+ * Owns what an owner sets up for the site in the editor in place of a setting of the server:
71
+ * how its email is sent, to begin with. A key is sealed with the site's secret before it is
72
+ * kept and is never handed back to the editor. Where the server's own settings or the site's
73
+ * code already decide something, they win, and the editor says so.
74
+ */
75
+ export class SettingsService {
76
+ store;
77
+ seal;
78
+ access;
79
+ events;
80
+ #mail = null;
81
+ #storage = null;
82
+ #naming = null;
83
+ #challenge = null;
84
+ constructor(store, seal, access, events) {
85
+ this.store = store;
86
+ this.seal = seal;
87
+ this.access = access;
88
+ this.events = events;
89
+ }
90
+ /** Tells the service how email leaves this site. A host calls it once it knows. */
91
+ useMail(room) {
92
+ this.#mail = room;
93
+ }
94
+ /** How email is sent, for the settings screen. Owners only. */
95
+ async email(actor) {
96
+ this.access.require(actor, 'settings:manage');
97
+ return this.#shown();
98
+ }
99
+ /** Saves how email is sent. Owners only. */
100
+ async saveEmail(actor, changes) {
101
+ this.access.require(actor, 'settings:manage');
102
+ const kept = await this.store.get(EMAIL);
103
+ const current = kept !== null && isStoredEmail(kept.value) ? kept.value : null;
104
+ const revision = kept?.revision ?? 0;
105
+ if (revision !== changes.expectedRevision)
106
+ throw new ConflictError('The email settings were changed by someone else. Reload them and try again.');
107
+ const issues = [];
108
+ const provider = changes.provider ?? current?.provider ?? 'resend';
109
+ if (!EMAIL_PROVIDERS.includes(provider))
110
+ issues.push({ path: ['provider'], message: 'Choose one of the email services listed.' });
111
+ const from = changes.from.length > MAX_EMAIL_FROM_LENGTH ? null : senderFrom(changes.from);
112
+ if (from === null)
113
+ issues.push({ path: ['from'], message: 'Give an address such as hello@example.com, or a name with it: Lakeshore Realty <hello@example.com>.' });
114
+ const typedKey = typeof changes.apiKey === 'string' ? changes.apiKey.trim() : undefined;
115
+ if (typedKey !== undefined && (typedKey === '' || typedKey.length > MAX_EMAIL_KEY_LENGTH || /\s/.test(typedKey))) {
116
+ issues.push({ path: ['apiKey'], message: typedKey === '' ? 'Paste the API key.' : 'This does not look like an API key. Paste it as the email service shows it.' });
117
+ }
118
+ if (issues.length > 0 || from === null)
119
+ throw new ValidationError(issues.length === 1 ? 'One thing about the email settings needs another look.' : `${issues.length} things about the email settings need another look.`, issues);
120
+ const key = changes.apiKey === null ? undefined : typedKey !== undefined ? await this.seal.seal(typedKey) : current?.key;
121
+ const next = { provider, from, ...(key !== undefined && { key }) };
122
+ await this.store.save(EMAIL, next, revision + 1, kept === null ? null : revision);
123
+ await this.events.emit('settings.saved', { area: 'email', actor });
124
+ return this.#shown();
125
+ }
126
+ /**
127
+ * Sends a test email to whoever asks, the way email is sent now, so they know it works
128
+ * before a sign-in link depends on it. Owners only.
129
+ */
130
+ async testEmail(actor) {
131
+ this.access.require(actor, 'settings:manage');
132
+ const room = this.#mail;
133
+ if (room === null || !(await room.canTest())) {
134
+ throw new ConflictError('No test email can be sent yet. Save an API key and a sender first.');
135
+ }
136
+ await room.sendTest(actor);
137
+ }
138
+ /**
139
+ * What the editor's settings give to send email with, for the site's own server, or `null`
140
+ * when they are not complete. No permission is asked, and nothing else may call it: this is
141
+ * the one place a saved key is opened.
142
+ */
143
+ async mailAccount() {
144
+ const kept = await this.store.get(EMAIL);
145
+ if (kept === null || !isStoredEmail(kept.value) || kept.value.from === '')
146
+ return null;
147
+ const apiKey = await this.seal.open(kept.value.key);
148
+ return apiKey === undefined ? null : { provider: kept.value.provider, apiKey, from: kept.value.from };
149
+ }
150
+ /** Tells the service what the site is called without a setting. A host calls it once it knows. */
151
+ useSite(naming) {
152
+ this.#naming = naming;
153
+ }
154
+ /** The site's basics, for the settings screen. Owners only. */
155
+ async general(actor) {
156
+ this.access.require(actor, 'settings:manage');
157
+ return this.#shownGeneral();
158
+ }
159
+ /** Saves the site's basics. Owners only. */
160
+ async saveGeneral(actor, changes) {
161
+ this.access.require(actor, 'settings:manage');
162
+ const kept = await this.store.get(GENERAL);
163
+ const revision = kept?.revision ?? 0;
164
+ if (revision !== changes.expectedRevision)
165
+ throw new ConflictError('The settings were changed by someone else. Reload them and try again.');
166
+ const siteName = changes.siteName.trim().replace(/\s+/g, ' ');
167
+ // A name goes into the subject of an email and the title of a page: nothing in it may start a new line.
168
+ if (siteName.length > MAX_SITE_NAME_LENGTH || /[\p{Cc}<>]/u.test(changes.siteName.trim())) {
169
+ const message = siteName.length > MAX_SITE_NAME_LENGTH ? `Keep the site's name under ${MAX_SITE_NAME_LENGTH} characters.` : 'Give the site\'s name as plain words on one line.';
170
+ throw new ValidationError('The site\'s name needs another look.', [{ path: ['siteName'], message }]);
171
+ }
172
+ await this.store.save(GENERAL, { siteName }, revision + 1, kept === null ? null : revision);
173
+ await this.events.emit('settings.saved', { area: 'general', actor });
174
+ return this.#shownGeneral();
175
+ }
176
+ /**
177
+ * What an owner called the site, or `null` when nothing is saved and the site's own name
178
+ * stands. No permission is asked: a site's name is on its every page.
179
+ */
180
+ async siteName() {
181
+ const kept = await this.store.get(GENERAL);
182
+ return kept !== null && isStoredGeneral(kept.value) && kept.value.siteName !== '' ? kept.value.siteName : null;
183
+ }
184
+ async #shownGeneral() {
185
+ const kept = await this.store.get(GENERAL);
186
+ const fixedBy = this.#naming?.fixedBy ?? null;
187
+ return {
188
+ siteName: kept !== null && isStoredGeneral(kept.value) ? kept.value.siteName : '',
189
+ defaultSiteName: this.#naming?.defaultName ?? '',
190
+ ...(fixedBy !== null && { fixedBy }),
191
+ revision: kept?.revision ?? 0,
192
+ };
193
+ }
194
+ /** Tells the service how the challenge service is asked. A host calls it once it knows. */
195
+ useChallenge(room) {
196
+ this.#challenge = room;
197
+ }
198
+ /** How the site's forms are guarded, for the settings screen. Owners only. */
199
+ async forms(actor) {
200
+ this.access.require(actor, 'settings:manage');
201
+ return this.#shownForms();
202
+ }
203
+ /** Saves how the site's forms are guarded. Owners only. */
204
+ async saveForms(actor, changes) {
205
+ this.access.require(actor, 'settings:manage');
206
+ const kept = await this.store.get(FORMS);
207
+ const current = kept !== null && isStoredForms(kept.value) ? kept.value : null;
208
+ const revision = kept?.revision ?? 0;
209
+ if (revision !== changes.expectedRevision)
210
+ throw new ConflictError('The forms settings were changed by someone else. Reload them and try again.');
211
+ const issues = [];
212
+ const siteKey = changes.siteKey.trim();
213
+ if (siteKey !== '' && !CHALLENGE_KEY.test(siteKey))
214
+ issues.push({ path: ['siteKey'], message: 'This does not look like a site key. Paste it as Cloudflare shows it.' });
215
+ const typedSecret = typeof changes.secretKey === 'string' ? changes.secretKey.trim() : undefined;
216
+ if (typedSecret !== undefined && !CHALLENGE_KEY.test(typedSecret)) {
217
+ issues.push({ path: ['secretKey'], message: typedSecret === '' ? 'Paste the secret key.' : 'This does not look like a secret key. Paste it as Cloudflare shows it.' });
218
+ }
219
+ const secretStays = changes.secretKey === null ? false : typedSecret !== undefined || current?.secret !== undefined;
220
+ // A secret key with no site key would mark every post as spam: no page could draw the challenge.
221
+ if (siteKey === '' && secretStays)
222
+ issues.push({ path: ['siteKey'], message: 'Paste the site key too. Forms cannot show the check without it.' });
223
+ const { postsPerAddress } = changes;
224
+ if (!Number.isInteger(postsPerAddress) || postsPerAddress < 1 || postsPerAddress > MAX_FORM_POSTS_PER_ADDRESS) {
225
+ issues.push({ path: ['postsPerAddress'], message: `Give a whole number from 1 to ${MAX_FORM_POSTS_PER_ADDRESS}.` });
226
+ }
227
+ if (issues.length > 0)
228
+ throw new ValidationError(issues.length === 1 ? 'One thing about the forms settings needs another look.' : `${issues.length} things about the forms settings need another look.`, issues);
229
+ const secret = changes.secretKey === null ? undefined : typedSecret !== undefined ? await this.seal.seal(typedSecret) : current?.secret;
230
+ const next = { siteKey, postsPerAddress, ...(secret !== undefined && { secret }) };
231
+ await this.store.save(FORMS, next, revision + 1, kept === null ? null : revision);
232
+ await this.events.emit('settings.saved', { area: 'forms', actor });
233
+ return this.#shownForms();
234
+ }
235
+ /** Asks the challenge service whether it knows the secret key that is saved. Owners only. */
236
+ async testForms(actor) {
237
+ this.access.require(actor, 'settings:manage');
238
+ if (this.#challenge === null || (await this.challengeAccount()) === null) {
239
+ throw new ConflictError('There are no keys to check yet. Save the site key and the secret key first.');
240
+ }
241
+ await this.#challenge.test();
242
+ }
243
+ /**
244
+ * The challenge the editor's settings name, for the site's own server, or `null` when forms
245
+ * ask for none. No permission is asked, and nothing else may call it: this is the one place
246
+ * the saved secret key is opened.
247
+ */
248
+ async challengeAccount() {
249
+ const kept = await this.store.get(FORMS);
250
+ if (kept === null || !isStoredForms(kept.value) || kept.value.siteKey === '')
251
+ return null;
252
+ const secretKey = await this.seal.open(kept.value.secret);
253
+ return secretKey === undefined ? null : { provider: 'turnstile', siteKey: kept.value.siteKey, secretKey };
254
+ }
255
+ /**
256
+ * The site key a page shows the challenge with, or `null` when forms ask for none. No
257
+ * permission is asked: a site key is on every page that has a form.
258
+ */
259
+ async challengeSiteKey() {
260
+ return (await this.challengeAccount())?.siteKey ?? null;
261
+ }
262
+ /** How many posts the forms take from one address in ten minutes. No permission is asked. */
263
+ async formPostsPerAddress() {
264
+ const kept = await this.store.get(FORMS);
265
+ return kept !== null && isStoredForms(kept.value) ? kept.value.postsPerAddress : DEFAULT_FORM_POSTS_PER_ADDRESS;
266
+ }
267
+ async #shownForms() {
268
+ const kept = await this.store.get(FORMS);
269
+ const current = kept !== null && isStoredForms(kept.value) ? kept.value : null;
270
+ const hasSecret = current?.secret !== undefined && (await this.seal.open(current.secret)) !== undefined;
271
+ return {
272
+ provider: 'turnstile',
273
+ siteKey: current?.siteKey ?? '',
274
+ hasSecret,
275
+ checking: hasSecret && current.siteKey !== '',
276
+ postsPerAddress: current?.postsPerAddress ?? DEFAULT_FORM_POSTS_PER_ADDRESS,
277
+ revision: kept?.revision ?? 0,
278
+ };
279
+ }
280
+ /** Tells the service how uploads are kept on this site. A host calls it once it knows. */
281
+ useStorage(room) {
282
+ this.#storage = room;
283
+ }
284
+ /** Where uploads are kept, for the settings screen. Owners only. */
285
+ async storage(actor) {
286
+ this.access.require(actor, 'settings:manage');
287
+ return this.#shownStorage();
288
+ }
289
+ /** Saves the bucket uploads are kept in. Owners only. */
290
+ async saveStorage(actor, changes) {
291
+ this.access.require(actor, 'settings:manage');
292
+ const kept = await this.store.get(STORAGE);
293
+ const current = kept !== null && isStoredStorage(kept.value) ? kept.value : null;
294
+ const revision = kept?.revision ?? 0;
295
+ if (revision !== changes.expectedRevision)
296
+ throw new ConflictError('The storage settings were changed by someone else. Reload them and try again.');
297
+ const issues = [];
298
+ const endpoint = storageEndpointFrom(changes.endpoint);
299
+ if (endpoint === null)
300
+ issues.push({ path: ['endpoint'], message: 'Give the storage service\'s address, starting with https://, as the service shows it.' });
301
+ const bucket = changes.bucket.trim();
302
+ if (!BUCKET.test(bucket))
303
+ issues.push({ path: ['bucket'], message: 'Give the bucket\'s name as the storage service shows it: lowercase letters, digits, dots and hyphens.' });
304
+ const region = (changes.region ?? '').trim().toLowerCase();
305
+ if (region !== '' && !REGION.test(region))
306
+ issues.push({ path: ['region'], message: 'Give the region as the storage service writes it, such as eu-west-1, or leave this empty.' });
307
+ const accessKeyId = changes.accessKeyId.trim();
308
+ if (accessKeyId === '' || accessKeyId.length > MAX_STORAGE_FIELD_LENGTH || /\s/.test(accessKeyId))
309
+ issues.push({ path: ['accessKeyId'], message: 'Paste the access key ID.' });
310
+ const typedSecret = typeof changes.secretAccessKey === 'string' ? changes.secretAccessKey.trim() : undefined;
311
+ if (typedSecret !== undefined && (typedSecret === '' || typedSecret.length > MAX_STORAGE_FIELD_LENGTH || /\s/.test(typedSecret))) {
312
+ issues.push({ path: ['secretAccessKey'], message: typedSecret === '' ? 'Paste the secret access key.' : 'This does not look like a secret access key. Paste it as the storage service shows it.' });
313
+ }
314
+ if (issues.length > 0 || endpoint === null)
315
+ throw new ValidationError(issues.length === 1 ? 'One thing about the storage settings needs another look.' : `${issues.length} things about the storage settings need another look.`, issues);
316
+ const secret = changes.secretAccessKey === null ? undefined : typedSecret !== undefined ? await this.seal.seal(typedSecret) : current?.secret;
317
+ const next = { endpoint, bucket, region, accessKeyId, ...(secret !== undefined && { secret }) };
318
+ await this.store.save(STORAGE, next, revision + 1, kept === null ? null : revision);
319
+ await this.events.emit('settings.saved', { area: 'storage', actor });
320
+ return this.#shownStorage();
321
+ }
322
+ /** Tries the bucket the settings name: keeps a small file there, reads it back and removes it. Owners only. */
323
+ async testStorage(actor) {
324
+ this.access.require(actor, 'settings:manage');
325
+ if (this.#storage === null || (await this.bucketAccount()) === null) {
326
+ throw new ConflictError('There is no bucket to try yet. Save its address, name and both keys first.');
327
+ }
328
+ await this.#storage.test();
329
+ }
330
+ /**
331
+ * The bucket the editor's settings name, for the site's own server, or `null` when they are
332
+ * not complete. No permission is asked, and nothing else may call it: this is the one place
333
+ * the saved secret key is opened.
334
+ */
335
+ async bucketAccount() {
336
+ const kept = await this.store.get(STORAGE);
337
+ if (kept === null || !isStoredStorage(kept.value))
338
+ return null;
339
+ const { endpoint, bucket, region, accessKeyId, secret } = kept.value;
340
+ const secretAccessKey = await this.seal.open(secret);
341
+ return secretAccessKey === undefined ? null : { endpoint, bucket, accessKeyId, secretAccessKey, ...(region !== '' && { region }) };
342
+ }
343
+ async #shownStorage() {
344
+ const kept = await this.store.get(STORAGE);
345
+ const current = kept !== null && isStoredStorage(kept.value) ? kept.value : null;
346
+ const hasSecret = current?.secret !== undefined && (await this.seal.open(current.secret)) !== undefined;
347
+ const fixedBy = this.#storage?.fixedBy() ?? null;
348
+ return {
349
+ endpoint: current?.endpoint ?? '',
350
+ bucket: current?.bucket ?? '',
351
+ region: current?.region ?? '',
352
+ accessKeyId: current?.accessKeyId ?? '',
353
+ hasSecret,
354
+ ...(fixedBy !== null && { fixedBy }),
355
+ keeping: (await this.#storage?.keeping()) ?? (hasSecret ? 'bucket' : 'none'),
356
+ revision: kept?.revision ?? 0,
357
+ };
358
+ }
359
+ async #shown() {
360
+ const kept = await this.store.get(EMAIL);
361
+ const current = kept !== null && isStoredEmail(kept.value) ? kept.value : null;
362
+ // A key sealed with a secret the site no longer has is as good as none: it is asked for again.
363
+ const hasKey = current?.key !== undefined && (await this.seal.open(current.key)) !== undefined;
364
+ const fixedBy = this.#mail?.fixedBy() ?? null;
365
+ const complete = hasKey && current.from !== '';
366
+ return {
367
+ provider: current?.provider ?? 'resend',
368
+ from: current?.from ?? '',
369
+ hasKey,
370
+ ...(fixedBy !== null && { fixedBy }),
371
+ sending: fixedBy !== null || complete,
372
+ canTest: (await this.#mail?.canTest()) ?? false,
373
+ revision: kept?.revision ?? 0,
374
+ };
375
+ }
376
+ }
377
+ //# sourceMappingURL=settings-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-service.js","sourceRoot":"","sources":["../../src/services/settings-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAwB,MAAM,cAAc,CAAC;AAmBpF,MAAM,CAAC,MAAM,eAAe,GAA6B,CAAC,QAAQ,CAAC,CAAC;AACpE,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAgBxC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAC5C,MAAM,CAAC,MAA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AC;QACzC,MAAM,OAAO,GAAG,IAAI,KAAK,IAAI,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QAC/E,+FAA+F;QAC/F,MAAM,MAAM,GAAG,OAAO,EAAE,GAAG,KAAK,SAAS,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,SAAS,CAAC;QAC/F,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,IAAI,CAAC;QAC9C,MAAM,QAAQ,GAAG,MAAM,IAAI,OAAO,CAAC,IAAI,KAAK,EAAE,CAAC;QAC/C,OAAO;YACL,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,QAAQ;YACvC,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,EAAE;YACzB,MAAM;YACN,GAAG,CAAC,OAAO,KAAK,IAAI,IAAI,EAAE,OAAO,EAAE,CAAC;YACpC,OAAO,EAAE,OAAO,KAAK,IAAI,IAAI,QAAQ;YACrC,OAAO,EAAE,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,IAAI,KAAK;YAC/C,QAAQ,EAAE,IAAI,EAAE,QAAQ,IAAI,CAAC;SAC9B,CAAC;IACJ,CAAC;CACF"}
@@ -1,4 +1,4 @@
1
- import type { ContactRepository, CustomFieldsStore, DealRepository, PipelineStore, EntryRepository, FormRepository, SubmissionRepository, MediaRepository, MediaStore, PluginStore, SchemaRepository, SearchIndex } from '../ports.js';
1
+ import type { ContactRepository, CustomFieldsStore, DealRepository, PipelineStore, SettingsStore, EntryRepository, FormRepository, SubmissionRepository, MediaRepository, MediaStore, PluginStore, SchemaRepository, SearchIndex } from '../ports.js';
2
2
  export declare function entryRepositoryContract(name: string, create: () => Promise<EntryRepository>): void;
3
3
  export declare function schemaRepositoryContract(name: string, create: () => Promise<SchemaRepository>): void;
4
4
  export declare function searchIndexContract(name: string, create: () => Promise<SearchIndex>): void;
@@ -11,6 +11,8 @@ export declare function submissionRepositoryContract(name: string, create: () =>
11
11
  export declare function dealRepositoryContract(name: string, create: () => Promise<DealRepository>): void;
12
12
  /** Run this against every `PipelineStore` adapter. */
13
13
  export declare function pipelineStoreContract(name: string, create: () => Promise<PipelineStore>): void;
14
+ /** Run this against every `SettingsStore` adapter. */
15
+ export declare function settingsStoreContract(name: string, create: () => Promise<SettingsStore>): void;
14
16
  /** Run this against every `CustomFieldsStore` adapter. */
15
17
  export declare function customFieldsStoreContract(name: string, create: () => Promise<CustomFieldsStore>): void;
16
18
  /** Run this against every `ContactRepository` adapter. */
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/testing/contracts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,oBAAoB,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,gBAAgB,EAAkB,WAAW,EAAE,MAAM,aAAa,CAAC;AA6BvP,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI,CA4MlG;AAsBD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAqCpG;AAWD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CA8E1F;AAcD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI,CAuClG;AAED,wBAAgB,kBAAkB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wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAmB9F;AAED,0DAA0D;AAC1D,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAiBtG;AAED,0DAA0D;AAC1D,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAyGtG"}
@@ -690,7 +690,7 @@ export function pipelineStoreContract(name, create) {
690
690
  it('answers null until a pipeline is saved, gives it back as saved, and refuses a save from an old revision', async () => {
691
691
  const store = await create();
692
692
  expect(await store.get()).toBeNull();
693
- const first = { stages: [{ id: 'new', kind: 'open', chance: 10 }, { id: 's1', label: 'Viewing booked', kind: 'open' }, { id: 'won', kind: 'won' }], currency: 'EUR', assignTo: ['u1', 'u2'], revision: 1 };
693
+ const first = { stages: [{ id: 'new', kind: 'open', chance: 10 }, { id: 's1', label: 'Viewing booked', kind: 'open' }, { id: 'won', kind: 'won' }], currency: 'EUR', assignTo: ['u1', 'u2'], monthlyTarget: 20000, revision: 1 };
694
694
  await expect(store.save(first, 1)).rejects.toBeInstanceOf(ConflictError);
695
695
  expect(await store.save(first, null)).toEqual(first);
696
696
  expect(await store.get()).toEqual(first);
@@ -702,6 +702,27 @@ export function pipelineStoreContract(name, create) {
702
702
  });
703
703
  });
704
704
  }
705
+ /** Run this against every `SettingsStore` adapter. */
706
+ export function settingsStoreContract(name, create) {
707
+ describe(`${name}: SettingsStore contract`, () => {
708
+ it('keeps each part by its name, gives it back as saved, and refuses a save from an old revision', async () => {
709
+ const store = await create();
710
+ expect(await store.get('email')).toBeNull();
711
+ const first = { provider: 'resend', from: 'hello@example.com', key: { iv: '00', sealed: 'ff' } };
712
+ await expect(store.save('email', first, 1, 1)).rejects.toBeInstanceOf(ConflictError);
713
+ await store.save('email', first, 1, null);
714
+ expect(await store.get('email')).toEqual({ value: first, revision: 1 });
715
+ await expect(store.save('email', first, 2, null)).rejects.toBeInstanceOf(ConflictError);
716
+ await store.save('email', { provider: 'resend', from: 'team@example.com' }, 2, 1);
717
+ await expect(store.save('email', first, 3, 1)).rejects.toBeInstanceOf(ConflictError);
718
+ expect(await store.get('email')).toEqual({ value: { provider: 'resend', from: 'team@example.com' }, revision: 2 });
719
+ // One part knows nothing of another.
720
+ expect(await store.get('storage')).toBeNull();
721
+ await store.save('storage', { bucket: 'photos' }, 1, null);
722
+ expect((await store.get('email'))?.revision).toBe(2);
723
+ });
724
+ });
725
+ }
705
726
  /** Run this against every `CustomFieldsStore` adapter. */
706
727
  export function customFieldsStoreContract(name, create) {
707
728
  describe(`${name}: CustomFieldsStore contract`, () => {