@antelopejs/dms-media 0.5.0 → 0.6.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.
Files changed (69) hide show
  1. package/dist/frontend-module.d.ts +4 -0
  2. package/dist/frontend-module.js +24 -0
  3. package/dist/frontend-module.js.map +1 -0
  4. package/dist/index.d.ts +1 -3
  5. package/dist/index.js +3 -19
  6. package/dist/index.js.map +1 -1
  7. package/dist/library/realtime.js +8 -1
  8. package/dist/library/realtime.js.map +1 -1
  9. package/dist/pages/activity.d.ts +1 -0
  10. package/dist/pages/activity.js +3 -0
  11. package/dist/pages/activity.js.map +1 -1
  12. package/dist/pages/overview.d.ts +1 -0
  13. package/dist/pages/overview.js +3 -2
  14. package/dist/pages/overview.js.map +1 -1
  15. package/dist/pages/toolbar.d.ts +3 -0
  16. package/dist/pages/toolbar.js +19 -0
  17. package/dist/pages/toolbar.js.map +1 -0
  18. package/dist/pages/uploads.d.ts +1 -0
  19. package/dist/pages/uploads.js +4 -0
  20. package/dist/pages/uploads.js.map +1 -1
  21. package/dist/routes/media/manage.d.ts +23 -0
  22. package/dist/routes/media/manage.js +7 -4
  23. package/dist/routes/media/manage.js.map +1 -1
  24. package/dist/test/antelope.test.js +9 -4
  25. package/dist/test/antelope.test.js.map +1 -1
  26. package/dist/test/integration/media-activity-overview.test.js +6 -0
  27. package/dist/test/integration/media-activity-overview.test.js.map +1 -1
  28. package/dist/test/unit/library/realtime.test.d.ts +1 -0
  29. package/dist/test/unit/library/realtime.test.js +43 -0
  30. package/dist/test/unit/library/realtime.test.js.map +1 -0
  31. package/dist/test/unit/pages/toolbar.test.d.ts +1 -0
  32. package/dist/test/unit/pages/toolbar.test.js +64 -0
  33. package/dist/test/unit/pages/toolbar.test.js.map +1 -0
  34. package/dist/test/unit/routes/preset-row.test.d.ts +1 -0
  35. package/dist/test/unit/routes/preset-row.test.js +36 -0
  36. package/dist/test/unit/routes/preset-row.test.js.map +1 -0
  37. package/frontend-vue/app/components/Explorer.vue +2 -0
  38. package/frontend-vue/app/components/FirstRun.vue +3 -1
  39. package/frontend-vue/app/components/PresetCards.vue +28 -5
  40. package/frontend-vue/app/components/RecentFiles.vue +11 -5
  41. package/frontend-vue/app/components/UploadQueue.vue +3 -1
  42. package/frontend-vue/app/components/UploadStrip.vue +3 -1
  43. package/frontend-vue/app/components/explorer/ExplorerDetailsDrawer.vue +10 -0
  44. package/frontend-vue/app/components/explorer/ExplorerInspector.vue +19 -14
  45. package/frontend-vue/app/components/explorer/ExplorerShell.vue +1 -11
  46. package/frontend-vue/app/composables/library/useExplorerCommands.ts +7 -1
  47. package/frontend-vue/app/composables/library/useExplorerDetailsDrawer.ts +75 -0
  48. package/frontend-vue/i18n/locales/media-en-GB.json +9 -2
  49. package/frontend-vue/i18n/locales/media-fr-FR.json +9 -2
  50. package/frontend-vue/package.json +1 -1
  51. package/frontend-vue/tests/detailsDrawer.test.ts +150 -0
  52. package/frontend-vue/tests/fixtures/serverRender.ts +70 -0
  53. package/frontend-vue/tests/locales.test.ts +17 -0
  54. package/frontend-vue/tests/serverRender.test.ts +47 -2
  55. package/package.json +7 -6
  56. package/skills/dms-media/SKILL.md +6 -0
  57. package/src/frontend-module.ts +35 -0
  58. package/src/index.ts +4 -28
  59. package/src/library/realtime.ts +12 -3
  60. package/src/pages/activity.ts +4 -0
  61. package/src/pages/overview.ts +4 -3
  62. package/src/pages/toolbar.ts +28 -0
  63. package/src/pages/uploads.ts +5 -0
  64. package/src/routes/media/manage.ts +17 -4
  65. package/src/test/antelope.test.ts +13 -4
  66. package/src/test/integration/media-activity-overview.test.ts +5 -0
  67. package/src/test/unit/library/realtime.test.ts +53 -0
  68. package/src/test/unit/pages/toolbar.test.ts +92 -0
  69. package/src/test/unit/routes/preset-row.test.ts +39 -0
