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,55 @@
|
|
|
1
|
+
import type { CheckProblem } from '../report.js';
|
|
2
|
+
import type { SiteLockRow } from '../site-lock/site-lock.js';
|
|
3
|
+
export type ImportTypeStatus = 'compatible' | 'hidden';
|
|
4
|
+
/**
|
|
5
|
+
* One content type of the export: `current` is its name in the code, or null when the site doesn't
|
|
6
|
+
* have it (its content is kept, hidden). `gaps`: documents that will need attention once imported.
|
|
7
|
+
*/
|
|
8
|
+
export interface ImportTypeReport {
|
|
9
|
+
type: string;
|
|
10
|
+
current: string | null;
|
|
11
|
+
label: string;
|
|
12
|
+
documents: number;
|
|
13
|
+
status: ImportTypeStatus;
|
|
14
|
+
gaps: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ImportLocaleReport {
|
|
17
|
+
locale: string;
|
|
18
|
+
documents: number;
|
|
19
|
+
status: 'compatible' | 'hidden';
|
|
20
|
+
}
|
|
21
|
+
export type SiteLockEffect = 'on' | 'off' | 'set' | 'changed' | 'removed';
|
|
22
|
+
/** The lock an export carries; `effects` is what importing it does to the receiving site, or null when that site isn't known. */
|
|
23
|
+
export interface ImportSiteLock {
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
hasPassword: boolean;
|
|
26
|
+
effects: SiteLockEffect[] | null;
|
|
27
|
+
}
|
|
28
|
+
/** What restoring an export would do, from a dry run. */
|
|
29
|
+
export interface ImportReport {
|
|
30
|
+
/** No problems: the import would go ahead. */
|
|
31
|
+
ok: boolean;
|
|
32
|
+
exportedAt: string;
|
|
33
|
+
inlayVersion: string;
|
|
34
|
+
types: ImportTypeReport[];
|
|
35
|
+
locales: ImportLocaleReport[];
|
|
36
|
+
/** Problems bringing the site up to date on top of the export; any of them blocks the import. */
|
|
37
|
+
general: CheckProblem[];
|
|
38
|
+
/** `files`: the media files that can be restored. `damaged`: filenames of the ones that can't, which the import leaves out. */
|
|
39
|
+
media: {
|
|
40
|
+
files: number;
|
|
41
|
+
damaged: string[];
|
|
42
|
+
};
|
|
43
|
+
redirects: {
|
|
44
|
+
count: number;
|
|
45
|
+
};
|
|
46
|
+
/** Titles of the shipped content the import would create or replace. */
|
|
47
|
+
shipped: string[];
|
|
48
|
+
/** The export's lock, or null for an export made before the lock existed (the import leaves the lock alone). */
|
|
49
|
+
siteLock: ImportSiteLock | null;
|
|
50
|
+
}
|
|
51
|
+
/** What replacing the lock `current` with `exported` changes. */
|
|
52
|
+
export declare function siteLockEffects(exported: SiteLockRow, current: SiteLockRow): SiteLockEffect[];
|
|
53
|
+
export declare function siteLockLines(lock: ImportSiteLock | null): string[];
|
|
54
|
+
/** The report as lines a person reads: one per type and locale, with the documents needing attention indented, then everything else. */
|
|
55
|
+
export declare function formatImportReport(report: ImportReport): string[];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { t } from '../messages/index.js';
|
|
2
|
+
/** What replacing the lock `current` with `exported` changes. */
|
|
3
|
+
export function siteLockEffects(exported, current) {
|
|
4
|
+
const effects = [];
|
|
5
|
+
if (exported.enabled && !current.enabled)
|
|
6
|
+
effects.push('on');
|
|
7
|
+
if (!exported.enabled && current.enabled)
|
|
8
|
+
effects.push('off');
|
|
9
|
+
if (exported.passwordHash !== null && current.passwordHash === null)
|
|
10
|
+
effects.push('set');
|
|
11
|
+
if (exported.passwordHash !== null && current.passwordHash !== null && exported.passwordHash !== current.passwordHash)
|
|
12
|
+
effects.push('changed');
|
|
13
|
+
if (exported.passwordHash === null && current.passwordHash !== null)
|
|
14
|
+
effects.push('removed');
|
|
15
|
+
return effects;
|
|
16
|
+
}
|
|
17
|
+
export function siteLockLines(lock) {
|
|
18
|
+
if (!lock)
|
|
19
|
+
return [];
|
|
20
|
+
if (lock.effects)
|
|
21
|
+
return lock.effects.map((effect) => t(`import.siteLock.${effect}`));
|
|
22
|
+
const lines = [t(lock.enabled ? 'import.siteLock.exportOn' : 'import.siteLock.exportOff')];
|
|
23
|
+
if (!lock.hasPassword)
|
|
24
|
+
lines.push(t('import.siteLock.exportNoPassword'));
|
|
25
|
+
return lines;
|
|
26
|
+
}
|
|
27
|
+
/** The report as lines a person reads: one per type and locale, with the documents needing attention indented, then everything else. */
|
|
28
|
+
export function formatImportReport(report) {
|
|
29
|
+
const lines = [];
|
|
30
|
+
for (const row of report.types) {
|
|
31
|
+
lines.push(t('import.typeLine', { label: row.label, status: t(`import.status.${row.status}`), documents: row.documents }));
|
|
32
|
+
if (row.gaps > 0)
|
|
33
|
+
lines.push(t('import.gaps', { count: row.gaps }));
|
|
34
|
+
}
|
|
35
|
+
for (const row of report.locales) {
|
|
36
|
+
lines.push(t('import.localeLine', { locale: row.locale, status: t(`import.status.${row.status}`), documents: row.documents }));
|
|
37
|
+
}
|
|
38
|
+
for (const problem of report.general) {
|
|
39
|
+
lines.push(t('import.general', { message: problem.message }));
|
|
40
|
+
for (const issue of problem.issues ?? [])
|
|
41
|
+
lines.push(t('import.issue', { message: issue.message }));
|
|
42
|
+
}
|
|
43
|
+
if (report.media.damaged.length > 0) {
|
|
44
|
+
lines.push(t('import.damagedMedia', { count: report.media.damaged.length, names: report.media.damaged.join(', ') }));
|
|
45
|
+
}
|
|
46
|
+
if (report.shipped.length > 0)
|
|
47
|
+
lines.push(t('import.shipped', { titles: report.shipped.join(', ') }));
|
|
48
|
+
lines.push(...siteLockLines(report.siteLock));
|
|
49
|
+
return lines;
|
|
50
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Registry } from '../registry/registry.js';
|
|
2
|
+
/**
|
|
3
|
+
* The JSON Schema (draft 2020-12) of a document of `type` as it is stored:
|
|
4
|
+
* every field titled with its label and described with its help.
|
|
5
|
+
*/
|
|
6
|
+
export declare function storedTypeSchema(registry: Registry, type: string): Record<string, unknown>;
|
|
7
|
+
/** The stored-shape JSON Schema of every type in `registry`, by type name. */
|
|
8
|
+
export declare function typeSchemas(registry: Registry): Record<string, unknown>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { docLabels, documentSchema } from '../content/schema.js';
|
|
3
|
+
import { fieldRegistry } from '../fields/define.js';
|
|
4
|
+
/**
|
|
5
|
+
* The JSON Schema (draft 2020-12) of a document of `type` as it is stored:
|
|
6
|
+
* every field titled with its label and described with its help.
|
|
7
|
+
*/
|
|
8
|
+
export function storedTypeSchema(registry, type) {
|
|
9
|
+
const { template } = registry.getType(type);
|
|
10
|
+
const json = z.toJSONSchema(documentSchema(registry, type, 'strict'), {
|
|
11
|
+
target: 'draft-2020-12',
|
|
12
|
+
io: 'input',
|
|
13
|
+
unrepresentable: 'any',
|
|
14
|
+
override: ({ zodSchema, jsonSchema }) => {
|
|
15
|
+
const meta = fieldRegistry.get(zodSchema);
|
|
16
|
+
if (!meta)
|
|
17
|
+
return;
|
|
18
|
+
const out = jsonSchema;
|
|
19
|
+
out.title = meta.label;
|
|
20
|
+
if (meta.help !== undefined)
|
|
21
|
+
out.description = meta.help;
|
|
22
|
+
if (meta.setting)
|
|
23
|
+
out['x-setting'] = true;
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const props = (json.properties ?? {});
|
|
27
|
+
for (const key of ['slug', 'path']) {
|
|
28
|
+
const labels = docLabels(registry, type, [key]);
|
|
29
|
+
const prop = props[key];
|
|
30
|
+
if (labels && prop)
|
|
31
|
+
prop.title = labels.at(-1);
|
|
32
|
+
}
|
|
33
|
+
const slots = (props.slots?.properties ?? {});
|
|
34
|
+
for (const [key, slot] of Object.entries(template.slots)) {
|
|
35
|
+
const prop = slots[key];
|
|
36
|
+
if (!prop)
|
|
37
|
+
continue;
|
|
38
|
+
prop.title = slot.label ?? slot.block.label;
|
|
39
|
+
if (slot.block.help !== undefined)
|
|
40
|
+
prop.description = slot.block.help;
|
|
41
|
+
}
|
|
42
|
+
return json;
|
|
43
|
+
}
|
|
44
|
+
/** The stored-shape JSON Schema of every type in `registry`, by type name. */
|
|
45
|
+
export function typeSchemas(registry) {
|
|
46
|
+
return Object.fromEntries([...registry.types.keys()].map((name) => [name, storedTypeSchema(registry, name)]));
|
|
47
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { type Core } from '../core.js';
|
|
3
|
+
import type { Database } from '../db/schema.js';
|
|
4
|
+
import type { SiteDefinition } from '../registry/define.js';
|
|
5
|
+
import type { CheckReport } from '../report.js';
|
|
6
|
+
import type { ExportBundle } from './read.js';
|
|
7
|
+
/** What to leave out of a stage: `media` holds the ids of media files to record as deleted instead. */
|
|
8
|
+
export interface Exclusions {
|
|
9
|
+
media: ReadonlySet<string>;
|
|
10
|
+
}
|
|
11
|
+
export interface Staged {
|
|
12
|
+
db: Kysely<Database>;
|
|
13
|
+
core: Core;
|
|
14
|
+
report: CheckReport;
|
|
15
|
+
/** Closes the scratch database and deletes its files. */
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export declare const noExclusions: Exclusions;
|
|
19
|
+
/**
|
|
20
|
+
* Loads `bundle` (minus `exclude`) into a new scratch database in `bundle.dir`
|
|
21
|
+
* and brings it up to date with `site` the way boot does. Problems go into
|
|
22
|
+
* `report`; when there are any, the scratch database still holds the content
|
|
23
|
+
* as it was in the export. The caller must `close()` it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function stageBundle(site: SiteDefinition, bundle: ExportBundle, exclude: Exclusions, now?: () => Date): Promise<Staged>;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { rm } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { upgradeDatabase } from '../boot.js';
|
|
5
|
+
import { syncRefs } from '../content/refs.js';
|
|
6
|
+
import { createCore } from '../core.js';
|
|
7
|
+
import { openDatabase } from '../db/connection.js';
|
|
8
|
+
import { migrateSystem } from '../db/migrate.js';
|
|
9
|
+
import { InlayError } from '../errors.js';
|
|
10
|
+
import { t } from '../messages/index.js';
|
|
11
|
+
export const noExclusions = { media: new Set() };
|
|
12
|
+
function stagePath(dir) {
|
|
13
|
+
for (let n = 1;; n++) {
|
|
14
|
+
const path = join(dir, `stage-${n}.db`);
|
|
15
|
+
if (!existsSync(path))
|
|
16
|
+
return path;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const derived = (data) => ({
|
|
20
|
+
slug: typeof data?.slug === 'string' ? data.slug : null,
|
|
21
|
+
path: typeof data?.path === 'string' ? data.path : null,
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Loads `bundle` (minus `exclude`) into a new scratch database in `bundle.dir`
|
|
25
|
+
* and brings it up to date with `site` the way boot does. Problems go into
|
|
26
|
+
* `report`; when there are any, the scratch database still holds the content
|
|
27
|
+
* as it was in the export. The caller must `close()` it.
|
|
28
|
+
*/
|
|
29
|
+
export async function stageBundle(site, bundle, exclude, now) {
|
|
30
|
+
const file = stagePath(bundle.dir);
|
|
31
|
+
const db = openDatabase(file);
|
|
32
|
+
const close = async () => {
|
|
33
|
+
await db.destroy();
|
|
34
|
+
for (const suffix of ['', '-wal', '-shm'])
|
|
35
|
+
await rm(`${file}${suffix}`, { force: true });
|
|
36
|
+
};
|
|
37
|
+
try {
|
|
38
|
+
await migrateSystem(db);
|
|
39
|
+
const { manifest } = bundle;
|
|
40
|
+
const { documents, revisions, redirects } = bundle;
|
|
41
|
+
const dataOf = new Map(revisions.map((r) => [r.id, r.data]));
|
|
42
|
+
await db.transaction().execute(async (trx) => {
|
|
43
|
+
for (const d of documents) {
|
|
44
|
+
const head = derived(d.headRevision === null ? undefined : dataOf.get(d.headRevision));
|
|
45
|
+
const published = derived(d.publishedRevision === null ? undefined : dataOf.get(d.publishedRevision));
|
|
46
|
+
await trx
|
|
47
|
+
.insertInto('documents')
|
|
48
|
+
.values({
|
|
49
|
+
id: d.id,
|
|
50
|
+
kind: d.kind,
|
|
51
|
+
type: d.type,
|
|
52
|
+
group_id: d.groupId,
|
|
53
|
+
locale: d.locale,
|
|
54
|
+
head_rev: null,
|
|
55
|
+
published_rev: null,
|
|
56
|
+
head_slug: head.slug,
|
|
57
|
+
published_slug: d.publishedRevision === null ? null : published.slug,
|
|
58
|
+
head_path: head.path,
|
|
59
|
+
published_path: d.publishedRevision === null ? null : published.path,
|
|
60
|
+
deleted_at: d.deletedAt,
|
|
61
|
+
created_at: d.createdAt,
|
|
62
|
+
key: d.key,
|
|
63
|
+
edition: d.edition,
|
|
64
|
+
})
|
|
65
|
+
.execute();
|
|
66
|
+
}
|
|
67
|
+
for (const r of revisions) {
|
|
68
|
+
await trx
|
|
69
|
+
.insertInto('revisions')
|
|
70
|
+
.values({
|
|
71
|
+
id: r.id,
|
|
72
|
+
document_id: r.documentId,
|
|
73
|
+
data: JSON.stringify(r.data),
|
|
74
|
+
author_id: r.authorId,
|
|
75
|
+
author_name: r.authorName,
|
|
76
|
+
source: r.source,
|
|
77
|
+
message: r.message,
|
|
78
|
+
created_at: r.createdAt,
|
|
79
|
+
release_id: r.releaseId,
|
|
80
|
+
})
|
|
81
|
+
.execute();
|
|
82
|
+
}
|
|
83
|
+
for (const d of documents) {
|
|
84
|
+
if (d.headRevision === null && d.publishedRevision === null)
|
|
85
|
+
continue;
|
|
86
|
+
await trx
|
|
87
|
+
.updateTable('documents')
|
|
88
|
+
.set({ head_rev: d.headRevision, published_rev: d.publishedRevision })
|
|
89
|
+
.where('id', '=', d.id)
|
|
90
|
+
.execute();
|
|
91
|
+
}
|
|
92
|
+
for (const e of bundle.publishEvents) {
|
|
93
|
+
await trx
|
|
94
|
+
.insertInto('publish_events')
|
|
95
|
+
.values({
|
|
96
|
+
id: e.id,
|
|
97
|
+
at: e.at,
|
|
98
|
+
user_id: e.userId,
|
|
99
|
+
user_name: e.userName,
|
|
100
|
+
source: e.source,
|
|
101
|
+
message: e.message,
|
|
102
|
+
items: JSON.stringify(e.items),
|
|
103
|
+
})
|
|
104
|
+
.execute();
|
|
105
|
+
}
|
|
106
|
+
for (const r of redirects) {
|
|
107
|
+
await trx
|
|
108
|
+
.insertInto('redirects')
|
|
109
|
+
.values({
|
|
110
|
+
id: r.id,
|
|
111
|
+
from_path: r.from,
|
|
112
|
+
to_path: 'path' in r.to ? r.to.path : null,
|
|
113
|
+
to_group_id: 'group' in r.to ? r.to.group : null,
|
|
114
|
+
status: r.status,
|
|
115
|
+
source: r.source,
|
|
116
|
+
note: r.note,
|
|
117
|
+
created_by_id: r.createdById,
|
|
118
|
+
created_by_name: r.createdBy,
|
|
119
|
+
created_at: r.createdAt,
|
|
120
|
+
})
|
|
121
|
+
.execute();
|
|
122
|
+
}
|
|
123
|
+
for (const m of bundle.media) {
|
|
124
|
+
if (exclude.media.has(m.id))
|
|
125
|
+
continue;
|
|
126
|
+
await trx
|
|
127
|
+
.insertInto('media')
|
|
128
|
+
.values({
|
|
129
|
+
id: m.id,
|
|
130
|
+
filename: m.filename,
|
|
131
|
+
mime: m.mime,
|
|
132
|
+
size: m.size,
|
|
133
|
+
width: m.width,
|
|
134
|
+
height: m.height,
|
|
135
|
+
default_alt: m.defaultAlt,
|
|
136
|
+
created_by_id: m.createdById,
|
|
137
|
+
created_by_name: m.createdBy,
|
|
138
|
+
created_at: m.createdAt,
|
|
139
|
+
})
|
|
140
|
+
.execute();
|
|
141
|
+
}
|
|
142
|
+
const deletions = [
|
|
143
|
+
...bundle.deletions,
|
|
144
|
+
...[...bundle.media, ...bundle.damaged]
|
|
145
|
+
.filter((m) => exclude.media.has(m.id))
|
|
146
|
+
.map((m) => ({
|
|
147
|
+
mediaId: m.id,
|
|
148
|
+
filename: m.filename,
|
|
149
|
+
deletedAt: manifest.exportedAt,
|
|
150
|
+
deletedById: null,
|
|
151
|
+
deletedBy: t('label.system'),
|
|
152
|
+
})),
|
|
153
|
+
];
|
|
154
|
+
for (const d of deletions) {
|
|
155
|
+
await trx
|
|
156
|
+
.insertInto('media_deletions')
|
|
157
|
+
.values({
|
|
158
|
+
media_id: d.mediaId,
|
|
159
|
+
filename: d.filename,
|
|
160
|
+
deleted_at: d.deletedAt,
|
|
161
|
+
deleted_by_id: d.deletedById,
|
|
162
|
+
deleted_by_name: d.deletedBy,
|
|
163
|
+
})
|
|
164
|
+
.execute();
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
const core = createCore({ site, db, media: join(bundle.dir, 'media'), ...(now && { now }) });
|
|
168
|
+
const report = await upgradeDatabase(db, core, []);
|
|
169
|
+
await db.transaction().execute(async (trx) => {
|
|
170
|
+
const deps = { db: trx, registry: core.registry, now: now ?? (() => new Date()), media: null, uploads: { maxBytes: 0, types: [] } };
|
|
171
|
+
const types = [...core.registry.types.keys()];
|
|
172
|
+
if (types.length === 0)
|
|
173
|
+
return;
|
|
174
|
+
// Refs need the type's schema, so documents of types the code doesn't define get none.
|
|
175
|
+
const known = await trx.selectFrom('documents').select('id').where('type', 'in', types).execute();
|
|
176
|
+
for (const { id } of known)
|
|
177
|
+
await syncRefs(deps, id);
|
|
178
|
+
});
|
|
179
|
+
return { db, core, report, close };
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
await close();
|
|
183
|
+
if (isConstraintError(e))
|
|
184
|
+
throw new InlayError('validation', 'error.exportDamaged', { detail: t('export.conflict') });
|
|
185
|
+
throw e;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/** Whether `e` is SQLite refusing a row, which for a checked export means records that clash. */
|
|
189
|
+
function isConstraintError(e) {
|
|
190
|
+
const code = e?.code;
|
|
191
|
+
return typeof code === 'string' && code.startsWith('SQLITE_CONSTRAINT');
|
|
192
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type RichTextDoc, type RichTextFeature } from '../richtext/schema.js';
|
|
3
|
+
interface BaseOptions {
|
|
4
|
+
label: string;
|
|
5
|
+
help?: string;
|
|
6
|
+
setting?: boolean;
|
|
7
|
+
}
|
|
8
|
+
interface TextOptions extends BaseOptions {
|
|
9
|
+
maxLength?: number;
|
|
10
|
+
}
|
|
11
|
+
/** Marks the issue from text and textarea's non-blank check (in `params.check`). */
|
|
12
|
+
export declare const NON_BLANK = "nonBlank";
|
|
13
|
+
/** The `check` param of the refinements that make a date or datetime field reject a malformed value. */
|
|
14
|
+
export declare const DATE_CHECK = "date";
|
|
15
|
+
export declare const DATETIME_CHECK = "datetime";
|
|
16
|
+
export declare const f: {
|
|
17
|
+
text: (o: TextOptions) => z.ZodString;
|
|
18
|
+
textarea: (o: TextOptions) => z.ZodString;
|
|
19
|
+
number(o: BaseOptions & {
|
|
20
|
+
min?: number;
|
|
21
|
+
max?: number;
|
|
22
|
+
integer?: boolean;
|
|
23
|
+
}): z.ZodNumber;
|
|
24
|
+
boolean: (o: BaseOptions) => z.ZodDefault<z.ZodBoolean>;
|
|
25
|
+
select<const T extends readonly [string, ...string[]]>(options: T, o: BaseOptions): z.ZodEnum<{ [k in T[number]]: k; } extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never>;
|
|
26
|
+
date: (o: BaseOptions) => z.ZodString;
|
|
27
|
+
datetime: (o: BaseOptions) => z.ZodString;
|
|
28
|
+
link(o: BaseOptions): z.ZodUnion<readonly [z.ZodObject<{
|
|
29
|
+
document: z.ZodUUID;
|
|
30
|
+
text: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
32
|
+
url: z.ZodString;
|
|
33
|
+
text: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, z.core.$strip>]>;
|
|
35
|
+
ref(collection: string, o: BaseOptions & {
|
|
36
|
+
many?: boolean;
|
|
37
|
+
min?: number;
|
|
38
|
+
max?: number;
|
|
39
|
+
}): z.ZodArray<z.ZodUUID> | z.ZodUUID;
|
|
40
|
+
image(o: BaseOptions): z.ZodObject<{
|
|
41
|
+
media: z.ZodString;
|
|
42
|
+
alt: z.ZodOptional<z.ZodString>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
file(o: BaseOptions): z.ZodObject<{
|
|
45
|
+
media: z.ZodString;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
richText(o: BaseOptions & {
|
|
48
|
+
features?: RichTextFeature[];
|
|
49
|
+
headings?: number[];
|
|
50
|
+
}): z.ZodPipe<z.ZodCustom<unknown, unknown>, z.ZodTransform<RichTextDoc, unknown>>;
|
|
51
|
+
list<T extends z.ZodObject>(item: T, o: BaseOptions & {
|
|
52
|
+
min?: number;
|
|
53
|
+
max?: number;
|
|
54
|
+
itemLabel?: string;
|
|
55
|
+
}): z.ZodArray<T>;
|
|
56
|
+
group<T extends z.ZodRawShape>(shape: T, o: BaseOptions & {
|
|
57
|
+
seo?: true;
|
|
58
|
+
}): z.ZodObject<{ -readonly [P in keyof T]: T[P]; }, z.core.$strip>;
|
|
59
|
+
seo(o?: {
|
|
60
|
+
label?: string;
|
|
61
|
+
}): z.ZodObject<{
|
|
62
|
+
title: z.ZodOptional<z.ZodString>;
|
|
63
|
+
description: z.ZodOptional<z.ZodString>;
|
|
64
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
65
|
+
media: z.ZodString;
|
|
66
|
+
alt: z.ZodOptional<z.ZodString>;
|
|
67
|
+
}, z.core.$strip>>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
};
|
|
70
|
+
export {};
|