rimecms 0.33.0 → 1.0.1
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/adapter-sqlite/auth.server.d.ts +2 -2
- package/dist/adapter-sqlite/columns.server.js +2 -2
- package/dist/adapter-sqlite/connect.server.d.ts +12 -0
- package/dist/adapter-sqlite/connect.server.js +31 -0
- package/dist/adapter-sqlite/generate-schema/index.server.js +11 -3
- package/dist/adapter-sqlite/generate-schema/root.server.d.ts +13 -4
- package/dist/adapter-sqlite/generate-schema/root.server.js +75 -131
- package/dist/adapter-sqlite/generate-schema/templates.server.d.ts +36 -15
- package/dist/adapter-sqlite/generate-schema/templates.server.js +60 -18
- package/dist/adapter-sqlite/index.server.d.ts +13 -5
- package/dist/adapter-sqlite/index.server.js +9 -6
- package/dist/adapter-sqlite/naming.server.d.ts +6 -8
- package/dist/adapter-sqlite/naming.server.js +22 -4
- package/dist/adapter-sqlite/paths.server.d.ts +10 -0
- package/dist/adapter-sqlite/paths.server.js +131 -0
- package/dist/adapter-sqlite/read.server.d.ts +10 -1
- package/dist/adapter-sqlite/read.server.js +22 -10
- package/dist/adapter-sqlite/rows.server.d.ts +1 -1
- package/dist/adapter-sqlite/select.server.d.ts +19 -0
- package/dist/adapter-sqlite/select.server.js +71 -63
- package/dist/adapter-sqlite/table.server.d.ts +2 -2
- package/dist/adapter-sqlite/transform.server.js +33 -3
- package/dist/adapter-sqlite/types.server.d.ts +10 -3
- package/dist/adapter-sqlite/where.server.d.ts +2 -3
- package/dist/adapter-sqlite/where.server.js +19 -1
- package/dist/core/adapter.d.ts +98 -0
- package/dist/core/auth/better-auth/config.server.d.ts +3 -3
- package/dist/core/auth/better-auth/instance.server.d.ts +6 -6
- package/dist/core/auth/handler/index.server.js +1 -1
- package/dist/core/auth/staff/derive.js +1 -1
- package/dist/core/auth/validate-config.js +3 -5
- package/dist/core/boot.server.d.ts +8 -8
- package/dist/core/config/context.server.d.ts +2 -2
- package/dist/core/config/types.d.ts +43 -5
- package/dist/core/config/validate.server.js +34 -51
- package/dist/core/dev/cli/commands/build.js +21 -6
- package/dist/core/dev/cli/commands/init.server.d.ts +2 -1
- package/dist/core/dev/cli/commands/init.server.js +32 -6
- package/dist/core/dev/cli/index.js +1 -0
- package/dist/core/dev/cli/templates/init.d.ts +6 -1
- package/dist/core/dev/cli/templates/init.js +30 -2
- package/dist/core/dev/cli/util/package-manager.server.d.ts +1 -0
- package/dist/core/dev/cli/util/package-manager.server.js +11 -8
- package/dist/core/dev/cli/util/package.server.d.ts +9 -0
- package/dist/core/dev/cli/util/package.server.js +43 -0
- package/dist/core/dev/codegen/routes/common.server.d.ts +2 -0
- package/dist/core/dev/codegen/routes/common.server.js +7 -3
- package/dist/core/dev/codegen/routes/util.server.d.ts +2 -1
- package/dist/core/dev/codegen/routes/util.server.js +4 -1
- package/dist/core/dev/codegen/types/contributions.server.d.ts +3 -2
- package/dist/core/dev/codegen/types/contributions.server.js +10 -3
- package/dist/core/dev/config-memo.server.js +4 -0
- package/dist/core/dev/vite.server.js +4 -3
- package/dist/core/fields/blank.d.ts +21 -0
- package/dist/core/fields/blank.js +37 -0
- package/dist/core/fields/builders/field-builder.d.ts +53 -0
- package/dist/core/fields/builders/field-builder.js +14 -1
- package/dist/core/fields/builders/form-field-builder.d.ts +8 -0
- package/dist/core/fields/builders/form-field-builder.js +14 -1
- package/dist/core/fields/util.d.ts +9 -2
- package/dist/core/fields/util.js +123 -135
- package/dist/core/fields/walk.d.ts +44 -0
- package/dist/core/fields/walk.js +55 -0
- package/dist/core/handler.server.js +4 -0
- package/dist/core/i18n/context.d.ts +5 -0
- package/dist/core/i18n/context.js +6 -0
- package/dist/core/i18n/en/common.d.ts +71 -0
- package/dist/core/i18n/en/common.js +72 -1
- package/dist/core/i18n/en/fields.d.ts +68 -0
- package/dist/core/i18n/en/fields.js +69 -1
- package/dist/core/i18n/fr/common.d.ts +71 -0
- package/dist/core/i18n/fr/common.js +72 -1
- package/dist/core/i18n/fr/fields.d.ts +68 -0
- package/dist/core/i18n/fr/fields.js +69 -1
- package/dist/core/i18n/index.d.ts +29 -3
- package/dist/core/i18n/index.js +55 -29
- package/dist/core/locale/copy.server.js +3 -3
- package/dist/core/logger.server.js +15 -6
- package/dist/core/pipeline/build-document.server.d.ts +3 -0
- package/dist/core/pipeline/build-document.server.js +10 -7
- package/dist/core/pipeline/config-map/index.d.ts +9 -0
- package/dist/core/pipeline/config-map/index.js +16 -50
- package/dist/core/pipeline/hooks/process-document-fields.server.d.ts +3 -0
- package/dist/core/pipeline/hooks/process-document-fields.server.js +48 -12
- package/dist/core/pipeline/hooks/set-default-values.server.d.ts +1 -0
- package/dist/core/pipeline/hooks/set-default-values.server.js +1 -0
- package/dist/core/pipeline/persist/blocks/extract.server.js +1 -1
- package/dist/core/pipeline/persist/relations/extract.server.js +2 -0
- package/dist/core/pipeline/populate-relations.server.d.ts +27 -0
- package/dist/core/pipeline/populate-relations.server.js +42 -0
- package/dist/core/pipeline/run.server.d.ts +17 -6
- package/dist/core/pipeline/run.server.js +44 -30
- package/dist/core/plugins/cache/module.server.d.ts +1 -1
- package/dist/core/plugins/cache/module.server.js +5 -5
- package/dist/core/prototype/area/api.server.js +1 -2
- package/dist/core/prototype/area/definition.js +1 -10
- package/dist/core/prototype/area/definition.server.js +4 -5
- package/dist/core/prototype/area/hooks.server.js +3 -2
- package/dist/core/prototype/area/operations/find.js +2 -0
- package/dist/core/prototype/blank.d.ts +26 -0
- package/dist/core/prototype/blank.js +22 -0
- package/dist/core/prototype/collection/api.server.d.ts +29 -3
- package/dist/core/prototype/collection/api.server.js +47 -4
- package/dist/core/prototype/collection/definition.js +0 -3
- package/dist/core/prototype/collection/hooks/merge-with-blank.server.d.ts +5 -1
- package/dist/core/prototype/collection/hooks/merge-with-blank.server.js +8 -22
- package/dist/core/prototype/collection/hooks.server.js +11 -5
- package/dist/core/prototype/collection/nested/module.server.js +3 -1
- package/dist/core/prototype/collection/nested/tree.d.ts +12 -0
- package/dist/core/prototype/collection/nested/tree.js +42 -0
- package/dist/core/prototype/collection/operations/duplicate.js +1 -1
- package/dist/core/prototype/collection/operations/find-by-id.js +2 -0
- package/dist/core/prototype/collection/operations/find-by-ids.d.ts +19 -0
- package/dist/core/prototype/collection/operations/find-by-ids.js +54 -0
- package/dist/core/prototype/collection/operations/find.js +21 -27
- package/dist/core/prototype/collection/operations/update-slug-by-id.d.ts +20 -0
- package/dist/core/prototype/collection/operations/update-slug-by-id.js +53 -0
- package/dist/core/prototype/collection/rest/index.server.js +3 -1
- package/dist/core/prototype/collection/rest/update-slug-by-id.server.d.ts +2 -0
- package/dist/core/prototype/collection/rest/update-slug-by-id.server.js +20 -0
- package/dist/core/prototype/collection/thumbnail/find-thumbnail.d.ts +2 -1
- package/dist/core/prototype/collection/thumbnail/find-thumbnail.js +4 -27
- package/dist/core/prototype/collection/thumbnail/hooks/set-document-thumbnail.server.js +1 -1
- package/dist/core/prototype/collection/upload/directories/derive.js +3 -1
- package/dist/core/prototype/collection/upload/disk/delete.server.js +1 -2
- package/dist/core/prototype/define.js +2 -0
- package/dist/core/prototype/shared/metas/fields.js +2 -1
- package/dist/core/prototype/shared/title/find-title.d.ts +2 -1
- package/dist/core/prototype/shared/title/find-title.js +5 -28
- package/dist/core/prototype/shared/title/hooks/set-document-title.server.js +1 -1
- package/dist/core/prototype/shared/url/addresses.server.d.ts +36 -0
- package/dist/core/prototype/shared/url/addresses.server.js +119 -0
- package/dist/core/prototype/shared/url/doc-type.d.ts +6 -0
- package/dist/core/prototype/shared/url/doc-type.js +9 -0
- package/dist/core/prototype/shared/url/format.server.d.ts +27 -0
- package/dist/core/prototype/shared/url/format.server.js +38 -0
- package/dist/core/prototype/shared/url/hooks/create-paths.server.d.ts +2 -0
- package/dist/core/prototype/shared/url/hooks/create-paths.server.js +9 -0
- package/dist/core/prototype/shared/url/hooks/detach-paths.server.d.ts +6 -0
- package/dist/core/prototype/shared/url/hooks/detach-paths.server.js +19 -0
- package/dist/core/prototype/shared/url/hooks/index.server.d.ts +5 -1
- package/dist/core/prototype/shared/url/hooks/index.server.js +5 -1
- package/dist/core/prototype/shared/url/hooks/set-area-url.server.d.ts +2 -0
- package/dist/core/prototype/shared/url/hooks/set-area-url.server.js +8 -0
- package/dist/core/prototype/shared/url/hooks/set-live-url.server.d.ts +5 -0
- package/dist/core/prototype/shared/url/hooks/set-live-url.server.js +19 -0
- package/dist/core/prototype/shared/url/hooks/sync-paths.server.d.ts +8 -0
- package/dist/core/prototype/shared/url/hooks/sync-paths.server.js +38 -0
- package/dist/core/prototype/shared/url/refresh.server.d.ts +36 -0
- package/dist/core/prototype/shared/url/refresh.server.js +58 -0
- package/dist/core/prototype/shared/versions/configure.server.js +3 -0
- package/dist/core/routes/context.server.d.ts +2 -1
- package/dist/fields/blocks/component/AddBlockButton.svelte +48 -137
- package/dist/fields/blocks/component/Block.svelte +153 -117
- package/dist/fields/blocks/component/Block.svelte.d.ts +11 -5
- package/dist/fields/blocks/component/BlockActions.svelte +76 -26
- package/dist/fields/blocks/component/BlockActions.svelte.d.ts +3 -0
- package/dist/fields/blocks/component/Blocks.svelte +248 -91
- package/dist/fields/blocks/component/focus/BlocksFocus.svelte +680 -0
- package/dist/fields/blocks/component/focus/BlocksFocus.svelte.d.ts +7 -0
- package/dist/fields/blocks/component/focus/Layers.svelte +145 -0
- package/dist/fields/blocks/component/focus/Layers.svelte.d.ts +9 -0
- package/dist/fields/blocks/component/focus/LayersList.svelte +304 -0
- package/dist/fields/blocks/component/focus/LayersList.svelte.d.ts +10 -0
- package/dist/fields/blocks/component/focus/Palette.svelte +135 -0
- package/dist/fields/blocks/component/focus/Palette.svelte.d.ts +9 -0
- package/dist/fields/blocks/component/focus/RenderPlaceholder.svelte +77 -0
- package/dist/fields/blocks/component/focus/RenderPlaceholder.svelte.d.ts +10 -0
- package/dist/fields/blocks/component/focus/Renders.svelte +302 -0
- package/dist/fields/blocks/component/focus/Renders.svelte.d.ts +11 -0
- package/dist/fields/blocks/component/focus/Stage.svelte +190 -0
- package/dist/fields/blocks/component/focus/Stage.svelte.d.ts +8 -0
- package/dist/fields/blocks/component/focus/StagePlaceholder.svelte +69 -0
- package/dist/fields/blocks/component/focus/StagePlaceholder.svelte.d.ts +3 -0
- package/dist/fields/blocks/component/focus/focus.svelte.d.ts +140 -0
- package/dist/fields/blocks/component/focus/focus.svelte.js +424 -0
- package/dist/fields/blocks/component/picker/BlockPicker.svelte +88 -0
- package/dist/fields/blocks/component/picker/BlockPicker.svelte.d.ts +10 -0
- package/dist/fields/blocks/component/picker/BlockTile.svelte +121 -0
- package/dist/fields/blocks/component/picker/BlockTile.svelte.d.ts +12 -0
- package/dist/fields/blocks/index.d.ts +49 -7
- package/dist/fields/blocks/index.js +61 -12
- package/dist/fields/checkbox/component/Checkbox.svelte +11 -37
- package/dist/fields/checkbox/component/Checkbox.svelte.d.ts +1 -0
- package/dist/fields/combobox/component/ComboBox.svelte +37 -7
- package/dist/fields/combobox/component/combobox.css +26 -10
- package/dist/fields/date/component/Date.svelte +43 -12
- package/dist/fields/group/component/Group.svelte +110 -41
- package/dist/fields/group/index.d.ts +5 -1
- package/dist/fields/group/index.js +10 -2
- package/dist/fields/link/component/Link.svelte +184 -143
- package/dist/fields/link/component/RessourceInput.svelte +26 -24
- package/dist/fields/link/index.d.ts +2 -1
- package/dist/fields/link/module.server.js +2 -4
- package/dist/fields/number/component/Number.svelte +38 -20
- package/dist/fields/number/component/number.css +22 -20
- package/dist/fields/number/index.d.ts +1 -0
- package/dist/fields/radio/component/Radio.svelte +12 -0
- package/dist/fields/radio/index.js +1 -1
- package/dist/fields/relation/component/Relation.svelte +169 -40
- package/dist/fields/relation/component/RelationInline.svelte +258 -0
- package/dist/fields/relation/component/RelationInline.svelte.d.ts +26 -0
- package/dist/fields/relation/component/default/Default.svelte +210 -100
- package/dist/fields/relation/component/default/Default.svelte.d.ts +14 -1
- package/dist/fields/relation/component/types.d.ts +4 -0
- package/dist/fields/relation/component/upload/Browse.svelte +619 -88
- package/dist/fields/relation/component/upload/Browse.svelte.d.ts +10 -2
- package/dist/fields/relation/component/upload/Create.svelte +41 -0
- package/dist/fields/relation/component/upload/Create.svelte.d.ts +13 -0
- package/dist/fields/relation/component/upload/Upload.svelte +287 -101
- package/dist/fields/relation/component/upload/Upload.svelte.d.ts +6 -1
- package/dist/fields/relation/component/upload/upload.css +5 -81
- package/dist/fields/relation/index.d.ts +1 -41
- package/dist/fields/relation/index.js +0 -67
- package/dist/fields/relation/module.server.js +7 -1
- package/dist/fields/relation/populate.d.ts +8 -0
- package/dist/fields/relation/populate.js +49 -0
- package/dist/fields/relation/util.d.ts +69 -0
- package/dist/fields/relation/util.js +103 -0
- package/dist/fields/relation/value.d.ts +25 -0
- package/dist/fields/relation/value.js +27 -0
- package/dist/fields/rich-text/client.d.ts +2 -5
- package/dist/fields/rich-text/client.js +1 -3
- package/dist/fields/rich-text/component/Cell.svelte +1 -1
- package/dist/fields/rich-text/component/RichText.svelte +12 -80
- package/dist/fields/rich-text/component/RichText.svelte.d.ts +1 -1
- package/dist/fields/rich-text/component/RichTextInline.svelte +28 -0
- package/dist/fields/rich-text/component/RichTextInline.svelte.d.ts +11 -0
- package/dist/fields/rich-text/component/bubble-menu/bubble-menu.css +4 -3
- package/dist/fields/rich-text/component/bubble-menu/bubble-menu.svelte +3 -1
- package/dist/fields/rich-text/component/bubble-menu/icon-button/icon-button.css +2 -2
- package/dist/fields/rich-text/component/bubble-menu/node-selector/node-selector.css +7 -10
- package/dist/fields/rich-text/component/drag-handle/drag-handle.css +0 -2
- package/dist/fields/rich-text/component/styles/editor.css +111 -0
- package/dist/fields/rich-text/component/styles/field.css +71 -0
- package/dist/fields/rich-text/component/suggestion/suggestion.svelte +41 -56
- package/dist/fields/rich-text/core/build-editor-config.js +1 -1
- package/dist/fields/rich-text/core/extensions/drag-handle/drag-handle-plugin.js +29 -3
- package/dist/fields/rich-text/core/extensions/drag-handle/drag-handle.d.ts +1 -0
- package/dist/fields/rich-text/core/extensions/drag-handle/drag-handle.js +2 -1
- package/dist/fields/rich-text/core/features/fields/fields.css +2 -3
- package/dist/fields/rich-text/core/features/hr/hr.css +4 -4
- package/dist/fields/rich-text/core/features/link/component/link-selector.css +0 -4
- package/dist/fields/rich-text/core/features/link/component/link-selector.svelte +24 -8
- package/dist/fields/rich-text/core/features/resource/resource-extension.js +3 -3
- package/dist/fields/rich-text/core/features/resource/resource.svelte +21 -7
- package/dist/fields/rich-text/core/features/upload/upload-extension.js +3 -4
- package/dist/fields/rich-text/core/features/upload/upload.svelte +21 -9
- package/dist/fields/rich-text/core/rich-text-editor-core.svelte +103 -0
- package/dist/fields/rich-text/core/rich-text-editor-core.svelte.d.ts +15 -0
- package/dist/fields/rich-text/index.d.ts +0 -17
- package/dist/fields/rich-text/index.js +0 -44
- package/dist/fields/rich-text/json.d.ts +18 -0
- package/dist/fields/rich-text/json.js +44 -0
- package/dist/fields/select/component/Select.svelte +67 -28
- package/dist/fields/slug/component/Slug.svelte +26 -53
- package/dist/fields/slug/index.d.ts +1 -0
- package/dist/fields/slug/index.js +1 -1
- package/dist/fields/tabs/component/Tabs.svelte +28 -22
- package/dist/fields/tabs/index.d.ts +4 -1
- package/dist/fields/tabs/index.js +17 -5
- package/dist/fields/text/index.d.ts +1 -0
- package/dist/fields/textarea/component/TextArea.svelte +28 -13
- package/dist/fields/textarea/index.d.ts +1 -0
- package/dist/fields/time/component/Time.svelte +9 -2
- package/dist/fields/toggle/component/Toggle.svelte +8 -25
- package/dist/fields/toggle/component/Toggle.svelte.d.ts +1 -0
- package/dist/fields/toggle/index.d.ts +1 -0
- package/dist/fields/tree/component/AddItemButton.svelte +18 -5
- package/dist/fields/tree/component/Tree.svelte +48 -19
- package/dist/fields/tree/component/TreeBlock.svelte +318 -104
- package/dist/fields/tree/component/TreeBlockActions.svelte +71 -7
- package/dist/fields/tree/component/TreeBlockActions.svelte.d.ts +4 -0
- package/dist/fields/tree/component/props.d.ts +2 -1
- package/dist/fields/tree/index.d.ts +13 -1
- package/dist/fields/tree/index.js +35 -9
- package/dist/fields/types.d.ts +3 -1
- package/dist/index.d.ts +2 -8
- package/dist/index.js +2 -6
- package/dist/{panel/components/sections/live → live}/Consumer.svelte +2 -2
- package/dist/{panel/components/sections/live → live}/Consumer.svelte.d.ts +1 -1
- package/dist/{panel/components/sections/live → live}/LiveEdit.svelte +3 -3
- package/dist/{panel/components/sections/live → live}/Provider.svelte +1 -1
- package/dist/{panel/context/live.svelte.d.ts → live/context.svelte.d.ts} +1 -1
- package/dist/{panel/context/live.svelte.js → live/context.svelte.js} +3 -74
- package/dist/panel/components/Root.svelte +16 -44
- package/dist/panel/components/Root.svelte.d.ts +1 -1
- package/dist/panel/components/fields/Error.svelte +18 -3
- package/dist/panel/components/fields/FieldsPreview.svelte +30 -17
- package/dist/panel/components/fields/FieldsPreviewTrigger.svelte +25 -3
- package/dist/panel/components/fields/Hint.svelte +51 -8
- package/dist/panel/components/fields/Hint.svelte.d.ts +11 -0
- package/dist/panel/components/fields/Label.svelte +2 -0
- package/dist/panel/components/fields/LabelFor.svelte +7 -2
- package/dist/panel/components/fields/RenderFields.svelte +10 -3
- package/dist/panel/components/fields/fieldset.svelte.d.ts +4 -1
- package/dist/panel/components/fields/fieldset.svelte.js +9 -2
- package/dist/panel/components/fields/index.d.ts +1 -0
- package/dist/panel/components/fields/setting.css +82 -0
- package/dist/panel/components/sections/auth/AuthForm.svelte +25 -26
- package/dist/panel/components/sections/collection/Avatar.svelte +61 -0
- package/dist/panel/components/sections/collection/Avatar.svelte.d.ts +9 -0
- package/dist/panel/components/sections/collection/DocStatus.svelte +28 -0
- package/dist/panel/components/sections/collection/DocStatus.svelte.d.ts +7 -0
- package/dist/panel/components/sections/collection/Empty.svelte +3 -3
- package/dist/panel/components/sections/collection/StatusDot.svelte +7 -5
- package/dist/panel/components/sections/collection/When.svelte +33 -0
- package/dist/panel/components/sections/collection/When.svelte.d.ts +8 -0
- package/dist/panel/components/sections/collection/bulk-upload/BulkUploadDialog.svelte +65 -21
- package/dist/panel/components/sections/collection/bulk-upload/BulkUploadDialog.svelte.d.ts +3 -2
- package/dist/panel/components/sections/collection/bulk-upload/DropZone.svelte +45 -162
- package/dist/panel/components/sections/collection/bulk-upload/DropZone.svelte.d.ts +3 -2
- package/dist/panel/components/sections/collection/bulk-upload/FileDrop.svelte +151 -0
- package/dist/panel/components/sections/collection/bulk-upload/FileDrop.svelte.d.ts +17 -0
- package/dist/panel/components/sections/collection/bulk-upload/PageDrop.svelte +177 -0
- package/dist/panel/components/sections/collection/bulk-upload/PageDrop.svelte.d.ts +12 -0
- package/dist/panel/components/sections/collection/bulk-upload/UploadProgress.svelte +75 -0
- package/dist/panel/components/sections/collection/bulk-upload/UploadProgress.svelte.d.ts +8 -0
- package/dist/panel/components/sections/collection/folder/Folder.svelte +18 -3
- package/dist/panel/components/sections/collection/folder/FolderEdit.svelte +26 -18
- package/dist/panel/components/sections/collection/folder/FolderWithActions.svelte +98 -58
- package/dist/panel/components/sections/collection/folder/FolderWithActions.svelte.d.ts +0 -1
- package/dist/panel/components/sections/collection/folder/Folders.svelte +60 -0
- package/dist/panel/components/sections/collection/folder/Folders.svelte.d.ts +7 -0
- package/dist/panel/components/sections/collection/grid/CollectionGrid.svelte +31 -71
- package/dist/panel/components/sections/collection/grid/CollectionGrid.svelte.d.ts +1 -0
- package/dist/panel/components/sections/collection/grid/create-directory-dialog/CreateDirectoryDialog.svelte +5 -3
- package/dist/panel/components/sections/collection/grid/grid-item/GridItem.svelte +250 -37
- package/dist/panel/components/sections/collection/grid/grid-item/GridItem.svelte.d.ts +2 -0
- package/dist/panel/components/sections/collection/header/ButtonCreate.svelte +43 -18
- package/dist/panel/components/sections/collection/header/ButtonCreate.svelte.d.ts +6 -4
- package/dist/panel/components/sections/collection/header/DisplayMode.svelte +69 -58
- package/dist/panel/components/sections/collection/header/DisplayMode.svelte.d.ts +0 -1
- package/dist/panel/components/sections/collection/header/FilterMenu.svelte +60 -0
- package/dist/panel/components/sections/collection/header/FilterMenu.svelte.d.ts +14 -0
- package/dist/panel/components/sections/collection/header/SearchInput.svelte +17 -26
- package/dist/panel/components/sections/collection/header/SelectUI.svelte +19 -34
- package/dist/panel/components/sections/collection/list/CollectionList.svelte +99 -68
- package/dist/panel/components/sections/collection/list/columns.d.ts +21 -0
- package/dist/panel/components/sections/collection/list/columns.js +23 -0
- package/dist/panel/components/sections/collection/list/header/Header.svelte +99 -51
- package/dist/panel/components/sections/collection/list/row/Row.svelte +165 -82
- package/dist/panel/components/sections/collection/list/row/Row.svelte.d.ts +4 -0
- package/dist/panel/components/sections/collection/tree/CollectionTree.svelte +92 -44
- package/dist/panel/components/sections/collection/tree/CollectionTree.svelte.d.ts +1 -0
- package/dist/panel/components/sections/collection/tree/CollectionTreeNode.svelte +139 -43
- package/dist/panel/components/sections/collection/tree/CollectionTreeNode.svelte.d.ts +2 -0
- package/dist/panel/components/sections/collection/upload-thumb-cell/UploadThumbCell.svelte +1 -1
- package/dist/panel/components/sections/commands/CommandButton.svelte +99 -0
- package/dist/panel/components/sections/commands/CommandButton.svelte.d.ts +10 -0
- package/dist/panel/components/sections/commands/CommandPalette.svelte +275 -0
- package/dist/panel/components/sections/commands/CommandPalette.svelte.d.ts +8 -0
- package/dist/panel/components/sections/commands/Commands.svelte +18 -0
- package/dist/panel/components/sections/commands/Commands.svelte.d.ts +9 -0
- package/dist/panel/components/sections/document/AuthAPIKeyDialog.svelte +23 -7
- package/dist/panel/components/sections/document/AuthFooter.svelte +31 -12
- package/dist/panel/components/sections/document/AutoSaveBanner.svelte +24 -7
- package/dist/panel/components/sections/document/ButtonSave.svelte +32 -21
- package/dist/panel/components/sections/document/ButtonSave.svelte.d.ts +5 -5
- package/dist/panel/components/sections/document/ButtonStatus.svelte +68 -20
- package/dist/panel/components/sections/document/ChangeSlugDialog.svelte +199 -0
- package/dist/panel/components/sections/document/ChangeSlugDialog.svelte.d.ts +10 -0
- package/dist/panel/components/sections/document/CurrentlyEdited.svelte +2 -2
- package/dist/panel/components/sections/document/Document.svelte +96 -65
- package/dist/panel/components/sections/document/DocumentChildren.svelte +175 -0
- package/dist/panel/components/sections/document/DocumentChildren.svelte.d.ts +8 -0
- package/dist/panel/components/sections/document/DocumentUrl.svelte +119 -0
- package/dist/panel/components/sections/document/DocumentUrl.svelte.d.ts +9 -0
- package/dist/panel/components/sections/document/Header.svelte +171 -94
- package/dist/panel/components/sections/document/Settings.svelte +255 -110
- package/dist/panel/components/sections/document/Settings.svelte.d.ts +0 -1
- package/dist/panel/components/sections/document/Versions.svelte +5 -3
- package/dist/panel/components/sections/document/upload-header/UploadHeader.svelte +112 -53
- package/dist/panel/components/sections/document/upload-header/UploadHeader.svelte.d.ts +2 -2
- package/dist/panel/components/sections/document/upload-header/drop-zone/DropZone.svelte +74 -41
- package/dist/panel/components/sections/live/LiveFloatingUI.svelte +30 -11
- package/dist/panel/components/sections/live/live-edit-panel.css +2 -2
- package/dist/panel/components/sections/page-layout/Page.svelte +13 -1
- package/dist/panel/components/ui/breadcrumb/BreadCrumb.svelte +55 -27
- package/dist/panel/components/ui/button/button.svelte +81 -54
- package/dist/panel/components/ui/button/index.d.ts +7 -3
- package/dist/panel/components/ui/button/index.js +2 -2
- package/dist/panel/components/ui/calendar/calendar.css +27 -27
- package/dist/panel/components/ui/card/card-description.svelte +1 -1
- package/dist/panel/components/ui/card/card.svelte +21 -4
- package/dist/panel/components/ui/card-document/card-document.svelte +24 -12
- package/dist/panel/components/ui/card-resource/card-resource.svelte +26 -8
- package/dist/panel/components/ui/checkbox/checkbox.css +8 -10
- package/dist/panel/components/ui/checkbox/checkbox.svelte.d.ts +1 -1
- package/dist/panel/components/ui/command/command-dialog.css +28 -4
- package/dist/panel/components/ui/command/command-dialog.svelte +4 -1
- package/dist/panel/components/ui/command/command-dialog.svelte.d.ts +2 -0
- package/dist/panel/components/ui/command/command-empty.css +1 -1
- package/dist/panel/components/ui/command/command-group.css +3 -3
- package/dist/panel/components/ui/command/command-input-select.svelte +3 -3
- package/dist/panel/components/ui/command/command-input.svelte +38 -14
- package/dist/panel/components/ui/command/command-input.svelte.d.ts +6 -1
- package/dist/panel/components/ui/command/command-item.css +2 -2
- package/dist/panel/components/ui/command/command-list.css +1 -1
- package/dist/panel/components/ui/command/command-separator.css +1 -1
- package/dist/panel/components/ui/context-menu/context-menu-item.css +2 -2
- package/dist/panel/components/ui/context-menu/context-menu.css +6 -7
- package/dist/panel/components/ui/dialog/dialog-content.css +8 -10
- package/dist/panel/components/ui/dialog/dialog-content.svelte +19 -0
- package/dist/panel/components/ui/dialog/dialog-description.css +1 -1
- package/dist/panel/components/ui/dialog/dialog-footer.svelte +5 -1
- package/dist/panel/components/ui/dialog/dialog-overlay.css +1 -1
- package/dist/panel/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +19 -5
- package/dist/panel/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte.d.ts +1 -1
- package/dist/panel/components/ui/dropdown-menu/dropdown-menu-content.css +6 -4
- package/dist/panel/components/ui/dropdown-menu/dropdown-menu-item.css +1 -1
- package/dist/panel/components/ui/dropdown-menu/dropdown-menu-radio-item.css +1 -1
- package/dist/panel/components/ui/dropdown-menu/dropdown-menu-separator.css +1 -1
- package/dist/panel/components/ui/input/input.svelte +57 -31
- package/dist/panel/components/ui/kbd/Kbd.svelte +90 -0
- package/dist/panel/components/ui/kbd/Kbd.svelte.d.ts +11 -0
- package/dist/panel/components/ui/kbd/index.d.ts +1 -0
- package/dist/panel/components/ui/kbd/index.js +1 -0
- package/dist/panel/components/ui/label/label.css +5 -3
- package/dist/panel/components/ui/language-switcher/LanguageSwitcher.svelte +27 -15
- package/dist/panel/components/ui/nav/Nav.svelte +180 -110
- package/dist/panel/components/ui/nav/Nav.svelte.d.ts +0 -2
- package/dist/panel/components/ui/nav/NavGroup.svelte +87 -73
- package/dist/panel/components/ui/nav/NavItemButton.svelte +69 -29
- package/dist/panel/components/ui/nav/UserButton.svelte +132 -71
- package/dist/panel/components/ui/page-header/PageHeader.svelte +140 -42
- package/dist/panel/components/ui/page-header/PageHeader.svelte.d.ts +8 -1
- package/dist/panel/components/ui/popover/popover-content.css +4 -3
- package/dist/panel/components/ui/radio-group/radio-group.css +4 -6
- package/dist/panel/components/ui/radio-row-group/radio-row-group.css +19 -7
- package/dist/panel/components/ui/scroll-area/scroll-area.css +2 -2
- package/dist/panel/components/ui/separator/separator.svelte +1 -1
- package/dist/panel/components/ui/sheet/index.d.ts +4 -4
- package/dist/panel/components/ui/sheet/index.js +5 -5
- package/dist/panel/components/ui/sheet/sheet.css +50 -11
- package/dist/panel/components/ui/sonner/sonner.css +11 -8
- package/dist/panel/components/ui/switch/switch.css +13 -18
- package/dist/panel/components/ui/switch/switch.svelte.d.ts +1 -1
- package/dist/panel/components/ui/tabs/tabs.css +44 -35
- package/dist/panel/components/ui/tag/tag.svelte +20 -6
- package/dist/panel/components/ui/tooltip/tooltip-content.svelte +14 -4
- package/dist/panel/components/ui/tree/tree-rows.css +146 -0
- package/dist/panel/context/blocks-ops.d.ts +78 -0
- package/dist/panel/context/blocks-ops.js +170 -0
- package/dist/panel/context/collection.svelte.d.ts +28 -0
- package/dist/panel/context/collection.svelte.js +120 -65
- package/dist/panel/context/commands.svelte.d.ts +80 -0
- package/dist/panel/context/commands.svelte.js +108 -0
- package/dist/panel/context/config.svelte.d.ts +2 -2
- package/dist/panel/context/documentForm.svelte.d.ts +34 -2
- package/dist/panel/context/documentForm.svelte.js +106 -103
- package/dist/panel/context/nav.svelte.d.ts +23 -0
- package/dist/panel/context/nav.svelte.js +56 -0
- package/dist/panel/fonts/Geist-VariableFont_wght.ttf +0 -0
- package/dist/panel/fonts/GeistMono-VariableFont_wght.ttf +0 -0
- package/dist/panel/index.d.ts +7 -4
- package/dist/panel/index.js +11 -5
- package/dist/panel/pages/auth/forgot-password/ForgotPassword.svelte +16 -1
- package/dist/panel/pages/collection/CollectionPage.svelte +236 -61
- package/dist/panel/pages/collection/load.server.js +1 -1
- package/dist/panel/pages/dashboard/Dashboard.svelte +135 -90
- package/dist/panel/pages/dashboard/DashboardCard.svelte +109 -0
- package/dist/panel/pages/dashboard/DashboardCard.svelte.d.ts +14 -0
- package/dist/panel/pages/dashboard/DashboardCollection.svelte +180 -57
- package/dist/panel/pages/dashboard/DashboardCollection.svelte.d.ts +1 -0
- package/dist/panel/pages/dashboard/DashboardRow.svelte +93 -0
- package/dist/panel/pages/dashboard/DashboardRow.svelte.d.ts +16 -0
- package/dist/panel/pages/dashboard/load.server.js +49 -25
- package/dist/panel/pages/dashboard/time.d.ts +19 -0
- package/dist/panel/pages/dashboard/time.js +29 -0
- package/dist/panel/pages/dashboard/types.d.ts +9 -2
- package/dist/panel/pages/live/Live.svelte +53 -50
- package/dist/panel/public.d.ts +4 -0
- package/dist/panel/public.js +6 -0
- package/dist/panel/style/font.css +21 -32
- package/dist/panel/style/index.css +191 -122
- package/dist/panel/style/mixins/index.css +14 -0
- package/dist/panel/style/palette.css +35 -26
- package/dist/panel/style/postcss/size-function.d.ts +4 -0
- package/dist/panel/style/postcss/size-function.js +24 -0
- package/dist/panel/style/radius.css +4 -5
- package/dist/panel/style/scheme.css +111 -0
- package/dist/panel/style/size.css +3 -0
- package/dist/panel/util/Sortable.js +9 -4
- package/dist/panel/util/keys.d.ts +24 -0
- package/dist/panel/util/keys.js +63 -0
- package/dist/panel/util/time.d.ts +12 -0
- package/dist/panel/util/time.js +35 -0
- package/dist/panel/util/upload-file.d.ts +106 -0
- package/dist/panel/util/upload-file.js +165 -0
- package/dist/public.d.ts +13 -0
- package/dist/public.js +12 -0
- package/dist/util/index.d.ts +7 -10
- package/dist/util/index.js +7 -8
- package/dist/util/object.d.ts +10 -0
- package/dist/util/object.js +22 -1
- package/dist/util/string.d.ts +17 -0
- package/dist/util/string.js +23 -0
- package/package.json +12 -8
- package/dist/core/pipeline/config-map/build-tree-map.d.ts +0 -4
- package/dist/core/pipeline/config-map/build-tree-map.js +0 -30
- package/dist/core/prototype/doc.d.ts +0 -31
- package/dist/core/prototype/doc.js +0 -118
- package/dist/core/prototype/shared/url/augment.d.ts +0 -13
- package/dist/core/prototype/shared/url/augment.js +0 -11
- package/dist/core/prototype/shared/url/hooks/populate-url.server.d.ts +0 -4
- package/dist/core/prototype/shared/url/hooks/populate-url.server.js +0 -120
- package/dist/fields/relation/client.d.ts +0 -28
- package/dist/fields/relation/client.js +0 -37
- package/dist/fields/rich-text/component/styles/rich-text.css +0 -183
- package/dist/panel/components/sections/collection/header/Header.svelte +0 -17
- package/dist/panel/components/sections/collection/header/Header.svelte.d.ts +0 -3
- package/dist/panel/components/sections/collection/header/Separator.svelte +0 -8
- package/dist/panel/components/sections/collection/header/Separator.svelte.d.ts +0 -26
- package/dist/panel/components/sections/collection/tree/util.d.ts +0 -12
- package/dist/panel/components/sections/collection/tree/util.js +0 -22
- package/dist/panel/fonts/ChivoMono-Italic-VariableFont_wght.ttf +0 -0
- package/dist/panel/fonts/ChivoMono-VariableFont_wght.ttf +0 -0
- package/dist/panel/fonts/Inter-VariableFont_slnt,wght.ttf +0 -0
- package/dist/panel/fonts/Lora-Italic-VariableFont_wght.ttf +0 -0
- package/dist/panel/fonts/Lora-VariableFont_wght.ttf +0 -0
- package/dist/panel/style/shadow.css +0 -10
- package/dist/util/path.d.ts +0 -16
- package/dist/util/path.js +0 -19
- /package/dist/{panel/components/sections/live → live}/LiveEdit.svelte.d.ts +0 -0
- /package/dist/{panel/components/sections/live → live}/Provider.svelte.d.ts +0 -0
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { toSnakeCase } from '../../util/string.js';
|
|
2
|
-
import { baseTableName, declaredTableProperty, getSchemaColumnNames, joinName } from '../naming.server.js';
|
|
3
2
|
import dedent from 'dedent';
|
|
3
|
+
import { baseTableName, declaredTableProperty, getSchemaColumnNames, joinName, tableName } from '../naming.server.js';
|
|
4
4
|
const s = toSnakeCase;
|
|
5
5
|
/**
|
|
6
6
|
* Generates the standard imports needed for Drizzle ORM schema definitions
|
|
7
7
|
* Includes SQLite table definitions, relations, and a primary key helper function
|
|
8
8
|
*/
|
|
9
9
|
export const templateImports = `
|
|
10
|
-
import { text, integer, sqliteTable, real } from "drizzle-orm/sqlite-core";
|
|
11
|
-
import { defineRelations } from 'drizzle-orm';
|
|
10
|
+
import { text, integer, sqliteTable, real, index, unique, check, foreignKey } from "drizzle-orm/sqlite-core";
|
|
11
|
+
import { defineRelations, sql } from 'drizzle-orm';
|
|
12
12
|
|
|
13
13
|
const pk = () => text("id").primaryKey().$defaultFn(() => crypto.randomUUID());
|
|
14
14
|
`;
|
|
15
15
|
/**
|
|
16
16
|
* Generates a basic table definition with a primary key
|
|
17
|
-
* Takes a table name and
|
|
17
|
+
* Takes a table name, its columns, and the columns to index
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* ```typescript
|
|
@@ -22,18 +22,29 @@ const pk = () => text("id").primaryKey().$defaultFn(() => crypto.randomUUID());
|
|
|
22
22
|
* id: pk(),
|
|
23
23
|
* title: text('title'),
|
|
24
24
|
* content: text('content')
|
|
25
|
-
* })
|
|
25
|
+
* }, (t) => [index('pages_updated_at_idx').on(t.updatedAt)])
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
export const templateTable = (table, content) => {
|
|
28
|
+
export const templateTable = (table, content, indexed = []) => {
|
|
29
29
|
if (!content.includes('id:')) {
|
|
30
30
|
content = `id: pk(),\n${content}`;
|
|
31
31
|
}
|
|
32
32
|
return `export const ${table} = sqliteTable( '${table}', {
|
|
33
33
|
${content}
|
|
34
|
-
})
|
|
34
|
+
}${templateIndexes(table, indexed)})
|
|
35
35
|
`;
|
|
36
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* One index per column, named after the table and the column.
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* templateIndexes('pages__$rels', ['ownerId', 'mediasId'])
|
|
42
|
+
* // , (t) => [index('pages__$rels_owner_id_idx').on(t.ownerId), index('pages__$rels_medias_id_idx').on(t.mediasId)]
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export const templateIndexes = (table, columns) => columns.length
|
|
46
|
+
? `, (t) => [${columns.map((column) => `index('${table}_${s(column)}_idx').on(t.${column})`).join(', ')}]`
|
|
47
|
+
: '';
|
|
37
48
|
/**
|
|
38
49
|
* Generates a locale field for internationalized tables
|
|
39
50
|
*
|
|
@@ -160,12 +171,44 @@ export const templateUniqueRequired = (field, defaultValue) => {
|
|
|
160
171
|
* ```
|
|
161
172
|
*/
|
|
162
173
|
const templateDefault = (value) => value instanceof Date ? `new Date(${value.getTime()})` : JSON.stringify(value);
|
|
174
|
+
/**
|
|
175
|
+
* The addresses of a collection with `$url`: one row per page and per locale, off its base table.
|
|
176
|
+
*
|
|
177
|
+
* `path` is generated from the parent's path and the slug. Renaming or moving a row carries down
|
|
178
|
+
* its subtree, through the foreign key on `(locale, parent_path)`.
|
|
179
|
+
*
|
|
180
|
+
* ```ts
|
|
181
|
+
* export const pages__$paths = sqliteTable('pages__$paths', { …, path: text('path').generatedAlwaysAs(…) }, …)
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
export const templatePathsTable = (owner) => {
|
|
185
|
+
const table = tableName({ owner, child: { kind: 'paths' } });
|
|
186
|
+
return `
|
|
187
|
+
export const ${table} = sqliteTable('${table}', {
|
|
188
|
+
id: pk(),
|
|
189
|
+
ownerId: text('owner_id').notNull().references(() => ${owner}.id, { onDelete: 'cascade' }),
|
|
190
|
+
locale: text('locale').notNull(),
|
|
191
|
+
slug: text('slug').notNull(),
|
|
192
|
+
parentPath: text('parent_path'),
|
|
193
|
+
path: text('path').generatedAlwaysAs(sql\`coalesce(parent_path || '/', '') || slug\`, { mode: 'stored' }),
|
|
194
|
+
url: text('url')
|
|
195
|
+
}, (t) => [
|
|
196
|
+
unique('${table}_owner_locale').on(t.ownerId, t.locale),
|
|
197
|
+
unique('${table}_path').on(t.locale, t.path),
|
|
198
|
+
index('${table}_parent_idx').on(t.locale, t.parentPath),
|
|
199
|
+
index('${table}_url_idx').on(t.locale, t.url),
|
|
200
|
+
check('${table}_slug', sql\`slug <> ''\`),
|
|
201
|
+
foreignKey({ columns: [t.locale, t.parentPath], foreignColumns: [t.locale, t.path] }).onUpdate('cascade')
|
|
202
|
+
]);
|
|
203
|
+
`;
|
|
204
|
+
};
|
|
163
205
|
/** Template rows Relation */
|
|
164
206
|
/**
|
|
165
|
-
* The whole schema
|
|
207
|
+
* The drizzle relations of the whole schema. A read lists them in its `with` to load related rows
|
|
208
|
+
* in the same query, by the names given here.
|
|
166
209
|
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
210
|
+
* A child table (blocks, tree…) points at its owner through `ownerId`. It gets a relation each way,
|
|
211
|
+
* named after the table on the other end:
|
|
169
212
|
*
|
|
170
213
|
* ```ts
|
|
171
214
|
* export const relations = defineRelations(tables, (r) => ({
|
|
@@ -180,14 +223,13 @@ const templateDefault = (value) => value instanceof Date ? `new Date(${value.get
|
|
|
180
223
|
* }));
|
|
181
224
|
* ```
|
|
182
225
|
*
|
|
183
|
-
* A
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* A reference the read resolves is the other shape: the owner's row points at its target through
|
|
187
|
-
* the field's own column, one direction, keyed by `joinName(column)`:
|
|
226
|
+
* A reference field that stores another document's id in its own column: `updatedBy` holds a staff id.
|
|
227
|
+
* It gets one relation, from that column to the target, named after the column. Two columns can
|
|
228
|
+
* point at the same table:
|
|
188
229
|
*
|
|
189
230
|
* ```ts
|
|
190
231
|
* pages: {
|
|
232
|
+
* createdBy__$doc: r.one.staff({ from: r.pages.createdBy, to: r.staff.id }),
|
|
191
233
|
* updatedBy__$doc: r.one.staff({ from: r.pages.updatedBy, to: r.staff.id })
|
|
192
234
|
* }
|
|
193
235
|
* ```
|
|
@@ -234,7 +276,7 @@ export const templateFieldRelationColumn = (slug) => {
|
|
|
234
276
|
};
|
|
235
277
|
/**
|
|
236
278
|
* Generates a junction table for many-to-many relationships
|
|
237
|
-
* Creates a table with references to the owner table and related tables
|
|
279
|
+
* Creates a table with references to the owner table and related tables, each one indexed
|
|
238
280
|
* Includes path and position fields for ordering relationships
|
|
239
281
|
*
|
|
240
282
|
* @example
|
|
@@ -246,7 +288,7 @@ export const templateFieldRelationColumn = (slug) => {
|
|
|
246
288
|
* ownerId: text('owner_id').references(() => pages.id, { onDelete: 'cascade' }),
|
|
247
289
|
* mediasId: text('medias_id').references(() => medias.id, { onDelete: 'cascade' }),
|
|
248
290
|
* locale: text('locale'),
|
|
249
|
-
* })
|
|
291
|
+
* }, (t) => [index('pages_rels_owner_id_idx').on(t.ownerId), index('pages_rels_medias_id_idx').on(t.mediasId)])
|
|
250
292
|
* ```
|
|
251
293
|
*/
|
|
252
294
|
export const templateRelationFieldsTable = ({ table, junctionTable, relations, hasLocale }) => `
|
|
@@ -257,7 +299,7 @@ export const ${junctionTable} = sqliteTable('${junctionTable}', {
|
|
|
257
299
|
${templateParent(table)}
|
|
258
300
|
${relations.map((rel) => templateFieldRelationColumn(rel)).join(',\n')},
|
|
259
301
|
${hasLocale ? `locale: text('locale'),` : ''}
|
|
260
|
-
})
|
|
302
|
+
}${templateIndexes(junctionTable, ['ownerId', ...relations.map((rel) => `${rel}Id`)])})
|
|
261
303
|
`;
|
|
262
304
|
/**
|
|
263
305
|
* Generates an export of relation field mappings for runtime use
|
|
@@ -2,12 +2,21 @@ import type { Adapter } from '../core/adapter.js';
|
|
|
2
2
|
import type { Config } from '../core/config/types.js';
|
|
3
3
|
import type { ConfigContext } from '../core/rime.server.js';
|
|
4
4
|
import type { GetRegisterType } from '../index.js';
|
|
5
|
-
import {
|
|
5
|
+
import { type SqliteDriver } from './connect.server.js';
|
|
6
6
|
import generateSchema from './generate-schema/index.server.js';
|
|
7
7
|
import type { RelationFieldsMap } from './generate-schema/root.server.js';
|
|
8
|
-
import type { GenericTable } from './types.server.js';
|
|
8
|
+
import type { GenericTable, SqliteDatabase } from './types.server.js';
|
|
9
9
|
type Schema = GetRegisterType<'Schema'>;
|
|
10
|
-
export
|
|
10
|
+
export type { SqliteDriver };
|
|
11
|
+
export type AdapterSqliteOptions = {
|
|
12
|
+
/**
|
|
13
|
+
* `'bun'` opens the file with `bun:sqlite` — the app must then run on Bun
|
|
14
|
+
* (`bun --bun vite dev`, `bun index.js`). Migrations still go through drizzle-kit.
|
|
15
|
+
* @default 'libsql'
|
|
16
|
+
*/
|
|
17
|
+
driver?: SqliteDriver;
|
|
18
|
+
};
|
|
19
|
+
export declare function adapterSqlite(database: string, options?: AdapterSqliteOptions): {
|
|
11
20
|
createAdapter: <C extends Config>(configCtx: ConfigContext<C>) => Promise<SqliteAdapter>;
|
|
12
21
|
generateSchema: typeof generateSchema;
|
|
13
22
|
};
|
|
@@ -23,11 +32,10 @@ export declare function adapterSqlite(database: string): {
|
|
|
23
32
|
* that drifts from the contract is a build error rather than a runtime surprise.
|
|
24
33
|
*/
|
|
25
34
|
export type SqliteAdapter = Adapter & {
|
|
26
|
-
db:
|
|
35
|
+
db: SqliteDatabase;
|
|
27
36
|
tables: GetRegisterType<'Tables'>;
|
|
28
37
|
getTable<T>(key: string): T extends any ? GenericTable : T;
|
|
29
38
|
tableForSlug<T>(slug: string): T extends any ? GenericTable : T;
|
|
30
39
|
readonly schema: Schema;
|
|
31
40
|
readonly relationFieldsMap: RelationFieldsMap;
|
|
32
41
|
};
|
|
33
|
-
export {};
|
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import { drizzle, LibSQLDatabase } from 'drizzle-orm/libsql';
|
|
2
1
|
import path from 'path';
|
|
3
2
|
import createAuthHandle from './auth.server.js';
|
|
4
3
|
import createBlocksHandle from './blocks.server.js';
|
|
4
|
+
import { connect } from './connect.server.js';
|
|
5
5
|
import generateSchema from './generate-schema/index.server.js';
|
|
6
6
|
import { baseTableName } from './naming.server.js';
|
|
7
|
+
import createPathsHandle from './paths.server.js';
|
|
7
8
|
import { createPrototypeRegistry } from './registry.server.js';
|
|
8
9
|
import createRelationsHandle from './relations.server.js';
|
|
9
10
|
import { createTableHandles } from './table.server.js';
|
|
10
11
|
import { createTransformHandle } from './transform.server.js';
|
|
11
12
|
import createTreeHandle from './tree.server.js';
|
|
12
|
-
export function adapterSqlite(database) {
|
|
13
|
-
|
|
13
|
+
export function adapterSqlite(database, options = {}) {
|
|
14
|
+
const driver = options.driver ?? 'libsql';
|
|
14
15
|
return {
|
|
15
|
-
createAdapter: (configCtx) => createAdapter({ database, configCtx }),
|
|
16
|
+
createAdapter: (configCtx) => createAdapter({ database, driver, configCtx }),
|
|
16
17
|
generateSchema
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
const createAdapter = async (args) => {
|
|
20
|
-
const { database, configCtx } = args;
|
|
21
|
+
const { database, driver, configCtx } = args;
|
|
21
22
|
const schema = (await import('$rime/schema'));
|
|
22
23
|
const dbPath = path.join(process.cwd(), 'db', database);
|
|
23
24
|
// `relations`, not `schema`: a relational query resolves through the one `defineRelations`
|
|
24
25
|
// block the generator emits. `tables` is still read straight off the module everywhere else.
|
|
25
|
-
const db =
|
|
26
|
+
const db = await connect({ driver, dbPath, relations: schema.relations });
|
|
26
27
|
const tables = schema.tables;
|
|
27
28
|
// Two words, and each is the contract's own. `core/adapter.ts` declares `BlocksHandle`,
|
|
28
29
|
// `TreeHandle`, `RelationsHandle`, `TransformHandle` and `AuthHandle` — one object of verbs
|
|
@@ -32,6 +33,7 @@ const createAdapter = async (args) => {
|
|
|
32
33
|
const blocks = createBlocksHandle({ db, tables });
|
|
33
34
|
const tree = createTreeHandle({ db, tables });
|
|
34
35
|
const relations = createRelationsHandle({ db, tables });
|
|
36
|
+
const paths = createPathsHandle({ db, tables });
|
|
35
37
|
const auth = createAuthHandle({
|
|
36
38
|
db,
|
|
37
39
|
schema: schema.default
|
|
@@ -48,6 +50,7 @@ const createAdapter = async (args) => {
|
|
|
48
50
|
blocks,
|
|
49
51
|
tree,
|
|
50
52
|
relations,
|
|
53
|
+
paths,
|
|
51
54
|
transform,
|
|
52
55
|
auth,
|
|
53
56
|
db,
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* child pages__$relations hangs off an owner by `ownerId`
|
|
11
11
|
* pages__$blocks_hero one per block type
|
|
12
12
|
* pages__$tree_facts one per tree field
|
|
13
|
+
* pages__$paths a page's address per locale, off the base table
|
|
13
14
|
* branch pages__$blocks_hero__$$locales the localized half of whatever it hangs off
|
|
14
15
|
* ```
|
|
15
16
|
*
|
|
@@ -57,7 +58,7 @@ export declare const baseTableName: (slug: string) => TableName;
|
|
|
57
58
|
* the SQL name is derived.
|
|
58
59
|
*/
|
|
59
60
|
export declare const declaredTableProperty: (slug: string) => TableName;
|
|
60
|
-
export type ChildKind = 'blocks' | 'tree' | 'rels';
|
|
61
|
+
export type ChildKind = 'blocks' | 'tree' | 'rels' | 'paths';
|
|
61
62
|
export type TableParts = {
|
|
62
63
|
/**
|
|
63
64
|
* The base or versions table this hangs off, already resolved.
|
|
@@ -66,7 +67,7 @@ export type TableParts = {
|
|
|
66
67
|
* a whole subtree of children onto it.
|
|
67
68
|
*/
|
|
68
69
|
owner: TableName;
|
|
69
|
-
/** A child table. `name` is the block type or the tree field; `rels`
|
|
70
|
+
/** A child table. `name` is the block type or the tree field; `rels` and `paths` have none. */
|
|
70
71
|
child?: {
|
|
71
72
|
kind: ChildKind;
|
|
72
73
|
name?: string;
|
|
@@ -74,6 +75,8 @@ export type TableParts = {
|
|
|
74
75
|
/** The localized half of whatever the parts above resolve to. */
|
|
75
76
|
branch?: 'locales';
|
|
76
77
|
};
|
|
78
|
+
/** `pages__$paths` -> true: the addresses table a read joins off the base row. */
|
|
79
|
+
export declare const isPathsTable: (name: string) => boolean;
|
|
77
80
|
/**
|
|
78
81
|
* Assembles a Drizzle property name from its parts.
|
|
79
82
|
*
|
|
@@ -82,6 +85,7 @@ export type TableParts = {
|
|
|
82
85
|
* tableName({ owner: pagesShadow, branch: 'locales' }) // 'pages__shadow__$$locales'
|
|
83
86
|
* tableName({ owner: pages, child: { kind: 'blocks', name: 'hero' }}) // 'pages__$blocks_hero'
|
|
84
87
|
* tableName({ owner: pages, child: { kind: 'rels' } }) // 'pages__$relations'
|
|
88
|
+
* tableName({ owner: pages, child: { kind: 'paths' } }) // 'pages__$paths'
|
|
85
89
|
*/
|
|
86
90
|
export declare const tableName: (parts: TableParts) => TableName;
|
|
87
91
|
/**
|
|
@@ -93,12 +97,6 @@ export declare const tableName: (parts: TableParts) => TableName;
|
|
|
93
97
|
* underscore means what.
|
|
94
98
|
*/
|
|
95
99
|
export declare const toSqlTableName: (drizzleName: TableName) => TableName;
|
|
96
|
-
/**
|
|
97
|
-
* Every child table of `owner` of a given kind, read back off the schema.
|
|
98
|
-
*
|
|
99
|
-
* Excludes the `locales` branches, which are reached through their own owner rather than listed
|
|
100
|
-
* alongside it. Replaces the three hand-written filters, one of which was misnamed.
|
|
101
|
-
*/
|
|
102
100
|
export declare const childTableNames: (owner: TableName, kind: ChildKind, tables: Record<string, unknown>) => TableName[];
|
|
103
101
|
/**
|
|
104
102
|
* The relation key a resolved reference's target is joined under.
|
|
@@ -23,8 +23,11 @@ export const declaredTableProperty = (slug) => slug.replace(/^\$/, '');
|
|
|
23
23
|
const CHILD_MARKER = {
|
|
24
24
|
blocks: '__$blocks',
|
|
25
25
|
tree: '__$tree',
|
|
26
|
-
rels: '__$relations'
|
|
26
|
+
rels: '__$relations',
|
|
27
|
+
paths: '__$paths'
|
|
27
28
|
};
|
|
29
|
+
/** `pages__$paths` -> true: the addresses table a read joins off the base row. */
|
|
30
|
+
export const isPathsTable = (name) => name.endsWith(CHILD_MARKER.paths);
|
|
28
31
|
/** `__$$` marks a branch: the half of a table holding its localized columns. */
|
|
29
32
|
const BRANCH_MARKER = '__$$locales';
|
|
30
33
|
/**
|
|
@@ -35,6 +38,7 @@ const BRANCH_MARKER = '__$$locales';
|
|
|
35
38
|
* tableName({ owner: pagesShadow, branch: 'locales' }) // 'pages__shadow__$$locales'
|
|
36
39
|
* tableName({ owner: pages, child: { kind: 'blocks', name: 'hero' }}) // 'pages__$blocks_hero'
|
|
37
40
|
* tableName({ owner: pages, child: { kind: 'rels' } }) // 'pages__$relations'
|
|
41
|
+
* tableName({ owner: pages, child: { kind: 'paths' } }) // 'pages__$paths'
|
|
38
42
|
*/
|
|
39
43
|
export const tableName = (parts) => {
|
|
40
44
|
let name = parts.owner;
|
|
@@ -60,10 +64,24 @@ export const toSqlTableName = (drizzleName) => drizzleName;
|
|
|
60
64
|
* Excludes the `locales` branches, which are reached through their own owner rather than listed
|
|
61
65
|
* alongside it. Replaces the three hand-written filters, one of which was misnamed.
|
|
62
66
|
*/
|
|
67
|
+
const childTablesMemo = new WeakMap();
|
|
63
68
|
export const childTableNames = (owner, kind, tables) => {
|
|
64
|
-
|
|
65
|
-
//
|
|
66
|
-
|
|
69
|
+
// The schema does not change once loaded, and this is asked several times per query and twice
|
|
70
|
+
// per document read: answered once per schema, owner and kind.
|
|
71
|
+
let byOwner = childTablesMemo.get(tables);
|
|
72
|
+
if (!byOwner) {
|
|
73
|
+
byOwner = new Map();
|
|
74
|
+
childTablesMemo.set(tables, byOwner);
|
|
75
|
+
}
|
|
76
|
+
const key = `${owner}|${kind}`;
|
|
77
|
+
let names = byOwner.get(key);
|
|
78
|
+
if (!names) {
|
|
79
|
+
const prefix = tableName({ owner, child: { kind } });
|
|
80
|
+
// Keys of the generated schema: table names by construction.
|
|
81
|
+
names = Object.keys(tables).filter((key) => key.startsWith(prefix) && !key.endsWith(BRANCH_MARKER));
|
|
82
|
+
byOwner.set(key, names);
|
|
83
|
+
}
|
|
84
|
+
return names;
|
|
67
85
|
};
|
|
68
86
|
/**
|
|
69
87
|
* The relation key a resolved reference's target is joined under.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PathsHandle } from '../core/adapter.js';
|
|
2
|
+
import type { AdapterDeps } from './types.server.js';
|
|
3
|
+
/**
|
|
4
|
+
* The addresses of a collection's pages, in its `__$paths` table.
|
|
5
|
+
*
|
|
6
|
+
* Every statement names one page. The pages under it follow through the foreign key on
|
|
7
|
+
* `(locale, parent_path)`: SQLite rewrites their `parent_path`, which regenerates their `path`.
|
|
8
|
+
*/
|
|
9
|
+
declare const createPathsHandle: ({ db, tables }: AdapterDeps) => PathsHandle;
|
|
10
|
+
export default createPathsHandle;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { and, eq, gt, isNull, lt, notInArray, or, sql } from 'drizzle-orm';
|
|
2
|
+
import { alias } from 'drizzle-orm/sqlite-core';
|
|
3
|
+
import { baseTableName, tableName } from './naming.server.js';
|
|
4
|
+
/**
|
|
5
|
+
* The addresses of a collection's pages, in its `__$paths` table.
|
|
6
|
+
*
|
|
7
|
+
* Every statement names one page. The pages under it follow through the foreign key on
|
|
8
|
+
* `(locale, parent_path)`: SQLite rewrites their `parent_path`, which regenerates their `path`.
|
|
9
|
+
*/
|
|
10
|
+
const createPathsHandle = ({ db, tables }) => {
|
|
11
|
+
const tablesOf = (slug) => {
|
|
12
|
+
const base = baseTableName(slug);
|
|
13
|
+
return {
|
|
14
|
+
base: tables[base],
|
|
15
|
+
paths: tables[tableName({ owner: base, child: { kind: 'paths' } })]
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/** The parent's path in `locale`: a subquery, so the write stays one statement. */
|
|
19
|
+
const parentPathIn = (paths, parentId, locale) => {
|
|
20
|
+
const parent = alias(paths, 'parent');
|
|
21
|
+
return sql `(${db
|
|
22
|
+
.select({ path: parent.path })
|
|
23
|
+
.from(parent)
|
|
24
|
+
.where(and(eq(parent.ownerId, parentId), sql `${parent.locale} = ${locale}`))})`;
|
|
25
|
+
};
|
|
26
|
+
const rowsOf = (rows) => rows;
|
|
27
|
+
return {
|
|
28
|
+
insert: async ({ slug, ownerId, parentId, rows }) => {
|
|
29
|
+
if (!rows.length)
|
|
30
|
+
return [];
|
|
31
|
+
const { paths } = tablesOf(slug);
|
|
32
|
+
const inserted = await db
|
|
33
|
+
.insert(paths)
|
|
34
|
+
.values(rows.map((row) => ({
|
|
35
|
+
ownerId,
|
|
36
|
+
locale: row.locale,
|
|
37
|
+
slug: row.slug,
|
|
38
|
+
parentPath: parentId ? parentPathIn(paths, parentId, row.locale) : null
|
|
39
|
+
})))
|
|
40
|
+
.returning();
|
|
41
|
+
return rowsOf(inserted);
|
|
42
|
+
},
|
|
43
|
+
get: async ({ slug, ownerId, locale }) => {
|
|
44
|
+
const { paths } = tablesOf(slug);
|
|
45
|
+
const where = locale === undefined
|
|
46
|
+
? eq(paths.ownerId, ownerId)
|
|
47
|
+
: and(eq(paths.ownerId, ownerId), eq(paths.locale, locale));
|
|
48
|
+
return rowsOf(await db.select().from(paths).where(where));
|
|
49
|
+
},
|
|
50
|
+
setSlug: async ({ slug, ownerId, locale, value }) => {
|
|
51
|
+
const { paths } = tablesOf(slug);
|
|
52
|
+
const [row] = await db
|
|
53
|
+
.update(paths)
|
|
54
|
+
.set({ slug: value })
|
|
55
|
+
.where(and(eq(paths.ownerId, ownerId), eq(paths.locale, locale)))
|
|
56
|
+
.returning();
|
|
57
|
+
return row;
|
|
58
|
+
},
|
|
59
|
+
// One statement per locale, in one transaction: each row takes its new parent's path in its
|
|
60
|
+
// locale, and its slug there.
|
|
61
|
+
moveUnder: async ({ slug, ownerId, parentId, slugs }) => {
|
|
62
|
+
const { paths } = tablesOf(slug);
|
|
63
|
+
return db.transaction(async (tx) => {
|
|
64
|
+
const moved = [];
|
|
65
|
+
for (const [locale, value] of Object.entries(slugs)) {
|
|
66
|
+
const rows = await tx
|
|
67
|
+
.update(paths)
|
|
68
|
+
.set({
|
|
69
|
+
slug: value,
|
|
70
|
+
parentPath: parentId ? parentPathIn(paths, parentId, locale) : null
|
|
71
|
+
})
|
|
72
|
+
.where(and(eq(paths.ownerId, ownerId), eq(paths.locale, locale)))
|
|
73
|
+
.returning();
|
|
74
|
+
moved.push(...rows);
|
|
75
|
+
}
|
|
76
|
+
return rowsOf(moved);
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
children: async ({ slug, ownerId }) => {
|
|
80
|
+
const { paths } = tablesOf(slug);
|
|
81
|
+
const self = alias(paths, 'self');
|
|
82
|
+
const rows = await db
|
|
83
|
+
.selectDistinct({ ownerId: paths.ownerId })
|
|
84
|
+
.from(paths)
|
|
85
|
+
.where(sql `(${paths.locale}, ${paths.parentPath}) IN (${db
|
|
86
|
+
.select({ locale: self.locale, path: self.path })
|
|
87
|
+
.from(self)
|
|
88
|
+
.where(eq(self.ownerId, ownerId))})`);
|
|
89
|
+
return rows.map((row) => row.ownerId);
|
|
90
|
+
},
|
|
91
|
+
// `path/` <= p < `path0` is every path starting with `path/`, read off the unique index:
|
|
92
|
+
// '0' is the character after '/'.
|
|
93
|
+
under: async ({ slug, locale, path, withDescendants = true }) => {
|
|
94
|
+
const { paths } = tablesOf(slug);
|
|
95
|
+
const below = and(gt(paths.path, `${path}/`), lt(paths.path, `${path}0`));
|
|
96
|
+
const where = and(eq(paths.locale, locale), withDescendants ? or(eq(paths.path, path), below) : eq(paths.path, path));
|
|
97
|
+
return rowsOf(await db.select().from(paths).where(where));
|
|
98
|
+
},
|
|
99
|
+
siblingSlugs: async ({ slug, locale, parentId }) => {
|
|
100
|
+
const { paths } = tablesOf(slug);
|
|
101
|
+
const parent = parentId
|
|
102
|
+
? sql `${paths.parentPath} = ${parentPathIn(paths, parentId, locale)}`
|
|
103
|
+
: isNull(paths.parentPath);
|
|
104
|
+
const rows = await db
|
|
105
|
+
.select({ slug: paths.slug })
|
|
106
|
+
.from(paths)
|
|
107
|
+
.where(and(eq(paths.locale, locale), parent));
|
|
108
|
+
return rows.map((row) => row.slug);
|
|
109
|
+
},
|
|
110
|
+
missingOwners: async ({ slug, locale }) => {
|
|
111
|
+
const { base, paths } = tablesOf(slug);
|
|
112
|
+
const owned = db.select({ id: paths.ownerId }).from(paths).where(eq(paths.locale, locale));
|
|
113
|
+
const rows = await db.select({ id: base.id }).from(base).where(notInArray(base.id, owned));
|
|
114
|
+
return rows.map((row) => row.id);
|
|
115
|
+
},
|
|
116
|
+
setUrls: async ({ slug, rows }) => {
|
|
117
|
+
if (!rows.length)
|
|
118
|
+
return;
|
|
119
|
+
const { paths } = tablesOf(slug);
|
|
120
|
+
await db.transaction(async (tx) => {
|
|
121
|
+
for (const { ownerId, locale, url } of rows) {
|
|
122
|
+
await tx
|
|
123
|
+
.update(paths)
|
|
124
|
+
.set({ url })
|
|
125
|
+
.where(and(eq(paths.ownerId, ownerId), eq(paths.locale, locale)));
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
export default createPathsHandle;
|
|
@@ -28,6 +28,13 @@ type ReadArgs = {
|
|
|
28
28
|
locale?: string;
|
|
29
29
|
/** Whether an untranslated field reads from the other locales. `true` unless said otherwise. */
|
|
30
30
|
localeFallback?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The resolved references to join, by document path — a `$references(slug, { resolve: true })`
|
|
33
|
+
* field comes back as the document it points at only when its path is here. Every one when
|
|
34
|
+
* absent; `select` narrows further. The caller lists what its reader may see, so a row is never
|
|
35
|
+
* joined for a field the pipeline goes on to drop.
|
|
36
|
+
*/
|
|
37
|
+
resolve?: string[];
|
|
31
38
|
/** Which content row, when the caller means a particular one. The newest otherwise. */
|
|
32
39
|
content?: OperationQuery;
|
|
33
40
|
config: BuiltCollection | BuiltArea;
|
|
@@ -46,7 +53,7 @@ type ReadArgs = {
|
|
|
46
53
|
* The one structural difference between reading a singleton and reading one of many is the
|
|
47
54
|
* `where` on the root row — supply `id`, or don't.
|
|
48
55
|
*/
|
|
49
|
-
export declare const readPrototype: ({ db, tables, configCtx }: DepsWithConfig, { slug, id, select, locale, localeFallback, content, config, versions }: ReadArgs) => Promise<Dic | undefined>;
|
|
56
|
+
export declare const readPrototype: ({ db, tables, configCtx }: DepsWithConfig, { slug, id, select, resolve, locale, localeFallback, content, config, versions }: ReadArgs) => Promise<Dic | undefined>;
|
|
50
57
|
export declare const findManyPrototypes: ({ db, tables, configCtx }: DepsWithConfig, args: FindManyArgs) => Promise<RawDoc[]>;
|
|
51
58
|
/** Removes a document. Its content rows and children follow by cascade. */
|
|
52
59
|
type FindManyArgs = {
|
|
@@ -60,6 +67,8 @@ type FindManyArgs = {
|
|
|
60
67
|
locale?: string;
|
|
61
68
|
/** See `readPrototype`. */
|
|
62
69
|
localeFallback?: boolean;
|
|
70
|
+
/** See `readPrototype`. */
|
|
71
|
+
resolve?: string[];
|
|
63
72
|
/** Per document, which content row — see `readPrototype`. */
|
|
64
73
|
content?: OperationQuery;
|
|
65
74
|
config: BuiltCollection | BuiltArea;
|
|
@@ -6,7 +6,7 @@ import { buildOrderByParam } from './order-by.server.js';
|
|
|
6
6
|
import * as adapterUtil from './columns.server.js';
|
|
7
7
|
import { buildWhereParam } from './where.server.js';
|
|
8
8
|
import { localeOrder } from './locales.server.js';
|
|
9
|
-
import { buildWithParam, resolvedReferenceJoins } from './select.server.js';
|
|
9
|
+
import { buildWithParam, pathsJoin, resolvedReferenceJoins } from './select.server.js';
|
|
10
10
|
/**
|
|
11
11
|
* Reads one prototype document, merged with the content row it should show.
|
|
12
12
|
*
|
|
@@ -21,7 +21,7 @@ import { buildWithParam, resolvedReferenceJoins } from './select.server.js';
|
|
|
21
21
|
* The one structural difference between reading a singleton and reading one of many is the
|
|
22
22
|
* `where` on the root row — supply `id`, or don't.
|
|
23
23
|
*/
|
|
24
|
-
export const readPrototype = async ({ db, tables, configCtx }, { slug, id, select, locale, localeFallback, content, config, versions }) => {
|
|
24
|
+
export const readPrototype = async ({ db, tables, configCtx }, { slug, id, select, resolve, locale, localeFallback, content, config, versions }) => {
|
|
25
25
|
const table = baseTableName(slug);
|
|
26
26
|
const rootTable = tables[table];
|
|
27
27
|
const fallback = localeOrder(configCtx, locale, localeFallback);
|
|
@@ -34,7 +34,7 @@ export const readPrototype = async ({ db, tables, configCtx }, { slug, id, selec
|
|
|
34
34
|
return queryTable.findFirst({
|
|
35
35
|
columns: adapterUtil.columnsParams({ table: rootTable, select }),
|
|
36
36
|
...byId,
|
|
37
|
-
with: buildWithParam({ table, select, locale, fallback, tables, config }) || undefined
|
|
37
|
+
with: buildWithParam({ table, select, resolve, locale, fallback, tables, config }) || undefined
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
// See findManyPrototypes for why the versions table's slug is castable.
|
|
@@ -44,11 +44,21 @@ export const readPrototype = async ({ db, tables, configCtx }, { slug, id, selec
|
|
|
44
44
|
columns: adapterUtil.columnsParams({ table: rootTable, select }),
|
|
45
45
|
...byId,
|
|
46
46
|
with: {
|
|
47
|
-
// The base row's own resolved references; the content row's come with
|
|
48
|
-
|
|
47
|
+
// The base row's own resolved references and address; the content row's come with
|
|
48
|
+
// `buildWithParam`.
|
|
49
|
+
...resolvedReferenceJoins({ table, tables, config, select, resolve }),
|
|
50
|
+
...pathsJoin({ base: table, tables, locale, select }),
|
|
49
51
|
[contentTable]: {
|
|
50
52
|
columns: adapterUtil.columnsParams({ table: tables[contentTable], select }),
|
|
51
|
-
with: buildWithParam({
|
|
53
|
+
with: buildWithParam({
|
|
54
|
+
table: contentTable,
|
|
55
|
+
select,
|
|
56
|
+
resolve,
|
|
57
|
+
locale,
|
|
58
|
+
fallback,
|
|
59
|
+
tables,
|
|
60
|
+
config
|
|
61
|
+
}),
|
|
52
62
|
// The row the caller's filter names, else the newest — one query either way, and the
|
|
53
63
|
// adapter chooses nothing. Which content row a request means is decided above this module
|
|
54
64
|
// and arrives as an ordinary filter (`FeatureDefinition.readQuery`).
|
|
@@ -83,7 +93,7 @@ export const readPrototype = async ({ db, tables, configCtx }, { slug, id, selec
|
|
|
83
93
|
return adapterUtil.mergeContentRow(doc, contentTable, config, select);
|
|
84
94
|
};
|
|
85
95
|
export const findManyPrototypes = async ({ db, tables, configCtx }, args) => {
|
|
86
|
-
const { select, query: incomingQuery, sort, limit, offset, locale, localeFallback, content, config, versions } = args;
|
|
96
|
+
const { select, resolve, query: incomingQuery, sort, limit, offset, locale, localeFallback, content, config, versions } = args;
|
|
87
97
|
// buildOrderByParam and buildWhereParam resolve fields against the config, so they take a
|
|
88
98
|
// prototype slug. Registration guarantees this one is registered, hence is one.
|
|
89
99
|
const slug = args.slug;
|
|
@@ -93,7 +103,7 @@ export const findManyPrototypes = async ({ db, tables, configCtx }, args) => {
|
|
|
93
103
|
// No versions: everything is on the base table, so this is one plain query.
|
|
94
104
|
if (!versions) {
|
|
95
105
|
const params = {
|
|
96
|
-
with: buildWithParam({ table, select, tables, config, locale, fallback }) || undefined,
|
|
106
|
+
with: buildWithParam({ table, select, resolve, tables, config, locale, fallback }) || undefined,
|
|
97
107
|
orderBy: (t) => buildOrderByParam({ slug, locale, tables, configCtx, by: sort, rootTable: t }),
|
|
98
108
|
// sqlite requires a limit when an offset is present.
|
|
99
109
|
limit: limit || (typeof offset === 'number' ? 1000000 : undefined),
|
|
@@ -119,7 +129,8 @@ export const findManyPrototypes = async ({ db, tables, configCtx }, args) => {
|
|
|
119
129
|
// declares one also derives its config), so `buildWhereParam` can resolve fields against it.
|
|
120
130
|
const versionsSlug = versions.slug;
|
|
121
131
|
const contentTable = baseTableName(versionsSlug);
|
|
122
|
-
const withParam = buildWithParam({ table: contentTable, select, tables, config, locale, fallback }) ||
|
|
132
|
+
const withParam = buildWithParam({ table: contentTable, select, resolve, tables, config, locale, fallback }) ||
|
|
133
|
+
undefined;
|
|
123
134
|
// The caller's own filter, and the one saying which content row each document shows. Both
|
|
124
135
|
// resolve against the versions table, so they are two wheres to `and` rather than two query objects to
|
|
125
136
|
// splice — which is what this was, a condition spliced into somebody else's `where` by hand
|
|
@@ -161,7 +172,8 @@ export const findManyPrototypes = async ({ db, tables, configCtx }, args) => {
|
|
|
161
172
|
...params,
|
|
162
173
|
columns: adapterUtil.columnsParams({ table: tables[table], select }),
|
|
163
174
|
with: {
|
|
164
|
-
...resolvedReferenceJoins({ table, tables, config, select }),
|
|
175
|
+
...resolvedReferenceJoins({ table, tables, config, select, resolve }),
|
|
176
|
+
...pathsJoin({ base: table, tables, locale, select }),
|
|
165
177
|
[contentTable]: {
|
|
166
178
|
with: withParam,
|
|
167
179
|
where: { RAW: contentWhere },
|
|
@@ -13,10 +13,29 @@ export declare const resolvedReferenceJoins: (args: {
|
|
|
13
13
|
tables: Dic;
|
|
14
14
|
config: BuiltCollection | BuiltArea;
|
|
15
15
|
select?: string[];
|
|
16
|
+
/** The references to join at all, by path; every one when absent. */
|
|
17
|
+
resolve?: string[];
|
|
18
|
+
}) => Dic;
|
|
19
|
+
/**
|
|
20
|
+
* The page's row in its paths table, in the locale read, when its collection has `$url`. A page
|
|
21
|
+
* has a row in every locale, so there is no fallback to resolve.
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* pathsJoin({ base: 'pages', tables, locale: 'en' })
|
|
25
|
+
* // { 'pages__$paths': { where: { locale: 'en' }, columns: { slug: true, path: true, url: true } } }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const pathsJoin: (args: {
|
|
29
|
+
base: TableName;
|
|
30
|
+
tables: Dic;
|
|
31
|
+
locale?: string;
|
|
32
|
+
select?: string[];
|
|
16
33
|
}) => Dic;
|
|
17
34
|
export declare const buildWithParam: (args: {
|
|
18
35
|
table: TableName;
|
|
19
36
|
select?: string[];
|
|
37
|
+
/** See `resolvedReferenceJoins`. */
|
|
38
|
+
resolve?: string[];
|
|
20
39
|
locale?: string;
|
|
21
40
|
/** The locales a read draws on, first to last — `localeOrder`. The requested one alone if absent. */
|
|
22
41
|
fallback?: string[];
|