@antelopejs/dms-media 0.3.1 → 0.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/README.md +57 -180
- package/dist/db/models/mediaAssets.model.d.ts +1 -0
- package/dist/db/models/mediaEvents.model.d.ts +1 -0
- package/dist/db/models/mediaFavorites.model.d.ts +1 -0
- package/dist/db/models/mediaFolders.model.d.ts +1 -0
- package/dist/db/models/mediaUploads.model.d.ts +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/test/antelope.test.js +5 -5
- package/dist/test/helpers/pages.js +3 -2
- package/dist/test/helpers/pages.js.map +1 -1
- package/dist/test/integration/frontend-module.test.d.ts +1 -0
- package/dist/test/integration/frontend-module.test.js +13 -0
- package/dist/test/integration/frontend-module.test.js.map +1 -0
- package/frontend-vue/app/components/FileProperties.vue +9 -3
- package/frontend-vue/app/components/FirstRun.vue +1 -1
- package/frontend-vue/app/components/ImageEditor.vue +43 -26
- package/frontend-vue/app/components/PresetCards.vue +3 -11
- package/frontend-vue/app/components/RecentFiles.vue +6 -14
- package/frontend-vue/app/components/UploadQueue.vue +1 -1
- package/frontend-vue/app/components/UploadStrip.vue +1 -1
- package/frontend-vue/app/components/dialogs/DestinationDialog.vue +1 -2
- package/frontend-vue/app/components/explorer/ExplorerInspector.vue +17 -16
- package/frontend-vue/app/components/explorer/ExplorerShell.vue +11 -3
- package/frontend-vue/app/components/explorer/ExplorerToolbar.vue +2 -1
- package/frontend-vue/app/components/field/AssetValue.vue +12 -13
- package/frontend-vue/app/components/file/FileViewer.vue +1 -14
- package/frontend-vue/app/composables/library/useLibraryListing.ts +180 -79
- package/frontend-vue/app/composables/library/useLibraryTree.ts +31 -15
- package/frontend-vue/app/composables/library/useMediaLibrary.ts +17 -7
- package/frontend-vue/app/composables/uploadLimits.ts +25 -0
- package/frontend-vue/app/composables/useAssetContent.ts +20 -0
- package/frontend-vue/app/composables/useCurrentFile.ts +10 -8
- package/frontend-vue/app/composables/useFieldFolders.ts +19 -18
- package/frontend-vue/app/composables/useFileDetails.ts +117 -90
- package/frontend-vue/app/composables/useMediaApi.ts +18 -24
- package/frontend-vue/package.json +2 -1
- package/frontend-vue/pnpm-lock.yaml +17 -2
- package/frontend-vue/tests/engines.test.ts +20 -0
- package/frontend-vue/tests/fixtures/inertia.ts +8 -0
- package/frontend-vue/tests/fixtures/serverRender.ts +200 -0
- package/frontend-vue/tests/fixtures/unhead.ts +3 -0
- package/frontend-vue/tests/fixtures/vueI18n.ts +4 -0
- package/frontend-vue/tests/libraryListing.test.ts +120 -0
- package/frontend-vue/tests/serverRender.test.ts +215 -0
- package/frontend-vue/vitest.config.ts +21 -0
- package/package.json +40 -16
- package/skills/dms-media/SKILL.md +64 -0
- package/src/index.ts +19 -2
- package/src/test/antelope.test.ts +5 -5
- package/src/test/helpers/pages.ts +3 -2
- package/src/test/integration/frontend-module.test.ts +13 -0
- package/frontend-vue/app/composables/useSharedTree.ts +0 -73
package/README.md
CHANGED
|
@@ -1,214 +1,91 @@
|
|
|
1
|
-
# @antelopejs/dms-media
|
|
2
|
-
|
|
3
1
|
<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 [AGENTS.md](../../AGENTS.md) for code conventions.
|
|
13
|
-
|
|
14
|
-
## Installation
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
ajs project modules add @antelopejs/dms-media
|
|
18
|
-
```
|
|
19
2
|
|
|
20
|
-
|
|
3
|
+
# @antelopejs/dms-media
|
|
21
4
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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. An image sharp cannot read answers 422, a size that fails to render for another reason 503.
|
|
27
|
-
- **Server-side image editing** — `transform` (normalized crop, 90° rotations) overwrites the image everywhere it is used, `transform/copy` saves the edit as a new file next to the untouched source ("Save as copy"), and `revert` restores the original. The pristine original is preserved on first edit (its size counts in the storage), successive edits are rendered from it, 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 module** — registered with `RegisterModule` like every DMS module, so it is listed under Modules and its pages live under `/modules/media` (they are the owner's administration of the library, see [Access model](#access-model)): Library (Overview `/modules/media/overview`, Library `/modules/media/files`, Uploads `/modules/media/uploads`, plus the hidden File `/modules/media/file?asset=`, Edit image `/modules/media/editor?asset=` and Activity `/modules/media/activity` pages) and Settings (Image sizes `/modules/media/presets`). Every page is a backend block tree. Module pages are owner-only (see [Static permissions](#static-permissions)).
|
|
30
|
-
- **Explorer** — server-paged listings with facets (type, visibility, modification date, orientation), smart views (recents, starred, missing alt text, largest, public), server search over names, alt text and folders (accents, case and word order ignored), bulk move/visibility/delete, zip download of a selection or of a folder with its subfolders, drag and drop, keyboard shortcuts and a shared upload queue that survives navigation.
|
|
31
|
-
- **Unique names** — renaming a file, or creating, renaming or moving a folder, onto a name its folder already holds (case and Unicode form aside) answers 409, and an upload that collides offers "Keep both" (the next free name, `photo (2).jpg`, from `POST /api/media/upload/names`) or "Cancel". A name typed in the library that Windows or macOS cannot save is refused, a subfolder cannot be created in or moved into a linked folder (403), and validation errors answer `$dms_media.errors.*` keys the dashboard translates.
|
|
32
|
-
- **Activity** — every write is recorded in `media_events` (kept 90 days) and feeds the overview, the Activity page (filterable by kind of action), the file history and the upload batches.
|
|
5
|
+
<a href="https://www.npmjs.com/package/@antelopejs/dms-media"><img alt="npm" src="https://img.shields.io/npm/v/@antelopejs/dms-media?style=for-the-badge&labelColor=000000&color=000000"></a>
|
|
6
|
+
<a href="./LICENSE"><img alt="License" src="https://img.shields.io/npm/l/@antelopejs/dms-media?style=for-the-badge&labelColor=000000&color=000000"></a>
|
|
7
|
+
<a href="https://discord.gg/sjK28QHrA7"><img alt="Discord" src="https://img.shields.io/badge/Discord-18181B?logo=discord&style=for-the-badge&color=000000"></a>
|
|
8
|
+
<a href="https://dms.antelopejs.com/docs/modules/media"><img alt="Documentation" src="https://img.shields.io/badge/Docs-18181B?style=for-the-badge&color=000000"></a>
|
|
33
9
|
|
|
34
|
-
|
|
10
|
+
A media library for the AntelopeJS DMS: uploads, folders, image sizes and light editing.
|
|
35
11
|
|
|
36
|
-
|
|
12
|
+
</div>
|
|
37
13
|
|
|
38
|
-
|
|
39
|
-
|---|---|
|
|
40
|
-
| `modules.media.library.files` | Page permission of Library. Like every module page permission it is owner-only: it is not listed in Roles and `HasPermission` refuses it to any non-owner. It grants no folder right |
|
|
14
|
+

|
|
41
15
|
|
|
42
|
-
|
|
16
|
+
## What it does
|
|
43
17
|
|
|
44
|
-
|
|
18
|
+
- Organises images, videos and documents in a Finder-style explorer, with smart views, search, drag and drop and bulk actions.
|
|
19
|
+
- Uploads files straight to the project's file storage and delivers them from stable `/media/<id>/<name>` URLs.
|
|
20
|
+
- Renders named image sizes on first request, with crop and rotation that can revert to the original.
|
|
21
|
+
- Applies per-folder rights built on the DMS permissions and roles.
|
|
22
|
+
- Adds an `AssetType` form field, from [`@antelopejs/interface-dms-media`](https://github.com/AntelopeJS/dms-media/tree/main/packages/interface-dms-media), that opens the library as a picker on your pages.
|
|
45
23
|
|
|
46
|
-
|
|
24
|
+
## Install
|
|
47
25
|
|
|
48
|
-
|
|
26
|
+
Run the AntelopeJS CLI from the root of a project that already loads `@antelopejs/dms` and a file storage module:
|
|
49
27
|
|
|
50
|
-
```
|
|
51
|
-
@
|
|
52
|
-
export class ArticlesPage extends PageController("articles", { displayName: "Articles", category: pagesCategory }) {
|
|
53
|
-
static form = Form({
|
|
54
|
-
fields: [
|
|
55
|
-
{
|
|
56
|
-
id: "cover",
|
|
57
|
-
label: "Cover",
|
|
58
|
-
type: new AssetType({
|
|
59
|
-
mimetypes: ["image/*"],
|
|
60
|
-
binding: { id: "articles.cover", folderName: "Article covers", permissionsFromPage: ArticlesPage },
|
|
61
|
-
}),
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
The page permission must be an explicit grant of the role: a page every member opens by default (`memberAccess`, `publicAccess`) grants no folder right, because folder ACL subjects match the permissions a member holds. In a linked folder, the member can upload, describe, rename, move, delete and edit every file of the folder, whoever added it; making a file public or private stays with the owner. The rest of the library stays closed to members: the default root ACL grants nothing, and only a permission or role a project adds to `rootAcl`, opens it to the picker.
|
|
69
|
-
|
|
70
|
-
## Module configuration
|
|
71
|
-
|
|
72
|
-
```json
|
|
73
|
-
{
|
|
74
|
-
"dms-media": {
|
|
75
|
-
"config": {
|
|
76
|
-
"storage": "media",
|
|
77
|
-
"rootAcl": [{ "subject": { "kind": "permission", "id": "articles.page" }, "rights": ["read"] }],
|
|
78
|
-
"allowedMimetypes": ["image/*", "application/pdf"],
|
|
79
|
-
"storageQuotaBytes": 10000000000,
|
|
80
|
-
"publicBaseUrl": "${@api.API_PUBLIC_BASE_URL}",
|
|
81
|
-
"presets": [
|
|
82
|
-
{ "id": "thumb", "width": 300, "height": 300, "fit": "cover", "format": "webp", "quality": 80 }
|
|
83
|
-
]
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
28
|
+
```bash
|
|
29
|
+
ajs project modules add @antelopejs/dms-media
|
|
87
30
|
```
|
|
88
31
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
- `storage` selects a named `interface-file-storage` backend (default storage otherwise).
|
|
92
|
-
- `rootAcl` sets the rights every folder without its own ACL inherits. The default is empty: owners hold every right anyway, and members only reach the linked folders of their pages. An entry you add here opens the whole library to its subject.
|
|
93
|
-
- `allowedMimetypes` lists the file types the library accepts (`image/*` matches a prefix). The default is `image/*`, `video/*`, `audio/*`, `application/pdf`, the Office types (`application/msword`, `application/vnd.ms-excel`, `application/vnd.ms-powerpoint`, `application/vnd.openxmlformats-officedocument.*`), OpenDocument (`application/vnd.oasis.opendocument.*`), `application/rtf`, `text/plain`, `text/markdown` and `text/csv`. HTML, XHTML and PHP (`text/html`, `application/xhtml+xml`, the PHP types, and `.htm`, `.html`, `.xhtml`, `.xht`, `.shtml`, `.mht`, `.mhtml`, `.php`, `.php3`–`.php8`, `.phps`, `.pht`, `.phtml`, `.phar` files) are always refused, whatever the list says.
|
|
94
|
-
- `storageQuotaBytes` sets the storage plan: the overview measures usage against it, and `presign` refuses an upload that would go past it.
|
|
95
|
-
- `publicBaseUrl` is the public URL of the API, the origin serving `/media/...`: "Copy link" in the library and the links of the file page's Delivery tab start with it. Point it at the api module's public base URL (`"${@api.API_PUBLIC_BASE_URL}"`, as `file-storage-local`'s `baseUrl`). Without it, links start with the DMS `apiBaseUrl` (`GetApiBaseUrl`), and stay relative when neither is set; request headers (`Host`, `X-Forwarded-*`) are never read. Links do not use the dashboard's origin: it only relays non-HTML requests to `/media`, so a link opened in a tab would end on its 404.
|
|
96
|
-
- `presets` replaces the default `thumb`/`preview` presets. Keep a `thumb` preset — the Finder uses it for grid thumbnails.
|
|
32
|
+
## Quick start
|
|
97
33
|
|
|
98
|
-
|
|
34
|
+
Point the module's links at the API's public URL, and allow the dashboard's origin, since the browser uploads straight to the storage:
|
|
99
35
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
"file-storage-local": {
|
|
116
|
-
"config": { "baseUrl": "${@api.API_PUBLIC_BASE_URL}" }
|
|
117
|
-
}
|
|
118
|
-
}
|
|
36
|
+
```ts
|
|
37
|
+
// antelope.config.ts
|
|
38
|
+
"dms-media": {
|
|
39
|
+
source: { type: "package", package: "@antelopejs/dms-media", version: "^0.4.0" },
|
|
40
|
+
config: {
|
|
41
|
+
publicBaseUrl: "${@api.API_PUBLIC_BASE_URL}",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
api: {
|
|
45
|
+
config: {
|
|
46
|
+
cors: { allowedOrigins: ["https://dms.example.com"] },
|
|
47
|
+
},
|
|
48
|
+
},
|
|
119
49
|
```
|
|
120
50
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
## Declaring an AssetType field
|
|
124
|
-
|
|
125
|
-
`AssetType` and the folder bindings it declares live in the interface package [`@antelopejs/interface-dms-media`](../interface-dms-media), which this module implements. Declare the interface in the consumer module's `dependencies` and import from it:
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
pnpm add @antelopejs/interface-dms-media
|
|
129
|
-
```
|
|
51
|
+
Restart the backend, then the frontend, and open **Modules › Media** (`/modules/media/overview`). To let members pick files from your own pages, add an asset field:
|
|
130
52
|
|
|
131
53
|
```ts
|
|
132
54
|
import { AssetType } from "@antelopejs/interface-dms-media";
|
|
133
55
|
|
|
134
56
|
new AssetType({
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
mimetypes: ["image/*"],
|
|
138
|
-
binding: {
|
|
139
|
-
id: "articles.cover",
|
|
140
|
-
folderName: "Article covers",
|
|
141
|
-
permissionMapping: {
|
|
142
|
-
read: ["articles.page"],
|
|
143
|
-
write: ["articles.page.table.edit", "articles.page.table.add"],
|
|
144
|
-
},
|
|
145
|
-
},
|
|
57
|
+
mimetypes: ["image/*"],
|
|
58
|
+
binding: { id: "articles.cover", folderName: "Article covers", permissionsFromPage: ArticlesPage },
|
|
146
59
|
});
|
|
147
60
|
```
|
|
148
61
|
|
|
149
|
-
|
|
62
|
+
## Compatibility
|
|
150
63
|
|
|
151
|
-
|
|
64
|
+
| Package | Version |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| `@antelopejs/dms` | `>=0.9.0 <1.0.0` |
|
|
67
|
+
| `@antelopejs/interface-dms` | `>=0.7.0 <1.0.0` |
|
|
68
|
+
| `@antelopejs/dms-frontend` (renderer) | `>=0.6.0 <0.7.0` |
|
|
69
|
+
| `@antelopejs/interface-dms-media` | `>=0.2.1 <0.3.0` |
|
|
70
|
+
| File storage | an `@antelopejs/interface-file-storage` implementation, such as `@antelopejs/file-storage-local` |
|
|
152
71
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
- Library: `GET /api/media/tree` (folders, plus `allowedMimetypes`), `GET /api/media/folders/:id/assets|impact`, `GET /api/media/views/:view` (`recent`, `starred`, `missing-alt`, `largest`, `public`), `GET /api/media/search` (an empty `q` finds nothing), `POST /api/media/favorites`, `POST /api/media/folders/starter`. Folder listings and views take the `type`, `visibility`, `modified` and `orientation` facets; views also take a `folderId` to stay inside one folder
|
|
156
|
-
- Overview (owners only, 403 otherwise): `GET /api/media/stats/kpis|storage|attention|recent`, `GET /api/media/activity?type=`
|
|
157
|
-
- File: `GET /api/media/assets/:id/details|history|information|delivery|delivery/notice|tab-counts`, `GET /api/media/links/origin` (the origin copied links start with: `publicBaseUrl`, otherwise the DMS `apiBaseUrl`)
|
|
158
|
-
- Bulk: `POST /api/media/assets/bulk/move|visibility|delete`, `POST /api/media/assets/zip`, `POST /api/media/folders/:id/zip` (the folder and its subfolders, `read` right)
|
|
159
|
-
- Settings: `GET|POST /api/media/upload/batches`, `GET /api/media/presets`, `GET /api/media/presets/config`, `GET /api/media/presets/cache`
|
|
160
|
-
- `POST /api/media/folders`, `POST /api/media/folders/:id/rename|move|visibility`, `DELETE /api/media/folders/:id`
|
|
161
|
-
- `GET /api/media/assets`, `GET /api/media/assets/search`, `GET /api/media/assets/:id`, `GET /api/media/assets/:id/read-url?preset=`, `POST /api/media/previews`
|
|
162
|
-
- `POST /api/media/assets/:id/update|move|visibility|transform|transform/copy|revert`, `DELETE /api/media/assets/:id`
|
|
163
|
-
- Upload: `POST /api/media/upload/presign`, `POST /api/media/upload/confirm`, `POST /api/media/upload/abort` (deletes the staged file), `POST /api/media/upload/names` (free names for "Keep both")
|
|
164
|
-
- Public delivery: `GET /media/:assetId/:filename`, `GET /media/:assetId/:presetId/:filename`
|
|
165
|
-
|
|
166
|
-
`GET /api/media/stats/folders` and `GET /api/media/stats/largest` are removed: the overview no longer shows folder cards or the largest files, which the `largest` view lists.
|
|
167
|
-
|
|
168
|
-
Status codes worth handling:
|
|
169
|
-
|
|
170
|
-
| Route | Status | Body |
|
|
171
|
-
|---|---|---|
|
|
172
|
-
| `upload/presign` | 415 | `{ reason: "type_not_allowed", message }`: not in `allowedMimetypes`, or HTML/XHTML/PHP (by type or extension) |
|
|
173
|
-
| `upload/presign` | 415 | `{ reason: "field_type", message, accepted }`: the linked folder feeds a field that accepts fewer types |
|
|
174
|
-
| `upload/presign` | 413 | `{ reason: "quota", message, remaining, quota }`: the upload would go past `storageQuotaBytes` |
|
|
175
|
-
| `upload/confirm` | 422 | `{ reason: "invalid_image", message }`: a declared image that does not decode; the staged file is deleted |
|
|
176
|
-
| `assets/:id/update`, `folders`, `folders/:id/rename|move` | 409 | `$dms_media.errors.name_taken` or `folder_name_taken`: the name is taken in that folder, case aside |
|
|
177
|
-
| `folders`, `folders/:id/move` | 403 | `$dms_media.errors.bound_parent`: the parent is a linked folder |
|
|
178
|
-
| Folder, file and bulk writes | 400 | A `$dms_media.errors.*` key |
|
|
179
|
-
| `/media/:assetId/:filename` | 302 | To the signed storage URL (`no-cache` public, `no-store` private), to the canonical file name, or, for a browser without a token on a private file, to the dashboard's File page |
|
|
180
|
-
| `/media/:assetId/:filename` | 401 | Private file without a token: bare for scripts, an HTML page for a browser when the dashboard URL is unknown |
|
|
181
|
-
| `/media/:assetId/:presetId/:filename` | 422 / 503 | The image cannot be read / the size cannot be rendered right now |
|
|
182
|
-
|
|
183
|
-
## Development
|
|
184
|
-
|
|
185
|
-
The module lives in `packages/dms-media` of a pnpm workspace, next to the interface package it implements (`packages/interface-dms-media`). Run these from `packages/dms-media`:
|
|
186
|
-
|
|
187
|
-
```bash
|
|
188
|
-
pnpm install # whole workspace; the interface resolves to the sibling package
|
|
189
|
-
pnpm build # builds the interface, then the module
|
|
190
|
-
pnpm dev # backend, via playground (ajs project run -w -p playground)
|
|
191
|
-
pnpm frontend:dev # Vue 3 Inertia frontend, from playground (ajs dms dev)
|
|
192
|
-
pnpm test # build + full mocha suite (unit + HTTP integration)
|
|
193
|
-
pnpm test:unit # build + unit tests only (no HTTP)
|
|
194
|
-
pnpm test:reload # hot reload of a consumer and of the module, in a real project
|
|
195
|
-
```
|
|
72
|
+
On DMS 0.8, use `@antelopejs/dms-media` 0.3.
|
|
196
73
|
|
|
197
|
-
|
|
74
|
+
## Documentation
|
|
198
75
|
|
|
199
|
-
|
|
76
|
+
- [Introduction](https://dms.antelopejs.com/docs/modules/media/introduction)
|
|
77
|
+
- [Installation](https://dms.antelopejs.com/docs/modules/media/installation)
|
|
78
|
+
- [Configuration](https://dms.antelopejs.com/docs/modules/media/configuration)
|
|
79
|
+
- [Usage](https://dms.antelopejs.com/docs/modules/media/usage/overview)
|
|
80
|
+
- [Extending](https://dms.antelopejs.com/docs/modules/media/extending)
|
|
81
|
+
- [FAQ](https://dms.antelopejs.com/docs/modules/media/faq)
|
|
200
82
|
|
|
201
|
-
The
|
|
83
|
+
The guide's sources live in [`packages/dms-media/docs`](https://github.com/AntelopeJS/dms-media/tree/main/packages/dms-media/docs). The module ships the `dms-media` Claude Code skill in [`packages/dms-media/skills`](https://github.com/AntelopeJS/dms-media/tree/main/packages/dms-media/skills), declared under `antelopeJs.skills`.
|
|
202
84
|
|
|
203
|
-
|
|
85
|
+
## Contributing
|
|
204
86
|
|
|
205
|
-
|
|
87
|
+
This package lives in the [`AntelopeJS/dms-media`](https://github.com/AntelopeJS/dms-media) pnpm workspace, next to `@antelopejs/interface-dms-media`. Read [CONTRIBUTING.md](https://github.com/AntelopeJS/dms-media/blob/main/CONTRIBUTING.md) and the [repository README](https://github.com/AntelopeJS/dms-media#contributing) for the development commands.
|
|
206
88
|
|
|
207
|
-
##
|
|
89
|
+
## License
|
|
208
90
|
|
|
209
|
-
-
|
|
210
|
-
- The DMS invite flow does not expose invite tokens over HTTP (see the DMS module's `TESTING.md`), so the multi-user HTTP integration tests seed their invites straight into the database (`src/test/helpers/members.ts`).
|
|
211
|
-
- Folder visibility applies to the folder's direct assets (no recursive visibility inheritance); assets inherit or override individually.
|
|
212
|
-
- Cover cropping is centred (no focal point), and reference counting ("used in N records") is not supported yet.
|
|
213
|
-
- The `AssetType` field has no crop button: editing an image changes it everywhere it is used, and a crop per usage comes later.
|
|
214
|
-
- Replacing a file, a trash for deleted files and the server-side validation of `AssetType` values are not there yet; each comes in its own release.
|
|
91
|
+
[Apache-2.0](./LICENSE)
|
|
@@ -15,6 +15,7 @@ declare const MediaAssetModel_base: {
|
|
|
15
15
|
delete(id: string): Promise<number>;
|
|
16
16
|
};
|
|
17
17
|
readonly schemaName: string;
|
|
18
|
+
readonly tableClass: import("@antelopejs/interface-database-decorators").Constructible<MediaAsset>;
|
|
18
19
|
fromPlainData(obj: any): MediaAsset;
|
|
19
20
|
fromDatabase(obj: any): MediaAsset | undefined;
|
|
20
21
|
toDatabase(obj: any): Record<string, any>;
|
|
@@ -12,6 +12,7 @@ declare const MediaEventModel_base: {
|
|
|
12
12
|
delete(id: string): Promise<number>;
|
|
13
13
|
};
|
|
14
14
|
readonly schemaName: string;
|
|
15
|
+
readonly tableClass: import("@antelopejs/interface-database-decorators").Constructible<MediaEvent>;
|
|
15
16
|
fromPlainData(obj: any): MediaEvent;
|
|
16
17
|
fromDatabase(obj: any): MediaEvent | undefined;
|
|
17
18
|
toDatabase(obj: any): Record<string, any>;
|
|
@@ -12,6 +12,7 @@ declare const MediaFavoriteModel_base: {
|
|
|
12
12
|
delete(id: string): Promise<number>;
|
|
13
13
|
};
|
|
14
14
|
readonly schemaName: string;
|
|
15
|
+
readonly tableClass: import("@antelopejs/interface-database-decorators").Constructible<MediaFavorite>;
|
|
15
16
|
fromPlainData(obj: any): MediaFavorite;
|
|
16
17
|
fromDatabase(obj: any): MediaFavorite | undefined;
|
|
17
18
|
toDatabase(obj: any): Record<string, any>;
|
|
@@ -12,6 +12,7 @@ declare const MediaFolderModel_base: {
|
|
|
12
12
|
delete(id: string): Promise<number>;
|
|
13
13
|
};
|
|
14
14
|
readonly schemaName: string;
|
|
15
|
+
readonly tableClass: import("@antelopejs/interface-database-decorators").Constructible<MediaFolder>;
|
|
15
16
|
fromPlainData(obj: any): MediaFolder;
|
|
16
17
|
fromDatabase(obj: any): MediaFolder | undefined;
|
|
17
18
|
toDatabase(obj: any): Record<string, any>;
|
|
@@ -12,6 +12,7 @@ declare const MediaUploadModel_base: {
|
|
|
12
12
|
delete(id: string): Promise<number>;
|
|
13
13
|
};
|
|
14
14
|
readonly schemaName: string;
|
|
15
|
+
readonly tableClass: import("@antelopejs/interface-database-decorators").Constructible<MediaUpload>;
|
|
15
16
|
fromPlainData(obj: any): MediaUpload;
|
|
16
17
|
fromDatabase(obj: any): MediaUpload | undefined;
|
|
17
18
|
toDatabase(obj: any): Record<string, any>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type FrontendBackendProxy } from "@antelopejs/interface-dms/page";
|
|
1
2
|
import "./db";
|
|
2
3
|
import { type DmsMediaConfig } from "./config";
|
|
3
4
|
export * from "./acl";
|
|
@@ -12,6 +13,8 @@ export * from "./presets";
|
|
|
12
13
|
export * from "./routes";
|
|
13
14
|
export * from "./transform";
|
|
14
15
|
export * from "./types";
|
|
16
|
+
export declare const MEDIA_FRONTEND_MODULE = "@antelopejs/dms-media-frontend-vue";
|
|
17
|
+
export declare const MEDIA_DELIVERY_PROXY: FrontendBackendProxy;
|
|
15
18
|
export declare function construct(config?: DmsMediaConfig): Promise<void>;
|
|
16
19
|
export declare function start(): void;
|
|
17
20
|
export declare function stop(): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -39,6 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.MEDIA_DELIVERY_PROXY = exports.MEDIA_FRONTEND_MODULE = void 0;
|
|
42
43
|
exports.construct = construct;
|
|
43
44
|
exports.start = start;
|
|
44
45
|
exports.stop = stop;
|
|
@@ -63,16 +64,22 @@ __exportStar(require("./routes"), exports);
|
|
|
63
64
|
__exportStar(require("./transform"), exports);
|
|
64
65
|
__exportStar(require("./types"), exports);
|
|
65
66
|
let cronTasks = [];
|
|
67
|
+
exports.MEDIA_FRONTEND_MODULE = "@antelopejs/dms-media-frontend-vue";
|
|
68
|
+
exports.MEDIA_DELIVERY_PROXY = {
|
|
69
|
+
path: "/media/**",
|
|
70
|
+
auth: "session",
|
|
71
|
+
};
|
|
66
72
|
async function construct(config = {}) {
|
|
67
73
|
(0, config_1.configureMediaModule)(config);
|
|
68
74
|
(0, interface_core_1.ImplementInterface)(await Promise.resolve().then(() => __importStar(require("@antelopejs/interface-dms-media"))), await Promise.resolve().then(() => __importStar(require("./implementations/interface-dms-media"))));
|
|
69
75
|
const sourcePath = node_path_1.default.join(__dirname, "../frontend-vue");
|
|
70
76
|
await (0, page_1.AddFrontendModule)({
|
|
71
|
-
name:
|
|
77
|
+
name: exports.MEDIA_FRONTEND_MODULE,
|
|
72
78
|
sourcePath,
|
|
73
79
|
renderer: { name: "vue", version: "3" },
|
|
74
80
|
configKey: "dmsMedia",
|
|
75
81
|
priority: 0,
|
|
82
|
+
backendProxies: [exports.MEDIA_DELIVERY_PROXY],
|
|
76
83
|
});
|
|
77
84
|
}
|
|
78
85
|
function start() {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,8BAgBC;AAED,sBAEC;AAED,oBAWC;AA1ED,0DAA6B;AAC7B,+DAAgE;AAChE,yDAGwC;AACxC,gEAA6D;AAC7D,gBAAc;AAEd,qCAAqE;AACrE,mCAA6C;AAC7C,iDAAyD;AAEzD,wCAAsB;AACtB,6CAA2B;AAC3B,2CAAyB;AACzB,8CAA4B;AAC5B,0CAAwB;AACxB,uCAAqB;AACrB,gDAA8B;AAC9B,0CAAwB;AACxB,4CAA0B;AAC1B,2CAAyB;AACzB,8CAA4B;AAC5B,0CAAwB;AAExB,IAAI,SAAS,GAAoB,EAAE,CAAC;AAGvB,QAAA,qBAAqB,GAAG,oCAAoC,CAAC;AAO7D,QAAA,oBAAoB,GAAyB;IACxD,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,SAAS;CAChB,CAAC;AAEK,KAAK,UAAU,SAAS,CAAC,SAAyB,EAAE;IACzD,IAAA,6BAAoB,EAAC,MAAM,CAAC,CAAC;IAC7B,IAAA,mCAAkB,EAChB,wDAAa,iCAAiC,GAAC,EAC/C,wDAAa,uCAAuC,GAAC,CACtD,CAAC;IACF,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;IAE3D,MAAM,IAAA,wBAAiB,EAAC;QACtB,IAAI,EAAE,6BAAqB;QAC3B,UAAU;QACV,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE;QACvC,SAAS,EAAE,UAAU;QACrB,QAAQ,EAAE,CAAC;QACX,cAAc,EAAE,CAAC,4BAAoB,CAAC;KACvC,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,KAAK;IACnB,SAAS,GAAG,IAAA,0BAAkB,GAAE,CAAC;AACnC,CAAC;AAEM,KAAK,UAAU,IAAI;IACxB,IAAA,8BAAmB,GAAE,CAAC;IACtB,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,UAAU,CACxC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAC9C,CAAC;IACF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,IAAI,QAAQ,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YACnC,iBAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;IACD,SAAS,GAAG,EAAE,CAAC;AACjB,CAAC"}
|
|
@@ -99,7 +99,7 @@ exports.default = (0, config_1.defineConfig)({
|
|
|
99
99
|
source: {
|
|
100
100
|
type: "package",
|
|
101
101
|
package: "@antelopejs/dms",
|
|
102
|
-
version: ">=0.
|
|
102
|
+
version: ">=0.9.3 <1.0.0",
|
|
103
103
|
},
|
|
104
104
|
config: {
|
|
105
105
|
auth: {
|
|
@@ -111,7 +111,7 @@ exports.default = (0, config_1.defineConfig)({
|
|
|
111
111
|
source: {
|
|
112
112
|
type: "package",
|
|
113
113
|
package: "@antelopejs/mongodb",
|
|
114
|
-
version: "1.4.
|
|
114
|
+
version: "1.4.3",
|
|
115
115
|
},
|
|
116
116
|
},
|
|
117
117
|
"auth-jwt": {
|
|
@@ -128,7 +128,7 @@ exports.default = (0, config_1.defineConfig)({
|
|
|
128
128
|
source: {
|
|
129
129
|
type: "package",
|
|
130
130
|
package: "@antelopejs/api",
|
|
131
|
-
version: "1.3.
|
|
131
|
+
version: "1.3.5",
|
|
132
132
|
},
|
|
133
133
|
config: {
|
|
134
134
|
servers: [{ protocol: "http", host: "127.0.0.1", port: API_PORT }],
|
|
@@ -139,14 +139,14 @@ exports.default = (0, config_1.defineConfig)({
|
|
|
139
139
|
source: {
|
|
140
140
|
type: "package",
|
|
141
141
|
package: "@antelopejs/file-storage-local",
|
|
142
|
-
version: "0.1.
|
|
142
|
+
version: "0.1.9",
|
|
143
143
|
},
|
|
144
144
|
},
|
|
145
145
|
nodemailer: {
|
|
146
146
|
source: {
|
|
147
147
|
type: "package",
|
|
148
148
|
package: "@antelopejs/nodemailer",
|
|
149
|
-
version: "0.0.
|
|
149
|
+
version: "0.0.6",
|
|
150
150
|
},
|
|
151
151
|
config: {
|
|
152
152
|
host: SMTP_HOST,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.readPageAccess = readPageAccess;
|
|
4
|
+
const page_1 = require("@antelopejs/interface-dms/page");
|
|
4
5
|
const HTTP_OK = 200;
|
|
5
|
-
const
|
|
6
|
+
const PAGE_LAYOUT_ROUTE = "/pagelayout";
|
|
6
7
|
const OMIT_SHARED_PAGE = "false";
|
|
7
8
|
function countBlocks(components) {
|
|
8
9
|
if (Array.isArray(components))
|
|
@@ -11,7 +12,7 @@ function countBlocks(components) {
|
|
|
11
12
|
}
|
|
12
13
|
async function readPageAccess(client, slug) {
|
|
13
14
|
const [ownRoute, page, layout] = await Promise.all([
|
|
14
|
-
client.get(
|
|
15
|
+
client.get((0, page_1.pageRoutePath)(slug, PAGE_LAYOUT_ROUTE)),
|
|
15
16
|
client.get("/dms/page", {
|
|
16
17
|
params: { path: slug, shared: OMIT_SHARED_PAGE },
|
|
17
18
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pages.js","sourceRoot":"","sources":["../../../src/test/helpers/pages.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"pages.js","sourceRoot":"","sources":["../../../src/test/helpers/pages.ts"],"names":[],"mappings":";;AAuBA,wCAqBC;AA5CD,yDAA+D;AAG/D,MAAM,OAAO,GAAG,GAAG,CAAC;AACpB,MAAM,iBAAiB,GAAG,aAAa,CAAC;AACxC,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAYjC,SAAS,WAAW,CAAC,UAAmB;IACtC,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC,MAAM,CAAC;IACxD,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;AAC9C,CAAC;AAGM,KAAK,UAAU,cAAc,CAClC,MAAqB,EACrB,IAAY;IAEZ,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACjD,MAAM,CAAC,GAAG,CAAC,IAAA,oBAAa,EAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;QAClD,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE;YACtB,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE;SACjD,CAAC;QACF,MAAM,CAAC,GAAG,CAAC,iBAAiB,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC;KACpD,CAAC,CAAC;IACH,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CACb,QAAQ,IAAI,aAAa,IAAI,CAAC,MAAM,qBAAqB,MAAM,CAAC,MAAM,qBAAqB,CAC5F,CAAC;IACJ,CAAC;IACD,OAAO;QACL,cAAc,EAAE,QAAQ,CAAC,MAAM;QAC/B,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI;QAC9C,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;KAClD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const page_1 = require("@antelopejs/interface-dms/page");
|
|
4
|
+
const chai_1 = require("chai");
|
|
5
|
+
const index_1 = require("../../index");
|
|
6
|
+
describe("frontend module", () => {
|
|
7
|
+
it("declares the file links as a backend prefix the frontend server proxies with the session", async () => {
|
|
8
|
+
const modules = await (0, page_1.GetFrontendModules)();
|
|
9
|
+
const media = modules.find((module) => module.name === index_1.MEDIA_FRONTEND_MODULE);
|
|
10
|
+
(0, chai_1.expect)(media?.backendProxies).to.deep.equal([index_1.MEDIA_DELIVERY_PROXY]);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=frontend-module.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontend-module.test.js","sourceRoot":"","sources":["../../../src/test/integration/frontend-module.test.ts"],"names":[],"mappings":";;AAAA,yDAAoE;AACpE,+BAA8B;AAC9B,uCAA0E;AAE1E,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,0FAA0F,EAAE,KAAK,IAAI,EAAE;QACxG,MAAM,OAAO,GAAG,MAAM,IAAA,yBAAkB,GAAE,CAAC;QAC3C,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CACxB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,6BAAqB,CAClD,CAAC;QACF,IAAA,aAAM,EAAC,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,4BAAoB,CAAC,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -16,7 +16,14 @@ const assetLink = useAssetLink()
|
|
|
16
16
|
const file = useCurrentFile()
|
|
17
17
|
const asset = computed(() => file.asset.value)
|
|
18
18
|
const details = computed(() => file.details.value)
|
|
19
|
-
|
|
19
|
+
/** What the reader typed in the name field; the file's own name until then, so a server render shows it. */
|
|
20
|
+
const typedName = ref<string | null>(null)
|
|
21
|
+
const nameDraft = computed({
|
|
22
|
+
get: () => typedName.value ?? (asset.value ? baseNameOf(asset.value) : ''),
|
|
23
|
+
set: (value: string) => {
|
|
24
|
+
typedName.value = value
|
|
25
|
+
},
|
|
26
|
+
})
|
|
20
27
|
const extension = computed(() => (asset.value ? extensionOf(asset.value) : ''))
|
|
21
28
|
const hasExtension = computed(() => Boolean(asset.value?.name.toLowerCase().endsWith(`.${extension.value}`)))
|
|
22
29
|
const nameMaxLength = computed(() => NAME_MAX_LENGTH - (hasExtension.value ? extension.value.length + 1 : 0))
|
|
@@ -33,9 +40,8 @@ const keepsFormatHint = computed(() =>
|
|
|
33
40
|
watch(
|
|
34
41
|
() => [asset.value?.id, asset.value?.name],
|
|
35
42
|
() => {
|
|
36
|
-
|
|
43
|
+
typedName.value = null
|
|
37
44
|
},
|
|
38
|
-
{ immediate: true },
|
|
39
45
|
)
|
|
40
46
|
|
|
41
47
|
/** `banner.jpg` typed on a JPG keeps one `.jpg`, rather than saving `banner.jpg.jpg`. */
|