nuxt-media-library 0.0.44

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 (164) hide show
  1. package/README.md +243 -0
  2. package/dist/module.d.mts +31 -0
  3. package/dist/module.d.ts +31 -0
  4. package/dist/module.json +9 -0
  5. package/dist/module.mjs +118 -0
  6. package/dist/runtime/components/MLAssetManager/AssetActivity.d.vue.ts +6 -0
  7. package/dist/runtime/components/MLAssetManager/AssetActivity.vue +13 -0
  8. package/dist/runtime/components/MLAssetManager/AssetActivity.vue.d.ts +6 -0
  9. package/dist/runtime/components/MLAssetManager/AssetCard.d.vue.ts +14 -0
  10. package/dist/runtime/components/MLAssetManager/AssetCard.vue +100 -0
  11. package/dist/runtime/components/MLAssetManager/AssetCard.vue.d.ts +14 -0
  12. package/dist/runtime/components/MLAssetManager/AssetDetail.d.vue.ts +14 -0
  13. package/dist/runtime/components/MLAssetManager/AssetDetail.vue +156 -0
  14. package/dist/runtime/components/MLAssetManager/AssetDetail.vue.d.ts +14 -0
  15. package/dist/runtime/components/MLAssetManager/AssetList.d.vue.ts +15 -0
  16. package/dist/runtime/components/MLAssetManager/AssetList.vue +41 -0
  17. package/dist/runtime/components/MLAssetManager/AssetList.vue.d.ts +15 -0
  18. package/dist/runtime/components/MLAssetManager/AssetOverview.d.vue.ts +8 -0
  19. package/dist/runtime/components/MLAssetManager/AssetOverview.vue +321 -0
  20. package/dist/runtime/components/MLAssetManager/AssetOverview.vue.d.ts +8 -0
  21. package/dist/runtime/components/MLAssetManager/AssetPreview.d.vue.ts +10 -0
  22. package/dist/runtime/components/MLAssetManager/AssetPreview.vue +18 -0
  23. package/dist/runtime/components/MLAssetManager/AssetPreview.vue.d.ts +10 -0
  24. package/dist/runtime/components/MLAssetManager/AssetPreviewAudio.d.vue.ts +9 -0
  25. package/dist/runtime/components/MLAssetManager/AssetPreviewAudio.vue +21 -0
  26. package/dist/runtime/components/MLAssetManager/AssetPreviewAudio.vue.d.ts +9 -0
  27. package/dist/runtime/components/MLAssetManager/AssetPreviewDocument.d.vue.ts +9 -0
  28. package/dist/runtime/components/MLAssetManager/AssetPreviewDocument.vue +39 -0
  29. package/dist/runtime/components/MLAssetManager/AssetPreviewDocument.vue.d.ts +9 -0
  30. package/dist/runtime/components/MLAssetManager/AssetPreviewFallback.d.vue.ts +7 -0
  31. package/dist/runtime/components/MLAssetManager/AssetPreviewFallback.vue +41 -0
  32. package/dist/runtime/components/MLAssetManager/AssetPreviewFallback.vue.d.ts +7 -0
  33. package/dist/runtime/components/MLAssetManager/AssetPreviewImage.d.vue.ts +9 -0
  34. package/dist/runtime/components/MLAssetManager/AssetPreviewImage.vue +30 -0
  35. package/dist/runtime/components/MLAssetManager/AssetPreviewImage.vue.d.ts +9 -0
  36. package/dist/runtime/components/MLAssetManager/AssetPreviewSidebar.d.vue.ts +15 -0
  37. package/dist/runtime/components/MLAssetManager/AssetPreviewSidebar.vue +69 -0
  38. package/dist/runtime/components/MLAssetManager/AssetPreviewSidebar.vue.d.ts +15 -0
  39. package/dist/runtime/components/MLAssetManager/AssetPreviewVideo.d.vue.ts +9 -0
  40. package/dist/runtime/components/MLAssetManager/AssetPreviewVideo.vue +148 -0
  41. package/dist/runtime/components/MLAssetManager/AssetPreviewVideo.vue.d.ts +9 -0
  42. package/dist/runtime/components/MLAssetManager/AssetRenditions.d.vue.ts +8 -0
  43. package/dist/runtime/components/MLAssetManager/AssetRenditions.vue +148 -0
  44. package/dist/runtime/components/MLAssetManager/AssetRenditions.vue.d.ts +8 -0
  45. package/dist/runtime/components/MLAssetManager/Processing.d.vue.ts +8 -0
  46. package/dist/runtime/components/MLAssetManager/Processing.vue +84 -0
  47. package/dist/runtime/components/MLAssetManager/Processing.vue.d.ts +8 -0
  48. package/dist/runtime/components/MLAssetManager/SlotCard.d.vue.ts +17 -0
  49. package/dist/runtime/components/MLAssetManager/SlotCard.vue +94 -0
  50. package/dist/runtime/components/MLAssetManager/SlotCard.vue.d.ts +17 -0
  51. package/dist/runtime/components/MLAssetManager/Widget.d.vue.ts +14 -0
  52. package/dist/runtime/components/MLAssetManager/Widget.vue +328 -0
  53. package/dist/runtime/components/MLAssetManager/Widget.vue.d.ts +14 -0
  54. package/dist/runtime/components/MLPreviewProvider.d.vue.ts +31 -0
  55. package/dist/runtime/components/MLPreviewProvider.vue +51 -0
  56. package/dist/runtime/components/MLPreviewProvider.vue.d.ts +31 -0
  57. package/dist/runtime/components/MLProcessing/Forms/ConfigureStepModal.d.vue.ts +13 -0
  58. package/dist/runtime/components/MLProcessing/Forms/ConfigureStepModal.vue +47 -0
  59. package/dist/runtime/components/MLProcessing/Forms/ConfigureStepModal.vue.d.ts +13 -0
  60. package/dist/runtime/components/MLProcessing/Forms/FramePicker.d.vue.ts +11 -0
  61. package/dist/runtime/components/MLProcessing/Forms/FramePicker.vue +162 -0
  62. package/dist/runtime/components/MLProcessing/Forms/FramePicker.vue.d.ts +11 -0
  63. package/dist/runtime/components/MLProcessing/Forms/StepOptionsForm.d.vue.ts +14 -0
  64. package/dist/runtime/components/MLProcessing/Forms/StepOptionsForm.vue +113 -0
  65. package/dist/runtime/components/MLProcessing/Forms/StepOptionsForm.vue.d.ts +14 -0
  66. package/dist/runtime/components/MLProcessing/Pipeline.d.vue.ts +15 -0
  67. package/dist/runtime/components/MLProcessing/Pipeline.vue +178 -0
  68. package/dist/runtime/components/MLProcessing/Pipeline.vue.d.ts +15 -0
  69. package/dist/runtime/components/MLProcessing/PipelineStepItem.d.vue.ts +20 -0
  70. package/dist/runtime/components/MLProcessing/PipelineStepItem.vue +309 -0
  71. package/dist/runtime/components/MLProcessing/PipelineStepItem.vue.d.ts +20 -0
  72. package/dist/runtime/components/MLProcessing/ProgressBar.d.vue.ts +9 -0
  73. package/dist/runtime/components/MLProcessing/ProgressBar.vue +27 -0
  74. package/dist/runtime/components/MLProcessing/ProgressBar.vue.d.ts +9 -0
  75. package/dist/runtime/components/MLProcessing/StepLayout.d.vue.ts +31 -0
  76. package/dist/runtime/components/MLProcessing/StepLayout.vue +36 -0
  77. package/dist/runtime/components/MLProcessing/StepLayout.vue.d.ts +31 -0
  78. package/dist/runtime/components/MLProcessing/Stepper.d.vue.ts +16 -0
  79. package/dist/runtime/components/MLProcessing/Stepper.vue +87 -0
  80. package/dist/runtime/components/MLProcessing/Stepper.vue.d.ts +16 -0
  81. package/dist/runtime/components/MLProcessing/StepperItem.d.vue.ts +16 -0
  82. package/dist/runtime/components/MLProcessing/StepperItem.vue +150 -0
  83. package/dist/runtime/components/MLProcessing/StepperItem.vue.d.ts +16 -0
  84. package/dist/runtime/components/MLProcessing/TopBar.d.vue.ts +21 -0
  85. package/dist/runtime/components/MLProcessing/TopBar.vue +46 -0
  86. package/dist/runtime/components/MLProcessing/TopBar.vue.d.ts +21 -0
  87. package/dist/runtime/components/MLUploader/ButtonUploader.d.vue.ts +55 -0
  88. package/dist/runtime/components/MLUploader/ButtonUploader.vue +211 -0
  89. package/dist/runtime/components/MLUploader/ButtonUploader.vue.d.ts +55 -0
  90. package/dist/runtime/components/MLUploader/Item.d.vue.ts +34 -0
  91. package/dist/runtime/components/MLUploader/Item.vue +242 -0
  92. package/dist/runtime/components/MLUploader/Item.vue.d.ts +34 -0
  93. package/dist/runtime/components/MLUploader/PolicyPopover.d.vue.ts +7 -0
  94. package/dist/runtime/components/MLUploader/PolicyPopover.vue +160 -0
  95. package/dist/runtime/components/MLUploader/PolicyPopover.vue.d.ts +7 -0
  96. package/dist/runtime/components/MLUploader/Widget.d.vue.ts +44 -0
  97. package/dist/runtime/components/MLUploader/Widget.vue +251 -0
  98. package/dist/runtime/components/MLUploader/Widget.vue.d.ts +44 -0
  99. package/dist/runtime/composables/resourcePolicy/mimeUtils.d.ts +4 -0
  100. package/dist/runtime/composables/resourcePolicy/mimeUtils.js +71 -0
  101. package/dist/runtime/composables/resourcePolicy/useMLResourcePolicy.d.ts +17 -0
  102. package/dist/runtime/composables/resourcePolicy/useMLResourcePolicy.js +150 -0
  103. package/dist/runtime/composables/useElapsedTimer.d.ts +13 -0
  104. package/dist/runtime/composables/useElapsedTimer.js +46 -0
  105. package/dist/runtime/composables/useMLAssetLibrary.d.ts +31 -0
  106. package/dist/runtime/composables/useMLAssetLibrary.js +53 -0
  107. package/dist/runtime/composables/useMLAssetManager.d.ts +30 -0
  108. package/dist/runtime/composables/useMLAssetManager.js +229 -0
  109. package/dist/runtime/composables/useMLAssetManagerPreview.d.ts +28 -0
  110. package/dist/runtime/composables/useMLAssetManagerPreview.js +232 -0
  111. package/dist/runtime/composables/useMLAssetPreview.d.ts +23 -0
  112. package/dist/runtime/composables/useMLAssetPreview.js +153 -0
  113. package/dist/runtime/composables/useMLChunkUploader.d.ts +9 -0
  114. package/dist/runtime/composables/useMLChunkUploader.js +22 -0
  115. package/dist/runtime/composables/useMLProcessingPipeline.d.ts +38 -0
  116. package/dist/runtime/composables/useMLProcessingPipeline.js +258 -0
  117. package/dist/runtime/composables/useMLProcessingStatus.d.ts +34 -0
  118. package/dist/runtime/composables/useMLProcessingStatus.js +100 -0
  119. package/dist/runtime/composables/useMLProcessingStepper.d.ts +32 -0
  120. package/dist/runtime/composables/useMLProcessingStepper.js +280 -0
  121. package/dist/runtime/composables/useMLProcessingStrategies.d.ts +7 -0
  122. package/dist/runtime/composables/useMLProcessingStrategies.js +47 -0
  123. package/dist/runtime/composables/useMLRepeater.d.ts +5 -0
  124. package/dist/runtime/composables/useMLRepeater.js +11 -0
  125. package/dist/runtime/css/index.css +1 -0
  126. package/dist/runtime/index.d.ts +13 -0
  127. package/dist/runtime/index.js +13 -0
  128. package/dist/runtime/plugins/asset-direcetive-client.d.ts +2 -0
  129. package/dist/runtime/plugins/asset-direcetive-client.js +64 -0
  130. package/dist/runtime/plugins/config.d.ts +13 -0
  131. package/dist/runtime/plugins/config.js +23 -0
  132. package/dist/runtime/schemas/resource-policy.schema.d.ts +607 -0
  133. package/dist/runtime/schemas/resource-policy.schema.js +117 -0
  134. package/dist/runtime/server/assets-proxy.d.ts +2 -0
  135. package/dist/runtime/server/assets-proxy.js +81 -0
  136. package/dist/runtime/server/create-ml-proxy.d.ts +47 -0
  137. package/dist/runtime/server/create-ml-proxy.js +232 -0
  138. package/dist/runtime/server/delivery-proxy.d.ts +2 -0
  139. package/dist/runtime/server/delivery-proxy.js +74 -0
  140. package/dist/runtime/server/index.d.ts +2 -0
  141. package/dist/runtime/server/index.js +1 -0
  142. package/dist/runtime/server/processing-proxy.d.ts +2 -0
  143. package/dist/runtime/server/processing-proxy.js +55 -0
  144. package/dist/runtime/server/resource-policy-proxy.d.ts +2 -0
  145. package/dist/runtime/server/resource-policy-proxy.js +80 -0
  146. package/dist/runtime/server/tsconfig.json +0 -0
  147. package/dist/runtime/server/uploads-proxy.d.ts +2 -0
  148. package/dist/runtime/server/uploads-proxy.js +99 -0
  149. package/dist/runtime/types/asset.d.ts +174 -0
  150. package/dist/runtime/types/asset.js +7 -0
  151. package/dist/runtime/types/preview.d.ts +20 -0
  152. package/dist/runtime/types/preview.js +0 -0
  153. package/dist/runtime/types/resourcePolicy.d.ts +77 -0
  154. package/dist/runtime/types/resourcePolicy.js +25 -0
  155. package/dist/runtime/types/uploader.d.ts +71 -0
  156. package/dist/runtime/types/uploader.js +0 -0
  157. package/dist/runtime/utils/uploader/checksum.d.ts +21 -0
  158. package/dist/runtime/utils/uploader/checksum.js +23 -0
  159. package/dist/runtime/utils/uploader/chunking.d.ts +8 -0
  160. package/dist/runtime/utils/uploader/chunking.js +21 -0
  161. package/dist/runtime/utils/uploader/uploader.d.ts +20 -0
  162. package/dist/runtime/utils/uploader/uploader.js +206 -0
  163. package/dist/types.d.mts +11 -0
  164. package/package.json +81 -0
@@ -0,0 +1,80 @@
1
+ import { createError, defineEventHandler, getRequestHeaders, getRequestURL, proxyRequest } from "h3";
2
+ import { useRuntimeConfig } from "#imports";
3
+ const normalizeHeaders = (headers) => {
4
+ if (!headers) return {};
5
+ return typeof headers === "function" ? headers() : headers;
6
+ };
7
+ export default defineEventHandler(async (event) => {
8
+ try {
9
+ const config = useRuntimeConfig();
10
+ const baseURL = config.mediaLibrary?.baseURL;
11
+ if (!baseURL) {
12
+ throw createError({ statusCode: 500, statusMessage: "mediaLibrary.baseURL is required for resource policy proxying." });
13
+ }
14
+ try {
15
+ const parsed = new URL(baseURL);
16
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
17
+ throw new Error("Invalid protocol");
18
+ }
19
+ } catch {
20
+ throw createError({ statusCode: 500, statusMessage: "mediaLibrary.baseURL must be an absolute http(s) URL." });
21
+ }
22
+ const reqUrl = getRequestURL(event);
23
+ const path = reqUrl.pathname;
24
+ const prefix = "/api/media-library/manage/resource-policies";
25
+ if (!path.startsWith(prefix)) {
26
+ throw createError({ statusCode: 404, statusMessage: "Not found" });
27
+ }
28
+ const rest = path.slice(prefix.length);
29
+ const method = event.node.req.method || "GET";
30
+ const trimmedRest = rest.replace(/\/+$/, "");
31
+ const isCollection = trimmedRest === "";
32
+ const isSchema = trimmedRest === "/schema";
33
+ const isPipelineSteps = trimmedRest === "/pipelines/available-steps";
34
+ const isItem = !isSchema && !isPipelineSteps && /^\/[^/]+$/.test(trimmedRest);
35
+ if (!isCollection && !isSchema && !isPipelineSteps && !isItem) {
36
+ throw createError({ statusCode: 404, statusMessage: "Not found" });
37
+ }
38
+ const isDev = import.meta.dev;
39
+ const writeMethods = ["POST", "PUT", "DELETE"];
40
+ if (isSchema && method !== "GET") {
41
+ throw createError({ statusCode: 405, statusMessage: "Method Not Allowed" });
42
+ }
43
+ if (isPipelineSteps && method !== "GET") {
44
+ throw createError({ statusCode: 405, statusMessage: "Method Not Allowed" });
45
+ }
46
+ if (isCollection && method !== "GET" && !(isDev && method === "POST")) {
47
+ throw createError({ statusCode: 405, statusMessage: "Method Not Allowed" });
48
+ }
49
+ if (isItem && method !== "GET" && !(isDev && writeMethods.includes(method))) {
50
+ throw createError({ statusCode: 405, statusMessage: "Method Not Allowed" });
51
+ }
52
+ const upstreamPath = `/manage/resource-policies${trimmedRest}`;
53
+ const normalizedBase = baseURL.endsWith("/") ? baseURL : `${baseURL}/`;
54
+ const upstreamUrl = new URL(`.${upstreamPath}`, normalizedBase);
55
+ const incoming = new URLSearchParams(reqUrl.search);
56
+ incoming.forEach((value, key) => {
57
+ upstreamUrl.searchParams.append(key, value);
58
+ });
59
+ const forwardedHeaders = { ...getRequestHeaders(event) };
60
+ const extraHeaders = normalizeHeaders(config.mediaLibrary?.headers);
61
+ const proxyHeaders = { ...forwardedHeaders, ...extraHeaders };
62
+ delete proxyHeaders.connection;
63
+ delete proxyHeaders["transfer-encoding"];
64
+ delete proxyHeaders["keep-alive"];
65
+ delete proxyHeaders.upgrade;
66
+ delete proxyHeaders.expect;
67
+ delete proxyHeaders.host;
68
+ const result = await proxyRequest(event, upstreamUrl.toString(), {
69
+ headers: proxyHeaders,
70
+ streamRequest: true
71
+ });
72
+ if (event.node.res.statusCode >= 400) {
73
+ console.error(`[media-library] resource-policy-proxy upstream responded ${event.node.res.statusCode} for ${method} ${upstreamUrl.toString()}`);
74
+ }
75
+ return result;
76
+ } catch (err) {
77
+ console.error("[media-library] resource-policy-proxy error:", err);
78
+ throw err;
79
+ }
80
+ });
File without changes
@@ -0,0 +1,2 @@
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
2
+ export default _default;
@@ -0,0 +1,99 @@
1
+ import { createError, defineEventHandler, getRequestHeaders, getRequestURL, proxyRequest } from "h3";
2
+ import { useRuntimeConfig } from "#imports";
3
+ const resolveRoute = (route, params) => {
4
+ return route.replace(/:(\w+)/g, (_, key) => {
5
+ const value = params[key];
6
+ return value === void 0 ? "" : String(value);
7
+ });
8
+ };
9
+ export default defineEventHandler(async (event) => {
10
+ try {
11
+ const config = useRuntimeConfig();
12
+ const baseURL = config.mediaLibrary?.baseURL;
13
+ const routes = config.mediaLibrary?.routes;
14
+ const headers = config.mediaLibrary?.headers;
15
+ if (!baseURL || !routes) {
16
+ throw createError({ statusCode: 500, statusMessage: "mediaLibrary.baseURL and routes are required for upload proxying." });
17
+ }
18
+ try {
19
+ const parsed = new URL(baseURL);
20
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
21
+ throw new Error("Invalid protocol");
22
+ }
23
+ } catch {
24
+ throw createError({ statusCode: 500, statusMessage: "mediaLibrary.baseURL must be an absolute http(s) URL." });
25
+ }
26
+ const resolvedBaseURL = baseURL;
27
+ const resolvedRoutes = routes;
28
+ const reqUrl = getRequestURL(event);
29
+ const path = reqUrl.pathname;
30
+ const prefix = "/api/media-library/manage/uploads";
31
+ if (!path.startsWith(prefix)) {
32
+ throw createError({ statusCode: 404, statusMessage: "Not found" });
33
+ }
34
+ const rest = path.slice(prefix.length);
35
+ let upstreamPath = "";
36
+ const method = event.node.req.method || "GET";
37
+ if (rest === "/sessions" || rest === "/sessions/") {
38
+ if (method !== "POST") {
39
+ throw createError({ statusCode: 405, statusMessage: "Method Not Allowed" });
40
+ }
41
+ upstreamPath = resolvedRoutes.createSession;
42
+ } else {
43
+ const sessionMatch = rest.match(/^\/sessions\/([^/]+)$/);
44
+ const partMatch = rest.match(/^\/sessions\/([^/]+)\/parts\/([^/]+)$/);
45
+ const finalizeMatch = rest.match(/^\/sessions\/([^/]+)\/finalize$/);
46
+ const abortMatch = rest.match(/^\/sessions\/([^/]+)\/abort$/);
47
+ if (partMatch) {
48
+ if (method !== "PUT") {
49
+ throw createError({ statusCode: 405, statusMessage: "Method Not Allowed" });
50
+ }
51
+ upstreamPath = resolveRoute(resolvedRoutes.uploadPart, { id: partMatch[1], part: partMatch[2] });
52
+ } else if (finalizeMatch) {
53
+ if (method !== "POST") {
54
+ throw createError({ statusCode: 405, statusMessage: "Method Not Allowed" });
55
+ }
56
+ upstreamPath = resolveRoute(resolvedRoutes.finalize, { id: finalizeMatch[1] });
57
+ } else if (abortMatch && resolvedRoutes.abort) {
58
+ if (method !== "DELETE") {
59
+ throw createError({ statusCode: 405, statusMessage: "Method Not Allowed" });
60
+ }
61
+ upstreamPath = resolveRoute(resolvedRoutes.abort, { id: abortMatch[1] });
62
+ } else if (sessionMatch) {
63
+ if (method !== "GET") {
64
+ throw createError({ statusCode: 405, statusMessage: "Method Not Allowed" });
65
+ }
66
+ upstreamPath = resolveRoute(resolvedRoutes.getSession, { id: sessionMatch[1] });
67
+ }
68
+ }
69
+ if (!upstreamPath) {
70
+ throw createError({ statusCode: 404, statusMessage: "Unknown upload route" });
71
+ }
72
+ const normalizedBase = resolvedBaseURL.endsWith("/") ? resolvedBaseURL : `${resolvedBaseURL}/`;
73
+ const upstreamUrl = new URL(`.${upstreamPath}`, normalizedBase);
74
+ const incoming = new URLSearchParams(reqUrl.search);
75
+ incoming.forEach((value, key) => {
76
+ upstreamUrl.searchParams.append(key, value);
77
+ });
78
+ const forwardedHeaders = { ...getRequestHeaders(event) };
79
+ const extraHeaders = typeof headers === "function" ? headers() : headers;
80
+ const proxyHeaders = { ...forwardedHeaders, ...extraHeaders || {} };
81
+ delete proxyHeaders.connection;
82
+ delete proxyHeaders["transfer-encoding"];
83
+ delete proxyHeaders["keep-alive"];
84
+ delete proxyHeaders.upgrade;
85
+ delete proxyHeaders.expect;
86
+ delete proxyHeaders.host;
87
+ const result = await proxyRequest(event, upstreamUrl.toString(), {
88
+ headers: proxyHeaders,
89
+ streamRequest: true
90
+ });
91
+ if (event.node.res.statusCode >= 400) {
92
+ console.error(`[media-library] uploads-proxy upstream responded ${event.node.res.statusCode} for ${method} ${upstreamUrl.toString()}`);
93
+ }
94
+ return result;
95
+ } catch (err) {
96
+ console.error("[media-library] uploads-proxy error:", err);
97
+ throw err;
98
+ }
99
+ });
@@ -0,0 +1,174 @@
1
+ export type PreviewUrlType = "presign" | "cdn" | "volume_token";
2
+ export interface PreviewUrlFields {
3
+ previewUrl: string | null;
4
+ previewUrlType: PreviewUrlType | null;
5
+ previewUrlExpiresIn: number | null;
6
+ }
7
+ export interface AssetDetail extends PreviewUrlFields {
8
+ id: string;
9
+ kind: string;
10
+ title: string | null;
11
+ original_filename: string;
12
+ originalFilename?: string;
13
+ mime_type: string;
14
+ mimeType?: string;
15
+ size_bytes: number;
16
+ sizeBytes?: number;
17
+ bytes?: number;
18
+ hash_sha256: string | null;
19
+ hashSha256?: string | null;
20
+ content_hash_sha256?: string | null;
21
+ status: string;
22
+ visibility: string;
23
+ created_at: string;
24
+ createdAt?: string;
25
+ blob_id: string | null;
26
+ blobId?: string | null;
27
+ resource_policy_id: string | null;
28
+ resourcePolicyId?: string | null;
29
+ renditions: Rendition[];
30
+ slug?: string | null;
31
+ created_by?: string | null;
32
+ updated_at?: string | null;
33
+ deleted_at?: string | null;
34
+ upload_session_id?: string | null;
35
+ primary_blob_id?: string | null;
36
+ }
37
+ export interface AssetSlot {
38
+ label: string;
39
+ /** Single-asset slot id; empty string means empty. Ignored when `assetIds` is defined. */
40
+ assetId?: string;
41
+ /**
42
+ * Multi-asset slot ids. When this property is defined (even as `[]`) the
43
+ * slot is treated as multi-mode and the slot widget will allow multiple
44
+ * uploads / display the assets as a horizontal strip.
45
+ */
46
+ assetIds?: string[];
47
+ resourceType: string;
48
+ collectionName?: string | null;
49
+ }
50
+ export declare function getSlotAssetIds(slot: AssetSlot): string[];
51
+ export declare function isMultiSlot(slot: AssetSlot): boolean;
52
+ /** Null on non-FAILED rows. */
53
+ export type ProcessingFailureKind = 'validation' | 'timeout' | 'crash' | 'worker_lost';
54
+ export interface ProcessingTask {
55
+ id: string;
56
+ asset_id: string;
57
+ task_type: string;
58
+ status: string;
59
+ attempts: number;
60
+ last_error: string | null;
61
+ metadata_payload: Record<string, any> | null;
62
+ queued_at: string | null;
63
+ started_at: string | null;
64
+ finished_at: string | null;
65
+ input_blob_id?: string | null;
66
+ inputBlobId?: string | null;
67
+ output_blob_id?: string | null;
68
+ outputBlobId?: string | null;
69
+ rendition_id?: string | null;
70
+ renditionId?: string | null;
71
+ options?: Record<string, any> | null;
72
+ heartbeat_at?: string | null;
73
+ heartbeatAt?: string | null;
74
+ max_retries?: number | null;
75
+ maxRetries?: number | null;
76
+ failure_kind?: ProcessingFailureKind | null;
77
+ failureKind?: ProcessingFailureKind | null;
78
+ }
79
+ export interface PipelineOptionSchema {
80
+ type: string;
81
+ default?: any;
82
+ description?: string;
83
+ min?: number;
84
+ max?: number;
85
+ items?: string | {
86
+ type: string;
87
+ };
88
+ allowed_values?: any[];
89
+ }
90
+ export interface PipelineProcessor {
91
+ options: Record<string, PipelineOptionSchema>;
92
+ }
93
+ export interface PipelineConfig {
94
+ pipeline: string[];
95
+ processors: Record<string, PipelineProcessor>;
96
+ }
97
+ export type AvailableSteps = Record<string, PipelineConfig>;
98
+ export interface ListProcessingTasksResponse {
99
+ items: ProcessingTask[];
100
+ total: number;
101
+ page: number;
102
+ pageSize?: number;
103
+ page_size?: number;
104
+ pipeline: string[];
105
+ pipelineStepsSchema?: Record<string, Record<string, PipelineOptionSchema>>;
106
+ pipeline_steps_schema?: Record<string, Record<string, PipelineOptionSchema>>;
107
+ }
108
+ export interface RenditionVariant extends PreviewUrlFields {
109
+ name: string;
110
+ entrypoint: string;
111
+ locale: string | null;
112
+ width: number | null;
113
+ height: number | null;
114
+ bitrateKbps: number | null;
115
+ blobIds: string[];
116
+ extras: Record<string, any> | null;
117
+ }
118
+ export interface Rendition extends PreviewUrlFields {
119
+ id: string;
120
+ renditionType: string;
121
+ entrypoint: string | null;
122
+ storagePrefix: string | null;
123
+ blobIds: string[];
124
+ variants: RenditionVariant[] | null;
125
+ status: string;
126
+ durationSeconds: number | null;
127
+ pages: number | null;
128
+ channels: number | null;
129
+ extras: Record<string, any> | null;
130
+ createdAt: string;
131
+ updatedAt: string;
132
+ }
133
+ export interface DeliveryRenditionVariant extends PreviewUrlFields {
134
+ name: string;
135
+ width: number | null;
136
+ height: number | null;
137
+ bitrateKbps: number | null;
138
+ }
139
+ export interface DeliveryRendition extends PreviewUrlFields {
140
+ id: string;
141
+ renditionType: string;
142
+ status: string;
143
+ entrypoint: string | null;
144
+ durationSeconds: number | null;
145
+ variants: DeliveryRenditionVariant[];
146
+ }
147
+ export interface DeliveryAsset {
148
+ id: string;
149
+ kind: string;
150
+ title: string | null;
151
+ status: string;
152
+ visibility: string;
153
+ mimeType: string | null;
154
+ downloadType: string | null;
155
+ downloadUrl: string | null;
156
+ downloadUrlExpiresIn: number | null;
157
+ renditions: DeliveryRendition[];
158
+ }
159
+ export interface DeliveryAssetListResponse {
160
+ items: DeliveryAsset[];
161
+ total: number;
162
+ page: number;
163
+ pageSize: number;
164
+ }
165
+ export interface DeliveryBatchResolveItem {
166
+ assetId: string;
167
+ status: 'ok' | 'not_found';
168
+ asset: DeliveryAsset | null;
169
+ error: string | null;
170
+ }
171
+ export interface DeliveryBatchResolveResponse {
172
+ items: DeliveryBatchResolveItem[];
173
+ total: number;
174
+ }
@@ -0,0 +1,7 @@
1
+ export function getSlotAssetIds(slot) {
2
+ if (slot.assetIds !== void 0) return slot.assetIds;
3
+ return slot.assetId ? [slot.assetId] : [];
4
+ }
5
+ export function isMultiSlot(slot) {
6
+ return slot.assetIds !== void 0;
7
+ }
@@ -0,0 +1,20 @@
1
+ import type { DeliveryAsset, DeliveryRendition } from './asset.js';
2
+ export interface AssetSource {
3
+ url: string;
4
+ renditionType: string | null;
5
+ /** Variant name (e.g. "1080p"); null for rendition-level sources. */
6
+ name: string | null;
7
+ width: number | null;
8
+ height: number | null;
9
+ bitrateKbps: number | null;
10
+ }
11
+ export type AssetPreview = {
12
+ id: string;
13
+ asset_type: string;
14
+ url: string | null;
15
+ metadata: DeliveryAsset | null;
16
+ expiresIn: number | null;
17
+ renditions: DeliveryRendition[];
18
+ sources: AssetSource[];
19
+ forbidden: boolean;
20
+ };
File without changes
@@ -0,0 +1,77 @@
1
+ export declare enum Visibility {
2
+ Private = "private",
3
+ RESTRICTED = "restricted",
4
+ Public = "public"
5
+ }
6
+ export declare enum AssetKind {
7
+ Image = "image",
8
+ ImageBatch = "image_batch",
9
+ Video = "video",
10
+ Audio = "audio",
11
+ Document = "document",
12
+ Archive = "archive",
13
+ Font = "font",
14
+ Model3D = "model_3d",
15
+ WebApp = "web_app",
16
+ Other = "other"
17
+ }
18
+ export declare enum ResourcePolicySchemaMode {
19
+ Create = "create",
20
+ Update = "update",
21
+ Response = "response"
22
+ }
23
+ export interface FileConstraintsSchema {
24
+ allowed_mime_types: string[];
25
+ max_size_bytes?: number | null;
26
+ min_size_bytes?: number | null;
27
+ allow_multiple?: boolean;
28
+ }
29
+ export interface PermissionRequirementsSchema {
30
+ required_permissions?: string[];
31
+ allow_anonymous?: boolean;
32
+ }
33
+ export interface ProcessingConfigSchema {
34
+ auto_process: boolean;
35
+ step_options?: Record<string, Record<string, any>> | null;
36
+ }
37
+ export interface StorageConfigSchema {
38
+ storage_class: string;
39
+ visibility: string;
40
+ }
41
+ export interface CreateResourcePolicyRequest {
42
+ resource_type: string;
43
+ collection_name?: string | null;
44
+ file_constraints: FileConstraintsSchema;
45
+ permission_requirements?: PermissionRequirementsSchema;
46
+ processing_config: ProcessingConfigSchema;
47
+ kind: AssetKind;
48
+ visibility: Visibility;
49
+ }
50
+ export interface UpdateResourcePolicyRequest {
51
+ file_constraints?: FileConstraintsSchema | null;
52
+ permission_requirements?: PermissionRequirementsSchema | null;
53
+ processing_config?: ProcessingConfigSchema | null;
54
+ kind?: AssetKind | null;
55
+ visibility?: Visibility | null;
56
+ is_active?: boolean | null;
57
+ }
58
+ export interface ResourcePolicyResponse {
59
+ id: string;
60
+ tenant_id: string;
61
+ resource_type: string;
62
+ collection_name: string | null;
63
+ file_constraints: FileConstraintsSchema;
64
+ permission_requirements: PermissionRequirementsSchema;
65
+ processing_config: ProcessingConfigSchema;
66
+ storage_config?: StorageConfigSchema;
67
+ kind: AssetKind;
68
+ visibility: Visibility;
69
+ is_active: boolean;
70
+ version: number;
71
+ created_at: string;
72
+ updated_at: string;
73
+ }
74
+ export interface ResourcePolicyListQuery {
75
+ resource_type?: string | null;
76
+ is_active?: boolean | null;
77
+ }
@@ -0,0 +1,25 @@
1
+ export var Visibility = /* @__PURE__ */ ((Visibility2) => {
2
+ Visibility2["Private"] = "private";
3
+ Visibility2["RESTRICTED"] = "restricted";
4
+ Visibility2["Public"] = "public";
5
+ return Visibility2;
6
+ })(Visibility || {});
7
+ export var AssetKind = /* @__PURE__ */ ((AssetKind2) => {
8
+ AssetKind2["Image"] = "image";
9
+ AssetKind2["ImageBatch"] = "image_batch";
10
+ AssetKind2["Video"] = "video";
11
+ AssetKind2["Audio"] = "audio";
12
+ AssetKind2["Document"] = "document";
13
+ AssetKind2["Archive"] = "archive";
14
+ AssetKind2["Font"] = "font";
15
+ AssetKind2["Model3D"] = "model_3d";
16
+ AssetKind2["WebApp"] = "web_app";
17
+ AssetKind2["Other"] = "other";
18
+ return AssetKind2;
19
+ })(AssetKind || {});
20
+ export var ResourcePolicySchemaMode = /* @__PURE__ */ ((ResourcePolicySchemaMode2) => {
21
+ ResourcePolicySchemaMode2["Create"] = "create";
22
+ ResourcePolicySchemaMode2["Update"] = "update";
23
+ ResourcePolicySchemaMode2["Response"] = "response";
24
+ return ResourcePolicySchemaMode2;
25
+ })(ResourcePolicySchemaMode || {});
@@ -0,0 +1,71 @@
1
+ export type ChecksumAlgorithm = 'SHA-256';
2
+ export type ResolveRoute = string | ((...args: any[]) => string);
3
+ export interface ChunkUploaderRoutes {
4
+ createSession: string;
5
+ getSession: ResolveRoute;
6
+ uploadPart: ResolveRoute;
7
+ finalize: ResolveRoute;
8
+ abort?: ResolveRoute;
9
+ }
10
+ export interface ChunkUploaderChecksumConfig {
11
+ algorithm: ChecksumAlgorithm;
12
+ perPart: boolean;
13
+ final: boolean;
14
+ }
15
+ export interface ChunkUploaderConfig {
16
+ baseURL: string;
17
+ routes: ChunkUploaderRoutes;
18
+ /**
19
+ * When true, the client will not use baseURL directly and should
20
+ * send requests to same-origin proxy routes.
21
+ */
22
+ proxyUploads?: boolean;
23
+ partSize: number;
24
+ concurrency: number;
25
+ checksum: ChunkUploaderChecksumConfig;
26
+ headers: Record<string, string> | (() => Record<string, string>);
27
+ }
28
+ export interface CreateUploadSessionRequest {
29
+ resource_type?: string;
30
+ collection_name?: string | null;
31
+ expected_size_bytes?: number;
32
+ original_filename?: string;
33
+ mime_type?: string;
34
+ parts_expected?: number;
35
+ expected_sha256_hex?: string;
36
+ }
37
+ export interface UploadSessionResponse {
38
+ id: string;
39
+ state?: string;
40
+ part_size_bytes?: number;
41
+ expected_size_bytes?: number | null;
42
+ parts_expected?: number | null;
43
+ parts_received?: number;
44
+ received_parts?: number[];
45
+ expires_at?: string;
46
+ checksum_verified?: boolean;
47
+ final_blob_id?: string | null;
48
+ }
49
+ export interface FinalizeUploadRequest {
50
+ expected_sha256_hex?: string;
51
+ }
52
+ export interface UploadProgress {
53
+ totalBytes: number;
54
+ uploadedBytes: number;
55
+ percent: number;
56
+ }
57
+ export interface UploadResult {
58
+ sessionId: string;
59
+ finalize?: any;
60
+ expectedSha256Hex?: string;
61
+ }
62
+ export interface UploadFileOptions {
63
+ create: CreateUploadSessionRequest;
64
+ sessionId?: string;
65
+ onProgress?: (p: UploadProgress) => void;
66
+ onPartUploaded?: (partNumber: number) => void;
67
+ onState?: (s: {
68
+ phase: string;
69
+ message?: string;
70
+ }) => void;
71
+ }
File without changes
@@ -0,0 +1,21 @@
1
+ import type { ChecksumAlgorithm } from '../../types/uploader.js';
2
+ export declare function toHex(buffer: ArrayBuffer): string;
3
+ export declare function sha256Hex(data: ArrayBuffer): Promise<string>;
4
+ export declare function digestHex(alg: ChecksumAlgorithm, data: ArrayBuffer): Promise<string>;
5
+ /**
6
+ * Compute final SHA-256 by reading the file in chunks (does NOT load full file into memory).
7
+ * Uses a streaming-ish approach by buffering chunks and hashing incrementally is not available
8
+ * natively in WebCrypto, so we do: concatenate blocks? (too big)
9
+ *
10
+ * Practical approach:
11
+ * - If you must do true streaming SHA-256 in browser, use a JS streaming SHA-256 implementation.
12
+ * - For now: compute final hash by reading all bytes -> not acceptable for huge files.
13
+ *
14
+ * So we implement a "progressive" approach using a small dependency-free streaming SHA-256?
15
+ * Not here.
16
+ *
17
+ * Instead we offer:
18
+ * - per-part integrity always
19
+ * - optional final hash ONLY if file is within a safe max size threshold.
20
+ */
21
+ export declare function finalSha256HexIfSmall(file: File, maxBytes?: number): Promise<string>;
@@ -0,0 +1,23 @@
1
+ export function toHex(buffer) {
2
+ const bytes = new Uint8Array(buffer);
3
+ let hex = "";
4
+ for (const b of bytes) {
5
+ hex += b.toString(16).padStart(2, "0");
6
+ }
7
+ return hex;
8
+ }
9
+ export async function sha256Hex(data) {
10
+ const digest = await crypto.subtle.digest("SHA-256", data);
11
+ return toHex(digest);
12
+ }
13
+ export async function digestHex(alg, data) {
14
+ if (alg !== "SHA-256") throw new Error(`Unsupported checksum algorithm: ${alg}`);
15
+ return sha256Hex(data);
16
+ }
17
+ export async function finalSha256HexIfSmall(file, maxBytes = 200 * 1024 * 1024) {
18
+ if (file.size > maxBytes) {
19
+ throw new Error(`File too large to compute final SHA-256 in this implementation (${file.size} bytes). Enable a streaming SHA-256 lib or compute on server only.`);
20
+ }
21
+ const buf = await file.arrayBuffer();
22
+ return sha256Hex(buf);
23
+ }
@@ -0,0 +1,8 @@
1
+ export interface PartInfo {
2
+ partNumber: number;
3
+ start: number;
4
+ endExclusive: number;
5
+ size: number;
6
+ }
7
+ export declare function buildParts(totalSize: number, partSize: number): PartInfo[];
8
+ export declare function clampPercent(x: number): number;
@@ -0,0 +1,21 @@
1
+ export function buildParts(totalSize, partSize) {
2
+ if (partSize <= 0) throw new Error("partSize must be > 0");
3
+ const parts = [];
4
+ let partNumber = 1;
5
+ for (let start = 0; start < totalSize; start += partSize) {
6
+ const endExclusive = Math.min(start + partSize, totalSize);
7
+ parts.push({
8
+ partNumber,
9
+ start,
10
+ endExclusive,
11
+ size: endExclusive - start
12
+ });
13
+ partNumber++;
14
+ }
15
+ return parts;
16
+ }
17
+ export function clampPercent(x) {
18
+ if (x < 0) return 0;
19
+ if (x > 100) return 100;
20
+ return x;
21
+ }
@@ -0,0 +1,20 @@
1
+ import type { ChunkUploaderConfig, FinalizeUploadRequest, UploadFileOptions, UploadResult, UploadSessionResponse } from '../../types/uploader.js';
2
+ export declare class ChunkUploader {
3
+ private readonly cfg;
4
+ private controller;
5
+ constructor(cfg: ChunkUploaderConfig);
6
+ abort(): void;
7
+ createSession(createPayload: any): Promise<UploadSessionResponse>;
8
+ getSession(sessionId: string): Promise<UploadSessionResponse>;
9
+ uploadPart(params: {
10
+ sessionId: string;
11
+ partNumber: number;
12
+ blob: Blob;
13
+ start: number;
14
+ endExclusive: number;
15
+ total: number;
16
+ }): Promise<any>;
17
+ finalize(sessionId: string, payload: FinalizeUploadRequest): Promise<any>;
18
+ abortSession(sessionId: string): Promise<void>;
19
+ uploadFile(file: File, options: UploadFileOptions): Promise<UploadResult>;
20
+ }