@antelopejs/dms-media 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +190 -0
- package/README.md +114 -0
- package/dist/acl/defaults.d.ts +2 -0
- package/dist/acl/defaults.js +19 -0
- package/dist/acl/defaults.js.map +1 -0
- package/dist/acl/entries.d.ts +4 -0
- package/dist/acl/entries.js +21 -0
- package/dist/acl/entries.js.map +1 -0
- package/dist/acl/grantable.d.ts +1 -0
- package/dist/acl/grantable.js +11 -0
- package/dist/acl/grantable.js.map +1 -0
- package/dist/acl/index.d.ts +4 -0
- package/dist/acl/index.js +21 -0
- package/dist/acl/index.js.map +1 -0
- package/dist/acl/resolver.d.ts +15 -0
- package/dist/acl/resolver.js +115 -0
- package/dist/acl/resolver.js.map +1 -0
- package/dist/asset-lifecycle.d.ts +6 -0
- package/dist/asset-lifecycle.js +78 -0
- package/dist/asset-lifecycle.js.map +1 -0
- package/dist/asset-type/asset-type.d.ts +24 -0
- package/dist/asset-type/asset-type.js +54 -0
- package/dist/asset-type/asset-type.js.map +1 -0
- package/dist/asset-type/bindings.d.ts +19 -0
- package/dist/asset-type/bindings.js +116 -0
- package/dist/asset-type/bindings.js.map +1 -0
- package/dist/asset-type/index.d.ts +2 -0
- package/dist/asset-type/index.js +19 -0
- package/dist/asset-type/index.js.map +1 -0
- package/dist/config.d.ts +15 -0
- package/dist/config.js +24 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.js +10 -0
- package/dist/constants.js.map +1 -0
- package/dist/crons/index.d.ts +3 -0
- package/dist/crons/index.js +23 -0
- package/dist/crons/index.js.map +1 -0
- package/dist/crons/sweep-derivatives.d.ts +6 -0
- package/dist/crons/sweep-derivatives.js +63 -0
- package/dist/crons/sweep-derivatives.js.map +1 -0
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.js +19 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/models/index.d.ts +2 -0
- package/dist/db/models/index.js +19 -0
- package/dist/db/models/index.js.map +1 -0
- package/dist/db/models/mediaAssets.model.d.ts +26 -0
- package/dist/db/models/mediaAssets.model.js +58 -0
- package/dist/db/models/mediaAssets.model.js.map +1 -0
- package/dist/db/models/mediaFolders.model.d.ts +25 -0
- package/dist/db/models/mediaFolders.model.js +27 -0
- package/dist/db/models/mediaFolders.model.js.map +1 -0
- package/dist/db/tables/index.d.ts +2 -0
- package/dist/db/tables/index.js +19 -0
- package/dist/db/tables/index.js.map +1 -0
- package/dist/db/tables/mediaAssets.table.d.ts +24 -0
- package/dist/db/tables/mediaAssets.table.js +105 -0
- package/dist/db/tables/mediaAssets.table.js.map +1 -0
- package/dist/db/tables/mediaFolders.table.d.ts +14 -0
- package/dist/db/tables/mediaFolders.table.js +65 -0
- package/dist/db/tables/mediaFolders.table.js.map +1 -0
- package/dist/derivatives.d.ts +12 -0
- package/dist/derivatives.js +166 -0
- package/dist/derivatives.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/dist/pages/index.d.ts +1 -0
- package/dist/pages/index.js +18 -0
- package/dist/pages/index.js.map +1 -0
- package/dist/pages/media.d.ts +10 -0
- package/dist/pages/media.js +35 -0
- package/dist/pages/media.js.map +1 -0
- package/dist/permissions.d.ts +1 -0
- package/dist/permissions.js +37 -0
- package/dist/permissions.js.map +1 -0
- package/dist/presets.d.ts +15 -0
- package/dist/presets.js +48 -0
- package/dist/presets.js.map +1 -0
- package/dist/routes/index.d.ts +1 -0
- package/dist/routes/index.js +18 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/media/assets.d.ts +48 -0
- package/dist/routes/media/assets.js +263 -0
- package/dist/routes/media/assets.js.map +1 -0
- package/dist/routes/media/constants.d.ts +5 -0
- package/dist/routes/media/constants.js +12 -0
- package/dist/routes/media/constants.js.map +1 -0
- package/dist/routes/media/context.d.ts +49 -0
- package/dist/routes/media/context.js +95 -0
- package/dist/routes/media/context.js.map +1 -0
- package/dist/routes/media/delivery.d.ts +14 -0
- package/dist/routes/media/delivery.js +123 -0
- package/dist/routes/media/delivery.js.map +1 -0
- package/dist/routes/media/dto.d.ts +43 -0
- package/dist/routes/media/dto.js +66 -0
- package/dist/routes/media/dto.js.map +1 -0
- package/dist/routes/media/folders.d.ts +46 -0
- package/dist/routes/media/folders.js +259 -0
- package/dist/routes/media/folders.js.map +1 -0
- package/dist/routes/media/index.d.ts +9 -0
- package/dist/routes/media/index.js +26 -0
- package/dist/routes/media/index.js.map +1 -0
- package/dist/routes/media/storage-keys.d.ts +3 -0
- package/dist/routes/media/storage-keys.js +19 -0
- package/dist/routes/media/storage-keys.js.map +1 -0
- package/dist/routes/media/transform.d.ts +21 -0
- package/dist/routes/media/transform.js +99 -0
- package/dist/routes/media/transform.js.map +1 -0
- package/dist/routes/media/upload.d.ts +24 -0
- package/dist/routes/media/upload.js +145 -0
- package/dist/routes/media/upload.js.map +1 -0
- package/dist/test/antelope.test.d.ts +2 -0
- package/dist/test/antelope.test.js +202 -0
- package/dist/test/antelope.test.js.map +1 -0
- package/dist/test/helpers/assets.d.ts +21 -0
- package/dist/test/helpers/assets.js +61 -0
- package/dist/test/helpers/assets.js.map +1 -0
- package/dist/test/helpers/http.d.ts +4 -0
- package/dist/test/helpers/http.js +28 -0
- package/dist/test/helpers/http.js.map +1 -0
- package/dist/test/helpers/members.d.ts +10 -0
- package/dist/test/helpers/members.js +57 -0
- package/dist/test/helpers/members.js.map +1 -0
- package/dist/test/helpers/owner.d.ts +5 -0
- package/dist/test/helpers/owner.js +30 -0
- package/dist/test/helpers/owner.js.map +1 -0
- package/dist/test/integration/derivative-sweep-query.test.d.ts +1 -0
- package/dist/test/integration/derivative-sweep-query.test.js +61 -0
- package/dist/test/integration/derivative-sweep-query.test.js.map +1 -0
- package/dist/test/integration/folder-query.test.d.ts +1 -0
- package/dist/test/integration/folder-query.test.js +88 -0
- package/dist/test/integration/folder-query.test.js.map +1 -0
- package/dist/test/integration/media-api.test.d.ts +1 -0
- package/dist/test/integration/media-api.test.js +178 -0
- package/dist/test/integration/media-api.test.js.map +1 -0
- package/dist/test/integration/media-bindings.test.d.ts +1 -0
- package/dist/test/integration/media-bindings.test.js +141 -0
- package/dist/test/integration/media-bindings.test.js.map +1 -0
- package/dist/test/integration/media-cleanup.test.d.ts +1 -0
- package/dist/test/integration/media-cleanup.test.js +282 -0
- package/dist/test/integration/media-cleanup.test.js.map +1 -0
- package/dist/test/integration/media-delivery.test.d.ts +1 -0
- package/dist/test/integration/media-delivery.test.js +108 -0
- package/dist/test/integration/media-delivery.test.js.map +1 -0
- package/dist/test/integration/media-guards.test.d.ts +1 -0
- package/dist/test/integration/media-guards.test.js +128 -0
- package/dist/test/integration/media-guards.test.js.map +1 -0
- package/dist/test/integration/media-list-query.test.d.ts +1 -0
- package/dist/test/integration/media-list-query.test.js +86 -0
- package/dist/test/integration/media-list-query.test.js.map +1 -0
- package/dist/test/integration/media-permissions.test.d.ts +1 -0
- package/dist/test/integration/media-permissions.test.js +549 -0
- package/dist/test/integration/media-permissions.test.js.map +1 -0
- package/dist/test/integration/media-search-query.test.d.ts +1 -0
- package/dist/test/integration/media-search-query.test.js +100 -0
- package/dist/test/integration/media-search-query.test.js.map +1 -0
- package/dist/test/integration/media-transform.test.d.ts +1 -0
- package/dist/test/integration/media-transform.test.js +125 -0
- package/dist/test/integration/media-transform.test.js.map +1 -0
- package/dist/test/integration/setup.test.d.ts +1 -0
- package/dist/test/integration/setup.test.js +32 -0
- package/dist/test/integration/setup.test.js.map +1 -0
- package/dist/test/unit/acl/entries.test.d.ts +1 -0
- package/dist/test/unit/acl/entries.test.js +46 -0
- package/dist/test/unit/acl/entries.test.js.map +1 -0
- package/dist/test/unit/acl/grantable.test.d.ts +1 -0
- package/dist/test/unit/acl/grantable.test.js +41 -0
- package/dist/test/unit/acl/grantable.test.js.map +1 -0
- package/dist/test/unit/acl/resolver.test.d.ts +1 -0
- package/dist/test/unit/acl/resolver.test.js +183 -0
- package/dist/test/unit/acl/resolver.test.js.map +1 -0
- package/dist/test/unit/asset-type/bindings.test.d.ts +1 -0
- package/dist/test/unit/asset-type/bindings.test.js +127 -0
- package/dist/test/unit/asset-type/bindings.test.js.map +1 -0
- package/dist/test/unit/config.test.d.ts +1 -0
- package/dist/test/unit/config.test.js +38 -0
- package/dist/test/unit/config.test.js.map +1 -0
- package/dist/test/unit/derivatives.test.d.ts +1 -0
- package/dist/test/unit/derivatives.test.js +41 -0
- package/dist/test/unit/derivatives.test.js.map +1 -0
- package/dist/test/unit/routes/dto.test.d.ts +1 -0
- package/dist/test/unit/routes/dto.test.js +34 -0
- package/dist/test/unit/routes/dto.test.js.map +1 -0
- package/dist/test/unit/transform.test.d.ts +1 -0
- package/dist/test/unit/transform.test.js +37 -0
- package/dist/test/unit/transform.test.js.map +1 -0
- package/dist/transform.d.ts +22 -0
- package/dist/transform.js +117 -0
- package/dist/transform.js.map +1 -0
- package/dist/types.d.ts +12 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/validation/media.schema.d.ts +221 -0
- package/dist/validation/media.schema.js +94 -0
- package/dist/validation/media.schema.js.map +1 -0
- package/frontend-vue/.editorconfig +12 -0
- package/frontend-vue/.prettierrc +11 -0
- package/frontend-vue/app/components/AssetPicker.vue +272 -0
- package/frontend-vue/app/components/Library.vue +21 -0
- package/frontend-vue/app/components/PickerModal.vue +47 -0
- package/frontend-vue/app/components/StorageOverview.vue +105 -0
- package/frontend-vue/app/components/finder/Modal.vue +41 -0
- package/frontend-vue/app/components/finder/Root.vue +72 -0
- package/frontend-vue/app/components/finder/components/DeleteFolderConfirm.vue +55 -0
- package/frontend-vue/app/components/finder/components/EditImage.vue +157 -0
- package/frontend-vue/app/components/finder/components/Empty.vue +13 -0
- package/frontend-vue/app/components/finder/components/FilterMenu.vue +115 -0
- package/frontend-vue/app/components/finder/components/Preview.vue +35 -0
- package/frontend-vue/app/components/finder/components/search-file.vue +24 -0
- package/frontend-vue/app/components/finder/core/panel.vue +132 -0
- package/frontend-vue/app/components/finder/core/toolbar.vue +55 -0
- package/frontend-vue/app/components/finder/index.vue +87 -0
- package/frontend-vue/app/components/finder/layout/Footer.vue +97 -0
- package/frontend-vue/app/components/finder/layout/Header.vue +16 -0
- package/frontend-vue/app/components/finder/layout/navigation/Breadcrumbs.vue +114 -0
- package/frontend-vue/app/components/finder/layout/navigation/index.vue +40 -0
- package/frontend-vue/app/components/finder/layout/panel/Details.vue +192 -0
- package/frontend-vue/app/components/finder/layout/panel/Shortcuts.vue +265 -0
- package/frontend-vue/app/components/finder/layout/panel/Toogle.vue +27 -0
- package/frontend-vue/app/components/finder/layout/view/Column.vue +180 -0
- package/frontend-vue/app/components/finder/layout/view/Grid.vue +37 -0
- package/frontend-vue/app/components/finder/layout/view/List.vue +289 -0
- package/frontend-vue/app/components/finder/layout/view/Toggle.vue +27 -0
- package/frontend-vue/app/components/finder/layout/view/card/Column.vue +182 -0
- package/frontend-vue/app/components/finder/layout/view/card/Ghost.vue +46 -0
- package/frontend-vue/app/components/finder/layout/view/card/Grid.vue +219 -0
- package/frontend-vue/app/components/finder/layout/view/card/Input.vue +63 -0
- package/frontend-vue/app/components/finder/layout/view/card/List.vue +29 -0
- package/frontend-vue/app/components/finder/layout/view/index.vue +80 -0
- package/frontend-vue/app/components/picker/PickerColumnsView.vue +170 -0
- package/frontend-vue/app/components/picker/PickerDeleteConfirm.vue +62 -0
- package/frontend-vue/app/components/picker/PickerExplorer.vue +436 -0
- package/frontend-vue/app/components/picker/PickerGridView.vue +136 -0
- package/frontend-vue/app/components/picker/PickerItemThumb.vue +49 -0
- package/frontend-vue/app/components/picker/PickerLightbox.vue +158 -0
- package/frontend-vue/app/components/picker/PickerListView.vue +188 -0
- package/frontend-vue/app/components/picker/PickerMoveDialog.vue +115 -0
- package/frontend-vue/app/components/picker/PickerNameEdit.vue +50 -0
- package/frontend-vue/app/components/picker/PickerPreviewBody.vue +109 -0
- package/frontend-vue/app/components/picker/PickerPreviewPane.vue +21 -0
- package/frontend-vue/app/components/picker/PickerSidebar.vue +87 -0
- package/frontend-vue/app/components/picker/PickerToolbar.vue +142 -0
- package/frontend-vue/app/composables/finder/actions/useDeselectOnOutsideClick.ts +40 -0
- package/frontend-vue/app/composables/finder/actions/useDraggableItem.ts +102 -0
- package/frontend-vue/app/composables/finder/actions/useDropTarget.ts +81 -0
- package/frontend-vue/app/composables/finder/actions/useFileUpload.ts +45 -0
- package/frontend-vue/app/composables/finder/actions/useRowDragState.ts +47 -0
- package/frontend-vue/app/composables/finder/actions/useSelectionClick.ts +53 -0
- package/frontend-vue/app/composables/finder/api/useMediaApi.ts +135 -0
- package/frontend-vue/app/composables/finder/context/useFinderContext.ts +55 -0
- package/frontend-vue/app/composables/finder/context/useFinderDragAndDrop.ts +66 -0
- package/frontend-vue/app/composables/finder/context/useFinderHooks.ts +93 -0
- package/frontend-vue/app/composables/finder/context/useFinderLayout.ts +191 -0
- package/frontend-vue/app/composables/finder/context/useFinderNavigation.ts +36 -0
- package/frontend-vue/app/composables/finder/context/useFinderPicker.ts +22 -0
- package/frontend-vue/app/composables/finder/context/useFinderSelect.ts +72 -0
- package/frontend-vue/app/composables/finder/hooks/file.ts +86 -0
- package/frontend-vue/app/composables/finder/hooks/finder.ts +25 -0
- package/frontend-vue/app/composables/finder/hooks/folder.ts +66 -0
- package/frontend-vue/app/composables/finder/hooks/navigation.ts +64 -0
- package/frontend-vue/app/composables/finder/hooks/selection.ts +31 -0
- package/frontend-vue/app/composables/finder/menu/useContextMenu.ts +180 -0
- package/frontend-vue/app/composables/finder/menu/useFinderMenu.ts +41 -0
- package/frontend-vue/app/composables/finder/menu/useItemMenu.ts +114 -0
- package/frontend-vue/app/composables/finder/shortcuts/finderEscape.ts +9 -0
- package/frontend-vue/app/composables/finder/shortcuts/finderShiftA.ts +9 -0
- package/frontend-vue/app/composables/finder/sidebar/useFavoritesFolder.ts +110 -0
- package/frontend-vue/app/composables/finder/sidebar/useFolderSize.ts +49 -0
- package/frontend-vue/app/composables/finder/sidebar/useRecentFile.ts +20 -0
- package/frontend-vue/app/composables/finder/store/useFinderStore.ts +354 -0
- package/frontend-vue/app/composables/picker/usePickerExplorer.ts +788 -0
- package/frontend-vue/app/config/shortcuts-registry.ts +8 -0
- package/frontend-vue/app/types/finder.ts +47 -0
- package/frontend-vue/app/utils/finder/context.ts +25 -0
- package/frontend-vue/app/utils/finder/filegroup.ts +79 -0
- package/frontend-vue/app/utils/finder/filesize.ts +15 -0
- package/frontend-vue/app/utils/finder/formatter.ts +66 -0
- package/frontend-vue/app/utils/finder/helpers.ts +105 -0
- package/frontend-vue/app/utils/finder/mime.ts +108 -0
- package/frontend-vue/app/utils/finder/models.ts +153 -0
- package/frontend-vue/app/utils/finder/shortcuts.ts +29 -0
- package/frontend-vue/dms.frontend.ts +45 -0
- package/frontend-vue/eslint.config.mjs +16 -0
- package/frontend-vue/i18n/locales/media-en-GB.json +191 -0
- package/frontend-vue/i18n/locales/media-fr-FR.json +191 -0
- package/frontend-vue/package.json +35 -0
- package/frontend-vue/pnpm-lock.yaml +6074 -0
- package/frontend-vue/pnpm-workspace.yaml +2 -0
- package/frontend-vue/tests/registration.test.ts +36 -0
- package/frontend-vue/tsconfig.json +13 -0
- package/frontend-vue/vitest.config.ts +5 -0
- package/package.json +83 -0
- package/src/acl/defaults.ts +21 -0
- package/src/acl/entries.ts +19 -0
- package/src/acl/grantable.ts +11 -0
- package/src/acl/index.ts +4 -0
- package/src/acl/resolver.ts +159 -0
- package/src/asset-lifecycle.ts +100 -0
- package/src/asset-type/asset-type.ts +61 -0
- package/src/asset-type/bindings.ts +182 -0
- package/src/asset-type/index.ts +2 -0
- package/src/config.ts +38 -0
- package/src/constants.ts +8 -0
- package/src/crons/index.ts +8 -0
- package/src/crons/sweep-derivatives.ts +68 -0
- package/src/db/index.ts +2 -0
- package/src/db/models/index.ts +2 -0
- package/src/db/models/mediaAssets.model.ts +72 -0
- package/src/db/models/mediaFolders.model.ts +28 -0
- package/src/db/tables/index.ts +2 -0
- package/src/db/tables/mediaAssets.table.ts +83 -0
- package/src/db/tables/mediaFolders.table.ts +52 -0
- package/src/derivatives.ts +227 -0
- package/src/index.ts +52 -0
- package/src/pages/index.ts +1 -0
- package/src/pages/media.ts +39 -0
- package/src/permissions.ts +44 -0
- package/src/presets.ts +61 -0
- package/src/routes/index.ts +1 -0
- package/src/routes/media/assets.ts +278 -0
- package/src/routes/media/constants.ts +18 -0
- package/src/routes/media/context.ts +181 -0
- package/src/routes/media/delivery.ts +174 -0
- package/src/routes/media/dto.ts +116 -0
- package/src/routes/media/folders.ts +279 -0
- package/src/routes/media/index.ts +9 -0
- package/src/routes/media/storage-keys.ts +15 -0
- package/src/routes/media/transform.ts +96 -0
- package/src/routes/media/upload.ts +161 -0
- package/src/test/antelope.test.ts +211 -0
- package/src/test/helpers/assets.ts +95 -0
- package/src/test/helpers/http.ts +23 -0
- package/src/test/helpers/members.ts +78 -0
- package/src/test/helpers/owner.ts +37 -0
- package/src/test/integration/derivative-sweep-query.test.ts +65 -0
- package/src/test/integration/folder-query.test.ts +95 -0
- package/src/test/integration/media-api.test.ts +232 -0
- package/src/test/integration/media-bindings.test.ts +175 -0
- package/src/test/integration/media-cleanup.test.ts +320 -0
- package/src/test/integration/media-delivery.test.ts +136 -0
- package/src/test/integration/media-guards.test.ts +132 -0
- package/src/test/integration/media-list-query.test.ts +98 -0
- package/src/test/integration/media-permissions.test.ts +914 -0
- package/src/test/integration/media-search-query.test.ts +124 -0
- package/src/test/integration/media-transform.test.ts +181 -0
- package/src/test/integration/setup.test.ts +35 -0
- package/src/test/unit/acl/entries.test.ts +58 -0
- package/src/test/unit/acl/grantable.test.ts +54 -0
- package/src/test/unit/acl/resolver.test.ts +283 -0
- package/src/test/unit/asset-type/bindings.test.ts +141 -0
- package/src/test/unit/config.test.ts +44 -0
- package/src/test/unit/derivatives.test.ts +54 -0
- package/src/test/unit/routes/dto.test.ts +65 -0
- package/src/test/unit/transform.test.ts +51 -0
- package/src/transform.ts +183 -0
- package/src/types.ts +17 -0
- package/src/validation/media.schema.ts +117 -0
- package/tsconfig.json +29 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright (c) 2025-present - AntelopeJS Team
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# @antelopejs/dms-media
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<a href="https://www.npmjs.com/package/@antelopejs/dms-media"><img alt="NPM version" src="https://img.shields.io/npm/v/@antelopejs/dms-media.svg?style=for-the-badge&labelColor=000000"></a>
|
|
5
|
+
<a href="./LICENSE"><img alt="License" src="https://img.shields.io/badge/license-Apache--2.0-blue?style=for-the-badge&labelColor=000000"></a>
|
|
6
|
+
<a href="https://discord.gg/sjK28QHrA7"><img src="https://img.shields.io/badge/Discord-18181B?logo=discord&style=for-the-badge&color=000000" alt="Discord"></a>
|
|
7
|
+
<a href="https://antelopejs.com"><img src="https://img.shields.io/badge/Docs-18181B?style=for-the-badge&color=000000" alt="Documentation"></a>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
AntelopeJS DMS module providing an asset/media library: upload, folders, delivery derivatives and light image editing, with per-folder permissions that reuse the DMS authorization system. Ships a Finder-style file explorer (frontend) and an `AssetType` field to reference library assets from forms.
|
|
11
|
+
|
|
12
|
+
See [docs/PRD.md](./docs/PRD.md) for the architecture and product spec, and [AGENTS.md](./AGENTS.md) for code conventions.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
ajs project modules add @antelopejs/dms-media
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
- **Folder tree with per-folder ACL** — every folder can carry its own ACL (`AclEntry[]`), otherwise it inherits from its parent (root falls back to the configurable `rootAcl`). Entries grant `read`/`write`/`manage` rights to either a **permission id** (anyone holding e.g. `articles.page.table.edit`) or a **role id**. Rights imply weaker ones (`manage ⇒ write ⇒ read`). Ancestors of a readable folder are returned as **traverse-only shells** (name visible, content never listed).
|
|
23
|
+
- **Single data path** — listing, search, picker and delivery all resolve the same `readable`/`writable`/`manageable` sets per request; nothing bypasses the ACL.
|
|
24
|
+
- **Direct-to-storage uploads** — `presign` (staged) → client `PUT` → `confirm` (promote + DB row + sharp dimension probe). Bytes never transit through Node.
|
|
25
|
+
- **Stable delivery URLs** — `GET /media/:assetId/:filename` 302-redirects to a signed storage URL: long-lived and CDN-cacheable for public assets, short-lived `no-store` after auth + folder read check for private ones. Visibility (asset override → folder → private) is a flag flip; URLs never change.
|
|
26
|
+
- **Lazy image derivatives** — named presets (config) rendered by sharp on first request, cached in storage under a config-hashed cache key, served via `GET /media/:assetId/:presetId/:filename` and the authenticated `read-url` endpoint. Changing a preset invalidates naturally (new hash); a daily cron sweeps stale keys.
|
|
27
|
+
- **Server-side image editing** — `transform` (normalized crop, 90° rotations) and `revert`; the pristine original is preserved on first edit and derivatives are invalidated.
|
|
28
|
+
- **`AssetType` form field** — registers the `asset` data type whose widget (`DmsMediaAssetPicker`) opens the Finder as a picker. Declaring a `binding` auto-provisions a linked folder under the `Content` root (idempotency key = binding id) whose ACL derives from the declared permission mapping; linked folders cannot be renamed, moved, deleted or re-ACLed through the API.
|
|
29
|
+
- **Media page** — root `Media` nav category with the `Library` page (full-page Finder), guarded by the `media.access` permission.
|
|
30
|
+
|
|
31
|
+
## Static permissions
|
|
32
|
+
|
|
33
|
+
| Permission | Effect |
|
|
34
|
+
|---|---|
|
|
35
|
+
| `media.access` | See the Media page; grants `read` at the root via the default root ACL |
|
|
36
|
+
| `media.upload` | Grants `write` at the root via the default root ACL |
|
|
37
|
+
| `media.folders.manage` | Grants `manage` at the root via the default root ACL; always kept in control of linked folders |
|
|
38
|
+
| `media.permissions.manage` | Global gate for editing folder ACLs and flipping visibility |
|
|
39
|
+
|
|
40
|
+
Per-folder rights are the single authority for operations: upload requires `write` on the target folder, folder structure changes require `manage`, ACL/visibility edits additionally require `media.permissions.manage`.
|
|
41
|
+
|
|
42
|
+
## Module configuration
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"dms-media": {
|
|
47
|
+
"config": {
|
|
48
|
+
"storage": "media",
|
|
49
|
+
"rootAcl": [
|
|
50
|
+
{ "subject": { "kind": "permission", "id": "media.access" }, "rights": ["read"] }
|
|
51
|
+
],
|
|
52
|
+
"presets": [
|
|
53
|
+
{ "id": "thumb", "width": 300, "height": 300, "fit": "cover", "format": "webp", "quality": 80 }
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
All keys are optional: `storage` selects a named `interface-file-storage` backend (default storage otherwise), `rootAcl` replaces the default root ACL, `presets` replaces the default `thumb`/`preview` presets. Keep a `thumb` preset — the Finder uses it for grid thumbnails.
|
|
61
|
+
|
|
62
|
+
## Declaring an AssetType field
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { AssetType } from "@antelopejs/dms-media";
|
|
66
|
+
|
|
67
|
+
new AssetType({
|
|
68
|
+
multiple: true,
|
|
69
|
+
max: 4,
|
|
70
|
+
mimetypes: ["image/*"],
|
|
71
|
+
binding: {
|
|
72
|
+
id: "articles.cover",
|
|
73
|
+
folderName: "Article covers",
|
|
74
|
+
permissionMapping: {
|
|
75
|
+
read: ["articles.page"],
|
|
76
|
+
write: ["articles.page.table.edit", "articles.page.table.add"],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
When the field lives on a DMS page, `permissionsFromPage` derives the mapping from that page's effective permission instead of duplicating its id — pass the page class itself (`permissionsFromPage: ArticlesPage`); resolution happens lazily at folder provisioning, and explicit `permissionMapping` entries still win per right (an empty array opts that right out of the fallback).
|
|
83
|
+
|
|
84
|
+
Consumer modules should declare `@antelopejs/dms-media` as an AntelopeJS dependency so imports resolve to the runtime singleton (the module lists itself in `antelopeJs.implements`).
|
|
85
|
+
|
|
86
|
+
## HTTP surface
|
|
87
|
+
|
|
88
|
+
- `GET /api/media/tree`, `GET /api/media/folders/:id/assets|acl`
|
|
89
|
+
- `POST /api/media/folders`, `POST /api/media/folders/:id/rename|move|visibility`, `PUT /api/media/folders/:id/acl`, `DELETE /api/media/folders/:id`
|
|
90
|
+
- `GET /api/media/assets`, `GET /api/media/assets/search`, `GET /api/media/assets/:id`, `GET /api/media/assets/:id/read-url?preset=`
|
|
91
|
+
- `POST /api/media/assets/:id/update|move|visibility|transform|revert`, `DELETE /api/media/assets/:id`
|
|
92
|
+
- `POST /api/media/upload/presign`, `POST /api/media/upload/confirm`, `POST /api/media/previews`
|
|
93
|
+
- Public delivery: `GET /media/:assetId/:filename`, `GET /media/:assetId/:presetId/:filename`
|
|
94
|
+
|
|
95
|
+
## Development
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pnpm install
|
|
99
|
+
pnpm dev # backend, via playground (ajs project run -w -p playground)
|
|
100
|
+
pnpm frontend:dev # Vue 3 Inertia frontend, from playground (ajs-dms dev)
|
|
101
|
+
pnpm test # build + full mocha suite (unit + HTTP integration)
|
|
102
|
+
pnpm test:unit # resolver / bindings / derivatives unit tests only
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The frontend entry is `frontend-vue/dms.frontend.ts`. It registers the existing `DmsMedia` and nested `Finder` component names. Use relative imports for module-local files because the Inertia adapter copies the frontend separately from the backend. The adapter discovers locale files and `app/config/shortcuts-registry.ts`; no Nuxt installation is required.
|
|
106
|
+
|
|
107
|
+
The playground uses the `@antelopejs/dms-frontend` CLI. Run `pnpm --dir frontend-vue install` and `pnpm --dir frontend-vue test` for frontend tests. Set `DMS_FRONTEND_WORKSPACE` to the generated Inertia workspace before running `pnpm --dir frontend-vue typecheck`.
|
|
108
|
+
|
|
109
|
+
## Known limitations (v1)
|
|
110
|
+
|
|
111
|
+
- Abandoned staged uploads are expired by the storage backend (e.g. S3 lifecycle rule on the `__staging__/` prefix), not by this module — `interface-file-storage` exposes no listing.
|
|
112
|
+
- Multi-user ACL scenarios are covered by resolver unit tests; HTTP integration tests run as the owner because the DMS invite flow does not expose invite tokens over HTTP (see the DMS module's `TESTING.md` for the matching upstream limitation).
|
|
113
|
+
- Folder visibility applies to the folder's direct assets (no recursive visibility inheritance); assets inherit or override individually.
|
|
114
|
+
- Cover cropping is centred (no focal point) and reference counting ("used in N records") is out of scope — see the PRD's v2 list.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_ROOT_ACL = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
exports.DEFAULT_ROOT_ACL = [
|
|
6
|
+
{
|
|
7
|
+
subject: { kind: "permission", id: constants_1.MEDIA_ACCESS_PERMISSION },
|
|
8
|
+
rights: ["read"],
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
subject: { kind: "permission", id: constants_1.MEDIA_UPLOAD_PERMISSION },
|
|
12
|
+
rights: ["write"],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
subject: { kind: "permission", id: constants_1.MEDIA_FOLDERS_MANAGE_PERMISSION },
|
|
16
|
+
rights: ["manage"],
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/acl/defaults.ts"],"names":[],"mappings":";;;AAAA,4CAIsB;AAGT,QAAA,gBAAgB,GAAe;IAC1C;QACE,OAAO,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,mCAAuB,EAAE;QAC5D,MAAM,EAAE,CAAC,MAAM,CAAC;KACjB;IACD;QACE,OAAO,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,mCAAuB,EAAE;QAC5D,MAAM,EAAE,CAAC,OAAO,CAAC;KAClB;IACD;QACE,OAAO,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,2CAA+B,EAAE;QACpE,MAAM,EAAE,CAAC,QAAQ,CAAC;KACnB;CACF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseFolderAcl = parseFolderAcl;
|
|
4
|
+
exports.serializeAcl = serializeAcl;
|
|
5
|
+
function parseFolderAcl(folder) {
|
|
6
|
+
if (!folder.json_acl)
|
|
7
|
+
return undefined;
|
|
8
|
+
try {
|
|
9
|
+
const parsed = JSON.parse(folder.json_acl);
|
|
10
|
+
return Array.isArray(parsed) ? parsed : undefined;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function serializeAcl(entries) {
|
|
17
|
+
if (!entries)
|
|
18
|
+
return undefined;
|
|
19
|
+
return JSON.stringify(entries);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=entries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entries.js","sourceRoot":"","sources":["../../src/acl/entries.ts"],"names":[],"mappings":";;AAGA,wCAQC;AAED,oCAKC;AAfD,SAAgB,cAAc,CAAC,MAAmB;IAChD,IAAI,CAAC,MAAM,CAAC,QAAQ;QAAE,OAAO,SAAS,CAAC;IACvC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC3C,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,MAAqB,CAAC,CAAC,CAAC,SAAS,CAAC;IACpE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAgB,YAAY,CAC1B,OAA+B;IAE/B,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function filterGrantablePermissions(permissions: Set<string>): Set<string>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterGrantablePermissions = filterGrantablePermissions;
|
|
4
|
+
const permissions_1 = require("@antelopejs/interface-dms/permissions");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
function filterGrantablePermissions(permissions) {
|
|
7
|
+
if (permissions.has(constants_1.OWNER_WILDCARD_PERMISSION))
|
|
8
|
+
return permissions;
|
|
9
|
+
return new Set([...permissions].filter((id) => !(0, permissions_1.IsModuleScopedPermission)(id)));
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=grantable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grantable.js","sourceRoot":"","sources":["../../src/acl/grantable.ts"],"names":[],"mappings":";;AAGA,gEAOC;AAVD,uEAAiF;AACjF,4CAAyD;AAEzD,SAAgB,0BAA0B,CACxC,WAAwB;IAExB,IAAI,WAAW,CAAC,GAAG,CAAC,qCAAyB,CAAC;QAAE,OAAO,WAAW,CAAC;IACnE,OAAO,IAAI,GAAG,CACZ,CAAC,GAAG,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAA,sCAAwB,EAAC,EAAE,CAAC,CAAC,CAC/D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./defaults"), exports);
|
|
18
|
+
__exportStar(require("./entries"), exports);
|
|
19
|
+
__exportStar(require("./grantable"), exports);
|
|
20
|
+
__exportStar(require("./resolver"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/acl/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,4CAA0B;AAC1B,8CAA4B;AAC5B,6CAA2B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MediaFolder } from "../db/tables";
|
|
2
|
+
import type { AclEntry, AclRight } from "../types";
|
|
3
|
+
export interface AclActor {
|
|
4
|
+
permissions: ReadonlySet<string>;
|
|
5
|
+
roleIds: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
export interface FolderAccess {
|
|
8
|
+
readable: Set<string>;
|
|
9
|
+
writable: Set<string>;
|
|
10
|
+
manageable: Set<string>;
|
|
11
|
+
shells: Set<string>;
|
|
12
|
+
}
|
|
13
|
+
export declare function resolveRootRights(actor: AclActor, rootAcl: readonly AclEntry[]): Set<AclRight>;
|
|
14
|
+
export declare function evaluateAclEntries(entries: readonly AclEntry[], actor: AclActor): Set<AclRight>;
|
|
15
|
+
export declare function resolveFolderAccess(folders: readonly MediaFolder[], actor: AclActor, rootAcl: readonly AclEntry[]): FolderAccess;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveRootRights = resolveRootRights;
|
|
4
|
+
exports.evaluateAclEntries = evaluateAclEntries;
|
|
5
|
+
exports.resolveFolderAccess = resolveFolderAccess;
|
|
6
|
+
const constants_1 = require("../constants");
|
|
7
|
+
const entries_1 = require("./entries");
|
|
8
|
+
const ALL_RIGHTS = ["read", "write", "manage"];
|
|
9
|
+
const RIGHT_IMPLICATIONS = {
|
|
10
|
+
read: ["read"],
|
|
11
|
+
write: ["read", "write"],
|
|
12
|
+
manage: ["read", "write", "manage"],
|
|
13
|
+
};
|
|
14
|
+
const SUBJECT_MATCHERS = {
|
|
15
|
+
permission: (id, actor) => actor.permissions.has(constants_1.OWNER_WILDCARD_PERMISSION) ||
|
|
16
|
+
actor.permissions.has(id),
|
|
17
|
+
role: (id, actor) => actor.roleIds.includes(id),
|
|
18
|
+
};
|
|
19
|
+
function resolveRootRights(actor, rootAcl) {
|
|
20
|
+
if (actor.permissions.has(constants_1.OWNER_WILDCARD_PERMISSION)) {
|
|
21
|
+
return new Set(ALL_RIGHTS);
|
|
22
|
+
}
|
|
23
|
+
return evaluateAclEntries(rootAcl, actor);
|
|
24
|
+
}
|
|
25
|
+
function evaluateAclEntries(entries, actor) {
|
|
26
|
+
const granted = new Set();
|
|
27
|
+
for (const entry of entries) {
|
|
28
|
+
const matches = SUBJECT_MATCHERS[entry.subject.kind];
|
|
29
|
+
if (!matches?.(entry.subject.id, actor))
|
|
30
|
+
continue;
|
|
31
|
+
for (const right of entry.rights) {
|
|
32
|
+
for (const implied of RIGHT_IMPLICATIONS[right] ?? []) {
|
|
33
|
+
granted.add(implied);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return granted;
|
|
38
|
+
}
|
|
39
|
+
function resolveFolderAccess(folders, actor, rootAcl) {
|
|
40
|
+
if (actor.permissions.has(constants_1.OWNER_WILDCARD_PERMISSION)) {
|
|
41
|
+
return buildFullAccess(folders);
|
|
42
|
+
}
|
|
43
|
+
const access = buildEmptyAccess();
|
|
44
|
+
const childrenByParent = groupChildrenByParent(folders);
|
|
45
|
+
const queue = collectRoots(folders).map((folder) => ({
|
|
46
|
+
folder,
|
|
47
|
+
inherited: evaluateAclEntries(rootAcl, actor),
|
|
48
|
+
}));
|
|
49
|
+
for (let index = 0; index < queue.length; index++) {
|
|
50
|
+
const { folder, inherited } = queue[index];
|
|
51
|
+
const ownAcl = (0, entries_1.parseFolderAcl)(folder);
|
|
52
|
+
const rights = ownAcl ? evaluateAclEntries(ownAcl, actor) : inherited;
|
|
53
|
+
collectFolderRights(access, folder._id, rights);
|
|
54
|
+
for (const child of childrenByParent.get(folder._id) ?? []) {
|
|
55
|
+
queue.push({ folder: child, inherited: rights });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
collectAncestorShells(folders, access);
|
|
59
|
+
return access;
|
|
60
|
+
}
|
|
61
|
+
function buildEmptyAccess() {
|
|
62
|
+
return {
|
|
63
|
+
readable: new Set(),
|
|
64
|
+
writable: new Set(),
|
|
65
|
+
manageable: new Set(),
|
|
66
|
+
shells: new Set(),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function buildFullAccess(folders) {
|
|
70
|
+
const ids = folders.map((folder) => folder._id);
|
|
71
|
+
return {
|
|
72
|
+
readable: new Set(ids),
|
|
73
|
+
writable: new Set(ids),
|
|
74
|
+
manageable: new Set(ids),
|
|
75
|
+
shells: new Set(),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function groupChildrenByParent(folders) {
|
|
79
|
+
const childrenByParent = new Map();
|
|
80
|
+
for (const folder of folders) {
|
|
81
|
+
if (!folder.parentId)
|
|
82
|
+
continue;
|
|
83
|
+
const siblings = childrenByParent.get(folder.parentId) ?? [];
|
|
84
|
+
siblings.push(folder);
|
|
85
|
+
childrenByParent.set(folder.parentId, siblings);
|
|
86
|
+
}
|
|
87
|
+
return childrenByParent;
|
|
88
|
+
}
|
|
89
|
+
function collectRoots(folders) {
|
|
90
|
+
const knownIds = new Set(folders.map((folder) => folder._id));
|
|
91
|
+
return folders.filter((folder) => !folder.parentId || !knownIds.has(folder.parentId));
|
|
92
|
+
}
|
|
93
|
+
function collectFolderRights(access, folderId, rights) {
|
|
94
|
+
if (rights.has("read"))
|
|
95
|
+
access.readable.add(folderId);
|
|
96
|
+
if (rights.has("write"))
|
|
97
|
+
access.writable.add(folderId);
|
|
98
|
+
if (rights.has("manage"))
|
|
99
|
+
access.manageable.add(folderId);
|
|
100
|
+
}
|
|
101
|
+
function collectAncestorShells(folders, access) {
|
|
102
|
+
const foldersById = new Map(folders.map((folder) => [folder._id, folder]));
|
|
103
|
+
for (const folderId of access.readable) {
|
|
104
|
+
let current = foldersById.get(folderId);
|
|
105
|
+
while (current?.parentId) {
|
|
106
|
+
const parent = foldersById.get(current.parentId);
|
|
107
|
+
if (!parent || access.shells.has(parent._id))
|
|
108
|
+
break;
|
|
109
|
+
if (!access.readable.has(parent._id))
|
|
110
|
+
access.shells.add(parent._id);
|
|
111
|
+
current = parent;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../src/acl/resolver.ts"],"names":[],"mappings":";;AAyCA,8CAQC;AAED,gDAeC;AAED,kDAyBC;AA7FD,4CAAyD;AAGzD,uCAA2C;AAoB3C,MAAM,UAAU,GAAwB,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAEpE,MAAM,kBAAkB,GAA0C;IAChE,IAAI,EAAE,CAAC,MAAM,CAAC;IACd,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;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C,CAAC;YACpE,OAAO,GAAG,MAAM,CAAC;QACnB,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DeleteFile } from "@antelopejs/interface-file-storage";
|
|
2
|
+
import { type MediaAsset, MediaAssetModel } from "./db";
|
|
3
|
+
export declare function retiredFiles(asset: MediaAsset): string[];
|
|
4
|
+
export declare function updateAssetMedia(model: MediaAssetModel, asset: MediaAsset, patch: Partial<MediaAsset>): Promise<boolean>;
|
|
5
|
+
export declare function cleanupAssetFiles(model: MediaAssetModel, assetId: string, deleteFile?: typeof DeleteFile): Promise<number>;
|
|
6
|
+
export declare function deleteMediaAsset(model: MediaAssetModel, assetId: string, deleteFile?: typeof DeleteFile): Promise<void>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.retiredFiles = retiredFiles;
|
|
4
|
+
exports.updateAssetMedia = updateAssetMedia;
|
|
5
|
+
exports.cleanupAssetFiles = cleanupAssetFiles;
|
|
6
|
+
exports.deleteMediaAsset = deleteMediaAsset;
|
|
7
|
+
const interface_file_storage_1 = require("@antelopejs/interface-file-storage");
|
|
8
|
+
const db_1 = require("./db");
|
|
9
|
+
const storage_keys_1 = require("./routes/media/storage-keys");
|
|
10
|
+
function retiredFiles(asset) {
|
|
11
|
+
return JSON.parse(asset.json_retiredFiles);
|
|
12
|
+
}
|
|
13
|
+
async function updateAssetMedia(model, asset, patch) {
|
|
14
|
+
if (asset.isDeleting)
|
|
15
|
+
return false;
|
|
16
|
+
const next = db_1.MediaAssetModel.fromPlainData(Object.assign(db_1.MediaAssetModel.toDatabase(asset), patch));
|
|
17
|
+
const live = new Set(next.isDeleting ? [] : (0, storage_keys_1.collectAssetStorageKeys)(next));
|
|
18
|
+
const pending = retiredFiles(asset);
|
|
19
|
+
if (pending.some((key) => live.has(key))) {
|
|
20
|
+
throw new Error("Cannot publish a retired media file");
|
|
21
|
+
}
|
|
22
|
+
const retired = (0, storage_keys_1.collectAssetStorageKeys)(asset).filter((key) => !live.has(key));
|
|
23
|
+
return model.compareMedia(asset, {
|
|
24
|
+
...patch,
|
|
25
|
+
json_retiredFiles: JSON.stringify([...new Set([...pending, ...retired])]),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
async function acknowledgeFile(model, assetId, key) {
|
|
29
|
+
for (;;) {
|
|
30
|
+
const fresh = await model.get(assetId);
|
|
31
|
+
if (!fresh || !retiredFiles(fresh).includes(key))
|
|
32
|
+
return;
|
|
33
|
+
const pending = retiredFiles(fresh).filter((candidate) => candidate !== key);
|
|
34
|
+
if (await model.compareMedia(fresh, {
|
|
35
|
+
json_retiredFiles: JSON.stringify(pending),
|
|
36
|
+
}))
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async function cleanupAssetFiles(model, assetId, deleteFile = interface_file_storage_1.DeleteFile) {
|
|
41
|
+
const asset = await model.get(assetId);
|
|
42
|
+
if (!asset)
|
|
43
|
+
return 0;
|
|
44
|
+
let removed = 0;
|
|
45
|
+
for (const key of retiredFiles(asset)) {
|
|
46
|
+
const fresh = await model.get(assetId);
|
|
47
|
+
if (!fresh || !retiredFiles(fresh).includes(key))
|
|
48
|
+
continue;
|
|
49
|
+
if (!fresh.isDeleting && (0, storage_keys_1.collectAssetStorageKeys)(fresh).includes(key))
|
|
50
|
+
continue;
|
|
51
|
+
try {
|
|
52
|
+
if (await (0, interface_file_storage_1.FileExists)(key, fresh.storage))
|
|
53
|
+
await deleteFile(key, fresh.storage);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
await acknowledgeFile(model, assetId, key);
|
|
59
|
+
removed++;
|
|
60
|
+
}
|
|
61
|
+
const fresh = await model.get(assetId);
|
|
62
|
+
if (fresh?.isDeleting && retiredFiles(fresh).length === 0) {
|
|
63
|
+
await model.deleteCleanedAsset(fresh);
|
|
64
|
+
}
|
|
65
|
+
return removed;
|
|
66
|
+
}
|
|
67
|
+
async function deleteMediaAsset(model, assetId, deleteFile = interface_file_storage_1.DeleteFile) {
|
|
68
|
+
for (;;) {
|
|
69
|
+
const asset = await model.get(assetId);
|
|
70
|
+
if (!asset)
|
|
71
|
+
return;
|
|
72
|
+
if (asset.isDeleting ||
|
|
73
|
+
(await updateAssetMedia(model, asset, { isDeleting: true })))
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
await cleanupAssetFiles(model, assetId, deleteFile);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=asset-lifecycle.js.map
|