rimecms 1.3.0 → 1.4.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/collection.server.js +2 -1
- package/dist/adapter-sqlite/columns.server.d.ts +42 -61
- package/dist/adapter-sqlite/columns.server.js +50 -111
- package/dist/adapter-sqlite/generate-schema/column.server.d.ts +8 -6
- package/dist/adapter-sqlite/generate-schema/column.server.js +13 -49
- package/dist/adapter-sqlite/generate-schema/index.server.d.ts +1 -0
- package/dist/adapter-sqlite/generate-schema/index.server.js +6 -0
- package/dist/adapter-sqlite/generate-schema/relations/junction.server.d.ts +3 -3
- package/dist/adapter-sqlite/generate-schema/relations/junction.server.js +3 -3
- package/dist/adapter-sqlite/generate-schema/root.server.d.ts +4 -0
- package/dist/adapter-sqlite/generate-schema/root.server.js +26 -33
- package/dist/adapter-sqlite/generate-schema/templates.server.d.ts +0 -22
- package/dist/adapter-sqlite/generate-schema/templates.server.js +0 -33
- package/dist/adapter-sqlite/generate-schema/write.server.d.ts +6 -0
- package/dist/adapter-sqlite/generate-schema/write.server.js +6 -0
- package/dist/adapter-sqlite/index.server.js +5 -0
- package/dist/adapter-sqlite/locales.server.js +1 -4
- package/dist/adapter-sqlite/order-by.server.d.ts +6 -0
- package/dist/adapter-sqlite/order-by.server.js +6 -0
- package/dist/adapter-sqlite/read.server.d.ts +12 -1
- package/dist/adapter-sqlite/read.server.js +94 -38
- package/dist/adapter-sqlite/registry.server.d.ts +2 -2
- package/dist/adapter-sqlite/registry.server.js +2 -2
- package/dist/adapter-sqlite/relations.server.d.ts +5 -0
- package/dist/adapter-sqlite/relations.server.js +27 -7
- package/dist/adapter-sqlite/repeatable.server.d.ts +4 -1
- package/dist/adapter-sqlite/repeatable.server.js +4 -1
- package/dist/adapter-sqlite/select.server.d.ts +6 -0
- package/dist/adapter-sqlite/select.server.js +56 -113
- package/dist/adapter-sqlite/table.server.js +7 -0
- package/dist/adapter-sqlite/transform.server.js +8 -2
- package/dist/adapter-sqlite/where.server.d.ts +11 -0
- package/dist/adapter-sqlite/where.server.js +237 -236
- package/dist/adapter-sqlite/write.server.d.ts +5 -0
- package/dist/adapter-sqlite/write.server.js +9 -7
- package/dist/core/adapter.d.ts +36 -12
- package/dist/core/auth/access.d.ts +3 -5
- package/dist/core/auth/access.js +3 -5
- package/dist/core/auth/augment.js +3 -4
- package/dist/core/auth/augment.server.d.ts +4 -0
- package/dist/core/auth/augment.server.js +4 -0
- package/dist/core/auth/better-auth/config.server.d.ts +24 -16
- package/dist/core/auth/better-auth/config.server.js +6 -0
- package/dist/core/auth/better-auth/hooks.server.js +17 -5
- package/dist/core/auth/better-auth/instance.server.d.ts +38 -32
- package/dist/core/auth/better-auth/permissions.d.ts +8 -7
- package/dist/core/auth/better-auth/permissions.js +1 -0
- package/dist/core/auth/better-auth-tables.server.d.ts +5 -6
- package/dist/core/auth/better-auth-tables.server.js +5 -6
- package/dist/core/auth/constant.d.ts +3 -3
- package/dist/core/auth/constant.js +3 -3
- package/dist/core/auth/constant.server.d.ts +3 -3
- package/dist/core/auth/constant.server.js +3 -3
- package/dist/core/auth/handler/index.server.js +2 -6
- package/dist/core/auth/hooks/create-better-auth-user.server.d.ts +4 -2
- package/dist/core/auth/hooks/create-better-auth-user.server.js +132 -185
- package/dist/core/auth/hooks/forward-roles.server.d.ts +2 -1
- package/dist/core/auth/hooks/forward-roles.server.js +3 -3
- package/dist/core/auth/hooks/populate-api-key.server.d.ts +2 -2
- package/dist/core/auth/hooks/populate-api-key.server.js +11 -3
- package/dist/core/auth/hooks/prevent-user-mutations.server.d.ts +2 -2
- package/dist/core/auth/hooks/prevent-user-mutations.server.js +5 -4
- package/dist/core/auth/hooks/sign-in-new-user.server.d.ts +5 -6
- package/dist/core/auth/hooks/sign-in-new-user.server.js +5 -6
- package/dist/core/auth/staff/derive.d.ts +10 -0
- package/dist/core/auth/staff/derive.js +10 -0
- package/dist/core/auth/tables.d.ts +4 -0
- package/dist/core/auth/tables.js +4 -0
- package/dist/core/auth/types.d.ts +10 -5
- package/dist/core/auth/validate-config.d.ts +1 -3
- package/dist/core/auth/validate-config.js +2 -4
- package/dist/core/boot.server.d.ts +38 -32
- package/dist/core/codegen.server.js +8 -2
- package/dist/core/config/build.d.ts +1 -1
- package/dist/core/config/build.server.d.ts +2 -1
- package/dist/core/config/build.server.js +1 -0
- package/dist/core/config/context.server.d.ts +3 -9
- package/dist/core/config/context.server.js +3 -9
- package/dist/core/config/index.server.d.ts +4 -2
- package/dist/core/config/index.server.js +4 -2
- package/dist/core/config/types.d.ts +13 -4
- package/dist/core/config/validate.server.d.ts +4 -0
- package/dist/core/config/validate.server.js +100 -90
- package/dist/core/constants.d.ts +13 -5
- package/dist/core/constants.js +13 -5
- package/dist/core/constants.server.d.ts +7 -0
- package/dist/core/constants.server.js +7 -0
- package/dist/core/dev/cache.server.d.ts +10 -7
- package/dist/core/dev/cache.server.js +10 -11
- package/dist/core/dev/cli/commands/build.d.ts +5 -0
- package/dist/core/dev/cli/commands/build.js +17 -2
- package/dist/core/dev/cli/commands/clear.server.d.ts +1 -0
- package/dist/core/dev/cli/commands/clear.server.js +3 -2
- package/dist/core/dev/cli/commands/generate-exports.server.js +25 -4
- package/dist/core/dev/cli/commands/generate.server.d.ts +5 -0
- package/dist/core/dev/cli/commands/generate.server.js +7 -8
- package/dist/core/dev/cli/commands/init.server.d.ts +7 -0
- package/dist/core/dev/cli/commands/init.server.js +34 -7
- package/dist/core/dev/cli/index.js +16 -14
- package/dist/core/dev/cli/templates/build.d.ts +4 -0
- package/dist/core/dev/cli/templates/build.js +4 -0
- package/dist/core/dev/cli/templates/init.d.ts +2 -1
- package/dist/core/dev/cli/templates/init.js +17 -9
- package/dist/core/dev/cli/util/package-manager.server.d.ts +6 -1
- package/dist/core/dev/cli/util/package-manager.server.js +14 -10
- package/dist/core/dev/cli/util/package.server.d.ts +1 -0
- package/dist/core/dev/cli/util/package.server.js +2 -2
- package/dist/core/dev/cli/util/project-name.d.ts +2 -1
- package/dist/core/dev/cli/util/project-name.js +6 -4
- package/dist/core/dev/cli/util/prompt.server.d.ts +2 -1
- package/dist/core/dev/cli/util/prompt.server.js +2 -1
- package/dist/core/dev/codegen/routes/common.server.d.ts +12 -0
- package/dist/core/dev/codegen/routes/common.server.js +9 -17
- package/dist/core/dev/codegen/routes/custom-css.server.d.ts +3 -9
- package/dist/core/dev/codegen/routes/custom-css.server.js +8 -34
- package/dist/core/dev/codegen/routes/index.server.d.ts +4 -5
- package/dist/core/dev/codegen/routes/index.server.js +33 -17
- package/dist/core/dev/codegen/routes/util.server.d.ts +13 -23
- package/dist/core/dev/codegen/routes/util.server.js +15 -25
- package/dist/core/dev/codegen/runtime/index.server.d.ts +2 -3
- package/dist/core/dev/codegen/runtime/index.server.js +2 -3
- package/dist/core/dev/codegen/runtime/parse-exports.server.js +10 -3
- package/dist/core/dev/codegen/sanitize/index.server.d.ts +11 -1
- package/dist/core/dev/codegen/sanitize/index.server.js +81 -50
- package/dist/core/dev/codegen/types/index.server.d.ts +2 -4
- package/dist/core/dev/codegen/types/index.server.js +6 -10
- package/dist/core/dev/codegen/types/templates.server.d.ts +4 -2
- package/dist/core/dev/codegen/types/templates.server.js +13 -26
- package/dist/core/dev/config-memo.server.js +6 -7
- package/dist/core/dev/constants.server.d.ts +4 -2
- package/dist/core/dev/constants.server.js +7 -4
- package/dist/core/dev/ensure.server.d.ts +5 -0
- package/dist/core/dev/ensure.server.js +11 -6
- package/dist/core/dev/env.server.d.ts +3 -1
- package/dist/core/dev/env.server.js +3 -1
- package/dist/core/dev/vite.server.d.ts +10 -0
- package/dist/core/dev/vite.server.js +13 -1
- package/dist/core/errors/handler.server.d.ts +9 -3
- package/dist/core/errors/handler.server.js +11 -6
- package/dist/core/errors/index.d.ts +21 -1
- package/dist/core/errors/index.js +23 -3
- package/dist/core/fields/builders/boolean-builder.d.ts +4 -0
- package/dist/core/fields/builders/boolean-builder.js +6 -1
- package/dist/core/fields/builders/field-builder.d.ts +16 -4
- package/dist/core/fields/builders/field-builder.js +11 -0
- package/dist/core/fields/builders/form-field-builder.d.ts +46 -2
- package/dist/core/fields/builders/form-field-builder.js +47 -2
- package/dist/core/fields/builders/index.d.ts +0 -2
- package/dist/core/fields/builders/index.js +0 -2
- package/dist/core/fields/builders/select-builder.d.ts +13 -2
- package/dist/core/fields/builders/select-builder.js +13 -1
- package/dist/core/fields/initial.d.ts +4 -1
- package/dist/core/fields/types.d.ts +5 -6
- package/dist/core/fields/util.d.ts +9 -14
- package/dist/core/fields/util.js +10 -15
- package/dist/core/fields/validate.d.ts +3 -0
- package/dist/core/fields/validate.js +3 -0
- package/dist/core/fields/walk.d.ts +4 -1
- package/dist/core/fields/walk.js +1 -2
- package/dist/core/handler.server.d.ts +5 -0
- package/dist/core/handler.server.js +15 -1
- package/dist/core/i18n/en/common.d.ts +28 -0
- package/dist/core/i18n/en/common.js +28 -0
- package/dist/core/i18n/en/errors.d.ts +6 -0
- package/dist/core/i18n/en/errors.js +6 -0
- package/dist/core/i18n/en/fields.d.ts +11 -0
- package/dist/core/i18n/en/fields.js +12 -1
- package/dist/core/i18n/fr/common.d.ts +28 -0
- package/dist/core/i18n/fr/common.js +29 -0
- package/dist/core/i18n/fr/errors.d.ts +6 -0
- package/dist/core/i18n/fr/errors.js +6 -0
- package/dist/core/i18n/fr/fields.d.ts +11 -0
- package/dist/core/i18n/fr/fields.js +12 -1
- package/dist/core/i18n/index.d.ts +1 -0
- package/dist/core/i18n/index.js +7 -0
- package/dist/core/i18n/register.server.js +1 -1
- package/dist/core/locale/types.d.ts +2 -6
- package/dist/core/logger.server.js +8 -2
- package/dist/core/panel/configure.js +2 -2
- package/dist/core/panel/types.d.ts +4 -2
- package/dist/core/pipeline/build-document.server.d.ts +2 -2
- package/dist/core/pipeline/build-document.server.js +2 -2
- package/dist/core/pipeline/build.server.js +2 -12
- package/dist/core/{prototype/shared/versions/hooks → pipeline}/fallback-data-from-original.d.ts +6 -6
- package/dist/core/{prototype/shared/versions/hooks → pipeline}/fallback-data-from-original.js +5 -5
- package/dist/core/pipeline/hooks/original-config-map.server.d.ts +3 -2
- package/dist/core/pipeline/hooks/original-config-map.server.js +3 -2
- package/dist/core/pipeline/hooks/process-document-fields.server.d.ts +2 -1
- package/dist/core/pipeline/hooks/process-document-fields.server.js +4 -9
- package/dist/core/pipeline/hooks/sort-document-props.server.js +4 -3
- package/dist/core/pipeline/hooks/validate-fields.server.d.ts +15 -1
- package/dist/core/pipeline/hooks/validate-fields.server.js +142 -47
- package/dist/core/pipeline/persist/blocks/extract.server.d.ts +5 -0
- package/dist/core/pipeline/persist/blocks/extract.server.js +5 -0
- package/dist/core/pipeline/persist/blocks/index.server.d.ts +3 -7
- package/dist/core/pipeline/persist/blocks/index.server.js +3 -8
- package/dist/core/pipeline/persist/relations/diff.server.js +1 -0
- package/dist/core/pipeline/persist/relations/extract.server.d.ts +1 -0
- package/dist/core/pipeline/persist/relations/extract.server.js +2 -0
- package/dist/core/pipeline/persist/relations/index.server.d.ts +6 -0
- package/dist/core/pipeline/persist/relations/index.server.js +31 -8
- package/dist/core/pipeline/persist/repeatable.server.d.ts +21 -12
- package/dist/core/pipeline/persist/repeatable.server.js +28 -4
- package/dist/core/pipeline/persist/tree/extract.server.d.ts +5 -0
- package/dist/core/pipeline/persist/tree/extract.server.js +6 -8
- package/dist/core/pipeline/persist/tree/index.server.d.ts +5 -0
- package/dist/core/pipeline/persist/tree/index.server.js +5 -0
- package/dist/core/pipeline/populate-relations.server.d.ts +1 -0
- package/dist/core/pipeline/populate-relations.server.js +1 -0
- package/dist/core/pipeline/run.server.d.ts +26 -17
- package/dist/core/pipeline/run.server.js +51 -9
- package/dist/core/pipeline/types.d.ts +30 -7
- package/dist/core/pipeline/without-denied-fields.d.ts +15 -0
- package/dist/core/pipeline/without-denied-fields.js +53 -2
- package/dist/core/plugins/api-init/index.server.d.ts +8 -0
- package/dist/core/plugins/api-init/index.server.js +8 -0
- package/dist/core/plugins/cache/HeaderButton.svelte +15 -6
- package/dist/core/plugins/cache/cache.server.d.ts +9 -0
- package/dist/core/plugins/cache/cache.server.js +9 -0
- package/dist/core/plugins/cache/handler.server.d.ts +5 -0
- package/dist/core/plugins/cache/handler.server.js +5 -0
- package/dist/core/plugins/cache/module.server.d.ts +4 -19
- package/dist/core/plugins/cache/module.server.js +5 -1
- package/dist/core/plugins/cache/types.d.ts +6 -0
- package/dist/core/plugins/index.d.ts +1 -0
- package/dist/core/plugins/index.js +1 -0
- package/dist/core/plugins/mailer/index.server.d.ts +5 -2
- package/dist/core/plugins/mailer/index.server.js +4 -0
- package/dist/core/plugins/plugins.server.d.ts +1 -0
- package/dist/core/plugins/plugins.server.js +1 -0
- package/dist/core/plugins/sse/client.js +4 -0
- package/dist/core/prototype/area/definition.server.d.ts +2 -3
- package/dist/core/prototype/area/definition.server.js +2 -3
- package/dist/core/prototype/area/operations/find.d.ts +5 -0
- package/dist/core/prototype/area/operations/find.js +5 -0
- package/dist/core/prototype/area/rest/endpoint.server.d.ts +3 -3
- package/dist/core/prototype/area/rest/endpoint.server.js +3 -3
- package/dist/core/prototype/area/rest/get.server.d.ts +2 -1
- package/dist/core/prototype/area/rest/get.server.js +2 -1
- package/dist/core/prototype/area/rest/update.server.d.ts +2 -1
- package/dist/core/prototype/area/rest/update.server.js +2 -1
- package/dist/core/prototype/collection/api.server.d.ts +15 -1
- package/dist/core/prototype/collection/api.server.js +16 -0
- package/dist/core/prototype/collection/augment-label.d.ts +9 -0
- package/dist/core/prototype/collection/augment-label.js +9 -0
- package/dist/core/prototype/collection/definition.d.ts +1 -1
- package/dist/core/prototype/collection/definition.js +1 -1
- package/dist/core/prototype/collection/hooks/merge-with-initial.server.d.ts +3 -3
- package/dist/core/prototype/collection/hooks/merge-with-initial.server.js +3 -3
- package/dist/core/prototype/collection/hooks.server.d.ts +2 -6
- package/dist/core/prototype/collection/hooks.server.js +8 -9
- package/dist/core/prototype/collection/nested/hooks/add-children.server.d.ts +3 -1
- package/dist/core/prototype/collection/nested/hooks/add-children.server.js +19 -11
- package/dist/core/prototype/collection/nested/hooks/index.server.d.ts +1 -0
- package/dist/core/prototype/collection/nested/hooks/index.server.js +1 -0
- package/dist/core/prototype/collection/nested/hooks/place-at-end.server.d.ts +10 -0
- package/dist/core/prototype/collection/nested/hooks/place-at-end.server.js +24 -0
- package/dist/core/prototype/collection/nested/move.server.d.ts +35 -0
- package/dist/core/prototype/collection/nested/move.server.js +74 -0
- package/dist/core/prototype/collection/operations/count.d.ts +19 -0
- package/dist/core/prototype/collection/operations/count.js +23 -0
- package/dist/core/prototype/collection/operations/create.d.ts +16 -0
- package/dist/core/prototype/collection/operations/create.js +46 -26
- package/dist/core/prototype/collection/operations/delete-by-id.d.ts +5 -0
- package/dist/core/prototype/collection/operations/delete-by-id.js +5 -0
- package/dist/core/prototype/collection/operations/delete.d.ts +8 -0
- package/dist/core/prototype/collection/operations/delete.js +8 -0
- package/dist/core/prototype/collection/operations/duplicate.d.ts +8 -0
- package/dist/core/prototype/collection/operations/duplicate.js +12 -0
- package/dist/core/prototype/collection/operations/find-by-id.d.ts +5 -0
- package/dist/core/prototype/collection/operations/find-by-id.js +5 -0
- package/dist/core/prototype/collection/operations/find.d.ts +6 -1
- package/dist/core/prototype/collection/operations/find.js +7 -2
- package/dist/core/prototype/collection/rest/count.server.d.ts +5 -0
- package/dist/core/prototype/collection/rest/count.server.js +12 -0
- package/dist/core/prototype/collection/rest/create.server.d.ts +2 -1
- package/dist/core/prototype/collection/rest/create.server.js +2 -1
- package/dist/core/prototype/collection/rest/delete-by-id.server.d.ts +1 -3
- package/dist/core/prototype/collection/rest/delete-by-id.server.js +1 -3
- package/dist/core/prototype/collection/rest/get-by-id.server.d.ts +2 -1
- package/dist/core/prototype/collection/rest/get-by-id.server.js +2 -1
- package/dist/core/prototype/collection/rest/get.server.d.ts +2 -1
- package/dist/core/prototype/collection/rest/get.server.js +2 -1
- package/dist/core/prototype/collection/rest/index.server.js +5 -0
- package/dist/core/prototype/collection/rest/lock.server.js +0 -5
- package/dist/core/prototype/collection/rest/move.server.d.ts +11 -0
- package/dist/core/prototype/collection/rest/move.server.js +34 -0
- package/dist/core/prototype/collection/rest/update-by-id.server.d.ts +3 -1
- package/dist/core/prototype/collection/rest/update-by-id.server.js +3 -1
- package/dist/core/prototype/collection/thumbnail/hooks/set-document-thumbnail.server.js +17 -9
- package/dist/core/prototype/collection/upload/boot/index.server.d.ts +3 -5
- package/dist/core/prototype/collection/upload/boot/index.server.js +3 -5
- package/dist/core/prototype/collection/upload/directories/configure.server.js +1 -2
- package/dist/core/prototype/collection/upload/directories/create.server.d.ts +15 -0
- package/dist/core/prototype/collection/upload/directories/create.server.js +19 -0
- package/dist/core/prototype/collection/upload/directories/derive.js +2 -2
- package/dist/core/prototype/collection/upload/directories/pipeline.server.js +5 -4
- package/dist/core/prototype/collection/upload/disk/save.server.d.ts +9 -5
- package/dist/core/prototype/collection/upload/disk/save.server.js +19 -6
- package/dist/core/prototype/collection/upload/ensure.server.d.ts +2 -7
- package/dist/core/prototype/collection/upload/ensure.server.js +2 -7
- package/dist/core/prototype/collection/upload/handler.server.d.ts +4 -0
- package/dist/core/prototype/collection/upload/handler.server.js +13 -4
- package/dist/core/prototype/collection/upload/hooks/convert-base64.server.d.ts +3 -10
- package/dist/core/prototype/collection/upload/hooks/convert-base64.server.js +5 -18
- package/dist/core/prototype/collection/upload/hooks/delete-folder-contents.server.d.ts +10 -0
- package/dist/core/prototype/collection/upload/hooks/delete-folder-contents.server.js +30 -0
- package/dist/core/prototype/collection/upload/hooks/extract-path.server.d.ts +1 -1
- package/dist/core/prototype/collection/upload/hooks/extract-path.server.js +1 -1
- package/dist/core/prototype/collection/upload/hooks/handle-path-creation.server.js +8 -20
- package/dist/core/prototype/collection/upload/hooks/index.server.d.ts +2 -5
- package/dist/core/prototype/collection/upload/hooks/index.server.js +2 -5
- package/dist/core/prototype/collection/upload/hooks/populate-sizes.server.d.ts +4 -2
- package/dist/core/prototype/collection/upload/hooks/populate-sizes.server.js +18 -19
- package/dist/core/prototype/collection/upload/hooks/process-file-upload.server.d.ts +3 -1
- package/dist/core/prototype/collection/upload/hooks/process-file-upload.server.js +16 -3
- package/dist/core/prototype/collection/upload/hooks/update-directory-children.server.js +3 -2
- package/dist/core/prototype/collection/upload/module.d.ts +4 -2
- package/dist/core/prototype/collection/upload/module.js +12 -17
- package/dist/core/prototype/collection/upload/module.server.d.ts +3 -4
- package/dist/core/prototype/collection/upload/module.server.js +3 -4
- package/dist/core/prototype/collection/upload/types.d.ts +21 -6
- package/dist/core/prototype/collection/upload/util/client.d.ts +2 -2
- package/dist/core/prototype/collection/upload/util/client.js +2 -2
- package/dist/core/prototype/collection/upload/util/config.d.ts +1 -0
- package/dist/core/prototype/collection/upload/util/converter.server.d.ts +5 -0
- package/dist/core/prototype/collection/upload/util/converter.server.js +16 -24
- package/dist/core/prototype/collection/upload/util/mime.d.ts +60 -0
- package/dist/core/prototype/collection/upload/util/mime.js +94 -4
- package/dist/core/prototype/collection/upload/util/path.d.ts +5 -1
- package/dist/core/prototype/collection/upload/util/path.js +9 -12
- package/dist/core/prototype/define.d.ts +14 -0
- package/dist/core/prototype/define.js +14 -0
- package/dist/core/prototype/shared/title/find-title.js +1 -0
- package/dist/core/prototype/shared/title/select.d.ts +2 -2
- package/dist/core/prototype/shared/title/select.js +2 -2
- package/dist/core/prototype/shared/url/hooks/set-live-url.server.js +2 -3
- package/dist/core/prototype/shared/versions/augment.js +8 -4
- package/dist/core/prototype/shared/versions/hooks/handle-new-version.server.js +6 -2
- package/dist/core/prototype/shared/versions/validate-config.server.js +1 -2
- package/dist/core/prototype/types.d.ts +0 -5
- package/dist/core/rime.server.d.ts +3 -2
- package/dist/core/rime.server.js +3 -2
- package/dist/core/routes/context.server.d.ts +11 -0
- package/dist/core/routes/context.server.js +11 -0
- package/dist/core/routes/handler.server.d.ts +4 -3
- package/dist/core/routes/handler.server.js +4 -3
- package/dist/core/routes/panel-navigation.d.ts +4 -5
- package/dist/core/routes/panel-navigation.js +4 -8
- package/dist/core/routes/util.d.ts +8 -2
- package/dist/core/routes/util.js +10 -4
- package/dist/fields/blocks/component/AddBlockButton.svelte +1 -0
- package/dist/fields/blocks/component/Blocks.svelte +15 -11
- package/dist/fields/blocks/component/focus/BlocksFocus.svelte +22 -10
- package/dist/fields/blocks/component/focus/LayersList.svelte +5 -0
- package/dist/fields/blocks/component/focus/Palette.svelte +0 -1
- package/dist/fields/blocks/component/focus/Renders.svelte +5 -4
- package/dist/fields/blocks/component/focus/Renders.svelte.d.ts +2 -1
- package/dist/fields/blocks/component/focus/focus.svelte.js +42 -13
- package/dist/fields/blocks/component/picker/BlockPicker.svelte +2 -2
- package/dist/fields/blocks/index.d.ts +16 -0
- package/dist/fields/blocks/index.js +15 -2
- package/dist/fields/checkbox/component/Checkbox.svelte +1 -0
- package/dist/fields/combobox/component/ComboBox.svelte +3 -2
- package/dist/fields/combobox/index.d.ts +1 -0
- package/dist/fields/combobox/index.js +1 -0
- package/dist/fields/component/index.d.ts +3 -0
- package/dist/fields/component/index.js +3 -0
- package/dist/fields/date/component/Date.svelte +8 -5
- package/dist/fields/date/index.d.ts +1 -0
- package/dist/fields/date/index.js +1 -0
- package/dist/fields/email/component/Email.svelte +8 -5
- package/dist/fields/email/index.d.ts +1 -0
- package/dist/fields/email/index.js +1 -0
- package/dist/fields/group/component/Group.svelte +8 -15
- package/dist/fields/group/index.d.ts +7 -1
- package/dist/fields/group/index.js +5 -4
- package/dist/fields/link/component/Link.svelte +19 -8
- package/dist/fields/link/component/RessourceInput.svelte +68 -47
- package/dist/fields/link/index.d.ts +12 -0
- package/dist/fields/link/index.js +14 -1
- package/dist/fields/number/component/Number.svelte +1 -0
- package/dist/fields/number/index.js +5 -3
- package/dist/fields/radio/component/Radio.svelte +12 -3
- package/dist/fields/radio/index.d.ts +1 -0
- package/dist/fields/radio/index.js +1 -0
- package/dist/fields/relation/component/Cell.svelte +4 -4
- package/dist/fields/relation/component/Relation.svelte +92 -131
- package/dist/fields/relation/component/Relation.svelte.d.ts +0 -1
- package/dist/fields/relation/component/RelationInline.svelte +22 -27
- package/dist/fields/relation/component/default/Default.svelte +50 -19
- package/dist/fields/relation/component/default/Default.svelte.d.ts +12 -1
- package/dist/fields/relation/component/types.d.ts +5 -3
- package/dist/fields/relation/component/upload/Browse.svelte +50 -41
- package/dist/fields/relation/component/upload/Browse.svelte.d.ts +6 -1
- package/dist/fields/relation/component/upload/Upload.svelte +8 -3
- package/dist/fields/relation/component/upload/Upload.svelte.d.ts +0 -1
- package/dist/fields/relation/index.d.ts +27 -10
- package/dist/fields/relation/index.js +16 -0
- package/dist/fields/relation/populate.js +1 -0
- package/dist/fields/relation/query.d.ts +22 -0
- package/dist/fields/relation/query.js +29 -0
- package/dist/fields/relation/relation.test-d.js +11 -0
- package/dist/fields/repeatable/RepeatableActions.svelte +4 -0
- package/dist/fields/repeatable/RepeatableActions.svelte.d.ts +4 -0
- package/dist/fields/repeatable.js +3 -21
- package/dist/fields/rich-text/client.d.ts +26 -0
- package/dist/fields/rich-text/client.js +26 -0
- package/dist/fields/rich-text/component/RichTextInline.svelte +2 -9
- package/dist/fields/rich-text/component/RichTextInline.svelte.d.ts +2 -9
- package/dist/fields/rich-text/component/bubble-menu/bubble-menu.svelte +2 -0
- package/dist/fields/rich-text/component/bubble-menu/icon-button/icon-button.css +0 -1
- package/dist/fields/rich-text/component/bubble-menu/icon-button/icon-button.svelte +1 -2
- package/dist/fields/rich-text/component/bubble-menu/node-selector/node-selector.css +0 -1
- package/dist/fields/rich-text/component/bubble-menu/node-selector/node-selector.svelte +9 -6
- package/dist/fields/rich-text/component/context.svelte.d.ts +1 -0
- package/dist/fields/rich-text/component/context.svelte.js +1 -0
- package/dist/fields/rich-text/component/drag-handle/drag-handle.css +0 -1
- package/dist/fields/rich-text/component/drag-handle/drag-handle.svelte +1 -0
- package/dist/fields/rich-text/component/styles/editor.css +0 -1
- package/dist/fields/rich-text/component/styles/field.css +10 -11
- package/dist/fields/rich-text/core/build-editor-config.d.ts +15 -6
- package/dist/fields/rich-text/core/build-editor-config.js +47 -66
- package/dist/fields/rich-text/core/extensions/current-node/current-node.css +1 -0
- package/dist/fields/rich-text/core/extensions/current-node/current-node.d.ts +2 -2
- package/dist/fields/rich-text/core/extensions/current-node/current-node.js +3 -4
- package/dist/fields/rich-text/core/extensions/drag-handle/drag-handle-plugin.d.ts +5 -0
- package/dist/fields/rich-text/core/extensions/drag-handle/drag-handle-plugin.js +40 -77
- package/dist/fields/rich-text/core/extensions/drag-handle/drag-handle.d.ts +1 -1
- package/dist/fields/rich-text/core/extensions/drag-handle/drag-handle.js +1 -1
- package/dist/fields/rich-text/core/extensions/drag-handle/helpers/cloneElement.d.ts +4 -0
- package/dist/fields/rich-text/core/extensions/drag-handle/helpers/cloneElement.js +5 -0
- package/dist/fields/rich-text/core/extensions/drag-handle/helpers/dragHandler.d.ts +5 -0
- package/dist/fields/rich-text/core/extensions/drag-handle/helpers/dragHandler.js +11 -13
- package/dist/fields/rich-text/core/extensions/drag-handle/helpers/findNextElementFromCursor.d.ts +6 -8
- package/dist/fields/rich-text/core/extensions/drag-handle/helpers/findNextElementFromCursor.js +9 -14
- package/dist/fields/rich-text/core/extensions/drag-handle/helpers/getInnerCoords.d.ts +1 -0
- package/dist/fields/rich-text/core/extensions/drag-handle/helpers/getInnerCoords.js +6 -5
- package/dist/fields/rich-text/core/extensions/drag-handle/helpers/getOuterNode.d.ts +3 -1
- package/dist/fields/rich-text/core/extensions/drag-handle/helpers/getOuterNode.js +8 -21
- package/dist/fields/rich-text/core/features/blockquote.js +5 -1
- package/dist/fields/rich-text/core/features/bold.js +0 -3
- package/dist/fields/rich-text/core/features/bullet-list.js +5 -1
- package/dist/fields/rich-text/core/features/fields/extension.d.ts +1 -0
- package/dist/fields/rich-text/core/features/fields/extension.js +1 -0
- package/dist/fields/rich-text/core/features/fields/fields-form.svelte +54 -0
- package/dist/fields/rich-text/core/features/fields/fields-form.svelte.d.ts +14 -0
- package/dist/fields/rich-text/core/features/fields/fields.svelte +30 -35
- package/dist/fields/rich-text/core/features/fields/index.d.ts +2 -0
- package/dist/fields/rich-text/core/features/fields/index.js +1 -0
- package/dist/fields/rich-text/core/features/heading.js +19 -68
- package/dist/fields/rich-text/core/features/hr/hr.css +1 -2
- package/dist/fields/rich-text/core/features/hr/hr.js +5 -1
- package/dist/fields/rich-text/core/features/index.d.ts +1 -0
- package/dist/fields/rich-text/core/features/index.js +1 -0
- package/dist/fields/rich-text/core/features/json-attribute.d.ts +1 -1
- package/dist/fields/rich-text/core/features/json-attribute.js +1 -1
- package/dist/fields/rich-text/core/features/link/component/link-selector.svelte +61 -58
- package/dist/fields/rich-text/core/features/link/component/link-selector.svelte.d.ts +3 -1
- package/dist/fields/rich-text/core/features/link/index.d.ts +5 -0
- package/dist/fields/rich-text/core/features/link/index.js +2 -14
- package/dist/fields/rich-text/core/features/ordered-list.js +5 -1
- package/dist/fields/rich-text/core/features/paragraph.js +5 -1
- package/dist/fields/rich-text/core/features/pick-dialog.svelte +16 -4
- package/dist/fields/rich-text/core/features/pick-dialog.svelte.d.ts +7 -3
- package/dist/fields/rich-text/core/features/resource/index.d.ts +1 -0
- package/dist/fields/rich-text/core/features/resource/index.js +1 -0
- package/dist/fields/rich-text/core/features/resource/resource-extension.d.ts +1 -0
- package/dist/fields/rich-text/core/features/resource/resource-extension.js +8 -6
- package/dist/fields/rich-text/core/features/resource/resource.svelte +38 -49
- package/dist/fields/rich-text/core/features/resource/types.d.ts +1 -0
- package/dist/fields/rich-text/core/features/upload/index.d.ts +1 -0
- package/dist/fields/rich-text/core/features/upload/index.js +2 -1
- package/dist/fields/rich-text/core/features/upload/upload-extension.d.ts +6 -0
- package/dist/fields/rich-text/core/features/upload/upload-extension.js +2 -2
- package/dist/fields/{relation/component → rich-text/core/features}/upload/upload.css +1 -2
- package/dist/fields/rich-text/core/features/upload/upload.svelte +47 -73
- package/dist/fields/rich-text/core/features/upload/upload.svelte.d.ts +1 -0
- package/dist/fields/rich-text/core/render-rich-text.svelte +30 -16
- package/dist/fields/rich-text/core/rich-text-editor-core.svelte +8 -3
- package/dist/fields/rich-text/core/rich-text-editor-core.svelte.d.ts +1 -0
- package/dist/fields/rich-text/core/svelte/constant.d.ts +1 -0
- package/dist/fields/rich-text/core/svelte/constant.js +1 -0
- package/dist/fields/rich-text/core/svelte/node-view-renderer.svelte.d.ts +10 -0
- package/dist/fields/rich-text/core/svelte/node-view-renderer.svelte.js +23 -6
- package/dist/fields/rich-text/core/svelte/node-view-wrapper.svelte +6 -2
- package/dist/fields/rich-text/core/svelte/node-view-wrapper.svelte.d.ts +1 -0
- package/dist/fields/rich-text/core/svelte/renderer.d.ts +1 -0
- package/dist/fields/rich-text/core/svelte/renderer.js +1 -0
- package/dist/fields/rich-text/core/types.d.ts +11 -0
- package/dist/fields/rich-text/index.d.ts +2 -0
- package/dist/fields/rich-text/index.js +12 -7
- package/dist/fields/rich-text/json.d.ts +6 -4
- package/dist/fields/rich-text/json.js +6 -4
- package/dist/fields/select/component/Select.svelte +37 -12
- package/dist/fields/select/index.d.ts +2 -1
- package/dist/fields/select/index.js +1 -0
- package/dist/fields/separator/index.d.ts +1 -0
- package/dist/fields/separator/index.js +1 -0
- package/dist/fields/slug/component/Slug.svelte +14 -13
- package/dist/fields/slug/index.d.ts +11 -0
- package/dist/fields/slug/index.js +11 -0
- package/dist/fields/tabs/component/Tabs.svelte +4 -7
- package/dist/fields/tabs/index.d.ts +10 -0
- package/dist/fields/tabs/index.js +10 -0
- package/dist/fields/text/component/TextInline.svelte +12 -10
- package/dist/fields/text/index.d.ts +7 -0
- package/dist/fields/text/index.js +9 -2
- package/dist/fields/textarea/index.d.ts +3 -0
- package/dist/fields/textarea/index.js +5 -2
- package/dist/fields/time/index.d.ts +1 -0
- package/dist/fields/time/index.js +4 -6
- package/dist/fields/toggle/component/Toggle.svelte +1 -0
- package/dist/fields/toggle/index.d.ts +1 -0
- package/dist/fields/toggle/index.js +1 -0
- package/dist/fields/tree/component/AddItemButton.svelte +3 -2
- package/dist/fields/tree/component/AddItemButton.svelte.d.ts +1 -1
- package/dist/fields/tree/component/Tree.svelte +16 -57
- package/dist/fields/tree/component/TreeBlock.svelte +26 -40
- package/dist/fields/tree/component/props.d.ts +3 -2
- package/dist/fields/tree/index.js +14 -2
- package/dist/fields/tree/util.js +0 -3
- package/dist/fields/types.d.ts +23 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/live/Consumer.svelte +6 -0
- package/dist/live/LiveEdit.svelte +23 -5
- package/dist/live/LiveEdit.svelte.d.ts +2 -1
- package/dist/live/Provider.svelte +5 -1
- package/dist/live/context.svelte.d.ts +3 -4
- package/dist/live/context.svelte.js +9 -6
- package/dist/panel/components/Root.svelte +7 -1
- package/dist/panel/components/fields/FieldsPreview.svelte +15 -1
- package/dist/panel/components/fields/Label.svelte +2 -0
- package/dist/panel/components/fields/RenderFields.svelte +12 -1
- package/dist/panel/components/fields/fieldset.svelte.d.ts +7 -1
- package/dist/panel/components/fields/fieldset.svelte.js +7 -1
- package/dist/panel/components/fields/setting.css +7 -0
- package/dist/panel/components/sections/auth/AuthForm.svelte +4 -1
- package/dist/panel/components/sections/collection/Avatar.svelte +1 -1
- package/dist/panel/components/sections/collection/bulk-upload/FileDrop.svelte +3 -0
- package/dist/panel/components/sections/collection/bulk-upload/PageDrop.svelte +11 -1
- package/dist/panel/components/sections/collection/folder/FolderEdit.svelte +10 -1
- package/dist/panel/components/sections/collection/folder/FolderWithActions.svelte +45 -34
- package/dist/panel/components/sections/collection/folder/Folders.svelte +1 -0
- package/dist/panel/components/sections/collection/grid/CollectionGrid.svelte +8 -3
- package/dist/panel/components/sections/collection/grid/CollectionGrid.svelte.d.ts +2 -1
- package/dist/panel/components/sections/collection/grid/create-directory-dialog/CreateDirectoryDialog.svelte +3 -1
- package/dist/panel/components/sections/collection/grid/grid-item/GridItem.svelte +4 -0
- package/dist/panel/components/sections/collection/header/ButtonCreate.svelte +1 -5
- package/dist/panel/components/sections/collection/header/SearchInput.svelte +2 -0
- package/dist/panel/components/sections/collection/header/SelectUI.svelte +25 -5
- package/dist/panel/components/sections/collection/list/CollectionList.svelte +4 -1
- package/dist/panel/components/sections/collection/list/row/Row.svelte +16 -16
- package/dist/panel/components/sections/collection/list/row/Row.svelte.d.ts +4 -4
- package/dist/panel/components/sections/collection/tree/CollectionTree.svelte +4 -80
- package/dist/panel/components/sections/collection/tree/CollectionTreeNode.svelte +18 -8
- package/dist/panel/components/sections/collection/tree/sortable.d.ts +11 -0
- package/dist/panel/components/sections/collection/tree/sortable.js +45 -0
- package/dist/panel/components/sections/collection/upload-thumb-cell/UploadThumbCell.svelte +5 -3
- package/dist/panel/components/sections/collection/upload-thumb-cell/UploadThumbCell.svelte.d.ts +0 -1
- package/dist/panel/components/sections/commands/CommandPalette.svelte +5 -0
- package/dist/panel/components/sections/document/AuthAPIKeyDialog.svelte +14 -4
- package/dist/panel/components/sections/document/AuthAPIKeyDialog.svelte.d.ts +2 -0
- package/dist/panel/components/sections/document/AuthFooter.svelte +37 -31
- package/dist/panel/components/sections/document/AuthFooter.svelte.d.ts +0 -2
- package/dist/panel/components/sections/document/ButtonSave.svelte +2 -6
- package/dist/panel/components/sections/document/ButtonSave.svelte.d.ts +1 -3
- package/dist/panel/components/sections/document/ButtonStatus.svelte +24 -11
- package/dist/panel/components/sections/document/ChangeSlugDialog.svelte +16 -0
- package/dist/panel/components/sections/document/CurrentlyEdited.svelte +5 -3
- package/dist/panel/components/sections/document/CurrentlyEdited.svelte.d.ts +1 -0
- package/dist/panel/components/sections/document/Document.svelte +29 -18
- package/dist/panel/components/sections/document/DocumentChildren.svelte +48 -41
- package/dist/panel/components/sections/document/Header.svelte +13 -11
- package/dist/panel/components/sections/document/Settings.svelte +127 -157
- package/dist/panel/components/sections/document/Versions.svelte +11 -2
- package/dist/panel/components/sections/document/upload-header/UploadHeader.svelte +32 -13
- package/dist/panel/components/sections/document/upload-header/UploadHeader.svelte.d.ts +2 -0
- package/dist/panel/components/sections/document/upload-header/drop-zone/DropZone.svelte +24 -10
- package/dist/panel/components/sections/document/upload-header/drop-zone/DropZone.svelte.d.ts +3 -0
- package/dist/panel/components/sections/live/LiveEditPanel.svelte +11 -5
- package/dist/panel/components/sections/live/LiveEditPanel.svelte.d.ts +10 -3
- package/dist/panel/components/sections/live/LiveFloatingUI.svelte +18 -2
- package/dist/panel/components/sections/live/LiveFloatingUI.svelte.d.ts +3 -0
- package/dist/panel/components/ui/button/button.svelte +0 -3
- package/dist/panel/components/ui/calendar/calendar.css +0 -1
- package/dist/panel/components/ui/calendar/calendar.svelte.d.ts +1 -1
- package/dist/panel/components/ui/card-resource/card-resource.svelte +17 -3
- package/dist/panel/components/ui/card-resource/card-resource.svelte.d.ts +2 -0
- package/dist/panel/components/ui/checkbox/checkbox.svelte.d.ts +1 -1
- package/dist/panel/components/ui/command/command-count.css +6 -0
- package/dist/panel/components/ui/command/command-count.svelte +15 -0
- package/dist/panel/components/ui/command/command-count.svelte.d.ts +9 -0
- package/dist/panel/components/ui/command/command-dialog.css +2 -0
- package/dist/panel/components/ui/command/command-input-select.svelte +5 -0
- package/dist/panel/components/ui/command/filter.d.ts +10 -0
- package/dist/panel/components/ui/command/filter.js +11 -0
- package/dist/panel/components/ui/command/index.d.ts +2 -1
- package/dist/panel/components/ui/command/index.js +2 -1
- package/dist/panel/components/ui/context-menu/context-menu.css +2 -2
- package/dist/panel/components/ui/dialog/dialog-content.css +4 -1
- package/dist/panel/components/ui/dialog/dialog-content.svelte +8 -1
- package/dist/panel/components/ui/dialog/dialog-overlay.css +2 -1
- package/dist/panel/components/ui/dropdown-menu/dropdown-menu-content.css +2 -2
- package/dist/panel/components/ui/input/input.svelte +3 -0
- package/dist/panel/components/ui/language-switcher/LanguageSwitcher.svelte +1 -1
- package/dist/panel/components/ui/layer/layer.svelte.d.ts +22 -0
- package/dist/panel/components/ui/layer/layer.svelte.js +37 -0
- package/dist/panel/components/ui/nav/Nav.svelte +4 -9
- package/dist/panel/components/ui/nav/NavGroup.svelte +6 -6
- package/dist/panel/components/ui/nav/NavItem.svelte +1 -0
- package/dist/panel/components/ui/nav/NavItem.svelte.d.ts +1 -0
- package/dist/panel/components/ui/nav/UserButton.svelte +4 -4
- package/dist/panel/components/ui/page-header/PageHeader.svelte +1 -5
- package/dist/panel/components/ui/page-header/PageHeader.svelte.d.ts +1 -0
- package/dist/panel/components/ui/popover/popover-content.css +2 -1
- package/dist/panel/components/ui/radio-row-group/radio-row-group.css +0 -1
- package/dist/panel/components/ui/scroll-area/scroll-area-scrollbar.svelte +3 -4
- package/dist/panel/components/ui/scroll-area/scroll-area-scrollbar.svelte.d.ts +1 -1
- package/dist/panel/components/ui/scroll-area/scroll-area.css +0 -6
- package/dist/panel/components/ui/scroll-area/scroll-area.svelte +4 -1
- package/dist/panel/components/ui/sheet/index.d.ts +1 -1
- package/dist/panel/components/ui/sheet/sheet-content.svelte +13 -2
- package/dist/panel/components/ui/sheet/sheet-content.svelte.d.ts +3 -0
- package/dist/panel/components/ui/sheet/sheet.css +11 -43
- package/dist/panel/components/ui/sonner/sonner.css +5 -0
- package/dist/panel/components/ui/switch/switch.svelte.d.ts +1 -1
- package/dist/panel/components/ui/tag/tag.svelte +8 -1
- package/dist/panel/components/ui/tooltip/tooltip-content.svelte +1 -1
- package/dist/panel/components/ui/tree/tree-rows.css +1 -8
- package/dist/panel/context/api-proxy.svelte.d.ts +2 -0
- package/dist/panel/context/api-proxy.svelte.js +30 -4
- package/dist/panel/context/blocks-ops.d.ts +6 -0
- package/dist/panel/context/blocks-ops.js +6 -0
- package/dist/panel/context/bulk-delete.d.ts +4 -3
- package/dist/panel/context/bulk-delete.js +13 -7
- package/dist/panel/context/collection.svelte.d.ts +10 -22
- package/dist/panel/context/collection.svelte.js +73 -115
- package/dist/panel/context/commands.svelte.js +5 -0
- package/dist/panel/context/config.svelte.js +2 -0
- package/dist/panel/context/createContext.svelte.d.ts +1 -0
- package/dist/panel/context/createContext.svelte.js +1 -0
- package/dist/panel/context/documentForm.svelte.d.ts +4 -2
- package/dist/panel/context/documentForm.svelte.js +87 -159
- package/dist/panel/context/errors.svelte.d.ts +8 -0
- package/dist/panel/context/errors.svelte.js +8 -0
- package/dist/panel/context/form.svelte.d.ts +8 -1
- package/dist/panel/context/form.svelte.js +37 -40
- package/dist/panel/context/livePanel.svelte.d.ts +3 -0
- package/dist/panel/context/locale.svelte.js +3 -0
- package/dist/panel/context/nav.svelte.js +9 -21
- package/dist/panel/context/tree-ops.d.ts +14 -0
- package/dist/panel/context/tree-ops.js +70 -0
- package/dist/panel/context/versions.svelte.d.ts +6 -0
- package/dist/panel/context/versions.svelte.js +18 -0
- package/dist/panel/index.d.ts +1 -10
- package/dist/panel/pages/area/Area.svelte +1 -1
- package/dist/panel/pages/area/actions.server.js +1 -0
- package/dist/panel/pages/area/load.server.d.ts +1 -0
- package/dist/panel/pages/area/load.server.js +1 -1
- package/dist/panel/pages/auth/forgot-password/ForgotPassword.svelte +23 -16
- package/dist/panel/pages/auth/forgot-password/load.server.d.ts +1 -0
- package/dist/panel/pages/auth/forgot-password/load.server.js +3 -5
- package/dist/panel/pages/auth/image.server.d.ts +6 -0
- package/dist/panel/pages/auth/image.server.js +19 -0
- package/dist/panel/pages/auth/reset-password/ResetPassword.svelte +22 -15
- package/dist/panel/pages/auth/reset-password/load.server.d.ts +3 -0
- package/dist/panel/pages/auth/reset-password/load.server.js +5 -5
- package/dist/panel/pages/auth/sign-in/actions.server.js +33 -25
- package/dist/panel/pages/auth/sign-in/load.server.d.ts +4 -0
- package/dist/panel/pages/auth/sign-in/load.server.js +6 -5
- package/dist/panel/pages/collection/Collection.svelte.d.ts +1 -1
- package/dist/panel/pages/collection/CollectionPage.svelte +31 -27
- package/dist/panel/pages/collection/CollectionPage.svelte.d.ts +1 -1
- package/dist/panel/pages/collection/load.server.d.ts +5 -2
- package/dist/panel/pages/collection/load.server.js +53 -54
- package/dist/panel/pages/collection-document/CollectionDocument.svelte +1 -1
- package/dist/panel/pages/collection-document/actions.server.js +3 -11
- package/dist/panel/pages/collection-document/load.server.d.ts +5 -0
- package/dist/panel/pages/collection-document/load.server.js +10 -3
- package/dist/panel/pages/dashboard/load.server.d.ts +3 -0
- package/dist/panel/pages/dashboard/load.server.js +19 -8
- package/dist/panel/pages/live/Live.svelte +45 -45
- package/dist/panel/pages/live/load.server.d.ts +5 -0
- package/dist/panel/pages/live/load.server.js +5 -0
- package/dist/panel/pages/shared/DocumentPage.svelte +9 -5
- package/dist/panel/pages/shared/DocumentPage.svelte.d.ts +0 -1
- package/dist/panel/style/font.css +1 -1
- package/dist/panel/style/index.css +21 -6
- package/dist/panel/style/palette.css +1 -1
- package/dist/panel/style/size.css +1 -0
- package/dist/panel/style/z-index.css +18 -0
- package/dist/panel/types.d.ts +0 -1
- package/dist/panel/util/Sortable.d.ts +6 -1
- package/dist/panel/util/Sortable.js +6 -1
- package/dist/panel/util/auth.d.ts +18 -0
- package/dist/panel/util/auth.js +25 -0
- package/dist/panel/util/candidates.svelte.d.ts +118 -0
- package/dist/panel/util/candidates.svelte.js +176 -0
- package/dist/panel/util/count.d.ts +19 -0
- package/dist/panel/util/count.js +20 -0
- package/dist/panel/util/dataError.d.ts +1 -0
- package/dist/panel/util/dataError.js +1 -0
- package/dist/panel/util/storage.d.ts +13 -0
- package/dist/panel/util/storage.js +37 -0
- package/dist/panel/util/time.d.ts +7 -1
- package/dist/panel/util/time.js +19 -5
- package/dist/panel/util/upload-file.d.ts +0 -8
- package/dist/panel/util/upload-file.js +6 -12
- package/dist/server.js +3 -0
- package/dist/util/form-data.d.ts +3 -3
- package/dist/util/form-data.js +4 -2
- package/dist/util/function.d.ts +7 -6
- package/dist/util/function.js +7 -6
- package/dist/util/object.d.ts +10 -11
- package/dist/util/object.js +21 -55
- package/dist/util/random.d.ts +8 -12
- package/dist/util/random.js +34 -88
- package/dist/util/string.js +76 -114
- package/dist/util/types.d.ts +2 -0
- package/package.json +12 -15
- package/dist/fields/rich-text/core/extensions/drag-handle/helpers/getComputedStyle.d.ts +0 -1
- package/dist/fields/rich-text/core/extensions/drag-handle/helpers/getComputedStyle.js +0 -4
- package/dist/fields/rich-text/core/features/link/component/link-selector.css +0 -0
- package/dist/fields/rich-text/core/features/resource/resource.css +0 -0
- package/dist/panel/style/util.css +0 -3
- package/dist/panel/util/once.svelte.d.ts +0 -3
- package/dist/panel/util/once.svelte.js +0 -12
|
@@ -6,14 +6,29 @@ import { isRelationField } from '../fields/relation/index.js';
|
|
|
6
6
|
import {} from '../index.js';
|
|
7
7
|
import { isObjectLiteral } from '../util/object.js';
|
|
8
8
|
import * as drizzleORM from 'drizzle-orm';
|
|
9
|
-
import { and, eq, getTableColumns, inArray, or } from 'drizzle-orm';
|
|
9
|
+
import { and, eq, getTableColumns, inArray, notInArray, or } from 'drizzle-orm';
|
|
10
10
|
import { localeOrder } from './locales.server.js';
|
|
11
11
|
import { baseTableName, junctionKey, tableName } from './naming.server.js';
|
|
12
|
+
/**
|
|
13
|
+
* A REST `where` as one drizzle condition on `slug`'s table. A key is a document path
|
|
14
|
+
* (`attributes.title`), a field of a related document (`author.name`), `url`, or `and`/`or`
|
|
15
|
+
* holding a list. Several keys, or several operators on one key, must all match. With `base`,
|
|
16
|
+
* `slug` is that prototype's versions table: `id` then means the document and `versionId` the
|
|
17
|
+
* row. `false` for an empty `and`/`or`.
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* buildWhereParam({ query: { where: { 'attributes.title': { like: 'home' } } }, slug: 'pages', … })
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
12
23
|
export const buildWhereParam = ({ query, slug, db, locale, tables, configCtx, base, rootTable }) => {
|
|
13
24
|
/** `slug` names a content table standing in for `base`, not a prototype's own rows. */
|
|
14
25
|
const isShadow = !!base;
|
|
15
26
|
/** The generated table named `key`. */
|
|
16
27
|
const getTable = (key) => tables[key];
|
|
28
|
+
/**
|
|
29
|
+
* The table of `slug`, its locales branch, and their column names. No localized column
|
|
30
|
+
* without a `locale`.
|
|
31
|
+
*/
|
|
17
32
|
function getTablesAndColumns(slug) {
|
|
18
33
|
// Get main table and localized table if applicable
|
|
19
34
|
const table = getTable(baseTableName(slug));
|
|
@@ -33,6 +48,16 @@ export const buildWhereParam = ({ query, slug, db, locale, tables, configCtx, ba
|
|
|
33
48
|
// slug: a camelCase slug is not a table name.
|
|
34
49
|
const baseTable = isShadow ? getTable(baseTableName(base)) : undefined;
|
|
35
50
|
const baseColumns = baseTable ? Object.keys(getTableColumns(baseTable)) : [];
|
|
51
|
+
/** The addresses of a collection with `$url`, kept off the base table. */
|
|
52
|
+
const pathsTable = getTable(tableName({ owner: baseTableName(base ?? slug), child: { kind: 'paths' } }));
|
|
53
|
+
/** The junction rows of `slug`'s relation fields. */
|
|
54
|
+
const relsTable = getTable(tableName({ owner: baseTableName(slug), child: { kind: 'rels' } }));
|
|
55
|
+
/**
|
|
56
|
+
* One condition: an `and`/`or` list, or `{ path: { operator: value } }` resolved against, in
|
|
57
|
+
* this order, the paths table (`url`, `_urlPath`), a column of the table, a localized column, a
|
|
58
|
+
* base-row column of a versions table, and a relation field. A path none of them knows matches
|
|
59
|
+
* nothing.
|
|
60
|
+
*/
|
|
36
61
|
const buildCondition = (conditionObject) => {
|
|
37
62
|
// `{ a: …, b: … }` is `a` and `b`; `{ price: { greater_than: 1, less_than: 10 } }` is both bounds.
|
|
38
63
|
const entries = Object.entries(conditionObject);
|
|
@@ -45,248 +70,170 @@ export const buildWhereParam = ({ query, slug, db, locale, tables, configCtx, ba
|
|
|
45
70
|
.map(([operator, value]) => buildCondition({ [key]: { [operator]: value } }))
|
|
46
71
|
.filter(Boolean));
|
|
47
72
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return
|
|
102
|
-
.select({ ownerId: tableLocales.ownerId })
|
|
103
|
-
.from(tableLocales)
|
|
104
|
-
.where(compare(tableLocales[sqlColumn]))), compare(resolved, tableLocales[sqlColumn]));
|
|
105
|
-
}
|
|
106
|
-
// A column the base row keeps — the hierarchy columns, and any `$root()` field — reached
|
|
107
|
-
// through `ownerId` when the table queried is the versions table.
|
|
108
|
-
if (baseTable && baseColumns.includes(sqlColumn)) {
|
|
109
|
-
return inArray(table.ownerId, db.select({ ownerId: baseTable.id }).from(baseTable).where(compare(baseTable[sqlColumn])));
|
|
73
|
+
if (Array.isArray(conditionObject.and))
|
|
74
|
+
return combine(and, conditionObject.and);
|
|
75
|
+
if (Array.isArray(conditionObject.or))
|
|
76
|
+
return combine(or, conditionObject.or);
|
|
77
|
+
const condition = getConditionMembers(normalizedForShadow(conditionObject, isShadow));
|
|
78
|
+
return (pathsCondition(condition) ??
|
|
79
|
+
columnCondition(condition) ??
|
|
80
|
+
localizedCondition(condition) ??
|
|
81
|
+
baseColumnCondition(condition) ??
|
|
82
|
+
relationCondition(condition));
|
|
83
|
+
};
|
|
84
|
+
/** `join` of the conditions of a list; `false` when none is left. */
|
|
85
|
+
const combine = (join, list) => {
|
|
86
|
+
const conditions = list.map((condition) => buildCondition(condition)).filter(Boolean);
|
|
87
|
+
return conditions.length ? join(...conditions) : false;
|
|
88
|
+
};
|
|
89
|
+
/** A condition no row meets, with the reason in the log. */
|
|
90
|
+
const matchNothing = (reason) => {
|
|
91
|
+
logger.warn(reason);
|
|
92
|
+
return eq(table.id, '-1');
|
|
93
|
+
};
|
|
94
|
+
// Each kind of path below answers a condition, or `undefined` for a path of another kind.
|
|
95
|
+
/**
|
|
96
|
+
* `url` or `_urlPath` of a collection with `$url`: its pages found by url or by path through
|
|
97
|
+
* its paths table, in the locale read. A versions table is matched through its `ownerId`, like
|
|
98
|
+
* any base-row filter.
|
|
99
|
+
*/
|
|
100
|
+
const pathsCondition = ({ column, compare }) => {
|
|
101
|
+
if (!pathsTable || (column !== 'url' && column !== '_urlPath'))
|
|
102
|
+
return undefined;
|
|
103
|
+
const owners = db
|
|
104
|
+
.select({ id: pathsTable.ownerId })
|
|
105
|
+
.from(pathsTable)
|
|
106
|
+
.where(and(eq(pathsTable.locale, locale ?? ''), compare(column === 'url' ? pathsTable.url : pathsTable.path)));
|
|
107
|
+
return inArray(isShadow ? table.ownerId : table.id, owners);
|
|
108
|
+
};
|
|
109
|
+
/** A column of the table itself. */
|
|
110
|
+
const columnCondition = ({ sqlColumn, compare }) => unlocalizedColumns.includes(sqlColumn) ? compare(table[sqlColumn]) : undefined;
|
|
111
|
+
/**
|
|
112
|
+
* A localized column, compared as a read would show it: the first locale in the fallback order
|
|
113
|
+
* that holds a value, `''` counting as none — so a page found by its slug in one locale is found
|
|
114
|
+
* by the same slug in a locale it was not translated to yet.
|
|
115
|
+
*/
|
|
116
|
+
const localizedCondition = ({ sqlColumn, operator, compare }) => {
|
|
117
|
+
if (!locale || !localizedColumns.includes(sqlColumn))
|
|
118
|
+
return undefined;
|
|
119
|
+
const { sql } = drizzleORM;
|
|
120
|
+
const order = localeOrder(configCtx, locale) ?? [locale];
|
|
121
|
+
const valueIn = (code) => sql `NULLIF((SELECT ${tableLocales[sqlColumn]} FROM ${tableLocales} WHERE ${tableLocales.ownerId} = ${table.id} AND ${tableLocales.locale} = ${code}), '')`;
|
|
122
|
+
const resolved = order.length > 1
|
|
123
|
+
? sql `COALESCE(${sql.join(order.map(valueIn), sql `, `)})`
|
|
124
|
+
: valueIn(order[0]);
|
|
125
|
+
if (operator !== 'equals' && operator !== 'in_array') {
|
|
126
|
+
return compare(resolved, tableLocales[sqlColumn]);
|
|
110
127
|
}
|
|
111
|
-
//
|
|
112
|
-
//
|
|
128
|
+
// A document whose read value matches has a locales row holding it, so the documents with
|
|
129
|
+
// one are asked first: that is what an index on the column answers, and the comparison
|
|
130
|
+
// above then runs on those alone.
|
|
131
|
+
return and(inArray(table.id, db
|
|
132
|
+
.select({ ownerId: tableLocales.ownerId })
|
|
133
|
+
.from(tableLocales)
|
|
134
|
+
.where(compare(tableLocales[sqlColumn]))), compare(resolved, tableLocales[sqlColumn]));
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* A column the base row keeps — the hierarchy columns, and any `$root()` field — reached
|
|
138
|
+
* through `ownerId` when the table queried is the versions table.
|
|
139
|
+
*/
|
|
140
|
+
const baseColumnCondition = ({ sqlColumn, compare }) => {
|
|
141
|
+
if (!baseTable || !baseColumns.includes(sqlColumn))
|
|
142
|
+
return undefined;
|
|
143
|
+
return inArray(table.ownerId, db.select({ ownerId: baseTable.id }).from(baseTable).where(compare(baseTable[sqlColumn])));
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* A relation field, `author`, or a field of the documents it points at, `author.name`. Any
|
|
147
|
+
* other path matches nothing, and so does an operator a relation with many values cannot answer.
|
|
148
|
+
*/
|
|
149
|
+
const relationCondition = (condition) => {
|
|
150
|
+
const { column, operator, rawValue, value, compare } = condition;
|
|
113
151
|
const documentConfig = configCtx.getBySlug(slug);
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
let relationPropertyPath = null;
|
|
118
|
-
let isRelationProperty = false;
|
|
119
|
-
// If the exact path isn't found, try progressively shorter prefixes to support
|
|
120
|
-
// relation property queries like `attributes.author.name` -> `attributes.author`
|
|
121
|
-
if (!fieldConfig) {
|
|
122
|
-
const parts = column.split('.');
|
|
123
|
-
for (let i = parts.length - 1; i > 0; i--) {
|
|
124
|
-
const prefix = parts.slice(0, i).join('.');
|
|
125
|
-
const candidate = getFieldAtPath(prefix, documentConfig.fields);
|
|
126
|
-
if (candidate) {
|
|
127
|
-
fieldConfig = candidate;
|
|
128
|
-
matchedPrefix = prefix;
|
|
129
|
-
relationPropertyPath = parts.slice(i).join('.');
|
|
130
|
-
isRelationProperty = true;
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
152
|
+
const { field, path, property } = fieldAtPrefix(column, documentConfig.fields);
|
|
153
|
+
if (!isRelationField(field)) {
|
|
154
|
+
return matchNothing(`the query contains the field "${column}", not found for ${documentConfig.slug} document`);
|
|
134
155
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return eq(table.id, '-1');
|
|
142
|
-
}
|
|
143
|
-
// Helper: normalize various input forms (rawValue, CSV string, or formatted array)
|
|
144
|
-
// into a unique array of values used for multi-valued relation comparisons.
|
|
145
|
-
const normalizeValues = (raw, formatted) => {
|
|
146
|
-
let out;
|
|
147
|
-
if (Array.isArray(raw))
|
|
148
|
-
out = raw;
|
|
149
|
-
else if (typeof raw === 'string' && raw.includes(','))
|
|
150
|
-
out = raw.split(',');
|
|
151
|
-
else if (Array.isArray(formatted))
|
|
152
|
-
out = formatted;
|
|
153
|
-
else
|
|
154
|
-
out = [formatted];
|
|
155
|
-
return Array.from(new Set(out));
|
|
156
|
-
};
|
|
157
|
-
// Handle relation property queries (e.g., attributes.author.name)
|
|
158
|
-
// by building a subquery on the related collection
|
|
159
|
-
const buildRelationPropertyCondition = () => {
|
|
160
|
-
const relatedSlug = fieldConfig.get.relationTo;
|
|
161
|
-
// A versioned target keeps its fields on its versions table: match a version, answer its
|
|
162
|
-
// document. A document matches when any of its versions holds the value, a draft included.
|
|
163
|
-
const versions = configCtx.getBySlug(relatedSlug)._versions;
|
|
164
|
-
const searched = versions ? versions.slug : relatedSlug;
|
|
165
|
-
const searchedTable = getTable(baseTableName(searched));
|
|
166
|
-
// Build a where clause for the related collection using the same operator/value
|
|
167
|
-
const relatedWhere = { [relationPropertyPath]: { [operator]: rawValue } };
|
|
168
|
-
// Recursive call to buildWhereParam for the related collection
|
|
169
|
-
const relatedCondition = buildWhereParam({
|
|
170
|
-
query: { where: relatedWhere },
|
|
171
|
-
slug: searched,
|
|
172
|
-
base: versions ? relatedSlug : undefined,
|
|
173
|
-
db,
|
|
174
|
-
locale,
|
|
175
|
-
tables,
|
|
176
|
-
configCtx
|
|
177
|
-
});
|
|
178
|
-
// Subquery of related document ids that match the property condition
|
|
179
|
-
const matchingRelatedIds = db
|
|
180
|
-
.select({ id: versions ? searchedTable.ownerId : searchedTable.id })
|
|
181
|
-
.from(searchedTable)
|
|
182
|
-
.where(relatedCondition);
|
|
183
|
-
const relsTable = getTable(tableName({ owner: baseTableName(slug), child: { kind: 'rels' } }));
|
|
184
|
-
// Join relation rows to documents by matching the related id and the relation path
|
|
185
|
-
const ownersWithMatching = db
|
|
156
|
+
if (property)
|
|
157
|
+
return relationPropertyCondition(field, path, property, condition);
|
|
158
|
+
const rows = junctionRows(column, !!field.get.localized);
|
|
159
|
+
const target = relsTable[junctionKey(field.get.relationTo)];
|
|
160
|
+
if (!field.get.many) {
|
|
161
|
+
return inArray(table.id, db
|
|
186
162
|
.select({ id: relsTable.ownerId })
|
|
187
163
|
.from(relsTable)
|
|
188
|
-
.where(and(
|
|
189
|
-
return inArray(table.id, ownersWithMatching);
|
|
190
|
-
};
|
|
191
|
-
// If this is a relation property query, delegate to the relation property handler
|
|
192
|
-
if (isRelationProperty && relationPropertyPath) {
|
|
193
|
-
return buildRelationPropertyCondition();
|
|
194
|
-
}
|
|
195
|
-
// Handle direct relation field queries (e.g., attributes.author)
|
|
196
|
-
// only support a subset of operators for multi-valued relations
|
|
197
|
-
const supportedRelationManyOperators = ['equals', 'not_equals', 'in_array', 'not_in_array'];
|
|
198
|
-
if (fieldConfig.get.many && !supportedRelationManyOperators.includes(operator)) {
|
|
199
|
-
const unsupportedMessage = `the operator "${operator}" is not supported for multi-valued relation field "${column}" in ${documentConfig.slug} document`;
|
|
200
|
-
logger.warn(unsupportedMessage);
|
|
201
|
-
// Return a condition that will always be false
|
|
202
|
-
return eq(table.id, '-1');
|
|
203
|
-
}
|
|
204
|
-
// Build relation condition
|
|
205
|
-
const [to, localized, many] = [
|
|
206
|
-
fieldConfig.get.relationTo,
|
|
207
|
-
fieldConfig.get.localized,
|
|
208
|
-
fieldConfig.get.many
|
|
209
|
-
];
|
|
210
|
-
const relsTableName = tableName({ owner: baseTableName(slug), child: { kind: 'rels' } });
|
|
211
|
-
const relsTable = getTable(relsTableName);
|
|
212
|
-
// Helpers for building common relation-owner subqueries (operate on the relations table)
|
|
213
|
-
const buildOwnersWithTotalCount = (count) => db
|
|
214
|
-
.select({ id: relsTable.ownerId })
|
|
215
|
-
.from(relsTable)
|
|
216
|
-
.where(and(eq(relsTable.path, column), ...(localized ? [eq(relsTable.locale, locale)] : [])))
|
|
217
|
-
.groupBy(relsTable.ownerId)
|
|
218
|
-
.having(drizzleORM.eq(drizzleORM.count(relsTable.id), count));
|
|
219
|
-
// Owners that have total relation count equal to the number of provided values
|
|
220
|
-
const buildOwnersWithMatchingCount = (values) => db
|
|
221
|
-
.select({ id: relsTable.ownerId })
|
|
222
|
-
.from(relsTable)
|
|
223
|
-
.where(and(drizzleORM.inArray(relsTable[junctionKey(to)], values), eq(relsTable.path, column), ...(localized ? [eq(relsTable.locale, locale)] : [])))
|
|
224
|
-
.groupBy(relsTable.ownerId)
|
|
225
|
-
.having(drizzleORM.eq(drizzleORM.count(relsTable.id), values.length));
|
|
226
|
-
// Owners that have at least one relation row NOT in the provided values
|
|
227
|
-
const buildOwnersWithNonMatching = (values) => db
|
|
228
|
-
.select({ id: relsTable.ownerId })
|
|
229
|
-
.from(relsTable)
|
|
230
|
-
.where(and(drizzleORM.notInArray(relsTable[junctionKey(to)], values), eq(relsTable.path, column), ...(localized ? [eq(relsTable.locale, locale)] : [])))
|
|
231
|
-
.groupBy(relsTable.ownerId)
|
|
232
|
-
.having(drizzleORM.gt(drizzleORM.count(relsTable.id), 0));
|
|
233
|
-
// Owners that have any relation rows (to exclude docs with no relations)
|
|
234
|
-
const buildOwnersWithRelations = () => db
|
|
235
|
-
.select({ id: relsTable.ownerId })
|
|
236
|
-
.from(relsTable)
|
|
237
|
-
.where(and(eq(relsTable.path, column), ...(localized ? [eq(relsTable.locale, locale)] : [])))
|
|
238
|
-
.groupBy(relsTable.ownerId)
|
|
239
|
-
.having(drizzleORM.gt(drizzleORM.count(relsTable.id), 0));
|
|
240
|
-
// Handle multi-valued relations specially when operator is `equals` to provide
|
|
241
|
-
// strict equality semantics (the relation set must equal the provided value(s)).
|
|
242
|
-
if (many && operator === 'equals') {
|
|
243
|
-
// Accept various input forms and normalize to a unique array
|
|
244
|
-
const values = normalizeValues(rawValue, value);
|
|
245
|
-
// Owners with total relation count equal to values.length
|
|
246
|
-
const ownersWithTotalCount = buildOwnersWithTotalCount(values.length);
|
|
247
|
-
// Owners with matching relations count equal to values.length
|
|
248
|
-
const ownersWithMatchingCount = buildOwnersWithMatchingCount(values);
|
|
249
|
-
return and(inArray(table.id, ownersWithTotalCount), inArray(table.id, ownersWithMatchingCount));
|
|
250
|
-
}
|
|
251
|
-
// For multi-valued relations, allow `in_array` to act as a subset check:
|
|
252
|
-
// The provided values must contain ALL relation values of the document.
|
|
253
|
-
if (many && operator === 'in_array') {
|
|
254
|
-
// Accept various input forms and normalize to a unique array
|
|
255
|
-
const values = normalizeValues(rawValue, value);
|
|
256
|
-
// Owners that have at least one relation row not included in the provided set
|
|
257
|
-
const ownersWithNonMatching = buildOwnersWithNonMatching(values);
|
|
258
|
-
// Owners that have any relation rows (to exclude docs with no relations)
|
|
259
|
-
const ownersWithRelations = buildOwnersWithRelations();
|
|
260
|
-
// Match documents that have relations and do NOT have any non-matching relation rows
|
|
261
|
-
return and(drizzleORM.notInArray(table.id, ownersWithNonMatching), inArray(table.id, ownersWithRelations));
|
|
262
|
-
}
|
|
263
|
-
// For multi-valued relations, `not_in_array` should match documents where the provided
|
|
264
|
-
// set does NOT contain all of the document's relation values (inverse of `in_array`).
|
|
265
|
-
if (many && operator === 'not_in_array') {
|
|
266
|
-
// Accept various input forms and normalize to a unique array
|
|
267
|
-
const values = normalizeValues(rawValue, value);
|
|
268
|
-
const ownersWithNonMatching = buildOwnersWithNonMatching(values);
|
|
269
|
-
return inArray(table.id, ownersWithNonMatching);
|
|
164
|
+
.where(and(...rows, compare(target))));
|
|
270
165
|
}
|
|
271
|
-
|
|
272
|
-
if (
|
|
273
|
-
|
|
274
|
-
const values = normalizeValues(rawValue, value);
|
|
275
|
-
const ownersWithTotalCount = buildOwnersWithTotalCount(values.length);
|
|
276
|
-
const ownersWithMatchingCount = buildOwnersWithMatchingCount(values);
|
|
277
|
-
return or(drizzleORM.notInArray(table.id, ownersWithTotalCount), drizzleORM.notInArray(table.id, ownersWithMatchingCount));
|
|
166
|
+
const set = relationSets[operator];
|
|
167
|
+
if (!set) {
|
|
168
|
+
return matchNothing(`the operator "${operator}" is not supported for multi-valued relation field "${column}" in ${documentConfig.slug} document`);
|
|
278
169
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
170
|
+
return set(rows, target, normalizeValues(rawValue, value));
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* `property` of the documents the relation at `path` points at, with the condition's operator
|
|
174
|
+
* and value. A versioned target keeps its fields on its versions table: a version is matched
|
|
175
|
+
* and its document answered, so a document matches when any of its versions holds the value,
|
|
176
|
+
* a draft included.
|
|
177
|
+
*/
|
|
178
|
+
const relationPropertyCondition = (relation, path, property, { operator, rawValue }) => {
|
|
179
|
+
const relatedSlug = relation.get.relationTo;
|
|
180
|
+
const versions = configCtx.getBySlug(relatedSlug)._versions;
|
|
181
|
+
const searched = versions ? versions.slug : relatedSlug;
|
|
182
|
+
const searchedTable = getTable(baseTableName(searched));
|
|
183
|
+
const relatedCondition = buildWhereParam({
|
|
184
|
+
query: { where: { [property]: { [operator]: rawValue } } },
|
|
185
|
+
slug: searched,
|
|
186
|
+
base: versions ? relatedSlug : undefined,
|
|
187
|
+
db,
|
|
188
|
+
locale,
|
|
189
|
+
tables,
|
|
190
|
+
configCtx
|
|
191
|
+
});
|
|
192
|
+
const matchingIds = db
|
|
193
|
+
.select({ id: versions ? searchedTable.ownerId : searchedTable.id })
|
|
194
|
+
.from(searchedTable)
|
|
195
|
+
.where(relatedCondition);
|
|
196
|
+
const owners = db
|
|
287
197
|
.select({ id: relsTable.ownerId })
|
|
288
198
|
.from(relsTable)
|
|
289
|
-
.where(and(...
|
|
199
|
+
.where(and(inArray(relsTable[junctionKey(relatedSlug)], matchingIds), ...junctionRows(path, !!relation.get.localized)));
|
|
200
|
+
return inArray(table.id, owners);
|
|
201
|
+
};
|
|
202
|
+
/** The junction rows of the relation at `path`, those of the locale read when it is localized. */
|
|
203
|
+
const junctionRows = (path, localized) => [
|
|
204
|
+
eq(relsTable.path, path),
|
|
205
|
+
...(localized ? [eq(relsTable.locale, locale)] : [])
|
|
206
|
+
];
|
|
207
|
+
/** The documents with exactly `count` of the junction rows `where` picks. */
|
|
208
|
+
const ownersWithCount = (where, count) => db
|
|
209
|
+
.select({ id: relsTable.ownerId })
|
|
210
|
+
.from(relsTable)
|
|
211
|
+
.where(and(...where))
|
|
212
|
+
.groupBy(relsTable.ownerId)
|
|
213
|
+
.having(eq(drizzleORM.count(relsTable.id), count));
|
|
214
|
+
/** The documents with at least one of the junction rows `where` picks. */
|
|
215
|
+
const ownersWithAny = (where) => db
|
|
216
|
+
.select({ id: relsTable.ownerId })
|
|
217
|
+
.from(relsTable)
|
|
218
|
+
.where(and(...where))
|
|
219
|
+
.groupBy(relsTable.ownerId)
|
|
220
|
+
.having(drizzleORM.gt(drizzleORM.count(relsTable.id), 0));
|
|
221
|
+
/**
|
|
222
|
+
* A relation with many values compared as a set, by operator. `rows` picks its junction rows,
|
|
223
|
+
* `target` is their column of related ids, and `values` the ids sent.
|
|
224
|
+
*
|
|
225
|
+
* ```
|
|
226
|
+
* equals the same set, in any order
|
|
227
|
+
* not_equals any other set, an empty one included
|
|
228
|
+
* in_array a set inside the list, and not an empty one
|
|
229
|
+
* not_in_array a set with a value outside the list
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
const relationSets = {
|
|
233
|
+
equals: (rows, target, values) => and(inArray(table.id, ownersWithCount(rows, values.length)), inArray(table.id, ownersWithCount([inArray(target, values), ...rows], values.length))),
|
|
234
|
+
not_equals: (rows, target, values) => or(notInArray(table.id, ownersWithCount(rows, values.length)), notInArray(table.id, ownersWithCount([inArray(target, values), ...rows], values.length))),
|
|
235
|
+
in_array: (rows, target, values) => and(notInArray(table.id, ownersWithAny([notInArray(target, values), ...rows])), inArray(table.id, ownersWithAny(rows))),
|
|
236
|
+
not_in_array: (rows, target, values) => inArray(table.id, ownersWithAny([notInArray(target, values), ...rows]))
|
|
290
237
|
};
|
|
291
238
|
return buildCondition(query.where);
|
|
292
239
|
};
|
|
@@ -367,7 +314,11 @@ const castTo = (column, value) => {
|
|
|
367
314
|
}
|
|
368
315
|
return value;
|
|
369
316
|
};
|
|
370
|
-
|
|
317
|
+
/**
|
|
318
|
+
* The column, operator and value of a `{ path: { operator: value } }` condition, and `compare`,
|
|
319
|
+
* its operator on a column. Only the first key, and the first operator, are read. An unknown
|
|
320
|
+
* operator throws.
|
|
321
|
+
*/
|
|
371
322
|
function getConditionMembers(obj) {
|
|
372
323
|
const [column, operatorObj] = Object.entries(obj)[0];
|
|
373
324
|
const [operator, rawValue] = Object.entries(operatorObj)[0];
|
|
@@ -379,7 +330,57 @@ function getConditionMembers(obj) {
|
|
|
379
330
|
const sqlColumn = pathToDatabaseColumn(column);
|
|
380
331
|
// Shaped for its operator: a list, two bounds or a pattern
|
|
381
332
|
const value = formatValue({ operator, value: rawValue });
|
|
382
|
-
|
|
333
|
+
/**
|
|
334
|
+
* The operator on `column`, the value cast for `cast` (the column itself, unless it is an
|
|
335
|
+
* expression). A `like` pattern is text whatever the column, and is never cast.
|
|
336
|
+
*/
|
|
337
|
+
const compare = (column, cast = column) => fn(column, LIKE_OPERATORS.includes(operator) ? value : castTo(cast, value));
|
|
338
|
+
return { column, sqlColumn, operator, rawValue, value, compare };
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* The field at `path`, or else the field at its longest prefix and the rest of the path, a field
|
|
342
|
+
* of the related document.
|
|
343
|
+
*
|
|
344
|
+
* ```ts
|
|
345
|
+
* fieldAtPrefix('attributes.author.name', fields)
|
|
346
|
+
* // { field: <attributes.author>, path: 'attributes.author', property: 'name' }
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
function fieldAtPrefix(path, fields) {
|
|
350
|
+
const field = getFieldAtPath(path, fields);
|
|
351
|
+
if (field)
|
|
352
|
+
return { field, path, property: '' };
|
|
353
|
+
const parts = path.split('.');
|
|
354
|
+
for (let i = parts.length - 1; i > 0; i--) {
|
|
355
|
+
const prefix = parts.slice(0, i).join('.');
|
|
356
|
+
const candidate = getFieldAtPath(prefix, fields);
|
|
357
|
+
if (candidate)
|
|
358
|
+
return { field: candidate, path: prefix, property: parts.slice(i).join('.') };
|
|
359
|
+
}
|
|
360
|
+
return { field: undefined, path, property: '' };
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* The ids a relation set is compared with, each once: the list sent, a CSV string, or one id.
|
|
364
|
+
*
|
|
365
|
+
* ```ts
|
|
366
|
+
* normalizeValues('a,b,a', ['a', 'b', 'a']) // ['a', 'b']
|
|
367
|
+
* ```
|
|
368
|
+
*/
|
|
369
|
+
function normalizeValues(raw, formatted) {
|
|
370
|
+
let out;
|
|
371
|
+
if (Array.isArray(raw)) {
|
|
372
|
+
out = raw;
|
|
373
|
+
}
|
|
374
|
+
else if (typeof raw === 'string' && raw.includes(',')) {
|
|
375
|
+
out = raw.split(',');
|
|
376
|
+
}
|
|
377
|
+
else if (Array.isArray(formatted)) {
|
|
378
|
+
out = formatted;
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
out = [formatted];
|
|
382
|
+
}
|
|
383
|
+
return Array.from(new Set(out));
|
|
383
384
|
}
|
|
384
385
|
/**
|
|
385
386
|
* The condition as a versions table reads it, as a new object: `id` names the document, which is
|
|
@@ -71,6 +71,11 @@ export declare const insertPrototype: ({ db, tables }: Deps, { slug, data, conte
|
|
|
71
71
|
id: string;
|
|
72
72
|
contentId: string;
|
|
73
73
|
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Deletes the document's base row by id and answers the id. Its blocks, tree rows, junction rows,
|
|
76
|
+
* locales rows, addresses and versions go with it through `ON DELETE CASCADE`, which needs
|
|
77
|
+
* foreign keys on (connect.server.ts). Throws NOT_FOUND when no row has that id.
|
|
78
|
+
*/
|
|
74
79
|
export declare const deletePrototype: ({ db, tables }: Deps, { slug, id }: {
|
|
75
80
|
slug: string;
|
|
76
81
|
id: string;
|
|
@@ -26,7 +26,7 @@ const insertRowWithLocales = async ({ db, tables }, args) => {
|
|
|
26
26
|
});
|
|
27
27
|
// A locales row says the locale was written. With nothing to say there is no row, and the
|
|
28
28
|
// first write in that locale makes one — the same for a document and for a singleton's
|
|
29
|
-
// bootstrap
|
|
29
|
+
// bootstrap. An `id` is not a value.
|
|
30
30
|
const { data, isLocalized, locale } = args.localized;
|
|
31
31
|
const written = Object.entries(data).some(([key, value]) => key !== 'id' && value !== null && value !== undefined);
|
|
32
32
|
if (isLocalized && written) {
|
|
@@ -191,10 +191,14 @@ export const insertPrototype = async ({ db, tables }, { slug, data, content, loc
|
|
|
191
191
|
now,
|
|
192
192
|
localized: { data: localizedData, isLocalized, locale }
|
|
193
193
|
});
|
|
194
|
-
// No
|
|
195
|
-
// No versions: the content is on the base row, so that is the row children hang off.
|
|
194
|
+
// No versions: the content is on the base row, the one children hang off.
|
|
196
195
|
return { id: docId, contentId: docId };
|
|
197
196
|
};
|
|
197
|
+
/**
|
|
198
|
+
* Deletes the document's base row by id and answers the id. Its blocks, tree rows, junction rows,
|
|
199
|
+
* locales rows, addresses and versions go with it through `ON DELETE CASCADE`, which needs
|
|
200
|
+
* foreign keys on (connect.server.ts). Throws NOT_FOUND when no row has that id.
|
|
201
|
+
*/
|
|
198
202
|
export const deletePrototype = async ({ db, tables }, { slug, id }) => {
|
|
199
203
|
const table = tables[baseTableName(slug)];
|
|
200
204
|
const docs = await db.delete(table).where(eq(table.id, id)).returning();
|
|
@@ -226,8 +230,7 @@ export const ensurePrototypeExists = async ({ db, tables }, { slug, initial, loc
|
|
|
226
230
|
tables,
|
|
227
231
|
mainTableName: contentTable,
|
|
228
232
|
localesTableName: tableName({ owner: contentTable, branch: 'locales' }),
|
|
229
|
-
locale
|
|
230
|
-
fillNotNull: true
|
|
233
|
+
locale
|
|
231
234
|
});
|
|
232
235
|
const contentId = await insertRowWithLocales({ db, tables }, {
|
|
233
236
|
table: contentTable,
|
|
@@ -242,8 +245,7 @@ export const ensurePrototypeExists = async ({ db, tables }, { slug, initial, loc
|
|
|
242
245
|
tables,
|
|
243
246
|
mainTableName: table,
|
|
244
247
|
localesTableName: localesTable,
|
|
245
|
-
locale
|
|
246
|
-
fillNotNull: true
|
|
248
|
+
locale
|
|
247
249
|
});
|
|
248
250
|
const contentId = await insertRowWithLocales({ db, tables }, {
|
|
249
251
|
table,
|