@lacecms/application 0.0.0-stage → 0.1.0-alpha.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/LICENSE +21 -0
- package/dist/configuration-sync.d.ts +129 -0
- package/dist/configuration-sync.d.ts.map +1 -0
- package/dist/configuration-sync.js +283 -0
- package/dist/configuration-sync.js.map +1 -0
- package/dist/content-use-cases.d.ts +94 -0
- package/dist/content-use-cases.d.ts.map +1 -0
- package/dist/content-use-cases.js +227 -0
- package/dist/content-use-cases.js.map +1 -0
- package/dist/dispatchers.d.ts +50 -0
- package/dist/dispatchers.d.ts.map +1 -0
- package/dist/dispatchers.js +186 -0
- package/dist/dispatchers.js.map +1 -0
- package/dist/index.d.ts +547 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +118 -0
- package/dist/index.js.map +1 -0
- package/dist/media-use-cases.d.ts +80 -0
- package/dist/media-use-cases.d.ts.map +1 -0
- package/dist/media-use-cases.js +273 -0
- package/dist/media-use-cases.js.map +1 -0
- package/dist/site-build-use-cases.d.ts +15 -0
- package/dist/site-build-use-cases.d.ts.map +1 -0
- package/dist/site-build-use-cases.js +30 -0
- package/dist/site-build-use-cases.js.map +1 -0
- package/package.json +30 -3
- package/README.md +0 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { requirePermission } from "@lacecms/domain";
|
|
2
|
+
export const packageName = "@lacecms/application";
|
|
3
|
+
export * from "./configuration-sync.js";
|
|
4
|
+
export * from "./site-build-use-cases.js";
|
|
5
|
+
export * from "./dispatchers.js";
|
|
6
|
+
function opaqueBrand(value, name) {
|
|
7
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
8
|
+
throw new TypeError(`${name} must be a non-empty string.`);
|
|
9
|
+
}
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
export function opaqueCursor(value) {
|
|
13
|
+
return opaqueBrand(value, "OpaqueCursor");
|
|
14
|
+
}
|
|
15
|
+
export function opaqueTokenSecret(value) {
|
|
16
|
+
return opaqueBrand(value, "OpaqueTokenSecret");
|
|
17
|
+
}
|
|
18
|
+
export function opaqueTokenVerifier(value) {
|
|
19
|
+
return opaqueBrand(value, "OpaqueTokenVerifier");
|
|
20
|
+
}
|
|
21
|
+
export function dispatcherEventId(value) {
|
|
22
|
+
return opaqueBrand(value, "DispatcherEventId");
|
|
23
|
+
}
|
|
24
|
+
export function dispatcherLeaseId(value) {
|
|
25
|
+
return opaqueBrand(value, "DispatcherLeaseId");
|
|
26
|
+
}
|
|
27
|
+
/** A caller-supplied key that makes one guarded publication retry-safe. */
|
|
28
|
+
export function publicationIdempotencyKey(value) {
|
|
29
|
+
return opaqueBrand(value, "PublicationIdempotencyKey");
|
|
30
|
+
}
|
|
31
|
+
/** Canonical application-generated identity of the complete publication request. */
|
|
32
|
+
export function publicationRequestFingerprint(value) {
|
|
33
|
+
return opaqueBrand(value, "PublicationRequestFingerprint");
|
|
34
|
+
}
|
|
35
|
+
export const CONTENT_ENTRY_STATUSES = Object.freeze([
|
|
36
|
+
"changed",
|
|
37
|
+
"draft",
|
|
38
|
+
"published",
|
|
39
|
+
]);
|
|
40
|
+
export const CONTENT_ENTRY_SORTS = Object.freeze([
|
|
41
|
+
"-publishedAt",
|
|
42
|
+
"-title",
|
|
43
|
+
"-updatedAt",
|
|
44
|
+
"publishedAt",
|
|
45
|
+
"title",
|
|
46
|
+
"updatedAt",
|
|
47
|
+
]);
|
|
48
|
+
export const DEFAULT_CONTENT_ENTRY_SORT = "-updatedAt";
|
|
49
|
+
export const MAX_CONTENT_ENTRY_SEARCH_LENGTH = 200;
|
|
50
|
+
/** Display name used for `system:` audit actors such as configuration sync. */
|
|
51
|
+
export const SYSTEM_ACTOR_DISPLAY_NAME = "System";
|
|
52
|
+
/** Display name used when an audit actor no longer has a user record. */
|
|
53
|
+
export const UNKNOWN_ACTOR_DISPLAY_NAME = "Unknown user";
|
|
54
|
+
/** Resolves the portable display-name fallbacks shared by every runtime adapter. */
|
|
55
|
+
export function actorDisplayName(id, storedName) {
|
|
56
|
+
const name = storedName?.trim();
|
|
57
|
+
if (name !== undefined && name.length > 0)
|
|
58
|
+
return name;
|
|
59
|
+
return id.startsWith("system:") ? SYSTEM_ACTOR_DISPLAY_NAME : UNKNOWN_ACTOR_DISPLAY_NAME;
|
|
60
|
+
}
|
|
61
|
+
/** Folds only ASCII letters, matching SQLite `lower()` so every adapter searches alike. */
|
|
62
|
+
export function foldAscii(value) {
|
|
63
|
+
return value.replace(/[A-Z]/gu, (letter) => letter.toLowerCase());
|
|
64
|
+
}
|
|
65
|
+
/** Keeps the role matrix in the domain policy rather than HTTP handlers. */
|
|
66
|
+
export function requireUsersManager(actor) {
|
|
67
|
+
requirePermission(actor, "users:manage");
|
|
68
|
+
}
|
|
69
|
+
/** Fixed dispatcher timing keeps recovery semantics identical across runtimes. */
|
|
70
|
+
export const DISPATCHER_LEASE_DURATION_MS = 60_000;
|
|
71
|
+
export const SITE_BUILD_DEBOUNCE_MS = 5_000;
|
|
72
|
+
export const defaultDispatcherRetryPolicy = Object.freeze({
|
|
73
|
+
baseDelayMs: 1_000,
|
|
74
|
+
maxAttempts: 8,
|
|
75
|
+
maxDelayMs: 15 * 60_000,
|
|
76
|
+
});
|
|
77
|
+
export const siteBuildRetryPolicy = Object.freeze({
|
|
78
|
+
baseDelayMs: 5_000,
|
|
79
|
+
maxAttempts: 8,
|
|
80
|
+
maxDelayMs: 15 * 60_000,
|
|
81
|
+
});
|
|
82
|
+
/** Calculates full-jitter exponential retry delay without choosing the random sample. */
|
|
83
|
+
export function dispatcherRetryDelay(policy, failedAttempt, random) {
|
|
84
|
+
if (!Number.isSafeInteger(policy.baseDelayMs) ||
|
|
85
|
+
!Number.isSafeInteger(policy.maxDelayMs) ||
|
|
86
|
+
!Number.isSafeInteger(policy.maxAttempts) ||
|
|
87
|
+
policy.baseDelayMs < 1 ||
|
|
88
|
+
policy.maxDelayMs < policy.baseDelayMs ||
|
|
89
|
+
policy.maxAttempts < 1 ||
|
|
90
|
+
!Number.isSafeInteger(failedAttempt) ||
|
|
91
|
+
failedAttempt < 1 ||
|
|
92
|
+
!Number.isFinite(random) ||
|
|
93
|
+
random < 0 ||
|
|
94
|
+
random >= 1) {
|
|
95
|
+
throw new TypeError("Dispatcher retry inputs are invalid.");
|
|
96
|
+
}
|
|
97
|
+
const ceiling = Math.min(policy.maxDelayMs, policy.baseDelayMs * 2 ** (failedAttempt - 1));
|
|
98
|
+
return Math.floor(random * (ceiling + 1));
|
|
99
|
+
}
|
|
100
|
+
export const MEDIA_SORTS = Object.freeze([
|
|
101
|
+
"-createdAt",
|
|
102
|
+
"-filename",
|
|
103
|
+
"-size",
|
|
104
|
+
"createdAt",
|
|
105
|
+
"filename",
|
|
106
|
+
"size",
|
|
107
|
+
]);
|
|
108
|
+
export const DEFAULT_MEDIA_SORT = "-createdAt";
|
|
109
|
+
export const MAX_MEDIA_SEARCH_LENGTH = 200;
|
|
110
|
+
/** Upper bound on the referencing entries returned by one media usage read. */
|
|
111
|
+
export const MAX_MEDIA_USAGE_ENTRIES = 50;
|
|
112
|
+
export * from "./content-use-cases.js";
|
|
113
|
+
export * from "./media-use-cases.js";
|
|
114
|
+
/** Authorizes read-only installation metadata with the existing content permission. */
|
|
115
|
+
export function requireContentReader(actor) {
|
|
116
|
+
requirePermission(actor, "content:read");
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,CAAC,MAAM,WAAW,GAAG,sBAAsB,CAAC;AAElD,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AAUjC,SAAS,WAAW,CAAsB,KAAa,EAAE,IAAU;IACjE,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C/E,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAgH1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AAErC,uFAAuF;AACvF,MAAM,UAAU,oBAAoB,CAAC,KAAY;IAC/C,iBAAiB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Actor, MediaId, MediaMetadata, UnixMilliseconds } from "@lacecms/domain";
|
|
2
|
+
import type { ActorSummary, ByteStream, Clock, CursorPage, IdGenerator, ImageInspector, MediaCatalogPort, MediaCommandPort, MediaListPort, MediaMimeType, MediaReadPort, MediaUsageEntry, ObjectStorage, OpaqueCursor, OperationalLogger, PublicContentReadPort } from "./index.js";
|
|
3
|
+
export declare const MAX_MEDIA_BYTES: number;
|
|
4
|
+
export declare const MAX_IMAGE_DIMENSION = 12000;
|
|
5
|
+
export declare const MAX_IMAGE_PIXELS = 100000000;
|
|
6
|
+
export declare const ALLOWED_MEDIA_MIME_TYPES: readonly ["image/avif", "image/jpeg", "image/png", "image/webp"];
|
|
7
|
+
export interface MediaView {
|
|
8
|
+
readonly createdAt: UnixMilliseconds;
|
|
9
|
+
readonly createdBy: ActorSummary;
|
|
10
|
+
readonly filename: string;
|
|
11
|
+
readonly height?: number;
|
|
12
|
+
readonly id: MediaId;
|
|
13
|
+
readonly mimeType: MediaMimeType;
|
|
14
|
+
readonly size: number;
|
|
15
|
+
readonly status: MediaMetadata["status"];
|
|
16
|
+
readonly updatedAt: UnixMilliseconds;
|
|
17
|
+
readonly usageCount: number;
|
|
18
|
+
readonly width?: number;
|
|
19
|
+
}
|
|
20
|
+
/** A single media item with the bounded list of entries that use it. */
|
|
21
|
+
export interface MediaDetailView extends MediaView {
|
|
22
|
+
readonly usage: readonly MediaUsageEntry[];
|
|
23
|
+
}
|
|
24
|
+
export interface CreateMediaUseCaseInput {
|
|
25
|
+
readonly actor: Actor;
|
|
26
|
+
readonly body: ByteStream;
|
|
27
|
+
readonly filename: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ListMediaUseCaseInput {
|
|
30
|
+
readonly actor: Actor;
|
|
31
|
+
readonly after?: OpaqueCursor;
|
|
32
|
+
readonly limit: number;
|
|
33
|
+
readonly q?: string;
|
|
34
|
+
readonly sort?: string;
|
|
35
|
+
readonly type?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface GetMediaUseCaseInput {
|
|
38
|
+
readonly actor: Actor;
|
|
39
|
+
readonly mediaId: MediaId;
|
|
40
|
+
}
|
|
41
|
+
export interface DeleteMediaUseCaseInput extends GetMediaUseCaseInput {
|
|
42
|
+
}
|
|
43
|
+
export interface PublicMediaBinaryUseCaseInput {
|
|
44
|
+
readonly mediaId: MediaId;
|
|
45
|
+
}
|
|
46
|
+
export interface MediaBinary {
|
|
47
|
+
readonly body: ByteStream;
|
|
48
|
+
readonly filename: string;
|
|
49
|
+
readonly mimeType: MediaMimeType;
|
|
50
|
+
}
|
|
51
|
+
export interface MediaUseCaseDependencies {
|
|
52
|
+
readonly clock: Clock;
|
|
53
|
+
readonly idGenerator: IdGenerator;
|
|
54
|
+
readonly imageInspector: ImageInspector;
|
|
55
|
+
readonly logger: OperationalLogger;
|
|
56
|
+
readonly media: MediaReadPort & MediaListPort & MediaCatalogPort & MediaCommandPort;
|
|
57
|
+
readonly publicMedia?: Pick<PublicContentReadPort, "loadPublicMedia">;
|
|
58
|
+
readonly storage: ObjectStorage;
|
|
59
|
+
}
|
|
60
|
+
/** Detects format only; ImageInspector validates container structure and dimensions. */
|
|
61
|
+
export declare function detectMediaMimeType(bytes: Uint8Array): MediaMimeType;
|
|
62
|
+
export declare function sanitizeMediaFilename(value: string): string;
|
|
63
|
+
export declare function collectMediaBytes(body: ByteStream): Promise<Uint8Array>;
|
|
64
|
+
/** Portable orchestration for media policy and metadata lifecycle commands. */
|
|
65
|
+
export declare class MediaUseCases {
|
|
66
|
+
private readonly dependencies;
|
|
67
|
+
constructor(dependencies: MediaUseCaseDependencies);
|
|
68
|
+
create(input: CreateMediaUseCaseInput): Promise<MediaView>;
|
|
69
|
+
get(input: GetMediaUseCaseInput): Promise<MediaDetailView | null>;
|
|
70
|
+
list(input: ListMediaUseCaseInput): Promise<CursorPage<MediaView>>;
|
|
71
|
+
requestDeletion(input: DeleteMediaUseCaseInput): Promise<MediaView>;
|
|
72
|
+
retryDeletion(input: DeleteMediaUseCaseInput): Promise<MediaView>;
|
|
73
|
+
preview(input: GetMediaUseCaseInput): Promise<MediaBinary | null>;
|
|
74
|
+
readPublic(input: PublicMediaBinaryUseCaseInput): Promise<MediaBinary | null>;
|
|
75
|
+
private catalogView;
|
|
76
|
+
private readBinary;
|
|
77
|
+
private cleanupAfterMetadataFailure;
|
|
78
|
+
private recordOperationalError;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=media-use-cases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-use-cases.d.ts","sourceRoot":"","sources":["../src/media-use-cases.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAOvF,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,KAAK,EACL,UAAU,EACV,WAAW,EACX,cAAc,EAEd,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,EAEb,eAAe,EACf,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,eAAe,QAAmB,CAAC;AAChD,eAAO,MAAM,mBAAmB,QAAS,CAAC;AAC1C,eAAO,MAAM,gBAAgB,YAAc,CAAC;AAC5C,eAAO,MAAM,wBAAwB,kEAK1B,CAAC;AAEZ,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,QAAQ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AC,SAAS,CAAC,CAAC,CA0B9E;IAEY,eAAe,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,SAAS,CAAC,CAQ/E;IAEY,aAAa,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,SAAS,CAAC,CAQ7E;IAEY,OAAO,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAI7E;IAEY,UAAU,CAAC,KAAK,EAAE,6BAA6B,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAKzF;YAEa,WAAW;YAMX,UAAU;YAcV,2BAA2B;YAoB3B,sBAAsB;CAUrC"}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { DomainError, mediaId, requirePermission } from "@lacecms/domain";
|
|
2
|
+
import { DEFAULT_MEDIA_SORT, MAX_MEDIA_SEARCH_LENGTH, MAX_MEDIA_USAGE_ENTRIES, MEDIA_SORTS, } from "./index.js";
|
|
3
|
+
export const MAX_MEDIA_BYTES = 10 * 1024 * 1024;
|
|
4
|
+
export const MAX_IMAGE_DIMENSION = 12_000;
|
|
5
|
+
export const MAX_IMAGE_PIXELS = 100_000_000;
|
|
6
|
+
export const ALLOWED_MEDIA_MIME_TYPES = Object.freeze([
|
|
7
|
+
"image/avif",
|
|
8
|
+
"image/jpeg",
|
|
9
|
+
"image/png",
|
|
10
|
+
"image/webp",
|
|
11
|
+
]);
|
|
12
|
+
function failure(message) {
|
|
13
|
+
throw new DomainError("CONTENT_INVALID_STATE", message);
|
|
14
|
+
}
|
|
15
|
+
function detached(value) {
|
|
16
|
+
return JSON.parse(JSON.stringify(value));
|
|
17
|
+
}
|
|
18
|
+
function isPrefix(bytes, prefix) {
|
|
19
|
+
return prefix.every((value, index) => bytes[index] === value);
|
|
20
|
+
}
|
|
21
|
+
/** Detects format only; ImageInspector validates container structure and dimensions. */
|
|
22
|
+
export function detectMediaMimeType(bytes) {
|
|
23
|
+
if (bytes.byteLength === 0)
|
|
24
|
+
failure("Media upload must not be empty.");
|
|
25
|
+
if (isPrefix(bytes, [0xff, 0xd8, 0xff]))
|
|
26
|
+
return "image/jpeg";
|
|
27
|
+
if (isPrefix(bytes, [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]))
|
|
28
|
+
return "image/png";
|
|
29
|
+
if (bytes.byteLength >= 12 &&
|
|
30
|
+
String.fromCharCode(...bytes.slice(0, 4)) === "RIFF" &&
|
|
31
|
+
String.fromCharCode(...bytes.slice(8, 12)) === "WEBP") {
|
|
32
|
+
return "image/webp";
|
|
33
|
+
}
|
|
34
|
+
if (bytes.byteLength >= 16 &&
|
|
35
|
+
String.fromCharCode(...bytes.slice(4, 8)) === "ftyp" &&
|
|
36
|
+
["avif", "avis"].includes(String.fromCharCode(...bytes.slice(8, 12)))) {
|
|
37
|
+
return "image/avif";
|
|
38
|
+
}
|
|
39
|
+
failure("Media upload is not an allowed image format.");
|
|
40
|
+
}
|
|
41
|
+
export function sanitizeMediaFilename(value) {
|
|
42
|
+
const withoutUnsafeCharacters = [...value.normalize("NFKC")]
|
|
43
|
+
.map((character) => {
|
|
44
|
+
const code = character.charCodeAt(0);
|
|
45
|
+
return code <= 0x1f ||
|
|
46
|
+
(code >= 0x7f && code <= 0x9f) ||
|
|
47
|
+
character === "/" ||
|
|
48
|
+
character === "\\"
|
|
49
|
+
? " "
|
|
50
|
+
: character;
|
|
51
|
+
})
|
|
52
|
+
.join("");
|
|
53
|
+
const normalized = withoutUnsafeCharacters.replace(/\s+/gu, " ").trim().slice(0, 255);
|
|
54
|
+
return normalized.length === 0 ? "upload" : normalized;
|
|
55
|
+
}
|
|
56
|
+
export async function collectMediaBytes(body) {
|
|
57
|
+
const chunks = [];
|
|
58
|
+
let size = 0;
|
|
59
|
+
for await (const chunk of body) {
|
|
60
|
+
if (!(chunk instanceof Uint8Array))
|
|
61
|
+
failure("Media stream yielded invalid binary data.");
|
|
62
|
+
size += chunk.byteLength;
|
|
63
|
+
if (size > MAX_MEDIA_BYTES)
|
|
64
|
+
failure("Media upload exceeds the 10 MiB limit.");
|
|
65
|
+
chunks.push(chunk.slice());
|
|
66
|
+
}
|
|
67
|
+
const bytes = new Uint8Array(size);
|
|
68
|
+
let offset = 0;
|
|
69
|
+
for (const chunk of chunks) {
|
|
70
|
+
bytes.set(chunk, offset);
|
|
71
|
+
offset += chunk.byteLength;
|
|
72
|
+
}
|
|
73
|
+
return bytes;
|
|
74
|
+
}
|
|
75
|
+
function streamBytes(bytes) {
|
|
76
|
+
return {
|
|
77
|
+
async *[Symbol.asyncIterator]() {
|
|
78
|
+
yield bytes.slice();
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function toMediaView(item) {
|
|
83
|
+
const value = item.media;
|
|
84
|
+
const mimeType = value.mimeType;
|
|
85
|
+
if (!ALLOWED_MEDIA_MIME_TYPES.includes(mimeType)) {
|
|
86
|
+
failure("Media metadata has an unsupported MIME type.");
|
|
87
|
+
}
|
|
88
|
+
return Object.freeze({
|
|
89
|
+
createdAt: value.createdAt,
|
|
90
|
+
createdBy: Object.freeze({ displayName: item.createdBy.displayName, id: item.createdBy.id }),
|
|
91
|
+
filename: value.filename,
|
|
92
|
+
...(value.height === undefined ? {} : { height: value.height }),
|
|
93
|
+
id: value.id,
|
|
94
|
+
mimeType: mimeType,
|
|
95
|
+
size: value.size,
|
|
96
|
+
status: value.status,
|
|
97
|
+
updatedAt: value.updatedAt,
|
|
98
|
+
usageCount: item.usageCount,
|
|
99
|
+
...(value.width === undefined ? {} : { width: value.width }),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function validateDimensions(width, height) {
|
|
103
|
+
if (!Number.isSafeInteger(width) ||
|
|
104
|
+
!Number.isSafeInteger(height) ||
|
|
105
|
+
width < 1 ||
|
|
106
|
+
height < 1 ||
|
|
107
|
+
width > MAX_IMAGE_DIMENSION ||
|
|
108
|
+
height > MAX_IMAGE_DIMENSION ||
|
|
109
|
+
width * height > MAX_IMAGE_PIXELS) {
|
|
110
|
+
failure("Image dimensions exceed the allowed limits.");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** Portable orchestration for media policy and metadata lifecycle commands. */
|
|
114
|
+
export class MediaUseCases {
|
|
115
|
+
dependencies;
|
|
116
|
+
constructor(dependencies) {
|
|
117
|
+
this.dependencies = dependencies;
|
|
118
|
+
}
|
|
119
|
+
async create(input) {
|
|
120
|
+
requirePermission(input.actor, "media:write");
|
|
121
|
+
const bytes = await collectMediaBytes(input.body);
|
|
122
|
+
const mimeType = detectMediaMimeType(bytes);
|
|
123
|
+
const dimensions = await this.dependencies.imageInspector.inspect(bytes, mimeType);
|
|
124
|
+
validateDimensions(dimensions.width, dimensions.height);
|
|
125
|
+
const id = mediaId(this.dependencies.idGenerator.next());
|
|
126
|
+
const storageKey = `media/${id}`;
|
|
127
|
+
const stored = await this.dependencies.storage.put({
|
|
128
|
+
body: streamBytes(bytes),
|
|
129
|
+
contentType: mimeType,
|
|
130
|
+
key: storageKey,
|
|
131
|
+
});
|
|
132
|
+
if (stored.key !== storageKey ||
|
|
133
|
+
stored.contentType !== mimeType ||
|
|
134
|
+
stored.size !== bytes.byteLength) {
|
|
135
|
+
await this.cleanupAfterMetadataFailure(storageKey, false);
|
|
136
|
+
failure("Object storage returned unexpected media metadata.");
|
|
137
|
+
}
|
|
138
|
+
const now = this.dependencies.clock.now();
|
|
139
|
+
try {
|
|
140
|
+
await this.dependencies.media.createMedia({
|
|
141
|
+
createdAt: now,
|
|
142
|
+
createdBy: input.actor.id,
|
|
143
|
+
filename: sanitizeMediaFilename(input.filename),
|
|
144
|
+
height: dimensions.height,
|
|
145
|
+
id,
|
|
146
|
+
mimeType,
|
|
147
|
+
size: bytes.byteLength,
|
|
148
|
+
storageKey,
|
|
149
|
+
width: dimensions.width,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
await this.cleanupAfterMetadataFailure(storageKey, true);
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
// Metadata is committed: a reload failure must not trigger object cleanup.
|
|
157
|
+
return this.catalogView(id, "Created media could not be reloaded.");
|
|
158
|
+
}
|
|
159
|
+
async get(input) {
|
|
160
|
+
requirePermission(input.actor, "content:read");
|
|
161
|
+
const item = await this.dependencies.media.loadMediaCatalogItem(input.mediaId);
|
|
162
|
+
if (item === null)
|
|
163
|
+
return null;
|
|
164
|
+
const usage = await this.dependencies.media.loadMediaUsage({
|
|
165
|
+
limit: MAX_MEDIA_USAGE_ENTRIES,
|
|
166
|
+
mediaId: input.mediaId,
|
|
167
|
+
});
|
|
168
|
+
return Object.freeze({
|
|
169
|
+
...toMediaView(detached(item)),
|
|
170
|
+
usage: Object.freeze(detached(usage.slice(0, MAX_MEDIA_USAGE_ENTRIES))),
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
async list(input) {
|
|
174
|
+
requirePermission(input.actor, "content:read");
|
|
175
|
+
const q = input.q?.trim();
|
|
176
|
+
if (q !== undefined && q.length > MAX_MEDIA_SEARCH_LENGTH) {
|
|
177
|
+
failure(`Search terms must not exceed ${MAX_MEDIA_SEARCH_LENGTH} characters.`);
|
|
178
|
+
}
|
|
179
|
+
if (input.type !== undefined &&
|
|
180
|
+
!ALLOWED_MEDIA_MIME_TYPES.includes(input.type)) {
|
|
181
|
+
failure("Media type filter is unsupported.");
|
|
182
|
+
}
|
|
183
|
+
if (input.sort !== undefined && !MEDIA_SORTS.includes(input.sort)) {
|
|
184
|
+
failure("Media sort is unsupported.");
|
|
185
|
+
}
|
|
186
|
+
const page = await this.dependencies.media.listMedia({
|
|
187
|
+
...(input.after === undefined ? {} : { after: input.after }),
|
|
188
|
+
limit: input.limit,
|
|
189
|
+
...(q === undefined || q.length === 0 ? {} : { q }),
|
|
190
|
+
sort: input.sort ?? DEFAULT_MEDIA_SORT,
|
|
191
|
+
...(input.type === undefined ? {} : { type: input.type }),
|
|
192
|
+
});
|
|
193
|
+
return Object.freeze({
|
|
194
|
+
items: Object.freeze(page.items.map((item) => toMediaView(detached(item)))),
|
|
195
|
+
...(page.nextCursor === undefined ? {} : { nextCursor: page.nextCursor }),
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
async requestDeletion(input) {
|
|
199
|
+
requirePermission(input.actor, "media:write");
|
|
200
|
+
const result = await this.dependencies.media.markForDeletion({
|
|
201
|
+
mediaId: input.mediaId,
|
|
202
|
+
requestedAt: this.dependencies.clock.now(),
|
|
203
|
+
requestedBy: input.actor,
|
|
204
|
+
});
|
|
205
|
+
return this.catalogView(result.media.id, "Media deletion mark could not be reloaded.");
|
|
206
|
+
}
|
|
207
|
+
async retryDeletion(input) {
|
|
208
|
+
requirePermission(input.actor, "media:write");
|
|
209
|
+
const result = await this.dependencies.media.retryDeletion({
|
|
210
|
+
mediaId: input.mediaId,
|
|
211
|
+
requestedAt: this.dependencies.clock.now(),
|
|
212
|
+
requestedBy: input.actor,
|
|
213
|
+
});
|
|
214
|
+
return this.catalogView(result.media.id, "Media deletion retry could not be reloaded.");
|
|
215
|
+
}
|
|
216
|
+
async preview(input) {
|
|
217
|
+
requirePermission(input.actor, "content:read");
|
|
218
|
+
const media = await this.dependencies.media.loadMedia(input.mediaId);
|
|
219
|
+
return media === null || media.status !== "active" ? null : this.readBinary(media);
|
|
220
|
+
}
|
|
221
|
+
async readPublic(input) {
|
|
222
|
+
const media = await this.dependencies.publicMedia?.loadPublicMedia(input.mediaId);
|
|
223
|
+
return media === undefined || media === null || media.status !== "active"
|
|
224
|
+
? null
|
|
225
|
+
: this.readBinary(media);
|
|
226
|
+
}
|
|
227
|
+
async catalogView(id, missing) {
|
|
228
|
+
const item = await this.dependencies.media.loadMediaCatalogItem(id);
|
|
229
|
+
if (item === null)
|
|
230
|
+
throw new Error(missing);
|
|
231
|
+
return toMediaView(detached(item));
|
|
232
|
+
}
|
|
233
|
+
async readBinary(media) {
|
|
234
|
+
const mimeType = media.mimeType;
|
|
235
|
+
if (!ALLOWED_MEDIA_MIME_TYPES.includes(mimeType)) {
|
|
236
|
+
throw new Error("Stored media has an unsupported MIME type.");
|
|
237
|
+
}
|
|
238
|
+
const body = await this.dependencies.storage.get(media.storageKey);
|
|
239
|
+
if (body === null)
|
|
240
|
+
throw new Error("Stored media object is unavailable.");
|
|
241
|
+
return Object.freeze({
|
|
242
|
+
body,
|
|
243
|
+
filename: sanitizeMediaFilename(media.filename),
|
|
244
|
+
mimeType: mimeType,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
async cleanupAfterMetadataFailure(storageKey, metadataFailure) {
|
|
248
|
+
if (metadataFailure) {
|
|
249
|
+
await this.recordOperationalError({
|
|
250
|
+
code: "MEDIA_METADATA_CREATE_FAILED",
|
|
251
|
+
storageKey,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
try {
|
|
255
|
+
await this.dependencies.storage.delete(storageKey);
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
await this.recordOperationalError({
|
|
259
|
+
code: "MEDIA_OBJECT_CLEANUP_FAILED",
|
|
260
|
+
storageKey,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
async recordOperationalError(input) {
|
|
265
|
+
try {
|
|
266
|
+
await this.dependencies.logger.error(input);
|
|
267
|
+
}
|
|
268
|
+
catch {
|
|
269
|
+
// Operational logging must not prevent object cleanup or replace the original failure.
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=media-use-cases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-use-cases.js","sourceRoot":"","sources":["../src/media-use-cases.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,WAAW,GACZ,MA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AM,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACnE,IAAI,IAAI,KAAK,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QAC1E,OAAO,MAAM,CAAC,MAAM,CAAC;YACnB,IAAI;YACJ,QAAQ,EAAE,qBAAqB,CAAC,KAAK,CAAC,QAAQ,CAAC;YAC/C,QAAQ,EAAE,QAAyB;SACpC,CAAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,2BAA2B,CACvC,UAAkB,EAClB,eAAwB;QAExB,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,IAAI,CAAC,sBAAsB,CAAC;gBAChC,IAAI,EAAE,8BAA8B;gBACpC,UAAU;aACX,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACrD,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,CAAC,sBAAsB,CAAC;gBAChC,IAAI,EAAE,6BAA6B;gBACnC,UAAU;aACX,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,sBAAsB,CAAC,KAGpC;QACC,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC9C,CAAC;QAAC,MAAM,CAAC;YACP,uFAAuF;QACzF,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Actor } from "@lacecms/domain";
|
|
2
|
+
import type { BuildQueueReceipt, Clock, SiteBuildCommandPort, SiteBuildReadPort } from "./index.js";
|
|
3
|
+
/** Administrator commands enqueue durable work without invoking a build provider. */
|
|
4
|
+
export declare class SiteBuildUseCases {
|
|
5
|
+
private readonly dependencies;
|
|
6
|
+
constructor(dependencies: {
|
|
7
|
+
readonly clock: Clock;
|
|
8
|
+
readonly builds: SiteBuildCommandPort & SiteBuildReadPort;
|
|
9
|
+
});
|
|
10
|
+
list(_actor: Actor): Promise<readonly import("./index.js").SiteBuildRecord[]>;
|
|
11
|
+
get(_actor: Actor, buildId: string): Promise<import("./index.js").SiteBuildRecord | null>;
|
|
12
|
+
request(actor: Actor): Promise<BuildQueueReceipt>;
|
|
13
|
+
retry(actor: Actor, buildId: string): Promise<BuildQueueReceipt>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=site-build-use-cases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-build-use-cases.d.ts","sourceRoot":"","sources":["../src/site-build-use-cases.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpG,qFAAqF;AACrF,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAD/B,YACmB,YAAY,EAAE;QAC7B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;QACtB,QAAQ,CAAC,MAAM,EAAE,oBAAoB,GAAG,iBAAiB,CAAC;KAC3D,EACC;IAEG,IAAI,CAAC,MAAM,EAAE,KAAK,4DAExB;IAEM,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,wDAExC;IAEM,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAMvD;IAEM,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAOtE;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { requirePermission, siteBuildId } from "@lacecms/domain";
|
|
2
|
+
/** Administrator commands enqueue durable work without invoking a build provider. */
|
|
3
|
+
export class SiteBuildUseCases {
|
|
4
|
+
dependencies;
|
|
5
|
+
constructor(dependencies) {
|
|
6
|
+
this.dependencies = dependencies;
|
|
7
|
+
}
|
|
8
|
+
list(_actor) {
|
|
9
|
+
return this.dependencies.builds.listSiteBuilds(50);
|
|
10
|
+
}
|
|
11
|
+
get(_actor, buildId) {
|
|
12
|
+
return this.dependencies.builds.getSiteBuild(siteBuildId(buildId));
|
|
13
|
+
}
|
|
14
|
+
request(actor) {
|
|
15
|
+
requirePermission(actor, "settings:manage");
|
|
16
|
+
return this.dependencies.builds.requestBuild({
|
|
17
|
+
requestedAt: this.dependencies.clock.now(),
|
|
18
|
+
requestedBy: actor,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
retry(actor, buildId) {
|
|
22
|
+
requirePermission(actor, "settings:manage");
|
|
23
|
+
return this.dependencies.builds.requestBuild({
|
|
24
|
+
requestedAt: this.dependencies.clock.now(),
|
|
25
|
+
requestedBy: actor,
|
|
26
|
+
retryOfBuildId: siteBuildId(buildId),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=site-build-use-cases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-build-use-cases.js","sourceRoot":"","sources":["../src/site-build-use-cases.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAIjE,qFAAqF;AACrF,MAAM,OAAO,iBAAiB;IAET,YAAY;IAD/B,YACmB,YAGhB;4BAHgB,YAAY;IAI5B,CAAC;IAEG,IAAI,CAAC,MAAa;QACvB,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IACrD,CAAC;IAEM,GAAG,CAAC,MAAa,EAAE,OAAe;QACvC,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IACrE,CAAC;IAEM,OAAO,CAAC,KAAY;QACzB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC;YAC3C,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE;YAC1C,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,KAAY,EAAE,OAAe;QACxC,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC;YAC3C,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE;YAC1C,WAAW,EAAE,KAAK;YAClB,cAAc,EAAE,WAAW,CAAC,OAAO,CAAC;SACrC,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lacecms/application",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/lacecms/lace.git",
|
|
8
|
+
"directory": "packages/application"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"type": "module",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public",
|
|
23
|
+
"tag": "next"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@lacecms/config": "0.1.0-alpha.2",
|
|
27
|
+
"@lacecms/content": "0.1.0-alpha.2",
|
|
28
|
+
"@lacecms/domain": "0.1.0-alpha.2"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=24.12.0 <25"
|
|
32
|
+
}
|
|
6
33
|
}
|
package/README.md
DELETED