图片资源
owlmeans2026-10-25查看 1000复制 1247
如何使用 @owlmeans/image-resource——基于 @owlmeans/storage-common 共享存储文件类型的图像形状名称和 AJV schema。在为图像记录标注类型或验证图像上传时自动调用。
📘如何使用这个技能
- 1复制技能内容·点击上方「Copy SKILL.md」复制全部内容,或 Download 下载到本地
- 2打开你的 AI 客户端·支持 Claude Code、Trae、Cursor、ChatGPT、DeepSeek、Kimi 等任意 AI 助手
- 3粘贴为系统提示/知识文件·Claude Code:放入 .claude/skills/ 目录;普通对话:作为首条消息发送并说「请严格按这份技能文档执行」
- 4直接提出你的需求·AI 会按技能定义的工作流、格式和约束来处理,无需再解释背景
💡 提示:技能生效后,每次对话只需一句需求,AI 会按 SKILL.md 的流程执行。
SKILL.md2276 chars
---
name: image-resource
description: How to use @owlmeans/image-resource — the image-shaped names and AJV schemas over the shared stored-file types from @owlmeans/storage-common. Auto-invoked when typing image records or validating an image upload.
user-invocable: false
---
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
# @owlmeans/image-resource
**Layer:** Infra
**Install:** `"@owlmeans/image-resource": "^0.1.18-rc.42"` in `dependencies` (peer `ajv`)
Types and schemas only — no resource is registered here. An image *is* a stored file
([[storage-common]]); this package gives that file image-shaped names so a signature says what it
carries, and re-emits the schemas so an image endpoint validates against its own.
## Key Exports
| Export | Description |
|--------|-------------|
| `ImageMeta`, `StoredImage`, `ImageData` | The image spellings of `StoredFileMeta`, `StoredFile` and `StoredFileWithData` |
| `ImageMetaSchema`, `StoredImageSchema`, `ImageDataSchema` | The matching AJV schemas |
## Usage
Type the record that *describes* the image, and keep it in a database resource — that is what
answers criteria, sorting and paging. The bytes go to a bucket through
[[storage-resource]]'s upload-only `create`.
```typescript
import type { StoredImage } from '@owlmeans/image-resource'
const images = ctx.resource<Resource<StoredImage>>('images')
await images.list({ entityId, mimeType: { $startsWith: 'image/' } }, { sort: ['name'], size: 20 })
```
`instances` carries the renditions — original, thumbnail, converted format — each with its own
`url` and `size`. Pick the one a screen needs from that map; never rebuild a url by string surgery.
## Depends On
- `@owlmeans/storage-resource` — the only declared dependency
- peer `ajv`
The schemas here are built from `StoredFileMetaSchema`, `StoredFileSchema` and
`StoredFileWithDataSchema`, which are **runtime values** from `@owlmeans/storage-common`, and the
package does not declare it. Install `@owlmeans/storage-common` explicitly rather than relying on it
arriving under `@owlmeans/storage-resource`.
## Related
- [[storage-common]] — the stored-file types and schemas these specialize
- [[storage-resource]] — the bucket upload · [[resource]] — the record store behind it