feat: add hash and thumbnail columns to file, sort column and order method to manifestattachment
This commit is contained in:
@@ -18,10 +18,15 @@ Attaches a file to an existing manifest.
|
||||
| `input.mimetype` | `string` | The MIME type of the file (e.g. `'application/pdf'`). |
|
||||
| `input.name` | `string` | The file name. |
|
||||
| `input.content` | `Buffer` | The file content. |
|
||||
| `[input.sort]` | `number` | Optional display sort order. |
|
||||
| `[input.hash]` | `string` | The file hash (auto-computed SHA-256 if omitted). |
|
||||
| `[input.thumbavif]` | `Buffer` | Optional AVIF thumbnail buffer. |
|
||||
| `[input.thumbx]` | `number` | Optional thumbnail width. |
|
||||
| `[input.thumby]` | `number` | Optional thumbnail height. |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<{id: number, manifestId: number, fileId: number, mimetype: string, name: string}>` — The created attachment record.
|
||||
`Promise<{id: number, manifestId: number, fileId: number, sort: number, hash: string, mimetype: string, name: string, thumbavif: Buffer|null, thumbx: number|null, thumby: number|null}>` — The created attachment record.
|
||||
|
||||
**Throws**
|
||||
|
||||
@@ -35,7 +40,7 @@ const attachment = await store.manifestattachment.add(42, 1, {
|
||||
name: 'invoice.pdf',
|
||||
content: fileBuffer,
|
||||
});
|
||||
// => { id, manifestId, fileId, mimetype, name }
|
||||
// => { id, manifestId, fileId, sort, hash, mimetype, name, thumbavif, thumbx, thumby }
|
||||
```
|
||||
|
||||
## `manifestattachment.getById`
|
||||
@@ -54,7 +59,7 @@ Gets an attachment for a manifest by its attachment ID or file ID, including ful
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<{id: number, manifestId: number, fileId: number, mimetype: string, name: string, content: Buffer}>` — The attachment record with binary content.
|
||||
`Promise<{id: number, manifestId: number, fileId: number, sort: number, hash: string, mimetype: string, name: string, content: Buffer, thumbavif: Buffer|null, thumbx: number|null, thumby: number|null}>` — The attachment record with binary content.
|
||||
|
||||
**Throws**
|
||||
|
||||
@@ -64,7 +69,7 @@ Gets an attachment for a manifest by its attachment ID or file ID, including ful
|
||||
|
||||
```js
|
||||
const attachment = await store.manifestattachment.getById(42, 1, 5);
|
||||
// => { id, manifestId, fileId, mimetype, name, content }
|
||||
// => { id, manifestId, fileId, sort, hash, mimetype, name, content, thumbavif, thumbx, thumby }
|
||||
```
|
||||
|
||||
## `manifestattachment.listByManifestId`
|
||||
@@ -82,7 +87,7 @@ Lists all attachments for a given manifest, without loading their full binary co
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<Array<{id: number, manifestId: number, fileId: number, mimetype: string, name: string, size: number}>>` — A list of attachment metadata objects.
|
||||
`Promise<Array<{id: number, manifestId: number, fileId: number, sort: number, hash: string, mimetype: string, name: string, size: number, thumbavif: Buffer|null, thumbx: number|null, thumby: number|null}>>` — A list of attachment metadata objects.
|
||||
|
||||
**Throws**
|
||||
|
||||
@@ -92,7 +97,37 @@ Lists all attachments for a given manifest, without loading their full binary co
|
||||
|
||||
```js
|
||||
const attachments = await store.manifestattachment.listByManifestId(42, 1);
|
||||
// => [{ id, manifestId, fileId, mimetype, name, size }]
|
||||
// => [{ id, manifestId, fileId, sort, hash, mimetype, name, size, thumbavif, thumbx, thumby }]
|
||||
```
|
||||
|
||||
## `manifestattachment.order`
|
||||
|
||||
*Source: `src/store/manifestattachment/order.js`*
|
||||
|
||||
Reorders the attachments of a manifest.
|
||||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `googleAuthId` | `number` | The id of the Google auth user. |
|
||||
| `manifestId` | `number` | The manifest ID. |
|
||||
| `input` | `object|Array<number>` | The reorder input or array of IDs. |
|
||||
| `[input.ids]` | `Array<number>` | The attachment ids in their new order. |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<{ids: Array<number>}>` — The applied order.
|
||||
|
||||
**Throws**
|
||||
|
||||
`Error` — If the order is invalid.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const result = await store.manifestattachment.order(42, 1, { ids: [12, 10, 15] });
|
||||
// => { ids: [12, 10, 15] }
|
||||
```
|
||||
|
||||
## `manifestattachment.remove`
|
||||
|
||||
Reference in New Issue
Block a user