1 |
|
2 | import { ApplicationBase } from './app';
|
3 | import { ConfigurationBase } from './config';
|
4 |
|
5 | export type Types =
|
6 | | 'Float'
|
7 | | 'Boolean'
|
8 | | 'Date'
|
9 | | 'DateTime'
|
10 | | 'Integer'
|
11 | | 'Short'
|
12 | | 'Counter'
|
13 | | 'Duration'
|
14 | | 'Number'
|
15 | | 'Text'
|
16 | | 'Time'
|
17 | | 'URL'
|
18 | | 'Language'
|
19 | | 'Model'
|
20 | | 'Guid'
|
21 | | 'Object'
|
22 | | 'NegativeInteger'
|
23 | | 'NegativeNumber'
|
24 | | 'NonNegativeInteger'
|
25 | | 'NonNegativeNumber'
|
26 | | 'NonPositiveInteger'
|
27 | | 'NonPositiveNumber'
|
28 | | 'PositiveInteger'
|
29 | | 'PositiveNumber'
|
30 | | 'Email'
|
31 | | 'AbsoluteURI'
|
32 | | 'RelativeURI';
|
33 |
|
34 | export interface DataAssociationMappingBase {
|
35 | associationType?: 'association' | 'junction';
|
36 | associationAdapter?: string;
|
37 | associationObjectField?: string;
|
38 | associationValueField?: string;
|
39 | parentModel?: string;
|
40 | parentField?: string;
|
41 | childModel?: string;
|
42 | childField?: string;
|
43 | cascade?: 'delete' | 'none';
|
44 | options?: {
|
45 | |
46 |
|
47 |
|
48 | $orderby?: string;
|
49 | |
50 |
|
51 |
|
52 | $select?: string;
|
53 | |
54 |
|
55 |
|
56 | $expand?: string;
|
57 | |
58 |
|
59 |
|
60 | $levels?: string;
|
61 | [k: string]: unknown;
|
62 | };
|
63 | privileges?: {
|
64 | |
65 |
|
66 |
|
67 | mask: number;
|
68 | |
69 |
|
70 |
|
71 | type: 'self' | 'global' | 'parent' | 'item';
|
72 | |
73 |
|
74 |
|
75 | account?: string;
|
76 | |
77 |
|
78 |
|
79 | filter?: string;
|
80 | [k: string]: unknown;
|
81 | }[];
|
82 | [k: string]: unknown;
|
83 | }
|
84 |
|
85 | export interface DataFieldBase {
|
86 | |
87 |
|
88 |
|
89 | '@id'?: string;
|
90 | |
91 |
|
92 |
|
93 | description?: string;
|
94 | |
95 |
|
96 |
|
97 | name: string;
|
98 | |
99 |
|
100 |
|
101 | title?: string;
|
102 | |
103 |
|
104 |
|
105 | type?: Types | string;
|
106 | |
107 |
|
108 |
|
109 | size?: number;
|
110 | |
111 |
|
112 |
|
113 | nullable?: boolean;
|
114 | |
115 |
|
116 |
|
117 | primary?: boolean;
|
118 | |
119 |
|
120 |
|
121 | value?: string;
|
122 | |
123 |
|
124 |
|
125 | calculation?: string;
|
126 | |
127 |
|
128 |
|
129 | readonly?: boolean;
|
130 | |
131 |
|
132 |
|
133 | editable?: boolean;
|
134 | |
135 |
|
136 |
|
137 | indexed?: boolean;
|
138 | |
139 |
|
140 |
|
141 | property?: string;
|
142 | |
143 |
|
144 |
|
145 | many?: boolean;
|
146 | |
147 |
|
148 |
|
149 | expandable?: boolean;
|
150 | |
151 |
|
152 |
|
153 | nested?: boolean;
|
154 | |
155 |
|
156 |
|
157 | scale?: number;
|
158 | |
159 |
|
160 |
|
161 | multiplicity?: 'ZeroOrOne' | 'Many' | 'One' | 'Unknown',
|
162 | mapping?: DataAssociationMappingBase;
|
163 | |
164 |
|
165 |
|
166 | validation?: {
|
167 | |
168 |
|
169 |
|
170 | minValue?: {
|
171 | [k: string]: unknown;
|
172 | };
|
173 | |
174 |
|
175 |
|
176 | maxValue?: {
|
177 | [k: string]: unknown;
|
178 | };
|
179 | |
180 |
|
181 |
|
182 | minLength?: number;
|
183 | |
184 |
|
185 |
|
186 | maxLength?: number;
|
187 | |
188 |
|
189 |
|
190 | pattern?: string;
|
191 | |
192 |
|
193 |
|
194 | patternMessage?: string;
|
195 | |
196 |
|
197 |
|
198 | message?: string;
|
199 | |
200 |
|
201 |
|
202 | type?: Types | string;
|
203 | |
204 |
|
205 |
|
206 | validator?: string;
|
207 | [k: string]: unknown;
|
208 | };
|
209 | [k: string]: unknown;
|
210 | }
|
211 |
|
212 | export interface DataModelConstraintBase {
|
213 | |
214 |
|
215 |
|
216 | type: 'unique';
|
217 | |
218 |
|
219 |
|
220 | description?: string;
|
221 | fields?: string[];
|
222 | }
|
223 |
|
224 | export interface DataModelEventListenerBase {
|
225 | |
226 |
|
227 |
|
228 | name?: string;
|
229 | |
230 |
|
231 |
|
232 | type: string;
|
233 | }
|
234 |
|
235 | export interface DataModelPrivilegeBase {
|
236 | |
237 |
|
238 |
|
239 | mask: number;
|
240 | |
241 |
|
242 |
|
243 | type: 'self' | 'global' | 'parent' | 'item';
|
244 | |
245 |
|
246 |
|
247 | account?: string;
|
248 | |
249 |
|
250 |
|
251 | filter?: string;
|
252 | [k: string]: unknown;
|
253 | }
|
254 |
|
255 | export interface DataModelProperties {
|
256 | |
257 |
|
258 |
|
259 | '@id'?: string;
|
260 | |
261 |
|
262 |
|
263 | name: string;
|
264 | |
265 |
|
266 |
|
267 | id?: number;
|
268 | |
269 |
|
270 |
|
271 | title?: string;
|
272 | |
273 |
|
274 |
|
275 | inherits?: string;
|
276 | |
277 |
|
278 |
|
279 | implements?: string;
|
280 | |
281 |
|
282 |
|
283 | sealed?: boolean;
|
284 | |
285 |
|
286 |
|
287 | abstract?: boolean;
|
288 | |
289 |
|
290 |
|
291 | hidden?: boolean;
|
292 | |
293 |
|
294 |
|
295 | classPath?: string;
|
296 | |
297 |
|
298 |
|
299 | source?: string;
|
300 | |
301 |
|
302 |
|
303 | view?: string;
|
304 | |
305 |
|
306 |
|
307 | version: string;
|
308 | |
309 |
|
310 |
|
311 | caching?: 'none' | 'always' | 'conditional';
|
312 | fields?: DataFieldBase[];
|
313 | constraints?: DataModelConstraintBase[];
|
314 | eventListeners?: DataModelEventListenerBase[];
|
315 | privileges?: DataModelPrivilegeBase[];
|
316 | }
|
317 |
|
318 | export interface DataModelBase extends DataModelProperties {
|
319 | get context(): DataContextBase;
|
320 | set context(value: DataContextBase);
|
321 | asQueryable(): DataQueryableBase;
|
322 | base(): DataModelBase;
|
323 | clone(): DataModelBase;
|
324 | find(obj: any):DataQueryableBase;
|
325 | getAttribute(name: string): DataFieldBase;
|
326 | getDataObjectType<T>(): new (...args: any) => T;
|
327 | getPrimaryKey(): DataFieldBase;
|
328 | getReferenceMappings(deep?: boolean): DataAssociationMappingBase[];
|
329 | getSubTypes(): string[];
|
330 | getSuperTypes(): string[];
|
331 | inferMapping(attr: any): DataAssociationMappingBase;
|
332 | inferState(obj: any, callback: (err?: Error, res?: any) => void): void;
|
333 | inferStateAsync(obj: any): Promise<any>;
|
334 | insert(obj: any | any[]): Promise<any>;
|
335 | isSilent(): boolean;
|
336 | migrate: ((err?: Error, result?: any) => void);
|
337 | migrateAsync(): Promise<void>;
|
338 | save(obj: any | any[]): Promise<any>;
|
339 | silent(value?: boolean): this;
|
340 | update(obj: any | any[]): Promise<any>;
|
341 | remove(obj: any | any[]): Promise<any>;
|
342 | where(attr: any): DataQueryableBase;
|
343 | }
|
344 |
|
345 | export interface DataAdapterBase {
|
346 | rawConnection?:any;
|
347 | options?:any;
|
348 | open(callback:(err?:Error) => void): void;
|
349 | openAsync(): Promise<void>;
|
350 |
|
351 | close(callback:(err?:Error) => void): void;
|
352 | closeAsync(): Promise<void>;
|
353 |
|
354 | execute(query:any, values:any[], callback:(err?:Error, result?:any) => void): void;
|
355 | executeAsync(query:any, values:any[]): Promise<void>;
|
356 |
|
357 | selectIdentity(entity:string, attribute:string , callback?:(err?:Error, result?:any) => void): void;
|
358 | selectIdentityAsync(entity:string, attribute:string): Promise<void>;
|
359 |
|
360 | executeInTransaction(func: () => void, callback:(err?:Error) => void): void;
|
361 | executeInTransactionAsync(func: () => Promise<void>): Promise<void>;
|
362 | }
|
363 |
|
364 |
|
365 | export interface DataContextBase {
|
366 | db?: DataAdapterBase;
|
367 | application?: ApplicationBase;
|
368 |
|
369 | model(name:any): DataModelBase;
|
370 | getConfiguration(): ConfigurationBase;
|
371 | finalize(callback?:(err?:Error) => void): void;
|
372 | finalizeAsync(): Promise<void>;
|
373 | executeInTransactionAsync(func: () => Promise<void>): Promise<void>;
|
374 |
|
375 | }
|
376 |
|
377 | export interface DataQueryableBase {
|
378 | readonly model: DataModelBase;
|
379 | clone(): DataQueryableBase;
|
380 | where(attr: any): this;
|
381 | search(text: string): this;
|
382 | join(model: any): this;
|
383 | and(attr: any): this;
|
384 | or(attr: any): this;
|
385 | prepare(orElse?: boolean): this;
|
386 | is(value: any): this;
|
387 | equal(value: any): this;
|
388 | notEqual(value: any): this;
|
389 | greaterThan(value: any): this;
|
390 | greaterOEqual(value: any): this;
|
391 | bit(value: any, result?:number): this;
|
392 | lowerThan(value: any): this;
|
393 | lowerOrEqual(value: any): this;
|
394 | startsWith(value: any): this;
|
395 | endsWith(value: any): this;
|
396 | contains(value: any): this;
|
397 | notContains(value: any): this;
|
398 | between(value1: any, value2: any): this;
|
399 | select(...attr: any[]): this;
|
400 | orderBy(attr: any): this;
|
401 | orderByDescending(attr: any): this;
|
402 | thenBy(attr: any): this;
|
403 | thenByDescending(attr: any): this;
|
404 | groupBy(...attr: any[]): this;
|
405 | skip(n:number): this;
|
406 | take(n:number): this;
|
407 | getItem(): Promise<any>;
|
408 | getItems(): Promise<any[]>;
|
409 | getTypedItem<T>(): Promise<T>;
|
410 | getTypedItems<T>(): Promise<T[]>;
|
411 | getList(): Promise<any>;
|
412 | getTypedList(): Promise<any>;
|
413 | getAllItems(): Promise<any[]>;
|
414 | count(): Promise<number>;
|
415 | value(): Promise<any>;
|
416 | min(): Promise<any>;
|
417 | max(): Promise<any>;
|
418 | average(): Promise<any>;
|
419 | silent(value?: boolean): this;
|
420 | cache(value?: boolean): this;
|
421 | expand(...attr: any[]): this;
|
422 | add(x: any): this;
|
423 | subtract(x: any): this;
|
424 | multiply(x: any): this;
|
425 | divide(x: any): this;
|
426 | round(n?:number): this;
|
427 | substr(start: number, length?:number): this;
|
428 | indexOf(s: string): this;
|
429 | concat(s: string): this;
|
430 | trim(): this;
|
431 | length(): this;
|
432 | getDate(): this;
|
433 | getYear(): this;
|
434 | getMonth(): this;
|
435 | getDay(): this;
|
436 | getFullYear(): this;
|
437 | getMinutes(): this;
|
438 | getSeconds(): this;
|
439 | getHours(): this;
|
440 | floor(): this;
|
441 | ceil(): this;
|
442 | toLowerCase(): this;
|
443 | toLocaleLowerCase(): this;
|
444 | toUpperCase(): this;
|
445 | toLocaleUpperCase(): this;
|
446 | levels(n:number): this;
|
447 | }
|
448 |
|
449 | export interface DataObjectBase {
|
450 |
|
451 | context?: DataContextBase;
|
452 | getType(): any;
|
453 | getId():any;
|
454 | save(context?: DataContextBase): Promise<void>;
|
455 | remove(context?: DataContextBase): Promise<void>;
|
456 | getModel(): DataModelBase;
|
457 | getAdditionalModel():Promise<DataModelBase>;
|
458 | getAdditionalObject():Promise<DataContextBase|any>;
|
459 | query(attr:string):DataQueryableBase;
|
460 |
|
461 | }
|
462 |
|
463 | export declare interface DataAdapterTable {
|
464 | create(fields: Array<any>, callback: (err: Error) => void): void;
|
465 | createAsync(fields: Array<any>): Promise<void>;
|
466 | add(fields: Array<any>, callback: (err: Error) => void): void;
|
467 | addAsync(fields: Array<any>): Promise<void>;
|
468 | change(fields: Array<any>, callback: (err: Error) => void): void;
|
469 | changeAsync(fields: Array<any>): Promise<void>;
|
470 | exists(callback: (err: Error, result: boolean) => void): void;
|
471 | existsAsync(): Promise<boolean>;
|
472 | version(callback: (err: Error, result: string) => void): void;
|
473 | versionAsync(): Promise<string>;
|
474 | columns(callback: (err: Error, result: Array<any>) => void): void;
|
475 | columnsAsync(): Promise<Array<any>>;
|
476 | }
|
477 |
|
478 | export declare interface DataAdapterIndex {
|
479 | name: string;
|
480 | columns: Array<string>;
|
481 | }
|
482 |
|
483 | export declare interface DataAdapterIndexes {
|
484 | create(name: string, columns: Array<string>, callback: (err: Error, res?: number) => void): void;
|
485 | createAsync(name: string, columns: Array<string>): Promise<number>;
|
486 | drop(name: string, callback: (err: Error, res?: number) => void): void;
|
487 | dropAsync(name: string): Promise<number>;
|
488 | list(callback: (err: Error, res: Array<DataAdapterIndex>) => void): void;
|
489 | listAsync(): Promise<Array<DataAdapterIndex>>;
|
490 | }
|
491 |
|
492 | export declare interface DataAdapterView {
|
493 | create(query: any, callback: (err: Error) => void): void;
|
494 | createAsync(query: any): Promise<void>;
|
495 | exists(callback: (err: Error, result: boolean) => void): void;
|
496 | existsAsync(): Promise<boolean>;
|
497 | drop(callback: (err: Error) => void): void;
|
498 | dropAsync(): Promise<void>;
|
499 | }
|
500 |
|
501 | export declare interface DataAdapterDatabase {
|
502 | exists(callback: (err: Error, result: boolean) => void): void;
|
503 | existsAsync(): Promise<boolean>;
|
504 | create(callback: (err: Error) => void): void;
|
505 | createAsync(): Promise<void>;
|
506 | }
|
507 |
|
508 | export declare interface DataAdapterMigration {
|
509 | add: Array<any>;
|
510 | change?: Array<any>;
|
511 | appliesTo: string;
|
512 | version: string;
|
513 | indexes?: Array<{name: string, columns: Array<string>}>;
|
514 | updated: boolean;
|
515 | }
|
516 |
|
517 | export declare interface DataAdapterBase {
|
518 | constructor(options?: any);
|
519 | formatType(field: any): string;
|
520 | open(callback: (err: Error) => void): void;
|
521 | close(callback: (err: Error) => void): void;
|
522 | openAsync(): Promise<void>;
|
523 | closeAsync(): Promise<void>;
|
524 | prepare(query: any, values?: Array<any>): any;
|
525 | createView(name: string, query: any, callback: (err: Error) => void): void;
|
526 | executeInTransaction(func: any, callback: (err: Error) => void): void;
|
527 | executeInTransactionAsync(func: Promise<any>): Promise<any>;
|
528 | migrate(obj: DataAdapterMigration, callback: (err: Error, result?: any) => void): void;
|
529 | migrateAsync(obj: DataAdapterMigration): Promise<any>;
|
530 | selectIdentity(entity: string, attribute: string, callback: (err: Error, value: any) => void): void;
|
531 | execute(query: any, values: any, callback: (err: Error, value: any) => void): void;
|
532 | executeAsync(query: any, values: any): Promise<any>;
|
533 | executeAsync<T>(query: any, values: any): Promise<Array<T>>;
|
534 | table(name: string): DataAdapterTable;
|
535 | view(name: string): DataAdapterView;
|
536 | indexes(name: string): DataAdapterIndexes;
|
537 | database(name: string): DataAdapterDatabase;
|
538 | } |
\ | No newline at end of file |