Skip to content

Commit

Permalink
feat: Add IOCozyApp typings
Browse files Browse the repository at this point in the history
It was previously declared in cozy-flagship.
It is needed to update documentation in cozy-doctypes
following this commit (acceptFromFlagship is not mentionned)
  • Loading branch information
acezard committed Nov 17, 2023
1 parent aceb4ee commit 7e692bb
Show file tree
Hide file tree
Showing 2 changed files with 268 additions and 0 deletions.
92 changes: 92 additions & 0 deletions packages/cozy-client/src/types.js
Expand Up @@ -69,6 +69,98 @@ import { QueryDefinition } from './queries/dsl'
* @typedef {CozyClientDocument & KonnectorsDocument} IOCozyKonnector - An io.cozy.konnectors document
*/

/**
* @typedef {Object} Developer - name and url for the developer
* @property {string} name
* @property {string} url
*/

/**
* @typedef {Object} Intent - (application specific) a list of intents provided by this app
* @property {string} action
* @property {string[]} type
* @property {string} href
*/

/**
* @typedef {Object} Locale - an object with language slug as property, each name property is an object of localized informations
* @property {string} long_description
* @property {string[]} screenshots
* @property {string} short_description
*/

/**
* @typedef {Object} Permission - a map of permissions needed by the app
* @property {string} type
* @property {string} [description]
* @property {string[]} [verbs]
* @property {string} [selector]
* @property {string[]} [values]
*/

/**
* @typedef {Object} Route - (application specific) a map of routes for the app
* @property {string} folder
* @property {string} index
* @property {boolean} public
*/

/**
* @typedef {Object} Service - (application specific) a map of the services associated with the app (see cozy-stack services doc for more details)
* @property {string} type
* @property {string} file
* @property {string} [debounce]
* @property {string} trigger
* @property {string} trigger_id
*/

/**
* @typedef {Object} Terms - an object defining properties for terms that need to be displayed/accepted by the user when installing the application
* @property {string} url
* @property {string} version
*/

/**
* @typedef {Object} AcceptDocumentsFromFlagship - The acceptance document details from cozy-flagship.
* @property {string[]} accepted_mime_types
* @property {number} max_number_of_files
* @property {number} max_size_per_file_in_MB
* @property {string} route_to_upload - The route provided by the cozy-app to trigger the upload user flow
*/

/**
* @typedef {Object} AppsDocument
* See https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.apps/
*
* @property {AcceptDocumentsFromFlagship} [accept_documents_from_flagship] - The acceptance document details from flagship.
* @property {boolean} [accept_from_flagship] - Whether to accept file upload from cozy-flagship.
* @property {string[]} categories - array of categories for your apps (see authorized categories), it will be ['others'] by default if empty
* @property {string} checksum
* @property {string} created_at
* @property {Developer} developer - name and url for the developer
* @property {string} editor - the editor’s name to display on the cozy-bar
* @property {string} icon - path to the icon for the home
* @property {Intent[]} intents - (application specific) a list of intents provided by this app
* @property {string[]} langs - Languages available in the app
* @property {string} licence - the SPDX license identifier
* @property {Object.<string, Locale>} locales - an object with language slug as property, each name property is an object of localized informations
* @property {string} name - the name to display on the home
* @property {string} name_prefix - the prefix to display with the name
* @property {null} notifications
* @property {Object.<string, Permission>} permissions - a map of permissions needed by the app
* @property {Object.<string, Route>} routes - (application specific) a map of routes for the app
* @property {string[]} screenshots - an array of paths to the screenshots of the application
* @property {Object.<string, Service>} services - (application specific) a map of the services associated with the app
* @property {string} slug - the default slug that should never change (alpha-numeric lowercase)
* @property {string} source - where the files of the app can be downloaded
* @property {string} state
* @property {Terms} terms - an object defining properties for terms that need to be displayed/accepted by the user when installing the application
* @property {"webapp"} type - type of application
* @property {string} updated_at
* @property {string} version - the current version number
* @typedef {CozyClientDocument & AppsDocument} IOCozyApp - An io.cozy.apps document
*/

