@puzzle-ui/media 0.0.0-stage → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +305 -2
  2. package/ai/instructions.md +70 -0
  3. package/ai/manifest.json +10 -0
  4. package/dist/LICENSE +21 -0
  5. package/dist/adapters-Bon320yF.js +481 -0
  6. package/dist/adapters-Bon320yF.js.map +1 -0
  7. package/dist/adapters-C4N2gqSK.d.cts +63 -0
  8. package/dist/adapters-DXycRsjJ.cjs +492 -0
  9. package/dist/adapters-DXycRsjJ.cjs.map +1 -0
  10. package/dist/adapters-DhPviL_C.d.ts +63 -0
  11. package/dist/browser/index.cjs +200 -0
  12. package/dist/browser/index.cjs.map +1 -0
  13. package/dist/browser/index.d.cts +89 -0
  14. package/dist/browser/index.d.ts +89 -0
  15. package/dist/browser/index.js +195 -0
  16. package/dist/browser/index.js.map +1 -0
  17. package/dist/image-processing-B1lRPpsg.cjs +444 -0
  18. package/dist/image-processing-B1lRPpsg.cjs.map +1 -0
  19. package/dist/image-processing-XkoQ8NT7.js +400 -0
  20. package/dist/image-processing-XkoQ8NT7.js.map +1 -0
  21. package/dist/image-worker.cjs +36 -0
  22. package/dist/image-worker.cjs.map +1 -0
  23. package/dist/image-worker.d.cts +1 -0
  24. package/dist/image-worker.d.ts +1 -0
  25. package/dist/image-worker.js +37 -0
  26. package/dist/image-worker.js.map +1 -0
  27. package/dist/index-8Seqy-LJ.d.ts +297 -0
  28. package/dist/index-BP0ikbAS.d.cts +297 -0
  29. package/dist/index.cjs +38 -0
  30. package/dist/index.d.cts +4 -0
  31. package/dist/index.d.ts +4 -0
  32. package/dist/index.js +3 -0
  33. package/dist/media-validation-By6karZu.cjs +361 -0
  34. package/dist/media-validation-By6karZu.cjs.map +1 -0
  35. package/dist/media-validation-OyjGVUq3.js +230 -0
  36. package/dist/media-validation-OyjGVUq3.js.map +1 -0
  37. package/dist/media.types-dzfu0Nep.d.cts +127 -0
  38. package/dist/media.types-dzfu0Nep.d.ts +127 -0
  39. package/dist/processing.types-CPaSB88L.d.ts +238 -0
  40. package/dist/processing.types-Dd2XT8Qr.d.cts +238 -0
  41. package/dist/src-8d6s1iWH.js +1286 -0
  42. package/dist/src-8d6s1iWH.js.map +1 -0
  43. package/dist/src-C7WU7ovP.cjs +1363 -0
  44. package/dist/src-C7WU7ovP.cjs.map +1 -0
  45. package/dist/testing/adapters.cjs +4 -0
  46. package/dist/testing/adapters.d.cts +2 -0
  47. package/dist/testing/adapters.d.ts +2 -0
  48. package/dist/testing/adapters.js +1 -0
  49. package/dist/testing/index.cjs +264 -0
  50. package/dist/testing/index.cjs.map +1 -0
  51. package/dist/testing/index.d.cts +14 -0
  52. package/dist/testing/index.d.ts +14 -0
  53. package/dist/testing/index.js +260 -0
  54. package/dist/testing/index.js.map +1 -0
  55. package/package.json +84 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-validation-OyjGVUq3.js","names":[],"sources":["../src/errors/media.errors.ts","../src/utils/media-validation.ts"],"sourcesContent":["export type MediaErrorCode =\n | \"INVALID_FILE\"\n | \"QUOTA_EXCEEDED\"\n | \"UNSUPPORTED_MEDIA\"\n | \"UPLOAD_EXPIRED\"\n | \"CHECKSUM_MISMATCH\"\n | \"PROCESSING_FAILED\"\n | \"PERMISSION_DENIED\"\n | \"ASSET_CONFLICT\"\n | \"NOT_FOUND\"\n | \"VALIDATION\"\n | \"CAPABILITY\"\n | \"OBJECT_STORAGE\"\n | \"UNKNOWN\";\n\nexport type MediaErrorOptions = {\n readonly cause?: unknown;\n readonly details?: Readonly<Record<string, unknown>>;\n};\n\nexport class MediaError extends Error {\n readonly code: MediaErrorCode;\n override readonly cause?: unknown;\n readonly details?: Readonly<Record<string, unknown>>;\n\n constructor(\n code: MediaErrorCode,\n message: string,\n options?: MediaErrorOptions,\n ) {\n super(message);\n this.name = \"MediaError\";\n this.code = code;\n this.cause = options?.cause;\n this.details = options?.details;\n }\n}\n\nexport class InvalidMediaFileError extends MediaError {\n constructor(message: string, options?: MediaErrorOptions) {\n super(\"INVALID_FILE\", message, options);\n this.name = \"InvalidMediaFileError\";\n }\n}\n\nexport class MediaQuotaExceededError extends MediaError {\n constructor(message = \"The media quota has been exceeded.\") {\n super(\"QUOTA_EXCEEDED\", message);\n this.name = \"MediaQuotaExceededError\";\n }\n}\n\nexport class UnsupportedMediaError extends MediaError {\n constructor(message: string, options?: MediaErrorOptions) {\n super(\"UNSUPPORTED_MEDIA\", message, options);\n this.name = \"UnsupportedMediaError\";\n }\n}\n\nexport class MediaUploadExpiredError extends MediaError {\n constructor(message = \"The media upload session has expired.\") {\n super(\"UPLOAD_EXPIRED\", message);\n this.name = \"MediaUploadExpiredError\";\n }\n}\n\nexport class MediaChecksumMismatchError extends MediaError {\n constructor(message = \"The uploaded object's checksum does not match.\") {\n super(\"CHECKSUM_MISMATCH\", message);\n this.name = \"MediaChecksumMismatchError\";\n }\n}\n\nexport class MediaProcessingError extends MediaError {\n readonly retryable: boolean;\n\n constructor(\n message: string,\n options?: MediaErrorOptions & { readonly retryable?: boolean },\n ) {\n super(\"PROCESSING_FAILED\", message, options);\n this.name = \"MediaProcessingError\";\n this.retryable = options?.retryable ?? true;\n }\n}\n\nexport class MediaPermissionDeniedError extends MediaError {\n constructor(message = \"The actor is not permitted to perform this operation.\") {\n super(\"PERMISSION_DENIED\", message);\n this.name = \"MediaPermissionDeniedError\";\n }\n}\n\nexport class MediaAssetConflictError extends MediaError {\n constructor(message: string, options?: MediaErrorOptions) {\n super(\"ASSET_CONFLICT\", message, options);\n this.name = \"MediaAssetConflictError\";\n }\n}\n\nexport class MediaNotFoundError extends MediaError {\n constructor(resource = \"Media resource\") {\n super(\"NOT_FOUND\", `${resource} was not found.`);\n this.name = \"MediaNotFoundError\";\n }\n}\n\nexport class MediaValidationError extends MediaError {\n constructor(\n message: string,\n details?: Readonly<Record<string, unknown>>,\n ) {\n super(\"VALIDATION\", message, { details });\n this.name = \"MediaValidationError\";\n }\n}\n\nexport class MediaCapabilityError extends MediaError {\n readonly capability: string;\n\n constructor(capability: string) {\n super(\n \"CAPABILITY\",\n `The configured adapter does not support the required capability: ${capability}.`,\n { details: { capability } },\n );\n this.name = \"MediaCapabilityError\";\n this.capability = capability;\n }\n}\n\nexport class MediaObjectStorageError extends MediaError {\n constructor(message: string, options?: MediaErrorOptions) {\n super(\"OBJECT_STORAGE\", message, options);\n this.name = \"MediaObjectStorageError\";\n }\n}\n","import { MediaValidationError } from \"../errors/media.errors\";\nimport type {\n MediaChecksum,\n MediaCrop,\n MediaFocalPoint,\n MediaFileMetadata,\n MediaHotspot,\n MediaKind,\n MediaObjectReference,\n} from \"../types/media.types\";\nimport type {\n MediaImageProfile,\n MediaVideoRenditionProfile,\n} from \"../types/processing.types\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isFinitePositive = (value: unknown): value is number =>\n typeof value === \"number\" && Number.isFinite(value) && value > 0;\n\nconst assertNormalizedCoordinate = (value: unknown, field: string): number => {\n if (typeof value !== \"number\" || !Number.isFinite(value) || value < 0 || value > 1) {\n throw new MediaValidationError(`${field} must be a finite number from 0 to 1.`);\n }\n return value;\n};\n\nconst validateProfileSize = (\n profile: { readonly maxWidth?: number; readonly maxHeight?: number },\n name: string,\n): void => {\n if (profile.maxWidth === undefined && profile.maxHeight === undefined) {\n throw new MediaValidationError(\n `Profile \"${name}\" must define maxWidth, maxHeight, or both.`,\n );\n }\n for (const [key, value] of [\n [\"maxWidth\", profile.maxWidth],\n [\"maxHeight\", profile.maxHeight],\n ] as const) {\n if (value !== undefined && (!Number.isInteger(value) || value < 1)) {\n throw new MediaValidationError(\n `Profile \"${name}\" ${key} must be a positive integer.`,\n );\n }\n }\n};\n\nexport const normalizeMediaChecksum = (input: unknown): MediaChecksum => {\n if (!isRecord(input) || input.algorithm !== \"sha256\" || typeof input.value !== \"string\") {\n throw new MediaValidationError(\"Checksum must be a sha256 digest.\");\n }\n const value = input.value.toLowerCase();\n if (!/^[a-f0-9]{64}$/.test(value)) {\n throw new MediaValidationError(\"A sha256 checksum must contain 64 hexadecimal characters.\");\n }\n return { algorithm: \"sha256\", value };\n};\n\nexport const normalizeMediaObjectReference = (\n input: unknown,\n): MediaObjectReference => {\n if (!isRecord(input) || typeof input.key !== \"string\" || input.key.trim() === \"\") {\n throw new MediaValidationError(\"A media object reference requires a non-empty key.\");\n }\n if (/[\\u0000-\\u001f\\u007f]/.test(input.key)) {\n throw new MediaValidationError(\"A media object key cannot contain control characters.\");\n }\n if (\n input.versionId !== undefined &&\n (typeof input.versionId !== \"string\" ||\n input.versionId.trim() === \"\" ||\n /[\\u0000-\\u001f\\u007f]/.test(input.versionId))\n ) {\n throw new MediaValidationError(\"Object versionId must be a non-empty safe string.\");\n }\n return {\n key: input.key,\n ...(input.versionId !== undefined ? { versionId: input.versionId } : {}),\n };\n};\n\nexport const normalizeMediaCrop = (input: unknown): MediaCrop => {\n if (!isRecord(input)) {\n throw new MediaValidationError(\"A crop must be an object.\");\n }\n const x = assertNormalizedCoordinate(input.x, \"crop.x\");\n const y = assertNormalizedCoordinate(input.y, \"crop.y\");\n const width = assertNormalizedCoordinate(input.width, \"crop.width\");\n const height = assertNormalizedCoordinate(input.height, \"crop.height\");\n if (width <= 0 || height <= 0 || x + width > 1 || y + height > 1) {\n throw new MediaValidationError(\n \"A crop must have positive dimensions and remain within the image bounds.\",\n );\n }\n return { x, y, width, height };\n};\n\nexport const normalizeMediaFocalPoint = (input: unknown): MediaFocalPoint => {\n if (!isRecord(input)) {\n throw new MediaValidationError(\n \"A focal point must be an object with x and y coordinates.\",\n );\n }\n return {\n x: assertNormalizedCoordinate(input.x, \"focalPoint.x\"),\n y: assertNormalizedCoordinate(input.y, \"focalPoint.y\"),\n };\n};\n\nexport const normalizeMediaHotspots = (input: unknown): readonly MediaHotspot[] => {\n if (!Array.isArray(input)) {\n throw new MediaValidationError(\"Hotspots must be an array.\");\n }\n const ids = new Set<string>();\n return input.map((item, index) => {\n if (!isRecord(item) || typeof item.id !== \"string\" || item.id.trim() === \"\") {\n throw new MediaValidationError(`Hotspot at index ${index} requires an id.`);\n }\n if (ids.has(item.id)) {\n throw new MediaValidationError(`Hotspot id \"${item.id}\" is duplicated.`);\n }\n ids.add(item.id);\n const x = assertNormalizedCoordinate(item.x, `hotspots[${index}].x`);\n const y = assertNormalizedCoordinate(item.y, `hotspots[${index}].y`);\n const width =\n item.width === undefined\n ? undefined\n : assertNormalizedCoordinate(item.width, `hotspots[${index}].width`);\n const height =\n item.height === undefined\n ? undefined\n : assertNormalizedCoordinate(item.height, `hotspots[${index}].height`);\n if ((width === undefined) !== (height === undefined)) {\n throw new MediaValidationError(\n `Hotspot \"${item.id}\" must define both width and height, or neither.`,\n );\n }\n if (\n width !== undefined &&\n height !== undefined &&\n ((width === 0) !== (height === 0) || x + width > 1 || y + height > 1)\n ) {\n throw new MediaValidationError(\n `Hotspot \"${item.id}\" must be a point or have positive dimensions within image bounds.`,\n );\n }\n if (item.label !== undefined && typeof item.label !== \"string\") {\n throw new MediaValidationError(`Hotspot \"${item.id}\" label must be a string.`);\n }\n if (item.data !== undefined) {\n if (!isRecord(item.data)) {\n throw new MediaValidationError(`Hotspot \"${item.id}\" data must be an object.`);\n }\n for (const value of Object.values(item.data)) {\n if (\n value !== null &&\n typeof value !== \"string\" &&\n typeof value !== \"number\" &&\n typeof value !== \"boolean\"\n ) {\n throw new MediaValidationError(\n `Hotspot \"${item.id}\" data must contain only JSON scalar values.`,\n );\n }\n }\n }\n return {\n id: item.id,\n x,\n y,\n ...(width !== undefined ? { width, height } : {}),\n ...(typeof item.label === \"string\" ? { label: item.label } : {}),\n ...(isRecord(item.data)\n ? {\n data: item.data as Readonly<\n Record<string, string | number | boolean | null>\n >,\n }\n : {}),\n };\n });\n};\n\nexport const normalizeMediaTags = (input: unknown): readonly string[] => {\n if (!Array.isArray(input) || input.some((tag) => typeof tag !== \"string\")) {\n throw new MediaValidationError(\"Tags must be an array of strings.\");\n }\n return [...new Set(input.map((tag: string) => tag.trim()).filter(Boolean))];\n};\n\nexport const validateMediaFileMetadata = (\n input: unknown,\n): MediaFileMetadata => {\n if (!isRecord(input)) {\n throw new MediaValidationError(\"Media metadata must be an object.\");\n }\n const kinds: readonly MediaKind[] = [\n \"image\",\n \"video\",\n \"audio\",\n \"document\",\n \"other\",\n ];\n if (!kinds.includes(input.kind as MediaKind)) {\n throw new MediaValidationError(\"Media kind is not supported.\");\n }\n if (\n typeof input.mimeType !== \"string\" ||\n !/^[a-z0-9!#$&^_.+-]+\\/[a-z0-9!#$&^_.+-]+$/i.test(input.mimeType)\n ) {\n throw new MediaValidationError(\"Media mimeType must be a valid type/subtype.\");\n }\n const kind = input.kind as MediaKind;\n if (\n (kind === \"image\" || kind === \"video\" || kind === \"audio\") &&\n !input.mimeType.toLowerCase().startsWith(`${kind}/`)\n ) {\n throw new MediaValidationError(\n `A ${kind} asset must have a ${kind}/* MIME type.`,\n );\n }\n if (!Number.isSafeInteger(input.size) || (input.size as number) < 1) {\n throw new MediaValidationError(\"Media size must be a positive safe integer.\");\n }\n const dimensionsPresent = input.width !== undefined || input.height !== undefined;\n if (\n dimensionsPresent &&\n (!isFinitePositive(input.width) ||\n !isFinitePositive(input.height) ||\n !Number.isSafeInteger(input.width) ||\n !Number.isSafeInteger(input.height))\n ) {\n throw new MediaValidationError(\n \"Media dimensions must include positive integer width and height values.\",\n );\n }\n if (input.duration !== undefined && !isFinitePositive(input.duration) && input.duration !== 0) {\n throw new MediaValidationError(\"Media duration must be a finite non-negative number.\");\n }\n if (\n input.orientation !== undefined &&\n (typeof input.orientation !== \"number\" ||\n !Number.isInteger(input.orientation) ||\n input.orientation < 1 ||\n input.orientation > 8)\n ) {\n throw new MediaValidationError(\"Image orientation must be an integer from 1 to 8.\");\n }\n const checksum =\n input.checksum === undefined\n ? undefined\n : normalizeMediaChecksum(input.checksum);\n return {\n kind,\n mimeType: input.mimeType.toLowerCase(),\n size: input.size as number,\n ...(checksum ? { checksum } : {}),\n ...(dimensionsPresent\n ? { width: input.width as number, height: input.height as number }\n : {}),\n ...(input.duration !== undefined ? { duration: input.duration as number } : {}),\n ...(input.orientation !== undefined\n ? { orientation: input.orientation as number }\n : {}),\n };\n};\n\nexport const validateMediaImageProfiles = (\n profiles: readonly MediaImageProfile[],\n): readonly MediaImageProfile[] => {\n if (profiles.length === 0) {\n throw new MediaValidationError(\"At least one image processing profile is required.\");\n }\n const names = new Set<string>();\n for (const profile of profiles) {\n if (profile.name.trim() === \"\" || names.has(profile.name)) {\n throw new MediaValidationError(\n \"Image profile names must be non-empty and unique.\",\n );\n }\n names.add(profile.name);\n validateProfileSize(profile, profile.name);\n if (\n profile.quality !== undefined &&\n (!Number.isFinite(profile.quality) ||\n profile.quality < 0 ||\n profile.quality > 1)\n ) {\n throw new MediaValidationError(\n `Image profile \"${profile.name}\" quality must be from 0 to 1.`,\n );\n }\n }\n return profiles;\n};\n\nexport const validateMediaVideoProfiles = (\n profiles: readonly MediaVideoRenditionProfile[],\n): readonly MediaVideoRenditionProfile[] => {\n if (profiles.length === 0) {\n throw new MediaValidationError(\"At least one video rendition profile is required.\");\n }\n const names = new Set<string>();\n for (const profile of profiles) {\n if (profile.name.trim() === \"\" || names.has(profile.name)) {\n throw new MediaValidationError(\n \"Video profile names must be non-empty and unique.\",\n );\n }\n names.add(profile.name);\n validateProfileSize(profile, profile.name);\n for (const [key, value] of [\n [\"videoBitrate\", profile.videoBitrate],\n [\"audioBitrate\", profile.audioBitrate],\n ] as const) {\n if (value !== undefined && (!Number.isInteger(value) || value < 1)) {\n throw new MediaValidationError(\n `Video profile \"${profile.name}\" ${key} must be a positive integer.`,\n );\n }\n }\n }\n return profiles;\n};\n"],"mappings":";AAoBA,IAAa,aAAb,cAAgC,MAAM;CACpC;CACA;CACA;CAEA,YACE,MACA,SACA,SACA;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;E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IAAI;EACtB,oBAAoB,SAAS,QAAQ,IAAI;EACzC,IACE,QAAQ,YAAY,KAAA,MACnB,CAAC,OAAO,SAAS,QAAQ,OAAO,KAC/B,QAAQ,UAAU,KAClB,QAAQ,UAAU,IAEpB,MAAM,IAAI,qBACR,kBAAkB,QAAQ,KAAK,+BACjC;CAEJ;CACA,OAAO;AACT;AAEA,MAAa,8BACX,aAC0C;CAC1C,IAAI,SAAS,WAAW,GACtB,MAAM,IAAI,qBAAqB,mDAAmD;CAEpF,MAAM,wBAAQ,IAAI,IAAY;CAC9B,KAAK,MAAM,WAAW,UAAU;EAC9B,IAAI,QAAQ,KAAK,KAAK,MAAM,MAAM,MAAM,IAAI,QAAQ,IAAI,GACtD,MAAM,IAAI,qBACR,mDACF;EAEF,MAAM,IAAI,QAAQ,IAAI;EACtB,oBAAoB,SAAS,QAAQ,IAAI;EACzC,KAAK,MAAM,CAAC,KAAK,UAAU,CACzB,CAAC,gBAAgB,QAAQ,YAAY,GACrC,CAAC,gBAAgB,QAAQ,YAAY,CACvC,GACE,IAAI,UAAU,KAAA,MAAc,CAAC,OAAO,UAAU,KAAK,KAAK,QAAQ,IAC9D,MAAM,IAAI,qBACR,kBAAkB,QAAQ,KAAK,IAAI,IAAI,6BACzC;CAGN;CACA,OAAO;AACT"}
