Skip to content

Commit

Permalink
feat: Add missing types for IOCozyFile
Browse files Browse the repository at this point in the history
  • Loading branch information
cballevre committed Jul 10, 2024
1 parent efc8ef2 commit 54761c9
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 2 deletions.
26 changes: 25 additions & 1 deletion packages/cozy-client/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
*/

/**
Expand All @@ -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
Expand Down
70 changes: 69 additions & 1 deletion packages/cozy-client/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -673,7 +729,7 @@ export type CozyClientDocument = {
/**
* - Cozy Metadata
*/
cozyMetadata?: object;
cozyMetadata?: CozyMetadata;
};
/**
* - A io.cozy.files document's metadata
Expand Down Expand Up @@ -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
Expand All @@ -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
*/
Expand Down

0 comments on commit 54761c9

Please sign in to comment.