@ossy/media-tasks
v3.0.6
Published
Changestream-triggered media processing tasks (image resize, AI descriptors)
Readme
@ossy/media-tasks
Changestream-triggered media processing tasks for the Ossy platform.
Tasks in this package are registered with TaskService.RegisterTask() at API startup and fire automatically when matching ADR 0008 resource events appear on the event store change stream.
Tasks
| Task id | Trigger | Description |
|---------|---------|-------------|
| @ossy/media-tasks/tasks/resize-common-web | @ossy/platform/schema/file Created (content.ContentType: image/*) | Generates common web thumbnail and gallery sizes using sharp |
| @ossy/media-tasks/tasks/visual-content-descriptors | @ossy/platform/schema/file Created (image/*, video/*) | Uses GPT-4o to generate title, description, tags, and alt text |
Schemas
Task outcome schemas live in src/*.schema.js and are auto-discovered at build time:
| Schema | Id |
|--------|----|
| Resize Common Web | @ossy/media-tasks/schema/resize-common-web |
| Visual Content Descriptors | @ossy/media-tasks/schema/visual-content-descriptors |
These describe optional task-run documents; handlers are implemented in the matching *.task.js files.
Task contract
Each *.task.js file exports:
export const metadata = {
id: '@ossy/media-tasks/tasks/my-task',
triggers: [{ type, event, match?, location? }],
}
export async function run ({ event, sdk }) { ... }metadata.id— canonical task id (@ossy/<package>/tasks/…)triggers[].type— resource schema id to watch (e.g.@ossy/platform/schema/file)triggers[].event— lifecycle event name (Created,Patched, …)triggers[].match— optional field matcher onevent.payload(e.g.{ 'content.ContentType': 'image/*' })event— the raw eventstorefullDocument(resourceId,type,event,payload, …)sdk— platform SDK instance (passed from API startup;nullduring local dev if unconfigured)
Dependencies
sharp(peer) — image resizing inresize-common-webopenai(peer) — GPT-4o vision invisual-content-descriptors@ossy/platform—StorageClient.loadfor reading uploaded file bytes (provided at runtime by the platform server)
