173 lines
4.2 KiB
TypeScript
173 lines
4.2 KiB
TypeScript
import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-type";
|
|
import { ReferenceTypeExternalApiHTTPMethodType } from "@app/core/common/enum/reference-type-external-api-http-method-type";
|
|
import { ReferenceTypeSourceType } from "@app/core/common/enum/reference-type-source-type";
|
|
import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model";
|
|
import { Guid } from "@common/types/guid";
|
|
|
|
export interface ReferenceType extends BaseEntity{
|
|
name: string;
|
|
code: string;
|
|
definition: ReferenceTypeDefinition;
|
|
}
|
|
|
|
export interface ReferenceTypeDefinition{
|
|
fields: ReferenceTypeField[];
|
|
sources: ReferenceTypeSourceBaseConfiguration[];
|
|
}
|
|
|
|
export interface ReferenceTypeField {
|
|
code: string;
|
|
label: string;
|
|
description: string;
|
|
dataType: ReferenceFieldDataType;
|
|
}
|
|
|
|
export interface ReferenceTypeSourceBaseConfiguration extends ReferenceTypeSourceExternalApiConfiguration, ReferenceTypeSourceStaticOptionConfiguration{
|
|
type: ReferenceTypeSourceType;
|
|
key: string;
|
|
label: string;
|
|
ordinal: number;
|
|
referenceTypeDependencies?: ReferenceType[];
|
|
}
|
|
|
|
export interface ReferenceTypeSourceExternalApiConfiguration{
|
|
url: string;
|
|
results: ResultsConfiguration;
|
|
paginationPath: string;
|
|
contentType: string;
|
|
firstPage: string;
|
|
httpMethod: ReferenceTypeExternalApiHTTPMethodType;
|
|
requestBody?: string;
|
|
filterType?: string;
|
|
auth: AuthenticationConfiguration;
|
|
queries?: QueryConfig[];
|
|
}
|
|
|
|
export interface ResultsConfiguration{
|
|
resultsArrayPath: string;
|
|
fieldsMapping: ResultFieldsMappingConfiguration[];
|
|
}
|
|
|
|
|
|
export interface ResultFieldsMappingConfiguration{
|
|
code: string;
|
|
responsePath: string;
|
|
}
|
|
|
|
export interface AuthenticationConfiguration{
|
|
enabled: boolean;
|
|
authUrl: string;
|
|
authMethod: ReferenceTypeExternalApiHTTPMethodType;
|
|
authTokenPath: string;
|
|
authRequestBody: string;
|
|
type: string;
|
|
}
|
|
|
|
export interface QueryConfig{
|
|
name: string;
|
|
defaultValue: string;
|
|
cases: QueryCaseConfig[];
|
|
}
|
|
|
|
export interface QueryCaseConfig{
|
|
likePattern: string,
|
|
separator: string;
|
|
value: string;
|
|
referenceType?: ReferenceType;
|
|
referenceTypeSourceKey: string
|
|
}
|
|
|
|
export interface ReferenceTypeSourceStaticOptionConfiguration{
|
|
options: ReferenceTypeStaticOption[];
|
|
}
|
|
|
|
export interface ReferenceTypeStaticOption{
|
|
code: string;
|
|
value: string;
|
|
}
|
|
|
|
// Persist
|
|
|
|
export interface ReferenceTypePersist extends BaseEntityPersist{
|
|
name: string;
|
|
code: string;
|
|
definition: ReferenceTypeDefinitionPersist;
|
|
}
|
|
|
|
export interface ReferenceTypeDefinitionPersist{
|
|
fields?: ReferenceTypeFieldPersist[];
|
|
sources: ReferenceTypeSourceBaseConfigurationPersist[];
|
|
}
|
|
|
|
export interface ReferenceTypeFieldPersist {
|
|
code: string;
|
|
label: string;
|
|
description: string;
|
|
dataType: ReferenceFieldDataType;
|
|
}
|
|
|
|
export interface ReferenceTypeSourceBaseConfigurationPersist extends ReferenceTypeSourceExternalApiConfigurationPersist, ReferenceTypeSourceStaticOptionConfigurationPersist{
|
|
type: ReferenceTypeSourceType;
|
|
key: string;
|
|
label: string;
|
|
ordinal: number;
|
|
referenceTypeDependencyIds?: Guid[];
|
|
}
|
|
|
|
export interface ReferenceTypeSourceExternalApiConfigurationPersist{
|
|
url: string;
|
|
results: ResultsConfigurationPersist;
|
|
paginationPath: string;
|
|
contentType: string;
|
|
firstPage: string;
|
|
httpMethod: ReferenceTypeExternalApiHTTPMethodType;
|
|
requestBody?: string;
|
|
filterType?: string;
|
|
auth: AuthenticationConfigurationPersist;
|
|
queries?: QueryConfigPersist[];
|
|
}
|
|
|
|
export interface ResultsConfigurationPersist{
|
|
resultsArrayPath: string;
|
|
fieldsMapping: ResultFieldsMappingConfigurationPersist[];
|
|
}
|
|
|
|
|
|
|
|
export interface ResultFieldsMappingConfigurationPersist{
|
|
code: string;
|
|
responsePath: string;
|
|
}
|
|
|
|
export interface AuthenticationConfigurationPersist{
|
|
enabled: boolean;
|
|
authUrl: string;
|
|
authMethod: ReferenceTypeExternalApiHTTPMethodType;
|
|
authTokenPath: string;
|
|
authRequestBody: string;
|
|
type: string;
|
|
}
|
|
|
|
export interface QueryConfigPersist{
|
|
name: string;
|
|
defaultValue: string;
|
|
cases: QueryCaseConfigPersist[];
|
|
}
|
|
|
|
export interface QueryCaseConfigPersist{
|
|
likePattern: string,
|
|
separator: string;
|
|
value: string;
|
|
referenceTypeId: Guid;
|
|
referenceTypeSourceKey: string
|
|
}
|
|
|
|
export interface ReferenceTypeSourceStaticOptionConfigurationPersist {
|
|
options: ReferenceTypeStaticOptionPersist[];
|
|
}
|
|
|
|
export interface ReferenceTypeStaticOptionPersist{
|
|
code: string;
|
|
value: string;
|
|
}
|