@crombolo/server 0.42.1 → 0.44.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/NOTICE +9 -0
- package/package.json +13 -13
- package/src/approvals-api.ts +21 -1
- package/src/config.ts +42 -2
- package/src/core.ts +5 -1
- package/src/form-submit.ts +32 -5
- package/src/form-workflows.ts +7 -1
- package/src/index.ts +1 -0
- package/src/no-nodes.ts +151 -26
- package/src/overview.ts +133 -0
- package/src/remote-ci.ts +334 -0
- package/src/remote.ts +459 -11
- package/src/schema.ts +7 -0
- package/src/seed/compile.ts +17 -15
- package/src/seed/export.ts +16 -9
- package/src/seed/read.ts +43 -13
- package/src/server.ts +68 -4
- package/src/settings.ts +13 -4
package/src/seed/compile.ts
CHANGED
|
@@ -41,7 +41,7 @@ import { createMediaPort } from '../adapters/media.ts'
|
|
|
41
41
|
import { type CromboloConfig, VERSION } from '../config.ts'
|
|
42
42
|
import { blockKey, pickKey, SEED_NAMESPACE, seedKey, uuidV5 } from './keys.ts'
|
|
43
43
|
import { lineOf } from './lines.ts'
|
|
44
|
-
import { readSeed, type SeedFinding, type SeedItem } from './read.ts'
|
|
44
|
+
import { kindDir, readSeed, type SeedFinding, type SeedItem } from './read.ts'
|
|
45
45
|
|
|
46
46
|
export interface SeedBuild {
|
|
47
47
|
findings: SeedFinding[]
|
|
@@ -89,7 +89,7 @@ export async function compileSeed(db: Db, config: CromboloConfig): Promise<SeedB
|
|
|
89
89
|
|
|
90
90
|
const find = (item: SeedItem, path: readonly string[], code: string, message: string) =>
|
|
91
91
|
findings.push({
|
|
92
|
-
file: item.file ??
|
|
92
|
+
file: item.file ?? `${kindDir(item.kind)}/${item.path}`,
|
|
93
93
|
line: item.text ? lineOf(item.text, path) : 1,
|
|
94
94
|
code,
|
|
95
95
|
message,
|
|
@@ -354,7 +354,7 @@ export async function compileSeed(db: Db, config: CromboloConfig): Promise<SeedB
|
|
|
354
354
|
const key = await contentKey(raw, why)
|
|
355
355
|
return key
|
|
356
356
|
? { ok: true, value: `umb://document/${key.replaceAll('-', '')}` }
|
|
357
|
-
: fail(`"${raw}" is not a page in the
|
|
357
|
+
: fail(`"${raw}" is not a page in the content files or on the site`)
|
|
358
358
|
}
|
|
359
359
|
case 'Umbraco.MediaPicker3': {
|
|
360
360
|
if (isRecord(raw) || (Array.isArray(raw) && raw.some(isRecord)))
|
|
@@ -363,7 +363,7 @@ export async function compileSeed(db: Db, config: CromboloConfig): Promise<SeedB
|
|
|
363
363
|
for (const ref of list(raw)) {
|
|
364
364
|
if (typeof ref !== 'string') return fail('a media picker takes media paths')
|
|
365
365
|
const media = await mediaRef(ref, why)
|
|
366
|
-
if (!media) return fail(`"${ref}" is not media in the
|
|
366
|
+
if (!media) return fail(`"${ref}" is not media in the content files or on the site`)
|
|
367
367
|
picks.push({
|
|
368
368
|
key: pickKey(media.key),
|
|
369
369
|
mediaKey: media.key,
|
|
@@ -379,7 +379,8 @@ export async function compileSeed(db: Db, config: CromboloConfig): Promise<SeedB
|
|
|
379
379
|
for (const ref of list(raw)) {
|
|
380
380
|
if (typeof ref !== 'string') return fail('an element picker takes Library paths')
|
|
381
381
|
const key = await libraryKey(ref, why)
|
|
382
|
-
if (!key)
|
|
382
|
+
if (!key)
|
|
383
|
+
return fail(`"${ref}" is not a Library element in the content files or on the site`)
|
|
383
384
|
keys.push(key)
|
|
384
385
|
}
|
|
385
386
|
return { ok: true, value: keys }
|
|
@@ -390,7 +391,7 @@ export async function compileSeed(db: Db, config: CromboloConfig): Promise<SeedB
|
|
|
390
391
|
const link = typeof entry === 'string' ? { path: entry } : entry
|
|
391
392
|
if (!isRecord(link))
|
|
392
393
|
return fail('a link is a path, a URL, or { path | url, name, target }')
|
|
393
|
-
// A link as the editor stores it, as `
|
|
394
|
+
// A link as the editor stores it, as `bundle export --source` writes one.
|
|
394
395
|
if ('unique' in link || 'type' in link) {
|
|
395
396
|
links.push(link)
|
|
396
397
|
continue
|
|
@@ -415,7 +416,8 @@ export async function compileSeed(db: Db, config: CromboloConfig): Promise<SeedB
|
|
|
415
416
|
if (!path) return fail('a link needs a path or a url')
|
|
416
417
|
const media = mediaByPath.get(trimPath(path))
|
|
417
418
|
const key = media ? keyOf.get(media) : await contentKey(path, why)
|
|
418
|
-
if (!key)
|
|
419
|
+
if (!key)
|
|
420
|
+
return fail(`"${path}" is not a page or media in the content files or on the site`)
|
|
419
421
|
links.push({
|
|
420
422
|
unique: key,
|
|
421
423
|
type: media ? 'media' : 'document',
|
|
@@ -519,7 +521,7 @@ export async function compileSeed(db: Db, config: CromboloConfig): Promise<SeedB
|
|
|
519
521
|
item,
|
|
520
522
|
['type'],
|
|
521
523
|
'element-as-page',
|
|
522
|
-
`"${type.alias}" is an element type: put it in
|
|
524
|
+
`"${type.alias}" is an element type: put it in content/library`,
|
|
523
525
|
)
|
|
524
526
|
continue
|
|
525
527
|
}
|
|
@@ -708,8 +710,8 @@ export async function compileSeed(db: Db, config: CromboloConfig): Promise<SeedB
|
|
|
708
710
|
|
|
709
711
|
if (findings.length > 0) return { findings, blobs, counts }
|
|
710
712
|
|
|
711
|
-
//
|
|
712
|
-
// `start --
|
|
713
|
+
// Its identity is its content: changed files are a new bundle, which
|
|
714
|
+
// `start --bundle .` applies and the three-way import takes as a newer one.
|
|
713
715
|
const identity = createHash('sha256')
|
|
714
716
|
for (const item of tree.items) {
|
|
715
717
|
identity.update(`${item.kind}\0${item.path}\0${item.text}\0`)
|
|
@@ -722,9 +724,9 @@ export async function compileSeed(db: Db, config: CromboloConfig): Promise<SeedB
|
|
|
722
724
|
manifest: {
|
|
723
725
|
formatVersion: BUNDLE_FORMAT_VERSION,
|
|
724
726
|
id,
|
|
725
|
-
label: '
|
|
727
|
+
label: 'Content files',
|
|
726
728
|
createdAt: new Date(0).toISOString(),
|
|
727
|
-
createdBy: 'crombolo
|
|
729
|
+
createdBy: 'crombolo bundle apply',
|
|
728
730
|
integrity: '',
|
|
729
731
|
snapshot: 'drafts',
|
|
730
732
|
provenance: {
|
|
@@ -737,7 +739,7 @@ export async function compileSeed(db: Db, config: CromboloConfig): Promise<SeedB
|
|
|
737
739
|
selector: {
|
|
738
740
|
roots: bundleNodes.filter((n) => n.parent === null).map((n) => n.key),
|
|
739
741
|
descendants: true,
|
|
740
|
-
asGiven: ['
|
|
742
|
+
asGiven: ['content/'],
|
|
741
743
|
},
|
|
742
744
|
counts: tally,
|
|
743
745
|
dependencies: {
|
|
@@ -758,8 +760,8 @@ export async function compileSeed(db: Db, config: CromboloConfig): Promise<SeedB
|
|
|
758
760
|
name: 'crombolo-site-seed',
|
|
759
761
|
version: '0.0.0',
|
|
760
762
|
id: 'site-seed',
|
|
761
|
-
label: '
|
|
762
|
-
description: `The
|
|
763
|
+
label: 'Content files',
|
|
764
|
+
description: `The content files of ${config.siteName}, built by crombolo bundle build`,
|
|
763
765
|
private: true,
|
|
764
766
|
peerRange: `>=${VERSION}`,
|
|
765
767
|
})
|
package/src/seed/export.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Content already in a site, written out as
|
|
3
|
-
* an existing site can
|
|
4
|
-
* elements to `
|
|
2
|
+
* Content already in a site, written out as content files (stories 163, 164,
|
|
3
|
+
* 167), so an existing site can keep its content as files. Pages go to
|
|
4
|
+
* `content/pages/`, Library elements to `content/library/`, and media, files and
|
|
5
|
+
* all, to `content/media/`.
|
|
5
6
|
*
|
|
6
|
-
* Values are written in the shorthand `
|
|
7
|
+
* Values are written in the shorthand `bundle apply` reads back — rich text as
|
|
7
8
|
* `{ html }`, pickers and links as paths to what the export carries, blocks as
|
|
8
9
|
* `{ type, key, values }` — and in their editor's stored shape where there is
|
|
9
10
|
* none. A node keeps its key in its file wherever it is not the one its path
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
} from '@crombolo/data'
|
|
24
25
|
import type { MediaFileStore } from '../media-files.ts'
|
|
25
26
|
import { pickKey, seedKey } from './keys.ts'
|
|
27
|
+
import { CONTENT_FILES_DIR, KIND_DIRS, kindDir, type SeedKind } from './read.ts'
|
|
26
28
|
|
|
27
29
|
/** A URL segment from a name: `About us` → `about-us`. */
|
|
28
30
|
export const segmentOf = (name: string) =>
|
|
@@ -323,18 +325,23 @@ export async function exportSeed(
|
|
|
323
325
|
|
|
324
326
|
// --------------------------------------------------------- the files
|
|
325
327
|
const written: string[] = []
|
|
326
|
-
const seedRoot = resolve(siteDir,
|
|
328
|
+
const seedRoot = resolve(siteDir, CONTENT_FILES_DIR)
|
|
329
|
+
// `<kind>/<path>` to its file: pages under `content/pages`, and so on.
|
|
330
|
+
const placed = (relative: string) => {
|
|
331
|
+
const [kind, ...rest] = relative.split('/')
|
|
332
|
+
return `${KIND_DIRS[kind as SeedKind] ?? kind}/${rest.join('/')}`
|
|
333
|
+
}
|
|
327
334
|
const under = (relative: string) => {
|
|
328
|
-
const file = resolve(seedRoot, relative)
|
|
335
|
+
const file = resolve(seedRoot, placed(relative))
|
|
329
336
|
if (!file.startsWith(seedRoot + sep))
|
|
330
|
-
throw new Error(`Refusing to write ${relative} outside the
|
|
337
|
+
throw new Error(`Refusing to write ${relative} outside the content files.`)
|
|
331
338
|
return file
|
|
332
339
|
}
|
|
333
340
|
const write = (relative: string, text: string) => {
|
|
334
341
|
const file = under(relative)
|
|
335
342
|
mkdirSync(join(file, '..'), { recursive: true })
|
|
336
343
|
writeFileSync(file, text)
|
|
337
|
-
written.push(
|
|
344
|
+
written.push(`${CONTENT_FILES_DIR}/${placed(relative)}`)
|
|
338
345
|
}
|
|
339
346
|
const valueLines = async (
|
|
340
347
|
values: ReadonlyArray<{
|
|
@@ -386,7 +393,7 @@ export async function exportSeed(
|
|
|
386
393
|
const file = under(`media/${path}`)
|
|
387
394
|
mkdirSync(join(file, '..'), { recursive: true })
|
|
388
395
|
writeFileSync(file, await stored.bytes())
|
|
389
|
-
written.push(
|
|
396
|
+
written.push(`${kindDir('media')}/${path}`)
|
|
390
397
|
}
|
|
391
398
|
// A sidecar only for what the file cannot say.
|
|
392
399
|
if (normaliseUuid(node.key) !== derived) lines.push(`key = ${JSON.stringify(node.key)}`)
|
package/src/seed/read.ts
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Reading a site's
|
|
3
|
-
*
|
|
4
|
-
* and their folders from `
|
|
5
|
-
* its URL segment, with its children in a folder of the same
|
|
6
|
-
* may have a sidecar, `photo.jpg.toml`.
|
|
2
|
+
* Reading a site's content files (story 163) into items: pages from
|
|
3
|
+
* `content/pages/`, Library elements from `content/library/`, and media files
|
|
4
|
+
* and their folders from `content/media/` (story 167; once `seed/`). A page is a
|
|
5
|
+
* TOML file named for its URL segment, with its children in a folder of the same
|
|
6
|
+
* name; a media file may have a sidecar, `photo.jpg.toml`.
|
|
7
7
|
*/
|
|
8
8
|
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
|
|
9
9
|
import { join, relative } from 'node:path'
|
|
10
10
|
|
|
11
11
|
export type SeedKind = 'content' | 'library' | 'media'
|
|
12
12
|
|
|
13
|
+
/** The folder a site's content files are in. */
|
|
14
|
+
export const CONTENT_FILES_DIR = 'content'
|
|
15
|
+
|
|
16
|
+
/** Each kind's folder under it. A page's kind is `content`, as the keys derived from it say. */
|
|
17
|
+
export const KIND_DIRS: Readonly<Record<SeedKind, string>> = {
|
|
18
|
+
content: 'pages',
|
|
19
|
+
library: 'library',
|
|
20
|
+
media: 'media',
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** A kind's folder, relative to the site: `content/pages`. */
|
|
24
|
+
export const kindDir = (kind: SeedKind) => `${CONTENT_FILES_DIR}/${KIND_DIRS[kind]}`
|
|
25
|
+
|
|
26
|
+
/** What to run when a site still has its content files where they were before story 167. */
|
|
27
|
+
export const MOVE_FROM_SEED = 'git mv seed content && git mv content/content content/pages'
|
|
28
|
+
|
|
13
29
|
export interface SeedItem {
|
|
14
30
|
kind: SeedKind
|
|
15
31
|
/** Its path in the tree, by segment: `about/team`, `logos/mark.png`. */
|
|
@@ -22,7 +38,7 @@ export interface SeedItem {
|
|
|
22
38
|
data: Record<string, unknown>
|
|
23
39
|
/** A media file's bytes. */
|
|
24
40
|
bytes?: Uint8Array
|
|
25
|
-
/** A media folder: a directory under `
|
|
41
|
+
/** A media folder: a directory under `content/media/`. */
|
|
26
42
|
folder?: boolean
|
|
27
43
|
}
|
|
28
44
|
|
|
@@ -57,10 +73,23 @@ function syntaxLine(text: string): number {
|
|
|
57
73
|
}
|
|
58
74
|
|
|
59
75
|
export function readSeed(siteDir: string): SeedTree {
|
|
60
|
-
const root = join(siteDir,
|
|
76
|
+
const root = join(siteDir, CONTENT_FILES_DIR)
|
|
61
77
|
const items: SeedItem[] = []
|
|
62
78
|
const findings: SeedFinding[] = []
|
|
63
79
|
const shown = (path: string) => relative(siteDir, path)
|
|
80
|
+
// Content files where they were before story 167 are not read, and say where to go.
|
|
81
|
+
if (existsSync(join(siteDir, 'seed')) && !existsSync(root))
|
|
82
|
+
return {
|
|
83
|
+
items,
|
|
84
|
+
findings: [
|
|
85
|
+
{
|
|
86
|
+
file: 'seed',
|
|
87
|
+
line: 1,
|
|
88
|
+
code: 'moved',
|
|
89
|
+
message: `content files now live in content/pages, content/library and content/media: ${MOVE_FROM_SEED}`,
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
}
|
|
64
93
|
|
|
65
94
|
const parse = (path: string): { text: string; data: Record<string, unknown> } | undefined => {
|
|
66
95
|
const text = readFileSync(path, 'utf8')
|
|
@@ -91,7 +120,7 @@ export function readSeed(siteDir: string): SeedTree {
|
|
|
91
120
|
file: shown(path),
|
|
92
121
|
line: 1,
|
|
93
122
|
code: 'library-folder',
|
|
94
|
-
message: 'Library elements sit at the top of
|
|
123
|
+
message: 'Library elements sit at the top of content/library: folders are not read yet',
|
|
95
124
|
})
|
|
96
125
|
continue
|
|
97
126
|
}
|
|
@@ -165,11 +194,12 @@ export function readSeed(siteDir: string): SeedTree {
|
|
|
165
194
|
}
|
|
166
195
|
}
|
|
167
196
|
|
|
168
|
-
content('content', join(root,
|
|
169
|
-
content('library', join(root,
|
|
170
|
-
media(join(root,
|
|
197
|
+
content('content', join(root, KIND_DIRS.content), null)
|
|
198
|
+
content('library', join(root, KIND_DIRS.library), null)
|
|
199
|
+
media(join(root, KIND_DIRS.media), null)
|
|
171
200
|
return { items, findings }
|
|
172
201
|
}
|
|
173
202
|
|
|
174
|
-
/** Whether a site has
|
|
175
|
-
export const hasSeed = (siteDir: string) =>
|
|
203
|
+
/** Whether a site has content files at all, where they are or where they were. */
|
|
204
|
+
export const hasSeed = (siteDir: string) =>
|
|
205
|
+
existsSync(join(siteDir, CONTENT_FILES_DIR)) || existsSync(join(siteDir, 'seed'))
|
package/src/server.ts
CHANGED
|
@@ -66,7 +66,10 @@ import {
|
|
|
66
66
|
DEFAULT_UPLOAD_SETTINGS,
|
|
67
67
|
DELIVERY_API_PREFIX,
|
|
68
68
|
FormPermissions,
|
|
69
|
+
formTokenSubject,
|
|
69
70
|
hasAccessToSensitiveData,
|
|
71
|
+
libraryFormId,
|
|
72
|
+
libraryFormTypeKey,
|
|
70
73
|
localReturnUrl,
|
|
71
74
|
MANAGEMENT_API_PREFIX,
|
|
72
75
|
managementApiPrefix,
|
|
@@ -77,12 +80,14 @@ import {
|
|
|
77
80
|
import {
|
|
78
81
|
appendCacheInstruction,
|
|
79
82
|
type Db,
|
|
83
|
+
ensureFormLibraryTypes,
|
|
80
84
|
ensureKeyValue,
|
|
81
85
|
FormEntryRepository,
|
|
82
86
|
FormWorkflowRepository,
|
|
83
87
|
JobRepository,
|
|
84
88
|
type JobState,
|
|
85
89
|
latestContentVersionId,
|
|
90
|
+
listLibraryForms,
|
|
86
91
|
MediaAccessRepository,
|
|
87
92
|
MemberRepository,
|
|
88
93
|
PublicAccessRepository,
|
|
@@ -193,6 +198,7 @@ import { createMediaAccess } from './media-access.ts'
|
|
|
193
198
|
import { createMemberAuth, MEMBER_ROUTE_PREFIX } from './member-auth.ts'
|
|
194
199
|
import { noNodesPage } from './no-nodes.ts'
|
|
195
200
|
import { NotImplementedLog } from './not-implemented.ts'
|
|
201
|
+
import { overview, readOverviewQuery } from './overview.ts'
|
|
196
202
|
import { createDeps, PREVIEW_COOKIE, resolveUserLinkSender } from './ports.ts'
|
|
197
203
|
import {
|
|
198
204
|
previewSigningSecret,
|
|
@@ -865,7 +871,11 @@ export async function createServer(config: CromboloConfig = loadConfig()): Promi
|
|
|
865
871
|
apiForm(tools.resolve(form), {
|
|
866
872
|
types: formTypes.types,
|
|
867
873
|
action: `${origin}${formAction(form)}`,
|
|
868
|
-
token: signFormToken(
|
|
874
|
+
token: signFormToken(
|
|
875
|
+
formSecret,
|
|
876
|
+
formTokenSubject(form.key ?? form.alias, form.library?.key),
|
|
877
|
+
now,
|
|
878
|
+
),
|
|
869
879
|
renderedAt: now,
|
|
870
880
|
redirectUrl: form.redirectTo ? tools.urlOf(form.redirectTo) : undefined,
|
|
871
881
|
})
|
|
@@ -1690,7 +1700,7 @@ export async function createServer(config: CromboloConfig = loadConfig()): Promi
|
|
|
1690
1700
|
if (pathname.startsWith(`${paths.pluginPath}/api/bundles/`)) {
|
|
1691
1701
|
const principal = await authenticate(request)
|
|
1692
1702
|
if (!principal) return new Response('Unauthorized', { status: 401 })
|
|
1693
|
-
if (!hasSection(principal, '
|
|
1703
|
+
if (!hasSection(principal, 'settings')) return new Response('Forbidden', { status: 403 })
|
|
1694
1704
|
const action = pathname.slice(`${paths.pluginPath}/api/bundles/`.length)
|
|
1695
1705
|
|
|
1696
1706
|
if (action === 'marketplace' && request.method === 'GET') {
|
|
@@ -1945,6 +1955,17 @@ export async function createServer(config: CromboloConfig = loadConfig()): Promi
|
|
|
1945
1955
|
return Response.json(webhookStoreView(webhook.store, webhooks.stores()))
|
|
1946
1956
|
}
|
|
1947
1957
|
|
|
1958
|
+
// CI access (story 160): the trust rules, for the Settings screen, as the remote serves them.
|
|
1959
|
+
if (
|
|
1960
|
+
pathname === `${paths.pluginPath}/api/remote-trust` ||
|
|
1961
|
+
pathname.startsWith(`${paths.pluginPath}/api/remote-trust/`)
|
|
1962
|
+
) {
|
|
1963
|
+
const principal = await authenticate(request)
|
|
1964
|
+
if (!principal) return new Response('Unauthorized', { status: 401 })
|
|
1965
|
+
const rest = pathname.slice(`${paths.pluginPath}/api/remote-`.length)
|
|
1966
|
+
return remote.trust(request, principal, rest)
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1948
1969
|
if (pathname.startsWith(`${paths.pluginPath}/api/forms`)) {
|
|
1949
1970
|
const principal = await authenticate(request)
|
|
1950
1971
|
if (!principal) return new Response('Unauthorized', { status: 401 })
|
|
@@ -1962,6 +1983,25 @@ export async function createServer(config: CromboloConfig = loadConfig()): Promi
|
|
|
1962
1983
|
// Hyphenated, so no form alias (letters and digits) can be mistaken for it.
|
|
1963
1984
|
if (action === 'available-types' && request.method === 'GET')
|
|
1964
1985
|
return Response.json(describeFormTypes(formTypes.types))
|
|
1986
|
+
// The Library forms (story 239), for a page's form picker and the entries filter.
|
|
1987
|
+
if (action === 'library-forms' && request.method === 'GET') {
|
|
1988
|
+
const known = new Map(definitions.map((form) => [form.key ?? form.alias, form]))
|
|
1989
|
+
return Response.json({
|
|
1990
|
+
items: (await listLibraryForms(db)).map((item) => ({
|
|
1991
|
+
...item,
|
|
1992
|
+
formAlias: known.get(item.formKey)?.alias ?? null,
|
|
1993
|
+
formName: known.get(item.formKey)?.name ?? null,
|
|
1994
|
+
})),
|
|
1995
|
+
})
|
|
1996
|
+
}
|
|
1997
|
+
// Which content types are made from a form, for the note in their editor.
|
|
1998
|
+
if (action === 'library-types' && request.method === 'GET')
|
|
1999
|
+
return Response.json({
|
|
2000
|
+
items: definitions.map((form) => ({
|
|
2001
|
+
typeKey: libraryFormTypeKey(libraryFormId(form)),
|
|
2002
|
+
formName: form.name,
|
|
2003
|
+
})),
|
|
2004
|
+
})
|
|
1965
2005
|
// The designer's "E-mail design" picker.
|
|
1966
2006
|
if (action === 'email-templates' && request.method === 'GET')
|
|
1967
2007
|
return Response.json({
|
|
@@ -2015,6 +2055,10 @@ export async function createServer(config: CromboloConfig = loadConfig()): Promi
|
|
|
2015
2055
|
if (next === 'approved') {
|
|
2016
2056
|
const form = byKey.get(updated.formKey)
|
|
2017
2057
|
const onApprove = form?.workflows.filter((workflow) => workflow.on === 'approve') ?? []
|
|
2058
|
+
// Through a Library form: its recipients as they are now (story 239).
|
|
2059
|
+
const recipients = updated.libraryKey
|
|
2060
|
+
? (await cache.libraryForm(updated.libraryKey))?.library?.recipients
|
|
2061
|
+
: undefined
|
|
2018
2062
|
if (onApprove.length > 0)
|
|
2019
2063
|
await new FormWorkflowRepository(db).enqueue(
|
|
2020
2064
|
onApprove.map((workflow) => ({
|
|
@@ -2028,6 +2072,7 @@ export async function createServer(config: CromboloConfig = loadConfig()): Promi
|
|
|
2028
2072
|
fieldAlias: value.fieldAlias,
|
|
2029
2073
|
values: value.values,
|
|
2030
2074
|
})),
|
|
2075
|
+
...(recipients ? { recipients } : {}),
|
|
2031
2076
|
})),
|
|
2032
2077
|
)
|
|
2033
2078
|
}
|
|
@@ -2085,8 +2130,11 @@ export async function createServer(config: CromboloConfig = loadConfig()): Promi
|
|
|
2085
2130
|
const key = decodeURIComponent(listMatch[1] as string)
|
|
2086
2131
|
const since = url.searchParams.get('from')
|
|
2087
2132
|
const until = url.searchParams.get('to')
|
|
2133
|
+
// `library=none` for the entries that came through no Library form.
|
|
2134
|
+
const library = url.searchParams.get('library')
|
|
2088
2135
|
const page = await entries.list({
|
|
2089
2136
|
formKey: key,
|
|
2137
|
+
...(library ? { libraryKey: library === 'none' ? null : library } : {}),
|
|
2090
2138
|
state: parseEntryState(url.searchParams.get('state')),
|
|
2091
2139
|
from: since ? new Date(since) : undefined,
|
|
2092
2140
|
to: until ? new Date(until) : undefined,
|
|
@@ -2150,6 +2198,8 @@ export async function createServer(config: CromboloConfig = loadConfig()): Promi
|
|
|
2150
2198
|
// The memo would otherwise hold the old definition for a second, which
|
|
2151
2199
|
// is exactly long enough for the designer to reload and see it.
|
|
2152
2200
|
forms.invalidate()
|
|
2201
|
+
await ensureFormLibraryTypes(db, forms.all())
|
|
2202
|
+
cache.invalidate()
|
|
2153
2203
|
log.info('{user} saved the form {form}', {
|
|
2154
2204
|
user: principal.email,
|
|
2155
2205
|
form: coerceForm(body).alias,
|
|
@@ -2168,6 +2218,8 @@ export async function createServer(config: CromboloConfig = loadConfig()): Promi
|
|
|
2168
2218
|
{ status: removed.status === 'readOnly' ? 409 : 404 },
|
|
2169
2219
|
)
|
|
2170
2220
|
forms.invalidate()
|
|
2221
|
+
await ensureFormLibraryTypes(db, forms.all())
|
|
2222
|
+
cache.invalidate()
|
|
2171
2223
|
log.info('{user} deleted the form {form}; its entries are kept', {
|
|
2172
2224
|
user: principal.email,
|
|
2173
2225
|
form: form.alias,
|
|
@@ -2296,6 +2348,16 @@ export async function createServer(config: CromboloConfig = loadConfig()): Promi
|
|
|
2296
2348
|
: Response.json({ ok: false, message: outcome.message }, { status: outcome.status })
|
|
2297
2349
|
}
|
|
2298
2350
|
|
|
2351
|
+
// Non-contract: the Content section's Overview (story 236), as the user may see it.
|
|
2352
|
+
if (pathname === `${paths.pluginPath}/api/overview` && request.method === 'GET') {
|
|
2353
|
+
const principal = await authenticate(request)
|
|
2354
|
+
if (!principal) return new Response('Unauthorized', { status: 401 })
|
|
2355
|
+
if (!hasSection(principal, 'content')) return new Response('Forbidden', { status: 403 })
|
|
2356
|
+
return Response.json(await overview(db, principal, readOverviewQuery(url)), {
|
|
2357
|
+
headers: { 'cache-control': 'no-store' },
|
|
2358
|
+
})
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2299
2361
|
// Non-contract: approval workflows (story 028) — the page's Workflow tab, the
|
|
2300
2362
|
// Workflows section and its designer. Content or Workflows, as either screen is.
|
|
2301
2363
|
if (pathname.startsWith(`${paths.pluginPath}/api/approvals/`)) {
|
|
@@ -2338,7 +2400,7 @@ export async function createServer(config: CromboloConfig = loadConfig()): Promi
|
|
|
2338
2400
|
if (pathname.startsWith(`${paths.pluginPath}/api/transfers/`)) {
|
|
2339
2401
|
const principal = await authenticate(request)
|
|
2340
2402
|
if (!principal) return new Response('Unauthorized', { status: 401 })
|
|
2341
|
-
if (!hasSection(principal, '
|
|
2403
|
+
if (!hasSection(principal, 'settings')) return new Response('Forbidden', { status: 403 })
|
|
2342
2404
|
const action = pathname.slice(`${paths.pluginPath}/api/transfers/`.length)
|
|
2343
2405
|
const response = await handleTransferAction(request, action, {
|
|
2344
2406
|
db,
|
|
@@ -2383,7 +2445,7 @@ export async function createServer(config: CromboloConfig = loadConfig()): Promi
|
|
|
2383
2445
|
const bundles = await tablesReport(db, chains)
|
|
2384
2446
|
const upgrades = summariseUpgrades(await readLedger(db), VERSION)
|
|
2385
2447
|
// The answers a finding can be given, offered only to those who may import.
|
|
2386
|
-
const mayImport = hasSection(principal, '
|
|
2448
|
+
const mayImport = hasSection(principal, 'settings')
|
|
2387
2449
|
const offered = findings.map((f) =>
|
|
2388
2450
|
f.source === 'transfer' && f.status === 'open' && mayImport
|
|
2389
2451
|
? { ...f, choices: choicesFor(f) }
|
|
@@ -2747,6 +2809,8 @@ export async function createServer(config: CromboloConfig = loadConfig()): Promi
|
|
|
2747
2809
|
mediaFiles,
|
|
2748
2810
|
uploads: DEFAULT_UPLOAD_SETTINGS,
|
|
2749
2811
|
urlOf: async (contentKey) => (await cache.byKey(contentKey))?.url,
|
|
2812
|
+
// A Library form's type is invariant, so any culture's view has its words.
|
|
2813
|
+
libraryForm: (libraryKey) => cache.libraryForm(libraryKey),
|
|
2750
2814
|
// The page it was sent from names the culture; the keys a source offers
|
|
2751
2815
|
// are the same in every culture, so only the stored labels depend on it.
|
|
2752
2816
|
resolveForm: async (form) => {
|
package/src/settings.ts
CHANGED
|
@@ -836,11 +836,12 @@ const DECLARED = [
|
|
|
836
836
|
|
|
837
837
|
// Remote
|
|
838
838
|
{
|
|
839
|
-
env: '
|
|
840
|
-
kind: '
|
|
841
|
-
default: '
|
|
839
|
+
env: 'CROMBOLO_REMOTE_ACCESS',
|
|
840
|
+
kind: 'string',
|
|
841
|
+
default: 'off',
|
|
842
842
|
section: 'Remote',
|
|
843
|
-
description:
|
|
843
|
+
description:
|
|
844
|
+
'What `crombolo` may do to this site from elsewhere: `off`, `read` (pull), `content` (apply bundles of content) or `all` (whole-site pushes, and bundles that change content types, views or code). Who may do it is still up to their permissions.',
|
|
844
845
|
},
|
|
845
846
|
{
|
|
846
847
|
env: 'CROMBOLO_REMOTE_ENVIRONMENT',
|
|
@@ -873,6 +874,14 @@ const DECLARED = [
|
|
|
873
874
|
description:
|
|
874
875
|
'The largest push or media file a client may upload, in gigabytes. Every other request keeps the usual body limit.',
|
|
875
876
|
},
|
|
877
|
+
{
|
|
878
|
+
env: 'CROMBOLO_REMOTE_OIDC_ISSUERS',
|
|
879
|
+
kind: 'string',
|
|
880
|
+
default: '',
|
|
881
|
+
section: 'Remote',
|
|
882
|
+
description:
|
|
883
|
+
"A self-managed GitLab's address, or several separated by commas, whose CI jobs may sign in beside GitHub Actions and gitlab.com. Each job still needs a trust rule in Settings.",
|
|
884
|
+
},
|
|
876
885
|
|
|
877
886
|
// Logging
|
|
878
887
|
{
|