From 09506021d90b3614d67ed0dd20fa9741a9e09a70 Mon Sep 17 00:00:00 2001 From: cballevre Date: Wed, 10 Jul 2024 16:36:59 +0200 Subject: [PATCH] feat: Add missing types for IOCozyFile --- packages/cozy-client/src/types.js | 26 +++++++++- packages/cozy-client/types/types.d.ts | 70 ++++++++++++++++++++++++++- 2 files changed, 94 insertions(+), 2 deletions(-) diff --git a/packages/cozy-client/src/types.js b/packages/cozy-client/src/types.js index a0b4a7ae81..2843c2ea6e 100644 --- a/packages/cozy-client/src/types.js +++ b/packages/cozy-client/src/types.js @@ -386,6 +386,27 @@ import { QueryDefinition } from './queries/dsl' * @property {Function} [updateQueries] */ +/** + * @typedef {object} UpdatedByApp + * @property {string} slug - Slug of the app that updated the document + * @property {string} date - Date of the update + * @property {number} version - Version of the app that updated the document + */ + +/** + * @typedef {object} CozyMetadata + * @property {number} [doctypeVersion] - Version of the doctype + * @property {number} [metadataVersion] - Version of the metadata + * @property {string} [createdAt] - Date of creation + * @property {string} [createdByApp] - Slug of the app that created the document + * @property {string} [createdByAppVersion] - Version of the app that created the document + * @property {string} [updatedAt] - Date of the last update + * @property {UpdatedByApp[]} [updatedByApps] - List of apps that updated the document + * @property {string} [sourceAccount] - Id of the account associated to the document + * @property {string} [sourceAccountIdentifier] - Identifier of the source account + * @property {boolean} [favorite] - Whether the document is marked as favorite + */ + /** * @typedef {object} CozyClientDocument - A document * @property {string} [_id] - Id of the document @@ -395,7 +416,7 @@ import { QueryDefinition } from './queries/dsl' * @property {boolean} [_deleted] - When the document has been deleted * @property {ReferencedByRelationship} [relationships] - Relationships of the document * @property {Reference[]} [referenced_by] - referenced by of another document - * @property {object} [cozyMetadata] - Cozy Metadata + * @property {CozyMetadata} [cozyMetadata] - Cozy Metadata */ /** @@ -418,12 +439,15 @@ import { QueryDefinition } from './queries/dsl' * @property {string} [referencedDate] - Reference date of the paper * @property {string} [noticePeriod] - Notice period of the paper, in days * @property {string} [datetime] - Image EXIF date, if relevant + * @property {string} [instanceName] - Name of the instance */ /** * @typedef {object} FileDocument - An io.cozy.files document * @property {string} _id - Id of the file * @property {FilesDoctype} _type - Doctype of the file + * @property {string} dir_id - Id of the parent folder + * @property {string} [path] - Path of the file * @property {string} name - Name of the file * @property {FileMetadata} metadata - Metadata of the file * @property {string} type - Type of the file diff --git a/packages/cozy-client/types/types.d.ts b/packages/cozy-client/types/types.d.ts index 3166cc426e..2a527ba158 100644 --- a/packages/cozy-client/types/types.d.ts +++ b/packages/cozy-client/types/types.d.ts @@ -638,6 +638,62 @@ export type MutationOptions = { update?: Function; updateQueries?: Function; }; +export type UpdatedByApp = { + /** + * - Slug of the app that updated the document + */ + slug: string; + /** + * - Date of the update + */ + date: string; + /** + * - Version of the app that updated the document + */ + version: number; +}; +export type CozyMetadata = { + /** + * - Version of the doctype + */ + doctypeVersion?: number; + /** + * - Version of the metadata + */ + metadataVersion?: number; + /** + * - Date of creation + */ + createdAt?: string; + /** + * - Slug of the app that created the document + */ + createdByApp?: string; + /** + * - Version of the app that created the document + */ + createdByAppVersion?: string; + /** + * - Date of the last update + */ + updatedAt?: string; + /** + * - List of apps that updated the document + */ + updatedByApps?: UpdatedByApp[]; + /** + * - Id of the account associated to the document + */ + sourceAccount?: string; + /** + * - Identifier of the source account + */ + sourceAccountIdentifier?: string; + /** + * - Whether the document is marked as favorite + */ + favorite?: boolean; +}; /** * - A document */ @@ -673,7 +729,7 @@ export type CozyClientDocument = { /** * - Cozy Metadata */ - cozyMetadata?: object; + cozyMetadata?: CozyMetadata; }; /** * - A io.cozy.files document's metadata @@ -719,6 +775,10 @@ export type FileMetadata = { * - Image EXIF date, if relevant */ datetime?: string; + /** + * - Name of the instance + */ + instanceName?: string; }; /** * - An io.cozy.files document @@ -732,6 +792,14 @@ export type FileDocument = { * - Doctype of the file */ _type: FilesDoctype; + /** + * - Id of the parent folder + */ + dir_id: string; + /** + * - Path of the file + */ + path?: string; /** * - Name of the file */