feat: add local auth billing and usage management
This commit is contained in:
1 parent
f642b5e71f
commit
196fdde83f
119 files changed
+15695
-2650
No files matched your search
@@ -146,29 +146,6 @@ export async function importRemoteAssetAsAsset(input: {
|
||||
});
|
||||
}
|
||||
|
||||
export async function saveMaskDataUrl(input: {
|
||||
ownerId: string;
|
||||
dataUrl: string;
|
||||
origin: string;
|
||||
jobHint?: string;
|
||||
}): Promise<Asset> {
|
||||
const parsed = parseDataUrl(input.dataUrl);
|
||||
return saveGeneratedAsset({
|
||||
ownerId: input.ownerId,
|
||||
bytes: parsed.bytes,
|
||||
fileName: `mask-${input.jobHint || createId("brush")}.png`,
|
||||
contentType: parsed.contentType,
|
||||
origin: input.origin,
|
||||
source: "edited",
|
||||
capability: "image.inpaint",
|
||||
kind: "mask",
|
||||
tags: ["mask"],
|
||||
metadata: {
|
||||
maskRule: "black keeps original pixels, white repaints selected pixels"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function readLocalServedFile(area: "uploads" | "generated-results", pathParts: string[]): Promise<{
|
||||
bytes: Buffer;
|
||||
contentType: string;
|
||||
@@ -415,15 +392,6 @@ function inferKind(contentType: string): AssetKind {
|
||||
return "other";
|
||||
}
|
||||
|
||||
function parseDataUrl(dataUrl: string): { contentType: string; bytes: Buffer } {
|
||||
const match = dataUrl.match(/^data:([^;,]+);base64,(.+)$/);
|
||||
if (!match) throw new Error("Invalid mask data URL.");
|
||||
return {
|
||||
contentType: match[1],
|
||||
bytes: Buffer.from(match[2], "base64")
|
||||
};
|
||||
}
|
||||
|
||||
function extensionForContentType(contentType: string): string {
|
||||
if (contentType.includes("jpeg") || contentType.includes("jpg")) return ".jpg";
|
||||
if (contentType.includes("webp")) return ".webp";
|
||||
|
||||
Reference in new issue
Block a user