@antelopejs/dms-media 0.7.0 → 0.7.2
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 +18 -24
- package/dist/acl/entries.js +2 -1
- package/dist/acl/entries.js.map +1 -1
- package/dist/asset-lifecycle.js.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/db/models/mediaAssets.model.d.ts +7 -5
- package/dist/db/models/mediaDeclarations.model.d.ts +7 -5
- package/dist/db/models/mediaEvents.model.d.ts +7 -5
- package/dist/db/models/mediaFavorites.model.d.ts +7 -5
- package/dist/db/models/mediaFolders.model.d.ts +7 -5
- package/dist/db/models/mediaUploads.model.d.ts +7 -5
- package/dist/declared/assets.js +3 -7
- package/dist/declared/assets.js.map +1 -1
- package/dist/declared/records.d.ts +2 -1
- package/dist/declared/records.js.map +1 -1
- package/dist/library/activity.d.ts +1 -1
- package/dist/library/activity.js +2 -1
- package/dist/library/activity.js.map +1 -1
- package/dist/pages/uploads.js +1 -1
- package/dist/pages/uploads.js.map +1 -1
- package/dist/routes/media/asset-actions.js +12 -4
- package/dist/routes/media/asset-actions.js.map +1 -1
- package/dist/routes/media/manage.js +2 -2
- package/dist/routes/media/manage.js.map +1 -1
- package/dist/routes/media/overview.js +5 -1
- package/dist/routes/media/overview.js.map +1 -1
- package/dist/routes/media/storage-keys.js.map +1 -1
- package/dist/routes/media/upload.js +1 -3
- package/dist/routes/media/upload.js.map +1 -1
- package/dist/test/antelope.test.js +13 -6
- package/dist/test/antelope.test.js.map +1 -1
- package/dist/test/helpers/assets.d.ts +24 -5
- package/dist/test/helpers/assets.js +22 -7
- package/dist/test/helpers/assets.js.map +1 -1
- package/dist/test/helpers/bodies.d.ts +31 -0
- package/dist/test/helpers/bodies.js +16 -0
- package/dist/test/helpers/bodies.js.map +1 -0
- package/dist/test/helpers/folders.d.ts +50 -0
- package/dist/test/helpers/folders.js +4 -2
- package/dist/test/helpers/folders.js.map +1 -1
- package/dist/test/helpers/members.js +10 -3
- package/dist/test/helpers/members.js.map +1 -1
- package/dist/test/helpers/owner.js +6 -1
- package/dist/test/helpers/owner.js.map +1 -1
- package/dist/test/helpers/permissions-world.d.ts +132 -11
- package/dist/test/helpers/permissions-world.js +21 -2
- package/dist/test/helpers/permissions-world.js.map +1 -1
- package/dist/test/helpers/setup-token.d.ts +1 -0
- package/dist/test/helpers/setup-token.js +5 -0
- package/dist/test/helpers/setup-token.js.map +1 -0
- package/dist/test/integration/derivative-sweep-query.test.js +1 -2
- package/dist/test/integration/derivative-sweep-query.test.js.map +1 -1
- package/dist/test/integration/folder-cascade.test.js +3 -1
- package/dist/test/integration/folder-cascade.test.js.map +1 -1
- package/dist/test/integration/media-activity-overview.test.js +39 -12
- package/dist/test/integration/media-activity-overview.test.js.map +1 -1
- package/dist/test/integration/media-api.test.js +22 -21
- package/dist/test/integration/media-api.test.js.map +1 -1
- package/dist/test/integration/media-bindings.test.js +6 -5
- package/dist/test/integration/media-bindings.test.js.map +1 -1
- package/dist/test/integration/media-declared-content.test.js +2 -1
- package/dist/test/integration/media-declared-content.test.js.map +1 -1
- package/dist/test/integration/media-delivery-editing.test.js +12 -2
- package/dist/test/integration/media-delivery-editing.test.js.map +1 -1
- package/dist/test/integration/media-delivery.test.js +5 -3
- package/dist/test/integration/media-delivery.test.js.map +1 -1
- package/dist/test/integration/media-explorer-writes.test.js +27 -4
- package/dist/test/integration/media-explorer-writes.test.js.map +1 -1
- package/dist/test/integration/media-file-history.test.d.ts +1 -0
- package/dist/test/integration/media-file-history.test.js +33 -0
- package/dist/test/integration/media-file-history.test.js.map +1 -0
- package/dist/test/integration/media-guards.test.js +11 -16
- package/dist/test/integration/media-guards.test.js.map +1 -1
- package/dist/test/integration/media-library.test.js +73 -23
- package/dist/test/integration/media-library.test.js.map +1 -1
- package/dist/test/integration/media-linked-subfolders.test.js +38 -2
- package/dist/test/integration/media-linked-subfolders.test.js.map +1 -1
- package/dist/test/integration/media-member-access.test.js +18 -2
- package/dist/test/integration/media-member-access.test.js.map +1 -1
- package/dist/test/integration/media-permissions.test.js +7 -2
- package/dist/test/integration/media-permissions.test.js.map +1 -1
- package/dist/test/integration/media-project-field.test.js +17 -2
- package/dist/test/integration/media-project-field.test.js.map +1 -1
- package/dist/test/integration/media-search-views.test.js +24 -10
- package/dist/test/integration/media-search-views.test.js.map +1 -1
- package/dist/test/integration/media-storage-origin-unreachable.test.js +2 -1
- package/dist/test/integration/media-storage-origin-unreachable.test.js.map +1 -1
- package/dist/test/integration/media-transform.test.js +8 -9
- package/dist/test/integration/media-transform.test.js.map +1 -1
- package/dist/test/integration/media-upload-history-filters.test.d.ts +1 -0
- package/dist/test/integration/media-upload-history-filters.test.js +67 -0
- package/dist/test/integration/media-upload-history-filters.test.js.map +1 -0
- package/dist/test/integration/media-upload-policy.test.js +70 -20
- package/dist/test/integration/media-upload-policy.test.js.map +1 -1
- package/dist/test/integration/permissions-management.js +15 -4
- package/dist/test/integration/permissions-management.js.map +1 -1
- package/dist/test/stack-modules.json +7 -0
- package/dist/test/unit/declared.test.js +1 -1
- package/dist/test/unit/declared.test.js.map +1 -1
- package/dist/test/unit/library/activity-overview.test.js +9 -0
- package/dist/test/unit/library/activity-overview.test.js.map +1 -1
- package/dist/test/unit/library/zip-names.test.js +22 -4
- package/dist/test/unit/library/zip-names.test.js.map +1 -1
- package/dist/test/unit/pages/toolbar.test.js +4 -4
- package/dist/test/unit/pages/toolbar.test.js.map +1 -1
- package/dist/test/unit/upload-rules.test.js +10 -0
- package/dist/test/unit/upload-rules.test.js.map +1 -1
- package/dist/transform-ops.js.map +1 -1
- package/dist/upload-checks.d.ts +1 -3
- package/dist/upload-checks.js +12 -14
- package/dist/upload-checks.js.map +1 -1
- package/dist/upload-policy.js +11 -11
- package/dist/upload-policy.js.map +1 -1
- package/dist/validation/declared.schema.d.ts +4 -4
- package/dist/validation/library.schema.d.ts +10 -10
- package/dist/validation/media.schema.d.ts +9 -9
- package/dist/validation/media.schema.js +5 -6
- package/dist/validation/media.schema.js.map +1 -1
- package/frontend-vue/app/components/explorer/ExplorerShell.vue +11 -7
- 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 +39 -39
- package/package.json +14 -12
- package/skills/dms-media/SKILL.md +3 -3
- package/src/acl/entries.ts +5 -2
- package/src/asset-lifecycle.ts +2 -1
- package/src/config.ts +4 -3
- package/src/declared/assets.ts +8 -10
- package/src/declared/records.ts +5 -1
- package/src/library/activity.ts +9 -3
- package/src/pages/uploads.ts +1 -1
- package/src/routes/media/asset-actions.ts +24 -3
- package/src/routes/media/manage.ts +2 -2
- package/src/routes/media/overview.ts +5 -4
- package/src/routes/media/storage-keys.ts +1 -0
- package/src/routes/media/upload.ts +2 -5
- package/src/test/antelope.test.ts +10 -6
- package/src/test/helpers/assets.ts +28 -15
- package/src/test/helpers/bodies.ts +22 -0
- package/src/test/helpers/folders.ts +6 -3
- package/src/test/helpers/members.ts +11 -3
- package/src/test/helpers/owner.ts +6 -1
- package/src/test/helpers/permissions-world.ts +23 -19
- package/src/test/helpers/setup-token.ts +6 -0
- package/src/test/integration/derivative-sweep-query.test.ts +4 -3
- package/src/test/integration/folder-cascade.test.ts +3 -1
- package/src/test/integration/media-activity-overview.test.ts +52 -37
- package/src/test/integration/media-api.test.ts +25 -27
- package/src/test/integration/media-bindings.test.ts +10 -16
- package/src/test/integration/media-declared-content.test.ts +2 -1
- package/src/test/integration/media-delivery-editing.test.ts +13 -2
- package/src/test/integration/media-delivery.test.ts +8 -3
- package/src/test/integration/media-explorer-writes.test.ts +28 -4
- package/src/test/integration/media-file-history.test.ts +38 -0
- package/src/test/integration/media-guards.test.ts +18 -13
- package/src/test/integration/media-library.test.ts +101 -47
- package/src/test/integration/media-linked-subfolders.test.ts +48 -3
- package/src/test/integration/media-member-access.test.ts +22 -24
- package/src/test/integration/media-permissions.test.ts +11 -5
- package/src/test/integration/media-project-field.test.ts +21 -9
- package/src/test/integration/media-search-views.test.ts +35 -31
- package/src/test/integration/media-storage-origin-unreachable.test.ts +2 -1
- package/src/test/integration/media-transform.test.ts +8 -9
- package/src/test/integration/media-upload-history-filters.test.ts +77 -0
- package/src/test/integration/media-upload-policy.test.ts +84 -30
- package/src/test/integration/permissions-management.ts +16 -4
- package/src/test/stack-modules.json +7 -0
- package/src/test/unit/declared.test.ts +4 -1
- package/src/test/unit/library/activity-overview.test.ts +15 -0
- package/src/test/unit/library/zip-names.test.ts +26 -7
- package/src/test/unit/pages/toolbar.test.ts +4 -4
- package/src/test/unit/upload-rules.test.ts +11 -0
- package/src/transform-ops.ts +1 -0
- package/src/upload-checks.ts +22 -18
- package/src/upload-policy.ts +11 -11
- package/src/validation/media.schema.ts +9 -8
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { AxiosInstance } from "axios";
|
|
2
2
|
import { expect } from "chai";
|
|
3
|
+
import { z } from "zod";
|
|
3
4
|
import { uploadAsset } from "../helpers/assets";
|
|
5
|
+
import { createdBody, readBody } from "../helpers/bodies";
|
|
4
6
|
import { authorizedClient } from "../helpers/http";
|
|
5
7
|
import { createRole, registerMember } from "../helpers/members";
|
|
6
8
|
import { ensureOwnerSession } from "../helpers/owner";
|
|
@@ -11,25 +13,35 @@ const TEXT_MIMETYPE = "text/plain";
|
|
|
11
13
|
const BODY = Buffer.alloc(10, 1);
|
|
12
14
|
const BATCH_ID = "overview-retried-batch";
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
id: string
|
|
16
|
-
landingSlug: string
|
|
17
|
-
readout
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const moduleEntrySchema = z.object({
|
|
17
|
+
id: z.string(),
|
|
18
|
+
landingSlug: z.string(),
|
|
19
|
+
readout: z
|
|
20
|
+
.array(z.object({ text: z.string(), tone: z.string().optional() }))
|
|
21
|
+
.optional(),
|
|
22
|
+
status: z.string().optional(),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const modulesBody = z.union([
|
|
26
|
+
z.array(moduleEntrySchema),
|
|
27
|
+
z.object({ modules: z.array(moduleEntrySchema) }),
|
|
28
|
+
]);
|
|
20
29
|
|
|
21
|
-
|
|
22
|
-
_id: string
|
|
23
|
-
files: number
|
|
24
|
-
failed: number
|
|
25
|
-
result: string
|
|
26
|
-
attention: string
|
|
27
|
-
}
|
|
30
|
+
const batchRowSchema = z.object({
|
|
31
|
+
_id: z.string(),
|
|
32
|
+
files: z.number(),
|
|
33
|
+
failed: z.number(),
|
|
34
|
+
result: z.string(),
|
|
35
|
+
attention: z.string(),
|
|
36
|
+
});
|
|
28
37
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
38
|
+
const batchesBody = z.object({ results: z.array(batchRowSchema) });
|
|
39
|
+
const attentionBody = z.object({
|
|
40
|
+
items: z.array(z.object({ id: z.string(), value: z.number().optional() })),
|
|
41
|
+
});
|
|
42
|
+
const activityBody = z.object({
|
|
43
|
+
items: z.array(z.object({ title: z.string(), to: z.string().optional() })),
|
|
44
|
+
});
|
|
33
45
|
|
|
34
46
|
describe("[integration] media activity and overview — figures, upload history and module catalog", () => {
|
|
35
47
|
let client: AxiosInstance;
|
|
@@ -39,9 +51,10 @@ describe("[integration] media activity and overview — figures, upload history
|
|
|
39
51
|
this.timeout(30_000);
|
|
40
52
|
const session = await ensureOwnerSession();
|
|
41
53
|
client = authorizedClient(session.accessToken);
|
|
42
|
-
folderId = (
|
|
43
|
-
await client.post("/api/media/folders", { name: "Overview figures" })
|
|
44
|
-
|
|
54
|
+
folderId = readBody(
|
|
55
|
+
await client.post("/api/media/folders", { name: "Overview figures" }),
|
|
56
|
+
createdBody,
|
|
57
|
+
).id;
|
|
45
58
|
});
|
|
46
59
|
|
|
47
60
|
after(async () => {
|
|
@@ -51,9 +64,8 @@ describe("[integration] media activity and overview — figures, upload history
|
|
|
51
64
|
it("lands the catalog tile on the overview, with a readout", async () => {
|
|
52
65
|
const response = await client.get("/dms/modules-listing");
|
|
53
66
|
expect(response.status).to.equal(HTTP_OK);
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
: response.data.modules;
|
|
67
|
+
const listing = readBody(response, modulesBody);
|
|
68
|
+
const entries = Array.isArray(listing) ? listing : listing.modules;
|
|
57
69
|
const media = entries.find((entry) => entry.id === "media");
|
|
58
70
|
expect(media?.landingSlug).to.equal("/modules/media/overview");
|
|
59
71
|
expect(media?.readout).to.have.length(2);
|
|
@@ -77,29 +89,30 @@ describe("[integration] media activity and overview — figures, upload history
|
|
|
77
89
|
const failedOnly = await client.get("/api/media/upload/batches", {
|
|
78
90
|
params: { filter_result: "is:partial,failed" },
|
|
79
91
|
});
|
|
80
|
-
expect(
|
|
81
|
-
|
|
82
|
-
);
|
|
92
|
+
expect(
|
|
93
|
+
readBody(failedOnly, batchesBody).results.map((row) => row._id),
|
|
94
|
+
).to.include(BATCH_ID);
|
|
83
95
|
expect((await report(2, 0)).status).to.equal(HTTP_OK);
|
|
84
96
|
const all = await client.get("/api/media/upload/batches");
|
|
85
|
-
const row = all.
|
|
86
|
-
(entry
|
|
97
|
+
const row = readBody(all, batchesBody).results.find(
|
|
98
|
+
(entry) => entry._id === BATCH_ID,
|
|
87
99
|
);
|
|
88
100
|
expect(row).to.include({ failed: 0, result: "complete" });
|
|
89
101
|
const stillFailed = await client.get("/api/media/upload/batches", {
|
|
90
102
|
params: { filter_result: "is:partial,failed" },
|
|
91
103
|
});
|
|
92
104
|
expect(
|
|
93
|
-
stillFailed.
|
|
105
|
+
readBody(stillFailed, batchesBody).results.map((entry) => entry._id),
|
|
94
106
|
).to.not.include(BATCH_ID);
|
|
95
107
|
});
|
|
96
108
|
|
|
97
109
|
it("counts on the overview exactly the failures the history flags", async () => {
|
|
98
|
-
const failingFolder = (
|
|
110
|
+
const failingFolder = readBody(
|
|
99
111
|
await client.post("/api/media/folders", {
|
|
100
112
|
name: "Overview failing uploads",
|
|
101
|
-
})
|
|
102
|
-
|
|
113
|
+
}),
|
|
114
|
+
createdBody,
|
|
115
|
+
).id;
|
|
103
116
|
await client.post("/api/media/upload/batches", {
|
|
104
117
|
batchId: "overview-failing-batch",
|
|
105
118
|
folderId: failingFolder,
|
|
@@ -112,15 +125,15 @@ describe("[integration] media activity and overview — figures, upload history
|
|
|
112
125
|
const rows = await client.get("/api/media/upload/batches", {
|
|
113
126
|
params: { filter_attention: "is:yes" },
|
|
114
127
|
});
|
|
115
|
-
return rows.
|
|
116
|
-
(total
|
|
128
|
+
return readBody(rows, batchesBody).results.reduce(
|
|
129
|
+
(total, row) => total + row.failed,
|
|
117
130
|
0,
|
|
118
131
|
);
|
|
119
132
|
};
|
|
120
133
|
const counted = async () => {
|
|
121
134
|
const attention = await client.get("/api/media/stats/attention");
|
|
122
|
-
const item = attention.
|
|
123
|
-
(entry
|
|
135
|
+
const item = readBody(attention, attentionBody).items.find(
|
|
136
|
+
(entry) => entry.id === "failed-uploads",
|
|
124
137
|
);
|
|
125
138
|
return item?.value ?? 0;
|
|
126
139
|
};
|
|
@@ -136,7 +149,9 @@ describe("[integration] media activity and overview — figures, upload history
|
|
|
136
149
|
const response = await client.get("/api/media/activity", {
|
|
137
150
|
params: { limit: 50 },
|
|
138
151
|
});
|
|
139
|
-
const titles = response.
|
|
152
|
+
const titles = readBody(response, activityBody).items.map(
|
|
153
|
+
(item) => item.title,
|
|
154
|
+
);
|
|
140
155
|
expect(titles).to.not.include("$dms_media.activity.upload_batch");
|
|
141
156
|
expect(titles).to.not.include("$dms_media.activity.upload_batch_partial");
|
|
142
157
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { AxiosInstance } from "axios";
|
|
2
|
-
import axios from "axios";
|
|
3
2
|
import { expect } from "chai";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { putPresigned } from "../helpers/assets";
|
|
5
|
+
import { createdBody, presignBody, readBody } from "../helpers/bodies";
|
|
4
6
|
import { authorizedClient } from "../helpers/http";
|
|
5
7
|
import { ensureOwnerSession } from "../helpers/owner";
|
|
6
8
|
|
|
@@ -26,18 +28,17 @@ async function waitForMediaApi(client: AxiosInstance): Promise<void> {
|
|
|
26
28
|
throw new Error("Timed out waiting for the media API to be ready");
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
31
|
+
const treeBody = z.object({
|
|
32
|
+
folders: z.array(
|
|
33
|
+
z.object({
|
|
34
|
+
id: z.string(),
|
|
35
|
+
parentId: z.string().nullable(),
|
|
36
|
+
rights: z
|
|
37
|
+
.object({ read: z.boolean(), write: z.boolean(), manage: z.boolean() })
|
|
38
|
+
.strict(),
|
|
39
|
+
}),
|
|
40
|
+
),
|
|
41
|
+
});
|
|
41
42
|
|
|
42
43
|
describe("[integration] media API — owner lifecycle", () => {
|
|
43
44
|
let client: AxiosInstance;
|
|
@@ -64,7 +65,7 @@ describe("[integration] media API — owner lifecycle", () => {
|
|
|
64
65
|
name: "Brand",
|
|
65
66
|
});
|
|
66
67
|
expect(created.status).to.equal(HTTP_OK);
|
|
67
|
-
brandFolderId = created.
|
|
68
|
+
brandFolderId = readBody(created, createdBody).id;
|
|
68
69
|
expect(brandFolderId).to.be.a("string");
|
|
69
70
|
|
|
70
71
|
const sub = await client.post("/api/media/folders", {
|
|
@@ -72,15 +73,15 @@ describe("[integration] media API — owner lifecycle", () => {
|
|
|
72
73
|
parentId: brandFolderId,
|
|
73
74
|
});
|
|
74
75
|
expect(sub.status).to.equal(HTTP_OK);
|
|
75
|
-
subFolderId = sub.
|
|
76
|
+
subFolderId = readBody(sub, createdBody).id;
|
|
76
77
|
|
|
77
78
|
const tree = await client.get("/api/media/tree");
|
|
78
79
|
expect(tree.data.folders).to.have.length(2);
|
|
79
|
-
const subNode = tree.
|
|
80
|
-
(node
|
|
80
|
+
const subNode = readBody(tree, treeBody).folders.find(
|
|
81
|
+
(node) => node.id === subFolderId,
|
|
81
82
|
);
|
|
82
|
-
expect(subNode
|
|
83
|
-
expect(subNode
|
|
83
|
+
expect(subNode?.parentId).to.equal(brandFolderId);
|
|
84
|
+
expect(subNode?.rights).to.deep.equal({
|
|
84
85
|
read: true,
|
|
85
86
|
write: true,
|
|
86
87
|
manage: true,
|
|
@@ -103,22 +104,19 @@ describe("[integration] media API — owner lifecycle", () => {
|
|
|
103
104
|
mimetype: FILE_MIMETYPE,
|
|
104
105
|
});
|
|
105
106
|
expect(presign.status).to.equal(HTTP_OK);
|
|
106
|
-
|
|
107
|
+
const presigned = readBody(presign, presignBody);
|
|
108
|
+
expect(presigned.resourceKey).to.be.a("string");
|
|
107
109
|
|
|
108
|
-
const putStatus = await
|
|
109
|
-
presign.data.uploadUrl,
|
|
110
|
-
presign.data.headers,
|
|
111
|
-
body,
|
|
112
|
-
);
|
|
110
|
+
const putStatus = (await putPresigned(presigned, body)).status;
|
|
113
111
|
expect(putStatus).to.be.lessThan(300);
|
|
114
112
|
|
|
115
113
|
const confirm = await client.post("/api/media/upload/confirm", {
|
|
116
114
|
folderId: brandFolderId,
|
|
117
|
-
resourceKey:
|
|
115
|
+
resourceKey: presigned.resourceKey,
|
|
118
116
|
filename: FILE_NAME,
|
|
119
117
|
});
|
|
120
118
|
expect(confirm.status).to.equal(HTTP_OK);
|
|
121
|
-
assetId = confirm.
|
|
119
|
+
assetId = readBody(confirm, z.object({ asset: createdBody })).asset.id;
|
|
122
120
|
expect(confirm.data.asset.name).to.equal(FILE_NAME);
|
|
123
121
|
expect(confirm.data.asset.mimetype).to.equal(FILE_MIMETYPE);
|
|
124
122
|
expect(confirm.data.asset.size).to.equal(body.byteLength);
|
|
@@ -8,7 +8,8 @@ import { CustomComponent } from "@antelopejs/interface-dms/base/custom";
|
|
|
8
8
|
import type { AxiosInstance } from "axios";
|
|
9
9
|
import { assert, expect } from "chai";
|
|
10
10
|
import { RegisterAssetBinding } from "@antelopejs/interface-dms-media";
|
|
11
|
-
import {
|
|
11
|
+
import { readBody } from "../helpers/bodies";
|
|
12
|
+
import { folderTreeBody, readFolderAcl } from "../helpers/folders";
|
|
12
13
|
import { authorizedClient } from "../helpers/http";
|
|
13
14
|
import { ensureOwnerSession } from "../helpers/owner";
|
|
14
15
|
|
|
@@ -28,13 +29,6 @@ class PageBoundProbePage extends PageController("page-bound-probe", {
|
|
|
28
29
|
static content = CustomComponent("dms-media-page-bound-probe");
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
interface FolderNode {
|
|
32
|
-
id: string;
|
|
33
|
-
name: string;
|
|
34
|
-
parentId: string | null;
|
|
35
|
-
bound: boolean;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
32
|
describe("[integration] media bindings — linked folder provisioning", () => {
|
|
39
33
|
let client: AxiosInstance;
|
|
40
34
|
let contentRootId: string;
|
|
@@ -62,7 +56,7 @@ describe("[integration] media bindings — linked folder provisioning", () => {
|
|
|
62
56
|
it("provisions the content root and the linked folder lazily", async () => {
|
|
63
57
|
const tree = await client.get("/api/media/tree");
|
|
64
58
|
expect(tree.status).to.equal(HTTP_OK);
|
|
65
|
-
const folders
|
|
59
|
+
const folders = readBody(tree, folderTreeBody).folders;
|
|
66
60
|
const contentRoot = folders.find(
|
|
67
61
|
(folder) => folder.name === "Content" && folder.parentId === null,
|
|
68
62
|
);
|
|
@@ -79,8 +73,8 @@ describe("[integration] media bindings — linked folder provisioning", () => {
|
|
|
79
73
|
const first = await client.get("/api/media/tree");
|
|
80
74
|
const second = await client.get("/api/media/tree");
|
|
81
75
|
expect(second.data.folders.length).to.equal(first.data.folders.length);
|
|
82
|
-
const bound = second.
|
|
83
|
-
(folder
|
|
76
|
+
const bound = readBody(second, folderTreeBody).folders.filter(
|
|
77
|
+
(folder) => folder.name === "Article covers",
|
|
84
78
|
);
|
|
85
79
|
expect(bound).to.have.length(1);
|
|
86
80
|
});
|
|
@@ -101,10 +95,10 @@ describe("[integration] media bindings — linked folder provisioning", () => {
|
|
|
101
95
|
const pagePermission = GetPermissionId(PageBoundProbePage);
|
|
102
96
|
expect(pagePermission, "probe page permission").to.be.a("string");
|
|
103
97
|
const tree = await client.get("/api/media/tree");
|
|
104
|
-
const folder = tree.
|
|
105
|
-
(node
|
|
98
|
+
const folder = readBody(tree, folderTreeBody).folders.find(
|
|
99
|
+
(node) => node.name === PAGE_BOUND_FOLDER_NAME,
|
|
106
100
|
);
|
|
107
|
-
|
|
101
|
+
assert.isDefined(folder, "page-bound folder");
|
|
108
102
|
const entries = await readFolderAcl(folder.id);
|
|
109
103
|
expect(entries).to.deep.include({
|
|
110
104
|
subject: { kind: "permission", id: pagePermission },
|
|
@@ -150,8 +144,8 @@ describe("[integration] media bindings — linked folder provisioning", () => {
|
|
|
150
144
|
expect(response.status).to.equal(HTTP_OK);
|
|
151
145
|
}
|
|
152
146
|
const tree = await client.get("/api/media/tree");
|
|
153
|
-
const probes = tree.
|
|
154
|
-
(folder
|
|
147
|
+
const probes = readBody(tree, folderTreeBody).folders.filter(
|
|
148
|
+
(folder) => folder.name === PROBE_NAME,
|
|
155
149
|
);
|
|
156
150
|
expect(probes).to.have.length(1);
|
|
157
151
|
});
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
MediaFolderModel,
|
|
22
22
|
} from "../../db";
|
|
23
23
|
import { ONE_PIXEL_PNG, PNG_MIMETYPE } from "../helpers/assets";
|
|
24
|
+
import { readBody, urlBody } from "../helpers/bodies";
|
|
24
25
|
import { readFolderAcl } from "../helpers/folders";
|
|
25
26
|
import { authorizedClient } from "../helpers/http";
|
|
26
27
|
import { ensureOwnerSession } from "../helpers/owner";
|
|
@@ -336,7 +337,7 @@ describe("[integration] media declared content — folders and files shipped as
|
|
|
336
337
|
`/api/media/assets/${first.id}/read-url`,
|
|
337
338
|
);
|
|
338
339
|
expect(readUrl.status).to.equal(HTTP_OK);
|
|
339
|
-
const stored = await fetch(readUrl.
|
|
340
|
+
const stored = await fetch(readBody(readUrl, urlBody).url);
|
|
340
341
|
expect(Buffer.from(await stored.arrayBuffer())).to.deep.equal(
|
|
341
342
|
ONE_PIXEL_PNG,
|
|
342
343
|
);
|
|
@@ -4,6 +4,7 @@ import { assert, expect } from "chai";
|
|
|
4
4
|
import { GetModel } from "@antelopejs/interface-database-decorators";
|
|
5
5
|
import { DEFAULT_TENANT_ID } from "@antelopejs/interface-dms/constants";
|
|
6
6
|
import sharp from "sharp";
|
|
7
|
+
import { z } from "zod";
|
|
7
8
|
import { MediaAssetModel } from "../../db";
|
|
8
9
|
import { uploadStorageBytes } from "../../derivatives";
|
|
9
10
|
import {
|
|
@@ -12,9 +13,16 @@ import {
|
|
|
12
13
|
MediaAssetChangedError,
|
|
13
14
|
} from "../../transform";
|
|
14
15
|
import { type UploadedAsset, uploadAsset } from "../helpers/assets";
|
|
16
|
+
import { createdBody, readBody } from "../helpers/bodies";
|
|
15
17
|
import { authorizedClient, getBaseUrl } from "../helpers/http";
|
|
16
18
|
import { ensureOwnerSession } from "../helpers/owner";
|
|
17
19
|
|
|
20
|
+
const previewsBody = z.object({
|
|
21
|
+
previews: z
|
|
22
|
+
.record(z.string())
|
|
23
|
+
.transform((urls) => new Map(Object.entries(urls))),
|
|
24
|
+
});
|
|
25
|
+
|
|
18
26
|
const HTTP_OK = 200;
|
|
19
27
|
const HTTP_FOUND = 302;
|
|
20
28
|
const HTTP_NOT_MODIFIED = 304;
|
|
@@ -153,7 +161,7 @@ describe("[integration] media delivery and editing — cache, orientation, activ
|
|
|
153
161
|
name: "Delivery and editing",
|
|
154
162
|
});
|
|
155
163
|
expect(folder.status).to.equal(HTTP_OK);
|
|
156
|
-
folderId = folder.
|
|
164
|
+
folderId = readBody(folder, createdBody).id;
|
|
157
165
|
jpeg = await uploadAsset(
|
|
158
166
|
client,
|
|
159
167
|
folderId,
|
|
@@ -341,9 +349,12 @@ describe("[integration] media delivery and editing — cache, orientation, activ
|
|
|
341
349
|
`/api/media/previews?ids=${logo.id}&ids=${banner.id}`,
|
|
342
350
|
);
|
|
343
351
|
expect(answer.status).to.equal(HTTP_OK);
|
|
352
|
+
const { previews } = readBody(answer, previewsBody);
|
|
344
353
|
const [vector, raster] = await Promise.all(
|
|
345
354
|
[logo.id, banner.id].map(async (id) => {
|
|
346
|
-
const
|
|
355
|
+
const preview = previews.get(id);
|
|
356
|
+
assert.isDefined(preview, `preview of ${id}`);
|
|
357
|
+
const response = await fetch(preview);
|
|
347
358
|
return sharp(Buffer.from(await response.arrayBuffer())).metadata();
|
|
348
359
|
}),
|
|
349
360
|
);
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { AxiosInstance } from "axios";
|
|
2
2
|
import { assert, expect } from "chai";
|
|
3
|
+
import { z } from "zod";
|
|
3
4
|
import {
|
|
4
5
|
ONE_PIXEL_PNG,
|
|
5
6
|
PNG_NAME,
|
|
6
7
|
rawGet,
|
|
7
8
|
uploadPixelPng,
|
|
8
9
|
} from "../helpers/assets";
|
|
10
|
+
import { createdBody, readBody, urlBody } from "../helpers/bodies";
|
|
9
11
|
import { authorizedClient } from "../helpers/http";
|
|
10
12
|
import { ensureOwnerSession } from "../helpers/owner";
|
|
11
13
|
|
|
@@ -39,7 +41,7 @@ describe("[integration] media delivery — visibility and derivatives", () => {
|
|
|
39
41
|
name: "Delivery",
|
|
40
42
|
});
|
|
41
43
|
expect(folder.status).to.equal(HTTP_OK);
|
|
42
|
-
folderId = folder.
|
|
44
|
+
folderId = readBody(folder, createdBody).id;
|
|
43
45
|
const asset = await uploadPixelPng(client, folderId);
|
|
44
46
|
assetId = asset.id;
|
|
45
47
|
});
|
|
@@ -115,7 +117,7 @@ describe("[integration] media delivery — visibility and derivatives", () => {
|
|
|
115
117
|
`/api/media/assets/${assetId}/read-url?preset=thumb`,
|
|
116
118
|
);
|
|
117
119
|
expect(derived.status).to.equal(HTTP_OK);
|
|
118
|
-
const bytes = await fetchBytes(derived.
|
|
120
|
+
const bytes = await fetchBytes(readBody(derived, urlBody).url);
|
|
119
121
|
expect(bytes.byteLength).to.be.greaterThan(0);
|
|
120
122
|
});
|
|
121
123
|
|
|
@@ -123,7 +125,10 @@ describe("[integration] media delivery — visibility and derivatives", () => {
|
|
|
123
125
|
const listing = await client.get("/api/media/assets");
|
|
124
126
|
expect(listing.status).to.equal(HTTP_OK);
|
|
125
127
|
expect(listing.data.truncated).to.equal(false);
|
|
126
|
-
const ids =
|
|
128
|
+
const ids = readBody(
|
|
129
|
+
listing,
|
|
130
|
+
z.object({ assets: z.array(createdBody) }),
|
|
131
|
+
).assets.map((asset) => asset.id);
|
|
127
132
|
expect(ids).to.include(assetId);
|
|
128
133
|
|
|
129
134
|
const secondAsset = await uploadPixelPng(client, folderId);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AxiosInstance } from "axios";
|
|
2
2
|
import { expect } from "chai";
|
|
3
|
+
import { z } from "zod";
|
|
3
4
|
import { GetModel } from "@antelopejs/interface-database-decorators";
|
|
4
5
|
import { DEFAULT_TENANT_ID } from "@antelopejs/interface-dms/constants";
|
|
5
6
|
import {
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
import { CONTENT_ROOT_BINDING } from "../../bindings";
|
|
10
11
|
import { MediaEventModel, MediaFolderModel } from "../../db";
|
|
11
12
|
import { uploadPixelPng, uploadTextAsset } from "../helpers/assets";
|
|
13
|
+
import { createdBody, readBody } from "../helpers/bodies";
|
|
12
14
|
import { fetchFolderNodes } from "../helpers/folders";
|
|
13
15
|
import { authorizedClient } from "../helpers/http";
|
|
14
16
|
import { ensureOwnerSession } from "../helpers/owner";
|
|
@@ -72,12 +74,12 @@ describe("[integration] media explorer writes — names, linked folders, zips",
|
|
|
72
74
|
name: "Explorer writes",
|
|
73
75
|
});
|
|
74
76
|
expect(root.status).to.equal(HTTP_OK);
|
|
75
|
-
rootId = root.
|
|
77
|
+
rootId = readBody(root, createdBody).id;
|
|
76
78
|
const other = await client.post("/api/media/folders", {
|
|
77
79
|
name: "Other",
|
|
78
80
|
parentId: rootId,
|
|
79
81
|
});
|
|
80
|
-
otherId = other.
|
|
82
|
+
otherId = readBody(other, createdBody).id;
|
|
81
83
|
});
|
|
82
84
|
|
|
83
85
|
after(async () => {
|
|
@@ -116,7 +118,7 @@ describe("[integration] media explorer writes — names, linked folders, zips",
|
|
|
116
118
|
const event = events.find((entry) => entry.targetName === "Traced");
|
|
117
119
|
expect(event?.folderId).to.equal(rootId);
|
|
118
120
|
expect(JSON.parse(event?.json_details ?? "{}")).to.deep.equal({
|
|
119
|
-
targetId: created.
|
|
121
|
+
targetId: readBody(created, createdBody).id,
|
|
120
122
|
});
|
|
121
123
|
});
|
|
122
124
|
|
|
@@ -157,6 +159,28 @@ describe("[integration] media explorer writes — names, linked folders, zips",
|
|
|
157
159
|
expect(sameNameElsewhere.status).to.equal(HTTP_OK);
|
|
158
160
|
});
|
|
159
161
|
|
|
162
|
+
it("refuses to move a file onto a name the target folder already holds, regardless of case", async () => {
|
|
163
|
+
const held = await uploadTextAsset(client, otherId, "Report.txt");
|
|
164
|
+
const mover = await uploadTextAsset(client, rootId, "report.txt");
|
|
165
|
+
const moved = await client.post(`/api/media/assets/${mover.id}/move`, {
|
|
166
|
+
folderId: otherId,
|
|
167
|
+
});
|
|
168
|
+
expect(moved.status).to.equal(HTTP_CONFLICT);
|
|
169
|
+
expect(moved.data).to.equal(`${ERRORS}.name_taken`);
|
|
170
|
+
const bulk = await client.post("/api/media/assets/bulk/move", {
|
|
171
|
+
ids: [mover.id],
|
|
172
|
+
folderId: otherId,
|
|
173
|
+
});
|
|
174
|
+
expect(bulk.data.done).to.deep.equal([]);
|
|
175
|
+
expect(bulk.data.refused).to.deep.equal([
|
|
176
|
+
{ id: mover.id, status: HTTP_CONFLICT, message: `${ERRORS}.name_taken` },
|
|
177
|
+
]);
|
|
178
|
+
const detail = await client.get(`/api/media/assets/${mover.id}`);
|
|
179
|
+
expect(detail.data.asset.folderId).to.equal(rootId);
|
|
180
|
+
await client.delete(`/api/media/assets/${held.id}`);
|
|
181
|
+
await client.delete(`/api/media/assets/${mover.id}`);
|
|
182
|
+
});
|
|
183
|
+
|
|
160
184
|
it("answers validation errors with i18n keys instead of zod dumps", async () => {
|
|
161
185
|
const asset = await uploadPixelPng(client, rootId);
|
|
162
186
|
const tooLong = await client.post(`/api/media/assets/${asset.id}/update`, {
|
|
@@ -190,7 +214,7 @@ describe("[integration] media explorer writes — names, linked folders, zips",
|
|
|
190
214
|
expect(zipped.headers["content-disposition"]).to.contain(
|
|
191
215
|
"Explorer writes.zip",
|
|
192
216
|
);
|
|
193
|
-
const names = zipEntryNames(
|
|
217
|
+
const names = zipEntryNames(readBody(zipped, z.instanceof(Buffer)));
|
|
194
218
|
expect(names).to.include.members([
|
|
195
219
|
"Notes.txt",
|
|
196
220
|
"other.txt",
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { uploadPixelPng } from "../helpers/assets";
|
|
4
|
+
import { createdBody, readBody } from "../helpers/bodies";
|
|
5
|
+
import { authorizedClient } from "../helpers/http";
|
|
6
|
+
import { ensureOwnerSession } from "../helpers/owner";
|
|
7
|
+
|
|
8
|
+
const HTTP_OK = 200;
|
|
9
|
+
const RENAMES = 55;
|
|
10
|
+
|
|
11
|
+
const historyBody = z.object({
|
|
12
|
+
items: z.array(z.object({ title: z.string() })),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe("[integration] file history — every event of the file", () => {
|
|
16
|
+
it("lists more than 50 events, the upload last", async function () {
|
|
17
|
+
this.timeout(60_000);
|
|
18
|
+
const session = await ensureOwnerSession();
|
|
19
|
+
const client = authorizedClient(session.accessToken);
|
|
20
|
+
const folderId = readBody(
|
|
21
|
+
await client.post("/api/media/folders", { name: "File history spec" }),
|
|
22
|
+
createdBody,
|
|
23
|
+
).id;
|
|
24
|
+
const asset = await uploadPixelPng(client, folderId);
|
|
25
|
+
for (let index = 1; index <= RENAMES; index += 1) {
|
|
26
|
+
const rename = await client.post(`/api/media/assets/${asset.id}/update`, {
|
|
27
|
+
name: `history-${index}.png`,
|
|
28
|
+
});
|
|
29
|
+
expect(rename.status, `rename ${index}`).to.equal(HTTP_OK);
|
|
30
|
+
}
|
|
31
|
+
const history = await client.get(`/api/media/assets/${asset.id}/history`);
|
|
32
|
+
const titles = readBody(history, historyBody).items.map(
|
|
33
|
+
(item) => item.title,
|
|
34
|
+
);
|
|
35
|
+
expect(titles).to.have.length(RENAMES + 1);
|
|
36
|
+
expect(titles.at(-1)).to.equal("$dms_media.activity.asset_upload");
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import
|
|
2
|
+
import type { AxiosInstance } from "axios";
|
|
3
3
|
import { expect } from "chai";
|
|
4
|
+
import { putPresigned } from "../helpers/assets";
|
|
5
|
+
import { createdBody, presignBody, readBody } from "../helpers/bodies";
|
|
4
6
|
import { authorizedClient, createClient } from "../helpers/http";
|
|
5
7
|
import { ensureOwnerSession } from "../helpers/owner";
|
|
6
8
|
|
|
@@ -99,12 +101,14 @@ describe("[integration] media guards — every endpoint requires auth and rights
|
|
|
99
101
|
});
|
|
100
102
|
expect(folder.status).to.equal(HTTP_OK);
|
|
101
103
|
const confirm = await owner.post("/api/media/upload/confirm", {
|
|
102
|
-
folderId: folder.
|
|
104
|
+
folderId: readBody(folder, createdBody).id,
|
|
103
105
|
resourceKey: "media/whatever/not-staged.txt",
|
|
104
106
|
filename: "not-staged.txt",
|
|
105
107
|
});
|
|
106
108
|
expect(confirm.status).to.equal(HTTP_BAD_REQUEST);
|
|
107
|
-
await owner.delete(
|
|
109
|
+
await owner.delete(
|
|
110
|
+
`/api/media/folders/${readBody(folder, createdBody).id}`,
|
|
111
|
+
);
|
|
108
112
|
});
|
|
109
113
|
|
|
110
114
|
it("filters unreadable assets out of previews instead of failing", async () => {
|
|
@@ -120,25 +124,26 @@ describe("[integration] media guards — every endpoint requires auth and rights
|
|
|
120
124
|
const folderB = await owner.post("/api/media/folders", { name: "KeyB" });
|
|
121
125
|
const body = Buffer.from("cross-folder");
|
|
122
126
|
const presign = await owner.post("/api/media/upload/presign", {
|
|
123
|
-
folderId: folderA.
|
|
127
|
+
folderId: readBody(folderA, createdBody).id,
|
|
124
128
|
filename: "x.txt",
|
|
125
129
|
size: body.byteLength,
|
|
126
130
|
mimetype: "text/plain",
|
|
127
131
|
});
|
|
128
132
|
expect(presign.status).to.equal(HTTP_OK);
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
validateStatus: () => true,
|
|
132
|
-
transformRequest: [(data) => data],
|
|
133
|
-
});
|
|
133
|
+
const presigned = readBody(presign, presignBody);
|
|
134
|
+
const put = await putPresigned(presigned, body);
|
|
134
135
|
expect(put.status).to.be.lessThan(300);
|
|
135
136
|
const confirm = await owner.post("/api/media/upload/confirm", {
|
|
136
|
-
folderId: folderB.
|
|
137
|
-
resourceKey:
|
|
137
|
+
folderId: readBody(folderB, createdBody).id,
|
|
138
|
+
resourceKey: presigned.resourceKey,
|
|
138
139
|
filename: "x.txt",
|
|
139
140
|
});
|
|
140
141
|
expect(confirm.status).to.equal(HTTP_BAD_REQUEST);
|
|
141
|
-
await owner.delete(
|
|
142
|
-
|
|
142
|
+
await owner.delete(
|
|
143
|
+
`/api/media/folders/${readBody(folderA, createdBody).id}`,
|
|
144
|
+
);
|
|
145
|
+
await owner.delete(
|
|
146
|
+
`/api/media/folders/${readBody(folderB, createdBody).id}`,
|
|
147
|
+
);
|
|
143
148
|
});
|
|
144
149
|
});
|