feat: expose trash entry size metadata
This commit is contained in:
parent
dd9168dad5
commit
5ddf7f2020
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AACzF,OAAO,KAAK,EAAwB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAQ3E,MAAM,WAAW,oBAAoB;IACnC,aAAa,CAAC,EAAE,4BAA4B,CAAC;CAC9C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAetF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW,CASnF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,SAAgB,EAAE,OAAO,GAAE,oBAAyB,GAAG,gBAAgB,CA2WlH;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAgCxF;AAGD,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,EAAE,EAAE,CAAC"}
|
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AACzF,OAAO,KAAK,EAAwB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAQ3E,MAAM,WAAW,oBAAoB;IACnC,aAAa,CAAC,EAAE,4BAA4B,CAAC;CAC9C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAetF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW,CASnF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,SAAgB,EAAE,OAAO,GAAE,oBAAyB,GAAG,gBAAgB,CA4WlH;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAgCxF;AAGD,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,EAAE,EAAE,CAAC"}
|
||||||
|
|
@ -327,6 +327,7 @@ export function createMockPluginAPI(pluginId = 'test.plugin', options = {}) {
|
||||||
deletedAt: new Date().toISOString(),
|
deletedAt: new Date().toISOString(),
|
||||||
originalType: node.type,
|
originalType: node.type,
|
||||||
basename: baseName(path),
|
basename: baseName(path),
|
||||||
|
size: node.type === 'file' ? (node.content || '').length : 0,
|
||||||
};
|
};
|
||||||
const moving = Array.from(files.entries()).filter(([candidate]) => candidate === path || candidate.startsWith(`${path}/`));
|
const moving = Array.from(files.entries()).filter(([candidate]) => candidate === path || candidate.startsWith(`${path}/`));
|
||||||
trashPayloads.set(trashId, moving.map(([candidate, movingNode]) => ({
|
trashPayloads.set(trashId, moving.map(([candidate, movingNode]) => ({
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -105,6 +105,8 @@ export interface TrashResult {
|
||||||
trashPath: string;
|
trashPath: string;
|
||||||
trashId: string;
|
trashId: string;
|
||||||
deletedAt: string;
|
deletedAt: string;
|
||||||
|
/** Original regular-file size in bytes, when the host can provide it. */
|
||||||
|
size?: number;
|
||||||
}
|
}
|
||||||
export interface TrashEntry extends TrashResult {
|
export interface TrashEntry extends TrashResult {
|
||||||
originalType: FileEntry['type'];
|
originalType: FileEntry['type'];
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -32,7 +32,7 @@
|
||||||
{ "name": "vault.watch", "description": "Watch vault file changes", "dangerous": false },
|
{ "name": "vault.watch", "description": "Watch vault file changes", "dangerous": false },
|
||||||
{ "name": "files.read", "description": "List files and read bounded text or byte payloads through the vault Files API", "dangerous": false },
|
{ "name": "files.read", "description": "List files and read bounded text or byte payloads through the vault Files API", "dangerous": false },
|
||||||
{ "name": "files.write", "description": "Create folders, write bounded text or byte payloads, and move paths through the vault Files API", "dangerous": true },
|
{ "name": "files.write", "description": "Create folders, write bounded text or byte payloads, and move paths through the vault Files API", "dangerous": true },
|
||||||
{ "name": "files.delete", "description": "Trash vault files and folders through the vault Files API", "dangerous": true },
|
{ "name": "files.delete", "description": "Trash vault files and folders and permanently delete trash entries through the vault Files API", "dangerous": true },
|
||||||
{ "name": "files.openExternal", "description": "Open vault files and folders in external OS applications", "dangerous": true },
|
{ "name": "files.openExternal", "description": "Open vault files and folders in external OS applications", "dangerous": true },
|
||||||
{ "name": "storage.namespace", "description": "Read/write plugin's own storage namespace", "dangerous": false },
|
{ "name": "storage.namespace", "description": "Read/write plugin's own storage namespace", "dangerous": false },
|
||||||
{ "name": "storage.migrations", "description": "Run database migrations in plugin namespace", "dangerous": false },
|
{ "name": "storage.migrations", "description": "Run database migrations in plugin namespace", "dangerous": false },
|
||||||
|
|
|
||||||
|
|
@ -351,6 +351,7 @@ describe('VerstakPluginAPI contract', () => {
|
||||||
expect(trash.originalPath).toBe('PlatformTest/two.txt');
|
expect(trash.originalPath).toBe('PlatformTest/two.txt');
|
||||||
expect(trash.trashId).toBeTruthy();
|
expect(trash.trashId).toBeTruthy();
|
||||||
expect(trash.trashPath).toMatch(/^\.verstak\/trash\/files\/.+\/two\.txt$/);
|
expect(trash.trashPath).toMatch(/^\.verstak\/trash\/files\/.+\/two\.txt$/);
|
||||||
|
expect(trash.size).toBe(5);
|
||||||
await expect(api.files.listTrash()).resolves.toEqual([
|
await expect(api.files.listTrash()).resolves.toEqual([
|
||||||
expect.objectContaining({ originalPath: 'PlatformTest/two.txt', trashId: trash.trashId }),
|
expect.objectContaining({ originalPath: 'PlatformTest/two.txt', trashId: trash.trashId }),
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -316,6 +316,7 @@ export function createMockPluginAPI(pluginId = 'test.plugin', options: MockPlugi
|
||||||
deletedAt: new Date().toISOString(),
|
deletedAt: new Date().toISOString(),
|
||||||
originalType: node.type,
|
originalType: node.type,
|
||||||
basename: baseName(path),
|
basename: baseName(path),
|
||||||
|
size: node.type === 'file' ? (node.content || '').length : 0,
|
||||||
};
|
};
|
||||||
const moving = Array.from(files.entries()).filter(([candidate]) => candidate === path || candidate.startsWith(`${path}/`));
|
const moving = Array.from(files.entries()).filter(([candidate]) => candidate === path || candidate.startsWith(`${path}/`));
|
||||||
trashPayloads.set(trashId, moving.map(([candidate, movingNode]) => ({
|
trashPayloads.set(trashId, moving.map(([candidate, movingNode]) => ({
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,8 @@ export interface TrashResult {
|
||||||
trashPath: string;
|
trashPath: string;
|
||||||
trashId: string;
|
trashId: string;
|
||||||
deletedAt: string;
|
deletedAt: string;
|
||||||
|
/** Original regular-file size in bytes, when the host can provide it. */
|
||||||
|
size?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TrashEntry extends TrashResult {
|
export interface TrashEntry extends TrashResult {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue