@ttt-productions/media-processing-core 0.0.3 → 0.0.4
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/dist/server/firebase-media-io.d.ts +7 -0
- package/dist/server/firebase-media-io.d.ts.map +1 -0
- package/dist/server/firebase-media-io.js +67 -0
- package/dist/server/firebase-media-io.js.map +1 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +2 -0
- package/dist/server/index.js.map +1 -0
- package/package.json +16 -3
- package/dist/firebase/firestore.d.ts +0 -53
- package/dist/firebase/firestore.d.ts.map +0 -1
- package/dist/firebase/firestore.js +0 -10
- package/dist/firebase/firestore.js.map +0 -1
- package/dist/firebase/storage.d.ts +0 -2
- package/dist/firebase/storage.d.ts.map +0 -1
- package/dist/firebase/storage.js +0 -7
- package/dist/firebase/storage.js.map +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MediaIO } from "../io/types.js";
|
|
2
|
+
export interface CreateFirebaseMediaIOArgs {
|
|
3
|
+
inputStoragePath: string;
|
|
4
|
+
outputStorageBasePath: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function createFirebaseMediaIO(args: CreateFirebaseMediaIOArgs): MediaIO;
|
|
7
|
+
//# sourceMappingURL=firebase-media-io.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firebase-media-io.d.ts","sourceRoot":"","sources":["../../src/server/firebase-media-io.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,WAAW,yBAAyB;IACxC,gBAAgB,EAAE,MAAM,CAAC;IACzB,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAmC9E"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Firebase Storage MediaIO adapter for the media-processing pipeline.
|
|
2
|
+
// Server-only — relies on firebase-admin. Imported via `/server` subpath.
|
|
3
|
+
//
|
|
4
|
+
// The adapter constructs download URLs that respect emulator mode:
|
|
5
|
+
// when `FIREBASE_STORAGE_EMULATOR_HOST` is set (the Firebase Admin SDK
|
|
6
|
+
// auto-sets it when the Storage emulator is running), URLs target the
|
|
7
|
+
// local emulator; otherwise they target the production Firebase Storage
|
|
8
|
+
// CDN. This is critical for E2E tests — without it, the browser fetches
|
|
9
|
+
// production URLs that 404 because the file lives in the local emulator.
|
|
10
|
+
import { getStorage } from "firebase-admin/storage";
|
|
11
|
+
import { randomUUID } from "node:crypto";
|
|
12
|
+
export function createFirebaseMediaIO(args) {
|
|
13
|
+
const bucket = getStorage().bucket();
|
|
14
|
+
return {
|
|
15
|
+
input: {
|
|
16
|
+
async readToFile(localPath) {
|
|
17
|
+
await bucket.file(args.inputStoragePath).download({ destination: localPath });
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
output: {
|
|
21
|
+
async writeFromFile(localPath, outputKey) {
|
|
22
|
+
const ext = localPath.split(".").pop() || "";
|
|
23
|
+
const destinationPath = `${args.outputStorageBasePath}/${outputKey}.${ext}`;
|
|
24
|
+
const downloadToken = randomUUID();
|
|
25
|
+
await bucket.upload(localPath, {
|
|
26
|
+
destination: destinationPath,
|
|
27
|
+
metadata: {
|
|
28
|
+
contentType: getMimeFromExt(ext),
|
|
29
|
+
cacheControl: "public, max-age=31536000",
|
|
30
|
+
metadata: { firebaseStorageDownloadTokens: downloadToken },
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
const encodedPath = encodeURIComponent(destinationPath);
|
|
34
|
+
const emulatorHost = process.env.FIREBASE_STORAGE_EMULATOR_HOST;
|
|
35
|
+
const baseUrl = emulatorHost
|
|
36
|
+
? `http://${emulatorHost}`
|
|
37
|
+
: "https://firebasestorage.googleapis.com";
|
|
38
|
+
const url = `${baseUrl}/v0/b/${bucket.name}/o/${encodedPath}?alt=media&token=${downloadToken}`;
|
|
39
|
+
return { url, path: destinationPath };
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function getMimeFromExt(ext) {
|
|
45
|
+
switch (ext.toLowerCase()) {
|
|
46
|
+
case "jpg":
|
|
47
|
+
case "jpeg":
|
|
48
|
+
return "image/jpeg";
|
|
49
|
+
case "png":
|
|
50
|
+
return "image/png";
|
|
51
|
+
case "webp":
|
|
52
|
+
return "image/webp";
|
|
53
|
+
case "mp4":
|
|
54
|
+
return "video/mp4";
|
|
55
|
+
case "webm":
|
|
56
|
+
return "video/webm";
|
|
57
|
+
case "m4a":
|
|
58
|
+
return "audio/mp4";
|
|
59
|
+
case "aac":
|
|
60
|
+
return "audio/aac";
|
|
61
|
+
case "mp3":
|
|
62
|
+
return "audio/mpeg";
|
|
63
|
+
default:
|
|
64
|
+
return "application/octet-stream";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=firebase-media-io.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firebase-media-io.js","sourceRoot":"","sources":["../../src/server/firebase-media-io.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,0EAA0E;AAC1E,EAAE;AACF,mEAAmE;AACnE,uEAAuE;AACvE,sEAAsE;AACtE,wEAAwE;AACxE,wEAAwE;AACxE,yEAAyE;AAEzE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAQzC,MAAM,UAAU,qBAAqB,CAAC,IAA+B;IACnE,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC,MAAM,EAAE,CAAC;IAErC,OAAO;QACL,KAAK,EAAE;YACL,KAAK,CAAC,UAAU,CAAC,SAAiB;gBAChC,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,E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M;YACT,OAAO,YAAY,CAAC;QACtB,KAAK,KAAK;YACR,OAAO,WAAW,CAAC;QACrB,KAAK,MAAM;YACT,OAAO,YAAY,CAAC;QACtB,KAAK,KAAK;YACR,OAAO,WAAW,CAAC;QACrB,KAAK,KAAK;YACR,OAAO,WAAW,CAAC;QACrB,KAAK,KAAK;YACR,OAAO,YAAY,CAAC;QACtB;YACE,OAAO,0BAA0B,CAAC;IACtC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttt-productions/media-processing-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/ttt-productions/ttt-packages.git",
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
".": {
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
20
|
"default": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./server": {
|
|
23
|
+
"types": "./dist/server/index.d.ts",
|
|
24
|
+
"default": "./dist/server/index.js"
|
|
21
25
|
}
|
|
22
26
|
},
|
|
23
27
|
"scripts": {
|
|
@@ -27,12 +31,21 @@
|
|
|
27
31
|
"prepublishOnly": "npm run clean && npm run build"
|
|
28
32
|
},
|
|
29
33
|
"dependencies": {
|
|
30
|
-
"@ttt-productions/firebase-helpers": "
|
|
31
|
-
"@ttt-productions/media-contracts": "
|
|
34
|
+
"@ttt-productions/firebase-helpers": "*",
|
|
35
|
+
"@ttt-productions/media-contracts": "*",
|
|
32
36
|
"sharp": "^0.34.1"
|
|
33
37
|
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"firebase-admin": ">=10.0.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependenciesMeta": {
|
|
42
|
+
"firebase-admin": {
|
|
43
|
+
"optional": true
|
|
44
|
+
}
|
|
45
|
+
},
|
|
34
46
|
"devDependencies": {
|
|
35
47
|
"@types/node": "^22.10.0",
|
|
48
|
+
"firebase-admin": "^12.0.0",
|
|
36
49
|
"typescript": "^5.8.3"
|
|
37
50
|
},
|
|
38
51
|
"author": "DJ (TTT Productions)",
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { MediaProcessingResult } from "@ttt-productions/media-contracts";
|
|
2
|
-
export declare function mapResultForFirestore(result: MediaProcessingResult): {
|
|
3
|
-
status: string;
|
|
4
|
-
result: {
|
|
5
|
-
ok: boolean;
|
|
6
|
-
mediaType: "image" | "video" | "audio" | "other";
|
|
7
|
-
error?: {
|
|
8
|
-
code: "rejected" | "invalid_mime" | "too_large" | "too_long" | "upload_failed" | "upload_canceled" | "upload_timeout" | "network_error" | "quota_exceeded" | "invalid_spec" | "unsupported_format" | "processing_failed" | "processing_canceled" | "not_found" | "permission_denied" | "orientation_mismatch" | "aspect_ratio_mismatch" | "dimensions_mismatch" | "unknown";
|
|
9
|
-
message: string;
|
|
10
|
-
details?: Record<string, unknown> | undefined;
|
|
11
|
-
} | undefined;
|
|
12
|
-
meta?: {
|
|
13
|
-
width?: number | undefined;
|
|
14
|
-
height?: number | undefined;
|
|
15
|
-
mime?: string | undefined;
|
|
16
|
-
sizeBytes?: number | undefined;
|
|
17
|
-
durationSec?: number | undefined;
|
|
18
|
-
} | undefined;
|
|
19
|
-
moderation?: {
|
|
20
|
-
status: "rejected" | "passed" | "flagged" | "error";
|
|
21
|
-
reasons?: string[] | undefined;
|
|
22
|
-
provider?: string | undefined;
|
|
23
|
-
findings?: {
|
|
24
|
-
category?: string | undefined;
|
|
25
|
-
label?: string | undefined;
|
|
26
|
-
score?: number | undefined;
|
|
27
|
-
severity?: string | undefined;
|
|
28
|
-
reasons?: string[] | undefined;
|
|
29
|
-
meta?: Record<string, unknown> | undefined;
|
|
30
|
-
}[] | undefined;
|
|
31
|
-
reviewedAt?: string | number | undefined;
|
|
32
|
-
} | undefined;
|
|
33
|
-
outputs?: {
|
|
34
|
-
key: string;
|
|
35
|
-
url: string;
|
|
36
|
-
path?: string | undefined;
|
|
37
|
-
width?: number | undefined;
|
|
38
|
-
height?: number | undefined;
|
|
39
|
-
mime?: string | undefined;
|
|
40
|
-
sizeBytes?: number | undefined;
|
|
41
|
-
durationSec?: number | undefined;
|
|
42
|
-
extra?: Record<string, unknown> | undefined;
|
|
43
|
-
}[] | undefined;
|
|
44
|
-
warnings?: string[] | undefined;
|
|
45
|
-
} | null;
|
|
46
|
-
error: {
|
|
47
|
-
code: "rejected" | "invalid_mime" | "too_large" | "too_long" | "upload_failed" | "upload_canceled" | "upload_timeout" | "network_error" | "quota_exceeded" | "invalid_spec" | "unsupported_format" | "processing_failed" | "processing_canceled" | "not_found" | "permission_denied" | "orientation_mismatch" | "aspect_ratio_mismatch" | "dimensions_mismatch" | "unknown";
|
|
48
|
-
message: string;
|
|
49
|
-
details?: Record<string, unknown> | undefined;
|
|
50
|
-
} | null;
|
|
51
|
-
updatedAt: number;
|
|
52
|
-
};
|
|
53
|
-
//# sourceMappingURL=firestore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"firestore.d.ts","sourceRoot":"","sources":["../../src/firebase/firestore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAE9E,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,qBAAqB;;;;;;;;mBAQok7B,CAAC;;;iBAAoF,CAAC;kBAAoC,CAAC;gBAAkC,CAAC;qBAAuC,CAAC;uBAAyC,CAAC;;;;mBAAwI,CAAC;oBAAwC,CAAC;oBAAsC,CAAC;wBAAwB,CAAC;qBAAuC,CAAC;qBAAuC,CAAC;wBAA0C,CAAC;uBAAyC,CAAC;oBAAwC,CAAC;;sBAAkF,CAAC;;;;;gBAAwH,CAAC;iBAAmC,CAAC;kBAAoC,CAAC;gBAAkC,CAAC;qBAAuC,CAAC;uBAAyC,CAAC;iBAAmC,CAAC;;;;;;;;;;EAAhs9B"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { now } from "@ttt-productions/firebase-helpers";
|
|
2
|
-
export function mapResultForFirestore(result) {
|
|
3
|
-
return {
|
|
4
|
-
status: result.ok ? "ready" : "failed",
|
|
5
|
-
result: result.ok ? result : null,
|
|
6
|
-
error: result.ok ? null : result.error ?? null,
|
|
7
|
-
updatedAt: now()
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=firestore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"firestore.js","sourceRoot":"","sources":["../../src/firebase/firestore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mCAAmC,CAAC;AAGxD,MAAM,UAAU,qBAAqB,CACnC,MAA6B;IAE7B,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;QACtC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI;QACjC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,IAAI;QAC9C,SAAS,EAAE,GAAG,EAAE;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/firebase/storage.ts"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,CAC5B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,MAAM,CAEV"}
|
package/dist/firebase/storage.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// functions-only helpers for firebase-admin storage
|
|
2
|
-
// kept minimal so handlers stay thin
|
|
3
|
-
import { joinPath } from "@ttt-productions/firebase-helpers";
|
|
4
|
-
export function buildStoragePath(basePath, filename) {
|
|
5
|
-
return joinPath(basePath, filename);
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=storage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/firebase/storage.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,qCAAqC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D,MAAM,UAAU,gBAAgB,CAC5B,QAAgB,EAChB,QAAgB;IAEhB,OAAO,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACxC,CAAC"}
|