/**
* @typedef {object} TriggersDocument
* @property {String} [_id] - document identifier
Expand Down
176 changes: 176 additions & 0 deletions packages/cozy-client/types/types.d.ts
Expand Up @@ -181,6 +181,182 @@ export type KonnectorsDocument = {
* - An io.cozy.konnectors document
*/
export type IOCozyKonnector = CozyClientDocument & KonnectorsDocument;
/**
* - name and url for the developer
*/
export type Developer = {
name: string;
url: string;
};
/**
* - (application specific) a list of intents provided by this app
*/
export type Intent = {
action: string;
type: string[];
href: string;
};
/**
* - an object with language slug as property, each name property is an object of localized informations
*/
export type Locale = {
long_description: string;
screenshots: string[];
short_description: string;
};
/**
* - a map of permissions needed by the app
*/
export type Permission = {
type: string;
description?: string;
verbs?: string[];
selector?: string;
values?: string[];
};
/**
* - (application specific) a map of routes for the app
*/
export type Route = {
folder: string;
index: string;
public: boolean;
};
/**
* - (application specific) a map of the services associated with the app (see cozy-stack services doc for more details)
*/
export type Service = {
type: string;
file: string;
debounce?: string;
trigger: string;
trigger_id: string;
};
/**
* - an object defining properties for terms that need to be displayed/accepted by the user when installing the application
*/
export type Terms = {
url: string;
version: string;
};
/**
* - The acceptance document details from cozy-flagship.
*/
export type AcceptDocumentsFromFlagship = {
accepted_mime_types: string[];
max_number_of_files: number;
max_size_per_file_in_MB: number;
/**
* - The route provided by the cozy-app to trigger the upload user flow
*/
route_to_upload: string;
};
/**
* See https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.apps/
*/
export type AppsDocument = {
/**
* - The acceptance document details from flagship.
*/
accept_documents_from_flagship?: AcceptDocumentsFromFlagship;
/**
* - Whether to accept file upload from cozy-flagship.
*/
accept_from_flagship?: boolean;
/**
* - array of categories for your apps (see authorized categories), it will be ['others'] by default if empty
*/
categories: string[];
checksum: string;
created_at: string;
/**
* - name and url for the developer
*/
developer: Developer;
/**
* - the editor’s name to display on the cozy-bar
*/
editor: string;
/**
* - path to the icon for the home
*/
icon: string;
/**
* - (application specific) a list of intents provided by this app
*/
intents: Intent[];
/**
* - Languages available in the app
*/
langs: string[];
/**
* - the SPDX license identifier
*/
licence: string;
/**
* - an object with language slug as property, each name property is an object of localized informations
*/
locales: {
[x: string]: Locale;
};
/**
* - the name to display on the home
*/
name: string;
/**
* - the prefix to display with the name
*/
name_prefix: string;
notifications: null;
/**
* - a map of permissions needed by the app
*/
permissions: {
[x: string]: Permission;
};
/**
* - (application specific) a map of routes for the app
*/
routes: {
[x: string]: Route;
};
/**
* - an array of paths to the screenshots of the application
*/
screenshots: string[];
/**
* - (application specific) a map of the services associated with the app
*/
services: {
[x: string]: Service;
};
/**
* - the default slug that should never change (alpha-numeric lowercase)
*/
slug: string;
/**
* - where the files of the app can be downloaded
*/
source: string;
state: string;
/**
* - an object defining properties for terms that need to be displayed/accepted by the user when installing the application
*/
terms: Terms;
/**
* - type of application
*/
type: "webapp";
updated_at: string;
/**
* - the current version number
*/
version: string;
};
/**
* - An io.cozy.apps document
*/
export type IOCozyApp = CozyClientDocument & AppsDocument;
export type TriggersDocument = {
/**
* - document identifier
Expand Down

0 comments on commit 7e692bb

Please sign in to comment.