feat: manage files via manifestattachment with auth and cascade trigger, format API.md method signatures
This commit is contained in:
124
API.manifestattachment.md
Normal file
124
API.manifestattachment.md
Normal file
@@ -0,0 +1,124 @@
|
||||
# manifestattachment
|
||||
|
||||
This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`.
|
||||
|
||||
## `manifestattachment.add`
|
||||
|
||||
*Source: `src/store/manifestattachment/add.js`*
|
||||
|
||||
Attaches a file to an existing manifest.
|
||||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `googleAuthId` | `number` | The id of the Google auth user. |
|
||||
| `manifestId` | `number` | The id of the manifest. |
|
||||
| `input` | `object` | The file data. |
|
||||
| `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. |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<object>` — The created attachment record.
|
||||
|
||||
**Throws**
|
||||
|
||||
`Error` — If the manifest is not found or file input is invalid.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const attachment = await store.manifestattachment.add(42, 1, {
|
||||
mimetype: 'application/pdf',
|
||||
name: 'invoice.pdf',
|
||||
content: fileBuffer,
|
||||
});
|
||||
// => { id, manifestId, fileId, mimetype, name }
|
||||
```
|
||||
|
||||
## `manifestattachment.getById`
|
||||
|
||||
*Source: `src/store/manifestattachment/getById.js`*
|
||||
|
||||
Gets an attachment for a manifest by its attachment ID or file ID, including full file content.
|
||||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `googleAuthId` | `number` | The id of the Google auth user. |
|
||||
| `manifestId` | `number` | The manifest ID. |
|
||||
| `id` | `number` | The attachment ID or file ID. |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<object>` — The attachment record with binary content.
|
||||
|
||||
**Throws**
|
||||
|
||||
`Error` — If the manifest or attachment is not found, or user is not authorized.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const attachment = await store.manifestattachment.getById(42, 1, 5);
|
||||
// => { id, manifestId, fileId, mimetype, name, content }
|
||||
```
|
||||
|
||||
## `manifestattachment.listByManifestId`
|
||||
|
||||
*Source: `src/store/manifestattachment/listByManifestId.js`*
|
||||
|
||||
Lists all attachments for a given manifest, without loading their full binary content.
|
||||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `googleAuthId` | `number` | The id of the Google auth user. |
|
||||
| `manifestId` | `number` | The manifest ID. |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<Array<object>>` — A list of attachment metadata objects.
|
||||
|
||||
**Throws**
|
||||
|
||||
`Error` — If the manifest is not found or the user is not authorized.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const attachments = await store.manifestattachment.listByManifestId(42, 1);
|
||||
// => [{ id, manifestId, fileId, mimetype, name, size }]
|
||||
```
|
||||
|
||||
## `manifestattachment.remove`
|
||||
|
||||
*Source: `src/store/manifestattachment/remove.js`*
|
||||
|
||||
Removes a file attachment from a manifest and deletes the underlying file.
|
||||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `googleAuthId` | `number` | The id of the Google auth user. |
|
||||
| `manifestId` | `number` | The manifest ID. |
|
||||
| `id` | `number` | The attachment ID or file ID to remove. |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<void>`
|
||||
|
||||
**Throws**
|
||||
|
||||
`Error` — If the manifest or attachment is not found, or user is not authorized.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
await store.manifestattachment.remove(42, 1, 5);
|
||||
```
|
||||
Reference in New Issue
Block a user