-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservicestack-client.d.ts
536 lines (536 loc) · 19.8 KB
/
servicestack-client.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
export interface IReturnVoid {
createResponse(): any;
}
export interface IReturn<T> {
createResponse(): T;
}
export declare class ResponseStatus {
constructor(init?: Partial<ResponseStatus>);
errorCode: string;
message: string;
stackTrace: string;
errors: ResponseError[];
meta: {
[index: string]: string;
};
}
export declare class ResponseError {
constructor(init?: Partial<ResponseError>);
errorCode: string;
fieldName: string;
message: string;
meta: {
[index: string]: string;
};
}
export declare class ErrorResponse {
constructor(init?: Partial<ErrorResponse>);
type: ErrorResponseType;
responseStatus: ResponseStatus;
}
export declare class NavItem {
label: string;
href: string;
exact: boolean;
id: string;
className: string;
iconClass: string;
show: string;
hide: string;
children: NavItem[];
meta: {
[index: string]: string;
};
constructor(init?: Partial<NavItem>);
}
export declare class GetNavItems {
constructor(init?: Partial<GetNavItems>);
createResponse(): GetNavItemsResponse;
getTypeName(): string;
}
export declare class GetNavItemsResponse {
baseUrl: string;
results: NavItem[];
navItemsMap: {
[index: string]: NavItem[];
};
meta: {
[index: string]: string;
};
responseStatus: ResponseStatus;
constructor(init?: Partial<GetNavItemsResponse>);
}
export declare type ErrorResponseType = null | "RefreshTokenException";
export interface IAuthSession {
userName: string;
displayName: string;
userId?: string;
roles?: string[];
permissions?: string[];
profileUrl?: string;
}
export interface IResolver {
tryResolve(Function: any): any;
}
export declare class NewInstanceResolver implements IResolver {
tryResolve(ctor: ObjectConstructor): any;
}
export declare class SingletonInstanceResolver implements IResolver {
tryResolve(ctor: ObjectConstructor): any;
}
export interface ServerEventMessage {
type: "ServerEventConnect" | "ServerEventHeartbeat" | "ServerEventJoin" | "ServerEventLeave" | "ServerEventUpdate" | "ServerEventMessage";
eventId: number;
channel: string;
data: string;
selector: string;
json: string;
op: string;
target: string;
cssSelector: string;
body: any;
meta: {
[index: string]: string;
};
}
export interface ServerEventCommand extends ServerEventMessage {
userId: string;
displayName: string;
channels: string;
profileUrl: string;
}
export interface ServerEventConnect extends ServerEventCommand {
id: string;
unRegisterUrl: string;
heartbeatUrl: string;
updateSubscriberUrl: string;
heartbeatIntervalMs: number;
idleTimeoutMs: number;
}
export interface ServerEventHeartbeat extends ServerEventCommand {
}
export interface ServerEventJoin extends ServerEventCommand {
}
export interface ServerEventLeave extends ServerEventCommand {
}
export interface ServerEventUpdate extends ServerEventCommand {
}
export interface IReconnectServerEventsOptions {
url?: string;
onerror?: (...args: any[]) => void;
onmessage?: (...args: any[]) => void;
error?: Error;
}
/**
* EventSource
*/
export declare enum ReadyState {
CONNECTING = 0,
OPEN = 1,
CLOSED = 2
}
export interface IEventSourceStatic extends EventTarget {
new (url: string, eventSourceInitDict?: IEventSourceInit): IEventSourceStatic;
url: string;
withCredentials: boolean;
CONNECTING: ReadyState;
OPEN: ReadyState;
CLOSED: ReadyState;
readyState: ReadyState;
onopen: Function;
onmessage: (event: IOnMessageEvent) => void;
onerror: Function;
close: () => void;
}
export interface IEventSourceInit {
withCredentials?: boolean;
}
export interface IOnMessageEvent {
data: string;
}
export interface IEventSourceOptions {
channels?: string;
handlers?: any;
receivers?: any;
onException?: Function;
onReconnect?: Function;
onTick?: Function;
resolver?: IResolver;
validate?: (request: ServerEventMessage) => boolean;
heartbeatUrl?: string;
unRegisterUrl?: string;
updateSubscriberUrl?: string;
heartbeatIntervalMs?: number;
heartbeat?: number;
resolveStreamUrl?: (url: string) => string;
}
export declare class ServerEventsClient {
channels: string[];
options: IEventSourceOptions;
eventSource: IEventSourceStatic;
static UnknownChannel: string;
eventStreamUri: string;
updateSubscriberUrl: string;
connectionInfo: ServerEventConnect;
serviceClient: JsonServiceClient;
stopped: boolean;
resolver: IResolver;
listeners: {
[index: string]: ((e: ServerEventMessage) => void)[];
};
EventSource: IEventSourceStatic;
withCredentials: boolean;
constructor(baseUrl: string, channels: string[], options?: IEventSourceOptions, eventSource?: IEventSourceStatic);
onMessage: (e: IOnMessageEvent) => void;
_onMessage: (e: IOnMessageEvent) => void;
onError: (error?: any) => void;
getEventSourceOptions(): {
withCredentials: boolean;
};
reconnectServerEvents(opt?: IReconnectServerEventsOptions): IEventSourceStatic;
start(): this;
stop(): Promise<void>;
invokeReceiver(r: any, cmd: string, el: Element, request: ServerEventMessage, name: string): void;
hasConnected(): boolean;
registerHandler(name: string, fn: Function): this;
setResolver(resolver: IResolver): this;
registerReceiver(receiver: any): this;
registerNamedReceiver(name: string, receiver: any): this;
unregisterReceiver(name?: string): this;
updateChannels(channels: string[]): void;
update(subscribe: string | string[], unsubscribe: string | string[]): void;
addListener(eventName: string, handler: ((e: ServerEventMessage) => void)): this;
removeListener(eventName: string, handler: ((e: ServerEventMessage) => void)): this;
raiseEvent(eventName: string, msg: ServerEventMessage): void;
getConnectionInfo(): ServerEventConnect;
getSubscriptionId(): string;
updateSubscriber(request: UpdateEventSubscriber): Promise<void>;
subscribeToChannels(...channels: string[]): Promise<void>;
unsubscribeFromChannels(...channels: string[]): Promise<void>;
getChannelSubscribers(): Promise<ServerEventUser[]>;
toServerEventUser(map: {
[id: string]: string;
}): ServerEventUser;
}
export interface IReceiver {
noSuchMethod(selector: string, message: any): any;
}
export declare class ServerEventReceiver implements IReceiver {
client: ServerEventsClient;
request: ServerEventMessage;
noSuchMethod(selector: string, message: any): void;
}
export declare class UpdateEventSubscriber implements IReturn<UpdateEventSubscriberResponse> {
id: string;
subscribeChannels: string[];
unsubscribeChannels: string[];
createResponse(): UpdateEventSubscriberResponse;
getTypeName(): string;
}
export declare class UpdateEventSubscriberResponse {
responseStatus: ResponseStatus;
}
export declare class GetEventSubscribers implements IReturn<any[]> {
channels: string[];
createResponse(): any[];
getTypeName(): string;
}
export declare class ServerEventUser {
userId: string;
displayName: string;
profileUrl: string;
channels: string[];
meta: {
[index: string]: string;
};
}
export declare class HttpMethods {
static Get: string;
static Post: string;
static Put: string;
static Delete: string;
static Patch: string;
static Head: string;
static Options: string;
static hasRequestBody: (method: string) => boolean;
}
export interface IRequestFilterOptions {
url: string;
}
export interface IRequestInit extends RequestInit {
url?: string;
compress?: boolean;
}
export interface Cookie {
name: string;
value: string;
path: string;
domain?: string;
expires?: Date;
httpOnly?: boolean;
secure?: boolean;
sameSite?: string;
}
export declare class GetAccessTokenResponse {
accessToken: string;
responseStatus: ResponseStatus;
}
export interface ISendRequest {
method: string;
request: any | null;
body?: any | null;
args?: any;
url?: string;
returns?: {
createResponse: () => any;
};
}
export declare class JsonServiceClient {
baseUrl: string;
replyBaseUrl: string;
oneWayBaseUrl: string;
mode: RequestMode;
credentials: RequestCredentials;
headers: Headers;
userName: string;
password: string;
bearerToken: string;
refreshToken: string;
refreshTokenUri: string;
useTokenCookie: boolean;
requestFilter: (req: IRequestInit) => void;
responseFilter: (res: Response) => void;
exceptionFilter: (res: Response, error: any) => void;
urlFilter: (url: string) => void;
onAuthenticationRequired: () => Promise<any>;
manageCookies: boolean;
cookies: {
[index: string]: Cookie;
};
parseJson: (res: Response) => Promise<any>;
static toBase64: (rawString: string) => string;
constructor(baseUrl?: string);
setCredentials(userName: string, password: string): void;
setBearerToken(token: string): void;
get<T>(request: IReturn<T> | string, args?: any): Promise<T>;
delete<T>(request: IReturn<T> | string, args?: any): Promise<T>;
post<T>(request: IReturn<T>, args?: any): Promise<T>;
postToUrl<T>(url: string, request: IReturn<T>, args?: any): Promise<T>;
postBody<T>(request: IReturn<T>, body: string | any, args?: any): Promise<T>;
put<T>(request: IReturn<T>, args?: any): Promise<T>;
putToUrl<T>(url: string, request: IReturn<T>, args?: any): Promise<T>;
putBody<T>(request: IReturn<T>, body: string | any, args?: any): Promise<T>;
patch<T>(request: IReturn<T>, args?: any): Promise<T>;
patchToUrl<T>(url: string, request: IReturn<T>, args?: any): Promise<T>;
patchBody<T>(request: IReturn<T>, body: string | any, args?: any): Promise<T>;
publish(request: IReturnVoid, args?: any): Promise<any>;
sendOneWay<T>(request: IReturn<T> | IReturnVoid, args?: any): Promise<T>;
sendAll<T>(requests: IReturn<T>[]): Promise<T[]>;
sendAllOneWay<T>(requests: IReturn<T>[]): Promise<void>;
createUrlFromDto<T>(method: string, request: IReturn<T>): string;
toAbsoluteUrl(relativeOrAbsoluteUrl: string): string;
deleteCookie(name: string): void;
private createRequest;
private json;
private createResponse;
private handleError;
send<T>(method: string, request: any | null, args?: any, url?: string): Promise<T>;
private sendBody;
sendRequest<T>(info: ISendRequest): Promise<T>;
raiseError(res: Response, error: any): any;
}
export declare function isFormData(body: any): boolean;
export declare function toCamelCase(s: string): string;
export declare function toPascalCase(s: string): string;
export declare function sanitize(status: any): any;
export declare function nameOf(o: any): any;
export declare function css(selector: string | NodeListOf<Element>, name: string, value: string): void;
export declare function splitOnFirst(s: string, c: string): string[];
export declare function splitOnLast(s: string, c: string): string[];
export declare function leftPart(s: string, needle: string): string;
export declare function rightPart(s: string, needle: string): string;
export declare function lastLeftPart(s: string, needle: string): string;
export declare function lastRightPart(s: string, needle: string): string;
export declare function chop(str: string, len?: number): string;
export declare function onlyProps(obj: {
[index: string]: any;
}, keys: string[]): {
[index: string]: any;
};
export declare function humanize(s: any): any;
export declare function queryString(url: string): any;
export declare function combinePaths(...paths: string[]): string;
export declare function createPath(route: string, args: any): string;
export declare function createUrl(route: string, args: any): string;
export declare function appendQueryString(url: string, args: any): string;
export declare function bytesToBase64(aBytes: Uint8Array): string;
export declare function stripQuotes(s: string): string;
export declare function tryDecode(s: string): string;
export declare function parseCookie(setCookie: string): Cookie;
export declare function normalizeKey(key: string): string;
export declare function normalize(dto: any, deep?: boolean): any;
export declare function getField(o: any, name: string): any;
export declare function parseResponseStatus(json: string, defaultMsg?: any): any;
export declare function toFormData(o: any): FormData;
export declare function toObject(keys: any): {};
export declare function errorResponseSummary(): any;
export declare function errorResponseExcept(fieldNames: string[] | string): any;
export declare function errorResponse(fieldName: string): any;
export declare function toDate(s: string | any): Date;
export declare function toDateFmt(s: string): string;
export declare function padInt(n: number): string | number;
export declare function dateFmt(d?: Date): string;
export declare function dateFmtHM(d?: Date): string;
export declare function timeFmt12(d?: Date): string;
export declare function toLocalISOString(d?: Date): string;
export interface ICreateElementOptions {
insertAfter?: Element | null;
}
export declare function createElement(tagName: string, options?: ICreateElementOptions, attrs?: any): HTMLElement;
export declare function bootstrap(el?: Element): void;
export interface IBindHandlersOptions {
events: string[];
}
export declare function bindHandlers(handlers: any, el?: Document | Element, opt?: IBindHandlersOptions): void;
export interface IAjaxFormOptions {
type?: string;
url?: string;
model?: any;
credentials?: RequestCredentials;
validate?: (this: HTMLFormElement) => boolean;
onSubmitDisable?: string;
submit?: (this: HTMLFormElement, options: IAjaxFormOptions) => Promise<any>;
success?: (this: HTMLFormElement, result: any) => void;
error?: (this: HTMLFormElement, e: any) => void;
complete?: (this: HTMLFormElement) => void;
requestFilter?: (req: IRequestInit) => void;
responseFilter?: (res: Response) => void;
errorFilter?: (this: IValidation, message: string, errorCode: string, type: string) => void;
messages?: {
[index: string]: string;
};
}
export declare function bootstrapForm(form: HTMLFormElement | null, options: IAjaxFormOptions): void;
export interface IValidation {
overrideMessages: boolean;
messages: {
[index: string]: string;
};
errorFilter?: (this: IValidation, message: string, errorCode: string, type: string) => void;
}
export declare function toVarNames(names: string[] | string | null): string[];
export declare function formSubmit(this: HTMLFormElement, options?: IAjaxFormOptions): Promise<any>;
export declare function ajaxSubmit(f: HTMLFormElement, options?: IAjaxFormOptions): any;
export declare function serializeForm(form: HTMLFormElement, contentType?: string | null): string | FormData;
export declare function serializeToObject(form: HTMLFormElement): any;
export declare function serializeToUrlEncoded(form: HTMLFormElement): string;
export declare function serializeToFormData(form: HTMLFormElement): FormData;
export declare function triggerEvent(el: Element, name: string, data?: any): void;
export declare function populateForm(form: HTMLFormElement, model: any): void;
export declare function trimEnd(s: string, c: string): string;
export declare function safeVarName(s: string): string;
export declare function pick(o: any, keys: string[]): {};
export declare function omit(o: any, keys: string[]): {};
export declare function activeClassNav(x: NavItem, activePath: string): string;
export declare function activeClass(href: string | null, activePath: string, exact?: boolean): string;
export declare const BootstrapColors: string[];
export declare function btnColorClass(props: any): string;
export declare const BootstrapSizes: string[];
export declare function btnSizeClass(props: any): string;
export declare function btnClasses(props: any): any[];
export declare class NavDefaults {
static navClass: string;
static navItemClass: string;
static navLinkClass: string;
static childNavItemClass: string;
static childNavLinkClass: string;
static childNavMenuClass: string;
static childNavMenuItemClass: string;
static create(): NavOptions;
static forNav(options?: NavOptions | null): NavOptions;
static overrideDefaults(targets: NavOptions | null | undefined, source: NavOptions): NavOptions;
static showNav(navItem: NavItem, attributes: string[]): boolean;
}
export declare class NavLinkDefaults {
static forNavLink(options?: NavOptions | null): NavOptions;
}
export declare class NavbarDefaults {
static navClass: string;
static create(): NavOptions;
static forNavbar(options?: NavOptions | null): NavOptions;
}
export declare class NavButtonGroupDefaults {
static navClass: string;
static navItemClass: string;
static create(): NavOptions;
static forNavButtonGroup(options?: NavOptions | null): NavOptions;
}
export declare class LinkButtonDefaults {
static navItemClass: string;
static create(): NavOptions;
static forLinkButton(options?: NavOptions | null): NavOptions;
}
export declare class UserAttributes {
static fromSession(session: IAuthSession | null): string[];
}
export declare class NavOptions {
static fromSession(session: IAuthSession | null, to?: NavOptions): NavOptions;
attributes: string[];
activePath?: string;
baseHref?: string;
navClass?: string;
navItemClass?: string;
navLinkClass?: string;
childNavItemClass?: string;
childNavLinkClass?: string;
childNavMenuClass?: string;
childNavMenuItemClass?: string;
constructor(init?: Partial<NavOptions>);
}
export declare function classNames(...args: any[]): string;
export declare function fromXsdDuration(xsd: string): number;
export declare function toXsdDuration(time: number): string;
export declare function toTimeSpanFmt(time: number): string;
export declare function flatMap(f: Function, xs: any[]): any;
export declare function uniq(xs: string[]): string[];
export declare function enc(o: any): string;
export declare function htmlAttrs(o: any): string;
export declare function indexOfAny(str: string, needles: string[]): number;
export declare function isNullOrEmpty(o: any): boolean;
export declare function fromDateTime(dateTime: string): Date;
export declare function toDateTime(date: Date): string;
export declare function fromTimeSpan(xsdDuration: string): string;
export declare function toTimeSpan(xsdDuration: string): string;
export declare function fromGuid(xsdDuration: string): string;
export declare function toGuid(xsdDuration: string): string;
export declare function fromByteArray(base64: string): Uint8Array;
export declare function toByteArray(bytes: Uint8Array): string;
export declare function toBase64String(source: string): string;
export declare class StringBuffer {
buffer_: string;
constructor(opt_a1?: any, ...var_args: any[]);
set(s: string): void;
append(a1: any, opt_a2?: any, ...var_args: any[]): this;
clear(): void;
getLength(): number;
toString(): string;
}
export declare class JSV {
static ESCAPE_CHARS: string[];
static encodeString(str: string): string;
static encodeArray(array: any[]): string;
static encodeObject(obj: any): string;
static stringify(obj: any): any;
}
export declare function uniqueKeys(rows: any[]): string[];
export declare function alignLeft(str: string, len: number, pad?: string): string;
export declare function alignCenter(str: string, len: number, pad?: string): string;
export declare function alignRight(str: string, len: number, pad?: string): string;
export declare function alignAuto(obj: any, len: number, pad?: string): string;
export declare class Inspect {
static vars(obj: any): void;
static dump(obj: any): string;
static printDump(obj: any): void;
static dumpTable(rows: any[]): string;
static printDumpTable(rows: any[]): void;
}