alinea 2.0.0-preview.1 → 2.0.0-preview.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.init/.mcp.json +11 -0
- package/dist/.init/AGENTS.md +17 -0
- package/dist/.init/CLAUDE.md +1 -0
- package/dist/.init/content/pages/welcome.json +1 -1
- package/dist/.init/package.json +1 -1
- package/dist/.init/src/cms.ts +5 -6
- package/dist/.mcp/later/dev.json +1 -0
- package/dist/.mcp/lock/dev.json +1 -0
- package/dist/.mcp/online/dev.json +1 -0
- package/dist/LICENSES.md +2276 -250
- package/dist/adapter/next/ForwardCredentials.d.ts +1 -0
- package/dist/adapter/next/ForwardCredentials.js +17 -0
- package/dist/adapter/next/cms.d.ts +20 -6
- package/dist/adapter/next/cms.js +226 -54
- package/dist/adapter/next/context.d.ts +1 -1
- package/dist/adapter/next/context.js +15 -5
- package/dist/adapter/next/devCache.d.ts +16 -0
- package/dist/adapter/next/devCache.js +32 -0
- package/dist/adapter/next/handler.d.ts +6 -0
- package/dist/adapter/next/handler.js +121 -23
- package/dist/adapter/next/node.d.ts +5 -0
- package/dist/adapter/next/node.js +16 -0
- package/dist/adapter/next/previews.d.ts +4 -1
- package/dist/adapter/next/previews.js +20 -1
- package/dist/adapter/next/renderStats.d.ts +45 -0
- package/dist/adapter/next/renderStats.js +142 -0
- package/dist/adapter/next/syncCheck.d.ts +18 -0
- package/dist/adapter/next/syncCheck.js +53 -0
- package/dist/adapter/next/with-alinea.d.ts +0 -8
- package/dist/adapter/next/with-alinea.js +65 -46
- package/dist/adapter/vite/plugin.js +9 -4
- package/dist/backend/HandleAction.d.ts +1 -1
- package/dist/backend/HandleAction.js +1 -1
- package/dist/backend/Handler.d.ts +18 -14
- package/dist/backend/Handler.js +176 -35
- package/dist/backend/api/BasicAuth.d.ts +1 -1
- package/dist/backend/api/BasicAuth.js +14 -14
- package/dist/backend/api/CreateBackend.js +15 -3
- package/dist/backend/api/DatabaseApi.js +22 -135
- package/dist/backend/api/GithubApi.js +16 -7
- package/dist/backend/api/OAuth2.d.ts +3 -3
- package/dist/backend/api/OAuth2.js +28 -30
- package/dist/backend/api/ProxyMedia.d.ts +2 -0
- package/dist/backend/api/ProxyMedia.js +27 -0
- package/dist/backend/api/S3Uploads.d.ts +1 -1
- package/dist/backend/api/database.js +15 -3
- package/dist/backend/resolver/ParsePreview.d.ts +9 -5
- package/dist/backend/resolver/ParsePreview.js +40 -43
- package/dist/backend/router/NodeHandler.js +2 -0
- package/dist/backend/router/Router.js +2 -0
- package/dist/backend/store/GeneratedDatabase.d.ts +8 -0
- package/dist/backend/store/GeneratedDatabase.js +33 -0
- package/dist/backend/store/GeneratedDatabaseNode.d.ts +8 -0
- package/dist/backend/store/GeneratedDatabaseNode.js +25 -0
- package/dist/backend/store/GeneratedRelease.d.ts +1 -1
- package/dist/backend/store/GeneratedRelease.js +3 -4
- package/dist/backend/util/JWKS.d.ts +4 -0
- package/dist/backend/util/JWKS.js +40 -0
- package/dist/backend/util/ORM.js +4 -2
- package/dist/backend/util/Syncable.js +1 -1
- package/dist/bundled.d.ts +11657 -6061
- package/dist/chunks/bun-sqlite-5SHXN3AT.js +18 -0
- package/dist/chunks/ccitt-Y7TDCCPM.js +90 -0
- package/dist/chunks/chunk-2BJ2IFQM.js +1085 -0
- package/dist/chunks/chunk-2PIFHEYR.js +364 -0
- package/dist/chunks/chunk-66YZ47TY.js +94 -0
- package/dist/chunks/chunk-76VMZTLN.js +55 -0
- package/dist/chunks/{chunk-TL7ZW6BX.js → chunk-A3XXZBOQ.js} +2535 -2999
- package/dist/chunks/chunk-AC5ATYI3.js +1434 -0
- package/dist/chunks/chunk-AIU6CMVT.js +495 -0
- package/dist/chunks/chunk-ASYKC6IE.js +103 -0
- package/dist/chunks/chunk-ATF42T2B.js +35 -0
- package/dist/chunks/{chunk-Y7XOMJOC.js → chunk-CFNRVI3Y.js} +220 -247
- package/dist/chunks/chunk-D6UJHBJJ.js +183 -0
- package/dist/chunks/{chunk-NWQXN4SB.js → chunk-ETBQTP2S.js} +40 -29
- package/dist/chunks/chunk-ETWOY4AL.js +100 -0
- package/dist/chunks/{chunk-I7X64JTZ.js → chunk-JOF663EG.js} +6479 -3715
- package/dist/chunks/chunk-K62JP6HR.js +22 -0
- package/dist/chunks/chunk-MOWR65LM.js +610 -0
- package/dist/chunks/chunk-N47Y62CI.js +396 -0
- package/dist/chunks/{chunk-7ORQ7BYK.js → chunk-NP4M2257.js} +203 -269
- package/dist/chunks/{chunk-53DZYORR.js → chunk-PAYSVIYI.js} +76 -176
- package/dist/chunks/{chunk-IYAQC63Y.js → chunk-PSSMQKAH.js} +1607 -744
- package/dist/chunks/chunk-QBPYWU6C.js +24 -0
- package/dist/chunks/{chunk-X47OVDF3.js → chunk-QJGGYF6E.js} +356 -1000
- package/dist/chunks/chunk-QSN6RH6X.js +94 -0
- package/dist/chunks/{chunk-IWN3T3FL.js → chunk-RE523BQ7.js} +21443 -16177
- package/dist/chunks/chunk-RE6CDK2M.js +254 -0
- package/dist/chunks/chunk-TIJTT5ZI.js +228 -0
- package/dist/chunks/{chunk-I4GC3E65.js → chunk-UPY2RUZF.js} +0 -1
- package/dist/chunks/chunk-W5AXN7GH.js +219 -0
- package/dist/chunks/chunk-XCZXR3C2.js +112 -0
- package/dist/chunks/chunk-XTWYBWP2.js +81 -0
- package/dist/chunks/{chunk-FRYHNUEK.js → chunk-YCQR5GRT.js} +35 -7
- package/dist/chunks/dist-OU2RRDGP.js +7499 -0
- package/dist/chunks/jpeg-OJTBZV3C.js +292 -0
- package/dist/chunks/jpx-4VRYG2JB.js +667 -0
- package/dist/chunks/node-sqlite-XVNTNMCY.js +18 -0
- package/dist/cli/Generate.d.ts +2 -1
- package/dist/cli/Generate.js +91 -79
- package/dist/cli/Init.d.ts +43 -2
- package/dist/cli/Init.js +144 -28
- package/dist/cli/Mcp.d.ts +25 -0
- package/dist/cli/Mcp.js +106 -0
- package/dist/cli/Serve.d.ts +1 -1
- package/dist/cli/Serve.js +19 -6
- package/dist/cli/bin.js +45 -14
- package/dist/cli/generate/CopyStaticFiles.d.ts +1 -1
- package/dist/cli/generate/CopyStaticFiles.js +39 -24
- package/dist/cli/generate/DevDB.d.ts +21 -4
- package/dist/cli/generate/DevDB.js +139 -27
- package/dist/cli/generate/FillCache.d.ts +1 -1
- package/dist/cli/generate/FillCache.js +20 -9
- package/dist/cli/generate/GenerateContext.d.ts +3 -0
- package/dist/cli/generate/GenerateDashboard.d.ts +1 -1
- package/dist/cli/generate/GenerateDashboard.js +3 -1
- package/dist/cli/generate/GeneratedPaths.d.ts +21 -0
- package/dist/cli/generate/GeneratedPaths.js +33 -0
- package/dist/cli/generate/LinkMediaFiles.d.ts +7 -0
- package/dist/cli/generate/LinkMediaFiles.js +52 -0
- package/dist/cli/serve/CreateLocalServer.d.ts +3 -2
- package/dist/cli/serve/CreateLocalServer.js +106 -50
- package/dist/cli/serve/DevLock.d.ts +11 -0
- package/dist/cli/serve/DevLock.js +42 -0
- package/dist/cli/serve/DevServer.d.ts +8 -4
- package/dist/cli/serve/DevServer.js +85 -10
- package/dist/cli/serve/LiveReload.d.ts +2 -2
- package/dist/cli/serve/LiveReload.js +6 -2
- package/dist/cli/serve/LocalAuth.js +1 -1
- package/dist/cli/serve/ServeContext.d.ts +1 -1
- package/dist/cli/serve/StartServer.d.ts +3 -1
- package/dist/cli/serve/StartServer.js +10 -3
- package/dist/cli/serve/mcp/DevMcp.d.ts +16 -0
- package/dist/cli/serve/mcp/DevMcp.js +50 -0
- package/dist/cli/serve/mcp/McpGraph.d.ts +35 -0
- package/dist/cli/serve/mcp/McpGraph.js +64 -0
- package/dist/cli/serve/mcp/McpInput.d.ts +11 -0
- package/dist/cli/serve/mcp/McpInput.js +254 -0
- package/dist/cli/serve/mcp/McpInstructions.d.ts +1 -0
- package/dist/cli/serve/mcp/McpInstructions.js +16 -0
- package/dist/cli/serve/mcp/McpSchema.d.ts +31 -0
- package/dist/cli/serve/mcp/McpSchema.js +184 -0
- package/dist/cli/serve/mcp/McpServer.d.ts +47 -0
- package/dist/cli/serve/mcp/McpServer.js +112 -0
- package/dist/cli/serve/mcp/McpTools.d.ts +25 -0
- package/dist/cli/serve/mcp/McpTools.js +567 -0
- package/dist/cli/static/init/agents.md +13 -0
- package/dist/cli/static/init/cms.js +5 -6
- package/dist/cli/util/ContentType.d.ts +1 -0
- package/dist/cli/util/ContentType.js +36 -0
- package/dist/cli/util/Emitter.js +1 -1
- package/dist/cli/util/EnsureLibs.js +2 -2
- package/dist/cli/util/EnsureNode.js +2 -2
- package/dist/cli/util/ForwardCommand.js +4 -12
- package/dist/cli/util/PublicDefines.d.ts +1 -0
- package/dist/cli/util/PublicDefines.js +2 -1
- package/dist/cli/util/RunForwarded.d.ts +13 -0
- package/dist/cli/util/RunForwarded.js +166 -0
- package/dist/cli/util/WarnPublicEnv.js +2 -0
- package/dist/cloud/AuthResult.d.ts +2 -0
- package/dist/cloud/CloudHandshake.d.ts +13 -0
- package/dist/cloud/CloudHandshake.js +84 -0
- package/dist/cloud/CloudRemote.d.ts +4 -1
- package/dist/cloud/CloudRemote.js +41 -9
- package/dist/cms.d.ts +19 -0
- package/dist/cms.js +49 -0
- package/dist/components/Alert.d.ts +29 -0
- package/dist/components/Alert.js +86 -0
- package/dist/components/AppShell.d.ts +15 -0
- package/dist/components/AppShell.js +38 -0
- package/dist/components/Badge.d.ts +11 -0
- package/dist/components/Badge.js +51 -0
- package/dist/components/Blockquote.d.ts +7 -0
- package/dist/components/Blockquote.js +26 -0
- package/dist/components/Breadcrumbs.d.ts +39 -3
- package/dist/components/Breadcrumbs.js +103 -22
- package/dist/components/Button.d.ts +28 -8
- package/dist/components/Button.js +63 -22
- package/dist/components/Calendar.d.ts +28 -3
- package/dist/components/Calendar.js +162 -53
- package/dist/components/Checkbox.d.ts +18 -7
- package/dist/components/Checkbox.js +84 -38
- package/dist/components/CheckboxGroup.d.ts +11 -5
- package/dist/components/CheckboxGroup.js +55 -19
- package/dist/components/Code.d.ts +10 -0
- package/dist/components/Code.js +49 -0
- package/dist/components/Collapsible.d.ts +25 -0
- package/dist/components/Collapsible.js +146 -0
- package/dist/components/ColorSwatch.d.ts +9 -2
- package/dist/components/ColorSwatch.js +20 -20
- package/dist/components/ColorSwatchPicker.d.ts +18 -3
- package/dist/components/ColorSwatchPicker.js +29 -25
- package/dist/components/ComboBox.d.ts +27 -9
- package/dist/components/ComboBox.js +197 -99
- package/dist/components/Command.d.ts +66 -0
- package/dist/components/Command.js +236 -0
- package/dist/components/ContentCard.d.ts +30 -0
- package/dist/components/ContentCard.js +199 -0
- package/dist/components/ContentGrid.d.ts +58 -0
- package/dist/components/ContentGrid.js +220 -0
- package/dist/components/DataList.d.ts +27 -0
- package/dist/components/DataList.js +68 -0
- package/dist/components/DateField.d.ts +15 -4
- package/dist/components/DateField.js +51 -44
- package/dist/components/DatePicker.d.ts +17 -4
- package/dist/components/DatePicker.js +61 -68
- package/dist/components/DateRangePicker.d.ts +19 -4
- package/dist/components/DateRangePicker.js +69 -80
- package/dist/components/Dialog.d.ts +53 -3
- package/dist/components/Dialog.js +188 -20
- package/dist/components/DropZone.d.ts +25 -3
- package/dist/components/DropZone.js +98 -17
- package/dist/components/DropdownMenu.d.ts +78 -0
- package/dist/components/DropdownMenu.js +318 -0
- package/dist/components/Empty.d.ts +46 -0
- package/dist/components/Empty.js +93 -0
- package/dist/components/Field.d.ts +34 -0
- package/dist/components/Field.js +159 -0
- package/dist/components/FileTrigger.d.ts +21 -0
- package/dist/components/FileTrigger.js +53 -0
- package/dist/components/FoldIcon.js +2 -1
- package/dist/components/Heading.d.ts +13 -0
- package/dist/components/Heading.js +48 -0
- package/dist/components/Icon.d.ts +1 -1
- package/dist/components/Icon.js +3 -3
- package/dist/components/Kbd.d.ts +8 -0
- package/dist/components/Kbd.js +27 -0
- package/dist/components/Link.d.ts +14 -4
- package/dist/components/Link.js +22 -20
- package/dist/components/List.d.ts +20 -63
- package/dist/components/List.js +126 -247
- package/dist/components/MediaPreview.d.ts +35 -0
- package/dist/components/MediaPreview.js +227 -0
- package/dist/components/MultipleSelect.d.ts +22 -20
- package/dist/components/MultipleSelect.js +234 -216
- package/dist/components/NavRail.d.ts +41 -0
- package/dist/components/NavRail.js +121 -0
- package/dist/components/NumberField.d.ts +19 -4
- package/dist/components/NumberField.js +105 -54
- package/dist/components/Page.d.ts +57 -0
- package/dist/components/Page.js +130 -0
- package/dist/components/Popover.d.ts +39 -5
- package/dist/components/Popover.js +146 -22
- package/dist/components/PreviewFrame.d.ts +46 -0
- package/dist/components/PreviewFrame.js +182 -0
- package/dist/components/RadioGroup.d.ts +20 -7
- package/dist/components/RadioGroup.js +122 -32
- package/dist/components/Resizable.d.ts +51 -0
- package/dist/components/Resizable.js +1349 -0
- package/dist/components/SearchField.d.ts +37 -6
- package/dist/components/SearchField.js +116 -57
- package/dist/components/Select.d.ts +35 -10
- package/dist/components/Select.js +189 -97
- package/dist/components/Sidebar.d.ts +56 -0
- package/dist/components/Sidebar.js +136 -0
- package/dist/components/SortableList.d.ts +80 -0
- package/dist/components/SortableList.js +471 -0
- package/dist/components/Spinner.d.ts +8 -0
- package/dist/components/Spinner.js +86 -0
- package/dist/components/Surface.js +11 -1
- package/dist/components/Switch.d.ts +15 -4
- package/dist/components/Switch.js +31 -19
- package/dist/components/Table.d.ts +107 -14
- package/dist/components/Table.js +470 -100
- package/dist/components/Tabs.d.ts +33 -12
- package/dist/components/Tabs.js +68 -51
- package/dist/components/TagGroup.d.ts +26 -9
- package/dist/components/TagGroup.js +98 -32
- package/dist/components/Text.d.ts +16 -0
- package/dist/components/Text.js +44 -0
- package/dist/components/TextField.d.ts +27 -9
- package/dist/components/TextField.js +143 -47
- package/dist/components/TimeField.d.ts +20 -4
- package/dist/components/TimeField.js +76 -24
- package/dist/components/Timestamp.d.ts +17 -0
- package/dist/components/Timestamp.js +131 -0
- package/dist/components/Toggle.d.ts +15 -7
- package/dist/components/Toggle.js +4 -54
- package/dist/components/ToggleGroup.d.ts +33 -0
- package/dist/components/ToggleGroup.js +90 -0
- package/dist/components/Toolbar.d.ts +27 -8
- package/dist/components/Toolbar.js +50 -39
- package/dist/components/Tooltip.d.ts +22 -4
- package/dist/components/Tooltip.js +77 -34
- package/dist/components/Tree.d.ts +48 -18
- package/dist/components/Tree.js +228 -82
- package/dist/components/internal/Accept.d.ts +5 -0
- package/dist/components/internal/Accept.js +17 -0
- package/dist/components/internal/DateControl.d.ts +18 -0
- package/dist/components/internal/DateControl.js +92 -0
- package/dist/components/internal/DateValue.d.ts +16 -0
- package/dist/components/internal/DateValue.js +40 -0
- package/dist/components/internal/ListBoxOption.d.ts +20 -0
- package/dist/components/internal/ListBoxOption.js +111 -0
- package/dist/components/internal/Locale.d.ts +7 -0
- package/dist/components/internal/Locale.js +18 -0
- package/dist/components/internal/Placement.d.ts +3 -0
- package/dist/components/internal/Placement.js +13 -0
- package/dist/components/internal/PopoverSurface.d.ts +21 -0
- package/dist/components/internal/PopoverSurface.js +66 -0
- package/dist/components/internal/SelectionCheckbox.d.ts +8 -0
- package/dist/components/internal/SelectionCheckbox.js +57 -0
- package/dist/components/internal/Slot.d.ts +7 -0
- package/dist/components/internal/Slot.js +26 -0
- package/dist/components/internal/ToggleButton.d.ts +26 -0
- package/dist/components/internal/ToggleButton.js +68 -0
- package/dist/components/internal/Trigger.d.ts +16 -0
- package/dist/components/internal/Trigger.js +34 -0
- package/dist/components/internal/useDragDrop.d.ts +22 -0
- package/dist/components/internal/useDragDrop.js +110 -0
- package/dist/components/types.d.ts +106 -0
- package/dist/components/types.js +0 -0
- package/dist/components.d.ts +29 -5
- package/dist/components.js +28 -5
- package/dist/config.d.ts +1 -0
- package/dist/config.js +2 -0
- package/dist/core/Client.d.ts +1 -4
- package/dist/core/Client.js +8 -9
- package/dist/core/Config.d.ts +26 -3
- package/dist/core/Config.js +24 -2
- package/dist/core/Connection.d.ts +27 -9
- package/dist/core/Connection.js +17 -0
- package/dist/core/Document.d.ts +2 -2
- package/dist/core/Document.js +15 -3
- package/dist/core/Entry.d.ts +9 -0
- package/dist/core/Entry.js +14 -0
- package/dist/core/EntryFields.d.ts +5 -0
- package/dist/core/EntrySeed.d.ts +23 -0
- package/dist/core/EntrySeed.js +135 -0
- package/dist/core/Expr.d.ts +11 -0
- package/dist/core/Field.d.ts +28 -1
- package/dist/core/Field.js +23 -0
- package/dist/core/Filter.d.ts +53 -2
- package/dist/core/Filter.js +145 -0
- package/dist/core/Graph.d.ts +35 -13
- package/dist/core/Id.d.ts +1 -0
- package/dist/core/Id.js +8 -0
- package/dist/core/Infer.d.ts +25 -1
- package/dist/core/ListRow.d.ts +3 -0
- package/dist/core/ListRow.js +1 -0
- package/dist/core/OrderBy.d.ts +7 -3
- package/dist/core/Overview.d.ts +242 -0
- package/dist/core/Overview.js +47 -0
- package/dist/core/Reference.d.ts +1 -0
- package/dist/core/Role.d.ts +6 -1
- package/dist/core/Role.js +69 -65
- package/dist/core/Root.d.ts +18 -2
- package/dist/core/Root.js +11 -3
- package/dist/core/Scope.d.ts +4 -0
- package/dist/core/Scope.js +51 -2
- package/dist/core/TextDoc.d.ts +24 -1
- package/dist/core/TextDoc.js +1 -0
- package/dist/core/Trace.d.ts +8 -0
- package/dist/core/Trace.js +32 -0
- package/dist/core/Type.d.ts +42 -8
- package/dist/core/Type.js +48 -9
- package/dist/core/Validation.d.ts +56 -0
- package/dist/core/Validation.js +121 -0
- package/dist/core/Workspace.d.ts +7 -5
- package/dist/core/Workspace.js +5 -1
- package/dist/core/db/CommitRequest.d.ts +0 -3
- package/dist/core/db/CommitRequest.js +0 -9
- package/dist/core/db/EntryAliases.js +2 -15
- package/dist/core/db/EntryReference.d.ts +8 -7
- package/dist/core/db/EntryUrlConflictError.js +1 -1
- package/dist/core/db/EntryValidationError.d.ts +13 -0
- package/dist/core/db/EntryValidationError.js +23 -0
- package/dist/core/db/IndexEvent.d.ts +2 -1
- package/dist/core/db/IndexEvent.js +11 -3
- package/dist/core/db/LinkResolver.d.ts +13 -7
- package/dist/core/db/LinkResolver.js +0 -30
- package/dist/core/db/LocalStore.d.ts +27 -0
- package/dist/core/db/LocalStore.js +0 -0
- package/dist/core/db/Operation.d.ts +24 -3
- package/dist/core/db/Operation.js +119 -26
- package/dist/core/db/WriteableGraph.d.ts +5 -0
- package/dist/core/field/CreateField.d.ts +1 -1
- package/dist/core/field/ListField.js +44 -8
- package/dist/core/field/RecordField.js +16 -2
- package/dist/core/field/RichTextField.d.ts +30 -3
- package/dist/core/field/RichTextField.js +233 -64
- package/dist/core/field/ScalarField.d.ts +2 -2
- package/dist/core/field/UnionField.js +32 -2
- package/dist/core/media/CompressPdf.browser.d.ts +5 -0
- package/dist/core/media/CompressPdf.browser.js +13 -0
- package/dist/core/media/CompressPdf.d.ts +6 -0
- package/dist/core/media/CompressPdf.js +45 -0
- package/dist/core/media/CreatePreview.browser.d.ts +5 -1
- package/dist/core/media/CreatePreview.browser.js +16 -0
- package/dist/core/media/CreatePreview.d.ts +2 -1
- package/dist/core/media/CreatePreview.js +2 -0
- package/dist/core/media/FileKinds.d.ts +10 -0
- package/dist/core/media/FileKinds.js +25 -0
- package/dist/core/media/ImageTransform.d.ts +78 -0
- package/dist/core/media/ImageTransform.js +108 -0
- package/dist/core/media/MediaAltField.d.ts +1 -0
- package/dist/core/media/MediaAltField.js +9 -1
- package/dist/core/media/MediaLocation.d.ts +9 -15
- package/dist/core/media/MediaLocation.js +29 -19
- package/dist/core/media/MediaRoot.js +2 -0
- package/dist/core/media/MediaTypes.d.ts +14 -10
- package/dist/core/media/MediaTypes.js +158 -34
- package/dist/core/media/Pdf.d.ts +15 -0
- package/dist/core/media/Pdf.js +31 -0
- package/dist/core/media/TransformImage.browser.d.ts +7 -0
- package/dist/core/media/TransformImage.browser.js +38 -0
- package/dist/core/media/TransformImage.d.ts +7 -0
- package/dist/core/media/TransformImage.js +38 -0
- package/dist/core/source/FSSource.d.ts +14 -2
- package/dist/core/source/FSSource.js +58 -13
- package/dist/core/source/GitUtils.d.ts +4 -0
- package/dist/core/source/GitUtils.js +9 -10
- package/dist/core/source/GithubSource.js +60 -21
- package/dist/core/source/IndexedDBSource.d.ts +2 -1
- package/dist/core/source/IndexedDBSource.js +67 -53
- package/dist/core/source/MemorySource.js +5 -3
- package/dist/core/source/OverlaySource.d.ts +15 -0
- package/dist/core/source/OverlaySource.js +78 -0
- package/dist/core/source/Source.d.ts +4 -1
- package/dist/core/source/Source.js +18 -5
- package/dist/core/source/Tree.d.ts +10 -7
- package/dist/core/source/Tree.js +118 -70
- package/dist/core/source/Utils.js +6 -3
- package/dist/core/text/MarkdownToTextDoc.d.ts +29 -0
- package/dist/core/text/MarkdownToTextDoc.js +524 -0
- package/dist/core/text/TextDocToMarkdown.d.ts +20 -0
- package/dist/core/text/TextDocToMarkdown.js +316 -0
- package/dist/core/util/Arrays.d.ts +1 -0
- package/dist/core/util/Arrays.js +10 -0
- package/dist/core/util/Async.d.ts +7 -0
- package/dist/core/util/Async.js +15 -0
- package/dist/core/util/Checks.js +1 -1
- package/dist/core/util/EntryFilenames.d.ts +22 -1
- package/dist/core/util/EntryFilenames.js +56 -2
- package/dist/core/util/IndexedDB.d.ts +4 -0
- package/dist/core/util/IndexedDB.js +20 -0
- package/dist/core/util/JWT.d.ts +1 -1
- package/dist/core/util/Objects.d.ts +2 -0
- package/dist/core/util/Objects.js +7 -0
- package/dist/core/util/OrderKeys.d.ts +11 -0
- package/dist/core/util/OrderKeys.js +64 -0
- package/dist/core/util/Paths.js +5 -1
- package/dist/core.d.ts +3 -0
- package/dist/core.js +8 -1
- package/dist/dashboard/App.css +202 -76
- package/dist/dashboard/App.d.ts +3 -0
- package/dist/dashboard/App.js +56 -32
- package/dist/dashboard/StoryProvider.js +2 -2
- package/dist/dashboard/ViewKeys.d.ts +2 -0
- package/dist/dashboard/ViewKeys.js +2 -0
- package/dist/dashboard/app/AccessDenied.d.ts +16 -1
- package/dist/dashboard/app/AccessDenied.js +42 -25
- package/dist/dashboard/app/ActivityStatus.d.ts +5 -4
- package/dist/dashboard/app/ActivityStatus.js +122 -165
- package/dist/dashboard/app/AppearanceToggle.d.ts +1 -0
- package/dist/dashboard/app/AppearanceToggle.js +62 -0
- package/dist/dashboard/app/AuthView.d.ts +1 -1
- package/dist/dashboard/app/AuthView.js +79 -69
- package/dist/dashboard/app/CompactField.d.ts +19 -6
- package/dist/dashboard/app/CompactField.js +174 -48
- package/dist/dashboard/app/CroppedImage.d.ts +17 -0
- package/dist/dashboard/app/CroppedImage.js +73 -0
- package/dist/dashboard/app/DashboardErrorBoundary.js +44 -20
- package/dist/dashboard/app/DashboardLayout.d.ts +4 -2
- package/dist/dashboard/app/DashboardLayout.js +53 -34
- package/dist/dashboard/app/DashboardMeta.d.ts +2 -1
- package/dist/dashboard/app/DashboardMeta.js +20 -5
- package/dist/dashboard/app/DeleteDialog.d.ts +11 -0
- package/dist/dashboard/app/DeleteDialog.js +249 -0
- package/dist/dashboard/app/EntryFields.d.ts +12 -10
- package/dist/dashboard/app/EntryFields.js +15 -23
- package/dist/dashboard/app/EntryHeader.d.ts +2 -2
- package/dist/dashboard/app/EntryHeader.js +319 -214
- package/dist/dashboard/app/EntryHeaderActions.d.ts +24 -4
- package/dist/dashboard/app/EntryHeaderActions.js +46 -29
- package/dist/dashboard/app/EntryReferences.d.ts +13 -1
- package/dist/dashboard/app/EntryReferences.js +64 -62
- package/dist/dashboard/app/EntrySidebar.d.ts +8 -6
- package/dist/dashboard/app/EntrySidebar.js +111 -92
- package/dist/dashboard/app/EntrySidebarPreview.d.ts +5 -2
- package/dist/dashboard/app/EntrySidebarPreview.js +92 -129
- package/dist/dashboard/app/EntrySidebarPreview.story.d.ts +6 -1
- package/dist/dashboard/app/EntrySidebarToggle.js +5 -6
- package/dist/dashboard/app/EntryTranslationBanner.d.ts +3 -1
- package/dist/dashboard/app/EntryTranslationBanner.js +40 -45
- package/dist/dashboard/app/EntryValidationModal.d.ts +12 -0
- package/dist/dashboard/app/EntryValidationModal.js +77 -0
- package/dist/dashboard/app/Explorer.d.ts +15 -6
- package/dist/dashboard/app/Explorer.js +318 -354
- package/dist/dashboard/app/ExplorerBatchActions.d.ts +17 -0
- package/dist/dashboard/app/ExplorerBatchActions.js +158 -0
- package/dist/dashboard/app/ExplorerCards.d.ts +8 -3
- package/dist/dashboard/app/ExplorerCards.js +106 -314
- package/dist/dashboard/app/ExplorerControls.d.ts +20 -0
- package/dist/dashboard/app/ExplorerControls.js +170 -0
- package/dist/dashboard/app/ExplorerList.d.ts +7 -4
- package/dist/dashboard/app/ExplorerList.js +167 -103
- package/dist/dashboard/app/ExplorerModal.d.ts +2 -5
- package/dist/dashboard/app/ExplorerModal.js +6 -18
- package/dist/dashboard/app/ExplorerPickerContent.d.ts +19 -3
- package/dist/dashboard/app/ExplorerPickerContent.js +89 -7
- package/dist/dashboard/app/ExplorerTable.d.ts +8 -4
- package/dist/dashboard/app/ExplorerTable.js +159 -371
- package/dist/dashboard/app/ExternalLinkPicker.js +49 -48
- package/dist/dashboard/app/FileKind.d.ts +8 -0
- package/dist/dashboard/app/FileKind.js +40 -0
- package/dist/dashboard/app/ImageEditor.d.ts +13 -0
- package/dist/dashboard/app/ImageEditor.js +302 -0
- package/dist/dashboard/app/ImageEditorCrop.d.ts +19 -0
- package/dist/dashboard/app/ImageEditorCrop.js +90 -0
- package/dist/dashboard/app/ImagePicker.d.ts +1 -1
- package/dist/dashboard/app/ImagePicker.js +38 -87
- package/dist/dashboard/app/LinkPicker.d.ts +1 -1
- package/dist/dashboard/app/LinkPicker.js +124 -127
- package/dist/dashboard/app/LocaleMenu.d.ts +10 -1
- package/dist/dashboard/app/LocaleMenu.js +78 -53
- package/dist/dashboard/app/MediaPreviewCell.d.ts +8 -0
- package/dist/dashboard/app/MediaPreviewCell.js +50 -0
- package/dist/dashboard/app/MoveDialog.d.ts +10 -0
- package/dist/dashboard/app/MoveDialog.js +161 -0
- package/dist/dashboard/app/NodeEditor.d.ts +11 -0
- package/dist/dashboard/app/NodeEditor.js +13 -0
- package/dist/dashboard/app/OverviewCell.d.ts +15 -0
- package/dist/dashboard/app/OverviewCell.js +251 -0
- package/dist/dashboard/app/PendingUploadsDialog.d.ts +2 -0
- package/dist/dashboard/app/PendingUploadsDialog.js +49 -0
- package/dist/dashboard/app/PendingUploadsView.d.ts +19 -0
- package/dist/dashboard/app/PendingUploadsView.js +209 -0
- package/dist/dashboard/app/ReadOnlyBadge.d.ts +4 -0
- package/dist/dashboard/app/ReadOnlyBadge.js +33 -0
- package/dist/dashboard/app/SidebarLayout.d.ts +9 -0
- package/dist/dashboard/app/SidebarLayout.js +64 -0
- package/dist/dashboard/app/SidebarTree.d.ts +14 -11
- package/dist/dashboard/app/SidebarTree.js +268 -265
- package/dist/dashboard/app/ViewToggle.d.ts +1 -1
- package/dist/dashboard/app/ViewToggle.js +17 -10
- package/dist/dashboard/app/WorkspaceMenu.d.ts +11 -5
- package/dist/dashboard/app/WorkspaceMenu.js +123 -137
- package/dist/dashboard/app/WorkspaceRoots.d.ts +1 -1
- package/dist/dashboard/app/WorkspaceRoots.js +131 -188
- package/dist/dashboard/app/editor/FileEditor.d.ts +2 -3
- package/dist/dashboard/app/editor/FileEditor.js +125 -123
- package/dist/dashboard/app/editor/FilePreview.d.ts +5 -6
- package/dist/dashboard/app/editor/FilePreview.js +13 -138
- package/dist/dashboard/app/editor/MediaAltField.view.d.ts +1 -1
- package/dist/dashboard/app/editor/MediaAltField.view.js +14 -17
- package/dist/dashboard/app/modals/CreateEntry.js +108 -116
- package/dist/dashboard/app/pages/EntryPage.js +176 -91
- package/dist/dashboard/app/pages/RootPage.js +8 -10
- package/dist/dashboard/app/pages/SplashPage.d.ts +22 -0
- package/dist/dashboard/app/pages/SplashPage.js +414 -0
- package/dist/dashboard/app/pages/UsersPage.d.ts +20 -1
- package/dist/dashboard/app/pages/UsersPage.js +186 -259
- package/dist/dashboard/app/ui/DashboardModal.d.ts +18 -12
- package/dist/dashboard/app/ui/DashboardModal.js +54 -70
- package/dist/dashboard/atoms/ReactiveNode.js +59 -20
- package/dist/dashboard/atoms/activity.d.ts +0 -2
- package/dist/dashboard/atoms/activity.js +6 -13
- package/dist/dashboard/atoms/auth.d.ts +2 -0
- package/dist/dashboard/atoms/auth.js +10 -4
- package/dist/dashboard/atoms/config.d.ts +7 -5
- package/dist/dashboard/atoms/config.js +1 -1
- package/dist/dashboard/atoms/core.d.ts +16 -2
- package/dist/dashboard/atoms/core.js +20 -8
- package/dist/dashboard/atoms/create.js +4 -8
- package/dist/dashboard/atoms/dashboard.d.ts +14 -0
- package/dist/dashboard/atoms/dashboard.js +23 -3
- package/dist/dashboard/atoms/delete.d.ts +68 -0
- package/dist/dashboard/atoms/delete.js +143 -0
- package/dist/dashboard/atoms/editor.d.ts +8 -1
- package/dist/dashboard/atoms/editor.js +22 -35
- package/dist/dashboard/atoms/entry.d.ts +46 -55
- package/dist/dashboard/atoms/entry.js +364 -205
- package/dist/dashboard/atoms/entryTable.d.ts +10 -0
- package/dist/dashboard/atoms/entryTable.js +42 -0
- package/dist/dashboard/atoms/explorer.d.ts +179 -38
- package/dist/dashboard/atoms/explorer.js +564 -250
- package/dist/dashboard/atoms/graph.d.ts +1 -0
- package/dist/dashboard/atoms/graph.js +7 -2
- package/dist/dashboard/atoms/link.d.ts +3 -1
- package/dist/dashboard/atoms/link.js +43 -56
- package/dist/dashboard/atoms/move.d.ts +59 -0
- package/dist/dashboard/atoms/move.js +103 -0
- package/dist/dashboard/atoms/nav.d.ts +19 -4
- package/dist/dashboard/atoms/nav.js +107 -18
- package/dist/dashboard/atoms/overview.d.ts +203 -0
- package/dist/dashboard/atoms/overview.js +503 -0
- package/dist/dashboard/atoms/preview.d.ts +3 -0
- package/dist/dashboard/atoms/preview.js +19 -2
- package/dist/dashboard/atoms/root.d.ts +52 -24
- package/dist/dashboard/atoms/root.js +350 -180
- package/dist/dashboard/atoms/upload.d.ts +92 -3
- package/dist/dashboard/atoms/upload.js +245 -13
- package/dist/dashboard/atoms/user.d.ts +1 -1
- package/dist/dashboard/atoms/user.js +8 -6
- package/dist/dashboard/atoms/utils.d.ts +12 -4
- package/dist/dashboard/atoms/utils.js +36 -3
- package/dist/dashboard/boot/ActivityEvent.d.ts +1 -1
- package/dist/dashboard/boot/Boot.d.ts +2 -0
- package/dist/dashboard/boot/Boot.js +13 -13
- package/dist/dashboard/boot/BootDev.js +13 -10
- package/dist/dashboard/boot/BootProd.js +1 -0
- package/dist/dashboard/boot/DashboardWorker.d.ts +3 -3
- package/dist/dashboard/boot/DashboardWorker.js +115 -80
- package/dist/dashboard/boot/LoadWorker.js +3 -4
- package/dist/dashboard/boot/WorkerDB.d.ts +2 -2
- package/dist/dashboard/cms/EntryTable.d.ts +55 -0
- package/dist/dashboard/cms/EntryTable.js +265 -0
- package/dist/dashboard/cms/FieldChrome.d.ts +21 -0
- package/dist/dashboard/cms/FieldChrome.js +26 -0
- package/dist/dashboard/cms/ViewProps.d.ts +41 -0
- package/dist/dashboard/cms/ViewProps.js +0 -0
- package/dist/dashboard/cms/hooks.d.ts +104 -0
- package/dist/dashboard/cms/hooks.js +107 -0
- package/dist/dashboard/contexts.d.ts +58 -0
- package/dist/dashboard/contexts.js +42 -0
- package/dist/dashboard/editor/UseField.d.ts +29 -6
- package/dist/dashboard/editor/UseField.js +6 -6
- package/dist/dashboard/fixture/cms.d.ts +14 -2
- package/dist/dashboard/fixture/cms.js +54 -6
- package/dist/dashboard/hook/UseEntryEditor.d.ts +3 -0
- package/dist/dashboard/hook/UseGraph.d.ts +3 -1
- package/dist/dashboard/hook/UseGraph.js +4 -4
- package/dist/dashboard/hook/UseLocale.d.ts +3 -1
- package/dist/dashboard/hook/UseRoot.d.ts +3 -1
- package/dist/dashboard/hook/UseRoot.js +4 -4
- package/dist/dashboard/hook/UseSaveShortcut.d.ts +1 -0
- package/dist/dashboard/hook/UseSaveShortcut.js +24 -0
- package/dist/dashboard/hook/UseSearchShortcut.d.ts +11 -0
- package/dist/dashboard/hook/UseSearchShortcut.js +32 -0
- package/dist/dashboard/hook/UseWorkspace.d.ts +3 -1
- package/dist/dashboard/hooks.d.ts +20 -100
- package/dist/dashboard/hooks.js +39 -101
- package/dist/dashboard/icons.d.ts +12 -0
- package/dist/dashboard/icons.js +140 -0
- package/dist/dashboard/plugins/alineaFixturePlugin.js +14 -3
- package/dist/dashboard.d.ts +23 -1
- package/dist/dashboard.js +5 -2
- package/dist/database/BrowserEntryStore.d.ts +47 -0
- package/dist/database/BrowserEntryStore.js +190 -0
- package/dist/database/DatabaseSource.d.ts +13 -0
- package/dist/database/DatabaseSource.js +25 -0
- package/dist/database/DatabaseTables.d.ts +38 -0
- package/dist/database/DatabaseTables.js +53 -0
- package/dist/database/EntryDatabase.d.ts +97 -0
- package/dist/database/EntryDatabase.js +532 -0
- package/dist/database/EntryStore.d.ts +58 -0
- package/dist/database/EntryStore.js +230 -0
- package/dist/database/EntryTransaction.d.ts +28 -0
- package/dist/database/EntryTransaction.js +1052 -0
- package/dist/database/EntryUrlAliases.d.ts +2 -0
- package/dist/database/EntryUrlAliases.js +69 -0
- package/dist/database/LocalDB.d.ts +39 -0
- package/dist/database/LocalDB.js +79 -0
- package/dist/database/Version.d.ts +9 -0
- package/dist/database/Version.js +13 -0
- package/dist/database/driver/DatabaseHandle.d.ts +17 -0
- package/dist/database/driver/DatabaseHandle.js +0 -0
- package/dist/database/driver/OverlayExtension.browser.d.ts +2 -0
- package/dist/database/driver/OverlayExtension.browser.js +9 -0
- package/dist/database/driver/OverlayExtension.d.ts +1 -0
- package/dist/database/driver/OverlayExtension.js +7 -0
- package/dist/database/driver/RuntimeDatabase.d.ts +13 -0
- package/dist/database/driver/RuntimeDatabase.js +77 -0
- package/dist/database/driver/WasmDatabase.d.ts +29 -0
- package/dist/database/driver/WasmDatabase.js +48 -0
- package/dist/database/entry/EntryData.d.ts +13 -0
- package/dist/database/entry/EntryData.js +51 -0
- package/dist/database/entry/EntryTable.d.ts +189 -0
- package/dist/database/entry/EntryTable.js +193 -0
- package/dist/database/query/Condition.d.ts +13 -0
- package/dist/database/query/Condition.js +125 -0
- package/dist/database/query/EntryQuery.d.ts +48 -0
- package/dist/database/query/EntryQuery.js +446 -0
- package/dist/database/query/EntryReferences.d.ts +5 -0
- package/dist/database/query/EntryReferences.js +71 -0
- package/dist/database/query/Relation.d.ts +11 -0
- package/dist/database/query/Relation.js +123 -0
- package/dist/database/query/ResolveQuery.d.ts +12 -0
- package/dist/database/query/ResolveQuery.js +191 -0
- package/dist/database/query/Search.d.ts +41 -0
- package/dist/database/query/Search.js +177 -0
- package/dist/database/sync/Derive.d.ts +8 -0
- package/dist/database/sync/Derive.js +274 -0
- package/dist/database/sync/EntryParser.d.ts +8 -0
- package/dist/database/sync/EntryParser.js +91 -0
- package/dist/database/sync/EntrySyncer.d.ts +25 -0
- package/dist/database/sync/EntrySyncer.js +89 -0
- package/dist/database/sync/Ingest.d.ts +21 -0
- package/dist/database/sync/Ingest.js +146 -0
- package/dist/database/sync/SyncQueries.d.ts +161 -0
- package/dist/database/sync/SyncQueries.js +216 -0
- package/dist/field/check/CheckField.js +3 -1
- package/dist/field/check/CheckField.view.js +10 -9
- package/dist/field/code/CodeField.d.ts +9 -0
- package/dist/field/code/CodeField.view.d.ts +3 -1
- package/dist/field/code/CodeField.view.js +29 -20
- package/dist/field/code/SimpleCodeEditor.js +0 -18
- package/dist/field/date/DateField.view.js +7 -13
- package/dist/field/link/EntryLink.d.ts +1 -1
- package/dist/field/link/EntryLink.js +1 -0
- package/dist/field/link/FileLink.d.ts +3 -0
- package/dist/field/link/FileLink.js +1 -7
- package/dist/field/link/ImageLink.d.ts +3 -0
- package/dist/field/link/ImageLink.js +2 -3
- package/dist/field/link/Link.js +3 -2
- package/dist/field/link/LinkField.d.ts +10 -5
- package/dist/field/link/LinkField.js +25 -0
- package/dist/field/link/LinkField.view.js +493 -506
- package/dist/field/link/UrlLink.d.ts +1 -0
- package/dist/field/link.d.ts +1 -0
- package/dist/field/list/ListField.d.ts +10 -4
- package/dist/field/list/ListField.js +10 -5
- package/dist/field/list/ListField.view.js +376 -547
- package/dist/field/localiser/LocalisedField.view.js +19 -19
- package/dist/field/localiser/LocalisedFieldTab.d.ts +7 -0
- package/dist/field/localiser/LocalisedFieldTab.js +30 -0
- package/dist/field/localiser/LocalisedFieldTabs.js +5 -5
- package/dist/field/localiser/Localiser.js +25 -7
- package/dist/field/localiser/SelectLocale.d.ts +5 -0
- package/dist/field/localiser/SelectLocale.js +12 -0
- package/dist/field/metadata/MetadataAudit.d.ts +39 -0
- package/dist/field/metadata/MetadataAudit.js +124 -0
- package/dist/field/metadata/MetadataField.d.ts +30 -23
- package/dist/field/metadata/MetadataField.js +48 -104
- package/dist/field/metadata/MetadataField.view.d.ts +5 -0
- package/dist/field/metadata/MetadataField.view.js +48 -32
- package/dist/field/number/NumberField.d.ts +2 -0
- package/dist/field/number/NumberField.view.js +10 -9
- package/dist/field/object/ObjectField.view.js +15 -19
- package/dist/field/path/PathField.view.js +3 -3
- package/dist/field/path/SlugField.d.ts +1 -2
- package/dist/field/path/SlugField.js +5 -7
- package/dist/field/richtext/PickTextAnchor.js +10 -10
- package/dist/field/richtext/PickTextLink.d.ts +10 -1
- package/dist/field/richtext/PickTextLink.js +125 -22
- package/dist/field/richtext/ReferenceLink.d.ts +6 -1
- package/dist/field/richtext/ReferenceLink.js +23 -4
- package/dist/field/richtext/RichTextBlock.js +51 -46
- package/dist/field/richtext/RichTextBlocks.js +1 -1
- package/dist/field/richtext/RichTextDocument.d.ts +7 -2
- package/dist/field/richtext/RichTextDocument.js +43 -6
- package/dist/field/richtext/RichTextExtensions.d.ts +3 -1
- package/dist/field/richtext/RichTextExtensions.js +2722 -7475
- package/dist/field/richtext/RichTextField.d.ts +7 -0
- package/dist/field/richtext/RichTextField.story.d.ts +4 -0
- package/dist/field/richtext/RichTextField.view.js +66 -34
- package/dist/field/richtext/RichTextInsertMenu.js +304 -525
- package/dist/field/richtext/RichTextState.js +1 -1
- package/dist/field/richtext/RichTextToolbar.d.ts +5 -2
- package/dist/field/richtext/RichTextToolbar.js +95 -37
- package/dist/field/richtext/Toolbar.d.ts +19 -1
- package/dist/field/richtext/Toolbar.js +18 -13
- package/dist/field/richtext/extensions/Anchor.js +1 -1
- package/dist/field/richtext/extensions/Link.d.ts +1 -0
- package/dist/field/richtext/extensions/Link.js +2 -1
- package/dist/field/richtext/extensions/Small.js +1 -1
- package/dist/field/richtext.d.ts +2 -0
- package/dist/field/richtext.js +2 -0
- package/dist/field/select/SelectField.view.js +20 -83
- package/dist/field/tabs/Tabs.view.js +8 -8
- package/dist/field/text/TextField.view.js +11 -10
- package/dist/field/time/TimeField.d.ts +0 -2
- package/dist/field/time/TimeField.view.js +10 -18
- package/dist/field/views.js +4 -0
- package/dist/field.d.ts +1 -1
- package/dist/field.js +1 -1
- package/dist/index.css +5412 -4968
- package/dist/next.cjs +118 -46
- package/dist/next.d.ts +4 -2
- package/dist/next.edge.d.ts +3 -2
- package/dist/next.js +1 -2
- package/dist/picker/entry/EntryPicker.d.ts +7 -3
- package/dist/picker/entry/EntryPicker.js +12 -13
- package/dist/picker/entry/EntryReference.d.ts +2 -0
- package/dist/picker/entry/EntryReference.js +1 -0
- package/dist/picker/url/UrlPicker.js +1 -0
- package/dist/preview/PreviewMessage.d.ts +3 -0
- package/dist/preview/PreviewMessage.js +1 -0
- package/dist/preview/RegisterPreview.d.ts +1 -1
- package/dist/preview/RegisterPreview.js +28 -10
- package/dist/preview/react.d.ts +5 -1
- package/dist/preview/react.js +12 -9
- package/dist/preview/widget.d.ts +45 -0
- package/dist/preview/widget.js +100 -11
- package/dist/query.d.ts +16 -225
- package/dist/types.d.ts +6 -3
- package/dist/ui/RichText.d.ts +1 -0
- package/dist/ui/RichText.js +62 -20
- package/docs/ai-agents.md +316 -0
- package/docs/ai-setup.md +297 -0
- package/docs/cli.md +94 -0
- package/docs/components/alert.md +122 -0
- package/docs/components/app-shell.md +77 -0
- package/docs/components/badge.md +88 -0
- package/docs/components/blockquote.md +24 -0
- package/docs/components/breadcrumb.md +83 -0
- package/docs/components/button.md +141 -0
- package/docs/components/calendar.md +32 -0
- package/docs/components/checkbox-group.md +38 -0
- package/docs/components/checkbox.md +61 -0
- package/docs/components/code.md +37 -0
- package/docs/components/collapsible.md +53 -0
- package/docs/components/color-swatch-picker.md +47 -0
- package/docs/components/combo-box.md +57 -0
- package/docs/components/command.md +101 -0
- package/docs/components/content-card.md +63 -0
- package/docs/components/content-grid.md +71 -0
- package/docs/components/data-list.md +64 -0
- package/docs/components/date-field.md +34 -0
- package/docs/components/date-picker.md +35 -0
- package/docs/components/date-range-picker.md +34 -0
- package/docs/components/dialog.md +182 -0
- package/docs/components/drop-zone.md +45 -0
- package/docs/components/dropdown-menu.md +223 -0
- package/docs/components/empty.md +81 -0
- package/docs/components/field.md +66 -0
- package/docs/components/file-trigger.md +33 -0
- package/docs/components/fold-icon.md +34 -0
- package/docs/components/heading.md +33 -0
- package/docs/components/icon.md +43 -0
- package/docs/components/kbd.md +29 -0
- package/docs/components/link.md +35 -0
- package/docs/components/list.md +104 -0
- package/docs/components/media-preview.md +43 -0
- package/docs/components/multiple-select.md +56 -0
- package/docs/components/nav-rail.md +79 -0
- package/docs/components/number-field.md +49 -0
- package/docs/components/page.md +97 -0
- package/docs/components/popover.md +71 -0
- package/docs/components/preview-frame.md +63 -0
- package/docs/components/radio-group.md +47 -0
- package/docs/components/resizable-panel-group.md +63 -0
- package/docs/components/search-field.md +53 -0
- package/docs/components/select.md +138 -0
- package/docs/components/sidebar.md +104 -0
- package/docs/components/sortable-list.md +125 -0
- package/docs/components/spinner.md +29 -0
- package/docs/components/surface.md +54 -0
- package/docs/components/switch.md +52 -0
- package/docs/components/table.md +178 -0
- package/docs/components/tabs.md +120 -0
- package/docs/components/tag-group.md +56 -0
- package/docs/components/text-field.md +134 -0
- package/docs/components/text.md +44 -0
- package/docs/components/time-field.md +37 -0
- package/docs/components/timestamp.md +45 -0
- package/docs/components/toggle-group.md +46 -0
- package/docs/components/toggle.md +37 -0
- package/docs/components/toolbar.md +96 -0
- package/docs/components/tooltip.md +78 -0
- package/docs/components/tree.md +67 -0
- package/docs/components.md +131 -0
- package/docs/configuration.md +175 -0
- package/docs/content-model.md +87 -0
- package/docs/custom-fields.md +231 -0
- package/docs/dashboard-ui.md +3 -0
- package/docs/deploy/alinea-cloud.md +26 -0
- package/docs/deploy/self-host.md +193 -0
- package/docs/deploy.md +123 -0
- package/docs/editing-content.md +195 -0
- package/docs/fields/check.md +40 -0
- package/docs/fields/code.md +35 -0
- package/docs/fields/date.md +90 -0
- package/docs/fields/entry.md +179 -0
- package/docs/fields/file.md +60 -0
- package/docs/fields/image.md +139 -0
- package/docs/fields/link.md +121 -0
- package/docs/fields/list.md +126 -0
- package/docs/fields/number.md +58 -0
- package/docs/fields/object.md +91 -0
- package/docs/fields/path.md +105 -0
- package/docs/fields/rich-text.md +236 -0
- package/docs/fields/select.md +99 -0
- package/docs/fields/tabs.md +87 -0
- package/docs/fields/text.md +46 -0
- package/docs/fields/url.md +51 -0
- package/docs/fields.md +231 -0
- package/docs/get-started.md +3 -0
- package/docs/guides.md +3 -0
- package/docs/index.md +138 -0
- package/docs/instant-publishing.md +43 -0
- package/docs/internationalization.md +201 -0
- package/docs/introduction.md +5 -0
- package/docs/live-previews.md +151 -0
- package/docs/mcp.md +500 -0
- package/docs/overviews.md +456 -0
- package/docs/query/advanced.md +123 -0
- package/docs/query/examples.md +231 -0
- package/docs/query/filtering.md +160 -0
- package/docs/query/related.md +129 -0
- package/docs/query/structural.md +164 -0
- package/docs/query.md +139 -0
- package/docs/quickstart.md +203 -0
- package/docs/reference.md +3 -0
- package/docs/roles-permissions.md +234 -0
- package/docs/schema/document.md +98 -0
- package/docs/schema/type.md +131 -0
- package/docs/schema.md +66 -0
- package/docs/tutorial/step-1-landing-page.md +244 -0
- package/docs/tutorial/step-2-block-list.md +364 -0
- package/docs/tutorial/step-3-layout-root.md +200 -0
- package/docs/tutorial/step-4-blog.md +384 -0
- package/docs/tutorial/step-5-catch-all.md +222 -0
- package/docs/tutorial.md +21 -0
- package/docs/typescript.md +115 -0
- package/docs/upgrading.md +286 -0
- package/docs/workspaces/media.md +48 -0
- package/docs/workspaces/root.md +127 -0
- package/docs/workspaces.md +98 -0
- package/llms-full.txt +11973 -3202
- package/package.json +35 -7
- package/readme.md +136 -55
- package/dist/backend/store/GeneratedSource.d.ts +0 -2
- package/dist/backend/store/GeneratedSource.js +0 -21
- package/dist/chunks/chunk-AC4U3IMS.js +0 -205
- package/dist/chunks/chunk-G6E35DMJ.js +0 -1997
- package/dist/chunks/chunk-JFROOUG6.js +0 -6363
- package/dist/chunks/chunk-LUBOGJCG.js +0 -129
- package/dist/chunks/chunk-SJBZFMQ2.js +0 -2966
- package/dist/chunks/chunk-STAJCW4Z.js +0 -322
- package/dist/chunks/chunk-U4VOHNR2.js +0 -210
- package/dist/chunks/chunk-YK3OSMDM.js +0 -5473
- package/dist/components/Disclosure.d.ts +0 -5
- package/dist/components/Disclosure.js +0 -106
- package/dist/components/Label.d.ts +0 -48
- package/dist/components/Label.js +0 -210
- package/dist/components/Menu.d.ts +0 -16
- package/dist/components/Menu.js +0 -95
- package/dist/components/Modal.d.ts +0 -7
- package/dist/components/Modal.js +0 -58
- package/dist/components/ProgressCircle.d.ts +0 -6
- package/dist/components/ProgressCircle.js +0 -96
- package/dist/core/db/EntryDB.d.ts +0 -19
- package/dist/core/db/EntryDB.js +0 -48
- package/dist/core/db/EntryIndex.d.ts +0 -130
- package/dist/core/db/EntryIndex.js +0 -2610
- package/dist/core/db/EntryReferenceIndex.d.ts +0 -21
- package/dist/core/db/EntryReferenceIndex.js +0 -131
- package/dist/core/db/EntryResolver.d.ts +0 -56
- package/dist/core/db/EntryResolver.js +0 -624
- package/dist/core/db/EntryTarget.d.ts +0 -5
- package/dist/core/db/EntryTransaction.d.ts +0 -32
- package/dist/core/db/EntryTransaction.js +0 -941
- package/dist/core/db/LocalDB.d.ts +0 -43
- package/dist/core/db/LocalDB.js +0 -122
- package/dist/core/db/TestDB.d.ts +0 -19
- package/dist/core/db/TestDB.js +0 -50
- package/dist/dashboard/app/AppShell.d.ts +0 -4
- package/dist/dashboard/app/AppShell.js +0 -29
- package/dist/dashboard/app/Badge.d.ts +0 -8
- package/dist/dashboard/app/Badge.js +0 -42
- package/dist/dashboard/app/EditorBackButton.d.ts +0 -5
- package/dist/dashboard/app/EditorBackButton.js +0 -33
- package/dist/dashboard/app/EntrySidebarPreview.spec.d.ts +0 -1
- package/dist/dashboard/app/ExplorerFileCard.d.ts +0 -10
- package/dist/dashboard/app/ExplorerFileCard.js +0 -115
- package/dist/dashboard/app/StatusBadge.d.ts +0 -6
- package/dist/dashboard/app/StatusBadge.js +0 -26
- package/dist/dashboard/app/WorkspaceMenu.spec.d.ts +0 -1
- package/dist/dashboard/app/WorkspaceMenu.stories.d.ts +0 -5
- package/dist/dashboard/app/ui/Rail.d.ts +0 -18
- package/dist/dashboard/app/ui/Rail.js +0 -41
- package/dist/dashboard/app/ui/Sidebar.d.ts +0 -15
- package/dist/dashboard/app/ui/Sidebar.js +0 -55
- package/dist/field/link/LinkField.spec.d.ts +0 -1
- package/dist/field/link/LinkField.stories.d.ts +0 -15
- package/dist/field/list/ListField.spec.d.ts +0 -1
- package/dist/field/list/ListField.stories.d.ts +0 -6
- package/dist/field/richtext/RichTextField.spec.d.ts +0 -1
- /package/dist/{core/db/EntryTarget.js → .init-pm/bun.lock} +0 -0
|
@@ -1,941 +0,0 @@
|
|
|
1
|
-
import "../../chunks/chunk-CQ52GEHY.js";
|
|
2
|
-
|
|
3
|
-
// src/core/db/EntryTransaction.ts
|
|
4
|
-
import { Config } from "alinea/core/Config";
|
|
5
|
-
import { createRecord } from "alinea/core/EntryRecord";
|
|
6
|
-
import { Field } from "alinea/core/Field";
|
|
7
|
-
import { createId } from "alinea/core/Id";
|
|
8
|
-
import { getRoot } from "alinea/core/Internal";
|
|
9
|
-
import { ListRow } from "alinea/core/ListRow";
|
|
10
|
-
import { Type } from "alinea/core/Type";
|
|
11
|
-
import { ListEditor } from "alinea/core/field/ListField";
|
|
12
|
-
import { MediaLocation } from "alinea/core/media/MediaLocation";
|
|
13
|
-
import { entryUrl, pathSuffix } from "alinea/core/util/EntryFilenames";
|
|
14
|
-
import {
|
|
15
|
-
generateKeyBetween,
|
|
16
|
-
generateNKeysBetween,
|
|
17
|
-
isValidOrderKey
|
|
18
|
-
} from "alinea/core/util/FractionalIndexing";
|
|
19
|
-
import { entries, fromEntries, isRecord, keys } from "alinea/core/util/Objects";
|
|
20
|
-
import * as paths from "alinea/core/util/Paths";
|
|
21
|
-
import { slugify } from "alinea/core/util/Slugs";
|
|
22
|
-
import { unreachable } from "alinea/core/util/Types";
|
|
23
|
-
import { Permission, Policy } from "../Role.js";
|
|
24
|
-
import { ShaMismatchError } from "../source/ShaMismatchError.js";
|
|
25
|
-
import { SourceTransaction } from "../source/Source.js";
|
|
26
|
-
import { assert } from "../util/Assert.js";
|
|
27
|
-
import { commitChanges } from "./CommitRequest.js";
|
|
28
|
-
import { aliasesFromData, aliasUrl } from "./EntryAliases.js";
|
|
29
|
-
import { EntryUrlConflictError } from "./EntryUrlConflictError.js";
|
|
30
|
-
var EntryTransaction = class {
|
|
31
|
-
#checks = [];
|
|
32
|
-
#messages = [];
|
|
33
|
-
#config;
|
|
34
|
-
#index;
|
|
35
|
-
#tx;
|
|
36
|
-
#fileChanges = [];
|
|
37
|
-
#policy;
|
|
38
|
-
#urlClaims;
|
|
39
|
-
constructor(config, index, source, from, policy = Policy.ALLOW_ALL) {
|
|
40
|
-
if (index.sha !== from.sha) throw new ShaMismatchError(index.sha, from.sha);
|
|
41
|
-
this.#config = config;
|
|
42
|
-
this.#index = index;
|
|
43
|
-
this.#tx = new SourceTransaction(source, from);
|
|
44
|
-
this.#policy = policy;
|
|
45
|
-
}
|
|
46
|
-
get empty() {
|
|
47
|
-
return this.#messages.length === 0;
|
|
48
|
-
}
|
|
49
|
-
create({
|
|
50
|
-
locale,
|
|
51
|
-
type,
|
|
52
|
-
data,
|
|
53
|
-
root,
|
|
54
|
-
workspace,
|
|
55
|
-
fromSeed,
|
|
56
|
-
parentId = null,
|
|
57
|
-
id = createId(),
|
|
58
|
-
insertOrder = "last",
|
|
59
|
-
status = "published",
|
|
60
|
-
overwrite = false
|
|
61
|
-
}) {
|
|
62
|
-
const config = this.#config;
|
|
63
|
-
const index = this.#index;
|
|
64
|
-
const existing = index.byId(id);
|
|
65
|
-
if (existing) {
|
|
66
|
-
parentId = existing.parentId;
|
|
67
|
-
if (!workspace) workspace = existing.workspace;
|
|
68
|
-
if (!root) root = existing.root;
|
|
69
|
-
assert(
|
|
70
|
-
existing.workspace === workspace,
|
|
71
|
-
`Cannot create entry with id ${id} in workspace ${workspace}, already exists in ${existing.workspace}`
|
|
72
|
-
);
|
|
73
|
-
assert(
|
|
74
|
-
existing.root === root,
|
|
75
|
-
`Cannot create entry with id ${id} in root ${root}, already exists in ${existing.root}`
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
const workspaces = keys(config.workspaces);
|
|
79
|
-
if (!workspace) workspace = workspaces[0];
|
|
80
|
-
assert(
|
|
81
|
-
workspace in config.workspaces,
|
|
82
|
-
`Workspace "${workspace}" not found in config`
|
|
83
|
-
);
|
|
84
|
-
const roots = keys(config.workspaces[workspace]);
|
|
85
|
-
if (!root) root = roots[0];
|
|
86
|
-
assert(
|
|
87
|
-
root in config.workspaces[workspace],
|
|
88
|
-
`Root "${root}" not found in workspace "${workspace}"`
|
|
89
|
-
);
|
|
90
|
-
const rootConfig = this.#config.workspaces[workspace][root];
|
|
91
|
-
assert(rootConfig, "Invalid root");
|
|
92
|
-
this.#policy.assert(Permission.Create, {
|
|
93
|
-
workspace,
|
|
94
|
-
root,
|
|
95
|
-
type
|
|
96
|
-
});
|
|
97
|
-
const i18n = getRoot(rootConfig).i18n;
|
|
98
|
-
if (i18n) assert(i18n.locales.includes(locale), "Invalid locale");
|
|
99
|
-
else assert(locale === null, "Invalid locale");
|
|
100
|
-
let parent;
|
|
101
|
-
if (parentId) {
|
|
102
|
-
parent = index.findFirst((entry) => {
|
|
103
|
-
return entry.id === parentId && entry.locale === locale && entry.main;
|
|
104
|
-
});
|
|
105
|
-
assert(parent, `Parent not found: ${parentId}`);
|
|
106
|
-
this.#checks.push([parent.filePath, parent.fileHash]);
|
|
107
|
-
this.#policy.assert(Permission.Create, parent);
|
|
108
|
-
}
|
|
109
|
-
const siblings = Array.from(
|
|
110
|
-
index.findMany((entry) => {
|
|
111
|
-
return entry.root === root && entry.workspace === workspace && entry.parentId === parentId;
|
|
112
|
-
})
|
|
113
|
-
);
|
|
114
|
-
assert(typeof data === "object", "Invalid data");
|
|
115
|
-
const title = data.title ?? data.path;
|
|
116
|
-
assert(typeof title === "string", "Missing title");
|
|
117
|
-
let path = slugify(typeof data.path === "string" ? data.path : title);
|
|
118
|
-
assert(path.length > 0, "Invalid path");
|
|
119
|
-
const existingPath = existing?.get(locale)?.path;
|
|
120
|
-
const hasSamePath = existingPath === path;
|
|
121
|
-
if (!hasSamePath)
|
|
122
|
-
path = this.#getAvailablePath({
|
|
123
|
-
id,
|
|
124
|
-
path,
|
|
125
|
-
parentId,
|
|
126
|
-
root,
|
|
127
|
-
workspace,
|
|
128
|
-
locale
|
|
129
|
-
});
|
|
130
|
-
if (status !== "published" && existingPath) path = existingPath;
|
|
131
|
-
if (existingPath && !hasSamePath && status === "published") {
|
|
132
|
-
this.#rename(existing.id, locale, path);
|
|
133
|
-
}
|
|
134
|
-
if (overwrite && existing?.type === "MediaFile") {
|
|
135
|
-
const prev = existing.get(null)?.main;
|
|
136
|
-
assert(prev, "Previous entry not found");
|
|
137
|
-
const prevLocation = prev.data.location;
|
|
138
|
-
if (prevLocation !== data.location)
|
|
139
|
-
this.removeFile({
|
|
140
|
-
location: MediaLocation.storagePath(
|
|
141
|
-
this.#config,
|
|
142
|
-
prev.workspace,
|
|
143
|
-
prev.data.location
|
|
144
|
-
)
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
const parentDir = parent ? parent.childrenDir : Config.filePath(this.#config, workspace, root, locale);
|
|
148
|
-
const filePath = paths.join(
|
|
149
|
-
parentDir,
|
|
150
|
-
`${path}${status === "published" ? "" : `.${status}`}.json`
|
|
151
|
-
);
|
|
152
|
-
const hasSameVersion = existing?.get(locale)?.has(status);
|
|
153
|
-
const warnDuplicate = !overwrite && hasSameVersion;
|
|
154
|
-
assert(!warnDuplicate, `Cannot create duplicate entry with id ${id}`);
|
|
155
|
-
let newIndex;
|
|
156
|
-
if (existing) {
|
|
157
|
-
newIndex = existing.index;
|
|
158
|
-
if (status === "published") {
|
|
159
|
-
const versions = index.byId(id)?.get(locale);
|
|
160
|
-
if (versions)
|
|
161
|
-
for (const [status2, version] of versions) {
|
|
162
|
-
this.#tx.remove(version.filePath);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
} else {
|
|
166
|
-
const previous = insertOrder === "first" ? null : siblings.at(-1) ?? null;
|
|
167
|
-
const next = insertOrder === "last" ? null : siblings.at(0) ?? null;
|
|
168
|
-
newIndex = generateKeyBetween(
|
|
169
|
-
previous?.index ?? null,
|
|
170
|
-
next?.index ?? null
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
if (locale !== null && status === "published") {
|
|
174
|
-
const from = index.findFirst((entry) => {
|
|
175
|
-
return entry.id === id && entry.locale !== locale && entry.status === "published";
|
|
176
|
-
});
|
|
177
|
-
if (from) {
|
|
178
|
-
const typeInstance = this.#config.schema[type];
|
|
179
|
-
assert(typeInstance, `Type not found: ${type}`);
|
|
180
|
-
const shared = Type.sharedData(typeInstance, from.data);
|
|
181
|
-
data = { ...shared, ...data };
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
if (status === "published") {
|
|
185
|
-
const urlCandidate = {
|
|
186
|
-
id,
|
|
187
|
-
type,
|
|
188
|
-
path,
|
|
189
|
-
parentId,
|
|
190
|
-
workspace,
|
|
191
|
-
root,
|
|
192
|
-
locale,
|
|
193
|
-
data
|
|
194
|
-
};
|
|
195
|
-
data = this.#dataWithPreviousUrlAlias(
|
|
196
|
-
urlCandidate,
|
|
197
|
-
this.#publishedEntry(id, locale)
|
|
198
|
-
);
|
|
199
|
-
if (locale !== null) this.#persistSharedFields(id, locale, type, data);
|
|
200
|
-
this.#assertUniqueUrls({ ...urlCandidate, data });
|
|
201
|
-
}
|
|
202
|
-
const seeds = existing?.get(locale);
|
|
203
|
-
const seeded = fromSeed ?? seeds?.seeded ?? null;
|
|
204
|
-
const record = createRecord(
|
|
205
|
-
{ id, type, index: newIndex, path, seeded, data, title },
|
|
206
|
-
status
|
|
207
|
-
);
|
|
208
|
-
const contents = new TextEncoder().encode(JSON.stringify(record, null, 2));
|
|
209
|
-
this.#tx.add(filePath, contents);
|
|
210
|
-
this.#messages.push(this.#reportOp("create", title));
|
|
211
|
-
return this;
|
|
212
|
-
}
|
|
213
|
-
#rename(entryId, locale, path) {
|
|
214
|
-
const index = this.#index;
|
|
215
|
-
const versions = index.findMany((entry) => {
|
|
216
|
-
return entry.id === entryId && entry.locale === locale;
|
|
217
|
-
});
|
|
218
|
-
for (const version of versions) {
|
|
219
|
-
const name = version.status === "published" ? path : `${path}.${version.status}`;
|
|
220
|
-
const filePath = paths.join(version.parentDir, `${name}.json`);
|
|
221
|
-
this.#tx.rename(version.filePath, filePath);
|
|
222
|
-
const childrenDir = paths.join(version.parentDir, path);
|
|
223
|
-
this.#tx.rename(version.childrenDir, childrenDir);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
update({ id, locale, status, set }) {
|
|
227
|
-
const index = this.#index;
|
|
228
|
-
const entry = index.findFirst((entry2) => {
|
|
229
|
-
return entry2.id === id && entry2.locale === locale && entry2.status === status;
|
|
230
|
-
});
|
|
231
|
-
assert(entry, `Entry not found: ${id}`);
|
|
232
|
-
this.#policy.assert(Permission.Update, entry);
|
|
233
|
-
for (const key of keys(set)) {
|
|
234
|
-
this.#policy.assert(Permission.Update, {
|
|
235
|
-
workspace: entry.workspace,
|
|
236
|
-
root: entry.root,
|
|
237
|
-
type: entry.type,
|
|
238
|
-
id: entry.id,
|
|
239
|
-
parents: entry.parents,
|
|
240
|
-
locale: entry.locale,
|
|
241
|
-
field: key
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
const fieldUpdates = fromEntries(
|
|
245
|
-
entries(set).map(([key, value]) => {
|
|
246
|
-
return [key, value ?? null];
|
|
247
|
-
})
|
|
248
|
-
);
|
|
249
|
-
let data = { ...entry.data, ...fieldUpdates };
|
|
250
|
-
const desiredPath = slugify(
|
|
251
|
-
data.path ?? entry.data.path ?? entry.path
|
|
252
|
-
);
|
|
253
|
-
const lockPath = entry.status !== "published" && !entry.main;
|
|
254
|
-
const path = lockPath ? entry.path : this.#getAvailablePath({
|
|
255
|
-
id,
|
|
256
|
-
path: desiredPath,
|
|
257
|
-
parentId: entry.parentId,
|
|
258
|
-
root: entry.root,
|
|
259
|
-
workspace: entry.workspace,
|
|
260
|
-
locale
|
|
261
|
-
});
|
|
262
|
-
this.#checks.push([entry.filePath, entry.fileHash]);
|
|
263
|
-
const childrenDir = paths.join(entry.parentDir, path);
|
|
264
|
-
const filePath = `${childrenDir}${entry.status === "published" ? "" : `.${entry.status}`}.json`;
|
|
265
|
-
if (entry.status === "published") {
|
|
266
|
-
this.#policy.assert(Permission.Publish, entry);
|
|
267
|
-
if (filePath !== entry.filePath) this.#rename(id, locale, path);
|
|
268
|
-
const urlCandidate = {
|
|
269
|
-
id,
|
|
270
|
-
type: entry.type,
|
|
271
|
-
path,
|
|
272
|
-
parentId: entry.parentId,
|
|
273
|
-
root: entry.root,
|
|
274
|
-
workspace: entry.workspace,
|
|
275
|
-
locale,
|
|
276
|
-
data
|
|
277
|
-
};
|
|
278
|
-
data = this.#dataWithPreviousUrlAlias(urlCandidate, entry);
|
|
279
|
-
if (locale !== null)
|
|
280
|
-
this.#persistSharedFields(id, locale, entry.type, data);
|
|
281
|
-
this.#assertUniqueUrls({ ...urlCandidate, data });
|
|
282
|
-
}
|
|
283
|
-
const record = createRecord(
|
|
284
|
-
{
|
|
285
|
-
id,
|
|
286
|
-
type: entry.type,
|
|
287
|
-
index: entry.index,
|
|
288
|
-
path: entry.path,
|
|
289
|
-
seeded: entry.seeded,
|
|
290
|
-
data
|
|
291
|
-
},
|
|
292
|
-
status
|
|
293
|
-
);
|
|
294
|
-
if (entry.status !== "published" && path !== entry.path) record.path = path;
|
|
295
|
-
const contents = new TextEncoder().encode(JSON.stringify(record, null, 2));
|
|
296
|
-
this.#tx.add(filePath, contents);
|
|
297
|
-
this.#messages.push(this.#reportOp("update", entry.title));
|
|
298
|
-
return this;
|
|
299
|
-
}
|
|
300
|
-
#getAvailablePath(target) {
|
|
301
|
-
const conflictingPaths = Array.from(
|
|
302
|
-
this.#index.findMany((entry) => {
|
|
303
|
-
return entry.id !== target.id && entry.parentId === target.parentId && entry.workspace === target.workspace && entry.root === target.root && entry.locale === target.locale && (entry.path === target.path || entry.path.startsWith(`${target.path}-`));
|
|
304
|
-
})
|
|
305
|
-
).map((entry) => entry.path);
|
|
306
|
-
const suffix = pathSuffix(target.path, conflictingPaths);
|
|
307
|
-
if (suffix !== void 0) return `${target.path}-${suffix}`;
|
|
308
|
-
return target.path;
|
|
309
|
-
}
|
|
310
|
-
#assertUniqueUrls(candidate) {
|
|
311
|
-
const claims = this.#getUrlClaims();
|
|
312
|
-
const urls = this.#candidateUrls(candidate);
|
|
313
|
-
for (const url of urls) {
|
|
314
|
-
const key = this.#urlClaimKey(candidate.workspace, candidate.root, url);
|
|
315
|
-
const existing = claims.get(key);
|
|
316
|
-
if (existing && existing.id !== candidate.id) {
|
|
317
|
-
throw new EntryUrlConflictError({
|
|
318
|
-
url,
|
|
319
|
-
entryId: existing.id,
|
|
320
|
-
workspace: candidate.workspace,
|
|
321
|
-
root: candidate.root
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
for (const [key, claim] of claims) {
|
|
326
|
-
if (claim.id === candidate.id) claims.delete(key);
|
|
327
|
-
}
|
|
328
|
-
for (const url of urls) {
|
|
329
|
-
claims.set(this.#urlClaimKey(candidate.workspace, candidate.root, url), {
|
|
330
|
-
id: candidate.id,
|
|
331
|
-
url
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
#candidateUrls(candidate) {
|
|
336
|
-
return [this.#resolvedUrl(candidate), ...aliasUrlsFromData(candidate.data)];
|
|
337
|
-
}
|
|
338
|
-
#resolvedUrl(candidate) {
|
|
339
|
-
const type = this.#config.schema[candidate.type];
|
|
340
|
-
assert(type, `Type not found: ${candidate.type}`);
|
|
341
|
-
if (candidate.url !== void 0) return candidate.url;
|
|
342
|
-
return entryUrl(type, {
|
|
343
|
-
config: this.#config,
|
|
344
|
-
path: candidate.path,
|
|
345
|
-
parentPaths: candidate.parentPaths ?? this.#parentPaths(candidate.parentId, candidate.locale),
|
|
346
|
-
locale: candidate.locale,
|
|
347
|
-
status: "published",
|
|
348
|
-
workspace: candidate.workspace,
|
|
349
|
-
root: candidate.root,
|
|
350
|
-
data: candidate.data
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
#dataWithPreviousUrlAlias(candidate, previousEntry) {
|
|
354
|
-
if (!previousEntry) return candidate.data;
|
|
355
|
-
const previousUrl = this.#resolvedUrl(previousEntry);
|
|
356
|
-
const currentUrl = this.#resolvedUrl(candidate);
|
|
357
|
-
if (previousUrl === currentUrl) return candidate.data;
|
|
358
|
-
const type = this.#config.schema[candidate.type];
|
|
359
|
-
assert(type, `Type not found: ${candidate.type}`);
|
|
360
|
-
return dataWithUrlAlias(type, candidate.data, previousUrl, currentUrl);
|
|
361
|
-
}
|
|
362
|
-
#publishedEntry(id, locale) {
|
|
363
|
-
return this.#index.findFirst((entry) => {
|
|
364
|
-
return entry.id === id && entry.locale === locale && entry.status === "published";
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
#parentPaths(parentId, locale) {
|
|
368
|
-
const result = Array();
|
|
369
|
-
let current = parentId ? this.#index.byId(parentId) : void 0;
|
|
370
|
-
while (current) {
|
|
371
|
-
const language = current.get(locale);
|
|
372
|
-
assert(language, `Missing parent language node`);
|
|
373
|
-
result.unshift(language.main.path);
|
|
374
|
-
current = current.parent ?? void 0;
|
|
375
|
-
}
|
|
376
|
-
return result;
|
|
377
|
-
}
|
|
378
|
-
#getUrlClaims() {
|
|
379
|
-
if (this.#urlClaims) return this.#urlClaims;
|
|
380
|
-
const claims = /* @__PURE__ */ new Map();
|
|
381
|
-
for (const entry of this.#index.findMany((entry2) => {
|
|
382
|
-
return entry2.status === "published";
|
|
383
|
-
})) {
|
|
384
|
-
for (const url of [
|
|
385
|
-
this.#resolvedUrl(entry),
|
|
386
|
-
...aliasUrlsFromData(entry.data)
|
|
387
|
-
]) {
|
|
388
|
-
claims.set(this.#urlClaimKey(entry.workspace, entry.root, url), {
|
|
389
|
-
id: entry.id,
|
|
390
|
-
url
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
this.#urlClaims = claims;
|
|
395
|
-
return claims;
|
|
396
|
-
}
|
|
397
|
-
#urlClaimKey(workspace, root, url) {
|
|
398
|
-
return `${workspace}\0${root}\0${url}`;
|
|
399
|
-
}
|
|
400
|
-
#persistSharedFields(id, locale, type, data) {
|
|
401
|
-
const index = this.#index;
|
|
402
|
-
const typeInstance = this.#config.schema[type];
|
|
403
|
-
assert(type, `Type not found: ${type}`);
|
|
404
|
-
const shared = Type.sharedData(typeInstance, data);
|
|
405
|
-
if (shared) {
|
|
406
|
-
const translations = index.findMany((entry) => {
|
|
407
|
-
return entry.id === id && entry.locale !== locale;
|
|
408
|
-
});
|
|
409
|
-
for (const translation of translations) {
|
|
410
|
-
this.#checks.push([translation.filePath, translation.fileHash]);
|
|
411
|
-
const record = createRecord(
|
|
412
|
-
{
|
|
413
|
-
id,
|
|
414
|
-
type: translation.type,
|
|
415
|
-
index: translation.index,
|
|
416
|
-
path: translation.path,
|
|
417
|
-
seeded: translation.seeded,
|
|
418
|
-
data: {
|
|
419
|
-
...translation.data,
|
|
420
|
-
...shared
|
|
421
|
-
}
|
|
422
|
-
},
|
|
423
|
-
translation.status
|
|
424
|
-
);
|
|
425
|
-
const contents = new TextEncoder().encode(
|
|
426
|
-
JSON.stringify(record, null, 2)
|
|
427
|
-
);
|
|
428
|
-
this.#tx.add(translation.filePath, contents);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
#moveUrlAliasUpdates(target) {
|
|
433
|
-
const updates = Array();
|
|
434
|
-
for (const entry of this.#index.findMany((entry2) => {
|
|
435
|
-
return entry2.status === "published" && (entry2.id === target.id || entry2.parents.includes(target.id));
|
|
436
|
-
})) {
|
|
437
|
-
const parentPaths = this.#movedParentPaths(entry, target);
|
|
438
|
-
const candidate = {
|
|
439
|
-
id: entry.id,
|
|
440
|
-
type: entry.type,
|
|
441
|
-
path: entry.path,
|
|
442
|
-
parentId: entry.id === target.id ? target.parentId : entry.parentId,
|
|
443
|
-
parentPaths,
|
|
444
|
-
workspace: target.workspace,
|
|
445
|
-
root: target.root,
|
|
446
|
-
locale: entry.locale,
|
|
447
|
-
data: entry.data
|
|
448
|
-
};
|
|
449
|
-
const data = this.#dataWithPreviousUrlAlias(candidate, entry);
|
|
450
|
-
this.#assertUniqueUrls({ ...candidate, data });
|
|
451
|
-
updates.push({
|
|
452
|
-
entry,
|
|
453
|
-
data,
|
|
454
|
-
filePath: this.#movedFilePath(entry, target)
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
return updates;
|
|
458
|
-
}
|
|
459
|
-
#movedParentPaths(entry, target) {
|
|
460
|
-
const moved = this.#index.byId(target.id);
|
|
461
|
-
assert(moved, `Entry not found: ${target.id}`);
|
|
462
|
-
const movedLanguage = moved.get(entry.locale);
|
|
463
|
-
assert(movedLanguage, `Missing moved entry language node`);
|
|
464
|
-
const newParentPaths = this.#parentPaths(target.parentId, entry.locale);
|
|
465
|
-
if (entry.id === target.id) return newParentPaths;
|
|
466
|
-
const currentParentPaths = this.#parentPaths(entry.parentId, entry.locale);
|
|
467
|
-
const oldPrefix = this.#parentPaths(moved.parentId, entry.locale).concat(
|
|
468
|
-
movedLanguage.main.path
|
|
469
|
-
);
|
|
470
|
-
const newPrefix = newParentPaths.concat(movedLanguage.main.path);
|
|
471
|
-
assert(
|
|
472
|
-
startsWithSegments(currentParentPaths, oldPrefix),
|
|
473
|
-
`Moved child is outside moved entry path`
|
|
474
|
-
);
|
|
475
|
-
return newPrefix.concat(currentParentPaths.slice(oldPrefix.length));
|
|
476
|
-
}
|
|
477
|
-
#movedFilePath(entry, target) {
|
|
478
|
-
const moved = this.#index.byId(target.id);
|
|
479
|
-
assert(moved, `Entry not found: ${target.id}`);
|
|
480
|
-
const movedLanguage = moved.get(entry.locale);
|
|
481
|
-
assert(movedLanguage, `Missing moved entry language node`);
|
|
482
|
-
const parent = target.parentId ? this.#index.findFirst((parentEntry) => {
|
|
483
|
-
return parentEntry.id === target.parentId && parentEntry.locale === entry.locale;
|
|
484
|
-
}) : void 0;
|
|
485
|
-
const parentDir = parent ? parent.childrenDir : Config.filePath(
|
|
486
|
-
this.#config,
|
|
487
|
-
target.workspace,
|
|
488
|
-
target.root,
|
|
489
|
-
entry.locale
|
|
490
|
-
);
|
|
491
|
-
const nextPrefix = paths.join(parentDir, movedLanguage.main.path);
|
|
492
|
-
if (entry.id === target.id) {
|
|
493
|
-
return `${nextPrefix}${entry.status === "published" ? "" : `.${entry.status}`}.json`;
|
|
494
|
-
}
|
|
495
|
-
const previousPrefix = movedLanguage.main.childrenDir;
|
|
496
|
-
assert(
|
|
497
|
-
entry.filePath === previousPrefix || entry.filePath.startsWith(`${previousPrefix}/`),
|
|
498
|
-
`Moved child file is outside moved entry directory`
|
|
499
|
-
);
|
|
500
|
-
const suffix = entry.filePath.slice(previousPrefix.length).replace(/^\//, "");
|
|
501
|
-
return paths.join(nextPrefix, suffix);
|
|
502
|
-
}
|
|
503
|
-
publish({ id, locale, status }) {
|
|
504
|
-
const index = this.#index;
|
|
505
|
-
const entry = index.findFirst((entry2) => {
|
|
506
|
-
return entry2.id === id && entry2.locale === locale && entry2.status === status;
|
|
507
|
-
});
|
|
508
|
-
assert(entry, `Entry not found: ${id}`);
|
|
509
|
-
this.#policy.assert(Permission.Publish, entry);
|
|
510
|
-
const pathChange = entry.data.path && entry.data.path !== entry.path;
|
|
511
|
-
let path = slugify(entry.data.path ?? entry.path);
|
|
512
|
-
let data = entry.data;
|
|
513
|
-
path = this.#getAvailablePath({
|
|
514
|
-
id,
|
|
515
|
-
path,
|
|
516
|
-
parentId: entry.parentId,
|
|
517
|
-
root: entry.root,
|
|
518
|
-
workspace: entry.workspace,
|
|
519
|
-
locale
|
|
520
|
-
});
|
|
521
|
-
const childrenDir = paths.join(entry.parentDir, path);
|
|
522
|
-
const urlCandidate = {
|
|
523
|
-
id,
|
|
524
|
-
type: entry.type,
|
|
525
|
-
path,
|
|
526
|
-
parentId: entry.parentId,
|
|
527
|
-
root: entry.root,
|
|
528
|
-
workspace: entry.workspace,
|
|
529
|
-
locale,
|
|
530
|
-
data
|
|
531
|
-
};
|
|
532
|
-
data = this.#dataWithPreviousUrlAlias(
|
|
533
|
-
urlCandidate,
|
|
534
|
-
this.#publishedEntry(id, locale)
|
|
535
|
-
);
|
|
536
|
-
if (entry.locale !== null)
|
|
537
|
-
this.#persistSharedFields(id, entry.locale, entry.type, data);
|
|
538
|
-
this.#assertUniqueUrls({ ...urlCandidate, data });
|
|
539
|
-
const versions = index.byId(id)?.get(locale);
|
|
540
|
-
if (versions)
|
|
541
|
-
for (const [_, version] of versions) {
|
|
542
|
-
this.#tx.remove(version.filePath);
|
|
543
|
-
}
|
|
544
|
-
this.#checks.push([entry.filePath, entry.fileHash]);
|
|
545
|
-
this.#tx.remove(entry.filePath);
|
|
546
|
-
const record = createRecord({ ...entry, path, data }, "published");
|
|
547
|
-
const contents = new TextEncoder().encode(JSON.stringify(record, null, 2));
|
|
548
|
-
if (pathChange) {
|
|
549
|
-
this.#tx.remove(`${entry.parentDir}/${entry.path}.json`);
|
|
550
|
-
this.#tx.rename(entry.childrenDir, childrenDir);
|
|
551
|
-
}
|
|
552
|
-
this.#tx.add(`${childrenDir}.json`, contents);
|
|
553
|
-
this.#messages.push(this.#reportOp("publish", entry.title));
|
|
554
|
-
return this;
|
|
555
|
-
}
|
|
556
|
-
unpublish({ id, locale }) {
|
|
557
|
-
const index = this.#index;
|
|
558
|
-
const versions = index.byId(id)?.get(locale);
|
|
559
|
-
const mainEntry = versions?.main;
|
|
560
|
-
assert(mainEntry, `Entry not found: ${id}`);
|
|
561
|
-
this.#policy.assert(Permission.Publish, mainEntry);
|
|
562
|
-
for (const [_, version] of versions) {
|
|
563
|
-
if (version === mainEntry) continue;
|
|
564
|
-
this.#tx.remove(version.filePath);
|
|
565
|
-
}
|
|
566
|
-
this.#checks.push([mainEntry.filePath, mainEntry.fileHash]);
|
|
567
|
-
this.#tx.rename(mainEntry.filePath, `${mainEntry.childrenDir}.draft.json`);
|
|
568
|
-
this.#messages.push(this.#reportOp("unpublish", mainEntry.title));
|
|
569
|
-
return this;
|
|
570
|
-
}
|
|
571
|
-
archive({ id, locale }) {
|
|
572
|
-
const index = this.#index;
|
|
573
|
-
const versions = index.byId(id)?.get(locale);
|
|
574
|
-
const mainEntry = versions?.main;
|
|
575
|
-
assert(mainEntry, `Entry not found: ${id}`);
|
|
576
|
-
this.#policy.assert(Permission.Archive, mainEntry);
|
|
577
|
-
for (const [_, version] of versions) {
|
|
578
|
-
if (version === mainEntry) continue;
|
|
579
|
-
this.#tx.remove(version.filePath);
|
|
580
|
-
}
|
|
581
|
-
this.#checks.push([mainEntry.filePath, mainEntry.fileHash]);
|
|
582
|
-
this.#tx.rename(
|
|
583
|
-
mainEntry.filePath,
|
|
584
|
-
`${mainEntry.childrenDir}.archived.json`
|
|
585
|
-
);
|
|
586
|
-
this.#messages.push(this.#reportOp("archive", mainEntry.title));
|
|
587
|
-
return this;
|
|
588
|
-
}
|
|
589
|
-
move({ id, target, dropPosition, targetType }) {
|
|
590
|
-
const index = this.#index;
|
|
591
|
-
targetType ??= "entry";
|
|
592
|
-
const entries2 = Array.from(index.findMany((entry) => entry.id === id));
|
|
593
|
-
assert(entries2.length > 0, `Entry not found: ${id}`);
|
|
594
|
-
const targetEntry = targetType === "root" ? void 0 : index.findFirst((entry) => {
|
|
595
|
-
return entry.id === target;
|
|
596
|
-
});
|
|
597
|
-
assert(targetType === "root" || targetEntry, `Target not found: ${target}`);
|
|
598
|
-
assert(
|
|
599
|
-
targetType === "entry" || dropPosition === "on",
|
|
600
|
-
`Cannot move ${dropPosition} root ${target}`
|
|
601
|
-
);
|
|
602
|
-
const parentId = targetType === "root" ? null : dropPosition === "on" ? target : targetEntry?.parentId ?? null;
|
|
603
|
-
const root = targetType === "root" ? target : targetEntry?.root ?? entries2[0].root;
|
|
604
|
-
const workspace = targetEntry?.workspace ?? entries2[0].workspace;
|
|
605
|
-
const action = parentId !== entries2[0].parentId || root !== entries2[0].root ? Permission.Move : Permission.Reorder;
|
|
606
|
-
for (const entry of entries2) this.#policy.assert(action, entry);
|
|
607
|
-
if (action === Permission.Move && parentId === null) {
|
|
608
|
-
this.#policy.assert(Permission.Move, { workspace, root });
|
|
609
|
-
}
|
|
610
|
-
const siblingList = Array.from(
|
|
611
|
-
index.findMany((entry) => {
|
|
612
|
-
return entry.workspace === workspace && entry.root === root && entry.parentId === parentId && entry.id !== id;
|
|
613
|
-
})
|
|
614
|
-
);
|
|
615
|
-
let insertIndex = siblingList.length;
|
|
616
|
-
if (targetType !== "root") {
|
|
617
|
-
const targetIndex = siblingList.findIndex((entry) => entry.id === target);
|
|
618
|
-
if (dropPosition === "before") {
|
|
619
|
-
assert(targetIndex >= 0, `Sibling not found: ${target}`);
|
|
620
|
-
insertIndex = targetIndex;
|
|
621
|
-
} else if (dropPosition === "after") {
|
|
622
|
-
assert(targetIndex >= 0, `Sibling not found: ${target}`);
|
|
623
|
-
insertIndex = targetIndex + 1;
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
const previous = siblingList[insertIndex - 1] ?? null;
|
|
627
|
-
const next = siblingList[insertIndex] ?? null;
|
|
628
|
-
const seen = /* @__PURE__ */ new Set();
|
|
629
|
-
const hasDuplicates = siblingList.some((entry) => {
|
|
630
|
-
const wasSeen = seen.has(entry.index);
|
|
631
|
-
if (wasSeen) return true;
|
|
632
|
-
seen.add(entry.index);
|
|
633
|
-
return false;
|
|
634
|
-
});
|
|
635
|
-
let newIndex;
|
|
636
|
-
if (hasDuplicates) {
|
|
637
|
-
const self = index.findFirst((entry) => entry.id === id);
|
|
638
|
-
assert(self, `Entry not found: ${id}`);
|
|
639
|
-
siblingList.splice(insertIndex, 0, self);
|
|
640
|
-
for (const sibling of siblingList) {
|
|
641
|
-
this.#policy.assert(Permission.Reorder, sibling);
|
|
642
|
-
}
|
|
643
|
-
const newKeys = generateNKeysBetween(null, null, siblingList.length);
|
|
644
|
-
for (const [i, key] of newKeys.entries()) {
|
|
645
|
-
const id2 = siblingList[i].id;
|
|
646
|
-
const node = index.byId(id2);
|
|
647
|
-
assert(node);
|
|
648
|
-
for (const locale of node.keys()) {
|
|
649
|
-
for (const [_, version] of node.get(locale)) {
|
|
650
|
-
const record = createRecord(
|
|
651
|
-
{
|
|
652
|
-
id: id2,
|
|
653
|
-
type: version.type,
|
|
654
|
-
index: key,
|
|
655
|
-
path: version.path,
|
|
656
|
-
seeded: version.seeded,
|
|
657
|
-
data: version.data
|
|
658
|
-
},
|
|
659
|
-
version.status
|
|
660
|
-
);
|
|
661
|
-
const contents = new TextEncoder().encode(
|
|
662
|
-
JSON.stringify(record, null, 2)
|
|
663
|
-
);
|
|
664
|
-
this.#tx.add(version.filePath, contents);
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
newIndex = newKeys[insertIndex];
|
|
669
|
-
} else {
|
|
670
|
-
newIndex = generateKeyBetween(
|
|
671
|
-
previous?.index ?? null,
|
|
672
|
-
next?.index ?? null
|
|
673
|
-
);
|
|
674
|
-
}
|
|
675
|
-
const moveUrlAliasUpdates = action === Permission.Move ? this.#moveUrlAliasUpdates({ id, parentId, workspace, root }) : [];
|
|
676
|
-
const moveUrlAliasData = new Map(
|
|
677
|
-
moveUrlAliasUpdates.map((update) => [update.entry.filePath, update.data])
|
|
678
|
-
);
|
|
679
|
-
let info;
|
|
680
|
-
for (const entry of entries2) {
|
|
681
|
-
info = entry;
|
|
682
|
-
const parent = parentId ? index.findFirst((e) => {
|
|
683
|
-
return e.id === parentId && e.locale === entry.locale;
|
|
684
|
-
}) : void 0;
|
|
685
|
-
if (action === Permission.Move && parentId) {
|
|
686
|
-
assert(!entry.seeded, `Cannot move seeded entry ${entry.filePath}`);
|
|
687
|
-
assert(parent, `Parent not found: ${parentId}`);
|
|
688
|
-
this.#policy.assert(Permission.Move, parent);
|
|
689
|
-
assert(
|
|
690
|
-
!parent?.childrenDir.startsWith(entry.childrenDir),
|
|
691
|
-
"Cannot move entry into its own children"
|
|
692
|
-
);
|
|
693
|
-
const parentType = this.#config.schema[parent.type];
|
|
694
|
-
const childType = this.#config.schema[entry.type];
|
|
695
|
-
const allowed = Config.typeContains(this.#config, parentType, childType);
|
|
696
|
-
assert(
|
|
697
|
-
allowed,
|
|
698
|
-
`Parent of type ${parent.type} does not allow children of type ${entry.type}`
|
|
699
|
-
);
|
|
700
|
-
}
|
|
701
|
-
const parentDir = parent ? parent.childrenDir : Config.filePath(this.#config, workspace, root, entry.locale);
|
|
702
|
-
const childrenDir = paths.join(parentDir, entry.path);
|
|
703
|
-
const filePath = `${childrenDir}${entry.status === "published" ? "" : `.${entry.status}`}.json`;
|
|
704
|
-
const data = moveUrlAliasData.get(entry.filePath) ?? entry.data;
|
|
705
|
-
const record = createRecord(
|
|
706
|
-
{
|
|
707
|
-
id,
|
|
708
|
-
type: entry.type,
|
|
709
|
-
index: newIndex,
|
|
710
|
-
path: entry.path,
|
|
711
|
-
seeded: entry.seeded,
|
|
712
|
-
root,
|
|
713
|
-
workspace,
|
|
714
|
-
parentId,
|
|
715
|
-
data
|
|
716
|
-
},
|
|
717
|
-
entry.status
|
|
718
|
-
);
|
|
719
|
-
const contents = new TextEncoder().encode(JSON.stringify(record, null, 2));
|
|
720
|
-
if (action === Permission.Move) {
|
|
721
|
-
this.#tx.remove(entry.filePath);
|
|
722
|
-
this.#tx.rename(entry.childrenDir, childrenDir);
|
|
723
|
-
}
|
|
724
|
-
this.#tx.add(filePath, contents);
|
|
725
|
-
}
|
|
726
|
-
for (const update of moveUrlAliasUpdates) {
|
|
727
|
-
const entry = update.entry;
|
|
728
|
-
if (entry.id === id || update.data === entry.data) continue;
|
|
729
|
-
const record = createRecord(
|
|
730
|
-
{
|
|
731
|
-
...entry,
|
|
732
|
-
root,
|
|
733
|
-
workspace,
|
|
734
|
-
data: update.data
|
|
735
|
-
},
|
|
736
|
-
entry.status
|
|
737
|
-
);
|
|
738
|
-
const contents = new TextEncoder().encode(JSON.stringify(record, null, 2));
|
|
739
|
-
this.#tx.add(update.filePath, contents);
|
|
740
|
-
}
|
|
741
|
-
this.#messages.push(this.#reportOp("move", info.title));
|
|
742
|
-
return this;
|
|
743
|
-
}
|
|
744
|
-
remove({ id, locale, status }) {
|
|
745
|
-
const index = this.#index;
|
|
746
|
-
const entries2 = index.findMany((entry) => {
|
|
747
|
-
const matchesStatus = status === void 0 || entry.status === status;
|
|
748
|
-
const matchesLocale = locale === void 0 || entry.locale === locale;
|
|
749
|
-
return entry.id === id && matchesLocale && matchesStatus;
|
|
750
|
-
});
|
|
751
|
-
let info;
|
|
752
|
-
for (const entry of entries2) {
|
|
753
|
-
if (entry.status === "published")
|
|
754
|
-
assert(!entry.seeded, `Cannot remove seeded entry ${entry.filePath}`);
|
|
755
|
-
info = entry;
|
|
756
|
-
this.#checks.push([entry.filePath, entry.fileHash]);
|
|
757
|
-
this.#tx.remove(entry.filePath);
|
|
758
|
-
if (entry.status !== "draft") {
|
|
759
|
-
this.#tx.remove(entry.childrenDir);
|
|
760
|
-
}
|
|
761
|
-
if (entry.type === "MediaLibrary") {
|
|
762
|
-
const files = index.findMany((f) => {
|
|
763
|
-
return f.workspace === entry.workspace && f.root === entry.root && f.filePath.startsWith(entry.childrenDir) && f.type === "MediaFile";
|
|
764
|
-
});
|
|
765
|
-
for (const file of files) {
|
|
766
|
-
this.removeFile({
|
|
767
|
-
location: MediaLocation.storagePath(
|
|
768
|
-
this.#config,
|
|
769
|
-
entry.workspace,
|
|
770
|
-
file.data.location
|
|
771
|
-
)
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
if (entry.type === "MediaFile") {
|
|
776
|
-
this.removeFile({
|
|
777
|
-
location: MediaLocation.storagePath(
|
|
778
|
-
this.#config,
|
|
779
|
-
entry.workspace,
|
|
780
|
-
entry.data.location
|
|
781
|
-
)
|
|
782
|
-
});
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
if (info) {
|
|
786
|
-
this.#policy.assert(Permission.Delete, info);
|
|
787
|
-
this.#messages.unshift(this.#reportOp("remove", info.title));
|
|
788
|
-
}
|
|
789
|
-
return this;
|
|
790
|
-
}
|
|
791
|
-
removeFile(mutation) {
|
|
792
|
-
this.#policy.assert(Permission.Delete);
|
|
793
|
-
assert(mutation.location, "Missing location");
|
|
794
|
-
this.#messages.push(this.#reportOp("remove", mutation.location));
|
|
795
|
-
this.#fileChanges.push({ op: "removeFile", ...mutation });
|
|
796
|
-
return this;
|
|
797
|
-
}
|
|
798
|
-
uploadFile(mutation) {
|
|
799
|
-
this.#policy.assert(Permission.Upload);
|
|
800
|
-
this.#fileChanges.push({ op: "uploadFile", ...mutation });
|
|
801
|
-
return this;
|
|
802
|
-
}
|
|
803
|
-
description() {
|
|
804
|
-
return this.#messages.map((message, index, all) => {
|
|
805
|
-
if (index > 0) return message;
|
|
806
|
-
const suffix = all.length > 1 ? ` (and ${all.length - 1} other edits)` : "";
|
|
807
|
-
return `${message + suffix}`;
|
|
808
|
-
}).join("\n");
|
|
809
|
-
}
|
|
810
|
-
#reportOp(op, title) {
|
|
811
|
-
return `(${op}) ${title}`;
|
|
812
|
-
}
|
|
813
|
-
apply(mutations) {
|
|
814
|
-
for (const mutation of mutations) {
|
|
815
|
-
switch (mutation.op) {
|
|
816
|
-
case "create":
|
|
817
|
-
this.create(mutation);
|
|
818
|
-
break;
|
|
819
|
-
case "update":
|
|
820
|
-
this.update(mutation);
|
|
821
|
-
break;
|
|
822
|
-
case "publish":
|
|
823
|
-
this.publish(mutation);
|
|
824
|
-
break;
|
|
825
|
-
case "unpublish":
|
|
826
|
-
this.unpublish(mutation);
|
|
827
|
-
break;
|
|
828
|
-
case "archive":
|
|
829
|
-
this.archive(mutation);
|
|
830
|
-
break;
|
|
831
|
-
case "move":
|
|
832
|
-
this.move(mutation);
|
|
833
|
-
break;
|
|
834
|
-
case "remove":
|
|
835
|
-
this.remove(mutation);
|
|
836
|
-
break;
|
|
837
|
-
case "removeFile":
|
|
838
|
-
this.removeFile(mutation);
|
|
839
|
-
break;
|
|
840
|
-
case "uploadFile":
|
|
841
|
-
this.uploadFile(mutation);
|
|
842
|
-
break;
|
|
843
|
-
default:
|
|
844
|
-
unreachable(mutation);
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
async toRequest() {
|
|
849
|
-
const { from, into, changes } = await this.#tx.compile();
|
|
850
|
-
return {
|
|
851
|
-
fromSha: from.sha,
|
|
852
|
-
intoSha: into.sha,
|
|
853
|
-
description: this.description(),
|
|
854
|
-
checks: this.#checks,
|
|
855
|
-
changes: this.#fileChanges.concat(commitChanges(changes))
|
|
856
|
-
};
|
|
857
|
-
}
|
|
858
|
-
};
|
|
859
|
-
function aliasUrlsFromData(data) {
|
|
860
|
-
const result = /* @__PURE__ */ new Set();
|
|
861
|
-
for (const alias of aliasesFromData(data) ?? []) {
|
|
862
|
-
const url = aliasUrl(alias);
|
|
863
|
-
if (url) result.add(url);
|
|
864
|
-
}
|
|
865
|
-
return Array.from(result);
|
|
866
|
-
}
|
|
867
|
-
function dataWithUrlAlias(type, data, previousUrl, currentUrl) {
|
|
868
|
-
const target = typeAliasTarget(type);
|
|
869
|
-
if (!target) return data;
|
|
870
|
-
const aliasUrls = aliasUrlsFromData(data);
|
|
871
|
-
if (aliasUrls.includes(previousUrl)) return data;
|
|
872
|
-
const nextData = aliasUrls.includes(currentUrl) ? dataWithoutUrlAlias(data, currentUrl) : data;
|
|
873
|
-
const metadata = isRecord(nextData.metadata) ? nextData.metadata : {};
|
|
874
|
-
const aliases = target === "metadata" ? Array.isArray(metadata.aliases) ? metadata.aliases : [] : Array.isArray(nextData.aliases) ? nextData.aliases : [];
|
|
875
|
-
return dataWithAliases(
|
|
876
|
-
nextData,
|
|
877
|
-
target,
|
|
878
|
-
metadata,
|
|
879
|
-
aliases.concat(createUrlAliasRow(previousUrl, aliases))
|
|
880
|
-
);
|
|
881
|
-
}
|
|
882
|
-
function dataWithoutUrlAlias(data, url) {
|
|
883
|
-
let result = data;
|
|
884
|
-
if (Array.isArray(data.aliases)) {
|
|
885
|
-
result = {
|
|
886
|
-
...result,
|
|
887
|
-
aliases: data.aliases.filter((alias) => aliasUrl(alias) !== url)
|
|
888
|
-
};
|
|
889
|
-
}
|
|
890
|
-
const metadata = data.metadata;
|
|
891
|
-
if (isRecord(metadata) && Array.isArray(metadata.aliases)) {
|
|
892
|
-
result = {
|
|
893
|
-
...result,
|
|
894
|
-
metadata: {
|
|
895
|
-
...metadata,
|
|
896
|
-
aliases: metadata.aliases.filter((alias) => aliasUrl(alias) !== url)
|
|
897
|
-
}
|
|
898
|
-
};
|
|
899
|
-
}
|
|
900
|
-
return result;
|
|
901
|
-
}
|
|
902
|
-
function dataWithAliases(data, target, metadata, aliases) {
|
|
903
|
-
if (target === "aliases") return { ...data, aliases };
|
|
904
|
-
return {
|
|
905
|
-
...data,
|
|
906
|
-
metadata: {
|
|
907
|
-
...metadata,
|
|
908
|
-
aliases
|
|
909
|
-
}
|
|
910
|
-
};
|
|
911
|
-
}
|
|
912
|
-
function typeAliasTarget(type) {
|
|
913
|
-
if (Type.field(type, "aliases")) return "aliases";
|
|
914
|
-
const metadata = Type.field(type, "metadata");
|
|
915
|
-
if (!metadata) return void 0;
|
|
916
|
-
const options = Field.options(metadata);
|
|
917
|
-
const fields = options.fields;
|
|
918
|
-
if (!Type.isType(fields)) return void 0;
|
|
919
|
-
return Type.field(fields, "aliases") ? "metadata" : void 0;
|
|
920
|
-
}
|
|
921
|
-
function createUrlAliasRow(url, aliases) {
|
|
922
|
-
const orderedAliases = aliases.filter(isOrderedUrlAliasRow);
|
|
923
|
-
const editor = new ListEditor(orderedAliases);
|
|
924
|
-
const created = editor.add("alias", { url }).value().at(-1);
|
|
925
|
-
assert(created);
|
|
926
|
-
return created;
|
|
927
|
-
}
|
|
928
|
-
function isOrderedUrlAliasRow(value) {
|
|
929
|
-
if (!isRecord(value)) return false;
|
|
930
|
-
const id = value[ListRow.id];
|
|
931
|
-
const index = value[ListRow.index];
|
|
932
|
-
const type = value[ListRow.type];
|
|
933
|
-
const url = value.url;
|
|
934
|
-
return typeof id === "string" && typeof index === "string" && isValidOrderKey(index) && type === "alias" && typeof url === "string";
|
|
935
|
-
}
|
|
936
|
-
function startsWithSegments(value, prefix) {
|
|
937
|
-
return prefix.every((segment, index) => value[index] === segment);
|
|
938
|
-
}
|
|
939
|
-
export {
|
|
940
|
-
EntryTransaction
|
|
941
|
-
};
|