rimecms 1.3.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter-sqlite/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.d.ts +131 -0
- 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/index.d.ts +7 -0
- 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
|
@@ -2,8 +2,10 @@ import { UPLOADS } from '../constant.js';
|
|
|
2
2
|
import { filesOwner, mediasFolder } from '../disk/medias.server.js';
|
|
3
3
|
import { Hooks } from '../../../../pipeline/define-hook.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Runs on every read of an upload document: puts the URL of each image size in `sizes` (one key
|
|
6
|
+
* per format, `hero_webp`, when a size has several), `_thumbnail` (the `thumbnail` size or its
|
|
7
|
+
* first format, else the file) and `url`, and removes the raw size columns. The URLs point into
|
|
8
|
+
* the collection's folder:
|
|
7
9
|
*
|
|
8
10
|
* ```
|
|
9
11
|
* medias /uploads/medias/photo.jpg
|
|
@@ -18,25 +20,22 @@ export const populateSizes = Hooks.beforeRead(async function populateSizes(args)
|
|
|
18
20
|
if ('imageSizes' in config.upload && config.upload.imageSizes && doc.filename) {
|
|
19
21
|
doc.sizes = {};
|
|
20
22
|
for (const size of config.upload.imageSizes) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
delete doc[size.name];
|
|
23
|
+
const stored = doc[size.name];
|
|
24
|
+
delete doc[size.name];
|
|
25
|
+
if (!stored) {
|
|
26
|
+
// A size with no file of its own: the original
|
|
27
|
+
doc.sizes[size.name] = mediaUrl(doc.filename);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const formats = stored.split('|');
|
|
31
|
+
if (formats.length > 1) {
|
|
32
|
+
formats.forEach((format) => {
|
|
33
|
+
const extension = format.split('.').pop();
|
|
34
|
+
doc.sizes[`${size.name}_${extension}`] = mediaUrl(format);
|
|
35
|
+
});
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
38
|
-
|
|
39
|
-
doc.sizes[size.name] = mediaUrl(doc.filename);
|
|
38
|
+
doc.sizes[size.name] = mediaUrl(formats[0]);
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
// Add the _thumbnail prop
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Saves the file a write sends, with its image sizes, in the collection's folder, and puts its
|
|
3
|
-
* name on the row.
|
|
3
|
+
* name, type and size on the row. The type is the one its extension is served as, and a type
|
|
4
|
+
* `upload.accept` does not take answers 400 before anything is saved (`uploadType`).
|
|
4
5
|
*
|
|
5
6
|
* ```
|
|
7
|
+
* file: x.html 400 ".html is not an accepted file type", unless `accept` lists `text/html`
|
|
6
8
|
* file: File saved; `filename` and each size column name the saved files
|
|
7
9
|
* file: null the row names no file: `filename`, `mimeType`, `filesize` and the sizes are null
|
|
8
10
|
* no file nothing changes
|
|
@@ -4,11 +4,16 @@ import { filesOwner } from '../disk/medias.server.js';
|
|
|
4
4
|
import { saveFile } from '../disk/save.server.js';
|
|
5
5
|
import { omit } from '../../../../../util/object.js';
|
|
6
6
|
import { isUploadConfig } from '../util/config.js';
|
|
7
|
+
import { uploadType } from '../util/mime.js';
|
|
8
|
+
import { RimeError } from '../../../../errors/index.js';
|
|
9
|
+
import { fileSizeToString } from '../../../../../util/file.js';
|
|
7
10
|
/**
|
|
8
11
|
* Saves the file a write sends, with its image sizes, in the collection's folder, and puts its
|
|
9
|
-
* name on the row.
|
|
12
|
+
* name, type and size on the row. The type is the one its extension is served as, and a type
|
|
13
|
+
* `upload.accept` does not take answers 400 before anything is saved (`uploadType`).
|
|
10
14
|
*
|
|
11
15
|
* ```
|
|
16
|
+
* file: x.html 400 ".html is not an accepted file type", unless `accept` lists `text/html`
|
|
12
17
|
* file: File saved; `filename` and each size column name the saved files
|
|
13
18
|
* file: null the row names no file: `filename`, `mimeType`, `filesize` and the sizes are null
|
|
14
19
|
* no file nothing changes
|
|
@@ -19,8 +24,9 @@ import { isUploadConfig } from '../util/config.js';
|
|
|
19
24
|
*/
|
|
20
25
|
export const processFileUpload = Hooks.beforeUpsert(async function processFileUpload(args) {
|
|
21
26
|
const { operation, config } = args;
|
|
22
|
-
if (!isUploadConfig(config))
|
|
23
|
-
throw new Error('
|
|
27
|
+
if (!isUploadConfig(config)) {
|
|
28
|
+
throw new Error('processFileUpload runs on an upload collection only');
|
|
29
|
+
}
|
|
24
30
|
let data = args.data || {};
|
|
25
31
|
const hasSizeConfig = 'imageSizes' in config.upload && Array.isArray(config.upload.imageSizes);
|
|
26
32
|
const sizesConfig = hasSizeConfig ? config.upload.imageSizes : [];
|
|
@@ -28,11 +34,18 @@ export const processFileUpload = Hooks.beforeUpsert(async function processFileUp
|
|
|
28
34
|
const replaced = operation === 'update' ? rowFiles(args.context.originalDoc) : null;
|
|
29
35
|
const replacesFile = data.file !== undefined;
|
|
30
36
|
if (data.file) {
|
|
37
|
+
// The type the file is served as, from the extension it is saved under
|
|
38
|
+
const { mimeType, refusal } = uploadType(data.file.name, config.upload.accept);
|
|
39
|
+
if (refusal) {
|
|
40
|
+
throw new RimeError(RimeError.INVALID_DATA, refusal);
|
|
41
|
+
}
|
|
31
42
|
const owner = filesOwner(args.event.locals.rime.config, config);
|
|
32
43
|
const { filename, imageSizes } = await saveFile(owner, data.file, sizesConfig);
|
|
33
44
|
data = {
|
|
34
45
|
...omit(['file'], data),
|
|
35
46
|
filename,
|
|
47
|
+
mimeType,
|
|
48
|
+
filesize: fileSizeToString(data.file.size),
|
|
36
49
|
...imageSizes
|
|
37
50
|
};
|
|
38
51
|
}
|
|
@@ -9,8 +9,9 @@ export const prepareDirectoryChildren = Hooks.beforeUpdate(async function prepar
|
|
|
9
9
|
const data = args.data;
|
|
10
10
|
const { event, config, context } = args;
|
|
11
11
|
const originalDoc = context.originalDoc;
|
|
12
|
-
if (!originalDoc)
|
|
12
|
+
if (!originalDoc) {
|
|
13
13
|
throw new RimeError(RimeError.OPERATION_ERROR, 'missing originalDoc @prepareDirectoryChildren');
|
|
14
|
+
}
|
|
14
15
|
if (data.id) {
|
|
15
16
|
// `parent` is an ordinary field on the directories collection, which is never versioned,
|
|
16
17
|
// so the plain query answers this.
|
|
@@ -53,7 +54,7 @@ export const updateDirectoryChildren = Hooks.afterUpdate(async function updateDi
|
|
|
53
54
|
for (const update of updates) {
|
|
54
55
|
const [error] = await trycatch(() => collection.updateById(update));
|
|
55
56
|
if (error) {
|
|
56
|
-
throw new RimeError(RimeError.OPERATION_ERROR,
|
|
57
|
+
throw new RimeError(RimeError.OPERATION_ERROR, `Error when moving child directory ${update.id}: ${error.message}`);
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
return { ...args, doc };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Collection } from '../../../config/types.js';
|
|
2
2
|
import type { WithNormalizedUpload } from './types.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Adds what an upload collection stores beside the author's fields: one hidden column per image
|
|
5
|
+
* size (a 400px `thumbnail` first, unless the config names one), `mimeType`, `filename`,
|
|
6
|
+
* `filesize` and `_path`. Documents are named by their `filename`, and the dashboard shows the
|
|
7
|
+
* collection as a grid.
|
|
6
8
|
*/
|
|
7
9
|
export declare const augmentUpload: <T extends Collection<any>>(config: T) => WithNormalizedUpload<T>;
|
|
8
10
|
/**
|
|
@@ -12,10 +12,15 @@ import { validatePath } from './util/path.js';
|
|
|
12
12
|
* names the folder. The type still lives in types.ts: a type exported here would be stubbed as a
|
|
13
13
|
* value on the client.
|
|
14
14
|
*/
|
|
15
|
+
/**
|
|
16
|
+
* `upload: true` becomes `{}`, `false` becomes `undefined`, an object stays as it is.
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* withNormalizedUpload({ slug: 'medias', upload: true }); // { slug: 'medias', upload: {} }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
15
22
|
const withNormalizedUpload = (config) => {
|
|
16
|
-
// Create a new object without the upload property
|
|
17
23
|
const { upload, ...rest } = config;
|
|
18
|
-
// Determine the normalized upload value
|
|
19
24
|
let normalizedUpload;
|
|
20
25
|
if (typeof upload === 'boolean') {
|
|
21
26
|
normalizedUpload = upload === true ? {} : undefined;
|
|
@@ -23,15 +28,16 @@ const withNormalizedUpload = (config) => {
|
|
|
23
28
|
else {
|
|
24
29
|
normalizedUpload = upload;
|
|
25
30
|
}
|
|
26
|
-
// Return the new object with the normalized upload
|
|
27
31
|
return {
|
|
28
32
|
...rest,
|
|
29
33
|
upload: normalizedUpload
|
|
30
34
|
};
|
|
31
35
|
};
|
|
32
36
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
37
|
+
* Adds what an upload collection stores beside the author's fields: one hidden column per image
|
|
38
|
+
* size (a 400px `thumbnail` first, unless the config names one), `mimeType`, `filename`,
|
|
39
|
+
* `filesize` and `_path`. Documents are named by their `filename`, and the dashboard shows the
|
|
40
|
+
* collection as a grid.
|
|
35
41
|
*/
|
|
36
42
|
export const augmentUpload = (config) => {
|
|
37
43
|
const normalizedUploadConfig = withNormalizedUpload(config);
|
|
@@ -54,19 +60,8 @@ export const augmentUpload = (config) => {
|
|
|
54
60
|
// One hidden column per size
|
|
55
61
|
const sizesFields = upload.imageSizes.map((size) => text(size.name).hidden().access(serverOnly));
|
|
56
62
|
fields = [...fields, ...sizesFields];
|
|
57
|
-
// Add mimeType field
|
|
58
|
-
const mimeType = text('mimeType').table({ sort: true, position: 99 }).hidden();
|
|
59
|
-
// Add validation if accept is defined
|
|
60
|
-
if ('accept' in upload && Array.isArray(upload.accept)) {
|
|
61
|
-
const allowedMimeTypes = upload.accept;
|
|
62
|
-
mimeType.validate((value) => {
|
|
63
|
-
return ((typeof value === 'string' && allowedMimeTypes.includes(value)) ||
|
|
64
|
-
`File should be the type of ${allowedMimeTypes.toString()}`);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
63
|
const _pathField = text('_path').$root().hidden().validate(validatePath);
|
|
68
|
-
|
|
69
|
-
fields.push(mimeType, text('filename').hidden().access(serverOnly), text('filesize').hidden(), _pathField);
|
|
64
|
+
fields.push(text('mimeType').table({ sort: true, position: 99 }).hidden().access(serverOnly), text('filename').hidden().access(serverOnly), text('filesize').hidden().access(serverOnly), _pathField);
|
|
70
65
|
// What an upload document is called, overriding the prototype's fallback. Overrides rather than
|
|
71
66
|
// defers, so upload wins for the rare config carrying both — the `augments` order in
|
|
72
67
|
// `collection/definition.ts` puts this after auth's.
|
|
@@ -7,10 +7,9 @@ import type { WithNormalizedUpload } from './types.js';
|
|
|
7
7
|
* name.
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
|
-
* The client augment, plus
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* schema diff is the check that matters for this feature.
|
|
10
|
+
* The client augment, plus a foreign key from `_path` to the collection's directories table:
|
|
11
|
+
* deleting a folder deletes the documents filed in it, and renaming it moves them. The client
|
|
12
|
+
* config does not carry it.
|
|
14
13
|
*/
|
|
15
14
|
export declare const augmentUpload: <T extends Collection<any>>(config: T) => WithNormalizedUpload<T>;
|
|
16
15
|
/**
|
|
@@ -8,10 +8,9 @@ import { augmentUpload as augmentUploadBase } from './module.js';
|
|
|
8
8
|
* name.
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
|
-
* The client augment, plus
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* schema diff is the check that matters for this feature.
|
|
11
|
+
* The client augment, plus a foreign key from `_path` to the collection's directories table:
|
|
12
|
+
* deleting a folder deletes the documents filed in it, and renaming it moves them. The client
|
|
13
|
+
* config does not carry it.
|
|
15
14
|
*/
|
|
16
15
|
export const augmentUpload = (config) => {
|
|
17
16
|
const collection = augmentUploadBase(config);
|
|
@@ -3,7 +3,7 @@ import type { Field } from '../../../../fields/types.js';
|
|
|
3
3
|
import type { Access } from '../../../config/types.js';
|
|
4
4
|
import type { CollectionHooks } from '../../../config/types.js';
|
|
5
5
|
import type { BaseDoc, GenericDoc } from '../../types.js';
|
|
6
|
-
import type { Dic } from '../../../../util/types.js';
|
|
6
|
+
import type { AtLeastOne, Dic } from '../../../../util/types.js';
|
|
7
7
|
import type { UploadPath } from './util/path.js';
|
|
8
8
|
/**
|
|
9
9
|
* What a document of an upload collection carries beyond a plain one.
|
|
@@ -35,6 +35,10 @@ declare module '../../types.js' {
|
|
|
35
35
|
export type WithNormalizedUpload<T> = Omit<T, 'upload'> & {
|
|
36
36
|
upload?: UploadConfig;
|
|
37
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* A file sent as JSON: a data URI (`data:image/png;base64,…`) and what the client knows of it.
|
|
40
|
+
* `castBase64ToFile` turns it into a `File`.
|
|
41
|
+
*/
|
|
38
42
|
export type JsonFile = {
|
|
39
43
|
base64: string;
|
|
40
44
|
filename?: string;
|
|
@@ -42,12 +46,12 @@ export type JsonFile = {
|
|
|
42
46
|
filesize?: number;
|
|
43
47
|
lastModified?: number;
|
|
44
48
|
};
|
|
49
|
+
/** A folder as the panel reads it: `id` is its path (`root:press`), `parent` the path above it. */
|
|
45
50
|
export type Directory = GenericDoc & {
|
|
46
51
|
id: UploadPath;
|
|
47
52
|
name: string;
|
|
48
53
|
parent: UploadPath | null;
|
|
49
54
|
};
|
|
50
|
-
import type { AtLeastOne } from '../../../../util/types.js';
|
|
51
55
|
/** What an author writes under `upload`, and the image sizes it may ask for. */
|
|
52
56
|
export type UploadConfig = {
|
|
53
57
|
/**
|
|
@@ -83,23 +87,34 @@ export type UploadConfig = {
|
|
|
83
87
|
*/
|
|
84
88
|
imageSizes?: ImageSizesConfig[];
|
|
85
89
|
/**
|
|
86
|
-
*
|
|
90
|
+
* The types a file may have, by the extension it is saved under. Without it, every type is
|
|
91
|
+
* taken but the risky ones: pages and scripts a browser or a server runs, such as `.html`,
|
|
92
|
+
* `.xml`, `.js` and `.php` (`RISKY_MIME_TYPES`). A risky type is taken only when it is listed
|
|
93
|
+
* here. Images, SVG included, video and audio are never risky.
|
|
87
94
|
* @example
|
|
88
95
|
* ```typescript
|
|
89
|
-
* accept: ['image/jpeg', 'image/svg']
|
|
96
|
+
* accept: ['image/jpeg', 'image/svg+xml']
|
|
90
97
|
* ```
|
|
91
98
|
*/
|
|
92
99
|
accept?: string[];
|
|
93
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* The derived folders collection: extra fields, its access (the upload collection's by
|
|
102
|
+
* default) and its hooks.
|
|
103
|
+
*/
|
|
94
104
|
directories?: {
|
|
95
105
|
fields: FieldBuilder<Field>[];
|
|
96
106
|
access?: Access;
|
|
97
107
|
$hooks?: CollectionHooks<any>;
|
|
98
108
|
};
|
|
99
109
|
};
|
|
110
|
+
/**
|
|
111
|
+
* An image size generated on upload. `name` is a column of the collection; `width`, `height` or
|
|
112
|
+
* both set the box; `out` lists the formats written (the original's when empty); `compression`
|
|
113
|
+
* is the quality, 60 by default.
|
|
114
|
+
*/
|
|
100
115
|
export type ImageSizesConfig = {
|
|
101
116
|
name: string;
|
|
102
|
-
/** If none provided, will
|
|
117
|
+
/** If none provided, will fall back to the original file extension */
|
|
103
118
|
out?: Array<'jpg' | 'webp'>;
|
|
104
119
|
/** Default compression: 60 */
|
|
105
120
|
compression?: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export { getExtensionFromMimeType, getMimeTypeFromExtension } from './mime.js';
|
|
1
|
+
/** The upload helpers safe in the browser, published as `upload` in `rimecms/util`. */
|
|
2
|
+
export { getExtensionFromMimeType, getMimeTypeFromExtension, mimeTypesMap } from './mime.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export { getExtensionFromMimeType, getMimeTypeFromExtension } from './mime.js';
|
|
1
|
+
/** The upload helpers safe in the browser, published as `upload` in `rimecms/util`. */
|
|
2
|
+
export { getExtensionFromMimeType, getMimeTypeFromExtension, mimeTypesMap } from './mime.js';
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { type FilesConfig } from '../disk/medias.server.js';
|
|
2
2
|
import type { JsonFile } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* A file sent as JSON, as a `File` with its name, size and type. `base64` is a data URI; the
|
|
5
|
+
* JSON's `mimeType` wins over the URI's, and a type outside `mimeTypesMap` throws "File type not
|
|
6
|
+
* supported", even with a `filename`. Without one, the file is named `file-<timestamp>.<ext>`.
|
|
7
|
+
*/
|
|
3
8
|
export declare const jsonFileToFile: (jsonFile: JsonFile) => {
|
|
4
9
|
filename: string;
|
|
5
10
|
mimeType: string;
|
|
@@ -2,12 +2,15 @@ import { mediaFilePath } from '../disk/medias.server.js';
|
|
|
2
2
|
import { RimeError } from '../../../../errors/index.js';
|
|
3
3
|
import { logger } from '../../../../logger.server.js';
|
|
4
4
|
import { fileSizeToString } from '../../../../../util/file.js';
|
|
5
|
-
import { readFile } from 'fs/promises';
|
|
6
|
-
import fs from 'fs';
|
|
5
|
+
import { readFile, stat } from 'fs/promises';
|
|
7
6
|
import path from 'path';
|
|
8
|
-
import { getExtensionFromMimeType, getMimeTypeFromExtension } from './mime.js';
|
|
7
|
+
import { getExtensionFromMimeType, getMimeTypeFromExtension, servedMimeType } from './mime.js';
|
|
8
|
+
/**
|
|
9
|
+
* A file sent as JSON, as a `File` with its name, size and type. `base64` is a data URI; the
|
|
10
|
+
* JSON's `mimeType` wins over the URI's, and a type outside `mimeTypesMap` throws "File type not
|
|
11
|
+
* supported", even with a `filename`. Without one, the file is named `file-<timestamp>.<ext>`.
|
|
12
|
+
*/
|
|
9
13
|
export const jsonFileToFile = (jsonFile) => {
|
|
10
|
-
// Convert base64 to Blob
|
|
11
14
|
const base64String = jsonFile.base64;
|
|
12
15
|
// Extract the actual base64 content after the data URI prefix
|
|
13
16
|
const base64Content = base64String.split(',')[1];
|
|
@@ -75,30 +78,19 @@ export async function filePathToBase64(filePath) {
|
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
81
|
+
* A file of the uploads folder as a `File`, typed by its extension (`application/octet-stream`
|
|
82
|
+
* for an unknown one). Read without blocking; throws `RimeError.UPLOAD` when the file cannot be
|
|
83
|
+
* read.
|
|
84
|
+
*
|
|
85
|
+
* ```ts
|
|
82
86
|
* const file = await filePathToFile('/path/to/image.jpg');
|
|
87
|
+
* ```
|
|
83
88
|
*/
|
|
84
89
|
async function filePathToFile(filePath) {
|
|
85
90
|
try {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
// Read file stats and content
|
|
91
|
-
const fileStats = fs.statSync(filePath);
|
|
92
|
-
const buffer = fs.readFileSync(filePath);
|
|
93
|
-
// Get filename and extension
|
|
94
|
-
const filename = path.basename(filePath);
|
|
95
|
-
const ext = path.extname(filePath).slice(1).toLowerCase();
|
|
96
|
-
const mimeType = getMimeTypeFromExtension(ext) || 'application/octet-stream';
|
|
97
|
-
// Create a Blob with the file content
|
|
98
|
-
const blob = new Blob([new Uint8Array(buffer)], { type: mimeType });
|
|
99
|
-
// Create and return a File object
|
|
100
|
-
return new File([blob], filename, {
|
|
101
|
-
type: mimeType,
|
|
91
|
+
const [fileStats, buffer] = await Promise.all([stat(filePath), readFile(filePath)]);
|
|
92
|
+
return new File([new Uint8Array(buffer)], path.basename(filePath), {
|
|
93
|
+
type: servedMimeType(path.extname(filePath).slice(1)),
|
|
102
94
|
lastModified: fileStats.mtimeMs
|
|
103
95
|
});
|
|
104
96
|
}
|
|
@@ -1,3 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The file types rime knows, each with its extensions, the canonical one first. A base64 upload
|
|
3
|
+
* of a type outside this map is refused (`jsonFileToFile`).
|
|
4
|
+
*/
|
|
1
5
|
export declare const mimeTypesMap: Record<string, string[]>;
|
|
6
|
+
/**
|
|
7
|
+
* The canonical extension of a type, `null` for an unknown one.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* getExtensionFromMimeType('image/jpeg'); // 'jpg'
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
2
13
|
export declare function getExtensionFromMimeType(mimeType: string): string | null;
|
|
3
14
|
export declare function getMimeTypeFromExtension(extension: string): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* The type a file is served as, by its extension: `application/octet-stream`, which a browser
|
|
17
|
+
* downloads, for an unknown one.
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* servedMimeType('JPG'); // 'image/jpeg'
|
|
21
|
+
* servedMimeType(''); // 'application/octet-stream'
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const servedMimeType: (extension: string) => string;
|
|
25
|
+
/**
|
|
26
|
+
* The types an upload takes only when `upload.accept` lists them: a page or a script a browser
|
|
27
|
+
* runs from the site, and a script a server runs. Every image, video and audio type is taken,
|
|
28
|
+
* SVG included: an `<img>` runs no script of it, and `handleUploads` serves it sandboxed.
|
|
29
|
+
*/
|
|
30
|
+
export declare const RISKY_MIME_TYPES: string[];
|
|
31
|
+
/**
|
|
32
|
+
* Whether an upload of this type may be stored. With `accept`, the listed types only; without
|
|
33
|
+
* it, every type but the risky ones.
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* isAcceptedType('image/png'); // true
|
|
37
|
+
* isAcceptedType('image/svg+xml'); // true
|
|
38
|
+
* isAcceptedType('text/html'); // false
|
|
39
|
+
* isAcceptedType('application/octet-stream'); // true: no extension, or an unknown one
|
|
40
|
+
* isAcceptedType('text/html', ['text/html']); // true
|
|
41
|
+
* isAcceptedType('image/png', ['image/jpeg']); // false
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare const isAcceptedType: (mimeType: string, accept?: string[]) => boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The type an upload named `filename` is stored and served as, from the extension it is saved
|
|
47
|
+
* under, and why it is refused: `null` when `accept` takes it. The server and the panel both ask
|
|
48
|
+
* it, so a file the server refuses is refused in the panel with the same words.
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* uploadType('Photo.JPEG'); // { mimeType: 'image/jpeg', refusal: null }
|
|
52
|
+
* uploadType('scan'); // { mimeType: 'application/octet-stream', refusal: null }
|
|
53
|
+
* uploadType('x.html'); // { mimeType: 'text/html', refusal: '.html is not an accepted file type' }
|
|
54
|
+
* uploadType('scan', ['image/jpeg']); // { …, refusal: 'A file with no extension is not an accepted file type' }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare const uploadType: (filename: string, accept?: string[]) => {
|
|
58
|
+
mimeType: string;
|
|
59
|
+
refusal: null;
|
|
60
|
+
} | {
|
|
61
|
+
mimeType: string;
|
|
62
|
+
refusal: string;
|
|
63
|
+
};
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import { normalizeFileName } from '../../../../../util/file.js';
|
|
2
|
+
/**
|
|
3
|
+
* The file types rime knows, each with its extensions, the canonical one first. A base64 upload
|
|
4
|
+
* of a type outside this map is refused (`jsonFileToFile`).
|
|
5
|
+
*/
|
|
1
6
|
export const mimeTypesMap = {
|
|
2
7
|
// Images
|
|
3
8
|
'image/jpeg': ['jpg', 'jpeg'],
|
|
4
9
|
'image/png': ['png'],
|
|
5
10
|
'image/gif': ['gif'],
|
|
6
11
|
'image/webp': ['webp'],
|
|
7
|
-
'image/svg+xml': ['svg'],
|
|
12
|
+
'image/svg+xml': ['svg', 'svgz'],
|
|
8
13
|
'image/bmp': ['bmp'],
|
|
9
14
|
'image/tiff': ['tif', 'tiff'],
|
|
10
15
|
// Documents
|
|
@@ -17,7 +22,8 @@ export const mimeTypesMap = {
|
|
|
17
22
|
'application/vnd.openxmlformats-officedocument.presentationml.presentation': ['pptx'],
|
|
18
23
|
'text/plain': ['txt'],
|
|
19
24
|
'text/csv': ['csv'],
|
|
20
|
-
'text/html': ['html', 'htm'],
|
|
25
|
+
'text/html': ['html', 'htm', 'shtml'],
|
|
26
|
+
'application/xhtml+xml': ['xhtml', 'xht'],
|
|
21
27
|
// Audio
|
|
22
28
|
'audio/mpeg': ['mp3'],
|
|
23
29
|
'audio/wav': ['wav'],
|
|
@@ -39,9 +45,24 @@ export const mimeTypesMap = {
|
|
|
39
45
|
// Code
|
|
40
46
|
'application/json': ['json'],
|
|
41
47
|
'application/xml': ['xml'],
|
|
42
|
-
'
|
|
48
|
+
'application/xslt+xml': ['xsl', 'xslt'],
|
|
49
|
+
'text/javascript': ['js', 'mjs', 'cjs'],
|
|
43
50
|
'text/css': ['css'],
|
|
44
|
-
'application/x-httpd-php': [
|
|
51
|
+
'application/x-httpd-php': [
|
|
52
|
+
'php',
|
|
53
|
+
'phtml',
|
|
54
|
+
'pht',
|
|
55
|
+
'phps',
|
|
56
|
+
'phar',
|
|
57
|
+
'php3',
|
|
58
|
+
'php4',
|
|
59
|
+
'php5',
|
|
60
|
+
'php7',
|
|
61
|
+
'php8'
|
|
62
|
+
],
|
|
63
|
+
'application/x-asp': ['asp', 'aspx'],
|
|
64
|
+
'application/x-jsp': ['jsp', 'jspx'],
|
|
65
|
+
'application/x-perl': ['pl', 'cgi'],
|
|
45
66
|
'application/x-python-code': ['py'],
|
|
46
67
|
// Fonts
|
|
47
68
|
'font/ttf': ['ttf'],
|
|
@@ -49,6 +70,13 @@ export const mimeTypesMap = {
|
|
|
49
70
|
'font/woff': ['woff'],
|
|
50
71
|
'font/woff2': ['woff2']
|
|
51
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* The canonical extension of a type, `null` for an unknown one.
|
|
75
|
+
*
|
|
76
|
+
* ```ts
|
|
77
|
+
* getExtensionFromMimeType('image/jpeg'); // 'jpg'
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
52
80
|
export function getExtensionFromMimeType(mimeType) {
|
|
53
81
|
const extensions = mimeTypesMap[mimeType];
|
|
54
82
|
return extensions ? extensions[0] : null;
|
|
@@ -64,3 +92,65 @@ export function getMimeTypeFromExtension(extension) {
|
|
|
64
92
|
}
|
|
65
93
|
return null;
|
|
66
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* The type a file is served as, by its extension: `application/octet-stream`, which a browser
|
|
97
|
+
* downloads, for an unknown one.
|
|
98
|
+
*
|
|
99
|
+
* ```ts
|
|
100
|
+
* servedMimeType('JPG'); // 'image/jpeg'
|
|
101
|
+
* servedMimeType(''); // 'application/octet-stream'
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export const servedMimeType = (extension) => getMimeTypeFromExtension(extension) ?? 'application/octet-stream';
|
|
105
|
+
/**
|
|
106
|
+
* The types an upload takes only when `upload.accept` lists them: a page or a script a browser
|
|
107
|
+
* runs from the site, and a script a server runs. Every image, video and audio type is taken,
|
|
108
|
+
* SVG included: an `<img>` runs no script of it, and `handleUploads` serves it sandboxed.
|
|
109
|
+
*/
|
|
110
|
+
export const RISKY_MIME_TYPES = [
|
|
111
|
+
'text/html',
|
|
112
|
+
'application/xhtml+xml',
|
|
113
|
+
'application/xml',
|
|
114
|
+
'application/xslt+xml',
|
|
115
|
+
'text/javascript',
|
|
116
|
+
'application/x-httpd-php',
|
|
117
|
+
'application/x-asp',
|
|
118
|
+
'application/x-jsp',
|
|
119
|
+
'application/x-perl',
|
|
120
|
+
'application/x-python-code'
|
|
121
|
+
];
|
|
122
|
+
/**
|
|
123
|
+
* Whether an upload of this type may be stored. With `accept`, the listed types only; without
|
|
124
|
+
* it, every type but the risky ones.
|
|
125
|
+
*
|
|
126
|
+
* ```ts
|
|
127
|
+
* isAcceptedType('image/png'); // true
|
|
128
|
+
* isAcceptedType('image/svg+xml'); // true
|
|
129
|
+
* isAcceptedType('text/html'); // false
|
|
130
|
+
* isAcceptedType('application/octet-stream'); // true: no extension, or an unknown one
|
|
131
|
+
* isAcceptedType('text/html', ['text/html']); // true
|
|
132
|
+
* isAcceptedType('image/png', ['image/jpeg']); // false
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
export const isAcceptedType = (mimeType, accept) => accept?.length ? accept.includes(mimeType) : !RISKY_MIME_TYPES.includes(mimeType);
|
|
136
|
+
/**
|
|
137
|
+
* The type an upload named `filename` is stored and served as, from the extension it is saved
|
|
138
|
+
* under, and why it is refused: `null` when `accept` takes it. The server and the panel both ask
|
|
139
|
+
* it, so a file the server refuses is refused in the panel with the same words.
|
|
140
|
+
*
|
|
141
|
+
* ```ts
|
|
142
|
+
* uploadType('Photo.JPEG'); // { mimeType: 'image/jpeg', refusal: null }
|
|
143
|
+
* uploadType('scan'); // { mimeType: 'application/octet-stream', refusal: null }
|
|
144
|
+
* uploadType('x.html'); // { mimeType: 'text/html', refusal: '.html is not an accepted file type' }
|
|
145
|
+
* uploadType('scan', ['image/jpeg']); // { …, refusal: 'A file with no extension is not an accepted file type' }
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export const uploadType = (filename, accept) => {
|
|
149
|
+
const { extension } = normalizeFileName(filename);
|
|
150
|
+
const mimeType = servedMimeType(extension);
|
|
151
|
+
if (isAcceptedType(mimeType, accept)) {
|
|
152
|
+
return { mimeType, refusal: null };
|
|
153
|
+
}
|
|
154
|
+
const what = extension ? `.${extension}` : 'A file with no extension';
|
|
155
|
+
return { mimeType, refusal: `${what} is not an accepted file type` };
|
|
156
|
+
};
|
|
@@ -43,15 +43,19 @@ export declare function buildUploadAria({ path, slug, panelSegment }: {
|
|
|
43
43
|
slug: CollectionSlug;
|
|
44
44
|
panelSegment: string;
|
|
45
45
|
}): Partial<Route>[];
|
|
46
|
+
/** Drops the url of the last breadcrumb: the folder on screen is not a link. */
|
|
46
47
|
export declare function removePathFromLastAria(aria: Partial<Route>[]): Partial<Route>[];
|
|
48
|
+
/** A folder name: letters, digits, `-`, `_`, and spaces inside it — `my docs`, never ` docs `. */
|
|
49
|
+
export declare const FOLDER_NAME = "[a-zA-Z0-9\\-_](?:[a-zA-Z0-9\\-_ ]*[a-zA-Z0-9\\-_])?";
|
|
47
50
|
/**
|
|
48
51
|
* Validates that a path string follows the required format:
|
|
49
52
|
* - Must start with ROOT_NAME
|
|
50
|
-
* -
|
|
53
|
+
* - Each folder name follows `FOLDER_NAME`
|
|
51
54
|
* - Can only use the defined separator
|
|
52
55
|
* @example
|
|
53
56
|
* validatePath("root:folder:subfolder") // valid
|
|
54
57
|
* validatePath("root:folder with spaces:sub-folder_name") // valid
|
|
58
|
+
* validatePath("root: folder") // invalid
|
|
55
59
|
* validatePath("root/folder") // invalid
|
|
56
60
|
* validatePath("root:folder$") // invalid
|
|
57
61
|
*/
|