rimecms 1.2.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/constant.d.ts +16 -0
- package/dist/adapter-sqlite/constant.js +16 -0
- package/dist/adapter-sqlite/db-move.server.d.ts +31 -0
- package/dist/adapter-sqlite/db-move.server.js +102 -0
- package/dist/adapter-sqlite/drizzle-config.server.d.ts +9 -0
- package/dist/adapter-sqlite/drizzle-config.server.js +39 -0
- 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 +13 -3
- package/dist/adapter-sqlite/hooks.server.d.ts +3 -0
- package/dist/adapter-sqlite/hooks.server.js +64 -0
- package/dist/adapter-sqlite/index.server.d.ts +9 -1
- package/dist/adapter-sqlite/index.server.js +23 -2
- 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 +63 -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 +9 -7
- package/dist/core/auth/better-auth-tables.server.js +9 -7
- 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 +37 -15
- 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/user.server.d.ts +8 -3
- package/dist/core/auth/user.server.js +8 -3
- 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/boot.server.js +7 -2
- package/dist/core/codegen.server.d.ts +2 -3
- package/dist/core/codegen.server.js +18 -16
- 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 +17 -6
- 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 +7 -2
- package/dist/core/dev/cli/commands/build.js +38 -12
- package/dist/core/dev/cli/commands/clear.server.d.ts +6 -0
- package/dist/core/dev/cli/commands/clear.server.js +20 -6
- 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 +10 -1
- package/dist/core/dev/cli/commands/init.server.js +45 -53
- package/dist/core/dev/cli/commands/uploads-move.server.js +3 -0
- package/dist/core/dev/cli/index.js +34 -16
- 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 +7 -10
- package/dist/core/dev/cli/templates/init.js +22 -47
- package/dist/core/dev/cli/util/adapter-hooks.server.d.ts +15 -0
- package/dist/core/dev/cli/util/adapter-hooks.server.js +17 -0
- package/dist/core/dev/cli/util/package-manager.server.d.ts +10 -1
- package/dist/core/dev/cli/util/package-manager.server.js +21 -19
- 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/deny-storage.server.d.ts +2 -2
- package/dist/core/dev/deny-storage.server.js +2 -2
- package/dist/core/dev/ensure.server.d.ts +5 -0
- package/dist/core/dev/ensure.server.js +9 -22
- 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 +21 -5
- 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/DashboardRow.svelte +13 -0
- 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 +3 -3
- package/dist/panel/style/index.css +23 -8
- 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 +17 -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
|
@@ -3,12 +3,16 @@ import { isStaff } from '../../auth/access.js';
|
|
|
3
3
|
import { PARAMS } from '../../constants.js';
|
|
4
4
|
import { RimeError, RimeFormError } from '../../errors/index.js';
|
|
5
5
|
import { logger } from '../../logger.server.js';
|
|
6
|
+
import { VERSIONS_STATUS } from '../../prototype/shared/versions/constant.js';
|
|
6
7
|
import { missingRelations } from '../../../fields/relation/exists.server.js';
|
|
7
8
|
import { isRelationField } from '../../../fields/relation/index.js';
|
|
8
9
|
import { isFormField } from '../../fields/util.js';
|
|
9
|
-
import { walkFields } from '../../fields/walk.js';
|
|
10
|
-
import { deleteValueAtPath, getValueAtPath, isObjectLiteral, setValueAtPath } from '../../../util/object.js';
|
|
10
|
+
import { walkFields, walkValues } from '../../fields/walk.js';
|
|
11
|
+
import { deleteValueAtPath, getValueAtPath, isObjectLiteral, setValueAtPath, withDefaultValues } from '../../../util/object.js';
|
|
11
12
|
import { isWithin } from '../../../util/string.js';
|
|
13
|
+
import { buildConfigMap } from '../config-map/index.js';
|
|
14
|
+
import { fallbackDataFromOriginal } from '../fallback-data-from-original.js';
|
|
15
|
+
import { isSaved } from '../persist/repeatable.server.js';
|
|
12
16
|
import { withoutDeniedFields } from '../without-denied-fields.js';
|
|
13
17
|
/**
|
|
14
18
|
* Checks each field's write access, then runs its `validate`, checks that each relation names
|
|
@@ -16,13 +20,27 @@ import { withoutDeniedFields } from '../without-denied-fields.js';
|
|
|
16
20
|
*
|
|
17
21
|
* A field the caller may not write is deleted from **both** the data and `context.configMap`,
|
|
18
22
|
* with every field below it. Leaving its path in the map would make the dropped write look like an
|
|
19
|
-
* explicit "nothing here any more" and delete the existing rows.
|
|
23
|
+
* explicit "nothing here any more" and delete the existing rows. On a create, such a field that
|
|
24
|
+
* has a default is stored with it instead, unchecked, and a required one without a default
|
|
25
|
+
* refuses the create with a 403.
|
|
20
26
|
*
|
|
21
27
|
* ```ts
|
|
22
28
|
* // group('meta').access({ update: isAdmin }).fields(blocks('gallery', [image]))
|
|
23
29
|
* // an editor: PATCH { meta: { gallery: [] } } -> data {}, configMap {}: the gallery stays
|
|
24
30
|
* ```
|
|
25
31
|
*
|
|
32
|
+
* An update is checked as the document it leaves: `validate` reads that document, and `required`
|
|
33
|
+
* holds on it, sent value or stored. Only the sent values run their hooks.
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* // text('title').required(), text('summary').required(), stored { title: 'Home', summary: '' }
|
|
37
|
+
* // PATCH { title: 'Home 2' } -> summary: required_field
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* A unique value may be shared by a document and its own versions only. On a config with drafts,
|
|
41
|
+
* the other documents count by their published version, so a publish checks every unique value
|
|
42
|
+
* of the version it puts live, sent or not.
|
|
43
|
+
*
|
|
26
44
|
* A staff request with `?skipValidation=true` may leave required fields empty; a locale copy
|
|
27
45
|
* (`context.isLocaleCopy`) skips every check, its values were validated where they came from.
|
|
28
46
|
*/
|
|
@@ -32,7 +50,6 @@ export const validateFields = Hooks.beforeUpsert(async function validateFields(a
|
|
|
32
50
|
const { rime, user } = event.locals;
|
|
33
51
|
const locale = args.context.params.locale || args.event.locals.locale;
|
|
34
52
|
const slug = args.config.slug;
|
|
35
|
-
const isCollection = rime.config.isCollection(slug);
|
|
36
53
|
// The panel's bulk upload sends a file before its other fields: a staff request may leave
|
|
37
54
|
// required fields empty with ?skipValidation=true
|
|
38
55
|
const mayLeaveRequired = isStaff(user) && event.url.searchParams.get(PARAMS.SKIP_VALIDATION) === 'true';
|
|
@@ -45,16 +62,16 @@ export const validateFields = Hooks.beforeUpsert(async function validateFields(a
|
|
|
45
62
|
/****************************************************/
|
|
46
63
|
/* Access
|
|
47
64
|
/****************************************************/
|
|
48
|
-
// A denied field leaves the data, and the map with every key below it. It is never validated
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
//
|
|
65
|
+
// A denied field leaves the data, and the map with every key below it. It is never validated.
|
|
66
|
+
// A create writes its default, or leaves its column empty without one; an update leaves the
|
|
67
|
+
// stored column as it is. Inside a stored list row, an update writes back the stored value
|
|
68
|
+
// instead, unchecked.
|
|
52
69
|
//
|
|
53
70
|
// FormFieldBuilder's default `access.create` is `(user) => !!user`, so an anonymous create is
|
|
54
71
|
// denied most fields.
|
|
55
72
|
const { originalDoc, originalConfigMap } = args.context;
|
|
56
73
|
const allowed = skipAccess
|
|
57
|
-
? { data: args.data, configMap: { ...args.context.configMap }, kept: [] }
|
|
74
|
+
? { data: args.data, configMap: { ...args.context.configMap }, kept: [], missing: [] }
|
|
58
75
|
: withoutDeniedFields({
|
|
59
76
|
data: args.data,
|
|
60
77
|
configMap: args.context.configMap ?? {},
|
|
@@ -63,12 +80,55 @@ export const validateFields = Hooks.beforeUpsert(async function validateFields(a
|
|
|
63
80
|
id: originalDoc?.id,
|
|
64
81
|
stored: operation === 'update' && originalDoc && originalConfigMap
|
|
65
82
|
? { doc: originalDoc, configMap: originalConfigMap }
|
|
66
|
-
: undefined
|
|
83
|
+
: undefined,
|
|
84
|
+
event
|
|
67
85
|
});
|
|
86
|
+
// A create that leaves a required field it may not write empty, without a default, is refused
|
|
87
|
+
if (allowed.missing.length && !skipRequired) {
|
|
88
|
+
const paths = allowed.missing.map((path) => `\`${path}\``).join(', ');
|
|
89
|
+
logger.warn(`${slug}: a create was refused, ${paths} is required, has no default and is closed to this caller. Give it a defaultValue or open its access.create.`);
|
|
90
|
+
throw new RimeError(RimeError.UNAUTHORIZED, `may not create: ${paths} is required and closed to you`);
|
|
91
|
+
}
|
|
68
92
|
// Own copy: the steps below write into it
|
|
69
93
|
let output = { ...allowed.data };
|
|
70
94
|
const configMap = allowed.configMap;
|
|
95
|
+
// A versions collection holds the versions of a collection's documents: a unique value is looked
|
|
96
|
+
// up on that collection, which reads each document's published version (its newest without
|
|
97
|
+
// drafts). The document this save writes is left out: the one updated, or the owner of a new
|
|
98
|
+
// version row. A create has none yet.
|
|
99
|
+
//
|
|
100
|
+
// `$pages__versions` create { slug: 'about', ownerId: 'p1' }
|
|
101
|
+
// -> pages where slug = 'about' and id != 'p1'
|
|
102
|
+
// Only a collection can be a versions collection
|
|
103
|
+
const { _shadowOf: shadowOf } = args.config;
|
|
104
|
+
const uniqueSlug = (shadowOf ?? slug);
|
|
105
|
+
const checksUnique = !skipUnique && rime.config.isCollection(uniqueSlug);
|
|
106
|
+
const ownId = shadowOf ? args.data.ownerId : originalDoc?.id;
|
|
107
|
+
/** Whether another document holds `value` at `key`. */
|
|
108
|
+
const isTaken = async (key, value) => {
|
|
109
|
+
if (operation === 'update' && !ownId) {
|
|
110
|
+
throw new RimeError(RimeError.OPERATION_ERROR, 'missing originalDoc @validateFields');
|
|
111
|
+
}
|
|
112
|
+
// An object, never re-parsed: `a+b` is looked up as is
|
|
113
|
+
const sameValue = { [key]: { equals: value } };
|
|
114
|
+
const where = ownId ? { and: [sameValue, { id: { not_equals: ownId } }] } : sameValue;
|
|
115
|
+
const existing = await rime
|
|
116
|
+
.collection(uniqueSlug)
|
|
117
|
+
.system()
|
|
118
|
+
.find({ locale, query: { where }, select: ['id'] });
|
|
119
|
+
return existing.length > 0;
|
|
120
|
+
};
|
|
121
|
+
// The document this save leaves: on an update, what it sends over what is stored
|
|
122
|
+
const merged = operation === 'update' && originalDoc && originalConfigMap
|
|
123
|
+
? withStoredRows(fallbackDataFromOriginal({
|
|
124
|
+
data: allowed.data,
|
|
125
|
+
original: originalDoc,
|
|
126
|
+
configMap: originalConfigMap,
|
|
127
|
+
ignore: []
|
|
128
|
+
}), originalDoc, args.config.fields)
|
|
129
|
+
: allowed.data;
|
|
71
130
|
for (const [key, config] of Object.entries(configMap)) {
|
|
131
|
+
// A kept value, a stored one or a create's default, is written unchecked
|
|
72
132
|
if (allowed.kept.some((path) => isWithin(key, path)))
|
|
73
133
|
continue;
|
|
74
134
|
let value = getValueAtPath(key, output);
|
|
@@ -85,7 +145,7 @@ export const validateFields = Hooks.beforeUpsert(async function validateFields(a
|
|
|
85
145
|
if (config.get.validate && value !== undefined && value !== null && !skipHooks) {
|
|
86
146
|
try {
|
|
87
147
|
const valid = config.use.validate(value, {
|
|
88
|
-
data:
|
|
148
|
+
data: merged,
|
|
89
149
|
operation,
|
|
90
150
|
id: operation === 'update' ? args.context.originalDoc?.id : undefined,
|
|
91
151
|
user: user,
|
|
@@ -114,29 +174,9 @@ export const validateFields = Hooks.beforeUpsert(async function validateFields(a
|
|
|
114
174
|
}
|
|
115
175
|
// Unique: another document holds the value this save writes. An empty value has nothing to
|
|
116
176
|
// collide with, and a value `validate` refused is reported as that.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (isUnique && isCollection && !skipUnique && hasValue && !errors[key]) {
|
|
120
|
-
// An object, never re-parsed: `a+b` is looked up as is
|
|
121
|
-
const sameValue = { [key]: { equals: value } };
|
|
122
|
-
let where;
|
|
123
|
-
switch (operation) {
|
|
124
|
-
case 'create':
|
|
125
|
-
where = sameValue;
|
|
126
|
-
break;
|
|
127
|
-
case 'update':
|
|
128
|
-
if (!args.context.originalDoc) {
|
|
129
|
-
throw new RimeError(RimeError.OPERATION_ERROR, 'missing originalDoc @validateFields');
|
|
130
|
-
}
|
|
131
|
-
where = { and: [sameValue, { id: { not_equals: args.context.originalDoc.id } }] };
|
|
132
|
-
}
|
|
133
|
-
const existing = await rime
|
|
134
|
-
.collection(slug)
|
|
135
|
-
.system()
|
|
136
|
-
.find({ locale, query: { where }, select: ['id'] });
|
|
137
|
-
if (existing.length) {
|
|
177
|
+
if (checksUnique && isUnique(config) && hasValue(value) && !errors[key]) {
|
|
178
|
+
if (await isTaken(key, value))
|
|
138
179
|
errors[key] = RimeFormError.UNIQUE_FIELD;
|
|
139
|
-
}
|
|
140
180
|
}
|
|
141
181
|
// A relation names documents that exist. Checked here, before anything is written: a stale
|
|
142
182
|
// id fails the save, it is never dropped from it.
|
|
@@ -145,21 +185,37 @@ export const validateFields = Hooks.beforeUpsert(async function validateFields(a
|
|
|
145
185
|
if (missing.length)
|
|
146
186
|
errors[key] = RimeFormError.RELATION_NOT_FOUND;
|
|
147
187
|
}
|
|
148
|
-
//
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
188
|
+
// A required value left empty without the check takes the field's own default, else nothing
|
|
189
|
+
// is written: a create leaves the column empty, and an update leaves the stored column as it
|
|
190
|
+
// is. The key stays in the map, so a list or a relation sent empty is emptied.
|
|
191
|
+
if (skipRequired && config.get.required && config.use.isEmpty(value)) {
|
|
192
|
+
const fallback = config.use.defaultValue({ event });
|
|
193
|
+
output =
|
|
194
|
+
fallback === null || fallback === undefined
|
|
195
|
+
? deleteValueAtPath(output, key)
|
|
196
|
+
: setValueAtPath(key, output, fallback);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// A publish puts every value of the version live, sent or stored: each unique one is checked
|
|
200
|
+
const publishes = !!args.config.versions?.draft && allowed.data.status === VERSIONS_STATUS.PUBLISHED;
|
|
201
|
+
if (checksUnique && publishes) {
|
|
202
|
+
for (const [key, config] of Object.entries(buildConfigMap(merged, args.config.fields))) {
|
|
203
|
+
if (key in configMap || errors[key] || !isUnique(config))
|
|
204
|
+
continue;
|
|
205
|
+
const value = getValueAtPath(key, merged);
|
|
206
|
+
if (hasValue(value) && (await isTaken(key, value)))
|
|
207
|
+
errors[key] = RimeFormError.UNIQUE_FIELD;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
// Required: the document as saved holds a value, sent or stored. A sent value is read after its
|
|
211
|
+
// hooks.
|
|
212
|
+
if (!skipRequired) {
|
|
213
|
+
for (const [key, config] of Object.entries(buildConfigMap(merged, args.config.fields))) {
|
|
214
|
+
if (!config.get.required)
|
|
215
|
+
continue;
|
|
216
|
+
const value = getValueAtPath(key, key in configMap ? output : merged);
|
|
217
|
+
if (config.use.isEmpty(value))
|
|
161
218
|
errors[key] = RimeFormError.REQUIRED_FIELD;
|
|
162
|
-
}
|
|
163
219
|
}
|
|
164
220
|
}
|
|
165
221
|
// A group or tab sent as `null` clears every column below it: a required one is missing
|
|
@@ -180,6 +236,10 @@ export const validateFields = Hooks.beforeUpsert(async function validateFields(a
|
|
|
180
236
|
}
|
|
181
237
|
};
|
|
182
238
|
});
|
|
239
|
+
/** Whether the field says `.unique()`: only text, email and slug can. */
|
|
240
|
+
const isUnique = (config) => !!config.get.unique;
|
|
241
|
+
/** A value a unique lookup can collide with: an empty one has nothing to collide with. */
|
|
242
|
+
const hasValue = (value) => value !== undefined && value !== null && value !== '';
|
|
183
243
|
/**
|
|
184
244
|
* The paths of the required fields below a container `data` holds as `null`. Blocks and tree rows
|
|
185
245
|
* are left out: their fields are not columns of the document.
|
|
@@ -203,3 +263,38 @@ const requiredUnderNull = (data, fields) => [...walkFields(fields, { determinate
|
|
|
203
263
|
}
|
|
204
264
|
return false;
|
|
205
265
|
});
|
|
266
|
+
/**
|
|
267
|
+
* `data` with each saved row it sends laid over the stored row of the same `id`, wherever that row
|
|
268
|
+
* sat: the fields the row leaves out take their stored values. A new row, and a block sent as
|
|
269
|
+
* another type, stay as sent.
|
|
270
|
+
*
|
|
271
|
+
* ```ts
|
|
272
|
+
* // stored { layout: [{ id: 'b1', type: 'hero', title: 'Home', label: 'Go' }] }
|
|
273
|
+
* withStoredRows({ layout: [{ id: 'b1', type: 'hero', label: 'Start' }] }, stored, fields)
|
|
274
|
+
* // { layout: [{ id: 'b1', type: 'hero', title: 'Home', label: 'Start' }] }
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
const withStoredRows = (data, stored, fields) => {
|
|
278
|
+
const storedRows = new Map();
|
|
279
|
+
for (const { row } of savedRows(fields, stored))
|
|
280
|
+
storedRows.set(row.id, row);
|
|
281
|
+
let output = data;
|
|
282
|
+
for (const { path, row } of savedRows(fields, data)) {
|
|
283
|
+
const storedRow = storedRows.get(row.id);
|
|
284
|
+
if (!storedRow || storedRow.type !== row.type)
|
|
285
|
+
continue;
|
|
286
|
+
// `layout.0:hero` is set at `layout.0`: setValueAtPath drops the block type
|
|
287
|
+
output = setValueAtPath(path, output, withDefaultValues(row, storedRow));
|
|
288
|
+
}
|
|
289
|
+
return output;
|
|
290
|
+
};
|
|
291
|
+
/** Every saved block and tree item of `data`, at any depth, with the path it sits at. */
|
|
292
|
+
function* savedRows(fields, data) {
|
|
293
|
+
for (const { field, path, value } of walkValues(fields, data)) {
|
|
294
|
+
for (const node of field.use.nodesFor(value)) {
|
|
295
|
+
if (node.storage && isObjectLiteral(node.value) && isSaved(node.value)) {
|
|
296
|
+
yield { path: `${path}.${node.segment}`, row: node.value };
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
@@ -5,5 +5,10 @@ type ExtractBlocksArgs = {
|
|
|
5
5
|
data: Dic;
|
|
6
6
|
configMap: ConfigMap;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* Every block of every blocks field in the map, as one flat list. Each block's `path` and
|
|
10
|
+
* `position` come from where it sits in the data; a block list nested in a block is left out of
|
|
11
|
+
* its parent row and listed as rows of its own.
|
|
12
|
+
*/
|
|
8
13
|
export declare function extractBlocks({ data, configMap }: ExtractBlocksArgs): GenericBlock[];
|
|
9
14
|
export {};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { normalizeFieldPath } from '../../../../util/string.js';
|
|
2
2
|
import { getValueAtPath } from '../../../../util/object.js';
|
|
3
|
+
/**
|
|
4
|
+
* Every block of every blocks field in the map, as one flat list. Each block's `path` and
|
|
5
|
+
* `position` come from where it sits in the data; a block list nested in a block is left out of
|
|
6
|
+
* its parent row and listed as rows of its own.
|
|
7
|
+
*/
|
|
3
8
|
export function extractBlocks({ data, configMap }) {
|
|
4
9
|
const blocks = [];
|
|
5
10
|
Object.entries(configMap).forEach(([path, config]) => {
|
|
@@ -3,13 +3,9 @@ import type { GenericBlock, PrototypeSlug } from '../../../prototype/types.js';
|
|
|
3
3
|
import type { Dic } from '../../../../util/types.js';
|
|
4
4
|
import type { OperationContext } from '../../types.js';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* This function handles the complete lifecycle of block persistence:
|
|
10
|
-
* 1. Extract blocks from form data
|
|
11
|
-
* 2. Compare with existing blocks to determine changes
|
|
12
|
-
* 3. Execute database operations (create/update/delete)
|
|
6
|
+
* Writes a save's blocks: compares the stored blocks inside the paths the save replaces with the
|
|
7
|
+
* blocks it sends, then deletes, adds and updates rows. Answers the diff, whose deleted rows
|
|
8
|
+
* `saveRelations` reads to drop their relations.
|
|
13
9
|
*/
|
|
14
10
|
export declare const saveBlocks: (args: {
|
|
15
11
|
context: OperationContext;
|
|
@@ -2,16 +2,11 @@ import { RimeError } from '../../../errors/index.js';
|
|
|
2
2
|
import { diffRepeatables, replacedPaths, withinPaths } from '../repeatable.server.js';
|
|
3
3
|
import { extractBlocks } from './extract.server.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* This function handles the complete lifecycle of block persistence:
|
|
9
|
-
* 1. Extract blocks from form data
|
|
10
|
-
* 2. Compare with existing blocks to determine changes
|
|
11
|
-
* 3. Execute database operations (create/update/delete)
|
|
5
|
+
* Writes a save's blocks: compares the stored blocks inside the paths the save replaces with the
|
|
6
|
+
* blocks it sends, then deletes, adds and updates rows. Answers the diff, whose deleted rows
|
|
7
|
+
* `saveRelations` reads to drop their relations.
|
|
12
8
|
*/
|
|
13
9
|
export const saveBlocks = async (args) => {
|
|
14
|
-
//
|
|
15
10
|
const { context, ownerId, data, incomingPaths, adapter, ownerSlug } = args;
|
|
16
11
|
const { locale } = context.params;
|
|
17
12
|
const { originalDoc: original, configMap, originalConfigMap } = context;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** No locale on either side reads as `null`. */
|
|
2
2
|
const sameLocale = (existing, incoming) => (existing.locale ?? null) === (incoming.locale ?? null);
|
|
3
|
+
/** Whether the stored row must change to become the incoming one: place, document or locale. */
|
|
3
4
|
const needUpdate = (existing, incoming) => existing.position !== incoming.position ||
|
|
4
5
|
existing.documentId !== incoming.documentId ||
|
|
5
6
|
existing.path !== incoming.path ||
|
|
@@ -7,5 +7,6 @@ type Args = {
|
|
|
7
7
|
configMap: ConfigMap;
|
|
8
8
|
locale: string | undefined;
|
|
9
9
|
};
|
|
10
|
+
/** The junction rows the data names, one per document, numbered in each list from 0. */
|
|
10
11
|
export declare const extractRelations: ({ ownerId, data, configMap, locale }: Args) => BeforeOperationRelation[];
|
|
11
12
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isRelationField } from '../../../../fields/relation/index.js';
|
|
2
2
|
import { Relation } from '../../../../fields/relation/relation.js';
|
|
3
3
|
import { getValueAtPath, isObjectLiteral } from '../../../../util/object.js';
|
|
4
|
+
/** The junction rows the data names, one per document, numbered in each list from 0. */
|
|
4
5
|
export const extractRelations = ({ ownerId, data, configMap, locale }) => {
|
|
5
6
|
const relations = [];
|
|
6
7
|
// The config map keys every field the document holds; relations are the ones stored as junction
|
|
@@ -32,6 +33,7 @@ export const extractRelations = ({ ownerId, data, configMap, locale }) => {
|
|
|
32
33
|
}
|
|
33
34
|
return relations;
|
|
34
35
|
};
|
|
36
|
+
/** The id an entry names: a bare id, a ref's document, or a document read and sent back. */
|
|
35
37
|
const documentIdOf = (entry) => {
|
|
36
38
|
if (typeof entry === 'string')
|
|
37
39
|
return entry || null;
|
|
@@ -3,6 +3,12 @@ import type { GenericBlock, PrototypeSlug, TreeBlock } from '../../../prototype/
|
|
|
3
3
|
import type { Dic, WithRequired } from '../../../../util/types.js';
|
|
4
4
|
import type { ConfigMap } from '../../config-map/types.js';
|
|
5
5
|
import { type RepeatablesDiff } from '../repeatable.server.js';
|
|
6
|
+
/**
|
|
7
|
+
* Writes a save's relations: drops the relations under the block and tree rows the save
|
|
8
|
+
* deleted, moves the other locales' relations under the rows it moved, then compares the stored
|
|
9
|
+
* relations inside the paths the save replaces (a group's own path excluded) with the ones the
|
|
10
|
+
* data names, and deletes, updates and adds rows.
|
|
11
|
+
*/
|
|
6
12
|
export declare const saveRelations: (args: {
|
|
7
13
|
data: Dic;
|
|
8
14
|
configMap: ConfigMap;
|
|
@@ -1,23 +1,47 @@
|
|
|
1
|
-
import { replacedPaths, withinPaths } from '../repeatable.server.js';
|
|
1
|
+
import { movedPath, placeOf, replacedPaths, withinPaths } from '../repeatable.server.js';
|
|
2
2
|
import { defineRelationsDiff } from './diff.server.js';
|
|
3
3
|
import { extractRelations } from './extract.server.js';
|
|
4
|
+
/**
|
|
5
|
+
* Writes a save's relations: drops the relations under the block and tree rows the save
|
|
6
|
+
* deleted, moves the other locales' relations under the rows it moved, then compares the stored
|
|
7
|
+
* relations inside the paths the save replaces (a group's own path excluded) with the ones the
|
|
8
|
+
* data names, and deletes, updates and adds rows.
|
|
9
|
+
*/
|
|
4
10
|
export const saveRelations = async (args) => {
|
|
5
11
|
const { configMap, incomingPaths, blocksDiff, treeDiff, adapter, locale, ownerSlug, ownerId, data } = args;
|
|
6
|
-
/**
|
|
12
|
+
/** A blocks or tree row is every locale's when its list field is not localized. */
|
|
13
|
+
const isShared = (row) => {
|
|
14
|
+
// A tree item's list is its tree: `menu.0._children.1._children` -> `menu`
|
|
15
|
+
const list = configMap[row.path.replace(/(\.\d+\._children)+$/, '')];
|
|
16
|
+
return !!list && !list.get.localized;
|
|
17
|
+
};
|
|
18
|
+
// The relations under a removed row go with it: in every locale when its list is shared, in the
|
|
19
|
+
// request locale when the list is localized
|
|
20
|
+
const removed = [...blocksDiff.toDelete, ...treeDiff.toDelete];
|
|
7
21
|
await adapter.relations.deleteFromPaths({
|
|
8
22
|
parentSlug: ownerSlug,
|
|
9
23
|
ownerId,
|
|
10
|
-
paths:
|
|
11
|
-
locale
|
|
24
|
+
paths: removed.filter(isShared).map(placeOf)
|
|
12
25
|
});
|
|
13
|
-
/** Delete relations from deletedTreeItems */
|
|
14
26
|
await adapter.relations.deleteFromPaths({
|
|
15
27
|
parentSlug: ownerSlug,
|
|
16
28
|
ownerId,
|
|
17
|
-
paths:
|
|
29
|
+
paths: removed.filter((row) => !isShared(row)).map(placeOf),
|
|
18
30
|
locale
|
|
19
31
|
});
|
|
20
|
-
|
|
32
|
+
// The data places the request locale's relations. The other locales' relations under a moved
|
|
33
|
+
// row of a shared list move with it.
|
|
34
|
+
const moves = [...blocksDiff.moved, ...treeDiff.moved].filter(isShared);
|
|
35
|
+
if (locale && moves.length) {
|
|
36
|
+
// `getAll` with no locale answers every locale's rows
|
|
37
|
+
const followed = (await adapter.relations.getAll({ parentSlug: ownerSlug, ownerId })).flatMap((row) => {
|
|
38
|
+
const path = row.locale && row.locale !== locale ? movedPath(row.path, moves) : null;
|
|
39
|
+
return path ? [{ ...row, path }] : [];
|
|
40
|
+
});
|
|
41
|
+
if (followed.length) {
|
|
42
|
+
await adapter.relations.update({ parentSlug: ownerSlug, relations: followed });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
21
45
|
const incomingRelations = extractRelations({
|
|
22
46
|
ownerId,
|
|
23
47
|
data,
|
|
@@ -31,7 +55,6 @@ export const saveRelations = async (args) => {
|
|
|
31
55
|
locale: locale
|
|
32
56
|
})
|
|
33
57
|
.then((relations) => withinPaths(relations, replacedPaths(incomingPaths, configMap)));
|
|
34
|
-
/** get difference between them */
|
|
35
58
|
const relationsDiff = defineRelationsDiff({
|
|
36
59
|
existingRelations,
|
|
37
60
|
incomingRelations,
|
|
@@ -8,29 +8,38 @@ type Row = Dic & {
|
|
|
8
8
|
type SavedRow<R extends Row> = R & {
|
|
9
9
|
id: string;
|
|
10
10
|
};
|
|
11
|
+
/** Where a kept row went: its list, and its `path.position` before the save and after. */
|
|
12
|
+
export type RowMove = {
|
|
13
|
+
path: string;
|
|
14
|
+
from: string;
|
|
15
|
+
to: string;
|
|
16
|
+
};
|
|
11
17
|
export type RepeatablesDiff<R extends Row> = {
|
|
12
18
|
toAdd: R[];
|
|
13
19
|
toDelete: SavedRow<R>[];
|
|
14
20
|
toUpdate: SavedRow<R>[];
|
|
21
|
+
moved: RowMove[];
|
|
15
22
|
};
|
|
16
|
-
/**
|
|
23
|
+
/** Where a row sits: `sections.2`, `menu.0._children.1`. */
|
|
24
|
+
export declare const placeOf: (row: Row) => string;
|
|
25
|
+
/** A row the store holds: a string id that is not a temporary one. */
|
|
17
26
|
export declare const isSaved: <R extends Row>(row: R) => row is SavedRow<R>;
|
|
18
27
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
28
|
+
* What a save does to the stored rows: add the new ones, delete the stored ones it no longer sends,
|
|
29
|
+
* update the ones whose values changed, and where each kept row moved. `stored` holds the rows
|
|
30
|
+
* inside the saved paths only.
|
|
31
|
+
*/
|
|
32
|
+
export declare function diffRepeatables<R extends Row>(stored: R[], incoming: R[]): RepeatablesDiff<R>;
|
|
33
|
+
/**
|
|
34
|
+
* Where `path` lies once the rows above it have moved: the deepest move holding it decides, since
|
|
35
|
+
* its `to` already carries the moves of the rows above it. `null` under no moved row.
|
|
21
36
|
*
|
|
22
37
|
* ```ts
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* changesRow({ label: 'A' }, { label: 'A', subtitle: 'B' }); // true
|
|
38
|
+
* movedPath('sections.2.image', [{ path: 'sections', from: 'sections.2', to: 'sections.1' }]);
|
|
39
|
+
* // 'sections.1.image'
|
|
26
40
|
* ```
|
|
27
41
|
*/
|
|
28
|
-
export declare const
|
|
29
|
-
/**
|
|
30
|
-
* What a save does to the stored rows: add the new ones, delete the stored ones it no longer sends,
|
|
31
|
-
* update the ones whose values changed. `stored` holds the rows inside the saved paths only.
|
|
32
|
-
*/
|
|
33
|
-
export declare function diffRepeatables<R extends Row>(stored: R[], incoming: R[]): RepeatablesDiff<R>;
|
|
42
|
+
export declare const movedPath: (path: string, moves: RowMove[]) => string | null;
|
|
34
43
|
/** The rows inside one of the paths a save writes. */
|
|
35
44
|
export declare const withinPaths: <R extends Row>(rows: R[], paths: string[]) => R[];
|
|
36
45
|
/**
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { isTempId } from '../../../util/random.js';
|
|
2
2
|
import { isWithin } from '../../../util/string.js';
|
|
3
|
-
/**
|
|
4
|
-
export const
|
|
3
|
+
/** Where a row sits: `sections.2`, `menu.0._children.1`. */
|
|
4
|
+
export const placeOf = (row) => `${row.path}.${row.position}`;
|
|
5
|
+
/** A row the store holds: a string id that is not a temporary one. */
|
|
6
|
+
export const isSaved = (row) => typeof row.id === 'string' && row.id !== '' && !isTempId(row.id);
|
|
5
7
|
/**
|
|
6
8
|
* Whether the incoming row changes the stored one: a value it sends differs. Nested rows
|
|
7
9
|
* (`_children`, or a list of blocks) are compared as rows of their own.
|
|
@@ -12,7 +14,7 @@ export const isSaved = (row) => !!row.id && !isTempId(row.id);
|
|
|
12
14
|
* changesRow({ label: 'A' }, { label: 'A', subtitle: 'B' }); // true
|
|
13
15
|
* ```
|
|
14
16
|
*/
|
|
15
|
-
|
|
17
|
+
const changesRow = (stored, incoming) => Object.entries(incoming).some(([key, value]) => {
|
|
16
18
|
if (key === '_children')
|
|
17
19
|
return false;
|
|
18
20
|
if (Array.isArray(value) && value[0]?.type)
|
|
@@ -21,7 +23,8 @@ export const changesRow = (stored, incoming) => Object.entries(incoming).some(([
|
|
|
21
23
|
});
|
|
22
24
|
/**
|
|
23
25
|
* What a save does to the stored rows: add the new ones, delete the stored ones it no longer sends,
|
|
24
|
-
* update the ones whose values changed. `stored` holds the rows
|
|
26
|
+
* update the ones whose values changed, and where each kept row moved. `stored` holds the rows
|
|
27
|
+
* inside the saved paths only.
|
|
25
28
|
*/
|
|
26
29
|
export function diffRepeatables(stored, incoming) {
|
|
27
30
|
const sentIds = new Set(incoming.filter(isSaved).map((row) => row.id));
|
|
@@ -31,9 +34,30 @@ export function diffRepeatables(stored, incoming) {
|
|
|
31
34
|
toUpdate: incoming.filter(isSaved).filter((row) => {
|
|
32
35
|
const match = stored.find((candidate) => candidate.id === row.id);
|
|
33
36
|
return !!match && changesRow(match, row);
|
|
37
|
+
}),
|
|
38
|
+
moved: incoming.filter(isSaved).flatMap((row) => {
|
|
39
|
+
const match = stored.find((candidate) => candidate.id === row.id);
|
|
40
|
+
return match && placeOf(match) !== placeOf(row)
|
|
41
|
+
? [{ path: row.path, from: placeOf(match), to: placeOf(row) }]
|
|
42
|
+
: [];
|
|
34
43
|
})
|
|
35
44
|
};
|
|
36
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Where `path` lies once the rows above it have moved: the deepest move holding it decides, since
|
|
48
|
+
* its `to` already carries the moves of the rows above it. `null` under no moved row.
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* movedPath('sections.2.image', [{ path: 'sections', from: 'sections.2', to: 'sections.1' }]);
|
|
52
|
+
* // 'sections.1.image'
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export const movedPath = (path, moves) => {
|
|
56
|
+
const deepest = moves
|
|
57
|
+
.filter((move) => isWithin(path, move.from))
|
|
58
|
+
.sort((a, b) => b.from.length - a.from.length)[0];
|
|
59
|
+
return deepest ? deepest.to + path.slice(deepest.from.length) : null;
|
|
60
|
+
};
|
|
37
61
|
/** The rows inside one of the paths a save writes. */
|
|
38
62
|
export const withinPaths = (rows, paths) => rows.filter((row) => !!row.path && paths.some((path) => isWithin(row.path, path)));
|
|
39
63
|
/**
|
|
@@ -5,5 +5,10 @@ type ExtractTreesArgs = {
|
|
|
5
5
|
data: Dic;
|
|
6
6
|
configMap: ConfigMap;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* Every item of every tree field in the map, as one flat list: each item a row of its own, its
|
|
10
|
+
* `path` the list it sits in (`nav`, `nav.0._children`) and `position` its index there,
|
|
11
|
+
* `_children` emptied.
|
|
12
|
+
*/
|
|
8
13
|
export declare function extractTreeBlocks({ data, configMap }: ExtractTreesArgs): WithRequired<TreeBlock, "path">[];
|
|
9
14
|
export {};
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { getValueAtPath } from '../../../../util/object.js';
|
|
2
2
|
import cloneDeep from 'clone-deep';
|
|
3
|
+
/**
|
|
4
|
+
* Every item of every tree field in the map, as one flat list: each item a row of its own, its
|
|
5
|
+
* `path` the list it sits in (`nav`, `nav.0._children`) and `position` its index there,
|
|
6
|
+
* `_children` emptied.
|
|
7
|
+
*/
|
|
3
8
|
export function extractTreeBlocks({ data, configMap }) {
|
|
4
9
|
const blocks = [];
|
|
5
10
|
function processTreeItem(item, index, rootPath, parentPath) {
|
|
6
|
-
// Create a copy of the item to avoid modifying the original
|
|
7
11
|
const processedItem = cloneDeep({ ...item });
|
|
8
|
-
// Position is the index in its list
|
|
9
12
|
processedItem.position = index;
|
|
10
|
-
// Set path based on whether it's a root level or nested item
|
|
11
13
|
processedItem.path = parentPath ? `${parentPath}` : rootPath;
|
|
12
|
-
// Empty `_children`: each child becomes its own row
|
|
13
14
|
processedItem._children = [];
|
|
14
|
-
// Add the processed item to the flat array
|
|
15
15
|
blocks.push(processedItem);
|
|
16
|
-
// Process children recursively
|
|
17
16
|
(item._children || []).forEach((child, childIndex) => {
|
|
18
|
-
processTreeItem(child, childIndex, rootPath, `${processedItem.path}.${processedItem.position}._children`
|
|
19
|
-
);
|
|
17
|
+
processTreeItem(child, childIndex, rootPath, `${processedItem.path}.${processedItem.position}._children`);
|
|
20
18
|
});
|
|
21
19
|
}
|
|
22
20
|
Object.entries(configMap).forEach(([path, config]) => {
|
|
@@ -2,6 +2,11 @@ import type { Adapter } from '../../../adapter.js';
|
|
|
2
2
|
import type { TreeBlock, PrototypeSlug } from '../../../prototype/types.js';
|
|
3
3
|
import type { Dic, WithRequired } from '../../../../util/types.js';
|
|
4
4
|
import type { OperationContext } from '../../types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Writes a save's tree items: compares the stored items inside the paths the save replaces with
|
|
7
|
+
* the items it sends, then deletes, adds and updates rows. Answers the diff, whose deleted rows
|
|
8
|
+
* `saveRelations` reads to drop their relations.
|
|
9
|
+
*/
|
|
5
10
|
export declare const saveTreeBlocks: (args: {
|
|
6
11
|
context: OperationContext;
|
|
7
12
|
ownerId: string;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { RimeError } from '../../../errors/index.js';
|
|
2
2
|
import { diffRepeatables, replacedPaths, withinPaths } from '../repeatable.server.js';
|
|
3
3
|
import { extractTreeBlocks } from './extract.server.js';
|
|
4
|
+
/**
|
|
5
|
+
* Writes a save's tree items: compares the stored items inside the paths the save replaces with
|
|
6
|
+
* the items it sends, then deletes, adds and updates rows. Answers the diff, whose deleted rows
|
|
7
|
+
* `saveRelations` reads to drop their relations.
|
|
8
|
+
*/
|
|
4
9
|
export const saveTreeBlocks = async (args) => {
|
|
5
10
|
const { context, ownerId, data, incomingPaths, adapter, ownerSlug } = args;
|
|
6
11
|
const { locale } = context.params;
|
|
@@ -7,6 +7,7 @@ import type { RequestEvent } from '@sveltejs/kit';
|
|
|
7
7
|
* Read for one operation, by one reader, and dropped with it.
|
|
8
8
|
*/
|
|
9
9
|
export type Populated = Map<string, GenericDoc>;
|
|
10
|
+
/** The key a target is stored under, and looked up by in buildDocument: slug, locale, id. */
|
|
10
11
|
export declare const populatedKey: (slug: string, locale: string | undefined, id: string) => string;
|
|
11
12
|
/**
|
|
12
13
|
* Reads what the relations of a whole list point at, one `findByIds` per collection and locale.
|