nakedobjects.spa
Version:
Single Page Application client for a Naked Objects application.
649 lines (648 loc) • 25.9 kB
TypeScript
/// <reference types="lodash" />
import * as Ro from './ro-interfaces';
import * as RoCustom from './ro-interfaces-custom';
import { Dictionary } from 'lodash';
export declare function withNull<T>(v: T | undefined | null): T | null;
export declare function withUndefined<T>(v: T | undefined | null): T | undefined;
export declare function checkNotNull<T>(v: T | undefined | null): T;
export declare function toDateString(dt: Date): string;
export declare function toDateTimeString(dt: Date): string;
export declare function toTimeString(dt: Date): string;
export declare function getTime(rawTime: string): Date | null;
export declare function isDate(rep: IHasExtensions): boolean;
export declare function isDateTime(rep: IHasExtensions): boolean;
export declare function isDateOrDateTime(rep: IHasExtensions): boolean;
export declare function isTime(rep: IHasExtensions): boolean;
export declare function toTime(value: Value): Date | null;
export declare function toUtcDate(value: Value): Date | null;
export declare function getUtcDate(rawDate: string): Date | null;
export declare function compress(toCompress: string, shortCutMarker: string, urlShortCuts: string[]): string;
export declare function decompress(toDecompress: string, shortCutMarker: string, urlShortCuts: string[]): string;
export declare function getClassName(obj: any): string;
export declare function typeFromUrl(url: string): string;
export declare function idFromUrl(href: string): string;
export declare function propertyIdFromUrl(href: string): string;
export declare function friendlyTypeName(fullName: string): string;
export declare function friendlyNameForParam(action: ActionRepresentation | InvokableActionMember, parmId: string): string;
export declare function friendlyNameForProperty(obj: DomainObjectRepresentation, propId: string): string;
export declare function typePlusTitle(obj: DomainObjectRepresentation): string;
export declare function isResourceRepresentation(object: any): object is Ro.IResourceRepresentation;
export declare function isErrorRepresentation(object: any): object is Ro.IErrorRepresentation;
export declare function isIDomainObjectRepresentation(object: any): object is Ro.IDomainObjectRepresentation;
export interface IHateoasModel {
etagDigest?: string;
hateoasUrl: string;
method: Ro.HttpMethodsType;
populate(wrapped: Ro.IRepresentation): void;
getBody(): Ro.IRepresentation;
getUrl(): string;
keySeparator: string;
}
export declare enum ErrorCategory {
HttpClientError = 0,
HttpServerError = 1,
ClientError = 2,
}
export declare enum HttpStatusCode {
NoContent = 204,
BadRequest = 400,
Unauthorized = 401,
Forbidden = 403,
NotFound = 404,
MethodNotAllowed = 405,
NotAcceptable = 406,
PreconditionFailed = 412,
UnprocessableEntity = 422,
PreconditionRequired = 428,
InternalServerError = 500,
}
export declare enum ClientErrorCode {
ExpiredTransient = 0,
WrongType = 1,
NotImplemented = 2,
SoftwareError = 3,
ConnectionProblem = 0,
}
export declare class ErrorWrapper {
readonly category: ErrorCategory;
readonly originalUrl: string;
constructor(category: ErrorCategory, code: HttpStatusCode | ClientErrorCode, err: string | ErrorMap | ErrorRepresentation, originalUrl?: string);
title: string;
description: string;
errorCode: string;
httpErrorCode: HttpStatusCode;
clientErrorCode: ClientErrorCode;
message: string;
error: ErrorMap | ErrorRepresentation | null;
stackTrace: string[];
handled: boolean;
}
export declare class ObjectIdWrapper {
private readonly keySeparator;
constructor(keySeparator: string);
domainType: string;
instanceId: string;
splitInstanceId: string[];
isService: boolean;
getKey(): string;
static safeSplit(id: string, keySeparator: string): string[];
static fromObject(object: DomainObjectRepresentation): ObjectIdWrapper;
static fromLink(link: Link, keySeparator: string): ObjectIdWrapper;
static fromHref(href: string, keySeparator: string): ObjectIdWrapper;
static fromObjectId(objectId: string, keySeparator: string): ObjectIdWrapper;
static fromRaw(dt: string, id: string, keySeparator: string): ObjectIdWrapper;
static fromSplitRaw(dt: string, id: string[], keySeparator: string): ObjectIdWrapper;
isSame(other: ObjectIdWrapper): boolean;
}
export declare abstract class HateosModel implements IHateoasModel {
protected model: Ro.IRepresentation;
etagDigest?: string;
hateoasUrl: string;
method: Ro.HttpMethodsType;
urlParms: Dictionary<Object>;
keySeparator: string;
protected constructor(model?: Ro.IRepresentation);
populate(model: Ro.IRepresentation): void;
getBody(): Ro.IRepresentation;
getUrl(): string;
setUrlParameter(name: string, value: Object): void;
}
export declare abstract class ArgumentMap extends HateosModel {
map: Ro.IValueMap;
id: string;
protected constructor(map: Ro.IValueMap, id: string);
populate(wrapped: Ro.IValueMap): void;
}
export declare abstract class NestedRepresentation<T extends Ro.IResourceRepresentation> {
private model;
protected resource: () => T;
protected constructor(model: T);
private lazyLinks;
links(): Link[];
protected update(newResource: T): void;
private lazyExtensions;
extensions(): Extensions;
}
export declare class RelParm {
asString: string;
name: string | undefined;
value: string | undefined;
constructor(asString: string);
private decomposeParm();
}
export declare class Rel {
asString: string;
ns: string;
uniqueValue: string;
parms: RelParm[];
constructor(asString: string);
private decomposeRel();
}
export declare class MediaType {
asString: string;
applicationType: string;
profile: string;
xRoDomainType: string;
representationType: string;
domainType: string;
constructor(asString: string);
private decomposeMediaType();
}
export declare class Value {
private wrapped;
constructor(raw: Link | (Link | Ro.ValueType | Value)[] | Ro.ValueType | Blob | Value);
isBlob(): boolean;
isScalar(): boolean;
isReference(): boolean;
isFileReference(): boolean;
isList(): boolean;
isNull(): boolean;
blob(): Blob | null;
link(): Link | null;
getHref(): string | null;
scalar(): Ro.ScalarValueType;
list(): Value[] | null;
toString(): string;
private compress(shortCutMarker, urlShortCuts);
private decompress(shortCutMarker, urlShortCuts);
static fromJsonString(jsonString: string, shortCutMarker: string, urlShortCuts: string[]): Value;
toValueString(): string;
toJsonString(shortCutMarker: string, urlShortCuts: string[]): string;
setValue(target: Ro.IValue): void;
set(target: Dictionary<Ro.IValue | string>, name: string): void;
}
export declare class ErrorValue {
value: Value;
invalidReason: string | null;
constructor(value: Value, invalidReason: string | null);
}
export declare class Result {
readonly wrapped: Ro.IDomainObjectRepresentation | RoCustom.ICustomListRepresentation | Ro.IScalarValueRepresentation | null;
private readonly resultType;
constructor(wrapped: Ro.IDomainObjectRepresentation | RoCustom.ICustomListRepresentation | Ro.IScalarValueRepresentation | null, resultType: Ro.ResultTypeType);
object(): DomainObjectRepresentation | null;
list(): ListRepresentation | null;
scalar(): ScalarValueRepresentation | null;
isNull(): boolean;
isVoid(): boolean;
}
export declare class ErrorMap {
private readonly map;
statusCode: number;
warningMessage: string;
wrapped: () => Ro.IValueMap;
constructor(map: Ro.IValueMap | Ro.IObjectOfType, statusCode: number, warningMessage: string);
valuesMap(): Dictionary<ErrorValue>;
invalidReason(): string;
containsError(): boolean;
}
export declare class UpdateMap extends ArgumentMap implements IHateoasModel {
private readonly domainObject;
constructor(domainObject: DomainObjectRepresentation, map: Ro.IValueMap);
properties(): Dictionary<Value>;
setProperty(name: string, value: Value): void;
setValidateOnly(): void;
}
export declare class AddToRemoveFromMap extends ArgumentMap implements IHateoasModel {
private readonly collectionResource;
constructor(collectionResource: CollectionRepresentation, map: Ro.IValueMap, add: boolean);
}
export declare class ModifyMap extends ArgumentMap implements IHateoasModel {
private readonly propertyResource;
constructor(propertyResource: PropertyRepresentation | PropertyMember, map: Ro.IValueMap);
}
export declare class ClearMap extends ArgumentMap implements IHateoasModel {
constructor(propertyResource: PropertyRepresentation | PropertyMember);
}
export declare abstract class ResourceRepresentation<T extends Ro.IResourceRepresentation> extends HateosModel {
protected resource: () => T;
populate(wrapped: T): void;
private lazyLinks;
links(): Link[];
private lazyExtensions;
extensions(): Extensions;
}
export declare class Extensions {
private wrapped;
constructor(wrapped: RoCustom.ICustomExtensions);
friendlyName: () => string;
description: () => string;
returnType: () => string | null;
optional: () => boolean;
hasParams: () => boolean;
elementType: () => string | null;
domainType: () => string | null;
pluralName: () => string;
format: () => "string" | "time" | "blob" | "date-time" | "date" | "utc-millisec" | "big-integer" | "big-decimal" | "clob" | "decimal" | "int" | undefined;
memberOrder: () => number | undefined;
isService: () => boolean;
minLength: () => number | undefined;
maxLength: () => number | undefined;
pattern: () => string | undefined;
choices: () => {
[index: string]: Ro.ValueType[];
};
menuPath: () => string;
mask: () => string;
tableViewTitle: () => boolean;
tableViewColumns: () => string[];
multipleLines: () => number;
warnings: () => string[];
messages: () => string[];
interactionMode: () => string;
dataType: () => string;
range: () => RoCustom.IRange;
notNavigable: () => boolean;
renderEagerly: () => boolean;
presentationHint: () => string;
}
export declare class InvokeMap extends ArgumentMap implements IHateoasModel {
private readonly link;
constructor(link: Link);
setParameter(name: string, value: Value): void;
}
export declare class ActionResultRepresentation extends ResourceRepresentation<Ro.IActionInvokeRepresentation> {
wrapped: () => Ro.IActionInvokeRepresentation;
constructor();
selfLink(): Link | null;
getSelf(): ActionResultRepresentation | null;
resultType(): Ro.ResultTypeType;
result(): Result;
warningsOrMessages(): string | undefined;
shouldExpectResult(): boolean;
}
export interface IHasExtensions {
extensions(): Extensions;
}
export interface IField extends IHasExtensions {
id(): string;
choices(): Dictionary<Value> | null;
isScalar(): boolean;
isCollectionContributed(): boolean;
entryType(): EntryType;
getPromptMap(): PromptMap | null;
promptLink(): Link | null;
}
export declare class Parameter extends NestedRepresentation<Ro.IParameterRepresentation> implements IField {
parent: ActionMember | ActionRepresentation;
private readonly paramId;
wrapped: () => Ro.IParameterRepresentation;
constructor(wrapped: Ro.IParameterRepresentation, parent: ActionMember | ActionRepresentation, paramId: string);
id(): string;
choices(): Dictionary<Value> | null;
promptLink(): Link | null;
getPromptMap(): PromptMap | null;
default(): Value;
isScalar(): boolean;
isList(): boolean;
private hasPrompt();
isCollectionContributed(): boolean;
private hasChoices();
entryType(): EntryType;
}
export declare class ActionRepresentation extends ResourceRepresentation<Ro.IActionRepresentation> {
wrapped: () => Ro.IActionRepresentation;
parent: IHasActions;
selfLink(): Link;
upLink(): Link;
invokeLink(): Link | null;
getSelf(): ActionRepresentation;
getUp(): DomainObjectRepresentation;
getInvokeMap(): InvokeMap | null;
actionId(): string;
private parameterMap;
private initParameterMap();
parameters(): Dictionary<Parameter>;
disabledReason(): string;
isQueryOnly(): boolean;
isNotQueryOnly(): boolean;
isPotent(): boolean;
}
export declare class PromptMap extends ArgumentMap implements IHateoasModel {
private readonly link;
private readonly promptId;
constructor(link: Link, promptId: string);
private promptMap();
setSearchTerm(term: string): void;
setArgument(name: string, val: Value): void;
setArguments(args: Dictionary<Value>): void;
setMember(name: string, value: Value): void;
setMembers(objectValues: () => Dictionary<Value>): void;
}
export declare class PromptRepresentation extends ResourceRepresentation<Ro.IPromptRepresentation> {
wrapped: () => Ro.IPromptRepresentation;
constructor();
selfLink(): Link;
upLink(): Link;
getSelf(): PromptRepresentation;
getUp(): DomainObjectRepresentation;
instanceId(): string;
choices(addEmpty: boolean): Dictionary<Value> | null;
}
export declare class CollectionRepresentation extends ResourceRepresentation<RoCustom.ICustomCollectionRepresentation> implements IHasActions {
wrapped: () => RoCustom.ICustomCollectionRepresentation;
selfLink(): Link;
upLink(): Link;
addToLink(): Link | null;
removeFromLink(): Link | null;
getSelf(): CollectionRepresentation;
getUp(): DomainObjectRepresentation;
setFromMap(map: AddToRemoveFromMap): void;
private addToMap();
getAddToMap(): AddToRemoveFromMap | null;
private removeFromMap();
getRemoveFromMap(): AddToRemoveFromMap | null;
collectionId(): string;
size(): number;
private lazyValue;
value(): Link[];
disabledReason(): string;
hasTableData: () => boolean;
private actionMemberMap;
actionMembers(): Dictionary<ActionMember>;
actionMember(id: string): ActionMember;
hasActionMember(id: string): boolean;
}
export declare class PropertyRepresentation extends ResourceRepresentation<Ro.IPropertyRepresentation> {
wrapped: () => Ro.IPropertyRepresentation;
modifyLink(): Link | null;
clearLink(): Link | null;
selfLink(): Link;
upLink(): Link;
promptLink(): Link | null;
private modifyMap();
getSelf(): PropertyRepresentation;
getUp(): DomainObjectRepresentation;
setFromModifyMap(map: ModifyMap): void;
getModifyMap(): ModifyMap | null;
getClearMap(): ClearMap | null;
instanceId(): string;
value(): Value;
choices(): Dictionary<Value> | null;
disabledReason(): string;
isScalar(): boolean;
hasPrompt(): boolean;
}
export declare class Member<T extends Ro.IMember> extends NestedRepresentation<Ro.IMember> {
wrapped: () => Ro.IMember;
constructor(wrapped: T);
update(newValue: Ro.IMember): void;
memberType(): Ro.MemberTypeType;
detailsLink(): Link | null;
disabledReason(): string;
isScalar(): boolean;
static wrapLinkMember(toWrap: Ro.IPropertyMember | Ro.ICollectionMember, parent: Link, id: string): PropertyMember | CollectionMember;
static wrapMember(toWrap: Ro.IPropertyMember | Ro.ICollectionMember | Ro.IActionMember, parent: DomainObjectRepresentation | IHasActions, id: string): Member<Ro.IMember>;
}
export declare class PropertyMember extends Member<Ro.IPropertyMember> implements IField {
parent: DomainObjectRepresentation | Link;
private readonly propId;
wrapped: () => Ro.IPropertyMember;
constructor(wrapped: Ro.IPropertyMember, parent: DomainObjectRepresentation | Link, propId: string);
id(): string;
modifyLink(): Link | null;
clearLink(): Link | null;
private modifyMap();
setFromModifyMap(map: ModifyMap): void;
getModifyMap(id: string): ModifyMap | null;
getClearMap(id: string): ClearMap | null;
getPromptMap(): PromptMap | null;
value(): Value;
isScalar(): boolean;
attachmentLink(): Link | null;
promptLink(): Link | null;
getDetails(): PropertyRepresentation | null;
private hasChoices();
private hasPrompt();
choices(): Dictionary<Value> | null;
private hasConditionalChoices();
isCollectionContributed(): boolean;
entryType(): EntryType;
}
export declare class CollectionMember extends Member<RoCustom.ICustomCollectionMember> implements IHasLinksAsValue, IHasActions {
parent: DomainObjectRepresentation | Link;
private readonly id;
wrapped: () => RoCustom.ICustomCollectionMember;
constructor(wrapped: Ro.ICollectionMember, parent: DomainObjectRepresentation | Link, id: string);
collectionId(): string;
private lazyValue;
value(): Link[] | null;
size(): number | null;
getDetails(): CollectionRepresentation | null;
hasTableData: () => boolean | null;
private actionMemberMap;
actionMembers(): Dictionary<ActionMember>;
hasActionMember(id: string): boolean;
actionMember(id: string): ActionMember;
etagDigest?: string;
}
export declare class ActionMember extends Member<Ro.IActionMember> {
parent: IHasActions;
private readonly id;
wrapped: () => Ro.IActionMember;
constructor(wrapped: Ro.IActionMember, parent: IHasActions, id: string);
actionId(): string;
getDetails(): ActionRepresentation | null;
invokeLink(): Link | null;
disabledReason(): string;
}
export declare class InvokableActionMember extends ActionMember {
constructor(wrapped: Ro.IActionMember, parent: IHasActions, id: string);
getInvokeMap(): InvokeMap | null;
isQueryOnly(): boolean;
isNotQueryOnly(): boolean;
isPotent(): boolean;
private parameterMap;
private initParameterMap();
parameters(): Dictionary<Parameter>;
}
export declare class DomainObjectRepresentation extends ResourceRepresentation<Ro.IDomainObjectRepresentation> implements IHasActions {
wrapped: () => Ro.IDomainObjectRepresentation;
constructor(model?: Ro.IRepresentation);
id(): string;
title(): string;
domainType(): string | null;
serviceId(): string | null;
instanceId(): string | null;
private memberMap;
private propertyMemberMap;
private collectionMemberMap;
private actionMemberMap;
private resetMemberMaps();
private initMemberMaps();
members(): Dictionary<Member<Ro.IMember>>;
propertyMembers(): Dictionary<PropertyMember>;
collectionMembers(): Dictionary<CollectionMember>;
actionMembers(): Dictionary<ActionMember>;
member(id: string): Member<Ro.IMember>;
propertyMember(id: string): PropertyMember;
collectionMember(id: string): CollectionMember;
hasActionMember(id: string): boolean;
actionMember(id: string): ActionMember;
updateLink(): Link | null;
isTransient(): boolean;
persistLink(): Link | null;
selfLink(): Link | null;
private updateMap();
private persistMap();
getSelf(): DomainObjectRepresentation | null;
getPersistMap(): PersistMap;
getUpdateMap(): UpdateMap;
setInlinePropertyDetails(flag: boolean): void;
private oid;
getOid(): ObjectIdWrapper;
updateSelfLinkWithTitle(): Link | null;
}
export declare class MenuRepresentation extends ResourceRepresentation<RoCustom.IMenuRepresentation> implements IHasActions {
wrapped: () => RoCustom.IMenuRepresentation;
constructor();
title(): string;
menuId(): string;
private memberMap;
private actionMemberMap;
private resetMemberMaps();
private initMemberMaps();
members(): Dictionary<Member<Ro.IMember>>;
actionMembers(): Dictionary<ActionMember>;
member(id: string): Member<Ro.IMember>;
hasActionMember(id: string): boolean;
actionMember(id: string): ActionMember;
selfLink(): Link;
getSelf(): MenuRepresentation;
}
export declare class ScalarValueRepresentation extends NestedRepresentation<Ro.IScalarValueRepresentation> {
wrapped: () => Ro.IScalarValueRepresentation;
constructor(wrapped: Ro.IScalarValueRepresentation);
value(): Value;
}
export declare class ListRepresentation extends ResourceRepresentation<RoCustom.ICustomListRepresentation> implements IHasLinksAsValue, IHasActions {
constructor(model?: Ro.IRepresentation);
wrapped: () => RoCustom.ICustomListRepresentation;
selfLink(): Link;
getSelf(): ListRepresentation;
private lazyValue;
value(): Link[];
pagination(): RoCustom.IPagination | null;
private actionMemberMap;
actionMembers(): Dictionary<ActionMember>;
actionMember(id: string): ActionMember;
hasActionMember(id: string): boolean;
hasTableData: () => boolean;
}
export interface IErrorDetails {
message(): string;
stackTrace(): string[];
}
export declare class ErrorRepresentation extends ResourceRepresentation<Ro.IErrorRepresentation> implements IErrorDetails {
constructor();
wrapped: () => Ro.IErrorRepresentation;
static create(message: string, stackTrace?: string[], causedBy?: Ro.IErrorDetailsRepresentation): ErrorRepresentation;
message(): string;
stackTrace(): string[];
causedBy(): IErrorDetails | undefined;
}
export declare class PersistMap extends HateosModel implements IHateoasModel {
private readonly domainObject;
private readonly map;
constructor(domainObject: DomainObjectRepresentation, map: Ro.IObjectOfType);
setMember(name: string, value: Value): void;
setValidateOnly(): void;
}
export declare class VersionRepresentation extends ResourceRepresentation<Ro.IVersionRepresentation> {
wrapped: () => Ro.IVersionRepresentation;
selfLink(): Link;
upLink(): Link;
getSelf(): VersionRepresentation;
getUp(): HomePageRepresentation;
specVersion(): string;
implVersion(): string | null;
optionalCapabilities(): Ro.IOptionalCapabilities;
}
export declare class DomainServicesRepresentation extends ListRepresentation {
wrapped: () => RoCustom.ICustomListRepresentation;
upLink(): Link;
getSelf(): DomainServicesRepresentation;
getUp(): HomePageRepresentation;
getService(serviceType: string): DomainObjectRepresentation | null;
}
export declare class MenusRepresentation extends ListRepresentation {
wrapped: () => RoCustom.ICustomListRepresentation;
upLink(): Link;
getSelf(): MenusRepresentation;
getUp(): HomePageRepresentation;
getMenu(menuId: string): MenuRepresentation | undefined;
}
export declare class UserRepresentation extends ResourceRepresentation<Ro.IUserRepresentation> {
wrapped: () => Ro.IUserRepresentation;
selfLink(): Link;
upLink(): Link;
getSelf(): UserRepresentation;
getUp(): HomePageRepresentation;
userName(): string;
friendlyName(): string;
email(): string;
roles(): string[];
}
export declare class DomainTypeActionInvokeRepresentation extends ResourceRepresentation<Ro.IDomainTypeActionInvokeRepresentation> {
wrapped: () => Ro.IDomainTypeActionInvokeRepresentation;
constructor(againstType: string, toCheckType: string, appPath: string);
selfLink(): Link;
getSelf(): DomainTypeActionInvokeRepresentation;
id(): string;
value(): boolean;
}
export declare class HomePageRepresentation extends ResourceRepresentation<Ro.IHomePageRepresentation> {
constructor(rep: Ro.IRepresentation, appPath: string);
wrapped: () => Ro.IHomePageRepresentation;
serviceLink(): Link;
userLink(): Link;
selfLink(): Link;
versionLink(): Link;
menusLink(): Link;
getSelf(): HomePageRepresentation;
getUser(): UserRepresentation;
getDomainServices(): DomainServicesRepresentation;
getVersion(): VersionRepresentation;
getMenus(): MenusRepresentation;
}
export declare class Link {
wrapped: Ro.ILink;
constructor(wrapped: Ro.ILink);
compress(shortCutMarker: string, urlShortCuts: string[]): Link;
decompress(shortCutMarker: string, urlShortCuts: string[]): Link;
href(): string;
method(): Ro.HttpMethodsType;
rel(): Rel;
type(): MediaType;
title(): string | null;
setTitle(title: string): void;
arguments(): Ro.IValue | Ro.IValueMap | Ro.IObjectOfType | Ro.IPromptMap | null;
members(): Dictionary<PropertyMember | CollectionMember> | null;
private lazyExtensions;
extensions(): Extensions;
copyToHateoasModel(hateoasModel: IHateoasModel): void;
private getHateoasTarget(targetType);
private repTypeToModel;
getTarget(): IHateoasModel;
getTargetAs<T extends IHateoasModel>(): T;
private oid;
getOid(keySeparator: string): ObjectIdWrapper;
}
export interface IHasActions extends IHasExtensions {
actionMembers(): Dictionary<ActionMember>;
actionMember(id: string): ActionMember;
hasActionMember(id: string): boolean;
etagDigest?: string;
}
export interface IHasLinksAsValue {
value(): Link[] | null;
}
export declare enum EntryType {
FreeForm = 0,
Choices = 1,
MultipleChoices = 2,
ConditionalChoices = 3,
MultipleConditionalChoices = 4,
AutoComplete = 5,
File = 6,
}