nd-common
Version:
867 lines (866 loc) • 22.8 kB
TypeScript
import { Observable } from "rxjs";
import { CustomAttributeType, RepositoryAdminType, CabinetAdminType, UserType, AttachmentType, DefaultFromBehavior, ContainerType } from "../models";
/**
* Interfaces defines the functionality of a document model object.
* This model includes folders, filters, saved searches, workspaces, etc.
*/
export interface IDocumentModel {
/**
* Gets/Sets a 12 digit document id eg: 1234-5678-9012
*/
DocId: string;
/**
* Gets/Sets the envelope ID. Friendlier ID for making Rest calls. Looks
* like the Envelope URL but with : instead of /.
* eg: :q1:a:b:c:d:~160504112345678.nev|1
*/
EnvId: string;
/**
* Gets/Sets the document number in the envelope. Usually 1 except when dealing with a sharespace.
*/
DocNum: number;
/**
* Gets/Sets the standard attributes associated with a document.
*/
Attributes: IStandardAttributes;
/**
* Gets/Sets the status attributes of a document.
*/
Status?: IStatusAttributes;
/**
* Gets/Sets the source id information.
*/
Source?: ISourceInformation;
/**
* Gets/Sets the email information.
*/
Email?: IEmailInformation;
/**
* Gets/Sets miscellaneous information. Isn't validated because it never comes
* from the user.
*/
Misc?: IMiscellaneousInformation;
/**
* Gets/Sets the document's custom attributes.
*/
CustomAttributes?: Array<ICustomAttribute>;
/**
* Gets/Sets the document permissions.
*/
Permissions?: IPermissionsModel;
/**
* Gets/Sets the version information of document.
*/
Versions?: IVersionsModel;
/**
* Gets/Sets the document's attachment information.
*/
DocumentAttachments?: IAttachmentsModel;
/**
* Gets/Sets the synchronization information.
*/
Sync?: ISynchronization;
/**
* Gets/Sets the document check out information.
*/
CheckedOut?: ICheckOutInformation;
/**
* The document checking in/out state.
*/
CheckingStatus?: boolean;
/**
* Gets/Sets location information.
*/
Locations?: ILocationsModel;
/**
* Gets/Sets the list of document ancestors. This is an in order list.
*/
Ancestors?: Array<IBasicContainerInformation>;
/**
* Gets/Sets container specific document information.
*/
Container?: IContainerModel;
/**
* Gets/Sets if the document model has UI focus.
*/
Focused?: boolean;
/**
* Collection of subordinate items (such as sub-folders) to support recursion
*/
List?: Array<IDocumentModel>;
/**
* Updates the document model with information from another document model.
* @param source The source object to update from.
* @param updateThis A string array that defines the element of the document model to be updated.
* See OptionalAttributes for a complete list of attribute flags that control what is returned.
* The string form of the attributes can be used here.
*/
update?(source: IDocumentModel, updateThis: string[]): void;
/**
* Updates the document model with information from another document model.
* @param source The source object to update from.
* @param updateThis A string array that defines the element of the document model to be updated.
* See OptionalAttributes for a complete list of attribute flags that control what is returned.
* The string form of the attributes can be used here.
*/
update?(source: IDocumentModel, updateThis: string[]): boolean;
/**
* Fetches the number of attachments the active document has.
* If the document has no attachments, the number of attachments will be null.
*/
attachmentCount?(): number;
/**
* Fetches the number of locations the active document has.
* If the document has no locations, the number of locations will be null.
*/
locationCount?(): number;
/**
* Gets the value in the document model based off of the attribute Id.
* @param id The attribute id.
* @return The matching attribute found in the DocumentModel.
*/
getAttr?(id: number): any;
/**
* Gets/Sets if a row is selected on UI.
*/
Selected?: boolean;
/**
* Gets/Sets if row is highlighted on UI.
*/
Highlighted?: boolean;
/**
* Determine if the document model is that of an email.
*/
isEmail?(): boolean;
IsMyEmail?: boolean;
}
/** Subclass containing standard attributes */
export interface IStandardAttributes {
/**
* Document Name
*/
Name: string;
/**
* Document Extension
*/
Ext: string;
/**
* Size of unencrypted document, in bytes.
*/
Size: number;
/** Name of user who created the document
*
*/
CreatedBy: string;
/**
* GUID of user who created the document
*/
CreatedByGuid: string;
/**
* When the document was created in UTC
*/
Created: Date;
/**
* Name of user who last modified the document
*/
ModifiedBy: string;
/**
* Guid of user who last modified the document
*/
ModifiedByGuid: string;
/**
* When the document was last modified in UTC
*/
Modified: Date;
/**
* Documents linked to this document
*/
LinkedDocuments?: string[];
}
/**
* Easy light weight Cabinet Name and Guid pair.
*/
export interface ICabinetNameAndGuid {
/**
* Represents Cabinet Name value.
*/
Name: string;
/**
* Cabinet Guid.
*/
Guid: string;
}
/**
* Attribute value.
*/
export interface IAttribute {
/**
* Represents identifier of attribute.
*/
id: number;
/**
* Represents name for attribute.
*/
name: string;
}
/** Custom attribute value */
export interface ICustomAttribute {
/**
* Custom attribute Id. ie: 1001, 1002, 1003, etc...
*/
Id: number;
/**
* Custom attribute values. This is the key value. Array item 0 is default.
*/
Value?: Array<string>;
/**
* Descriptions corresponding to the values in Value or NumberValue.
*/
Description?: Array<string>;
/**
* Flag that tells us whether this value is a date or not (client side)
*/
Date?: boolean;
}
/** Custom attribute definition */
export interface ICustomAttributeDefinition {
Id: number;
QueryField?: number;
Name: string;
Type: string | CustomAttributeType;
MaxLength?: number;
PromptIfEmpty?: number;
ForceUppercase?: boolean;
AllowPunctuation?: boolean;
UseLookup?: boolean;
Linked?: number;
Security?: boolean;
HideLookup?: boolean;
DefaultFrom?: number;
ExtendLength?: number;
ReadOnly?: boolean;
DefaultToCurrentDate?: boolean;
AllowMultipleValues?: boolean;
DoNotCopy?: boolean;
DefaultFromBehavior?: DefaultFromBehavior;
}
/** Subclass containing status attributes */
export interface IStatusAttributes {
Deleted?: boolean;
Approved?: boolean;
Archived?: boolean;
Signed?: boolean;
Favorite?: boolean;
Hold?: boolean;
Echo?: boolean;
External?: boolean;
OfficialLocked?: boolean;
Access: IPermission;
}
/** Subclass holding source attributes, these are populated with standard attributes */
export interface ISourceInformation {
Name: string;
Id: string;
}
/** Email specific information */
export interface IEmailInformation {
MessageId: string;
EmId?: number;
Subject: string;
From: string;
To: string;
CC: string;
Attachments?: Array<IEmailAttachment>;
ConversationId?: string;
EmlConversationId?: string;
}
/**
* Interface that declares the functionality common to all attachments.
*/
export interface IAttachmentBase {
/**
* The attachment type.
*/
AttachmentType: AttachmentType;
/**
* The name of email attachment.
*/
Name: string;
/**
* A description of the attachment.
*/
Description?: string;
/**
* The UTC creation date of the attachment. NOTE: This is not part of the model in ndCommon.Models but is used in the code. Not sure why
*/
Created?: string;
/**
* An extension of the attachment.
*/
Ext: string;
}
/**
* Interface that declars the functionality of an email attachment.
*/
export interface IEmailAttachment extends IAttachmentBase {
}
/** Subclass holding information that doesn't fit anywhere else. */
export interface IMiscellaneousInformation {
Highlights: Array<string>;
Errors: Array<IErrorModel>;
}
/** This might be best moved to common.models */
export interface IErrorModel {
Id: number;
Description: string;
AutoCorrect: boolean;
}
/** Subclass representing a single ACL value */
export interface IPermission {
Principal?: string;
Name?: string;
Edit?: boolean;
View?: boolean;
Share?: boolean;
Administer?: boolean;
Default?: boolean;
None?: boolean;
}
/** Subclass containing cabinet and repository options */
export interface IOptions {
Cabinet: number;
Repository: number;
Repository2: number;
NdSyncOptions: INdSyncOptions;
}
/** Subclass containing cabinet and repository options */
export interface INdSyncOptions {
IsNdSyncOnForAll: boolean;
NdSyncAddresses: Array<string>;
}
/** Subclass containing permission information */
export interface IPermissionsModel {
UserIsExternal: boolean;
Status: string;
Acl: Array<IPermission>;
Options: IOptions;
}
/** Subclass representing an individual document version */
export interface IVersion {
Number: number;
Created: Date;
CreatedBy: string;
CreatedByGuid: string;
Source: number;
Description?: string;
Official: boolean;
Locked: boolean;
Ext: string;
Modified: Date;
ModifiedBy: string;
ModifiedByGuid: string;
DeliveryRevoked?: boolean;
Wopi?: string;
BlockReg?: string;
}
export interface IVersionsModel {
Count: number;
Official: number;
Versions: Array<IVersion>;
}
/**
* Interface that defines the functionality of a document attachment.
*/
export interface IAttachment extends IEmailAttachment {
/**
* The envelope level attachment Id.
*/
Id: string;
/**
* The attachment extension without an leading period.
*/
Ext: string;
}
/**
* Interface that defines a list of attachments.
*/
export interface IAttachmentsModel {
/**
* Gets/Sets an array of attachements.
*/
Attachments: Array<IAttachment>;
}
/** Subclass holding synchronization information */
export interface ISynchronization {
DocModNum: number;
NameModNum: number;
}
/** Subclass holding check out information */
export interface ICheckOutInformation {
Name: string;
Guid: string;
When: Date;
Comment: string;
}
/**
* Interface that defines and information about an entity in the system.
*/
export interface IPrincipal {
/**
* The guid of entity.
*/
Guid: string;
/**
* The name of entity.
*/
Name: string;
}
/**
* Inteface that defines the basic information about a container.
*/
export interface IBasicContainerInformation {
/**
* The name of container.
*/
Name: string;
/**
* The envelope id of container.
*/
Id: string;
/**
* The containe's type.
*/
Type: string;
}
/**
* Interface that defines a document's location information.
*/
export interface ILocationsModel {
/**
* An array of cabinets the document is a member of.
*/
Cabinets?: Array<IPrincipal>;
/**
* An array of repositories document is a member of.
*/
Repositories?: Array<IPrincipal>;
/**
* An array of containers the document can be found in.
*/
Containers?: Array<IBasicContainerInformation>;
/**
* The URL of document.
*/
Url?: string;
/**
* The email address of the document.
*/
Email?: string;
}
/** Subclass containing field specific sorting information */
export interface ISorting {
Field: number;
Direction: string;
UseMvpSorting: boolean;
ToString?(): string;
}
/** Subclass containing field specific sorting information */
export interface ISortingInfo {
All: Array<ISorting>;
Documents: Array<ISorting>;
Email: Array<ISorting>;
}
/** Subclass of container specific information associated with this document if it is a container. */
export interface IContainerModel {
Description: string;
TopLevel: boolean;
Synced: boolean;
SyncedSub: boolean;
Type: string | ContainerType;
Sorting: ISortingInfo;
Criteria?: ISearchCriteria;
}
/** Subclass of saved search container specific information */
export interface ISearchCriteria {
SingleCabinetSearch?: boolean;
DeletedItemsSearch?: boolean;
AllActiveCabinetsSearch?: boolean;
DocIdsSearch?: boolean;
QueryString?: string;
ParsedCriteria?: IParsedCriteria;
}
/** More Detailed breakdown of criteria string for easier use in UI */
export interface IParsedCriteria {
FullCriteria?: string;
CabinetsScope?: Array<string>;
RepositoriesScope?: Array<string>;
CriteriaWithoutScope?: string;
IsDeletedItemsSearch?: boolean;
}
export interface IndList {
label: string;
hoverTip?: string;
}
export interface IElementDimension {
offsetTop: number;
offsetBottom?: number;
offsetLeft: number;
offsetRight?: number;
offsetWidth: number;
offsetHeight: number;
marginTop: number;
x?: number;
y?: number;
}
/**
* This interface represents basic user information.
* Directly mapss to UserModel on the server side.
*/
export interface IUserInfo {
/**
* The user's guid. eg: VAULT-A1B2C3
*/
Guid: string;
/**
* The user's first or given name.
*/
FirstName: string;
/**
* The user's last or surname.
*/
LastName: string;
/**
* The user's middle initial.
*/
Initial: string;
/**
* The user's email address
*/
Email: string;
/**
* The list of groups user is member of.
*/
Groups: Array<string>;
/**
* The configured administrative user options.
*/
UserOptions: number;
}
/**
* This interface represents meta data about a user: his repository(s), cabinet(s), etc.
*/
export interface IMembership {
/**
* Repository collection
*/
Repositories: Array<IRepositoryData>;
/**
* User information
*/
UserInfo: IUserInfo;
}
/**
* Interface that defines what repository consists of.
*/
export interface IRepositoryData {
/**
* Repository guid (unique identifier); CA-M15VJWNS, for example.
*/
Guid: string;
/**
* Repository name
*/
Name: string;
/**
* Admin type
*/
AdminType: RepositoryAdminType;
/**
* User type
*/
UserType: UserType;
/**
* Repository options
*/
Options: number;
/**
* Repository options2
*/
Options2: number;
/**
* Custom Attributes
*/
CustomAttributes: Array<ICustomAttributeDefinition>;
/**
* Collection of cabinet data.
*/
Cabinets: Array<ICabinetData>;
/**
* Blockchain integration is enabled.
*/
BlockchainIntegration: boolean;
/**
* Analitycs configuration.
*/
Analytics: IAnalyticsConfiguration;
}
/**
Interface that defines analytics configuration.
*/
export interface IAnalyticsConfiguration {
/**
* Analytics enabled or not - boolean.
*/
IsAnalyticsEnabled: boolean;
/**
* NdAnalytics reports endpoint.
*/
ReportsUrl?: string;
/**
* NdAnalytics administration endpoint.
*/
AdminUrl?: string;
/**
* NdAnalytics application OAuth client ID.
*/
ClientId?: string;
}
/**
* Subclass of cabinet data
*/
export interface ICabinetData extends IPrincipal {
RepositoryName: string;
/**
* Cabinet admin
*/
AdminType: CabinetAdminType;
/**
* Cabinet options
*/
Options: number;
/**
* Primary cabinet
*/
DefaultCabinet: boolean;
/**
* Base attribute number
*/
WorkspaceAttribute?: number;
/**
* Base attribute plural name
*/
WorkSpacePluralName?: string;
/**
* Recent workspaces collection
*/
RecentWorkspaces?: Array<IDocumentModel>;
/**
* Favorite workspaces collection
*/
FavoriteWorkspaces?: Array<IDocumentModel>;
/**
* Folders collection (if workspaces are enabled in this cabinet)
*/
Folders?: Array<IDocumentModel>;
/**
* CollaborationSpaces collection
*/
CollaborationSpaces?: Array<IDocumentModel>;
/**
* Attributes marked for use in this cabinet
*/
CustomAttributes?: Array<number>;
/**
* Workspace name format (pattern)
*/
WorkspaceNameFormat?: string;
/**
* Determine whether collaboration space feature is enabled for current cabinet.
*/
IsCollaborationSpaceEnabled: boolean;
}
/** NavigationPanePinnedModel interface */
export interface INavigationPanePinnedModel {
Pinned: boolean;
}
/** PrimaryCabinetModel interface */
export interface IPrimaryCabinetModel {
CabinetGuid: string;
}
/** ListviewLayout interface */
export interface IListviewLayout {
dummy: string;
}
/** BrowserCache interface */
export interface IBrowserCache<T> {
xt: string;
Value: T;
}
/**
* Ancestry interface
*/
export interface IAncestry {
ancestors: IAncestor[];
root: IAncestor;
isDeleted: boolean;
}
/**
* Ancestor interface
*/
export interface IAncestor extends IBasicContainerInformation {
url?: string;
elementId?: string;
/**
* True if ancestor is not real and added manually.
*/
customAncestry?: boolean;
/**
* True if breadcrumb was search container and we shouldn't reload breadcrumb.
* Used only on UI.
*/
inSearchMode?: boolean;
/**
* Contains the code (and description) of the base (and link) attribute(s) of a workspace
*/
workspaceAttributes?: IWorkspaceAttributes;
}
/**
* Interface defining AncestryService.
*/
export interface IAncestryService {
/**
* The root URL that the ancestry applies to.
* @property {string}
*/
rootUrl: string;
/**
* The title of the root, this may not be a container and therefor the root URL may not exist.
* This occurs when navigating to pages like "Advanced Search"
* @property {string}
*/
rootTitle: string;
/**
* Makes a rest API call to get the current ancestry based on the rootUrl.
*/
getAncestry(): void;
/** getAncestry.
* @return Get the IAncestry as an Observable.
*/
Observable(): Observable<IAncestry>;
/**
* Updates the ancestry object.
* @return
*/
Update(ancestry: IAncestry): void;
/**
* Fetches the current snapshot of IAncestry.
* @return
*/
Snapshot(): IAncestry;
/**
* Sets the root of the ancestry service from the global values or the provided values.
* @return
*/
setRoot(rootUrl?: string, rootTitle?: string): Object;
}
/** Generic data service interface */
export interface IDataService<T> {
/**
* Fetches the data service's object that can be used to observe changes to the 'data'.
* @returns Returns the data service's observable object.
*/
Observable(): Observable<T>;
/**
* Fetchs a snapshot (copy) of the current data value.
*/
Snapshot(): T;
/**
* Assigns a new value to the 'data' object. Observers will be notified of value changes.
* @param value The new data value.
*/
Update(T: any): void;
}
/** Navigate browser to another page */
export interface IRedirect {
}
/**
* Request used when adding or removing favorite items
*/
export interface IFavoritesRequest {
/**
* Id of item to be added or removed from favorites
*/
Id: string;
/**
* Action type to perform add | remove
*/
Action: string;
/**
* If id is a workspace where to put in work space favorites list, if not a workspace what section of the homepage
*/
Target: string;
/**
* Only applies when id is a workspace then whether the new item goes before the target.
*/
Before: string;
}
/** IAutocompleteAttribute interface */
export interface IAutocompleteAttribute {
isParent: boolean;
key: string;
description: string;
fullDescription: string;
parentKey: string;
parentDesc: string;
parentFullDescription: string;
}
/**
* Document used when changing it's favorite status
*/
export interface IFavoriteDocumentModel {
/** Envelope id of item to be added or removed from favorites; eg: :q1:a:b:c:d:~160504112345678.nev|1 */
EnvId: string;
/** If value is true - document status is favorite, false - document status isn't favorite */
IsFavorite: boolean;
}
/**
* Info about results.
*/
export interface IResultsInfo {
/**
* total number of results.
*/
total?: number;
/**
* isPrecise is true when all results are loaded.
*/
isPrecise?: boolean;
}
/**
* Document attribute code and description
*/
export interface IDocumentAttribute {
code: string;
description: string;
}
/**
* Workspace base (and link) attribute(s)
*/
export interface IWorkspaceAttributes {
baseAttribute: IDocumentAttribute;
linkAttribute: IDocumentAttribute;
}
/**
* used to convert dates like mm/dd/YYYY to julian date
*/
declare global {
interface Date {
ToJulian(): number;
}
interface String {
GetRelativeDate(): Date;
}
interface Number {
JulianDayToDate(): Date;
}
}