inlaycms 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +469 -2
- package/assets/admin/admin.css +2 -0
- package/assets/admin/admin.js +1 -0
- package/assets/admin/editor.js +125 -0
- package/dist/adapters/admin/activity.d.ts +17 -0
- package/dist/adapters/admin/activity.js +59 -0
- package/dist/adapters/admin/assets.d.ts +14 -0
- package/dist/adapters/admin/assets.js +64 -0
- package/dist/adapters/admin/attention.d.ts +15 -0
- package/dist/adapters/admin/attention.js +34 -0
- package/dist/adapters/admin/context.d.ts +40 -0
- package/dist/adapters/admin/context.js +142 -0
- package/dist/adapters/admin/form/walk.d.ts +61 -0
- package/dist/adapters/admin/form/walk.js +565 -0
- package/dist/adapters/admin/pages.d.ts +38 -0
- package/dist/adapters/admin/pages.js +66 -0
- package/dist/adapters/admin/publish.d.ts +12 -0
- package/dist/adapters/admin/publish.js +195 -0
- package/dist/adapters/admin/routes.d.ts +47 -0
- package/dist/adapters/admin/routes.js +255 -0
- package/dist/adapters/admin/screens/backups.d.ts +11 -0
- package/dist/adapters/admin/screens/backups.js +223 -0
- package/dist/adapters/admin/screens/dashboard.d.ts +4 -0
- package/dist/adapters/admin/screens/dashboard.js +160 -0
- package/dist/adapters/admin/screens/editor.d.ts +67 -0
- package/dist/adapters/admin/screens/editor.js +416 -0
- package/dist/adapters/admin/screens/history.d.ts +4 -0
- package/dist/adapters/admin/screens/history.js +105 -0
- package/dist/adapters/admin/screens/lists.d.ts +4 -0
- package/dist/adapters/admin/screens/lists.js +297 -0
- package/dist/adapters/admin/screens/media.d.ts +20 -0
- package/dist/adapters/admin/screens/media.js +186 -0
- package/dist/adapters/admin/screens/pickers.d.ts +29 -0
- package/dist/adapters/admin/screens/pickers.js +134 -0
- package/dist/adapters/admin/screens/preview-pane.d.ts +10 -0
- package/dist/adapters/admin/screens/preview-pane.js +74 -0
- package/dist/adapters/admin/screens/redirects.d.ts +4 -0
- package/dist/adapters/admin/screens/redirects.js +137 -0
- package/dist/adapters/admin/screens/releases.d.ts +7 -0
- package/dist/adapters/admin/screens/releases.js +287 -0
- package/dist/adapters/admin/screens/search.d.ts +22 -0
- package/dist/adapters/admin/screens/search.js +113 -0
- package/dist/adapters/admin/screens/security.d.ts +4 -0
- package/dist/adapters/admin/screens/security.js +85 -0
- package/dist/adapters/admin/screens/users.d.ts +4 -0
- package/dist/adapters/admin/screens/users.js +330 -0
- package/dist/adapters/admin/theme.d.ts +1 -0
- package/dist/adapters/admin/theme.js +1 -0
- package/dist/adapters/admin/translations.d.ts +16 -0
- package/dist/adapters/admin/translations.js +23 -0
- package/dist/adapters/admin/upload.d.ts +8 -0
- package/dist/adapters/admin/upload.js +116 -0
- package/dist/adapters/admin/views/data-table.d.ts +82 -0
- package/dist/adapters/admin/views/data-table.js +117 -0
- package/dist/adapters/admin/views/icons.d.ts +48 -0
- package/dist/adapters/admin/views/icons.js +47 -0
- package/dist/adapters/admin/views/layout.d.ts +51 -0
- package/dist/adapters/admin/views/layout.js +145 -0
- package/dist/adapters/admin/views/sheet.d.ts +15 -0
- package/dist/adapters/admin/views/sheet.js +6 -0
- package/dist/adapters/admin/views/status.d.ts +32 -0
- package/dist/adapters/admin/views/status.js +74 -0
- package/dist/adapters/auth/handler.d.ts +10 -0
- package/dist/adapters/auth/handler.js +63 -0
- package/dist/adapters/auth/request.d.ts +8 -0
- package/dist/adapters/auth/request.js +14 -0
- package/dist/adapters/cli/bin.d.ts +2 -0
- package/dist/adapters/cli/bin.js +42 -0
- package/dist/adapters/cli/main.d.ts +7 -0
- package/dist/adapters/cli/main.js +982 -0
- package/dist/adapters/cli/remote.d.ts +52 -0
- package/dist/adapters/cli/remote.js +161 -0
- package/dist/adapters/mcp/agent-refs.d.ts +9 -0
- package/dist/adapters/mcp/agent-refs.js +25 -0
- package/dist/adapters/mcp/documents.d.ts +15 -0
- package/dist/adapters/mcp/documents.js +26 -0
- package/dist/adapters/mcp/fetch-url.d.ts +19 -0
- package/dist/adapters/mcp/fetch-url.js +244 -0
- package/dist/adapters/mcp/request-state.d.ts +15 -0
- package/dist/adapters/mcp/request-state.js +38 -0
- package/dist/adapters/mcp/results.d.ts +20 -0
- package/dist/adapters/mcp/results.js +61 -0
- package/dist/adapters/mcp/route.d.ts +34 -0
- package/dist/adapters/mcp/route.js +52 -0
- package/dist/adapters/mcp/server.d.ts +44 -0
- package/dist/adapters/mcp/server.js +49 -0
- package/dist/adapters/mcp/tools/history.d.ts +5 -0
- package/dist/adapters/mcp/tools/history.js +84 -0
- package/dist/adapters/mcp/tools/media.d.ts +5 -0
- package/dist/adapters/mcp/tools/media.js +102 -0
- package/dist/adapters/mcp/tools/publish.d.ts +5 -0
- package/dist/adapters/mcp/tools/publish.js +157 -0
- package/dist/adapters/mcp/tools/read.d.ts +5 -0
- package/dist/adapters/mcp/tools/read.js +279 -0
- package/dist/adapters/mcp/tools/redirects.d.ts +5 -0
- package/dist/adapters/mcp/tools/redirects.js +74 -0
- package/dist/adapters/mcp/tools/write.d.ts +5 -0
- package/dist/adapters/mcp/tools/write.js +304 -0
- package/dist/adapters/site/backup-schedule.d.ts +8 -0
- package/dist/adapters/site/backup-schedule.js +31 -0
- package/dist/adapters/site/cache.d.ts +29 -0
- package/dist/adapters/site/cache.js +63 -0
- package/dist/adapters/site/context.d.ts +29 -0
- package/dist/adapters/site/context.js +278 -0
- package/dist/adapters/site/head.d.ts +23 -0
- package/dist/adapters/site/head.js +44 -0
- package/dist/adapters/site/limiter.d.ts +17 -0
- package/dist/adapters/site/limiter.js +39 -0
- package/dist/adapters/site/lock.d.ts +30 -0
- package/dist/adapters/site/lock.js +143 -0
- package/dist/adapters/site/media-routes.d.ts +4 -0
- package/dist/adapters/site/media-routes.js +55 -0
- package/dist/adapters/site/plugin.d.ts +122 -0
- package/dist/adapters/site/plugin.js +436 -0
- package/dist/adapters/site/preview.d.ts +36 -0
- package/dist/adapters/site/preview.js +82 -0
- package/dist/adapters/site/public.d.ts +6 -0
- package/dist/adapters/site/public.js +87 -0
- package/dist/adapters/site/render.d.ts +45 -0
- package/dist/adapters/site/render.js +191 -0
- package/dist/adapters/site/routes.d.ts +17 -0
- package/dist/adapters/site/routes.js +125 -0
- package/dist/adapters/site/sitemap.d.ts +10 -0
- package/dist/adapters/site/sitemap.js +10 -0
- package/dist/adapters/web.d.ts +22 -0
- package/dist/adapters/web.js +75 -0
- package/dist/config.d.ts +21 -0
- package/dist/config.js +58 -0
- package/dist/core/agent/format.d.ts +62 -0
- package/dist/core/agent/format.js +211 -0
- package/dist/core/agent/schema.d.ts +6 -0
- package/dist/core/agent/schema.js +86 -0
- package/dist/core/archive.d.ts +12 -0
- package/dist/core/archive.js +72 -0
- package/dist/core/auth/auth.d.ts +4911 -0
- package/dist/core/auth/auth.js +61 -0
- package/dist/core/auth/roles.d.ts +10 -0
- package/dist/core/auth/roles.js +38 -0
- package/dist/core/auth/service.d.ts +118 -0
- package/dist/core/auth/service.js +424 -0
- package/dist/core/auth/upload-token.d.ts +8 -0
- package/dist/core/auth/upload-token.js +27 -0
- package/dist/core/backup/backup.d.ts +28 -0
- package/dist/core/backup/backup.js +126 -0
- package/dist/core/backup/restore.d.ts +41 -0
- package/dist/core/backup/restore.js +264 -0
- package/dist/core/backup/schedule.d.ts +12 -0
- package/dist/core/backup/schedule.js +29 -0
- package/dist/core/boot.d.ts +63 -0
- package/dist/core/boot.js +141 -0
- package/dist/core/check.d.ts +32 -0
- package/dist/core/check.js +111 -0
- package/dist/core/content/activity.d.ts +8 -0
- package/dist/core/content/activity.js +101 -0
- package/dist/core/content/delete.d.ts +5 -0
- package/dist/core/content/delete.js +100 -0
- package/dist/core/content/diff.d.ts +6 -0
- package/dist/core/content/diff.js +129 -0
- package/dist/core/content/dry-run.d.ts +24 -0
- package/dist/core/content/dry-run.js +69 -0
- package/dist/core/content/gaps.d.ts +25 -0
- package/dist/core/content/gaps.js +50 -0
- package/dist/core/content/hidden.d.ts +33 -0
- package/dist/core/content/hidden.js +103 -0
- package/dist/core/content/history.d.ts +15 -0
- package/dist/core/content/history.js +62 -0
- package/dist/core/content/patch.d.ts +40 -0
- package/dist/core/content/patch.js +287 -0
- package/dist/core/content/path.d.ts +6 -0
- package/dist/core/content/path.js +38 -0
- package/dist/core/content/publish.d.ts +26 -0
- package/dist/core/content/publish.js +211 -0
- package/dist/core/content/read.d.ts +99 -0
- package/dist/core/content/read.js +141 -0
- package/dist/core/content/reader.d.ts +37 -0
- package/dist/core/content/reader.js +195 -0
- package/dist/core/content/refs.d.ts +44 -0
- package/dist/core/content/refs.js +161 -0
- package/dist/core/content/release-migrations.d.ts +12 -0
- package/dist/core/content/release-migrations.js +154 -0
- package/dist/core/content/save.d.ts +25 -0
- package/dist/core/content/save.js +87 -0
- package/dist/core/content/schema.d.ts +22 -0
- package/dist/core/content/schema.js +127 -0
- package/dist/core/content/search.d.ts +8 -0
- package/dist/core/content/search.js +89 -0
- package/dist/core/content/shipped-input.d.ts +39 -0
- package/dist/core/content/shipped-input.js +221 -0
- package/dist/core/content/shipped.d.ts +112 -0
- package/dist/core/content/shipped.js +437 -0
- package/dist/core/content/slug.d.ts +23 -0
- package/dist/core/content/slug.js +182 -0
- package/dist/core/content/stats.d.ts +11 -0
- package/dist/core/content/stats.js +30 -0
- package/dist/core/content/translate.d.ts +3 -0
- package/dist/core/content/translate.js +68 -0
- package/dist/core/content/usages.d.ts +13 -0
- package/dist/core/content/usages.js +70 -0
- package/dist/core/content/validate.d.ts +21 -0
- package/dist/core/content/validate.js +124 -0
- package/dist/core/content/write.d.ts +10 -0
- package/dist/core/content/write.js +93 -0
- package/dist/core/core.d.ts +227 -0
- package/dist/core/core.js +251 -0
- package/dist/core/db/connection.d.ts +6 -0
- package/dist/core/db/connection.js +12 -0
- package/dist/core/db/migrate.d.ts +9 -0
- package/dist/core/db/migrate.js +42 -0
- package/dist/core/db/migrations/0001_content.d.ts +2 -0
- package/dist/core/db/migrations/0001_content.js +69 -0
- package/dist/core/db/migrations/0002_media.d.ts +2 -0
- package/dist/core/db/migrations/0002_media.js +26 -0
- package/dist/core/db/migrations/0003_redirects.d.ts +2 -0
- package/dist/core/db/migrations/0003_redirects.js +19 -0
- package/dist/core/db/migrations/0004_token_cutoffs.d.ts +3 -0
- package/dist/core/db/migrations/0004_token_cutoffs.js +8 -0
- package/dist/core/db/migrations/0005_site_lock.d.ts +3 -0
- package/dist/core/db/migrations/0005_site_lock.js +10 -0
- package/dist/core/db/migrations/0006_releases.d.ts +3 -0
- package/dist/core/db/migrations/0006_releases.js +34 -0
- package/dist/core/db/schema.d.ts +155 -0
- package/dist/core/db/schema.js +1 -0
- package/dist/core/errors.d.ts +27 -0
- package/dist/core/errors.js +15 -0
- package/dist/core/export/export.d.ts +17 -0
- package/dist/core/export/export.js +185 -0
- package/dist/core/export/format.d.ts +241 -0
- package/dist/core/export/format.js +106 -0
- package/dist/core/export/import.d.ts +54 -0
- package/dist/core/export/import.js +180 -0
- package/dist/core/export/read.d.ts +16 -0
- package/dist/core/export/read.js +234 -0
- package/dist/core/export/replace.d.ts +17 -0
- package/dist/core/export/replace.js +36 -0
- package/dist/core/export/report.d.ts +55 -0
- package/dist/core/export/report.js +50 -0
- package/dist/core/export/schema.d.ts +8 -0
- package/dist/core/export/schema.js +47 -0
- package/dist/core/export/stage.d.ts +25 -0
- package/dist/core/export/stage.js +192 -0
- package/dist/core/fields/builtins.d.ts +70 -0
- package/dist/core/fields/builtins.js +335 -0
- package/dist/core/fields/define.d.ts +86 -0
- package/dist/core/fields/define.js +34 -0
- package/dist/core/fields/walk.d.ts +49 -0
- package/dist/core/fields/walk.js +270 -0
- package/dist/core/fields/widgets.d.ts +27 -0
- package/dist/core/fields/widgets.js +330 -0
- package/dist/core/fields/zod-internals.d.ts +29 -0
- package/dist/core/fields/zod-internals.js +28 -0
- package/dist/core/media/detect.d.ts +5 -0
- package/dist/core/media/detect.js +66 -0
- package/dist/core/media/labels.d.ts +6 -0
- package/dist/core/media/labels.js +17 -0
- package/dist/core/media/library.d.ts +45 -0
- package/dist/core/media/library.js +239 -0
- package/dist/core/media/store.d.ts +11 -0
- package/dist/core/media/store.js +49 -0
- package/dist/core/media/variants.d.ts +10 -0
- package/dist/core/media/variants.js +59 -0
- package/dist/core/messages/en.d.ts +1278 -0
- package/dist/core/messages/en.js +1287 -0
- package/dist/core/messages/index.d.ts +7 -0
- package/dist/core/messages/index.js +14 -0
- package/dist/core/preview.d.ts +16 -0
- package/dist/core/preview.js +42 -0
- package/dist/core/redirects/collapse.d.ts +68 -0
- package/dist/core/redirects/collapse.js +153 -0
- package/dist/core/redirects/csv.d.ts +15 -0
- package/dist/core/redirects/csv.js +68 -0
- package/dist/core/redirects/redirects.d.ts +58 -0
- package/dist/core/redirects/redirects.js +545 -0
- package/dist/core/registry/content.d.ts +26 -0
- package/dist/core/registry/content.js +9 -0
- package/dist/core/registry/define.d.ts +145 -0
- package/dist/core/registry/define.js +41 -0
- package/dist/core/registry/migration.d.ts +44 -0
- package/dist/core/registry/migration.js +4 -0
- package/dist/core/registry/registry.d.ts +18 -0
- package/dist/core/registry/registry.js +255 -0
- package/dist/core/registry/render.d.ts +98 -0
- package/dist/core/registry/render.js +1 -0
- package/dist/core/registry/route.d.ts +42 -0
- package/dist/core/registry/route.js +3 -0
- package/dist/core/release/bundle.d.ts +21 -0
- package/dist/core/release/bundle.js +252 -0
- package/dist/core/release/keys.d.ts +11 -0
- package/dist/core/release/keys.js +60 -0
- package/dist/core/release/manifest.d.ts +103 -0
- package/dist/core/release/manifest.js +138 -0
- package/dist/core/release/pack.d.ts +20 -0
- package/dist/core/release/pack.js +97 -0
- package/dist/core/release/pointer.d.ts +19 -0
- package/dist/core/release/pointer.js +53 -0
- package/dist/core/release/read.d.ts +59 -0
- package/dist/core/release/read.js +256 -0
- package/dist/core/report.d.ts +31 -0
- package/dist/core/report.js +37 -0
- package/dist/core/richtext/html.d.ts +15 -0
- package/dist/core/richtext/html.js +81 -0
- package/dist/core/richtext/markdown.d.ts +19 -0
- package/dist/core/richtext/markdown.js +951 -0
- package/dist/core/richtext/schema.d.ts +98 -0
- package/dist/core/richtext/schema.js +275 -0
- package/dist/core/site/live.d.ts +56 -0
- package/dist/core/site/live.js +145 -0
- package/dist/core/site/paths.d.ts +15 -0
- package/dist/core/site/paths.js +64 -0
- package/dist/core/site/resolve.d.ts +9 -0
- package/dist/core/site/resolve.js +202 -0
- package/dist/core/site/sitemap.d.ts +11 -0
- package/dist/core/site/sitemap.js +24 -0
- package/dist/core/site-lock/site-lock.d.ts +21 -0
- package/dist/core/site-lock/site-lock.js +65 -0
- package/dist/core/site-lock/token.d.ts +7 -0
- package/dist/core/site-lock/token.js +24 -0
- package/dist/core/theme.d.ts +22 -0
- package/dist/core/theme.js +133 -0
- package/dist/core/types.d.ts +253 -0
- package/dist/core/types.js +1 -0
- package/dist/core/version.d.ts +1 -0
- package/dist/core/version.js +5 -0
- package/dist/host/activate.d.ts +53 -0
- package/dist/host/activate.js +162 -0
- package/dist/host/app.d.ts +46 -0
- package/dist/host/app.js +129 -0
- package/dist/host/bin.d.ts +5 -0
- package/dist/host/bin.js +8 -0
- package/dist/host/config.d.ts +36 -0
- package/dist/host/config.js +152 -0
- package/dist/host/dev.d.ts +10 -0
- package/dist/host/dev.js +293 -0
- package/dist/host/diff.d.ts +78 -0
- package/dist/host/diff.js +346 -0
- package/dist/host/hooks.d.ts +41 -0
- package/dist/host/hooks.js +49 -0
- package/dist/host/ipc.d.ts +123 -0
- package/dist/host/ipc.js +61 -0
- package/dist/host/preview-proxy.d.ts +24 -0
- package/dist/host/preview-proxy.js +154 -0
- package/dist/host/preview-worker.d.ts +42 -0
- package/dist/host/preview-worker.js +242 -0
- package/dist/host/primary.d.ts +38 -0
- package/dist/host/primary.js +357 -0
- package/dist/host/push.d.ts +125 -0
- package/dist/host/push.js +420 -0
- package/dist/host/serve.d.ts +16 -0
- package/dist/host/serve.js +150 -0
- package/dist/host/store.d.ts +48 -0
- package/dist/host/store.js +109 -0
- package/dist/host/worker.d.ts +67 -0
- package/dist/host/worker.js +310 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +32 -0
- package/dist/jsx/html.d.ts +16 -0
- package/dist/jsx/html.js +65 -0
- package/dist/jsx/jsx-dev-runtime.d.ts +4 -0
- package/dist/jsx/jsx-dev-runtime.js +5 -0
- package/dist/jsx/jsx-runtime.d.ts +17 -0
- package/dist/jsx/jsx-runtime.js +41 -0
- package/dist/site.d.ts +17 -0
- package/dist/site.js +14 -0
- package/package.json +111 -3
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Activity, DocumentSummary, RevisionSource } from '../../core/types.js';
|
|
2
|
+
/** One line of recent activity: as the core reports it, or a burst of edits by one person collapsed into one. */
|
|
3
|
+
export type ActivityLine = Activity | {
|
|
4
|
+
kind: 'edits';
|
|
5
|
+
at: string;
|
|
6
|
+
authorName: string;
|
|
7
|
+
source: RevisionSource;
|
|
8
|
+
documents: DocumentSummary[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Recent activity (newest first) grouped by UTC calendar day, labeled relative to `now`. Within a day, consecutive
|
|
12
|
+
* edits by the same person through the same channel, each within 10 minutes of the one before, become one line.
|
|
13
|
+
*/
|
|
14
|
+
export declare function groupActivity(items: readonly Activity[], now: Date): Array<{
|
|
15
|
+
day: string;
|
|
16
|
+
lines: ActivityLine[];
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { t } from '../../core/messages/index.js';
|
|
2
|
+
const BURST_GAP_MS = 10 * 60 * 1000;
|
|
3
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
4
|
+
const SHORT_DATE = new Intl.DateTimeFormat('en', { month: 'short', day: 'numeric', timeZone: 'UTC' });
|
|
5
|
+
const LONG_DATE = new Intl.DateTimeFormat('en', { month: 'short', day: 'numeric', year: 'numeric', timeZone: 'UTC' });
|
|
6
|
+
const utcDay = (date) => Math.floor(date.getTime() / DAY_MS);
|
|
7
|
+
function dayLabel(at, now) {
|
|
8
|
+
const diff = utcDay(now) - utcDay(at);
|
|
9
|
+
if (diff === 0)
|
|
10
|
+
return t('admin.activity.today');
|
|
11
|
+
if (diff === 1)
|
|
12
|
+
return t('admin.activity.yesterday');
|
|
13
|
+
return at.getUTCFullYear() === now.getUTCFullYear() ? SHORT_DATE.format(at) : LONG_DATE.format(at);
|
|
14
|
+
}
|
|
15
|
+
/** Whether `item` (older) continues the run of edits that `line` (newer) ends with. */
|
|
16
|
+
function continues(line, item, last) {
|
|
17
|
+
if (line === undefined || item.kind !== 'edit' || (line.kind !== 'edit' && line.kind !== 'edits'))
|
|
18
|
+
return false;
|
|
19
|
+
if (line.authorName !== item.authorName || line.source !== item.source)
|
|
20
|
+
return false;
|
|
21
|
+
return Date.parse(last) - Date.parse(item.at) <= BURST_GAP_MS;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Recent activity (newest first) grouped by UTC calendar day, labeled relative to `now`. Within a day, consecutive
|
|
25
|
+
* edits by the same person through the same channel, each within 10 minutes of the one before, become one line.
|
|
26
|
+
*/
|
|
27
|
+
export function groupActivity(items, now) {
|
|
28
|
+
const days = [];
|
|
29
|
+
let last = '';
|
|
30
|
+
for (const item of items) {
|
|
31
|
+
const at = new Date(item.at);
|
|
32
|
+
const key = utcDay(at);
|
|
33
|
+
let group = days[days.length - 1];
|
|
34
|
+
if (group === undefined || group.key !== key) {
|
|
35
|
+
group = { key, day: dayLabel(at, now), lines: [] };
|
|
36
|
+
days.push(group);
|
|
37
|
+
}
|
|
38
|
+
const prev = group.lines[group.lines.length - 1];
|
|
39
|
+
if (item.kind === 'edit' && prev !== undefined && continues(prev, item, last)) {
|
|
40
|
+
if (prev.kind === 'edit') {
|
|
41
|
+
group.lines[group.lines.length - 1] = {
|
|
42
|
+
kind: 'edits',
|
|
43
|
+
at: prev.at,
|
|
44
|
+
authorName: prev.authorName,
|
|
45
|
+
source: prev.source,
|
|
46
|
+
documents: [prev.document],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const merged = group.lines[group.lines.length - 1];
|
|
50
|
+
if (merged?.kind === 'edits' && !merged.documents.some((d) => d.id === item.document.id))
|
|
51
|
+
merged.documents.push(item.document);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
group.lines.push(item);
|
|
55
|
+
}
|
|
56
|
+
last = item.at;
|
|
57
|
+
}
|
|
58
|
+
return days.map(({ day, lines }) => ({ day, lines }));
|
|
59
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FastifyInstance } from 'fastify';
|
|
2
|
+
export type AssetName = 'admin.css' | 'admin.js' | 'editor.js';
|
|
3
|
+
export interface AdminAssets {
|
|
4
|
+
url(name: AssetName): string;
|
|
5
|
+
read(name: AssetName): Promise<{
|
|
6
|
+
body: Buffer;
|
|
7
|
+
type: string;
|
|
8
|
+
hash: string;
|
|
9
|
+
} | null>;
|
|
10
|
+
}
|
|
11
|
+
export declare function loadAdminAssets(opts?: {
|
|
12
|
+
dir?: string;
|
|
13
|
+
}): Promise<AdminAssets>;
|
|
14
|
+
export declare function registerAssetRoutes(scope: FastifyInstance, assets: AdminAssets): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { InlayError } from '../../core/errors.js';
|
|
6
|
+
const NAMES = ['admin.css', 'admin.js', 'editor.js'];
|
|
7
|
+
const TYPES = {
|
|
8
|
+
'admin.css': 'text/css; charset=utf-8',
|
|
9
|
+
'admin.js': 'text/javascript; charset=utf-8',
|
|
10
|
+
'editor.js': 'text/javascript; charset=utf-8',
|
|
11
|
+
};
|
|
12
|
+
const hashOf = (body) => createHash('sha256').update(body).digest('hex').slice(0, 10);
|
|
13
|
+
export async function loadAdminAssets(opts = {}) {
|
|
14
|
+
const dir = opts.dir ?? fileURLToPath(new URL('../../../assets/admin/', import.meta.url));
|
|
15
|
+
const entries = new Map();
|
|
16
|
+
async function load(name, path, type) {
|
|
17
|
+
try {
|
|
18
|
+
const info = await stat(path);
|
|
19
|
+
const cached = entries.get(name);
|
|
20
|
+
if (cached && cached.mtime === info.mtimeMs)
|
|
21
|
+
return cached;
|
|
22
|
+
const body = await readFile(path);
|
|
23
|
+
const entry = { path, type, mtime: info.mtimeMs, body, hash: hashOf(body) };
|
|
24
|
+
entries.set(name, entry);
|
|
25
|
+
return entry;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for (const name of ['admin.css', 'admin.js']) {
|
|
32
|
+
if (!(await load(name, join(dir, name), TYPES[name]))) {
|
|
33
|
+
throw new InlayError('config', 'config.adminAssetsMissing', { dir });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
await load('editor.js', join(dir, 'editor.js'), TYPES['editor.js']);
|
|
37
|
+
async function read(name) {
|
|
38
|
+
const entry = await load(name, join(dir, name), TYPES[name]);
|
|
39
|
+
return entry ? { body: entry.body, type: entry.type, hash: entry.hash } : null;
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
read,
|
|
43
|
+
url(name) {
|
|
44
|
+
const entry = entries.get(name);
|
|
45
|
+
return `/admin/assets/${name}${entry ? `?v=${entry.hash}` : ''}`;
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function registerAssetRoutes(scope, assets) {
|
|
50
|
+
scope.get('/admin/assets/:name', async (request, reply) => {
|
|
51
|
+
const { name } = request.params;
|
|
52
|
+
if (!NAMES.includes(name))
|
|
53
|
+
return reply.code(404).send();
|
|
54
|
+
const asset = await assets.read(name);
|
|
55
|
+
if (!asset)
|
|
56
|
+
return reply.code(404).send();
|
|
57
|
+
const current = request.query.v === asset.hash;
|
|
58
|
+
reply
|
|
59
|
+
.header('cache-control', current ? 'public, max-age=31536000, immutable' : 'no-cache')
|
|
60
|
+
.header('x-content-type-options', 'nosniff')
|
|
61
|
+
.header('x-robots-tag', 'noindex');
|
|
62
|
+
return reply.type(asset.type).send(asset.body);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AdminContext } from './context.js';
|
|
2
|
+
import { type TranslationRow } from './translations.js';
|
|
3
|
+
import type { IconName } from './views/icons.js';
|
|
4
|
+
export interface AttentionItem {
|
|
5
|
+
icon: IconName;
|
|
6
|
+
text: string;
|
|
7
|
+
href: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* What an editor should look at: missing translations, images without a description, and links to deleted content.
|
|
11
|
+
* `rows.singletons` saves working out the pages' translations again when the caller already has them.
|
|
12
|
+
*/
|
|
13
|
+
export declare function needsAttention(ctx: AdminContext, rows?: {
|
|
14
|
+
singletons?: TranslationRow[];
|
|
15
|
+
}): Promise<AttentionItem[]>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { t } from '../../core/messages/index.js';
|
|
2
|
+
import { missingTranslations, translationRows } from './translations.js';
|
|
3
|
+
const MAX_ITEMS = 8;
|
|
4
|
+
/**
|
|
5
|
+
* What an editor should look at: missing translations, images without a description, and links to deleted content.
|
|
6
|
+
* `rows.singletons` saves working out the pages' translations again when the caller already has them.
|
|
7
|
+
*/
|
|
8
|
+
export async function needsAttention(ctx, rows = {}) {
|
|
9
|
+
const { core } = ctx;
|
|
10
|
+
const { registry } = core;
|
|
11
|
+
const items = [];
|
|
12
|
+
if (registry.locales.length > 1) {
|
|
13
|
+
const pages = rows.singletons ?? (await translationRows(ctx, registry.site.singletons));
|
|
14
|
+
for (const [found, href] of [
|
|
15
|
+
[pages, '/admin/pages'],
|
|
16
|
+
[await translationRows(ctx, registry.site.globals), '/admin/globals'],
|
|
17
|
+
]) {
|
|
18
|
+
for (const { def, locale } of missingTranslations(found)) {
|
|
19
|
+
items.push({ icon: 'globe', text: t('admin.attention.untranslated', { title: def.label, locale: locale.toUpperCase() }), href });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const { imagesWithoutAlt } = await core.mediaStats();
|
|
24
|
+
if (imagesWithoutAlt > 0)
|
|
25
|
+
items.push({ icon: 'image', text: t('admin.attention.noAlt', { count: imagesWithoutAlt }), href: '/admin/media' });
|
|
26
|
+
for (const doc of await core.brokenReferences()) {
|
|
27
|
+
items.push({
|
|
28
|
+
icon: 'redirect',
|
|
29
|
+
text: t('admin.attention.brokenRef', { title: doc.title }),
|
|
30
|
+
href: `/admin/documents/${encodeURIComponent(doc.id)}`,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return items.slice(0, MAX_ITEMS);
|
|
34
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';
|
|
2
|
+
import type { FormValues } from '../../core/fields/define.js';
|
|
3
|
+
import { type MessageId } from '../../core/messages/index.js';
|
|
4
|
+
import type { Actor } from '../../core/types.js';
|
|
5
|
+
import type { AdminRouteOptions } from './routes.js';
|
|
6
|
+
export declare const HTML = "text/html; charset=utf-8";
|
|
7
|
+
export declare const SETUP_PATH = "/admin/setup";
|
|
8
|
+
/** Everything admin screens receive. */
|
|
9
|
+
export type AdminContext = AdminRouteOptions;
|
|
10
|
+
/** The part of the admin a page belongs to, for the navigation. */
|
|
11
|
+
export type Section = 'dashboard' | 'pages' | 'globals' | `collection:${string}` | 'media' | 'redirects' | 'users' | 'backups' | 'releases' | 'security' | 'account';
|
|
12
|
+
export type { FormValues };
|
|
13
|
+
/** The notices a redirect may ask for with `?notice=<key>`, and the counts each may carry in the query. */
|
|
14
|
+
export declare const NOTICES: Record<string, {
|
|
15
|
+
id: MessageId;
|
|
16
|
+
params?: readonly string[];
|
|
17
|
+
}>;
|
|
18
|
+
/** The text of the query's `notice`, when it names a known notice and every count it needs is a non-negative integer. */
|
|
19
|
+
export declare function noticeOf(query: unknown): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Where a redirect URI sends the user: the host (with any port) for http(s), otherwise the scheme and host
|
|
22
|
+
* (`evilapp://claude.ai`), or just the scheme for an app's own (`cursor:`), so another scheme can't pass for a website.
|
|
23
|
+
*/
|
|
24
|
+
export declare function hostOf(raw: string | null): string | undefined;
|
|
25
|
+
/** The submitted urlencoded form, with every repeated value; empty when the body wasn't one. */
|
|
26
|
+
export declare function formValues(request: FastifyRequest): FormValues;
|
|
27
|
+
/** The first value of each name in the submitted form; empty when the body wasn't one. */
|
|
28
|
+
export declare function formOf(request: FastifyRequest): Record<string, string>;
|
|
29
|
+
/** The signed-in user of a request to a route registered through `registerScreens`. */
|
|
30
|
+
export declare function adminActor(request: FastifyRequest): Actor;
|
|
31
|
+
/** The admin's "you can't open this page" page, with status 403. */
|
|
32
|
+
export declare function forbidden(reply: FastifyReply, ctx: AdminContext, actor: Actor): Promise<FastifyReply>;
|
|
33
|
+
/** The admin's "page not found" page, with status 404. */
|
|
34
|
+
export declare function notFound(reply: FastifyReply, ctx: AdminContext, actor: Actor): Promise<FastifyReply>;
|
|
35
|
+
/**
|
|
36
|
+
* Registers the screens that need a signed-in user in a child scope. Before any of its routes runs, a POST from
|
|
37
|
+
* another origin gets 403, and a request without a session is sent to log in: an htmx request gets 401 with
|
|
38
|
+
* `HX-Redirect`, anything else a 302 that comes back afterwards (or to setup while there is no owner yet).
|
|
39
|
+
*/
|
|
40
|
+
export declare function registerScreens(scope: FastifyInstance, ctx: AdminContext, register: (authed: FastifyInstance) => void): void;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { InlayError } from '../../core/errors.js';
|
|
2
|
+
import { t } from '../../core/messages/index.js';
|
|
3
|
+
import { html } from '../../jsx/html.js';
|
|
4
|
+
import { LOGIN_PATH, requestActor } from '../auth/request.js';
|
|
5
|
+
import { safeNext, sameOrigin } from '../web.js';
|
|
6
|
+
import { badOriginPage } from './pages.js';
|
|
7
|
+
import { adminPage } from './views/layout.js';
|
|
8
|
+
export const HTML = 'text/html; charset=utf-8';
|
|
9
|
+
export const SETUP_PATH = '/admin/setup';
|
|
10
|
+
/** The notices a redirect may ask for with `?notice=<key>`, and the counts each may carry in the query. */
|
|
11
|
+
export const NOTICES = {
|
|
12
|
+
saved: { id: 'admin.notice.saved' },
|
|
13
|
+
unchanged: { id: 'admin.notice.unchanged' },
|
|
14
|
+
created: { id: 'admin.notice.created' },
|
|
15
|
+
deleted: { id: 'admin.notice.deleted' },
|
|
16
|
+
restored: { id: 'admin.notice.restored' },
|
|
17
|
+
uploaded: { id: 'admin.notice.uploaded' },
|
|
18
|
+
reused: { id: 'admin.notice.reused' },
|
|
19
|
+
translated: { id: 'admin.notice.translated' },
|
|
20
|
+
backedUp: { id: 'admin.notice.backedUp' },
|
|
21
|
+
siteLocked: { id: 'admin.notice.siteLocked' },
|
|
22
|
+
siteUnlocked: { id: 'admin.notice.siteUnlocked' },
|
|
23
|
+
sitePasswordSaved: { id: 'admin.notice.sitePasswordSaved' },
|
|
24
|
+
passwordChanged: { id: 'admin.notice.passwordChanged' },
|
|
25
|
+
userAdded: { id: 'admin.notice.userAdded' },
|
|
26
|
+
userUpdated: { id: 'admin.notice.userUpdated' },
|
|
27
|
+
userRemoved: { id: 'admin.notice.userRemoved' },
|
|
28
|
+
keyRevoked: { id: 'admin.notice.keyRevoked' },
|
|
29
|
+
redirectAdded: { id: 'admin.notice.redirectAdded' },
|
|
30
|
+
redirectRemoved: { id: 'admin.notice.redirectRemoved' },
|
|
31
|
+
imported: { id: 'admin.notice.imported', params: ['created', 'updated'] },
|
|
32
|
+
contentImported: { id: 'admin.notice.contentImported', params: ['documents'] },
|
|
33
|
+
altSaved: { id: 'admin.notice.altSaved' },
|
|
34
|
+
bulkDeleted: { id: 'admin.bulkDelete.done', params: ['count'] },
|
|
35
|
+
published: { id: 'admin.notice.published' },
|
|
36
|
+
unpublished: { id: 'admin.notice.unpublished' },
|
|
37
|
+
releaseUploaded: { id: 'admin.notice.releaseUploaded' },
|
|
38
|
+
releaseActivated: { id: 'admin.notice.releaseActivated' },
|
|
39
|
+
releaseDeleted: { id: 'admin.notice.releaseDeleted' },
|
|
40
|
+
};
|
|
41
|
+
const COUNT = /^\d{1,15}$/;
|
|
42
|
+
/** The text of the query's `notice`, when it names a known notice and every count it needs is a non-negative integer. */
|
|
43
|
+
export function noticeOf(query) {
|
|
44
|
+
if (typeof query !== 'object' || query === null)
|
|
45
|
+
return undefined;
|
|
46
|
+
const q = query;
|
|
47
|
+
const key = q.notice;
|
|
48
|
+
if (typeof key !== 'string' || !Object.hasOwn(NOTICES, key))
|
|
49
|
+
return undefined;
|
|
50
|
+
const notice = NOTICES[key];
|
|
51
|
+
if (!notice)
|
|
52
|
+
return undefined;
|
|
53
|
+
const params = {};
|
|
54
|
+
for (const name of notice.params ?? []) {
|
|
55
|
+
const value = Object.hasOwn(q, name) ? q[name] : undefined;
|
|
56
|
+
if (typeof value !== 'string' || !COUNT.test(value))
|
|
57
|
+
return undefined;
|
|
58
|
+
params[name] = Number(value);
|
|
59
|
+
}
|
|
60
|
+
return t(notice.id, params);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Where a redirect URI sends the user: the host (with any port) for http(s), otherwise the scheme and host
|
|
64
|
+
* (`evilapp://claude.ai`), or just the scheme for an app's own (`cursor:`), so another scheme can't pass for a website.
|
|
65
|
+
*/
|
|
66
|
+
export function hostOf(raw) {
|
|
67
|
+
if (raw === null)
|
|
68
|
+
return undefined;
|
|
69
|
+
let url;
|
|
70
|
+
try {
|
|
71
|
+
url = new URL(raw);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
if (url.protocol === 'https:' || url.protocol === 'http:')
|
|
77
|
+
return url.host;
|
|
78
|
+
return url.host !== '' ? `${url.protocol}//${url.host}` : url.protocol;
|
|
79
|
+
}
|
|
80
|
+
const bodyOf = (request) => request.body instanceof URLSearchParams ? request.body : new URLSearchParams();
|
|
81
|
+
/** The submitted urlencoded form, with every repeated value; empty when the body wasn't one. */
|
|
82
|
+
export function formValues(request) {
|
|
83
|
+
const params = bodyOf(request);
|
|
84
|
+
return {
|
|
85
|
+
get: (name) => params.get(name) ?? undefined,
|
|
86
|
+
all: (name) => params.getAll(name),
|
|
87
|
+
names: () => [...new Set(params.keys())],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** The first value of each name in the submitted form; empty when the body wasn't one. */
|
|
91
|
+
export function formOf(request) {
|
|
92
|
+
const form = Object.create(null);
|
|
93
|
+
for (const [key, value] of bodyOf(request))
|
|
94
|
+
if (!Object.hasOwn(form, key))
|
|
95
|
+
form[key] = value;
|
|
96
|
+
return form;
|
|
97
|
+
}
|
|
98
|
+
const actors = new WeakMap();
|
|
99
|
+
/** The signed-in user of a request to a route registered through `registerScreens`. */
|
|
100
|
+
export function adminActor(request) {
|
|
101
|
+
const actor = actors.get(request);
|
|
102
|
+
if (!actor)
|
|
103
|
+
throw new InlayError('definition', 'definition.adminActor');
|
|
104
|
+
return actor;
|
|
105
|
+
}
|
|
106
|
+
/** The admin's "you can't open this page" page, with status 403. */
|
|
107
|
+
export async function forbidden(reply, ctx, actor) {
|
|
108
|
+
const body = html `<p>${t('admin.forbidden')}</p><p><a href="/admin" class="link">${t('admin.backToDashboard')}</a></p>`;
|
|
109
|
+
const page = await adminPage(ctx, { title: t('admin.forbidden.title'), actor, status: 403 }, body);
|
|
110
|
+
return reply.code(403).type(HTML).send(page);
|
|
111
|
+
}
|
|
112
|
+
/** The admin's "page not found" page, with status 404. */
|
|
113
|
+
export async function notFound(reply, ctx, actor) {
|
|
114
|
+
const body = html `<p>${t('admin.notFound')}</p><p><a href="/admin" class="link">${t('admin.backToDashboard')}</a></p>`;
|
|
115
|
+
const page = await adminPage(ctx, { title: t('admin.notFound.title'), actor, status: 404 }, body);
|
|
116
|
+
return reply.code(404).type(HTML).send(page);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Registers the screens that need a signed-in user in a child scope. Before any of its routes runs, a POST from
|
|
120
|
+
* another origin gets 403, and a request without a session is sent to log in: an htmx request gets 401 with
|
|
121
|
+
* `HX-Redirect`, anything else a 302 that comes back afterwards (or to setup while there is no owner yet).
|
|
122
|
+
*/
|
|
123
|
+
export function registerScreens(scope, ctx, register) {
|
|
124
|
+
scope.register(async (authed) => {
|
|
125
|
+
authed.addHook('onRequest', async (request, reply) => {
|
|
126
|
+
if (request.method === 'POST' && !sameOrigin(request, ctx.baseUrl)) {
|
|
127
|
+
return reply.code(403).type(HTML).send(await badOriginPage(ctx));
|
|
128
|
+
}
|
|
129
|
+
const actor = await requestActor(request, ctx.service);
|
|
130
|
+
if (actor) {
|
|
131
|
+
actors.set(request, actor);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (request.headers['hx-request'] === 'true')
|
|
135
|
+
return reply.code(401).header('hx-redirect', LOGIN_PATH).send();
|
|
136
|
+
if (!(await ctx.service.hasOwner()))
|
|
137
|
+
return reply.redirect(SETUP_PATH, 302);
|
|
138
|
+
return reply.redirect(`${LOGIN_PATH}?${new URLSearchParams({ next: safeNext(request.url) }).toString()}`, 302);
|
|
139
|
+
});
|
|
140
|
+
register(authed);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type AgentRefs, type FormValues } from '../../../core/fields/define.js';
|
|
2
|
+
import type { Registry } from '../../../core/registry/registry.js';
|
|
3
|
+
import type { ContentIssue, DocumentData, PathSegment } from '../../../core/types.js';
|
|
4
|
+
import type { Html } from '../../../jsx/html.js';
|
|
5
|
+
/** What the document form is rendered for. */
|
|
6
|
+
export interface FormContext {
|
|
7
|
+
registry: Registry;
|
|
8
|
+
type: string;
|
|
9
|
+
locale: string;
|
|
10
|
+
refs: AgentRefs;
|
|
11
|
+
/** The form's action, for the list buttons' `hx-post`. Without it they only submit the form. */
|
|
12
|
+
action?: string;
|
|
13
|
+
readOnly?: boolean;
|
|
14
|
+
/** Save problems by form name. */
|
|
15
|
+
problems?: Map<string, string[]>;
|
|
16
|
+
/** "Needed before publishing" hints by form name. */
|
|
17
|
+
hints?: Map<string, string[]>;
|
|
18
|
+
/** Form names of list items to render open (besides any with problems or hints). */
|
|
19
|
+
open?: Set<string>;
|
|
20
|
+
/** Card keys to render closed: 'fields' or a slot key. */
|
|
21
|
+
closed?: Set<string>;
|
|
22
|
+
}
|
|
23
|
+
/** The form name of a document path: its segments joined with dots. */
|
|
24
|
+
export declare const formName: (path: PathSegment[]) => string;
|
|
25
|
+
/** The id of the control for a form name. Field names can't contain `-`, so ids are unique. */
|
|
26
|
+
export declare const formId: (name: string) => string;
|
|
27
|
+
/**
|
|
28
|
+
* The editor form's fields for a document: a card of the entry slug and path and the page fields, then a card per
|
|
29
|
+
* slot in template order.
|
|
30
|
+
*/
|
|
31
|
+
export declare function DocumentFields({ ctx, data, entry }: {
|
|
32
|
+
ctx: FormContext;
|
|
33
|
+
data: DocumentData;
|
|
34
|
+
entry?: {
|
|
35
|
+
customPaths: boolean;
|
|
36
|
+
};
|
|
37
|
+
}): Html;
|
|
38
|
+
/** Every name the form renders for `data`: fields, groups, lists and their items, `slug`, `path` and slot switches. */
|
|
39
|
+
export declare function formNames(registry: Registry, type: string, data: DocumentData): Set<string>;
|
|
40
|
+
/** Puts each issue on the longest prefix of its path that the form renders; the rest are `unplaced`. */
|
|
41
|
+
export declare function placeIssues(registry: Registry, type: string, data: DocumentData, issues: ContentIssue[]): {
|
|
42
|
+
byName: Map<string, string[]>;
|
|
43
|
+
unplaced: ContentIssue[];
|
|
44
|
+
};
|
|
45
|
+
/** The document a submitted editor form describes. Driven by the schema: only schema keys are read. */
|
|
46
|
+
export declare function parseDocumentForm(registry: Registry, type: string, form: FormValues): DocumentData;
|
|
47
|
+
/**
|
|
48
|
+
* Applies a list button: `add:<list>` appends an empty item, and `remove|up|down:<list>.<i>` removes or moves
|
|
49
|
+
* one. Anything that isn't a list or an existing item gives back `data` itself.
|
|
50
|
+
*/
|
|
51
|
+
export declare function applyFormOp(registry: Registry, type: string, data: DocumentData, op: string): DocumentData;
|
|
52
|
+
/** Reads the comma-separated `_open` / `_closed` form values. */
|
|
53
|
+
export declare function readOpenState(form: FormValues): {
|
|
54
|
+
open: string[];
|
|
55
|
+
closed: string[];
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Item form names open after `op`, given those open before it: up/down move a name with its item, remove drops it
|
|
59
|
+
* and shifts later siblings down, add opens the new item. `data` is the form's data before `op` is applied.
|
|
60
|
+
*/
|
|
61
|
+
export declare function remapOpen(registry: Registry, type: string, data: DocumentData, op: string, open: string[]): string[];
|