rimecms 0.33.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +27 -6
- package/dist/adapter-sqlite/generate-schema/templates.server.js +52 -10
- 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 +122 -0
- package/dist/adapter-sqlite/read.server.d.ts +10 -1
- package/dist/adapter-sqlite/read.server.js +22 -10
- 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 +94 -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 +6 -6
- 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/types/contributions.server.d.ts +3 -2
- package/dist/core/dev/codegen/types/contributions.server.js +10 -3
- 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/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/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/url/addresses.server.d.ts +26 -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 +5 -0
- package/dist/core/prototype/shared/url/hooks/detach-paths.server.js +18 -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 +7 -0
- package/dist/core/prototype/shared/url/hooks/sync-paths.server.js +37 -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 +1 -0
- 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/module.server.js +7 -1
- package/dist/fields/relation/value.d.ts +25 -0
- package/dist/fields/relation/value.js +27 -0
- 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.svelte +20 -6
- package/dist/fields/rich-text/core/features/upload/upload.svelte +20 -8
- 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/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 +4 -3
- package/dist/index.js +3 -2
- 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/document/upload-header/drop-zone/DropZone.svelte.d.ts +1 -1
- package/dist/panel/components/sections/live/LiveEdit.svelte +2 -2
- 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/calendar/calendar.svelte.d.ts +1 -1
- 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/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-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/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/documentForm.svelte.d.ts +34 -2
- package/dist/panel/context/documentForm.svelte.js +105 -102
- package/dist/panel/context/live.svelte.js +2 -73
- 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 -1
- package/dist/panel/index.js +10 -1
- 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/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/populate.d.ts +8 -0
- package/dist/panel/util/populate.js +49 -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/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 +1 -3
- 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/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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GetRegisterType } from '../index.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SqliteDatabase } from './types.server.js';
|
|
3
3
|
/**
|
|
4
4
|
* All that is left of the auth facade: Better-auth's own database adapter.
|
|
5
5
|
*
|
|
@@ -11,7 +11,7 @@ import type { LibSQLDatabase } from 'drizzle-orm/libsql';
|
|
|
11
11
|
* because those are declared tables rather than a hand-written template.
|
|
12
12
|
*/
|
|
13
13
|
declare const createAuthHandle: (args: {
|
|
14
|
-
db:
|
|
14
|
+
db: SqliteDatabase;
|
|
15
15
|
schema: GetRegisterType<"Schema">;
|
|
16
16
|
}) => {
|
|
17
17
|
betterAuthAdapter: (options: import("better-auth").BetterAuthOptions) => import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>;
|
|
@@ -3,7 +3,7 @@ import { omit, pick } from '../util/object.js';
|
|
|
3
3
|
import { randomId } from '../util/random.js';
|
|
4
4
|
import { baseFieldNames } from '../core/fields/util.js';
|
|
5
5
|
import { and, eq, getTableColumns } from 'drizzle-orm';
|
|
6
|
-
import { JOIN_SUFFIX } from './naming.server.js';
|
|
6
|
+
import { isPathsTable, JOIN_SUFFIX } from './naming.server.js';
|
|
7
7
|
/**
|
|
8
8
|
* Main function to generated primaryKeys
|
|
9
9
|
*/
|
|
@@ -121,7 +121,7 @@ export function mergeContentRow(doc, contentTable, config, select) {
|
|
|
121
121
|
const rootProps = ['createdAt', 'id', ...baseFieldNames(config)];
|
|
122
122
|
const hasRootSelectColumn = rootProps.some((column) => select.includes(column));
|
|
123
123
|
// A resolved reference's target, joined only when its column was selected.
|
|
124
|
-
const joined = Object.keys(doc).filter((key) => key.endsWith(JOIN_SUFFIX));
|
|
124
|
+
const joined = Object.keys(doc).filter((key) => key.endsWith(JOIN_SUFFIX) || isPathsTable(key));
|
|
125
125
|
// Pick the selected base columns on doc, or only the "id"
|
|
126
126
|
const docFields = hasRootSelectColumn
|
|
127
127
|
? pick([...select.filter((field) => rootProps.includes(field)), 'id', ...joined], doc)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SqliteDatabase } from './types.server.js';
|
|
2
|
+
export type SqliteDriver = 'libsql' | 'bun';
|
|
3
|
+
/**
|
|
4
|
+
* Opens the database with the configured driver.
|
|
5
|
+
*
|
|
6
|
+
* Each driver is imported only when chosen, so a Node process never loads `bun:sqlite`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function connect(args: {
|
|
9
|
+
driver: SqliteDriver;
|
|
10
|
+
dbPath: string;
|
|
11
|
+
relations: any;
|
|
12
|
+
}): Promise<SqliteDatabase>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { building } from '$app/environment';
|
|
2
|
+
import { logger } from '../core/logger.server.js';
|
|
3
|
+
/**
|
|
4
|
+
* Opens the database with the configured driver.
|
|
5
|
+
*
|
|
6
|
+
* Each driver is imported only when chosen, so a Node process never loads `bun:sqlite`.
|
|
7
|
+
*/
|
|
8
|
+
export async function connect(args) {
|
|
9
|
+
const { dbPath, relations } = args;
|
|
10
|
+
let driver = args.driver;
|
|
11
|
+
if (driver === 'bun' && !process.versions.bun) {
|
|
12
|
+
// `rime generate`/`init` (bin runs on Node) and `vite build` only need a connection to
|
|
13
|
+
// boot, not a fast one — libsql opens the same file.
|
|
14
|
+
if (!building && !process.env.RIME_CLI) {
|
|
15
|
+
throw new Error("adapterSqlite driver 'bun' needs the Bun runtime — run with `bun --bun vite dev` / `bun index.js`");
|
|
16
|
+
}
|
|
17
|
+
logger.debug("driver 'bun' outside Bun, falling back to libsql");
|
|
18
|
+
driver = 'libsql';
|
|
19
|
+
}
|
|
20
|
+
// `relations` comes untyped from the generated schema module; the casts restore `Relations`.
|
|
21
|
+
if (driver === 'bun') {
|
|
22
|
+
const { drizzle } = await import('drizzle-orm/bun-sqlite');
|
|
23
|
+
const db = drizzle(dbPath, { relations });
|
|
24
|
+
// bun:sqlite opens a database with foreign keys off, libsql with them on. Every cascade and
|
|
25
|
+
// set-null of the schema depends on them.
|
|
26
|
+
db.$client.run('PRAGMA foreign_keys = ON');
|
|
27
|
+
return db;
|
|
28
|
+
}
|
|
29
|
+
const { drizzle } = await import('drizzle-orm/libsql');
|
|
30
|
+
return drizzle('file:' + dbPath, { relations });
|
|
31
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { authColumns } from '../../core/auth/tables.js';
|
|
2
|
-
import { baseTableName, declaredTableProperty } from '../naming.server.js';
|
|
2
|
+
import { baseTableName, declaredTableProperty, tableName } from '../naming.server.js';
|
|
3
3
|
import { date } from '../../fields/date/index.js';
|
|
4
4
|
import { generateJunctionTableDefinition } from './relations/junction.server.js';
|
|
5
5
|
import buildRootTable, {} from './root.server.js';
|
|
6
|
-
import { templateDeclaredTable, templateExportRelationsFieldsToTable, templateExportSchema, templateExportTables, templateHead, templateImports, templateRelations } from './templates.server.js';
|
|
6
|
+
import { templateDeclaredTable, templateExportRelationsFieldsToTable, templateExportSchema, templateExportTables, templateHead, templateImports, templatePathsTable, templateRelations } from './templates.server.js';
|
|
7
7
|
import write from './write.server.js';
|
|
8
8
|
export async function generateSchemaString(config) {
|
|
9
9
|
// Every prototype config in the build, each paired with the features that extend its kind —
|
|
@@ -43,7 +43,7 @@ export async function generateSchemaString(config) {
|
|
|
43
43
|
fields: [
|
|
44
44
|
...prototype.fields.filter((field) => field.get.root),
|
|
45
45
|
date('createdAt').hidden(),
|
|
46
|
-
date('updatedAt').hidden()
|
|
46
|
+
date('updatedAt').hidden().$index()
|
|
47
47
|
],
|
|
48
48
|
rootName: baseName,
|
|
49
49
|
locales: [],
|
|
@@ -87,6 +87,14 @@ export async function generateSchemaString(config) {
|
|
|
87
87
|
[rootTableName]: relationFieldsMap
|
|
88
88
|
};
|
|
89
89
|
schema.push(prototypeSchema, junctionTable);
|
|
90
|
+
// A collection with `$url` keeps its pages' addresses in a table of their own, off the base
|
|
91
|
+
// table: an address belongs to the page, not to one of its versions.
|
|
92
|
+
if (prototype.type === 'collection' && prototype.$url) {
|
|
93
|
+
const pathsTable = tableName({ owner: baseName, child: { kind: 'paths' } });
|
|
94
|
+
schema.push(templatePathsTable(baseName));
|
|
95
|
+
enumTables = [...enumTables, pathsTable];
|
|
96
|
+
(relationTree[baseName] ??= []).push(pathsTable);
|
|
97
|
+
}
|
|
90
98
|
}
|
|
91
99
|
// Tables no prototype declares — better-auth's own, plus whatever a plugin added during the
|
|
92
100
|
// configure phase. Nothing here knows who asked for one.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LocaleConfig } from '../../core/locale/types.js';
|
|
2
|
-
import {
|
|
2
|
+
import type { FieldBuilder } from '../../core/fields/builders/field-builder.js';
|
|
3
3
|
import type { Field } from '../../fields/types.js';
|
|
4
4
|
import type { TableName } from '../naming.server.js';
|
|
5
5
|
import type { ColumnDeclaration } from '../../core/adapter.js';
|
|
@@ -45,9 +45,18 @@ type Return = {
|
|
|
45
45
|
referenceJoins: ReferenceJoin[];
|
|
46
46
|
};
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
49
|
-
* and
|
|
50
|
-
*
|
|
48
|
+
* The table of a collection or area, its locales branch when a field is localized, and one child
|
|
49
|
+
* table per block type and per tree field. Relation fields become no column; they are collected in
|
|
50
|
+
* `relationFieldsMap` for the junction table built later.
|
|
51
|
+
*
|
|
52
|
+
* The branches below decide where a field's rows are stored, not what is below it:
|
|
53
|
+
*
|
|
54
|
+
* ```
|
|
55
|
+
* relation junction rows no column, an entry in relationFieldsMap
|
|
56
|
+
* a node with storage a child table blocks and tree, built by this function recursing
|
|
57
|
+
* a node without the owner's row group, tabs, and a container from a package
|
|
58
|
+
* leaf one column
|
|
59
|
+
* ```
|
|
51
60
|
*/
|
|
52
61
|
declare const buildRootTable: ({ fields: incomingFields, tableName, rootName, hasParent, locales, relationFieldsMap, relationsDic, featureColumns, versionsOf, blocksRegister }: Args) => Promise<Return>;
|
|
53
62
|
export default buildRootTable;
|
|
@@ -1,23 +1,60 @@
|
|
|
1
|
-
import {} from '../../core/fields/builders/field-builder.js';
|
|
2
1
|
import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
|
|
3
|
-
import {
|
|
4
|
-
import { GroupFieldBuilder } from '../../fields/group/index.js';
|
|
2
|
+
import { walkFields } from '../../core/fields/walk.js';
|
|
5
3
|
import { RelationFieldBuilder } from '../../fields/relation/index.js';
|
|
6
|
-
import { TabsBuilder } from '../../fields/tabs/index.js';
|
|
7
|
-
import { TreeBuilder } from '../../fields/tree/index.js';
|
|
8
4
|
import { tableName as buildTableName, getSchemaColumnNames } from '../naming.server.js';
|
|
9
5
|
import { toSchemaColumn } from './column.server.js';
|
|
10
6
|
import { templateDeclaredColumn, templateLocale, templateParent, templateTable } from './templates.server.js';
|
|
7
|
+
/** A container flattened into the owner's row: its name and the column's, joined. */
|
|
8
|
+
const joinColumn = (parent, part) => (parent ? `${parent}__${part}` : part);
|
|
11
9
|
/**
|
|
12
|
-
*
|
|
13
|
-
* and
|
|
14
|
-
*
|
|
10
|
+
* The table of a collection or area, its locales branch when a field is localized, and one child
|
|
11
|
+
* table per block type and per tree field. Relation fields become no column; they are collected in
|
|
12
|
+
* `relationFieldsMap` for the junction table built later.
|
|
13
|
+
*
|
|
14
|
+
* The branches below decide where a field's rows are stored, not what is below it:
|
|
15
|
+
*
|
|
16
|
+
* ```
|
|
17
|
+
* relation junction rows no column, an entry in relationFieldsMap
|
|
18
|
+
* a node with storage a child table blocks and tree, built by this function recursing
|
|
19
|
+
* a node without the owner's row group, tabs, and a container from a package
|
|
20
|
+
* leaf one column
|
|
21
|
+
* ```
|
|
15
22
|
*/
|
|
16
23
|
const buildRootTable = async ({ fields: incomingFields, tableName, rootName, hasParent, locales, relationFieldsMap = {}, relationsDic = {}, featureColumns = [], versionsOf, blocksRegister }) => {
|
|
17
24
|
const blocksTables = [];
|
|
18
25
|
const referenceJoins = [];
|
|
19
26
|
let relationFieldsHasLocale = false;
|
|
20
|
-
|
|
27
|
+
/**
|
|
28
|
+
* One child table under the root for a branch stored as rows of its own, built by recursing.
|
|
29
|
+
* Registered once: two blocks fields declaring the same type share the type's table.
|
|
30
|
+
*/
|
|
31
|
+
const childTable = async (storage, fields) => {
|
|
32
|
+
const name = buildTableName({ owner: rootName, child: storage });
|
|
33
|
+
if (blocksRegister.includes(name))
|
|
34
|
+
return;
|
|
35
|
+
relationsDic = { ...relationsDic, [rootName]: [...(relationsDic[rootName] || []), name] };
|
|
36
|
+
const nested = await buildRootTable({
|
|
37
|
+
blocksRegister,
|
|
38
|
+
fields,
|
|
39
|
+
tableName: name,
|
|
40
|
+
hasParent: true,
|
|
41
|
+
relationsDic,
|
|
42
|
+
relationFieldsMap,
|
|
43
|
+
locales,
|
|
44
|
+
rootName
|
|
45
|
+
});
|
|
46
|
+
relationsDic = nested.relationsDic;
|
|
47
|
+
relationFieldsMap = nested.relationFieldsMap;
|
|
48
|
+
if (nested.relationFieldsHasLocale)
|
|
49
|
+
relationFieldsHasLocale = true;
|
|
50
|
+
referenceJoins.push(...nested.referenceJoins);
|
|
51
|
+
blocksRegister.push(name);
|
|
52
|
+
blocksTables.push(nested.schema);
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* The columns of one table, and in `indexed` the ones a field asked `$index()` for.
|
|
56
|
+
*/
|
|
57
|
+
const generateFieldsTemplates = async (fields, withLocalized, parentPath = '', indexed = []) => {
|
|
21
58
|
let templates = [];
|
|
22
59
|
const checkLocalized = (field) => {
|
|
23
60
|
return ((withLocalized && field.get.localized) ||
|
|
@@ -25,19 +62,8 @@ const buildRootTable = async ({ fields: incomingFields, tableName, rootName, has
|
|
|
25
62
|
withLocalized === undefined);
|
|
26
63
|
};
|
|
27
64
|
for (const field of fields) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const groupFields = await generateFieldsTemplates(field.get.fields, withLocalized, groupPath);
|
|
31
|
-
templates = [...templates, ...groupFields];
|
|
32
|
-
}
|
|
33
|
-
else if (field instanceof TabsBuilder) {
|
|
34
|
-
for (const tab of field.get.tabs) {
|
|
35
|
-
const tabPath = parentPath ? `${parentPath}__${tab.name}` : tab.name;
|
|
36
|
-
const tabFields = await generateFieldsTemplates(tab.get.fields, withLocalized, tabPath);
|
|
37
|
-
templates = [...templates, ...tabFields];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else if (field instanceof RelationFieldBuilder) {
|
|
65
|
+
// Junction rows: no column here, and the relations table wants to know it exists.
|
|
66
|
+
if (field instanceof RelationFieldBuilder) {
|
|
41
67
|
if (field.get.localized) {
|
|
42
68
|
relationFieldsHasLocale = true;
|
|
43
69
|
}
|
|
@@ -49,72 +75,28 @@ const buildRootTable = async ({ fields: incomingFields, tableName, rootName, has
|
|
|
49
75
|
}
|
|
50
76
|
};
|
|
51
77
|
}
|
|
52
|
-
else if (field
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// Add the blocks as a relation of the root collection
|
|
60
|
-
relationsDic = {
|
|
61
|
-
...relationsDic,
|
|
62
|
-
[rootName]: [...(relationsDic[rootName] || []), blockTableName]
|
|
63
|
-
};
|
|
64
|
-
// Build the child blocks table
|
|
65
|
-
const { schema: blockTable, relationsDic: nestedRelationsDic, relationFieldsMap: nestedRelationFieldsDic, relationFieldsHasLocale: nestedRelationFieldsHasLocale, referenceJoins: nestedReferenceJoins } = await buildRootTable({
|
|
66
|
-
blocksRegister,
|
|
67
|
-
fields: block.get.fields,
|
|
68
|
-
tableName: blockTableName,
|
|
69
|
-
hasParent: true,
|
|
70
|
-
relationsDic,
|
|
71
|
-
relationFieldsMap,
|
|
72
|
-
locales,
|
|
73
|
-
rootName
|
|
74
|
-
});
|
|
75
|
-
relationsDic = nestedRelationsDic;
|
|
76
|
-
relationFieldsMap = nestedRelationFieldsDic;
|
|
77
|
-
if (nestedRelationFieldsHasLocale)
|
|
78
|
-
relationFieldsHasLocale = true;
|
|
79
|
-
referenceJoins.push(...nestedReferenceJoins);
|
|
80
|
-
blocksRegister.push(blockTableName);
|
|
81
|
-
blocksTables.push(blockTable);
|
|
78
|
+
else if (field.use.nodes().length) {
|
|
79
|
+
// A branch stored as rows of its own gets a child table; any other flattens into the
|
|
80
|
+
// owner's row, `attributes__seo__title`.
|
|
81
|
+
for (const node of field.use.nodes()) {
|
|
82
|
+
if (node.storage) {
|
|
83
|
+
await childTable(node.storage, node.fields);
|
|
84
|
+
continue;
|
|
82
85
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
});
|
|
90
|
-
if (!blocksRegister.includes(treeTableName)) {
|
|
91
|
-
// Add the tree table as relation of the root collection
|
|
92
|
-
relationsDic = {
|
|
93
|
-
...relationsDic,
|
|
94
|
-
[rootName]: [...(relationsDic[rootName] || []), treeTableName]
|
|
95
|
-
};
|
|
96
|
-
const { schema: treeTable, relationsDic: nestedRelationsDic, relationFieldsMap: nestedRelationFieldsDic, relationFieldsHasLocale: nestedRelationFieldsHasLocale, referenceJoins: nestedReferenceJoins } = await buildRootTable({
|
|
97
|
-
blocksRegister,
|
|
98
|
-
fields: field.get.fields,
|
|
99
|
-
tableName: treeTableName,
|
|
100
|
-
hasParent: true,
|
|
101
|
-
relationsDic,
|
|
102
|
-
relationFieldsMap,
|
|
103
|
-
locales,
|
|
104
|
-
rootName
|
|
105
|
-
});
|
|
106
|
-
relationsDic = nestedRelationsDic;
|
|
107
|
-
relationFieldsMap = nestedRelationFieldsDic;
|
|
108
|
-
if (nestedRelationFieldsHasLocale)
|
|
109
|
-
relationFieldsHasLocale = true;
|
|
110
|
-
referenceJoins.push(...nestedReferenceJoins);
|
|
111
|
-
blocksRegister.push(treeTableName);
|
|
112
|
-
blocksTables.push(treeTable);
|
|
86
|
+
const own = field.name ? joinColumn(parentPath, field.name) : parentPath;
|
|
87
|
+
const prefix = node.segment ? joinColumn(own, node.segment) : own;
|
|
88
|
+
templates = [
|
|
89
|
+
...templates,
|
|
90
|
+
...(await generateFieldsTemplates(node.fields, withLocalized, prefix, indexed))
|
|
91
|
+
];
|
|
113
92
|
}
|
|
114
93
|
}
|
|
115
94
|
else if (field instanceof FormFieldBuilder) {
|
|
116
95
|
if (checkLocalized(field)) {
|
|
117
96
|
templates.push(toSchemaColumn(field, parentPath) + ',');
|
|
97
|
+
if (field.get.index) {
|
|
98
|
+
indexed.push(getSchemaColumnNames({ name: field.name, parentPath }).camel);
|
|
99
|
+
}
|
|
118
100
|
// A reference the read resolves gets a relation to its target beside the column.
|
|
119
101
|
if (field._references?.resolve) {
|
|
120
102
|
referenceJoins.push({
|
|
@@ -128,12 +110,15 @@ const buildRootTable = async ({ fields: incomingFields, tableName, rootName, has
|
|
|
128
110
|
}
|
|
129
111
|
return templates;
|
|
130
112
|
};
|
|
113
|
+
// A child row is read by its owner. A field's `$index()` adds its own column below.
|
|
114
|
+
const indexed = hasParent || versionsOf ? ['ownerId'] : [];
|
|
131
115
|
let table;
|
|
132
116
|
if (locales && locales.length && hasLocalizedField(incomingFields)) {
|
|
133
117
|
const tableNameLocales = buildTableName({ owner: tableName, branch: 'locales' });
|
|
134
|
-
const
|
|
118
|
+
const localizedIndexed = [];
|
|
119
|
+
const strLocalizedFields = await generateFieldsTemplates(incomingFields, true, '', localizedIndexed);
|
|
135
120
|
relationsDic[tableName] = [...(relationsDic[tableName] || []), tableNameLocales];
|
|
136
|
-
const strUnlocalizedFields = await generateFieldsTemplates(incomingFields, false);
|
|
121
|
+
const strUnlocalizedFields = await generateFieldsTemplates(incomingFields, false, '', indexed);
|
|
137
122
|
if (hasParent) {
|
|
138
123
|
strUnlocalizedFields.push(templateParent(rootName));
|
|
139
124
|
}
|
|
@@ -143,11 +128,11 @@ const buildRootTable = async ({ fields: incomingFields, tableName, rootName, has
|
|
|
143
128
|
for (const column of featureColumns) {
|
|
144
129
|
strUnlocalizedFields.push(templateDeclaredColumn(column) + ',');
|
|
145
130
|
}
|
|
146
|
-
table = templateTable(tableName, strUnlocalizedFields.join('\n '));
|
|
147
|
-
table += templateTable(tableNameLocales, [...strLocalizedFields, templateLocale(), templateParent(tableName)].join('\n '));
|
|
131
|
+
table = templateTable(tableName, strUnlocalizedFields.join('\n '), indexed);
|
|
132
|
+
table += templateTable(tableNameLocales, [...strLocalizedFields, templateLocale(), templateParent(tableName)].join('\n '), ['ownerId', ...localizedIndexed]);
|
|
148
133
|
}
|
|
149
134
|
else {
|
|
150
|
-
const strFields = await generateFieldsTemplates(incomingFields);
|
|
135
|
+
const strFields = await generateFieldsTemplates(incomingFields, undefined, '', indexed);
|
|
151
136
|
if (hasParent) {
|
|
152
137
|
strFields.push(templateParent(rootName));
|
|
153
138
|
}
|
|
@@ -157,7 +142,7 @@ const buildRootTable = async ({ fields: incomingFields, tableName, rootName, has
|
|
|
157
142
|
for (const column of featureColumns) {
|
|
158
143
|
strFields.push(templateDeclaredColumn(column) + ',');
|
|
159
144
|
}
|
|
160
|
-
table = templateTable(tableName, strFields.join('\n '));
|
|
145
|
+
table = templateTable(tableName, strFields.join('\n '), indexed);
|
|
161
146
|
}
|
|
162
147
|
return {
|
|
163
148
|
schema: [table, ...blocksTables].join('\n\n'),
|
|
@@ -167,47 +152,6 @@ const buildRootTable = async ({ fields: incomingFields, tableName, rootName, has
|
|
|
167
152
|
referenceJoins
|
|
168
153
|
};
|
|
169
154
|
};
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
for (const field of fields) {
|
|
173
|
-
// Case 1: If it's a group field, check all fields within the group
|
|
174
|
-
if (field instanceof GroupFieldBuilder) {
|
|
175
|
-
if (hasLocalizedField(field.get.fields)) {
|
|
176
|
-
return true;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
// Case 2: If it's a tabs field, check all fields within each tab
|
|
180
|
-
else if (field instanceof TabsBuilder) {
|
|
181
|
-
for (const tab of field.get.tabs) {
|
|
182
|
-
if (hasLocalizedField(tab.get.fields)) {
|
|
183
|
-
return true;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
// Case 3: If it's a blocks field, check all fields within each block
|
|
188
|
-
else if (field instanceof BlocksBuilder) {
|
|
189
|
-
if (field.get.localized)
|
|
190
|
-
return true;
|
|
191
|
-
for (const block of field.get.blocks) {
|
|
192
|
-
if (hasLocalizedField(block.get.fields)) {
|
|
193
|
-
return true;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
// Case 3: If it's a tree field, check all fields
|
|
198
|
-
else if (field instanceof TreeBuilder) {
|
|
199
|
-
if (field.get.localized)
|
|
200
|
-
return true;
|
|
201
|
-
if (hasLocalizedField(field.get.fields)) {
|
|
202
|
-
return true;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
// Case 4: For regular form fields, check if it's marked as localized
|
|
206
|
-
else if (field instanceof FormFieldBuilder && field.get.localized) {
|
|
207
|
-
return true;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
// If no localized fields were found, return false
|
|
211
|
-
return false;
|
|
212
|
-
}
|
|
155
|
+
/** Whether anything in the tree is localized, container fields included. */
|
|
156
|
+
const hasLocalizedField = (fields) => [...walkFields(fields)].some((visit) => visit.field.get.localized);
|
|
213
157
|
export default buildRootTable;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { FieldReference } from '../../core/fields/builders/form-field-builder.js';
|
|
2
2
|
import type { ColumnDeclaration, TableDeclaration } from '../../core/adapter.js';
|
|
3
|
+
import { type TableName } from '../naming.server.js';
|
|
3
4
|
/**
|
|
4
5
|
* Generates the standard imports needed for Drizzle ORM schema definitions
|
|
5
6
|
* Includes SQLite table definitions, relations, and a primary key helper function
|
|
6
7
|
*/
|
|
7
|
-
export declare const templateImports = "\nimport { text, integer, sqliteTable, real } from \"drizzle-orm/sqlite-core\";\nimport { defineRelations } from 'drizzle-orm';\n\nconst pk = () => text(\"id\").primaryKey().$defaultFn(() => crypto.randomUUID());\n";
|
|
8
|
+
export declare const templateImports = "\nimport { text, integer, sqliteTable, real, index, unique, check, foreignKey } from \"drizzle-orm/sqlite-core\";\nimport { defineRelations, sql } from 'drizzle-orm';\n\nconst pk = () => text(\"id\").primaryKey().$defaultFn(() => crypto.randomUUID());\n";
|
|
8
9
|
/**
|
|
9
10
|
* Generates a basic table definition with a primary key
|
|
10
|
-
* Takes a table name and
|
|
11
|
+
* Takes a table name, its columns, and the columns to index
|
|
11
12
|
*
|
|
12
13
|
* @example
|
|
13
14
|
* ```typescript
|
|
@@ -15,10 +16,19 @@ export declare const templateImports = "\nimport { text, integer, sqliteTable, r
|
|
|
15
16
|
* id: pk(),
|
|
16
17
|
* title: text('title'),
|
|
17
18
|
* content: text('content')
|
|
18
|
-
* })
|
|
19
|
+
* }, (t) => [index('pages_updated_at_idx').on(t.updatedAt)])
|
|
19
20
|
* ```
|
|
20
21
|
*/
|
|
21
|
-
export declare const templateTable: (table: string, content: string) => string;
|
|
22
|
+
export declare const templateTable: (table: string, content: string, indexed?: string[]) => string;
|
|
23
|
+
/**
|
|
24
|
+
* One index per column, named after the table and the column.
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* templateIndexes('pages__$rels', ['ownerId', 'mediasId'])
|
|
28
|
+
* // , (t) => [index('pages__$rels_owner_id_idx').on(t.ownerId), index('pages__$rels_medias_id_idx').on(t.mediasId)]
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const templateIndexes: (table: string, columns: string[]) => string;
|
|
22
32
|
/**
|
|
23
33
|
* Generates a locale field for internationalized tables
|
|
24
34
|
*
|
|
@@ -90,6 +100,17 @@ export declare const templateUniqueRequired: (field: {
|
|
|
90
100
|
unique?: boolean;
|
|
91
101
|
required?: boolean;
|
|
92
102
|
}, defaultValue?: string | number | boolean | object | unknown[]) => string;
|
|
103
|
+
/**
|
|
104
|
+
* The addresses of a collection with `$url`: one row per page and per locale, off its base table.
|
|
105
|
+
*
|
|
106
|
+
* `path` is generated from the parent's path and the slug. Renaming or moving a row carries down
|
|
107
|
+
* its subtree, through the foreign key on `(locale, parent_path)`.
|
|
108
|
+
*
|
|
109
|
+
* ```ts
|
|
110
|
+
* export const pages__$paths = sqliteTable('pages__$paths', { …, path: text('path').generatedAlwaysAs(…) }, …)
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export declare const templatePathsTable: (owner: TableName) => string;
|
|
93
114
|
/** Template rows Relation */
|
|
94
115
|
/**
|
|
95
116
|
* The whole schema's relations, in one declaration.
|
|
@@ -142,7 +163,7 @@ export declare const templateRelations: (tree: Record<string, string[]>, referen
|
|
|
142
163
|
export declare const templateFieldRelationColumn: (slug: string) => string;
|
|
143
164
|
/**
|
|
144
165
|
* Generates a junction table for many-to-many relationships
|
|
145
|
-
* Creates a table with references to the owner table and related tables
|
|
166
|
+
* Creates a table with references to the owner table and related tables, each one indexed
|
|
146
167
|
* Includes path and position fields for ordering relationships
|
|
147
168
|
*
|
|
148
169
|
* @example
|
|
@@ -154,7 +175,7 @@ export declare const templateFieldRelationColumn: (slug: string) => string;
|
|
|
154
175
|
* ownerId: text('owner_id').references(() => pages.id, { onDelete: 'cascade' }),
|
|
155
176
|
* mediasId: text('medias_id').references(() => medias.id, { onDelete: 'cascade' }),
|
|
156
177
|
* locale: text('locale'),
|
|
157
|
-
* })
|
|
178
|
+
* }, (t) => [index('pages_rels_owner_id_idx').on(t.ownerId), index('pages_rels_medias_id_idx').on(t.mediasId)])
|
|
158
179
|
* ```
|
|
159
180
|
*/
|
|
160
181
|
export declare const templateRelationFieldsTable: ({ table, junctionTable, relations, hasLocale }: FieldsRelationTableArgs) => string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toSnakeCase } from '../../util/string.js';
|
|
2
|
-
import { baseTableName, declaredTableProperty, getSchemaColumnNames, joinName } from '../naming.server.js';
|
|
2
|
+
import { baseTableName, declaredTableProperty, getSchemaColumnNames, joinName, tableName } from '../naming.server.js';
|
|
3
3
|
import dedent from 'dedent';
|
|
4
4
|
const s = toSnakeCase;
|
|
5
5
|
/**
|
|
@@ -7,14 +7,14 @@ const s = toSnakeCase;
|
|
|
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,6 +171,37 @@ 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
207
|
* The whole schema's relations, in one declaration.
|
|
@@ -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 {};
|