@antelopejs/dms-media 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/pages/uploads.js +2 -1
- package/dist/pages/uploads.js.map +1 -1
- package/dist/test/antelope.test.js +3 -2
- package/dist/test/antelope.test.js.map +1 -1
- 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/dist/test/unit/config.test.js +0 -4
- package/dist/test/unit/config.test.js.map +1 -1
- 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/i18n/locales/media-en-GB.json +1 -0
- package/frontend-vue/i18n/locales/media-fr-FR.json +1 -0
- 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 +16 -10
- package/src/index.ts +19 -2
- package/src/pages/uploads.ts +2 -1
- package/src/test/antelope.test.ts +3 -2
- package/src/test/helpers/pages.ts +3 -2
- package/src/test/integration/frontend-module.test.ts +13 -0
- package/src/test/unit/config.test.ts +0 -5
- package/frontend-vue/app/composables/useSharedTree.ts +0 -73
package/src/index.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { ImplementInterface } from "@antelopejs/interface-core";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
AddFrontendModule,
|
|
5
|
+
type FrontendBackendProxy,
|
|
6
|
+
} from "@antelopejs/interface-dms/page";
|
|
4
7
|
import { Logging } from "@antelopejs/interface-core/logging";
|
|
5
8
|
import "./db";
|
|
6
9
|
import type { ScheduledTask } from "node-cron";
|
|
@@ -23,6 +26,19 @@ export * from "./types";
|
|
|
23
26
|
|
|
24
27
|
let cronTasks: ScheduledTask[] = [];
|
|
25
28
|
|
|
29
|
+
/** The frontend module the dashboard loads: its blocks, viewers and fields. */
|
|
30
|
+
export const MEDIA_FRONTEND_MODULE = "@antelopejs/dms-media-frontend-vue";
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The file links a dashboard page shows (`/media/<id>/<name>`), which the
|
|
34
|
+
* backend serves: proxied by the frontend server with the member's session,
|
|
35
|
+
* so that a private file opens for a member signed in, as on the API origin.
|
|
36
|
+
*/
|
|
37
|
+
export const MEDIA_DELIVERY_PROXY: FrontendBackendProxy = {
|
|
38
|
+
path: "/media/**",
|
|
39
|
+
auth: "session",
|
|
40
|
+
};
|
|
41
|
+
|
|
26
42
|
export async function construct(config: DmsMediaConfig = {}): Promise<void> {
|
|
27
43
|
configureMediaModule(config);
|
|
28
44
|
ImplementInterface(
|
|
@@ -32,11 +48,12 @@ export async function construct(config: DmsMediaConfig = {}): Promise<void> {
|
|
|
32
48
|
const sourcePath = path.join(__dirname, "../frontend-vue");
|
|
33
49
|
|
|
34
50
|
await AddFrontendModule({
|
|
35
|
-
name:
|
|
51
|
+
name: MEDIA_FRONTEND_MODULE,
|
|
36
52
|
sourcePath,
|
|
37
53
|
renderer: { name: "vue", version: "3" },
|
|
38
54
|
configKey: "dmsMedia",
|
|
39
55
|
priority: 0,
|
|
56
|
+
backendProxies: [MEDIA_DELIVERY_PROXY],
|
|
40
57
|
});
|
|
41
58
|
}
|
|
42
59
|
|
package/src/pages/uploads.ts
CHANGED
|
@@ -33,13 +33,14 @@ const history = TableView.fromSource({
|
|
|
33
33
|
},
|
|
34
34
|
],
|
|
35
35
|
rowActions: {
|
|
36
|
+
menuLabel: `${TEXTS}.history.row_actions`,
|
|
36
37
|
custom: [
|
|
37
38
|
{
|
|
38
39
|
label: `${TEXTS}.history.open_folder`,
|
|
39
40
|
icon: "i-ph-folder-open",
|
|
40
41
|
target: {
|
|
41
42
|
type: "page",
|
|
42
|
-
url: `${MEDIA_ROUTES.files}?folder={folderId}`,
|
|
43
|
+
url: `${MEDIA_ROUTES.files}?folder={{row.folderId}}`,
|
|
43
44
|
},
|
|
44
45
|
isDefault: true,
|
|
45
46
|
},
|
|
@@ -6,6 +6,7 @@ import { defineConfig } from "@antelopejs/interface-core/config";
|
|
|
6
6
|
import { MongoMemoryReplSet } from "mongodb-memory-server-core";
|
|
7
7
|
|
|
8
8
|
const API_PORT = 5019;
|
|
9
|
+
const LOCAL_BUILD_COMMAND = process.env.DMS_PREBUILT ? [] : ["pnpm build"];
|
|
9
10
|
const JWT_SECRET = "test-jwt-secret";
|
|
10
11
|
const MONGO_BINARY_VERSION = "8.0.8";
|
|
11
12
|
const SMTP_HOST = "127.0.0.1";
|
|
@@ -100,7 +101,7 @@ export default defineConfig({
|
|
|
100
101
|
source: {
|
|
101
102
|
type: "local",
|
|
102
103
|
path: ".",
|
|
103
|
-
installCommand:
|
|
104
|
+
installCommand: LOCAL_BUILD_COMMAND,
|
|
104
105
|
},
|
|
105
106
|
config: {},
|
|
106
107
|
},
|
|
@@ -108,7 +109,7 @@ export default defineConfig({
|
|
|
108
109
|
source: {
|
|
109
110
|
type: "package",
|
|
110
111
|
package: "@antelopejs/dms",
|
|
111
|
-
version: ">=0.
|
|
112
|
+
version: ">=0.9.0 <1.0.0",
|
|
112
113
|
},
|
|
113
114
|
config: {
|
|
114
115
|
auth: {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { pageRoutePath } from "@antelopejs/interface-dms/page";
|
|
1
2
|
import type { AxiosInstance } from "axios";
|
|
2
3
|
|
|
3
4
|
const HTTP_OK = 200;
|
|
4
|
-
const
|
|
5
|
+
const PAGE_LAYOUT_ROUTE = "/pagelayout";
|
|
5
6
|
const OMIT_SHARED_PAGE = "false";
|
|
6
7
|
|
|
7
8
|
/** What a caller gets from each surface that serves a DMS page. */
|
|
@@ -25,7 +26,7 @@ export async function readPageAccess(
|
|
|
25
26
|
slug: string,
|
|
26
27
|
): Promise<PageAccess> {
|
|
27
28
|
const [ownRoute, page, layout] = await Promise.all([
|
|
28
|
-
client.get(
|
|
29
|
+
client.get(pageRoutePath(slug, PAGE_LAYOUT_ROUTE)),
|
|
29
30
|
client.get("/dms/page", {
|
|
30
31
|
params: { path: slug, shared: OMIT_SHARED_PAGE },
|
|
31
32
|
}),
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GetFrontendModules } from "@antelopejs/interface-dms/page";
|
|
2
|
+
import { expect } from "chai";
|
|
3
|
+
import { MEDIA_DELIVERY_PROXY, MEDIA_FRONTEND_MODULE } from "../../index";
|
|
4
|
+
|
|
5
|
+
describe("frontend module", () => {
|
|
6
|
+
it("declares the file links as a backend prefix the frontend server proxies with the session", async () => {
|
|
7
|
+
const modules = await GetFrontendModules();
|
|
8
|
+
const media = modules.find(
|
|
9
|
+
(module) => module.name === MEDIA_FRONTEND_MODULE,
|
|
10
|
+
);
|
|
11
|
+
expect(media?.backendProxies).to.deep.equal([MEDIA_DELIVERY_PROXY]);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -36,9 +36,4 @@ describe("[unit] config — configureMediaModule", () => {
|
|
|
36
36
|
expect(presets.get("hero")?.width).to.equal(1200);
|
|
37
37
|
expect(presets.has("thumb")).to.equal(false);
|
|
38
38
|
});
|
|
39
|
-
|
|
40
|
-
it("keeps the configured storage name", () => {
|
|
41
|
-
configureMediaModule({ storage: "r2-main" });
|
|
42
|
-
expect(getMediaConfig().storage).to.equal("r2-main");
|
|
43
|
-
});
|
|
44
39
|
});
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type { MediaTree } from '../types/media'
|
|
2
|
-
import type { MediaApi } from './useMediaApi'
|
|
3
|
-
|
|
4
|
-
const DEFAULT_MAX_UPLOAD_BYTES = 500 * 1024 * 1024
|
|
5
|
-
|
|
6
|
-
/** What the library takes at all, from the module config: every upload is checked against it before it is sent. */
|
|
7
|
-
export interface UploadLimits {
|
|
8
|
-
maxUploadBytes: number
|
|
9
|
-
/** Mimetype patterns the library accepts; any type until the server says otherwise. */
|
|
10
|
-
allowedMimetypes: readonly string[] | null
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const sharedTree = ref<MediaTree | null>(null)
|
|
14
|
-
const limits = ref<UploadLimits>({
|
|
15
|
-
maxUploadBytes: DEFAULT_MAX_UPLOAD_BYTES,
|
|
16
|
-
allowedMimetypes: null,
|
|
17
|
-
})
|
|
18
|
-
let pendingLoad: Promise<void> | null = null
|
|
19
|
-
let consumers = 0
|
|
20
|
-
|
|
21
|
-
/** The upload limits the server last sent, shared by every screen that uploads. */
|
|
22
|
-
export const uploadLimits = readonly(limits)
|
|
23
|
-
|
|
24
|
-
/** Keeps the upload limits a server answer carries. */
|
|
25
|
-
export function rememberUploadLimits(answer: UploadLimits): void {
|
|
26
|
-
limits.value = {
|
|
27
|
-
maxUploadBytes: answer.maxUploadBytes,
|
|
28
|
-
allowedMimetypes: answer.allowedMimetypes,
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Reads the folder tree (counted over `scopeFolderId` when given) and keeps the upload limits it carries. */
|
|
33
|
-
export async function fetchTree(
|
|
34
|
-
api: MediaApi,
|
|
35
|
-
scopeFolderId?: string,
|
|
36
|
-
): Promise<MediaTree> {
|
|
37
|
-
const tree = await api.tree(scopeFolderId)
|
|
38
|
-
rememberUploadLimits(tree)
|
|
39
|
-
return tree
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* The folder tree every block of a page shares: read once when the first block
|
|
44
|
-
* mounts, read again on each library change, and dropped when the last block
|
|
45
|
-
* leaves so the next page starts from fresh data.
|
|
46
|
-
*/
|
|
47
|
-
export function useSharedTree() {
|
|
48
|
-
const api = useMediaApi()
|
|
49
|
-
|
|
50
|
-
function reload(): Promise<void> {
|
|
51
|
-
pendingLoad ??= fetchTree(api)
|
|
52
|
-
.then((tree) => {
|
|
53
|
-
sharedTree.value = tree
|
|
54
|
-
})
|
|
55
|
-
.catch(() => undefined)
|
|
56
|
-
.finally(() => {
|
|
57
|
-
pendingLoad = null
|
|
58
|
-
})
|
|
59
|
-
return pendingLoad
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
consumers += 1
|
|
63
|
-
onScopeDispose(() => {
|
|
64
|
-
consumers -= 1
|
|
65
|
-
if (consumers === 0) sharedTree.value = null
|
|
66
|
-
})
|
|
67
|
-
onMounted(() => {
|
|
68
|
-
if (!sharedTree.value) void reload()
|
|
69
|
-
})
|
|
70
|
-
onLibraryChange(reload)
|
|
71
|
-
|
|
72
|
-
return { tree: computed(() => sharedTree.value), reload }
|
|
73
|
-
}
|