ConceptPortal-public/rsconcept/frontend/src/features/library/models/library.ts

124 lines
2.3 KiB
TypeScript
Raw Normal View History

/**
* Module: Models for LibraryItem.
*/
2023-09-11 20:31:54 +03:00
import { UserID } from '@/features/users/models/user';
2024-05-27 20:42:34 +03:00
/**
* Represents type of library items.
2023-12-28 14:04:44 +03:00
*/
2023-09-11 20:31:54 +03:00
export enum LibraryItemType {
RSFORM = 'rsform',
OSS = 'oss'
2023-09-11 20:31:54 +03:00
}
/**
* Represents Access policy for library items.
*/
export enum AccessPolicy {
PUBLIC = 'public',
PROTECTED = 'protected',
PRIVATE = 'private'
}
/**
* Represents valid location headers.
*/
export enum LocationHead {
USER = '/U',
2024-06-04 11:19:21 +03:00
COMMON = '/S',
2024-06-19 22:10:15 +03:00
PROJECTS = '/P',
LIBRARY = '/L'
}
2024-09-12 13:27:20 +03:00
export const BASIC_SCHEMAS = '/L/Базовые';
2024-05-27 20:42:34 +03:00
/**
* Represents {@link LibraryItem} identifier type.
*/
export type LibraryItemID = number;
/**
* Represents {@link Version} identifier type.
*/
export type VersionID = number;
/**
* Represents library item version information.
*/
export interface IVersionInfo {
2024-05-27 20:42:34 +03:00
id: VersionID;
item: LibraryItemID;
version: string;
description: string;
time_create: string;
}
/**
* Represents library item common data typical for all item types.
2023-12-28 14:04:44 +03:00
*/
2023-09-11 20:31:54 +03:00
export interface ILibraryItem {
2024-03-17 19:24:12 +03:00
id: LibraryItemID;
2023-12-28 14:04:44 +03:00
item_type: LibraryItemType;
title: string;
alias: string;
comment: string;
visible: boolean;
read_only: boolean;
location: string;
access_policy: AccessPolicy;
2023-12-28 14:04:44 +03:00
time_create: string;
time_update: string;
2024-05-27 20:42:34 +03:00
owner: UserID | null;
2023-09-11 20:31:54 +03:00
}
2023-11-30 02:14:24 +03:00
/**
2024-08-01 00:36:06 +03:00
* Represents {@link ILibraryItem} constant data loaded for both OSS and RSForm.
2023-12-28 14:04:44 +03:00
*/
2024-06-04 23:00:22 +03:00
export interface ILibraryItemData extends ILibraryItem {
2024-05-27 20:42:34 +03:00
editors: UserID[];
2024-06-04 23:00:22 +03:00
}
/**
2024-08-01 00:36:06 +03:00
* Represents {@link ILibraryItem} minimal reference data.
*/
export interface ILibraryItemReference extends Pick<ILibraryItem, 'id' | 'alias'> {}
/**
* Represents {@link ILibraryItem} extended data with versions.
2024-06-04 23:00:22 +03:00
*/
export interface ILibraryItemVersioned extends ILibraryItemData {
2024-05-27 20:42:34 +03:00
version?: VersionID;
versions: IVersionInfo[];
2023-11-30 02:14:24 +03:00
}
2024-06-04 23:00:22 +03:00
/**
2024-08-01 00:36:06 +03:00
* Represents common {@link ILibraryItem} editor controller.
2024-06-04 23:00:22 +03:00
*/
export interface ILibraryItemEditor {
schema: ILibraryItemData;
deleteSchema: () => void;
2024-06-04 23:00:22 +03:00
isMutable: boolean;
isAttachedToOSS: boolean;
}
/**
* Represents Library filter parameters.
*/
export interface ILibraryFilter {
type?: LibraryItemType;
query?: string;
folderMode?: boolean;
subfolders?: boolean;
path?: string;
head?: LocationHead;
location?: string;
isVisible?: boolean;
isOwned?: boolean;
isEditor?: boolean;
filterUser?: UserID;
}