@antelopejs/dms-media 0.6.1 → 0.6.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 +16 -1
- package/dist/acl/entries.js +1 -2
- package/dist/acl/entries.js.map +1 -1
- package/dist/bindings.js +1 -3
- package/dist/bindings.js.map +1 -1
- package/dist/declared/folders.js +3 -2
- package/dist/declared/folders.js.map +1 -1
- package/dist/declared/records.d.ts +2 -2
- package/dist/declared/records.js +3 -2
- package/dist/declared/records.js.map +1 -1
- package/dist/derivatives.js +9 -6
- package/dist/derivatives.js.map +1 -1
- package/dist/guards.d.ts +4 -0
- package/dist/guards.js +19 -0
- package/dist/guards.js.map +1 -0
- package/dist/library/activity.js +7 -5
- package/dist/library/activity.js.map +1 -1
- package/dist/library/batches.js +6 -3
- package/dist/library/batches.js.map +1 -1
- package/dist/library/events.js +4 -4
- package/dist/library/events.js.map +1 -1
- package/dist/library/module-readout.js +5 -2
- package/dist/library/module-readout.js.map +1 -1
- package/dist/library/realtime.js.map +1 -1
- package/dist/pages/activity.js +1 -1
- package/dist/pages/activity.js.map +1 -1
- package/dist/routes/media/assets.d.ts +1 -1
- package/dist/routes/media/assets.js +5 -5
- package/dist/routes/media/assets.js.map +1 -1
- package/dist/routes/media/bulk.js +17 -13
- package/dist/routes/media/bulk.js.map +1 -1
- package/dist/routes/media/delivery-headers.js +9 -9
- package/dist/routes/media/delivery-headers.js.map +1 -1
- package/dist/routes/media/delivery-stream.js.map +1 -1
- package/dist/routes/media/delivery.js.map +1 -1
- package/dist/routes/media/manage.js.map +1 -1
- package/dist/routes/media/transform.js +13 -8
- package/dist/routes/media/transform.js.map +1 -1
- package/dist/test/antelope.test.js +13 -12
- package/dist/test/antelope.test.js.map +1 -1
- package/dist/test/helpers/folders.d.ts +27 -0
- package/dist/test/helpers/folders.js +15 -0
- package/dist/test/helpers/folders.js.map +1 -1
- package/dist/test/helpers/pages.js +10 -6
- package/dist/test/helpers/pages.js.map +1 -1
- package/dist/test/helpers/permissions-world.d.ts +98 -0
- package/dist/test/helpers/permissions-world.js +205 -0
- package/dist/test/helpers/permissions-world.js.map +1 -0
- package/dist/test/helpers/prototype.d.ts +1 -0
- package/dist/test/helpers/prototype.js +11 -0
- package/dist/test/helpers/prototype.js.map +1 -0
- package/dist/test/integration/derivative-sweep-query.test.js +13 -16
- package/dist/test/integration/derivative-sweep-query.test.js.map +1 -1
- package/dist/test/integration/folder-query.test.js +5 -9
- package/dist/test/integration/folder-query.test.js.map +1 -1
- package/dist/test/integration/media-bindings.test.js +2 -2
- package/dist/test/integration/media-bindings.test.js.map +1 -1
- package/dist/test/integration/media-cleanup.test.js +14 -17
- package/dist/test/integration/media-cleanup.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 +7 -5
- package/dist/test/integration/media-delivery-editing.test.js.map +1 -1
- package/dist/test/integration/media-delivery.test.js +19 -5
- package/dist/test/integration/media-delivery.test.js.map +1 -1
- package/dist/test/integration/media-explorer-writes.test.js +2 -2
- package/dist/test/integration/media-explorer-writes.test.js.map +1 -1
- package/dist/test/integration/media-guards.test.js +18 -7
- package/dist/test/integration/media-guards.test.js.map +1 -1
- package/dist/test/integration/media-library.test.js +1 -1
- package/dist/test/integration/media-library.test.js.map +1 -1
- package/dist/test/integration/media-linked-subfolders.test.js +5 -5
- package/dist/test/integration/media-linked-subfolders.test.js.map +1 -1
- package/dist/test/integration/media-member-access.test.js +2 -5
- package/dist/test/integration/media-member-access.test.js.map +1 -1
- package/dist/test/integration/media-permissions.test.js +142 -473
- package/dist/test/integration/media-permissions.test.js.map +1 -1
- package/dist/test/integration/media-project-field.test.js +3 -5
- package/dist/test/integration/media-project-field.test.js.map +1 -1
- package/dist/test/integration/media-search-query.test.js +11 -16
- package/dist/test/integration/media-search-query.test.js.map +1 -1
- package/dist/test/integration/media-storage-origin-unreachable.test.js +1 -0
- package/dist/test/integration/media-storage-origin-unreachable.test.js.map +1 -1
- package/dist/test/integration/media-upload-policy.test.js +2 -2
- package/dist/test/integration/media-upload-policy.test.js.map +1 -1
- package/dist/test/integration/permissions-management.d.ts +2 -0
- package/dist/test/integration/permissions-management.js +189 -0
- package/dist/test/integration/permissions-management.js.map +1 -0
- package/dist/test/unit/acl/entries.test.js +2 -1
- package/dist/test/unit/acl/entries.test.js.map +1 -1
- package/dist/test/unit/acl/resolver.test.js +10 -3
- package/dist/test/unit/acl/resolver.test.js.map +1 -1
- package/dist/test/unit/library/fixtures.d.ts +1 -1
- package/dist/test/unit/library/fixtures.js +6 -1
- package/dist/test/unit/library/fixtures.js.map +1 -1
- package/dist/test/unit/library/library.test.js +0 -1
- package/dist/test/unit/library/library.test.js.map +1 -1
- package/dist/test/unit/library/realtime.test.js.map +1 -1
- package/dist/test/unit/library/search-facets.test.js +2 -2
- package/dist/test/unit/library/search-facets.test.js.map +1 -1
- package/dist/test/unit/pages/toolbar.test.js +24 -7
- package/dist/test/unit/pages/toolbar.test.js.map +1 -1
- package/dist/test/unit/routes/dto.test.js +7 -6
- package/dist/test/unit/routes/dto.test.js.map +1 -1
- package/dist/test/unit/routes/file-page.test.js +5 -7
- package/dist/test/unit/routes/file-page.test.js.map +1 -1
- package/dist/test/unit/routes/preset-row.test.js +2 -1
- package/dist/test/unit/routes/preset-row.test.js.map +1 -1
- package/dist/transform.js +6 -6
- package/dist/transform.js.map +1 -1
- package/dist/upload-checks.d.ts +8 -2
- package/dist/upload-checks.js.map +1 -1
- package/dist/upload-policy.js +8 -8
- package/dist/upload-policy.js.map +1 -1
- package/dist/validation/declared.schema.js +14 -8
- package/dist/validation/declared.schema.js.map +1 -1
- package/dist/validation/media.schema.d.ts +1 -1
- package/dist/validation/media.schema.js +2 -2
- package/dist/validation/media.schema.js.map +1 -1
- package/frontend-vue/app/build/imageEditor/editorShapes.ts +118 -0
- package/frontend-vue/app/build/imageEditor/useEditorSaving.ts +86 -0
- package/frontend-vue/app/build/library/libraryActions.ts +444 -0
- package/frontend-vue/app/build/library/libraryCore.ts +136 -0
- package/frontend-vue/app/components/ImageEditor.vue +22 -179
- package/frontend-vue/app/composables/library/useMediaLibrary.ts +3 -575
- package/frontend-vue/app/composables/useMediaApi.ts +21 -5
- package/frontend-vue/build/backend-boundary.ts +122 -0
- package/frontend-vue/dms.frontend.build.ts +3 -0
- package/frontend-vue/eslint.config.mjs +13 -0
- package/frontend-vue/package.json +3 -1
- package/frontend-vue/pnpm-lock.yaml +217 -61
- package/frontend-vue/tests/backend-boundary.test.ts +203 -0
- package/frontend-vue/tests/mediaPreviews.test.ts +39 -0
- package/package.json +4 -10
- package/skills/dms-media/SKILL.md +1 -0
- package/skills/dms-media/cases.json +38 -0
- package/src/acl/entries.ts +6 -4
- package/src/bindings.ts +3 -3
- package/src/declared/folders.ts +3 -3
- package/src/declared/records.ts +9 -8
- package/src/derivatives.ts +10 -6
- package/src/guards.ts +19 -0
- package/src/library/activity.ts +17 -9
- package/src/library/batches.ts +12 -9
- package/src/library/events.ts +7 -4
- package/src/library/module-readout.ts +6 -2
- package/src/library/realtime.ts +5 -1
- package/src/library/zip.ts +1 -1
- package/src/pages/activity.ts +6 -2
- package/src/routes/media/assets.ts +4 -3
- package/src/routes/media/bulk.ts +16 -14
- package/src/routes/media/delivery-headers.ts +9 -12
- package/src/routes/media/delivery-stream.ts +3 -2
- package/src/routes/media/delivery.ts +4 -2
- package/src/routes/media/manage.ts +4 -6
- package/src/routes/media/transform.ts +27 -23
- package/src/test/antelope.test.ts +21 -17
- package/src/test/helpers/folders.ts +22 -0
- package/src/test/helpers/pages.ts +12 -5
- package/src/test/helpers/permissions-world.ts +326 -0
- package/src/test/helpers/prototype.ts +12 -0
- package/src/test/integration/derivative-sweep-query.test.ts +19 -21
- package/src/test/integration/folder-query.test.ts +11 -11
- package/src/test/integration/media-bindings.test.ts +7 -7
- package/src/test/integration/media-cleanup.test.ts +25 -37
- package/src/test/integration/media-declared-content.test.ts +18 -19
- package/src/test/integration/media-delivery-editing.test.ts +11 -7
- package/src/test/integration/media-delivery.test.ts +29 -8
- package/src/test/integration/media-explorer-writes.test.ts +2 -7
- package/src/test/integration/media-guards.test.ts +21 -7
- package/src/test/integration/media-library.test.ts +1 -1
- package/src/test/integration/media-linked-subfolders.test.ts +11 -20
- package/src/test/integration/media-member-access.test.ts +5 -9
- package/src/test/integration/media-permissions.test.ts +56 -570
- package/src/test/integration/media-project-field.test.ts +5 -7
- package/src/test/integration/media-search-query.test.ts +16 -20
- package/src/test/integration/media-storage-origin-unreachable.test.ts +3 -2
- package/src/test/integration/media-upload-policy.test.ts +2 -8
- package/src/test/integration/permissions-management.ts +292 -0
- package/src/test/unit/acl/entries.test.ts +2 -1
- package/src/test/unit/acl/resolver.test.ts +19 -7
- package/src/test/unit/library/fixtures.ts +9 -3
- package/src/test/unit/library/library.test.ts +1 -7
- package/src/test/unit/library/realtime.test.ts +1 -1
- package/src/test/unit/library/search-facets.test.ts +2 -2
- package/src/test/unit/pages/toolbar.test.ts +42 -17
- package/src/test/unit/routes/dto.test.ts +7 -6
- package/src/test/unit/routes/file-page.test.ts +10 -9
- package/src/test/unit/routes/preset-row.test.ts +2 -2
- package/src/transform.ts +6 -6
- package/src/upload-checks.ts +12 -3
- package/src/upload-policy.ts +8 -8
- package/src/validation/declared.schema.ts +17 -12
- package/src/validation/media.schema.ts +6 -6
- package/frontend-vue/tests/engines.test.ts +0 -20
- package/frontend-vue/tests/locales.test.ts +0 -61
package/src/library/realtime.ts
CHANGED
|
@@ -13,9 +13,13 @@ let pendingDueAt = 0;
|
|
|
13
13
|
let pendingChanges = 0;
|
|
14
14
|
let version = 0;
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Publishes the changes waiting to be announced as one message whose
|
|
18
|
+
* `payload.count` says how many it stands for: a paused page counts that many
|
|
19
|
+
* missed changes, not one per announcement.
|
|
20
|
+
*/
|
|
16
21
|
async function publishNow(): Promise<void> {
|
|
17
22
|
pending = undefined;
|
|
18
|
-
// A paused page counts `payload.count` as that many missed changes, not one per announcement.
|
|
19
23
|
const count = pendingChanges;
|
|
20
24
|
pendingChanges = 0;
|
|
21
25
|
try {
|
package/src/library/zip.ts
CHANGED
|
@@ -23,7 +23,7 @@ interface CentralEntry {
|
|
|
23
23
|
|
|
24
24
|
export type ZipChunkWriter = (chunk: Buffer) => void;
|
|
25
25
|
|
|
26
|
-
function dosDateTime(date: Date):
|
|
26
|
+
function dosDateTime(date: Date): Pick<CentralEntry, "time" | "date"> {
|
|
27
27
|
const year = Math.max(date.getFullYear(), DOS_EPOCH_YEAR);
|
|
28
28
|
return {
|
|
29
29
|
time:
|
package/src/pages/activity.ts
CHANGED
|
@@ -4,7 +4,11 @@ import { DefaultLayout } from "@antelopejs/interface-dms/base/layouts";
|
|
|
4
4
|
import { Tab } from "@antelopejs/interface-dms/base/tab";
|
|
5
5
|
import { PageController, RegisterPage } from "@antelopejs/interface-dms/page";
|
|
6
6
|
import { MEDIA_LIBRARY_TOPIC } from "../constants";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
ACTIVITY_FILTERS,
|
|
9
|
+
type ActivityFilter,
|
|
10
|
+
isActivityFilter,
|
|
11
|
+
} from "../library/activity";
|
|
8
12
|
import { libraryCategory, MEDIA_MODULE_ID } from "./module";
|
|
9
13
|
import { blockMeta } from "./texts";
|
|
10
14
|
import { MEDIA_LIVE, mediaPageToolbar } from "./toolbar";
|
|
@@ -14,7 +18,7 @@ const FEED_LENGTH = 50;
|
|
|
14
18
|
const SKELETON_ROWS = 8;
|
|
15
19
|
const ALL_SLOT = "all";
|
|
16
20
|
|
|
17
|
-
const FILTERS = Object.keys(ACTIVITY_FILTERS)
|
|
21
|
+
const FILTERS = Object.keys(ACTIVITY_FILTERS).filter(isActivityFilter);
|
|
18
22
|
|
|
19
23
|
function feed(filter?: ActivityFilter) {
|
|
20
24
|
const query = filter ? `&type=${filter}` : "";
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Delete,
|
|
10
10
|
Get,
|
|
11
11
|
JSONBody,
|
|
12
|
+
MultiParameter,
|
|
12
13
|
Parameter,
|
|
13
14
|
Post,
|
|
14
15
|
} from "@antelopejs/interface-api";
|
|
@@ -131,9 +132,9 @@ export class MediaAssetsController extends MediaApiController {
|
|
|
131
132
|
return { assets, truncated };
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
@
|
|
135
|
-
async previews(@
|
|
136
|
-
const { ids } = parseBody(
|
|
135
|
+
@Get("/previews")
|
|
136
|
+
async previews(@MultiParameter("ids", "query") queryIds: string[]) {
|
|
137
|
+
const { ids } = parseBody({ ids: queryIds }, previewIdsSchema);
|
|
137
138
|
const context = await this.resolveContext();
|
|
138
139
|
const { presets } = getMediaConfig();
|
|
139
140
|
const thumb = presets.get(THUMB_PRESET_ID);
|
package/src/routes/media/bulk.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
type MediaRequestContext,
|
|
24
24
|
requireFolderRight,
|
|
25
25
|
} from "./context";
|
|
26
|
+
import { isString } from "../../guards";
|
|
26
27
|
|
|
27
28
|
const HTTP_OK = 200;
|
|
28
29
|
const HTTP_INTERNAL_ERROR = 500;
|
|
@@ -55,19 +56,6 @@ export interface BulkOutcome {
|
|
|
55
56
|
refused: BulkRefusal[];
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
function describeFailure(id: string, error: unknown): BulkRefusal {
|
|
59
|
-
if (error instanceof HTTPResult) {
|
|
60
|
-
const body: unknown = error.getBody();
|
|
61
|
-
const message = typeof body === "string" ? body : JSON.stringify(body);
|
|
62
|
-
return { id, status: error.getStatus(), message: message ?? "" };
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
id,
|
|
66
|
-
status: HTTP_INTERNAL_ERROR,
|
|
67
|
-
message: error instanceof Error ? error.message : String(error),
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
59
|
/** Runs one operation per asset in order, keeping going past the ones refused. */
|
|
72
60
|
async function applyToEach(
|
|
73
61
|
context: MediaRequestContext,
|
|
@@ -81,7 +69,21 @@ async function applyToEach(
|
|
|
81
69
|
await operation(context, asset);
|
|
82
70
|
outcome.done.push(id);
|
|
83
71
|
} catch (error) {
|
|
84
|
-
|
|
72
|
+
if (error instanceof HTTPResult) {
|
|
73
|
+
const body: unknown = error.getBody();
|
|
74
|
+
const message = isString(body) ? body : JSON.stringify(body);
|
|
75
|
+
outcome.refused.push({
|
|
76
|
+
id,
|
|
77
|
+
status: error.getStatus(),
|
|
78
|
+
message: message ?? "",
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
outcome.refused.push({
|
|
82
|
+
id,
|
|
83
|
+
status: HTTP_INTERNAL_ERROR,
|
|
84
|
+
message: error instanceof Error ? error.message : String(error),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
return outcome;
|
|
@@ -12,13 +12,13 @@ type Disposition = "inline" | "attachment";
|
|
|
12
12
|
* Types a browser would run as a page from the API origin. SVG stays inline
|
|
13
13
|
* (it is an image) but sandboxed; documents are only ever downloaded.
|
|
14
14
|
*/
|
|
15
|
-
const ACTIVE_CONTENT_DISPOSITIONS
|
|
16
|
-
"image/svg+xml"
|
|
17
|
-
"text/html"
|
|
18
|
-
"application/xhtml+xml"
|
|
19
|
-
"text/xml"
|
|
20
|
-
"application/xml"
|
|
21
|
-
|
|
15
|
+
const ACTIVE_CONTENT_DISPOSITIONS = new Map<string, Disposition>([
|
|
16
|
+
["image/svg+xml", "inline"],
|
|
17
|
+
["text/html", "attachment"],
|
|
18
|
+
["application/xhtml+xml", "attachment"],
|
|
19
|
+
["text/xml", "attachment"],
|
|
20
|
+
["application/xml", "attachment"],
|
|
21
|
+
]);
|
|
22
22
|
|
|
23
23
|
export function normalizedMimetype(mimetype: string): string {
|
|
24
24
|
const essence = mimetype
|
|
@@ -29,10 +29,7 @@ export function normalizedMimetype(mimetype: string): string {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export function isActiveContent(mimetype: string): boolean {
|
|
32
|
-
return
|
|
33
|
-
ACTIVE_CONTENT_DISPOSITIONS,
|
|
34
|
-
normalizedMimetype(mimetype),
|
|
35
|
-
);
|
|
32
|
+
return ACTIVE_CONTENT_DISPOSITIONS.has(normalizedMimetype(mimetype));
|
|
36
33
|
}
|
|
37
34
|
|
|
38
35
|
function asciiFilename(filename: string): string {
|
|
@@ -47,7 +44,7 @@ function asciiFilename(filename: string): string {
|
|
|
47
44
|
|
|
48
45
|
export function contentDisposition(mimetype: string, filename: string): string {
|
|
49
46
|
const disposition =
|
|
50
|
-
ACTIVE_CONTENT_DISPOSITIONS
|
|
47
|
+
ACTIVE_CONTENT_DISPOSITIONS.get(normalizedMimetype(mimetype)) ?? "inline";
|
|
51
48
|
const extended = encodeURIComponent(filename).replace(
|
|
52
49
|
/['()*]/g,
|
|
53
50
|
(character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`,
|
|
@@ -79,6 +79,9 @@ function addRepresentationHeaders(
|
|
|
79
79
|
* or the attachment disposition these files need, every other file is
|
|
80
80
|
* redirected to the storage so its bandwidth never goes through Node.
|
|
81
81
|
* Byte ranges are not served: these files are small and rendered whole.
|
|
82
|
+
* The bytes are read from the storage itself, not through its read URL: that
|
|
83
|
+
* URL is the public origin, which the server may not reach (private network,
|
|
84
|
+
* egress policy).
|
|
82
85
|
*/
|
|
83
86
|
export async function streamStoredFile(
|
|
84
87
|
ctx: RequestContext,
|
|
@@ -92,8 +95,6 @@ export async function streamStoredFile(
|
|
|
92
95
|
response.setBody("");
|
|
93
96
|
return response;
|
|
94
97
|
}
|
|
95
|
-
// Read from the storage itself: its read URL is the public origin, which
|
|
96
|
-
// the server may not reach (private network, egress policy).
|
|
97
98
|
const stored = await ReadFile(file.storageKey, file.storage).catch(
|
|
98
99
|
() => undefined,
|
|
99
100
|
);
|
|
@@ -312,6 +312,10 @@ export class MediaDeliveryController extends Controller("/media") {
|
|
|
312
312
|
return deliverAsset(ctx, resolved);
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
+
/**
|
|
316
|
+
* Resolves (and authorizes) the asset before it touches the preset, so an
|
|
317
|
+
* unauthenticated caller cannot probe which preset IDs are configured.
|
|
318
|
+
*/
|
|
315
319
|
@Get("/:assetId/:presetId/:filename")
|
|
316
320
|
async deliverDerivative(
|
|
317
321
|
@Context() ctx: RequestContext,
|
|
@@ -320,8 +324,6 @@ export class MediaDeliveryController extends Controller("/media") {
|
|
|
320
324
|
@IfAuthUser() user?: User,
|
|
321
325
|
) {
|
|
322
326
|
assertNamedSegment(ctx);
|
|
323
|
-
// Resolve (and authorize) the asset before touching the preset so an
|
|
324
|
-
// unauthenticated caller cannot probe which preset IDs are configured.
|
|
325
327
|
const resolved = await guardSignIn(
|
|
326
328
|
ctx,
|
|
327
329
|
resolveDeliverableAsset(ctx, assetId, user),
|
|
@@ -4,6 +4,7 @@ import { getMediaConfig } from "../../config";
|
|
|
4
4
|
import { getLastSweep, SWEEP_DERIVATIVES_SCHEDULE } from "../../crons";
|
|
5
5
|
import type { MediaAsset } from "../../db";
|
|
6
6
|
import { buildUploadBatches, type UploadBatchRow } from "../../library/batches";
|
|
7
|
+
import type { MediaEventDetails } from "../../library/events";
|
|
7
8
|
import { loadUploadHistoryEvents } from "../../library/upload-history";
|
|
8
9
|
import { presetsConfigSnippet } from "../../library/snippets";
|
|
9
10
|
import { loadAssetsInFolders } from "../../library/listing";
|
|
@@ -60,8 +61,8 @@ function matchesFilters(
|
|
|
60
61
|
);
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
function batchDetails(summary: BatchSummary):
|
|
64
|
-
const details:
|
|
64
|
+
function batchDetails(summary: BatchSummary): MediaEventDetails {
|
|
65
|
+
const details: MediaEventDetails = {
|
|
65
66
|
batchId: summary.batchId,
|
|
66
67
|
total: summary.total,
|
|
67
68
|
failed: summary.failed,
|
|
@@ -110,10 +111,7 @@ function readSourcePage(query: Record<string, string>): SourcePage {
|
|
|
110
111
|
return { offset, limit };
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
function pageRows<T>(
|
|
114
|
-
rows: T[],
|
|
115
|
-
page: SourcePage,
|
|
116
|
-
): { results: T[]; total: number } {
|
|
114
|
+
function pageRows<T>(rows: T[], page: SourcePage) {
|
|
117
115
|
const results = page.limit
|
|
118
116
|
? rows.slice(page.offset, page.offset + page.limit)
|
|
119
117
|
: rows.slice(page.offset);
|
|
@@ -24,23 +24,27 @@ const HTTP_BAD_REQUEST = 400;
|
|
|
24
24
|
const HTTP_CONFLICT = 409;
|
|
25
25
|
const HTTP_UNPROCESSABLE_ENTITY = 422;
|
|
26
26
|
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
27
|
+
async function translatingTransformErrors<T>(work: Promise<T>): Promise<T> {
|
|
28
|
+
try {
|
|
29
|
+
return await work;
|
|
30
|
+
} catch (error) {
|
|
31
|
+
assert(
|
|
32
|
+
!(error instanceof AnimatedImageTransformError),
|
|
33
|
+
HTTP_UNPROCESSABLE_ENTITY,
|
|
34
|
+
"Animated images cannot be edited",
|
|
35
|
+
);
|
|
36
|
+
assert(
|
|
37
|
+
!(error instanceof OversizedImageTransformError),
|
|
38
|
+
HTTP_UNPROCESSABLE_ENTITY,
|
|
39
|
+
"This image is too large to be edited",
|
|
40
|
+
);
|
|
41
|
+
assert(
|
|
42
|
+
!(error instanceof MediaAssetChangedError),
|
|
43
|
+
HTTP_CONFLICT,
|
|
44
|
+
"This image was changed by someone else in the meantime. Reload the page to see the latest version.",
|
|
45
|
+
);
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
async function requireEditableAsset(
|
|
@@ -106,8 +110,8 @@ export class MediaTransformController extends MediaApiController {
|
|
|
106
110
|
const ops = assertValidation(body, (v) => transformSchema.parse(v));
|
|
107
111
|
const context = await this.resolveContext();
|
|
108
112
|
const asset = await requireEditableAsset(context, assetId);
|
|
109
|
-
await
|
|
110
|
-
|
|
113
|
+
await translatingTransformErrors(
|
|
114
|
+
applyImageTransform(context.assetModel, asset, ops),
|
|
111
115
|
);
|
|
112
116
|
const updated = await context.assetModel.get(assetId);
|
|
113
117
|
assert(updated, HTTP_CONFLICT, "Asset disappeared during transform");
|
|
@@ -132,8 +136,8 @@ export class MediaTransformController extends MediaApiController {
|
|
|
132
136
|
const ops = assertValidation(body, (v) => transformSchema.parse(v));
|
|
133
137
|
const context = await this.resolveContext();
|
|
134
138
|
const asset = await requireEditableAsset(context, assetId);
|
|
135
|
-
const copy = await
|
|
136
|
-
|
|
139
|
+
const copy = await translatingTransformErrors(
|
|
140
|
+
createEditedCopy(context, asset, ops),
|
|
137
141
|
);
|
|
138
142
|
await this.record(context, {
|
|
139
143
|
kind: "asset.upload",
|
|
@@ -156,8 +160,8 @@ export class MediaTransformController extends MediaApiController {
|
|
|
156
160
|
HTTP_CONFLICT,
|
|
157
161
|
"Asset has no original to revert to",
|
|
158
162
|
);
|
|
159
|
-
await
|
|
160
|
-
|
|
163
|
+
await translatingTransformErrors(
|
|
164
|
+
revertImageTransform(context.assetModel, asset),
|
|
161
165
|
);
|
|
162
166
|
const updated = await context.assetModel.get(assetId);
|
|
163
167
|
assert(updated, HTTP_CONFLICT, "Asset disappeared during revert");
|
|
@@ -4,6 +4,7 @@ import { tmpdir } from "node:os";
|
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { defineConfig } from "@antelopejs/interface-core/config";
|
|
6
6
|
import { MongoMemoryReplSet } from "mongodb-memory-server-core";
|
|
7
|
+
import { isString } from "../guards";
|
|
7
8
|
|
|
8
9
|
const API_PORT = 5019;
|
|
9
10
|
const LOCAL_BUILD_COMMAND = process.env.DMS_PREBUILT ? [] : ["pnpm build"];
|
|
@@ -13,16 +14,16 @@ const MONGO_BINARY_VERSION = "8.0.8";
|
|
|
13
14
|
const SMTP_HOST = "127.0.0.1";
|
|
14
15
|
const EPHEMERAL_PORT = 0;
|
|
15
16
|
const TEST_SENDER = "dms-media@test.local";
|
|
16
|
-
const SMTP_RESPONSES
|
|
17
|
-
EHLO
|
|
18
|
-
HELO
|
|
19
|
-
MAIL
|
|
20
|
-
RCPT
|
|
21
|
-
DATA
|
|
22
|
-
RSET
|
|
23
|
-
NOOP
|
|
24
|
-
QUIT
|
|
25
|
-
|
|
17
|
+
const SMTP_RESPONSES = new Map([
|
|
18
|
+
["EHLO", "250-dms-media.test\r\n250 PIPELINING\r\n"],
|
|
19
|
+
["HELO", "250 dms-media.test\r\n"],
|
|
20
|
+
["MAIL", "250 OK\r\n"],
|
|
21
|
+
["RCPT", "250 OK\r\n"],
|
|
22
|
+
["DATA", "354 End data with <CR><LF>.<CR><LF>\r\n"],
|
|
23
|
+
["RSET", "250 OK\r\n"],
|
|
24
|
+
["NOOP", "250 OK\r\n"],
|
|
25
|
+
["QUIT", "221 Bye\r\n"],
|
|
26
|
+
]);
|
|
26
27
|
|
|
27
28
|
interface SmtpConnectionState {
|
|
28
29
|
pending: string;
|
|
@@ -47,7 +48,7 @@ function processSmtpLine(
|
|
|
47
48
|
}
|
|
48
49
|
const command = line.split(" ", 1)[0]?.toUpperCase() ?? "";
|
|
49
50
|
state.isReadingData = command === "DATA";
|
|
50
|
-
const response = SMTP_RESPONSES
|
|
51
|
+
const response = SMTP_RESPONSES.get(command) ?? "250 OK\r\n";
|
|
51
52
|
if (command === "QUIT") socket.end(response);
|
|
52
53
|
else socket.write(response);
|
|
53
54
|
}
|
|
@@ -77,8 +78,7 @@ async function startSmtpFixture(): Promise<number> {
|
|
|
77
78
|
});
|
|
78
79
|
});
|
|
79
80
|
const address = smtpServer.address();
|
|
80
|
-
if (!address ||
|
|
81
|
-
throw new Error("Invalid SMTP address");
|
|
81
|
+
if (!address || isString(address)) throw new Error("Invalid SMTP address");
|
|
82
82
|
return address.port;
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -113,14 +113,18 @@ export default defineConfig({
|
|
|
113
113
|
version: ">=0.11.0 <1.0.0",
|
|
114
114
|
},
|
|
115
115
|
config: {
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
/**
|
|
117
|
+
* No frontend server runs here: the dashboard URL is the API, whose
|
|
118
|
+
* paths the front proxy serves unchanged.
|
|
119
|
+
*/
|
|
118
120
|
clientBaseUrl: `http://127.0.0.1:${API_PORT}`,
|
|
119
121
|
auth: {
|
|
120
122
|
jwtSecret: JWT_SECRET,
|
|
121
123
|
},
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Outside development, which the test run is not, dms 0.10 refuses
|
|
126
|
+
* to start without a render secret of its own.
|
|
127
|
+
*/
|
|
124
128
|
htmlRender: {
|
|
125
129
|
serviceSecret: HTML_RENDER_SECRET,
|
|
126
130
|
},
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { GetModel } from "@antelopejs/interface-database-decorators";
|
|
2
2
|
import { DEFAULT_TENANT_ID } from "@antelopejs/interface-dms/constants";
|
|
3
|
+
import type { AxiosInstance } from "axios";
|
|
4
|
+
import { z } from "zod";
|
|
3
5
|
import { parseFolderAcl, serializeAcl } from "../../acl";
|
|
4
6
|
import { MediaFolderModel } from "../../db";
|
|
5
7
|
import type { AclEntry } from "../../types";
|
|
@@ -23,3 +25,23 @@ export async function writeFolderAcl(
|
|
|
23
25
|
json_acl: serializeAcl(entries ?? undefined) ?? "",
|
|
24
26
|
});
|
|
25
27
|
}
|
|
28
|
+
|
|
29
|
+
const folderNodeSchema = z.object({
|
|
30
|
+
id: z.string(),
|
|
31
|
+
name: z.string(),
|
|
32
|
+
parentId: z.string().nullable(),
|
|
33
|
+
binding: z.string().nullable(),
|
|
34
|
+
acceptsSubfolders: z.boolean(),
|
|
35
|
+
accepts: z.array(z.string()).nullable(),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export type FolderNode = z.infer<typeof folderNodeSchema>;
|
|
39
|
+
|
|
40
|
+
/** The folders `/api/media/tree` answers, checked against the fields the suites read. */
|
|
41
|
+
export async function fetchFolderNodes(
|
|
42
|
+
client: AxiosInstance,
|
|
43
|
+
): Promise<FolderNode[]> {
|
|
44
|
+
const response = await client.get("/api/media/tree");
|
|
45
|
+
return z.object({ folders: z.array(folderNodeSchema) }).parse(response.data)
|
|
46
|
+
.folders;
|
|
47
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { pageRoutePath } from "@antelopejs/interface-dms/page";
|
|
2
2
|
import type { AxiosInstance } from "axios";
|
|
3
|
+
import { z } from "zod";
|
|
3
4
|
|
|
4
5
|
const HTTP_OK = 200;
|
|
5
6
|
const PAGE_LAYOUT_ROUTE = "/pagelayout";
|
|
@@ -15,10 +16,16 @@ export interface PageAccess {
|
|
|
15
16
|
servedBlocks: number;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const layoutSchema = z.object({
|
|
20
|
+
components: z
|
|
21
|
+
.union([z.array(z.unknown()), z.record(z.unknown())])
|
|
22
|
+
.nullish()
|
|
23
|
+
.transform((components) =>
|
|
24
|
+
Array.isArray(components)
|
|
25
|
+
? components.length
|
|
26
|
+
: Object.keys(components ?? {}).length,
|
|
27
|
+
),
|
|
28
|
+
});
|
|
22
29
|
|
|
23
30
|
/** Reads a page through its guarded route, its page entry and its by-slug layout. */
|
|
24
31
|
export async function readPageAccess(
|
|
@@ -40,6 +47,6 @@ export async function readPageAccess(
|
|
|
40
47
|
return {
|
|
41
48
|
ownRouteStatus: ownRoute.status,
|
|
42
49
|
hasAccess: page.data.route?.hasAccess === true,
|
|
43
|
-
servedBlocks:
|
|
50
|
+
servedBlocks: layoutSchema.parse(layout.data).components,
|
|
44
51
|
};
|
|
45
52
|
}
|