@sassoftware/vi-api
Version:
Types used in the SAS Visual Investigator API
282 lines (281 loc) • 10.5 kB
TypeScript
import { CoreStoredObjectField, Entity, Relationship, RelationshipDTO, StoredObjectDTO } from "../svi-datahub";
import { IdentitySummary } from "../current-user/currentUser-api";
export interface IdentityOption extends IdentitySummary {
label?: string;
icon?: string;
}
export interface NodeShapeMultipliers {
square: number;
circle: number;
ellipse: number;
triangle: number;
hexagon: number;
pentagon: number;
diamond: number;
custom: number;
}
export interface SandServicesField {
name: string;
value: string;
}
export interface EntityMetadata {
[entityName: string]: SandDataObject;
}
export interface SandDataObject extends DataObject {
parentName?: string;
label?: string;
relationshipsFrom?: any;
relationshipsTo?: any;
attachmentsIndexedForSearch?: boolean;
resolvedEntity?: boolean;
indexedForSearch?: boolean;
requireSearchBeforeCreate?: boolean;
}
export interface DataObject extends PersistableObject {
name: string;
dataStoreName?: string;
tableName?: string;
deleteTableName?: string;
readOnly: boolean;
archived: boolean;
historyEnabled?: boolean;
systemReserved: boolean;
type?: string;
fields: DataObjectField[];
fileCategories?: FileCategory[];
}
export interface FileCategory {
name: string;
displayName: string;
required: boolean;
allowMultiple: boolean;
documentLockRequired: boolean;
filesExist?: boolean;
}
export interface DataObjectField extends PersistableObject, LocalizableObject {
name: string;
label: string;
columnName: string;
dataType: string;
length: number;
precision: number;
displayIndex: number;
unique: boolean;
required: boolean;
readOnly: boolean;
readOnlyConditionally: {
conditionId: string;
objectState: "ENTERED" | "SAVED";
};
requiredConditionally: {
conditionId: string;
objectState: "ENTERED" | "SAVED";
};
primaryKeyField: boolean;
archived: boolean;
systemReserved: boolean;
multiValued: boolean;
autoGenerated: boolean;
autoGenStartValue: number;
ownerName: string;
jsonSchema: string;
constrainingListName?: string;
cascadingReferenceDataName?: string;
cascadingReferenceDataFilterByCode?: string;
cascadingReferenceDataFilterByField?: string;
masked?: boolean;
authorizedToRevealMasked?: IdentityOption[];
[index: string]: any;
}
export interface LocalizableObject {
label?: string;
localizedLabels: LocalizedLabel[];
description?: string;
localizedDescriptions: LocalizedDescription[];
}
export interface LocalizedLabel extends PersistableObject {
localeCd: string;
label: string;
}
export interface LocalizedDescription extends PersistableObject {
localeCd: string;
description: string;
}
export interface PersistableObject {
id?: number;
createdBy?: string;
createdAt?: Date;
lastUpdatedBy?: string;
lastUpdatedAt?: Date;
version?: number;
}
export interface ValidRelationshipTypes {
[relationshipName: string]: RelationshipTypes;
}
export interface RelationshipTypes {
isIndexedForSearch: boolean;
linkTypes: Relationship[];
name: string;
searchBeforeCreate: boolean;
}
export interface EntityAccessRules {
create: Promise<boolean>;
read: Promise<boolean>;
update: Promise<boolean>;
}
export interface EntityAccessRule {
documentType: string;
access?: boolean;
}
export interface EntitiesAccessRules {
create: Promise<EntityAccessRule[]>;
read: Promise<EntityAccessRule[]>;
update: Promise<EntityAccessRule[]>;
}
export interface ReferenceDataItem {
group?: string;
displayText: string;
value: string | null;
}
export type Picklist = ReferenceDataItem[];
export interface RelationshipWithLabel extends RelationshipDTO {
relationshipLabel?: string;
}
export interface ReferenceDataOptions {
constrainingListName?: string;
parentCode?: string;
}
/**
* This API provides the functionality related to retrieval of metadata.
*
* Accessed from the window at `window.sas.vi.metadata`.
*
* @example window.sas.vi.metadata.getEntityAccessRules(objectType);
* @category API
*/
export interface MetadataApi {
/**
* @method
* @description Gets create, read, and update access rights for an entity.
* @param objectType {string} Entity name.
* @returns Object with a Promise of type boolean for each rule.
*/
getEntityAccessRules(objectType: string): EntityAccessRules;
/**
* @method
* @description Gets create, read, and update access rights for the provided entities via batch call.
* @param {string[]} objectTypes Entity names.
* @returns Object with a Promise of type EntityAccessRule[] for each rule, where EntityAccessRule maps to the access rule of a given entity name.
*/
getEntitiesAccessRules(objectTypes: string[]): EntitiesAccessRules;
/**
* @method
* @description Checks access rights and gets metadata for an entity. Returns undefined if the entity does not exist.
* @param objectType {string} Entity name.
* @returns A Promise containing the entity metadata.
*/
getEntity(objectType: string): Promise<StoredObjectDTO | undefined>;
/**
* @method
* @description Gets metadata for an entity field.
* @param objectType {string} Entity name.
* @param fieldName {string} Field name.
* @returns A Promise containing the field metadata.
*/
getField(objectType: string, fieldName: string): Promise<CoreStoredObjectField>;
/**
* @method
* @description Gets managed entity types.
* @returns A Promise containing an array of managed entity types.
*/
getManagedEntityTypes(): Promise<StoredObjectDTO[]>;
/**
* @method
* @description Gets root type entities that are not child types.
* @returns A Promise containing an array of root types.
*/
getRootTypes(): Promise<StoredObjectDTO[]>;
/**
* @method
* @description Gets child entity types for a given entity.
* @param objectType {string} Checks for children for the named entity.
* @returns A Promise containing an array of child entity types or an empty list if none are found.
*/
getChildEntityTypes(objectType: string): Promise<StoredObjectDTO[]>;
/**
* @method
* @description Gets valid relationship types for a specified entity.
* If relationshipObjectType and RelationshipName are provided, the link types are filtered accordingly.
* Otherwise, all valid relationships related to the objectType are returned.
* @param objectType {string} Finds relationships for the entity.
* @param [relationshipObjectType] {string} Used for filtering the name of an expected related entity.
* @param [relationshipName] {string} Used for filtering the name of an expected relationship.
* @param flattenMultiLinkIntoSingles Whether Relationships with a One->(multiple) links will get flattened into many One->Single relationships.
* @returns A Promise resolving to an object containing relationship type metadata.
* The object is empty if no relationship types exist.
*/
getAllValidRelationshipTypes(objectType: string, relationshipObjectType?: string, relationshipName?: string, flattenMultiLinkIntoSingles?: boolean): Promise<ValidRelationshipTypes>;
/**
* @method
* @description Gets metadata for all resolved entities.
* @returns A Promise containing an array of the resolved entities metadata.
*/
getResolvedEntities(): Promise<Entity[]>;
/**
* @method
* @description Gets metadata for a resolved entity.
* @param objectType {string} Resolved Entity Name.
* @returns A Promise containing resolved entity metadata or undefined if none exists.
*/
getResolvedEntityMetadata(objectType: string): Promise<Entity | undefined>;
/**
* @method
* @description Gets the icon path for an entity.
* @param objectType {string} Entity name.
* @param [iconType] {string} Icon type. If iconType is not provided it is set to REGULAR by default.
* @returns A string containing the icon path. Returns undefined if objectType is empty.
*/
getIconForEntity(objectType: string, iconType?: string): string | undefined;
/**
* @deprecated Use [getRootTypes()]{@link getRootTypes} and [getResolvedEntities()]{@link getResolvedEntities}` instead.
*
* @method
* @description Gets metadata for both entities and resolved entities.
* @returns A Promise resolving to Search entity metadata.
*/
getSearchMetadata(): Promise<EntityMetadata>;
/**
* @method
* @description Gets reference data with the given name.
* @param {string} name Reference data list name.
* @param {ReferenceDataOptions} [options] Object containing name and filter constraints.
* If constrainingListName is defined, then the refDataName parameter is ignored.
* parentCode is used to filter list items to those that are children of this list name.
* @returns Promise containing the reference data or undefined if none exists.
*/
getReferenceData(name: string, options?: {
constrainingListName?: string;
parentCode?: string;
}): Promise<Picklist | undefined>;
/**
* @deprecated
* @method
* @description Gets relationships with a specified end type.
* @param endType {string} End type entity name.
* @param [includeHeterogeneous = false] {boolean} Boolean value to determine whether heterogeneous relationships are included.
* @returns A Promise resolving to a list of relationships, or an empty list if none are found.
*/
getRelationshipsFilteredByEndType(endType: string, includeHeterogeneous?: boolean): Promise<RelationshipWithLabel[]>;
/**
* @method
* @description Gets relationships with a specified end type.
* @param endType endType {string} End type entity name.
* @param options See {@link OptionsForGetRelationshipsForObjectType}
*/
getRelationshipsForObjectType(endType: string, options: OptionsForGetRelationshipsForObjectType): Promise<RelationshipWithLabel[]>;
}
export interface OptionsForGetRelationshipsForObjectType {
includeHeterogeneous?: boolean;
includeMultipleTypeRelationships?: boolean;
expandMultipleRelationshipsToSingle?: boolean;
}