import type { EntityByMetaType, DocumentWithPositionsMetaType, Id } from '..'; import type { Collection } from '../Collection'; import type { CompanyMetaType } from '../Company'; import type { Document, DocumentMetaType } from '../Document'; import type { Meta } from '../Meta'; import type { Expand, Patch } from '../utils'; import type { DomineEntityMetaType } from './types'; export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'; export type AuditCollectionEndpoint = `audit`; export type AuditEndpoint = `audit/${Id}`; export type AuditEventCollectionEndpoint = `audit/${Id}/events`; export type EmployeeContextEndpoint = `context/employee`; export type DownloadEndpoint = `download/${Id}`; export type AssortmentCollectionEndpoint = `entity/assortment`; export type CustomEntityCollectionEndpoint = `entity/customentity/${Id}`; export type CustomEntityEndpoint = `entity/customentity/${Id}/${Id}`; export type CompanyAccountCollectionEndpoint = `entity/${T}/${Id}/accounts`; export type DomineEntityCollectionEndpoint = `entity/${T}`; export type EntityMetadataEndpoint = `entity/${T}/metadata`; export type EntityAttributeMetadataEndpoint = `entity/${T}/metadata/attributes`; export type DomineEntityEndpoint = `entity/${T}/${Id}`; export type PrefilledDocumentEndpoint = `entity/${T}/new`; export type DocumentPositionCollectionEndpoint = `entity/${T}/${Id}/positions`; export type DocumentPositionEndpoint = `entity/${T}/${Id}/positions/${Id}`; export type HttpMethodPath = { GET: AuditCollectionEndpoint | AuditEndpoint | AuditEventCollectionEndpoint | EmployeeContextEndpoint | DownloadEndpoint | AssortmentCollectionEndpoint | CustomEntityCollectionEndpoint | CompanyAccountCollectionEndpoint | DomineEntityCollectionEndpoint | EntityMetadataEndpoint | EntityAttributeMetadataEndpoint | DomineEntityEndpoint | DocumentPositionCollectionEndpoint | DocumentPositionEndpoint; POST: DomineEntityCollectionEndpoint | DocumentPositionCollectionEndpoint; PUT: DomineEntityEndpoint | PrefilledDocumentEndpoint; DELETE: DomineEntityEndpoint; }; export type EndpointInterfaceInfo = { payload: Payload; response: ExpandStr extends string ? Expand : Response; }; export type EndpointInterface = string extends Endpoint ? EndpointInterfaceInfo : Endpoint extends DomineEntityEndpoint ? EntityType extends DomineEntityMetaType ? Method extends 'GET' ? EndpointInterfaceInfo : Method extends 'PUT' ? Endpoint extends `entity/${EntityType}/${infer Rest}` ? Rest extends 'new' ? EntityType extends DocumentMetaType ? EntityByMetaType[EntityType] extends Document ? EndpointInterfaceInfo, ExpandStr> : never : never : EndpointInterfaceInfo, EntityByMetaType[EntityType], ExpandStr> : never : EndpointInterfaceInfo : EndpointInterfaceInfo : Endpoint extends DomineEntityCollectionEndpoint ? EntityType extends DomineEntityMetaType ? Method extends 'GET' ? EndpointInterfaceInfo, ExpandStr> : Method extends 'POST' ? EndpointInterfaceInfo & { meta?: Meta; }>, EntityByMetaType[EntityType][], ExpandStr> : EndpointInterfaceInfo : EndpointInterfaceInfo : EndpointInterfaceInfo;