@happyvertical/smrt-images 0.56.0 → 0.56.2
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/images.d.ts.map +1 -1
- package/dist/index.js +6 -14
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +46 -6
- package/dist/smrt-knowledge.json +53 -274
- package/package.json +14 -14
package/dist/images.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../src/images.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../src/images.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAK1D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAS,CAAC;AAGhC,qBAAa,eAAgB,SAAQ,cAAc,CAAC,KAAK,CAAC;IACxD,MAAM,CAAC,QAAQ,CAAC,UAAU,eAAS;IAMnC;;;;;OAKG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAItD;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAMpC;;;;;OAKG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAMzD;;;;;;OAMG;IACG,kBAAkB,CACtB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,KAAK,EAAE,CAAC;IASnB;;;;;;OAMG;IACG,kBAAkB,CACtB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,KAAK,EAAE,CAAC;IASnB;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAQtC;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAOrC;;;;OAIG;IACG,SAAS,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAQnC;;;;OAIG;IACG,iBAAiB,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAM3C;;;;OAIG;IACG,iBAAiB,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAQ3C;;;;;;OAMG;IACG,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;CAc7E"}
|
package/dist/index.js
CHANGED
|
@@ -6,11 +6,11 @@ import { readFile, unlink, writeFile } from "node:fs/promises";
|
|
|
6
6
|
import { tmpdir } from "node:os";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { Asset, persistMediaBundleInspection as persistImageMediaBundleInspection } from "@happyvertical/smrt-assets";
|
|
9
|
-
import {
|
|
9
|
+
import { TenantScoped, getCurrentTenant, withTenantGlobalRead } from "@happyvertical/smrt-tenancy";
|
|
10
10
|
import { validatePhotoCutoutRig } from "@happyvertical/animation";
|
|
11
11
|
import sharp from "sharp";
|
|
12
12
|
//#region src/__smrt-register__.ts
|
|
13
|
-
ObjectRegistry.registerPackageManifest(JSON.parse(`{"version":"1.0.0","timestamp":0,"packageName":"@happyvertical/smrt-images","packageVersion":"0.56.0","objects":{"@happyvertical/smrt-images:Image":{"name":"image","className":"Image","qualifiedName":"@happyvertical/smrt-images:Image","collection":"assets","filePath":"/home/runner/work/smrt/smrt/packages/images/src/image.ts","packageName":"@happyvertical/smrt-images","fields":{"created_at":{"type":"datetime","required":false},"updated_at":{"type":"datetime","required":false},"tenantId":{"type":"text","required":false,"_meta":{"generated":true,"source":"tenantScoped_decorator","sqlType":"UUID","__tenancy":{"isTenantIdField":true,"mode":"optional","field":"tenantId","autoFilter":true,"autoPopulate":true,"allowSuperAdminBypass":false}}},"name":{"type":"text","required":false,"description":"A recognizable name for this file or media item.","_meta":{"description":"A recognizable name for this file or media item."}},"sourceUri":{"type":"text","required":false,"description":"Where the original file is stored or can be retrieved.","_meta":{"description":"Where the original file is stored or can be retrieved."}},"mimeType":{"type":"text","required":false,"description":"The file format, such as image/jpeg or application/pdf.","_meta":{"description":"The file format, such as image/jpeg or application/pdf."}},"description":{"type":"text","required":false,"description":"Explain what the file contains and when it should be used.","_meta":{"description":"Explain what the file contains and when it should be used."}},"metadata":{"type":"text","required":false,"description":"Additional details recorded while processing this file.","_meta":{"description":"Additional details recorded while processing this file."}},"version":{"type":"integer","required":true,"default":1,"description":"The revision number of this file in its version history.","_meta":{"description":"The revision number of this file in its version history."}},"primaryVersionId":{"type":"foreignKey","required":false,"related":"Asset","description":"The first version of this file, linking its revision history.","_meta":{"description":"The first version of this file, linking its revision history."}},"typeSlug":{"type":"text","required":false,"description":"The category of asset, such as an image, video, or document.","_meta":{"description":"The category of asset, such as an image, video, or document."}},"statusSlug":{"type":"text","required":false,"description":"The stage of this asset, such as draft, published, or archived.","_meta":{"description":"The stage of this asset, such as draft, published, or archived."}},"ownerProfileId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-profiles:Profile","description":"The person or organization responsible for this asset.","_meta":{"description":"The person or organization responsible for this asset."}},"sourceAssetId":{"type":"foreignKey","required":false,"related":"Asset","description":"The original asset used to produce this file or variation.","_meta":{"description":"The original asset used to produce this file or variation."}},"folderId":{"type":"foreignKey","required":false,"related":"Folder","description":"The folder that organizes this file in the asset library.","_meta":{"description":"The folder that organizes this file in the asset library."}},"sourceType":{"type":"text","required":false,"description":"The service or source from which this file was obtained.","_meta":{"description":"The service or source from which this file was obtained."}},"externalId":{"type":"text","required":false,"description":"The reference used to identify this file at its original source.","_meta":{"description":"The reference used to identify this file at its original source."}},"externalRefs":{"type":"text","required":false,"description":"References that connect this file to copies held by other services.","_meta":{"description":"References that connect this file to copies held by other services."}},"createdAt":{"type":"text","required":false},"updatedAt":{"type":"text","required":false},"width":{"type":"integer","required":false,"default":0},"height":{"type":"integer","required":false,"default":0},"alt":{"type":"text","required":false,"default":""}},"methods":{"getSlug":{"name":"getSlug","async":true,"parameters":[],"returnType":"Promise<string | null | undefined>","isStatic":false,"isPublic":true},"getMetadata":{"name":"getMetadata","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setMetadata":{"name":"setMetadata","async":false,"parameters":[{"name":"metadata","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"mergeMetadata":{"name":"mergeMetadata","async":false,"parameters":[{"name":"metadata","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"getExternalRefs":{"name":"getExternalRefs","async":false,"parameters":[],"returnType":"Record<string, AssetExternalReference>","isStatic":false,"isPublic":true},"getExternalRef":{"name":"getExternalRef","async":false,"parameters":[{"name":"provider","type":"string","optional":false}],"returnType":"AssetExternalReference | null","isStatic":false,"isPublic":true},"setExternalRef":{"name":"setExternalRef","async":false,"parameters":[{"name":"provider","type":"string","optional":false},{"name":"reference","type":"any","optional":false,"typeUnresolved":true}],"returnType":"void","isStatic":false,"isPublic":true},"getTags":{"name":"getTags","async":true,"parameters":[],"returnType":"Promise<Tag[]>","isStatic":false,"isPublic":true},"hasTag":{"name":"hasTag","async":true,"parameters":[{"name":"tagSlug","type":"string","optional":false},{"name":"context","type":"string","optional":true}],"returnType":"Promise<boolean>","isStatic":false,"isPublic":true},"getSource":{"name":"getSource","async":true,"parameters":[],"returnType":"Promise<Asset | null>","isStatic":false,"isPublic":true},"getDerivatives":{"name":"getDerivatives","async":true,"parameters":[],"returnType":"Promise<Asset[]>","isStatic":false,"isPublic":true},"getType":{"name":"getType","async":true,"parameters":[],"returnType":"Promise<AssetType | null>","isStatic":false,"isPublic":true},"getStatus":{"name":"getStatus","async":true,"parameters":[],"returnType":"Promise<AssetStatus | null>","isStatic":false,"isPublic":true},"getAssociations":{"name":"getAssociations","async":true,"parameters":[],"returnType":"Promise<AssetAssociation[]>","isStatic":false,"isPublic":true},"associateWith":{"name":"associateWith","async":true,"parameters":[{"name":"metaType","type":"string","optional":false},{"name":"metaId","type":"string","optional":false},{"name":"role","type":"any","optional":true,"default":"default"}],"returnType":"Promise<AssetAssociation>","isStatic":false,"isPublic":true},"getBySlug":{"name":"getBySlug","async":true,"parameters":[{"name":"_slug","type":"string","optional":false}],"returnType":"Promise<Asset | null>","isStatic":true,"isPublic":true},"isValidImageFormat":{"name":"isValidImageFormat","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isHighResolution":{"name":"isHighResolution","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"generateAltText":{"name":"generateAltText","async":true,"parameters":[],"returnType":"Promise<string>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update","delete"]},"mcp":{"include":["list","get","create","update","generateAltText"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"tableName":"assets","tableStrategy":"sti"},"extends":"Asset","exportName":"Image","collectionExportName":"ImageCollection","displayLabelField":"name","validationRules":[{"field":"version","rule":"required","fieldType":"integer"}],"schema":{"tableName":"assets","ddl":"CREATE TABLE IF NOT EXISTS \\"assets\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"name\\" TEXT,\\n \\"source_uri\\" TEXT,\\n \\"mime_type\\" TEXT,\\n \\"description\\" TEXT,\\n \\"metadata\\" TEXT,\\n \\"version\\" INTEGER DEFAULT 1,\\n \\"primary_version_id\\" UUID,\\n \\"type_slug\\" TEXT,\\n \\"status_slug\\" TEXT,\\n \\"owner_profile_id\\" UUID,\\n \\"source_asset_id\\" UUID,\\n \\"folder_id\\" UUID,\\n \\"source_type\\" TEXT,\\n \\"external_id\\" TEXT,\\n \\"external_refs\\" TEXT,\\n \\"width\\" INTEGER DEFAULT 0,\\n \\"height\\" INTEGER DEFAULT 0,\\n \\"alt\\" TEXT DEFAULT ''\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false},"name":{"type":"TEXT","notNull":false},"source_uri":{"type":"TEXT","notNull":false},"mime_type":{"type":"TEXT","notNull":false},"description":{"type":"TEXT","notNull":false},"metadata":{"type":"TEXT","notNull":false},"version":{"type":"INTEGER","notNull":false,"default":1},"primary_version_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"assets","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"type_slug":{"type":"TEXT","notNull":false},"status_slug":{"type":"TEXT","notNull":false},"owner_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"source_asset_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"assets","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"folder_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false},"source_type":{"type":"TEXT","notNull":false},"external_id":{"type":"TEXT","notNull":false},"external_refs":{"type":"TEXT","notNull":false},"width":{"type":"INTEGER","notNull":false,"default":0},"height":{"type":"INTEGER","notNull":false,"default":0},"alt":{"type":"TEXT","notNull":false,"default":""}},"indexes":[{"name":"assets_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"assets_meta_type_idx","columns":["_meta_type"]},{"name":"assets_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"assets_primary_version_id_idx","columns":["primary_version_id"]},{"name":"assets_owner_profile_id_idx","columns":["owner_profile_id"]},{"name":"assets_source_asset_id_idx","columns":["source_asset_id"]},{"name":"assets_folder_id_idx","columns":["folder_id"]}],"version":"dd79a8b6"},"importPath":"@happyvertical/smrt-images"},"@happyvertical/smrt-images:ImageCollection":{"name":"imagecollection","className":"ImageCollection","qualifiedName":"@happyvertical/smrt-images:ImageCollection","collection":"assets","filePath":"/home/runner/work/smrt/smrt/packages/images/src/images.ts","packageName":"@happyvertical/smrt-images","fields":{},"methods":{"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"getByMinDimensions":{"name":"getByMinDimensions","async":true,"parameters":[{"name":"minWidth","type":"number","optional":false},{"name":"minHeight","type":"number","optional":false}],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"getByMaxDimensions":{"name":"getByMaxDimensions","async":true,"parameters":[{"name":"maxWidth","type":"number","optional":false},{"name":"maxHeight","type":"number","optional":false}],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"getLandscape":{"name":"getLandscape","async":true,"parameters":[],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"getPortrait":{"name":"getPortrait","async":true,"parameters":[],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"getSquare":{"name":"getSquare","async":true,"parameters":[],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"getMissingAltText":{"name":"getMissingAltText","async":true,"parameters":[],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"getHighResolution":{"name":"getHighResolution","async":true,"parameters":[],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"getByAspectRatio":{"name":"getByAspectRatio","async":true,"parameters":[{"name":"minRatio","type":"number","optional":false},{"name":"maxRatio","type":"number","optional":false}],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"assets"},"extends":"SmrtCollection","extendsTypeArg":"Image","exportName":"ImageCollection","collectionExportName":"ImageCollectionCollection","schema":{"tableName":"assets","ddl":"CREATE TABLE IF NOT EXISTS \\"assets\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"name\\" TEXT,\\n \\"source_uri\\" TEXT,\\n \\"mime_type\\" TEXT,\\n \\"description\\" TEXT,\\n \\"metadata\\" TEXT,\\n \\"version\\" INTEGER DEFAULT 1,\\n \\"primary_version_id\\" UUID,\\n \\"type_slug\\" TEXT,\\n \\"status_slug\\" TEXT,\\n \\"owner_profile_id\\" UUID,\\n \\"source_asset_id\\" UUID,\\n \\"folder_id\\" UUID,\\n \\"source_type\\" TEXT,\\n \\"external_id\\" TEXT,\\n \\"external_refs\\" TEXT,\\n \\"width\\" INTEGER DEFAULT 0,\\n \\"height\\" INTEGER DEFAULT 0,\\n \\"alt\\" TEXT DEFAULT ''\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false},"name":{"type":"TEXT","notNull":false},"source_uri":{"type":"TEXT","notNull":false},"mime_type":{"type":"TEXT","notNull":false},"description":{"type":"TEXT","notNull":false},"metadata":{"type":"TEXT","notNull":false},"version":{"type":"INTEGER","notNull":false,"default":1},"primary_version_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"assets","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"type_slug":{"type":"TEXT","notNull":false},"status_slug":{"type":"TEXT","notNull":false},"owner_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"source_asset_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"assets","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"folder_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false},"source_type":{"type":"TEXT","notNull":false},"external_id":{"type":"TEXT","notNull":false},"external_refs":{"type":"TEXT","notNull":false},"width":{"type":"INTEGER","notNull":false,"default":0},"height":{"type":"INTEGER","notNull":false,"default":0},"alt":{"type":"TEXT","notNull":false,"default":""}},"indexes":[{"name":"assets_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"assets_meta_type_idx","columns":["_meta_type"]},{"name":"assets_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"assets_primary_version_id_idx","columns":["primary_version_id"]},{"name":"assets_owner_profile_id_idx","columns":["owner_profile_id"]},{"name":"assets_source_asset_id_idx","columns":["source_asset_id"]},{"name":"assets_folder_id_idx","columns":["folder_id"]}],"version":"dd79a8b6"},"importPath":"@happyvertical/smrt-images"}},"moduleType":"smrt","smrtDependencies":["@happyvertical/smrt-assets","@happyvertical/smrt-core","@happyvertical/smrt-profiles","@happyvertical/smrt-prompts","@happyvertical/smrt-tenancy"],"browser":{"status":"server-only","issues":["#3624","#3628"],"reason":"sharp, node:fs/promises, node:crypto, resvg native addon","via":["@happyvertical/smrt-tenancy"]},"stampsConstructors":true}`));
|
|
13
|
+
ObjectRegistry.registerPackageManifest(JSON.parse(`{"version":"1.0.0","timestamp":0,"packageName":"@happyvertical/smrt-images","packageVersion":"0.56.2","objects":{"@happyvertical/smrt-images:Image":{"name":"image","className":"Image","qualifiedName":"@happyvertical/smrt-images:Image","collection":"assets","filePath":"/home/runner/work/smrt/smrt/packages/images/src/image.ts","packageName":"@happyvertical/smrt-images","fields":{"created_at":{"type":"datetime","required":false},"updated_at":{"type":"datetime","required":false},"tenantId":{"type":"text","required":false,"_meta":{"generated":true,"source":"tenantScoped_decorator","sqlType":"UUID","__tenancy":{"isTenantIdField":true,"mode":"optional","field":"tenantId","autoFilter":true,"autoPopulate":true,"allowSuperAdminBypass":false}}},"accessMode":{"type":"text","required":false,"default":"public","description":"Whether this record is public to ordinary asset APIs or private.","_meta":{"description":"Whether this record is public to ordinary asset APIs or private."},"enum":["public","private"]},"name":{"type":"text","required":false,"description":"A recognizable name for this file or media item.","_meta":{"description":"A recognizable name for this file or media item."}},"sourceUri":{"type":"text","required":false,"description":"Where the original file is stored or can be retrieved.","_meta":{"description":"Where the original file is stored or can be retrieved."}},"mimeType":{"type":"text","required":false,"description":"The file format, such as image/jpeg or application/pdf.","_meta":{"description":"The file format, such as image/jpeg or application/pdf."}},"description":{"type":"text","required":false,"description":"Explain what the file contains and when it should be used.","_meta":{"description":"Explain what the file contains and when it should be used."}},"metadata":{"type":"text","required":false,"description":"Additional details recorded while processing this file.","_meta":{"description":"Additional details recorded while processing this file."}},"version":{"type":"integer","required":true,"default":1,"description":"The revision number of this file in its version history.","_meta":{"description":"The revision number of this file in its version history."}},"primaryVersionId":{"type":"foreignKey","required":false,"related":"Asset","description":"The first version of this file, linking its revision history.","_meta":{"description":"The first version of this file, linking its revision history."}},"typeSlug":{"type":"text","required":false,"description":"The category of asset, such as an image, video, or document.","_meta":{"description":"The category of asset, such as an image, video, or document."}},"statusSlug":{"type":"text","required":false,"description":"The stage of this asset, such as draft, published, or archived.","_meta":{"description":"The stage of this asset, such as draft, published, or archived."}},"ownerProfileId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-profiles:Profile","description":"The person or organization responsible for this asset.","_meta":{"description":"The person or organization responsible for this asset."}},"sourceAssetId":{"type":"foreignKey","required":false,"related":"Asset","description":"The original asset used to produce this file or variation.","_meta":{"description":"The original asset used to produce this file or variation."}},"folderId":{"type":"foreignKey","required":false,"related":"Folder","description":"The folder that organizes this file in the asset library.","_meta":{"description":"The folder that organizes this file in the asset library."}},"sourceType":{"type":"text","required":false,"description":"The service or source from which this file was obtained.","_meta":{"description":"The service or source from which this file was obtained."}},"externalId":{"type":"text","required":false,"description":"The reference used to identify this file at its original source.","_meta":{"description":"The reference used to identify this file at its original source."}},"externalRefs":{"type":"text","required":false,"description":"References that connect this file to copies held by other services.","_meta":{"description":"References that connect this file to copies held by other services."}},"createdAt":{"type":"text","required":false},"updatedAt":{"type":"text","required":false},"width":{"type":"integer","required":false,"default":0},"height":{"type":"integer","required":false,"default":0},"alt":{"type":"text","required":false,"default":""}},"methods":{"getSlug":{"name":"getSlug","async":true,"parameters":[],"returnType":"Promise<string | null | undefined>","isStatic":false,"isPublic":true},"getMetadata":{"name":"getMetadata","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setMetadata":{"name":"setMetadata","async":false,"parameters":[{"name":"metadata","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"mergeMetadata":{"name":"mergeMetadata","async":false,"parameters":[{"name":"metadata","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"getExternalRefs":{"name":"getExternalRefs","async":false,"parameters":[],"returnType":"Record<string, AssetExternalReference>","isStatic":false,"isPublic":true},"getExternalRef":{"name":"getExternalRef","async":false,"parameters":[{"name":"provider","type":"string","optional":false}],"returnType":"AssetExternalReference | null","isStatic":false,"isPublic":true},"setExternalRef":{"name":"setExternalRef","async":false,"parameters":[{"name":"provider","type":"string","optional":false},{"name":"reference","type":"any","optional":false,"typeUnresolved":true}],"returnType":"void","isStatic":false,"isPublic":true},"getTags":{"name":"getTags","async":true,"parameters":[],"returnType":"Promise<Tag[]>","isStatic":false,"isPublic":true},"hasTag":{"name":"hasTag","async":true,"parameters":[{"name":"tagSlug","type":"string","optional":false},{"name":"context","type":"string","optional":true}],"returnType":"Promise<boolean>","isStatic":false,"isPublic":true},"getSource":{"name":"getSource","async":true,"parameters":[],"returnType":"Promise<Asset | null>","isStatic":false,"isPublic":true},"getDerivatives":{"name":"getDerivatives","async":true,"parameters":[],"returnType":"Promise<Asset[]>","isStatic":false,"isPublic":true},"getType":{"name":"getType","async":true,"parameters":[],"returnType":"Promise<AssetType | null>","isStatic":false,"isPublic":true},"getStatus":{"name":"getStatus","async":true,"parameters":[],"returnType":"Promise<AssetStatus | null>","isStatic":false,"isPublic":true},"getAssociations":{"name":"getAssociations","async":true,"parameters":[],"returnType":"Promise<AssetAssociation[]>","isStatic":false,"isPublic":true},"associateWith":{"name":"associateWith","async":true,"parameters":[{"name":"metaType","type":"string","optional":false},{"name":"metaId","type":"string","optional":false},{"name":"role","type":"any","optional":true,"default":"default"}],"returnType":"Promise<AssetAssociation>","isStatic":false,"isPublic":true},"getBySlug":{"name":"getBySlug","async":true,"parameters":[{"name":"_slug","type":"string","optional":false}],"returnType":"Promise<Asset | null>","isStatic":true,"isPublic":true},"isValidImageFormat":{"name":"isValidImageFormat","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isHighResolution":{"name":"isHighResolution","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"generateAltText":{"name":"generateAltText","async":true,"parameters":[],"returnType":"Promise<string>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update","delete"]},"mcp":{"include":["list","get","create","update","generateAltText"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"tableName":"assets","tableStrategy":"sti"},"extends":"Asset","exportName":"Image","collectionExportName":"ImageCollection","displayLabelField":"name","validationRules":[{"field":"version","rule":"required","fieldType":"integer"}],"schema":{"tableName":"assets","ddl":"CREATE TABLE IF NOT EXISTS \\"assets\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"access_mode\\" TEXT DEFAULT 'public',\\n \\"name\\" TEXT,\\n \\"source_uri\\" TEXT,\\n \\"mime_type\\" TEXT,\\n \\"description\\" TEXT,\\n \\"metadata\\" TEXT,\\n \\"version\\" INTEGER DEFAULT 1,\\n \\"primary_version_id\\" UUID,\\n \\"type_slug\\" TEXT,\\n \\"status_slug\\" TEXT,\\n \\"owner_profile_id\\" UUID,\\n \\"source_asset_id\\" UUID,\\n \\"folder_id\\" UUID,\\n \\"source_type\\" TEXT,\\n \\"external_id\\" TEXT,\\n \\"external_refs\\" TEXT,\\n \\"width\\" INTEGER DEFAULT 0,\\n \\"height\\" INTEGER DEFAULT 0,\\n \\"alt\\" TEXT DEFAULT ''\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false},"access_mode":{"type":"TEXT","notNull":false,"default":"public"},"name":{"type":"TEXT","notNull":false},"source_uri":{"type":"TEXT","notNull":false},"mime_type":{"type":"TEXT","notNull":false},"description":{"type":"TEXT","notNull":false},"metadata":{"type":"TEXT","notNull":false},"version":{"type":"INTEGER","notNull":false,"default":1},"primary_version_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"assets","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"type_slug":{"type":"TEXT","notNull":false},"status_slug":{"type":"TEXT","notNull":false},"owner_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"source_asset_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"assets","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"folder_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false},"source_type":{"type":"TEXT","notNull":false},"external_id":{"type":"TEXT","notNull":false},"external_refs":{"type":"TEXT","notNull":false},"width":{"type":"INTEGER","notNull":false,"default":0},"height":{"type":"INTEGER","notNull":false,"default":0},"alt":{"type":"TEXT","notNull":false,"default":""}},"indexes":[{"name":"assets_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"assets_meta_type_idx","columns":["_meta_type"]},{"name":"assets_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"assets_primary_version_id_idx","columns":["primary_version_id"]},{"name":"assets_owner_profile_id_idx","columns":["owner_profile_id"]},{"name":"assets_source_asset_id_idx","columns":["source_asset_id"]},{"name":"assets_folder_id_idx","columns":["folder_id"]}],"version":"4dc794d3"},"importPath":"@happyvertical/smrt-images"},"@happyvertical/smrt-images:ImageCollection":{"name":"imagecollection","className":"ImageCollection","qualifiedName":"@happyvertical/smrt-images:ImageCollection","collection":"assets","filePath":"/home/runner/work/smrt/smrt/packages/images/src/images.ts","packageName":"@happyvertical/smrt-images","fields":{},"methods":{"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"getByMinDimensions":{"name":"getByMinDimensions","async":true,"parameters":[{"name":"minWidth","type":"number","optional":false},{"name":"minHeight","type":"number","optional":false}],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"getByMaxDimensions":{"name":"getByMaxDimensions","async":true,"parameters":[{"name":"maxWidth","type":"number","optional":false},{"name":"maxHeight","type":"number","optional":false}],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"getLandscape":{"name":"getLandscape","async":true,"parameters":[],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"getPortrait":{"name":"getPortrait","async":true,"parameters":[],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"getSquare":{"name":"getSquare","async":true,"parameters":[],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"getMissingAltText":{"name":"getMissingAltText","async":true,"parameters":[],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"getHighResolution":{"name":"getHighResolution","async":true,"parameters":[],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true},"getByAspectRatio":{"name":"getByAspectRatio","async":true,"parameters":[{"name":"minRatio","type":"number","optional":false},{"name":"maxRatio","type":"number","optional":false}],"returnType":"Promise<Image[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"assets","api":{"include":["list","get","create","update","delete"]},"mcp":{"include":["list","get","create","update"]}},"extends":"SmrtCollection","extendsTypeArg":"Image","exportName":"ImageCollection","collectionExportName":"ImageCollectionCollection","schema":{"tableName":"assets","ddl":"CREATE TABLE IF NOT EXISTS \\"assets\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"access_mode\\" TEXT DEFAULT 'public',\\n \\"name\\" TEXT,\\n \\"source_uri\\" TEXT,\\n \\"mime_type\\" TEXT,\\n \\"description\\" TEXT,\\n \\"metadata\\" TEXT,\\n \\"version\\" INTEGER DEFAULT 1,\\n \\"primary_version_id\\" UUID,\\n \\"type_slug\\" TEXT,\\n \\"status_slug\\" TEXT,\\n \\"owner_profile_id\\" UUID,\\n \\"source_asset_id\\" UUID,\\n \\"folder_id\\" UUID,\\n \\"source_type\\" TEXT,\\n \\"external_id\\" TEXT,\\n \\"external_refs\\" TEXT,\\n \\"width\\" INTEGER DEFAULT 0,\\n \\"height\\" INTEGER DEFAULT 0,\\n \\"alt\\" TEXT DEFAULT ''\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false},"access_mode":{"type":"TEXT","notNull":false,"default":"public"},"name":{"type":"TEXT","notNull":false},"source_uri":{"type":"TEXT","notNull":false},"mime_type":{"type":"TEXT","notNull":false},"description":{"type":"TEXT","notNull":false},"metadata":{"type":"TEXT","notNull":false},"version":{"type":"INTEGER","notNull":false,"default":1},"primary_version_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"assets","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"type_slug":{"type":"TEXT","notNull":false},"status_slug":{"type":"TEXT","notNull":false},"owner_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"source_asset_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"assets","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"folder_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false},"source_type":{"type":"TEXT","notNull":false},"external_id":{"type":"TEXT","notNull":false},"external_refs":{"type":"TEXT","notNull":false},"width":{"type":"INTEGER","notNull":false,"default":0},"height":{"type":"INTEGER","notNull":false,"default":0},"alt":{"type":"TEXT","notNull":false,"default":""}},"indexes":[{"name":"assets_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"assets_meta_type_idx","columns":["_meta_type"]},{"name":"assets_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"assets_primary_version_id_idx","columns":["primary_version_id"]},{"name":"assets_owner_profile_id_idx","columns":["owner_profile_id"]},{"name":"assets_source_asset_id_idx","columns":["source_asset_id"]},{"name":"assets_folder_id_idx","columns":["folder_id"]}],"version":"4dc794d3"},"importPath":"@happyvertical/smrt-images"}},"moduleType":"smrt","smrtDependencies":["@happyvertical/smrt-assets","@happyvertical/smrt-core","@happyvertical/smrt-profiles","@happyvertical/smrt-prompts","@happyvertical/smrt-tenancy"],"browser":{"status":"server-only","issues":["#3624","#3628"],"reason":"sharp, node:fs/promises, node:crypto, resvg native addon","via":["@happyvertical/smrt-tenancy"]},"stampsConstructors":true}`));
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/prompts.ts
|
|
16
16
|
var smrtImagesGenerateAltTextPrompt = definePrompt({
|
|
@@ -1088,7 +1088,6 @@ Image = __decorateClass([TenantScoped({ mode: "optional" }), smrt({
|
|
|
1088
1088
|
})], Image);
|
|
1089
1089
|
//#endregion
|
|
1090
1090
|
//#region src/images.ts
|
|
1091
|
-
var IMAGE_META_TYPE = "@happyvertical/smrt-images:Image";
|
|
1092
1091
|
var ImageCollection = class extends SmrtCollection {
|
|
1093
1092
|
static _itemClass = Image;
|
|
1094
1093
|
/**
|
|
@@ -1106,9 +1105,9 @@ var ImageCollection = class extends SmrtCollection {
|
|
|
1106
1105
|
* @returns Array of global images
|
|
1107
1106
|
*/
|
|
1108
1107
|
async findGlobal() {
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1108
|
+
const tenantId = getCurrentTenant()?.tenantId;
|
|
1109
|
+
const read = async () => this.list({ where: { tenantId: null } });
|
|
1110
|
+
return tenantId ? withTenantGlobalRead(tenantId, read) : read();
|
|
1112
1111
|
}
|
|
1113
1112
|
/**
|
|
1114
1113
|
* Find images belonging to a tenant plus all global images
|
|
@@ -1117,14 +1116,7 @@ var ImageCollection = class extends SmrtCollection {
|
|
|
1117
1116
|
* @returns Array of tenant-specific and global images
|
|
1118
1117
|
*/
|
|
1119
1118
|
async findWithGlobals(tenantId) {
|
|
1120
|
-
|
|
1121
|
-
if (tenantContext && !isSuperAdminBypass() && tenantContext.tenantId !== tenantId) throw new TenantIsolationError(`Tenant isolation violation in Image.findWithGlobals: context tenant is '${tenantContext.tenantId}' but query requested '${tenantId}'`, {
|
|
1122
|
-
tenantId: tenantContext.tenantId,
|
|
1123
|
-
attemptedTenantId: tenantId
|
|
1124
|
-
});
|
|
1125
|
-
return await this.query(`SELECT * FROM ${this.tableName}
|
|
1126
|
-
WHERE _meta_type = ?
|
|
1127
|
-
AND (tenant_id = ? OR tenant_id IS NULL)`, [IMAGE_META_TYPE, tenantId], { allowRawOnTenantScoped: true });
|
|
1119
|
+
return withTenantGlobalRead(tenantId, async () => this.list({ where: [[{ tenantId }], [{ tenantId: null }]] }));
|
|
1128
1120
|
}
|
|
1129
1121
|
/**
|
|
1130
1122
|
* Get images by minimum dimensions
|