@@ -78,16 +78,29 @@ interface PresetRowInput {
78
78
  example?: MediaAsset;
79
79
  }
80
80
 
81
- function presetRow({ preset, origin, renderedKeys, example }: PresetRowInput) {
81
+ /**
82
+ * A preset's card: `urlPattern` and `exampleUrl` are the absolute links a
83
+ * website copies, while `examplePreviewUrl` stays relative so the dashboard
84
+ * loads the preview through its own origin, which carries the member's
85
+ * session to a private example.
86
+ */
87
+ export function presetRow({
88
+ preset,
89
+ origin,
90
+ renderedKeys,
91
+ example,
92
+ }: PresetRowInput) {
82
93
  const cacheKey = presetCacheKey(preset);
94
+ const examplePath = example
95
+ ? `/media/${example._id}/${preset.id}/${encodeURIComponent(example.name)}`
96
+ : null;
83
97
  return {
84
98
  ...preset,
85
99
  cacheKey,
86
100
  rendered: renderedKeys.filter((key) => key === cacheKey).length,
87
101
  urlPattern: `${origin}/media/{asset}/${preset.id}/{filename}`,
88
- exampleUrl: example
89
- ? `${origin}/media/${example._id}/${preset.id}/${encodeURIComponent(example.name)}`
90
- : null,
102
+ exampleUrl: examplePath ? `${origin}${examplePath}` : null,
103
+ examplePreviewUrl: examplePath,
91
104
  };
92
105
  }
93
106
 
@@ -8,6 +8,7 @@ import { MongoMemoryReplSet } from "mongodb-memory-server-core";
8
8
  const API_PORT = 5019;
9
9
  const LOCAL_BUILD_COMMAND = process.env.DMS_PREBUILT ? [] : ["pnpm build"];
10
10
  const JWT_SECRET = "test-jwt-secret";
11
+ const HTML_RENDER_SECRET = "test-html-render-secret";
11
12
  const MONGO_BINARY_VERSION = "8.0.8";
12
13
  const SMTP_HOST = "127.0.0.1";
13
14
  const EPHEMERAL_PORT = 0;
@@ -109,19 +110,27 @@ export default defineConfig({
109
110
  source: {
110
111
  type: "package",
111
112
  package: "@antelopejs/dms",
112
- version: ">=0.9.3 <1.0.0",
113
+ version: ">=0.10.0 <1.0.0",
113
114
  },
114
115
  config: {
116
+ // No frontend server runs here: the dashboard URL is the API, whose
117
+ // paths the front proxy serves unchanged.
118
+ clientBaseUrl: `http://127.0.0.1:${API_PORT}`,
115
119
  auth: {
116
120
  jwtSecret: JWT_SECRET,
117
121
  },
122
+ // Outside development, which the test run is not, dms 0.10 refuses
123
+ // to start without a render secret of its own.
124
+ htmlRender: {
125
+ serviceSecret: HTML_RENDER_SECRET,
126
+ },
118
127
  },
119
128
  },
120
129
  mongodb: {
121
130
  source: {
122
131
  type: "package",
123
132
  package: "@antelopejs/mongodb",
124
- version: "1.4.3",
133
+ version: "1.4.4",
125
134
  },
126
135
  },
127
136
  "auth-jwt": {
@@ -138,7 +147,7 @@ export default defineConfig({
138
147
  source: {
139
148
  type: "package",
140
149
  package: "@antelopejs/api",
141
- version: "1.3.5",
150
+ version: "1.4.0",
142
151
  },
143
152
  config: {
144
153
  servers: [{ protocol: "http", host: "127.0.0.1", port: API_PORT }],
@@ -149,7 +158,7 @@ export default defineConfig({
149
158
  source: {
150
159
  type: "package",
151
160
  package: "@antelopejs/file-storage-local",
152
- version: "0.1.9",
161
+ version: "0.1.12",
153
162
  },
154
163
  },
155
164
  nodemailer: {
@@ -145,6 +145,11 @@ describe("[integration] media activity and overview — figures, upload history
145
145
  const response = await client.get("/api/media/presets");
146
146
  expect(response.data.isDefault).to.be.a("boolean");
147
147
  expect(response.data.presets[0].urlPattern).to.match(/^https?:\/\//);
148
+ for (const preset of response.data.presets) {
149
+ if (preset.examplePreviewUrl === null) continue;
150
+ expect(preset.examplePreviewUrl).to.match(/^\/media\//);
151
+ expect(preset.exampleUrl).to.match(/^https?:\/\//);
152
+ }
148
153
  const cache = await client.get("/api/media/presets/cache");
149
154
  expect(
150
155
  cache.data.items.map((item: { id: string }) => item.id),
@@ -0,0 +1,53 @@
1
+ import { expect } from "chai";
2
+ import {
3
+ type RealtimeMessage,
4
+ SubscribeMessage,
5
+ } from "@antelopejs/interface-dms";
6
+ import { MEDIA_LIBRARY_TOPIC } from "../../../constants";
7
+ import {
8
+ announceLibraryChange,
9
+ cancelLibraryChange,
10
+ } from "../../../library/realtime";
11
+
12
+ const SHORT_WINDOW_MS = 20;
13
+ const SETTLE_MS = 150;
14
+
15
+ function wait(ms: number): Promise<void> {
16
+ return new Promise((resolve) => setTimeout(resolve, ms));
17
+ }
18
+
19
+ describe("[unit] library — realtime", () => {
20
+ let messages: RealtimeMessage[];
21
+ let unsubscribe: () => void;
22
+
23
+ beforeEach(() => {
24
+ messages = [];
25
+ unsubscribe = SubscribeMessage(MEDIA_LIBRARY_TOPIC, (message) => {
26
+ messages.push(message);
27
+ });
28
+ });
29
+
30
+ afterEach(() => {
31
+ unsubscribe();
32
+ cancelLibraryChange();
33
+ });
34
+
35
+ it("announces a burst of changes once, with how many it stands for", async () => {
36
+ announceLibraryChange(SHORT_WINDOW_MS);
37
+ announceLibraryChange(SHORT_WINDOW_MS);
38
+ announceLibraryChange(SHORT_WINDOW_MS);
39
+ await wait(SETTLE_MS);
40
+ expect(messages).to.have.length(1);
41
+ expect(messages[0]?.payload).to.deep.equal({ count: 3 });
42
+ });
43
+
44
+ it("starts counting again after an announcement", async () => {
45
+ announceLibraryChange(SHORT_WINDOW_MS);
46
+ await wait(SETTLE_MS);
47
+ announceLibraryChange(SHORT_WINDOW_MS);
48
+ await wait(SETTLE_MS);
49
+ expect(messages.map((message) => message.payload?.count)).to.deep.equal([
50
+ 1, 1,
51
+ ]);
52
+ });
53
+ });
@@ -0,0 +1,92 @@
1
+ import { expect } from "chai";
2
+ import type { ComponentBuilder } from "@antelopejs/interface-dms/component";
3
+ import { MEDIA_LIBRARY_TOPIC } from "../../../constants";
4
+ import { MediaActivityPage } from "../../../pages/activity";
5
+ import { MediaOverviewPage } from "../../../pages/overview";
6
+ import { MEDIA_LIVE, mediaPageToolbar } from "../../../pages/toolbar";
7
+ import { MediaUploadsPage } from "../../../pages/uploads";
8
+
9
+ const TOOLBAR_COMPONENT = "dms-page-toolbar-block";
10
+ const LIVE_PAGES = {
11
+ overview: MediaOverviewPage,
12
+ activity: MediaActivityPage,
13
+ uploads: MediaUploadsPage,
14
+ };
15
+
16
+ type LivePage = (typeof LIVE_PAGES)[keyof typeof LIVE_PAGES];
17
+
18
+ /** The blocks a page declares, in the order it renders them. */
19
+ function pageBlocks(page: LivePage): ComponentBuilder<unknown>[] {
20
+ return Object.values(page) as ComponentBuilder<unknown>[];
21
+ }
22
+
23
+ /** What a block serializes to, as far as reading its data goes. */
24
+ interface SerializedBlock {
25
+ componentName: string;
26
+ options?: Record<string, unknown>;
27
+ children?: { id: string; component: SerializedBlock }[];
28
+ }
29
+
30
+ /**
31
+ * The blocks under `block` that read data, `block` included: a `fetchUrl`, or
32
+ * a table, which reads through a route of its own and only says its topic.
33
+ */
34
+ function fetchingBlocks(block: SerializedBlock): SerializedBlock[] {
35
+ const own =
36
+ block.options &&
37
+ ("fetchUrl" in block.options || "realtimeTopic" in block.options)
38
+ ? [block]
39
+ : [];
40
+ return [
41
+ ...own,
42
+ ...(block.children ?? []).flatMap((child: { component: SerializedBlock }) =>
43
+ fetchingBlocks(child.component),
44
+ ),
45
+ ];
46
+ }
47
+
48
+ describe("[unit] pages — toolbar", () => {
49
+ it("shows when the page last read the library and Direct / Pause, without a period", () => {
50
+ const serialized = mediaPageToolbar().serializeSync();
51
+ expect(serialized.componentName).to.equal(TOOLBAR_COMPONENT);
52
+ expect(serialized.children?.map((child) => child.id)).to.deep.equal([
53
+ "live",
54
+ ]);
55
+ expect(serialized.children?.[0]?.component.options).to.include({
56
+ missedLabel: "$dms_media.live.missed",
57
+ });
58
+ });
59
+
60
+ it("shares one Direct / Pause choice between the media pages", () => {
61
+ expect(MEDIA_LIVE.rememberKey).to.equal("media");
62
+ expect(MEDIA_LIVE.maxRate).to.be.greaterThan(0);
63
+ });
64
+
65
+ for (const [name, page] of Object.entries(LIVE_PAGES)) {
66
+ it(`puts the toolbar first on the ${name} page`, () => {
67
+ const [first] = pageBlocks(page);
68
+ expect(first?.serializeSync().componentName).to.equal(TOOLBAR_COMPONENT);
69
+ });
70
+ }
71
+
72
+ for (const [name, page] of Object.entries(LIVE_PAGES)) {
73
+ it(`reads every block of the ${name} page again on library changes`, () => {
74
+ const blocks = pageBlocks(page).flatMap((block) =>
75
+ fetchingBlocks(block.serializeSync() as SerializedBlock),
76
+ );
77
+ expect(blocks).to.have.length.greaterThan(0);
78
+ for (const block of blocks) {
79
+ expect(
80
+ block.options?.realtimeTopic,
81
+ `${block.componentName} ${JSON.stringify(block.options?.fetchUrl)}`,
82
+ ).to.equal(MEDIA_LIBRARY_TOPIC);
83
+ }
84
+ });
85
+ }
86
+
87
+ it("holds the upload history while the page is paused", () => {
88
+ expect(MediaUploadsPage.history.serializeSync().options).to.include({
89
+ liveHold: true,
90
+ });
91
+ });
92
+ });
@@ -0,0 +1,39 @@
1
+ import { expect } from "chai";
2
+ import type { MediaAsset } from "../../../db";
3
+ import type { MediaPresetConfig } from "../../../presets";
4
+ import { presetRow } from "../../../routes/media/manage";
5
+
6
+ const ORIGIN = "http://127.0.0.1:5010";
7
+ const ASSET_ID = "7554eb0a-c6fb-4518-a8b9-65c6e8a3e6a9";
8
+ const THUMB: MediaPresetConfig = { id: "thumb", width: 300, height: 300 };
9
+ const EXAMPLE = { _id: ASSET_ID, name: "Été à Liège.jpg" } as MediaAsset;
10
+ const EXAMPLE_PATH = `/media/${ASSET_ID}/thumb/%C3%89t%C3%A9%20%C3%A0%20Li%C3%A8ge.jpg`;
11
+
12
+ describe("[unit] routes/manage — image size cards", () => {
13
+ it("previews the example relative to the dashboard, which carries the session", () => {
14
+ const row = presetRow({
15
+ preset: THUMB,
16
+ origin: ORIGIN,
17
+ renderedKeys: [],
18
+ example: EXAMPLE,
19
+ });
20
+ expect(row.examplePreviewUrl).to.equal(EXAMPLE_PATH);
21
+ });
22
+
23
+ it("keeps the copied example link and pattern absolute on the public origin", () => {
24
+ const row = presetRow({
25
+ preset: THUMB,
26
+ origin: ORIGIN,
27
+ renderedKeys: [],
28
+ example: EXAMPLE,
29
+ });
30
+ expect(row.exampleUrl).to.equal(`${ORIGIN}${EXAMPLE_PATH}`);
31
+ expect(row.urlPattern).to.equal(`${ORIGIN}/media/{asset}/thumb/{filename}`);
32
+ });
33
+
34
+ it("has no example links without an example image", () => {
35
+ const row = presetRow({ preset: THUMB, origin: ORIGIN, renderedKeys: [] });
36
+ expect(row.exampleUrl).to.equal(null);
37
+ expect(row.examplePreviewUrl).to.equal(null);
38
+ });
39
+ });