UNPKG

@paroicms/server-image-cache-engine

Version:

The image variant engine that we use at Paroi.

66 lines 2.13 kB
import { parseSqliteDateTime } from "@paroicms/internal-server-lib"; import { type } from "arktype"; const ImageVariantBaseAT = type({ id: "number", mediaType: "string", resourceVersion: "string", rawWidth: "number", rawHeight: "number", slug: "string|null", mediaId: "string", "+": "reject", }); function pipeImageVariantBaseAT(r) { return { imageCacheId: String(r.id), variant: { mediaId: r.mediaId, mediaType: r.mediaType, resourceVersion: r.resourceVersion, rawWidth: r.rawWidth, rawHeight: r.rawHeight, slug: r.slug ?? undefined, rawSizeName: `${r.rawWidth}x${r.rawHeight}`, }, }; } export const ImageVariantRowAT = ImageVariantBaseAT.pipe(pipeImageVariantBaseAT); const BatchStoredCacheItemBaseAT = type({ "...": ImageVariantBaseAT, ownerHandle: "string|null", "+": "reject", }); function pipeBatchStoredCacheItemBaseAT(r) { return { ...pipeImageVariantBaseAT(r), ownerHandle: r.ownerHandle ?? undefined, }; } export const BatchStoredCacheItemRowAT = BatchStoredCacheItemBaseAT.pipe(pipeBatchStoredCacheItemBaseAT); const ImageVariantWithBinaryBaseAT = type({ "...": ImageVariantBaseAT, modifiedAt: "string|number|Date", weightB: "number", "+": "reject", }); function pipeImageVariantWithBinaryBaseAT(r) { return { ...pipeImageVariantBaseAT(r), modifiedAt: parseSqliteDateTime(r.modifiedAt), weightB: r.weightB, }; } export const ImageVariantWithBinaryRowAT = ImageVariantWithBinaryBaseAT.pipe(pipeImageVariantWithBinaryBaseAT); const ImageVariantWithBinaryByOwnerBaseAT = type({ "...": ImageVariantWithBinaryBaseAT, mediaId: "string", "+": "reject", }); function pipeImageVariantWithBinaryByOwnerBaseAT(r) { return { ...pipeImageVariantWithBinaryBaseAT(r), mediaId: r.mediaId, }; } export const ImageVariantWithBinaryByOwnerRowAT = ImageVariantWithBinaryByOwnerBaseAT.pipe(pipeImageVariantWithBinaryByOwnerBaseAT); //# sourceMappingURL=queries-at.js.map