@@ -0,0 +1,127 @@
1
+ declare const MEDIA_ASSET_STATUSES: readonly ["pending-upload", "uploaded", "processing", "ready", "failed", "deleted"];
2
+ type MediaAssetStatus = (typeof MEDIA_ASSET_STATUSES)[number];
3
+ declare const MEDIA_KINDS: readonly ["image", "video", "audio", "document", "other"];
4
+ type MediaKind = (typeof MEDIA_KINDS)[number];
5
+ type MediaChecksum = {
6
+ readonly algorithm: "sha256";
7
+ readonly value: string;
8
+ };
9
+ type MediaObjectReference = {
10
+ readonly key: string;
11
+ readonly versionId?: string;
12
+ };
13
+ type MediaCrop = {
14
+ /** Normalized x-coordinate relative to the original, oriented image. */
15
+ readonly x: number;
16
+ /** Normalized y-coordinate relative to the original, oriented image. */
17
+ readonly y: number;
18
+ readonly width: number;
19
+ readonly height: number;
20
+ };
21
+ type MediaFocalPoint = {
22
+ /** Normalized coordinates relative to the original, oriented image. */
23
+ readonly x: number;
24
+ readonly y: number;
25
+ };
26
+ type MediaHotspot = {
27
+ readonly id: string;
28
+ /** Normalized coordinates relative to the original, oriented image. */
29
+ readonly x: number;
30
+ readonly y: number;
31
+ /** Omit both dimensions or set both to zero for a point. Areas use positive dimensions. */
32
+ readonly width?: number;
33
+ readonly height?: number;
34
+ readonly label?: string;
35
+ readonly data?: Readonly<Record<string, string | number | boolean | null>>;
36
+ };
37
+ type MediaVariantStatus = "pending" | "ready" | "failed";
38
+ type MediaVariant = {
39
+ readonly id: string;
40
+ readonly assetId: string;
41
+ readonly name: string;
42
+ readonly kind: "image" | "video" | "poster" | "manifest" | "thumbnail";
43
+ readonly status: MediaVariantStatus;
44
+ readonly object?: MediaObjectReference;
45
+ readonly mimeType?: string;
46
+ readonly size?: number;
47
+ /** Content fingerprint only; checksums are not unique asset identifiers. */
48
+ readonly checksum?: MediaChecksum;
49
+ readonly width?: number;
50
+ readonly height?: number;
51
+ readonly duration?: number;
52
+ readonly bitrate?: number;
53
+ readonly createdAt: Date;
54
+ readonly updatedAt: Date;
55
+ readonly error?: string | null;
56
+ };
57
+ type MediaAsset = {
58
+ readonly id: string;
59
+ readonly tenantId: string;
60
+ readonly folderId: string | null;
61
+ readonly originalName: string;
62
+ readonly displayName: string;
63
+ readonly kind: MediaKind;
64
+ readonly mimeType: string;
65
+ readonly size: number;
66
+ /** Duplicate checksums are allowed; asset IDs remain distinct. */
67
+ readonly checksum?: MediaChecksum;
68
+ readonly object: MediaObjectReference;
69
+ readonly width?: number;
70
+ readonly height?: number;
71
+ readonly duration?: number;
72
+ readonly orientation?: number;
73
+ readonly status: MediaAssetStatus;
74
+ readonly altText?: string | null;
75
+ readonly caption?: string | null;
76
+ readonly title?: string | null;
77
+ readonly description?: string | null;
78
+ readonly tags: readonly string[];
79
+ readonly crop?: MediaCrop | null;
80
+ readonly hotspots: readonly MediaHotspot[];
81
+ readonly focalPoint: MediaFocalPoint | null;
82
+ readonly variants: readonly MediaVariant[];
83
+ readonly processingError?: string | null;
84
+ readonly processingJobId?: string | null;
85
+ readonly previousStatus?: Exclude<MediaAssetStatus, "deleted"> | null;
86
+ readonly createdAt: Date;
87
+ readonly updatedAt: Date;
88
+ readonly createdBy?: string | null;
89
+ readonly updatedBy?: string | null;
90
+ readonly deletedAt?: Date | null;
91
+ readonly revision: number;
92
+ };
93
+ type MediaFolder = {
94
+ readonly id: string;
95
+ readonly tenantId: string;
96
+ readonly parentId: string | null;
97
+ readonly name: string;
98
+ readonly createdAt: Date;
99
+ readonly updatedAt: Date;
100
+ readonly createdBy?: string | null;
101
+ readonly updatedBy?: string | null;
102
+ readonly deletedAt?: Date | null;
103
+ readonly revision: number;
104
+ };
105
+ type MediaAssetUsage = {
106
+ readonly id: string;
107
+ readonly tenantId: string;
108
+ readonly assetId: string;
109
+ readonly resourceType: string;
110
+ readonly resourceId: string;
111
+ readonly fieldKey: string;
112
+ readonly createdAt: Date;
113
+ readonly updatedAt: Date;
114
+ readonly createdBy?: string | null;
115
+ readonly revision: number;
116
+ };
117
+ type MediaFileMetadata = {
118
+ readonly kind: MediaKind;
119
+ readonly mimeType: string;
120
+ readonly size: number;
121
+ readonly checksum?: MediaChecksum;
122
+ readonly width?: number;
123
+ readonly height?: number;
124
+ readonly duration?: number;
125
+ readonly orientation?: number;
126
+ };
127
+ export { MediaAssetUsage as a, MediaFileMetadata as c, MediaHotspot as d, MediaKind as f, MediaVariantStatus as h, MediaAssetStatus as i, MediaFocalPoint as l, MediaVariant as m, MEDIA_KINDS as n, MediaChecksum as o, MediaObjectReference as p, MediaAsset as r, MediaCrop as s, MEDIA_ASSET_STATUSES as t, MediaFolder as u };
@@ -0,0 +1,127 @@
1
+ declare const MEDIA_ASSET_STATUSES: readonly ["pending-upload", "uploaded", "processing", "ready", "failed", "deleted"];
2
+ type MediaAssetStatus = (typeof MEDIA_ASSET_STATUSES)[number];
3
+ declare const MEDIA_KINDS: readonly ["image", "video", "audio", "document", "other"];
4
+ type MediaKind = (typeof MEDIA_KINDS)[number];
5
+ type MediaChecksum = {
6
+ readonly algorithm: "sha256";
7
+ readonly value: string;
8
+ };
9
+ type MediaObjectReference = {
10
+ readonly key: string;
11
+ readonly versionId?: string;
12
+ };
13
+ type MediaCrop = {
14
+ /** Normalized x-coordinate relative to the original, oriented image. */
15
+ readonly x: number;
16
+ /** Normalized y-coordinate relative to the original, oriented image. */
17
+ readonly y: number;
18
+ readonly width: number;
19
+ readonly height: number;
20
+ };
21
+ type MediaFocalPoint = {
22
+ /** Normalized coordinates relative to the original, oriented image. */
23
+ readonly x: number;
24
+ readonly y: number;
25
+ };
26
+ type MediaHotspot = {
27
+ readonly id: string;
28
+ /** Normalized coordinates relative to the original, oriented image. */
29
+ readonly x: number;
30
+ readonly y: number;
31
+ /** Omit both dimensions or set both to zero for a point. Areas use positive dimensions. */
32
+ readonly width?: number;
33
+ readonly height?: number;
34
+ readonly label?: string;
35
+ readonly data?: Readonly<Record<string, string | number | boolean | null>>;
36
+ };
37
+ type MediaVariantStatus = "pending" | "ready" | "failed";
38
+ type MediaVariant = {
39
+ readonly id: string;
40
+ readonly assetId: string;
41
+ readonly name: string;
42
+ readonly kind: "image" | "video" | "poster" | "manifest" | "thumbnail";
43
+ readonly status: MediaVariantStatus;
44
+ readonly object?: MediaObjectReference;
45
+ readonly mimeType?: string;
46
+ readonly size?: number;
47
+ /** Content fingerprint only; checksums are not unique asset identifiers. */
48
+ readonly checksum?: MediaChecksum;
49
+ readonly width?: number;
50
+ readonly height?: number;
51
+ readonly duration?: number;
52
+ readonly bitrate?: number;
53
+ readonly createdAt: Date;
54
+ readonly updatedAt: Date;
55
+ readonly error?: string | null;
56
+ };
57
+ type MediaAsset = {
58
+ readonly id: string;
59
+ readonly tenantId: string;
60
+ readonly folderId: string | null;
61
+ readonly originalName: string;
62
+ readonly displayName: string;
63
+ readonly kind: MediaKind;
64
+ readonly mimeType: string;
65
+ readonly size: number;
66
+ /** Duplicate checksums are allowed; asset IDs remain distinct. */
67
+ readonly checksum?: MediaChecksum;
68
+ readonly object: MediaObjectReference;
69
+ readonly width?: number;
70
+ readonly height?: number;
71
+ readonly duration?: number;
72
+ readonly orientation?: number;
73
+ readonly status: MediaAssetStatus;
74
+ readonly altText?: string | null;
75
+ readonly caption?: string | null;
76
+ readonly title?: string | null;
77
+ readonly description?: string | null;
78
+ readonly tags: readonly string[];
79
+ readonly crop?: MediaCrop | null;
80
+ readonly hotspots: readonly MediaHotspot[];
81
+ readonly focalPoint: MediaFocalPoint | null;
82
+ readonly variants: readonly MediaVariant[];
83
+ readonly processingError?: string | null;
84
+ readonly processingJobId?: string | null;
85
+ readonly previousStatus?: Exclude<MediaAssetStatus, "deleted"> | null;
86
+ readonly createdAt: Date;
87
+ readonly updatedAt: Date;
88
+ readonly createdBy?: string | null;
89
+ readonly updatedBy?: string | null;
90
+ readonly deletedAt?: Date | null;
91
+ readonly revision: number;
92
+ };
93
+ type MediaFolder = {
94
+ readonly id: string;
95
+ readonly tenantId: string;
96
+ readonly parentId: string | null;
97
+ readonly name: string;
98
+ readonly createdAt: Date;
99
+ readonly updatedAt: Date;
100
+ readonly createdBy?: string | null;
101
+ readonly updatedBy?: string | null;
102
+ readonly deletedAt?: Date | null;
103
+ readonly revision: number;
104
+ };
105
+ type MediaAssetUsage = {
106
+ readonly id: string;
107
+ readonly tenantId: string;
108
+ readonly assetId: string;
109
+ readonly resourceType: string;
110
+ readonly resourceId: string;
111
+ readonly fieldKey: string;
112
+ readonly createdAt: Date;
113
+ readonly updatedAt: Date;
114
+ readonly createdBy?: string | null;
115
+ readonly revision: number;
116
+ };
117
+ type MediaFileMetadata = {
118
+ readonly kind: MediaKind;
119
+ readonly mimeType: string;
120
+ readonly size: number;
121
+ readonly checksum?: MediaChecksum;
122
+ readonly width?: number;
123
+ readonly height?: number;
124
+ readonly duration?: number;
125
+ readonly orientation?: number;
126
+ };
127
+ export { MediaAssetUsage as a, MediaFileMetadata as c, MediaHotspot as d, MediaKind as f, MediaVariantStatus as h, MediaAssetStatus as i, MediaFocalPoint as l, MediaVariant as m, MEDIA_KINDS as n, MediaChecksum as o, MediaObjectReference as p, MediaAsset as r, MediaCrop as s, MEDIA_ASSET_STATUSES as t, MediaFolder as u };
@@ -0,0 +1,238 @@
1
+ import { m as MediaVariant, o as MediaChecksum, p as MediaObjectReference, r as MediaAsset } from "./media.types-dzfu0Nep.js";
2
+ type MediaUploadMode = "single" | "multipart";
3
+ type MediaUploadState = "pending" | "completed" | "aborted" | "expired";
4
+ type MediaUploadConstraints = {
5
+ readonly tenantId: string;
6
+ readonly fileName: string;
7
+ readonly contentType: string;
8
+ readonly expectedSize?: number;
9
+ readonly expectedChecksum?: MediaChecksum;
10
+ readonly expiresInMs: number;
11
+ readonly objectPrefix?: string;
12
+ };
13
+ type MediaUploadTarget = {
14
+ readonly url: string;
15
+ readonly method: "PUT";
16
+ readonly headers: Readonly<Record<string, string>>;
17
+ readonly expiresAt: Date;
18
+ };
19
+ type MediaMultipartPartTarget = {
20
+ readonly partNumber: number;
21
+ readonly url: string;
22
+ readonly method: "PUT";
23
+ readonly headers: Readonly<Record<string, string>>;
24
+ readonly expiresAt: Date;
25
+ };
26
+ /**
27
+ * An ephemeral upload capability. Never persist or log its URL, headers, or
28
+ * provider upload ID. Object keys remain server-side.
29
+ */
30
+ type MediaUploadSession = {
31
+ readonly id: string;
32
+ readonly tenantId: string;
33
+ readonly mode: MediaUploadMode;
34
+ readonly state: MediaUploadState;
35
+ readonly expectedSize?: number;
36
+ readonly expectedChecksum?: MediaChecksum;
37
+ readonly expiresAt: Date;
38
+ readonly uploadTarget?: MediaUploadTarget;
39
+ readonly partSizeBytes?: number;
40
+ };
41
+ type MediaStoredObject = {
42
+ readonly object: MediaObjectReference;
43
+ readonly tenantId: string;
44
+ readonly mimeType: string;
45
+ readonly size: number;
46
+ readonly checksum?: MediaChecksum;
47
+ readonly createdAt: Date;
48
+ };
49
+ type MediaReadTarget = {
50
+ readonly url: string;
51
+ readonly expiresAt: Date;
52
+ };
53
+ type MediaObjectSummary = {
54
+ readonly object: MediaObjectReference;
55
+ readonly tenantId: string;
56
+ readonly size: number;
57
+ readonly mimeType: string;
58
+ readonly checksum?: MediaChecksum;
59
+ readonly createdAt: Date;
60
+ };
61
+ type MediaObjectPage = {
62
+ readonly items: readonly MediaObjectSummary[];
63
+ readonly nextCursor: string | null;
64
+ };
65
+ type MediaMultipartCompletedPart = {
66
+ readonly partNumber: number;
67
+ readonly etag: string;
68
+ };
69
+ type MediaObjectListInput = {
70
+ readonly cursor?: string;
71
+ readonly first: number;
72
+ readonly olderThan?: Date;
73
+ };
74
+ interface MediaObjectStorageAdapter {
75
+ /** Create a short-lived target bound to the tenant and declared constraints. */
76
+ createUploadIntent(input: MediaUploadConstraints): Promise<MediaUploadSession>;
77
+ /** Create a resumable multipart intent; the provider upload ID stays server-side. */
78
+ createMultipartUpload(input: MediaUploadConstraints & {
79
+ readonly partSizeBytes: number;
80
+ }): Promise<MediaUploadSession>;
81
+ /** Create short-lived targets for validated part numbers in an active session. */
82
+ createMultipartPartTargets(sessionId: string, partNumbers: readonly number[], expiresInMs: number): Promise<readonly MediaMultipartPartTarget[]>;
83
+ /**
84
+ * Verify the completed object's actual size/checksum and finalize idempotently.
85
+ * A repeated completion for the same completed session must return the object.
86
+ */
87
+ completeUpload(sessionId: string, parts?: readonly MediaMultipartCompletedPart[]): Promise<MediaStoredObject>;
88
+ /** Abort an incomplete intent. Repeated aborts should be harmless. */
89
+ abortUpload(sessionId: string): Promise<boolean>;
90
+ getUploadSession(sessionId: string): Promise<MediaUploadSession | null>;
91
+ /** Return metadata for an exact internal object reference, or null if absent. */
92
+ getObjectMetadata(object: MediaObjectReference): Promise<MediaStoredObject | null>;
93
+ /** Issue a short-lived read capability only for an existing object. */
94
+ createReadTarget(object: MediaObjectReference, expiresInMs: number): Promise<MediaReadTarget>;
95
+ /** Delete an exact object reference; deleting an absent object is harmless. */
96
+ deleteObject(object: MediaObjectReference): Promise<boolean>;
97
+ /** List objects using a stable exclusive cursor, optionally older than a cutoff. */
98
+ listObjects(input: MediaObjectListInput): Promise<MediaObjectPage>;
99
+ /** List incomplete sessions whose expiry is at or before `before`. */
100
+ listExpiredUploadSessions(before: Date, first: number): Promise<readonly MediaUploadSession[]>;
101
+ }
102
+ type MediaImageProfile = {
103
+ readonly name: string;
104
+ readonly maxWidth?: number;
105
+ readonly maxHeight?: number;
106
+ readonly format?: "image/jpeg" | "image/png" | "image/webp" | "image/avif";
107
+ readonly quality?: number;
108
+ readonly required?: boolean;
109
+ };
110
+ type MediaVideoRenditionProfile = {
111
+ readonly name: string;
112
+ readonly maxWidth?: number;
113
+ readonly maxHeight?: number;
114
+ readonly videoBitrate?: number;
115
+ readonly audioBitrate?: number;
116
+ readonly container?: string;
117
+ readonly mimeType?: string;
118
+ readonly required?: boolean;
119
+ };
120
+ type MediaProcessingProfile = MediaImageProfile | MediaVideoRenditionProfile;
121
+ type MediaProcessingFailure = {
122
+ readonly message: string;
123
+ readonly code?: string;
124
+ readonly retryable: boolean;
125
+ };
126
+ type MediaProcessingJobStatus = "queued" | "processing" | "retrying" | "succeeded" | "failed" | "dead-letter" | "cancelled";
127
+ type MediaProcessingJobKind = "image" | "video";
128
+ type MediaProcessingJob = {
129
+ readonly id: string;
130
+ readonly tenantId: string;
131
+ readonly assetId: string;
132
+ readonly kind: MediaProcessingJobKind;
133
+ readonly profiles: readonly MediaProcessingProfile[];
134
+ readonly idempotencyKey: string;
135
+ readonly status: MediaProcessingJobStatus;
136
+ readonly attempt: number;
137
+ readonly maxAttempts: number;
138
+ readonly progress: number;
139
+ readonly availableAt: Date;
140
+ readonly workerId?: string | null;
141
+ readonly leaseExpiresAt?: Date | null;
142
+ readonly result?: readonly MediaVariant[];
143
+ readonly failure?: MediaProcessingFailure | null;
144
+ readonly createdAt: Date;
145
+ readonly updatedAt: Date;
146
+ readonly completedAt?: Date | null;
147
+ readonly revision: number;
148
+ };
149
+ type MediaProcessingJobInput = {
150
+ readonly id: string;
151
+ readonly tenantId: string;
152
+ readonly assetId: string;
153
+ readonly kind: MediaProcessingJobKind;
154
+ readonly profiles: readonly MediaProcessingProfile[];
155
+ readonly idempotencyKey: string;
156
+ readonly maxAttempts: number;
157
+ readonly availableAt?: Date;
158
+ readonly createdAt: Date;
159
+ };
160
+ type MediaProcessingQueueClaim = {
161
+ readonly workerId: string;
162
+ readonly leaseDurationMs: number;
163
+ readonly now: Date;
164
+ };
165
+ interface MediaProcessingQueueAdapter {
166
+ /**
167
+ * Idempotency is scoped by tenant/key. Reuse with a different payload must
168
+ * fail instead of silently enqueueing another operation.
169
+ */
170
+ enqueue(input: MediaProcessingJobInput): Promise<MediaProcessingJob>;
171
+ get(id: string): Promise<MediaProcessingJob | null>;
172
+ /** Atomically lease one available job and increment its attempt count. */
173
+ claimNext(input: MediaProcessingQueueClaim): Promise<MediaProcessingJob | null>;
174
+ updateProgress(id: string, workerId: string, progress: number, now: Date): Promise<MediaProcessingJob>;
175
+ /** Only the current lease owner may extend a live lease. */
176
+ renewLease(id: string, workerId: string, leaseDurationMs: number, now: Date): Promise<MediaProcessingJob>;
177
+ /** Completion must be conditional on the current lease owner. */
178
+ complete(id: string, workerId: string, result: readonly MediaVariant[], now: Date): Promise<MediaProcessingJob>;
179
+ /** Failure must be conditional on the current lease owner. `retryAt` schedules a retry. */
180
+ fail(id: string, workerId: string, failure: MediaProcessingFailure, retryAt: Date | null, now: Date): Promise<MediaProcessingJob>;
181
+ cancel(id: string, now: Date): Promise<MediaProcessingJob | null>;
182
+ }
183
+ type MediaProcessingOutputVariant = {
184
+ readonly name: string;
185
+ readonly kind: MediaVariant["kind"];
186
+ readonly object: MediaObjectReference;
187
+ readonly mimeType: string;
188
+ readonly size: number;
189
+ readonly checksum?: MediaChecksum;
190
+ readonly width?: number;
191
+ readonly height?: number;
192
+ readonly duration?: number;
193
+ readonly bitrate?: number;
194
+ };
195
+ type MediaProcessingOutput = {
196
+ readonly variants: readonly MediaProcessingOutputVariant[];
197
+ readonly failures?: readonly {
198
+ readonly profile: string;
199
+ readonly message: string;
200
+ readonly retryable?: boolean;
201
+ }[];
202
+ };
203
+ type MediaProcessorProgress = (progress: number) => void | Promise<void>;
204
+ type MediaProcessorInput = {
205
+ readonly jobId: string;
206
+ readonly idempotencyKey: string;
207
+ readonly asset: MediaAsset;
208
+ readonly profiles: readonly MediaImageProfile[];
209
+ readonly signal?: AbortSignal;
210
+ readonly onProgress: MediaProcessorProgress;
211
+ };
212
+ interface MediaProcessor {
213
+ processImage(input: MediaProcessorInput): Promise<MediaProcessingOutput>;
214
+ }
215
+ type VideoTranscoderInput = {
216
+ readonly jobId: string;
217
+ readonly idempotencyKey: string;
218
+ readonly asset: MediaAsset;
219
+ readonly profiles: readonly MediaVideoRenditionProfile[];
220
+ readonly signal?: AbortSignal;
221
+ readonly onProgress: MediaProcessorProgress;
222
+ };
223
+ interface VideoTranscoder {
224
+ transcode(input: VideoTranscoderInput): Promise<MediaProcessingOutput>;
225
+ }
226
+ type MediaProcessingServiceOptions = {
227
+ readonly storage: import("@puzzle-ui/storage").StorageAdapter;
228
+ readonly objectStorage: MediaObjectStorageAdapter;
229
+ readonly queue: MediaProcessingQueueAdapter;
230
+ readonly processor?: MediaProcessor;
231
+ readonly transcoder?: VideoTranscoder;
232
+ readonly idFactory?: () => string;
233
+ readonly now?: () => Date;
234
+ readonly baseRetryDelayMs?: number;
235
+ readonly maxRetryDelayMs?: number;
236
+ readonly leaseDurationMs?: number;
237
+ };
238
+ export { MediaUploadState as A, MediaObjectStorageAdapter as C, MediaUploadConstraints as D, MediaStoredObject as E, MediaUploadMode as O, MediaObjectPage as S, MediaReadTarget as T, VideoTranscoder as _, MediaProcessingJobKind as a, MediaMultipartPartTarget as b, MediaProcessingOutputVariant as c, MediaProcessingQueueClaim as d, MediaProcessingServiceOptions as f, MediaVideoRenditionProfile as g, MediaProcessorProgress as h, MediaProcessingJobInput as i, MediaUploadTarget as j, MediaUploadSession as k, MediaProcessingProfile as l, MediaProcessorInput as m, MediaProcessingFailure as n, MediaProcessingJobStatus as o, MediaProcessor as p, MediaProcessingJob as r, MediaProcessingOutput as s, MediaImageProfile as t, MediaProcessingQueueAdapter as u, VideoTranscoderInput as v, MediaObjectSummary as w, MediaObjectListInput as x, MediaMultipartCompletedPart as y };