-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.d.ts
431 lines (384 loc) · 20.8 KB
/
api.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
declare global {
export class bool {}
export class byte {} export class Byte {}
export class sbyte {} export class SByte {}
export class char {} export class Char {}
export class decimal {} export class Decimal {}
export class double {} export class Double {}
export class float {} export class Single {}
export class int {} export class Int32 {}
export class uint {} export class UInt32 {}
export class nint {} export class IntPtr {}
export class nuint {} export class UIntPtr {}
export class long {} export class Int64 {}
export class ulong {} export class UInt64 {}
export class short {} export class Int16 {}
export class ushort {} export class UInt16 {}
export class dynamic {} export class Dynamic {}
export class DateTime {}
export class TimeSpan {}
export class DateOnly {}
export class TimeOnly {}
export class DateTimeOffset {}
export class Guid {}
export class List<T> {}
export class HashSet<T> {}
export class Dictionary<Key,Value> {}
export class Color {}
export interface IReturn<T> {}
export interface IReturnVoid {}
export interface IGet {}
export interface IPost {}
export interface IPut {}
export interface IPatch {}
export interface IDelete {}
export interface IOptions {}
export interface ICreateDb<Table> {}
export interface IPatchDb<Table> {}
export interface IUpdateDb<Table> {}
export interface IDeleteDb<Table> {}
export class QueryDb<T> extends QueryBase {}
export class QueryDb2<From,Into> extends QueryBase {}
export class QueryBase {}
export interface IHasSessionId {}
export interface IHasBearerToken {}
export class EmptyResponse {}
export class IdResponse {}
export class StringsResponse {}
export class StringResponse {}
export class IntResponse {}
export class BoolResponse {}
export class ErrorResponse {}
export class ResponseError {}
export class ResponseStatus {}
export class AuditBase {
createdDate: Date
createdBy: string
modifiedDate: Date
modifiedBy: string
deletedDate?: Date
deletedBy?: string
}
// Assume User DTO exists
export class User {
id: string
userName: string
email: string
firstName: string
lastName: string
displayName: string
profileUrl: string
}
export type TypeOf = `typeof(${string})`
export type InputAttrOptions = { type?:string, value?:string, placeholder?:string, help?:string, label?:string, title?:string, size?:string,
pattern?:string, readOnly?:boolean, required?:boolean, disabled?:boolean, autocomplete?:string, autofocus?:string,
min?:string, max?:string, step?:string, minLength?:number, maxLength?:number, accept?:string, capture?:string, multiple?:boolean,
allowableValues?:string[], allowableValuesEnum?:TypeOf, options?:string, ignore?:boolean, evalAllowableValues?:string, evalAllowableEntries?:string, }
export type ScriptValueOptions = { value?: any, expression?: string, eval?: string, noCache?: boolean }
type ClassDecoratorDef = (
target: any,
context: ClassDecoratorContext
) => void
type ClassFieldDecoratorDef = (
target: any,
context: ClassFieldDecoratorContext
) => void
type ClassOrFieldDecoratorDef = (
target: any,
context: ClassDecoratorContext | ClassFieldDecoratorContext
) => void
export function validateRequest(validator:string) : ClassDecoratorDef
export function validateIsAuthenticated() : ClassDecoratorDef
export function validateIsAdmin() : ClassDecoratorDef
export function validateAuthSecret() : ClassDecoratorDef
export function validateHasRole(role:string) : ClassDecoratorDef
export function validateHasRoles(roles:string[]) : ClassDecoratorDef
export function validateHasPermission(permission:string) : ClassDecoratorDef
export function validateHasPermissions(permissions:string[]) : ClassDecoratorDef
export function validateHasClaim(claim:string) : ClassDecoratorDef
export function validateHasScope(scope:string) : ClassDecoratorDef
export function validateApiKey(scope?:string) : ClassDecoratorDef
export function schema(schema:string) : ClassDecoratorDef
export function compositeKey(columns:string[]) : ClassDecoratorDef
export function compositeIndex(unique:boolean, columns:string[]) : ClassDecoratorDef
export function preCreateTable(sql:string) : ClassDecoratorDef
export function preDropTable(sql:string) : ClassDecoratorDef
export function postCreateTable(sql:string) : ClassDecoratorDef
export function postDropTable(sql:string) : ClassDecoratorDef
export function api(description:string, opt?:{ bodyParameter?:number, requestContentType?:string, isRequired?:boolean }) : ClassDecoratorDef
export function apiResponse(statusCode:number, description:string, opt?:{ isDefaultResponse?:boolean, responseType?:TypeOf }) : ClassDecoratorDef
export function dataContract() : ClassDecoratorDef
export function route(path:string, opt?:{ summary?:string, notes?:string, verbs?:string, priority?:number, matches?:string, }|string) : ClassDecoratorDef
export function icon(opt?:{ svg?:string, uri?:string, alt?:string, cls?:string, }) : ClassDecoratorDef
export function field(opt?:InputAttrOptions & { name?:string, fieldCss?:string, inputCss?:string, labelCss?:string, }) : ClassDecoratorDef
export function tag(name?:string) : ClassDecoratorDef
export function worker(name:string) : ClassDecoratorDef
export function notes(notes:string) : ClassDecoratorDef
export function namedConnection(name:string) : ClassDecoratorDef
export function explorerCss(opt?:{ form?:string, fieldset?:string, field?:string, }) : ClassDecoratorDef
export function locodeCss(opt?:{ form?:string, fieldset?:string, field?:string, }) : ClassDecoratorDef
export enum QueryTerm { Default = 0, And = 1, Or = 2, Ensure = 3, }
export function queryDb(defaultTerm:QueryTerm) : ClassDecoratorDef
export function queryData(defaultTerm:QueryTerm) : ClassDecoratorDef
export function autoFilter(term:QueryTerm, field?:string, opt?:{ operand?:string, template?:string, valueFormat:string }) : ClassDecoratorDef
export function autoPopulate(field?:string, opt?:ScriptValueOptions) : ClassDecoratorDef
export function autoApply(name:string|Behavior, args?:string[]) : ClassDecoratorDef
export class SqlTemplate {
static IsNull: string
static IsNotNull: string
static GreaterThanOrEqual: string
static GreaterThan: string
static LessThan: string
static LessThanOrEqual: string
static NotEqual: string
static CaseSensitiveLike: string
static CaseInsensitiveLike: string
}
export enum Behavior {
AuditQuery,
AuditCreate,
AuditModify,
AuditDelete,
AuditSoftDelete,
}
export function alias(table:string) : ClassOrFieldDecoratorDef
export function meta(name:string,value:string) : ClassOrFieldDecoratorDef
export function priority(value:string) : ClassOrFieldDecoratorDef
export function description(description:string) : ClassOrFieldDecoratorDef
// Enum decorators
export function flags() : ClassDecoratorDef
export function enumMember(opt:{ value:string }) : ClassFieldDecoratorDef
export function validate(validator?:string) : ClassFieldDecoratorDef
export function validateNull() : ClassFieldDecoratorDef
export function validateEmpty() : ClassFieldDecoratorDef
export function validateEmail() : ClassFieldDecoratorDef
export function validateNotNull() : ClassFieldDecoratorDef
export function validateNotEmpty() : ClassFieldDecoratorDef
export function validateCreditCard() : ClassFieldDecoratorDef
export function validateLength(min:number, max:number) : ClassFieldDecoratorDef
export function validateExactLength(length:number) : ClassFieldDecoratorDef
export function validateMinimumLength(min:number) : ClassFieldDecoratorDef
export function validateMaximumLength(max:number) : ClassFieldDecoratorDef
export function validateLessThan(value:number) : ClassFieldDecoratorDef
export function validateLessThanOrEqual(value:number) : ClassFieldDecoratorDef
export function validateGreaterThan(value:number) : ClassFieldDecoratorDef
export function validateGreaterThanOrEqual(value:number) : ClassFieldDecoratorDef
export function validateScalePrecision(scale:number, precision:number) : ClassFieldDecoratorDef
export function validateRegularExpression(pattern:string) : ClassFieldDecoratorDef
export function validateEqualExpression(value:string|number|boolean) : ClassFieldDecoratorDef
export function validateNotEqualExpression(value:string|number|boolean) : ClassFieldDecoratorDef
export function validateInclusiveBetween(from:string|number,to:string|number) : ClassFieldDecoratorDef
export function validateExclusiveBetween(from:string|number,to:string|number) : ClassFieldDecoratorDef
export function allowReset() : ClassFieldDecoratorDef
export function denyReset() : ClassFieldDecoratorDef
export function primaryKey() : ClassFieldDecoratorDef
export function autoId() : ClassFieldDecoratorDef
export function autoIncrement() : ClassFieldDecoratorDef
export function belongTo(BelongToTableType:TypeOf) : ClassFieldDecoratorDef
export function index(opt?:{ name?:string, unique?:boolean, clustered?:boolean, nonClustered?:boolean, }) : ClassFieldDecoratorDef
export function compute() : ClassFieldDecoratorDef
export function computed() : ClassFieldDecoratorDef
export function persisted() : ClassFieldDecoratorDef
export function uniqueConstraint(columns:string[]) : ClassFieldDecoratorDef
export function addColumn() : ClassFieldDecoratorDef
export function removeColumn() : ClassFieldDecoratorDef
export function checkConstraint(constraint:string) : ClassFieldDecoratorDef
export function customField(sql:string, order?:number) : ClassFieldDecoratorDef
export function customSelect(sql:string) : ClassFieldDecoratorDef
export function customInsert(sql:string) : ClassFieldDecoratorDef
export function customUpdate(sql:string) : ClassFieldDecoratorDef
export function decimalLength(precision:number, scale?:number) : ClassFieldDecoratorDef
export function Default(value:string|number|boolean) : ClassFieldDecoratorDef
export function enumAsInt() : ClassFieldDecoratorDef
export function excludeMetadata() : ClassFieldDecoratorDef
export function excludeFromDescription() : ClassFieldDecoratorDef
export function explicitAutoQuery() : ClassFieldDecoratorDef
export type foreignKeyBehavior = "NO ACTION"|"RESTRICT"|"SET NULL"|"SET DEFAULT"|"CASCADE"
export function foreignKey(type:string, opt?:{ onDelete?:foreignKeyBehavior, onUpdate?:foreignKeyBehavior, foreignKeyName?:string }) : ClassFieldDecoratorDef
export function ignore() : ClassFieldDecoratorDef
export function ignoreOnUpdate() : ClassFieldDecoratorDef
export function ignoreOnInsert() : ClassFieldDecoratorDef
export function ignoreDataMember() : ClassFieldDecoratorDef
export function reference(opt?:{ selfId?:string, refId?:string, refLabel?:string }) : ClassFieldDecoratorDef
export function referenceField(model:TypeOf, id?:string, field?:string) : ClassFieldDecoratorDef
export function references(type:TypeOf) : ClassFieldDecoratorDef
export function required() : ClassFieldDecoratorDef
export function returnOnInsert() : ClassFieldDecoratorDef
export function rowVersion() : ClassFieldDecoratorDef
export function unique() : ClassFieldDecoratorDef
export enum ValueStyle { Single, Multiple, List, }
export function queryDbField(opt?:{ term:QueryTerm, operand?:string, template?:string, field?:string, valueFormat?:string, valueStyle?:ValueStyle, valueArity?:number }) : ClassFieldDecoratorDef
export function queryDataField(opt?:{ term:QueryTerm, condition?:string, field?:string }) : ClassFieldDecoratorDef
export enum AutoUpdateStyle { Always, NonDefaults }
export function autoUpdate(style:AutoUpdateStyle) : ClassFieldDecoratorDef
export function autoDefault(opt:ScriptValueOptions) : ClassOrFieldDecoratorDef
export function autoMap(to:string) : ClassOrFieldDecoratorDef
export function autoIgnore() : ClassFieldDecoratorDef
export function apiMember(opt?:{ name?:string, verb?:string, parameterType?:string, description?:string, dataType?:string,
format?:string, isRequired?:boolean, isOptional?:boolean, allowMultiple?:boolean, route?:string, excludeInSchema?:boolean
}) : ClassFieldDecoratorDef
export function apiAllowableValues(name:string, opt?:{ type?:"RANGE"|"LIST", min?:number, max?:number, values?:string[] }) : ClassFieldDecoratorDef
export function dataMember(opt?:{ name?:string, order?:number, isRequired?:boolean }) : ClassFieldDecoratorDef
export function input(opt?:InputAttrOptions) : ClassFieldDecoratorDef
export function fieldCss(opt?:{ field?:string, input?:string, label?:string, }) : ClassFieldDecoratorDef
export function uploadTo(location:string) : ClassFieldDecoratorDef
export function ref(opt?:{ modelType?:TypeOf, model?:string, refId?:string, refLabel?:string, selfId?:string, queryType?:TypeOf, none?:boolean, }) : ClassFieldDecoratorDef
export type FormatMethods = "currency"|"bytes"|"icon"|"iconRounded"|"attachment"|"link"|"linkMailTo"|"linkTel"|"enumFlags"|"hidden"
export function format(method:FormatMethods, opt?:{ options?:string, locale?:string }) : ClassFieldDecoratorDef
export enum IntlFormat { Number, DateTime, RelativeTime }
export enum NumberStyle { Undefined=0, Decimal, Currency, Percent, Unit, }
export enum DateStyle { Undefined=0, Full, Long, Medium, Short, }
export enum TimeStyle { Undefined=0, Full, Long, Medium, Short, }
export enum Numeric { Undefined=0, Always, Auto, }
export enum DatePart { Undefined=0, Numeric, Digits2, }
export enum DateMonth { Undefined=0, Numeric, Digits2, Narrow, Short, Long, }
export enum DateText { Undefined=0, Narrow, Short, Long }
export enum CurrencyDisplay { Undefined=0, Symbol, NarrowSymbol, Code, Name, }
export enum CurrencySign { Undefined=0, Accounting, Standard, }
export enum SignDisplay { Undefined=0, Always, Auto, ExceptZero, Negative, Never, }
export enum RoundingMode { Undefined=0, Ceil, Floor, Expand, Trunc, HalfCeil, HalfFloor, HalfExpand, HalfTrunc, HalfEven, }
export enum UnitDisplay { Undefined=0, Long, Short, Narrow }
export enum Notation { Undefined=0, Standard, Scientific, Engineering, Compact, }
export type IntlOptions = { locale?:string, options?:string, number?:NumberStyle, date?:DateStyle, time?:TimeStyle, numeric?:Numeric,
currency?:string, currencyDisplay?:CurrencyDisplay, currencySign?:CurrencySign, signDisplay?:SignDisplay, roundingMode?:RoundingMode,
unit?:string, unitDisplay?:UnitDisplay, notation?:Notation,
minimumIntegerDigits?:number, minimumFractionDigits?:number, maximumFractionDigits?:number, minimumSignificantDigits?:number, maximumSignificantDigits?:number, fractionalSecondDigits?:number,
weekday?:DateText, era?:DateText, year?:DatePart, month?:DateMonth, day?:DatePart, hour?:DatePart, minute?:DatePart, second?:DatePart,
timeZoneName?:DateText, timeZone?:string, hour12?:boolean
}
export function intl(type:IntlFormat, opt?:IntlOptions) : ClassFieldDecoratorDef
export function intlNumber(number?:NumberStyle|IntlOptions, opt?:IntlOptions) : ClassFieldDecoratorDef
export function intlDateTime(date?:DateStyle, time?:TimeStyle) : ClassFieldDecoratorDef
export function intlRelativeTime(numeric?:Numeric) : ClassFieldDecoratorDef
//RequestAttrs & TypeAttrs & DataModelAttrs & RequestPropAttrs & DataModelPropAttrs
export class All {
// RequestAttrs
api:typeof api
apiResponse:typeof apiResponse
validateRequest:typeof validateRequest
validateIsAuthenticated:typeof validateIsAuthenticated
validateIsAdmin:typeof validateIsAdmin
validateAuthSecret:typeof validateAuthSecret
validateHasRole:typeof validateHasRole
validateHasRoles:typeof validateHasRoles
validateHasPermission:typeof validateHasPermission
validateHasPermissions:typeof validateHasPermissions
validateHasClaim:typeof validateHasClaim
validateHasScope:typeof validateHasScope
validateApiKey:typeof validateApiKey
queryDb:typeof queryDb
queryData:typeof queryData
autoFilter:typeof autoFilter
autoPopulate:typeof autoPopulate
autoApply:typeof autoApply
route:typeof route
field:typeof field
tag:typeof tag
notes:typeof notes
// Type and Attrs
dataContract:typeof dataContract
// DataModelAttrs
schema:typeof schema
compositeKey:typeof compositeKey
preCreateTable:typeof preCreateTable
preDropTable:typeof preDropTable
postCreateTable:typeof postCreateTable
postDropTable:typeof postDropTable
namedConnection:typeof namedConnection
icon:typeof icon
locodeCss: typeof locodeCss
explorerCss: typeof explorerCss
// Class or Field Attrs
alias:typeof alias
meta:typeof meta // Type
flags:typeof flags // Enum
// RequestPropAttrs
validate:typeof validate
validateNull:typeof validateNull
validateEmpty:typeof validateEmpty
validateEmail:typeof validateEmail
validateNotNull:typeof validateNotNull
validateNotEmpty:typeof validateNotEmpty
validateCreditCard:typeof validateCreditCard
validateLength:typeof validateLength
validateExactLength:typeof validateExactLength
validateMinimumLength:typeof validateMinimumLength
validateMaximumLength:typeof validateMaximumLength
validateLessThan:typeof validateLessThan
validateLessThanOrEqual:typeof validateLessThanOrEqual
validateGreaterThan:typeof validateGreaterThan
validateGreaterThanOrEqual:typeof validateGreaterThanOrEqual
validateScalePrecision:typeof validateScalePrecision
validateRegularExpression:typeof validateRegularExpression
validateEqualExpression:typeof validateEqualExpression
validateNotEqualExpression:typeof validateNotEqualExpression
validateInclusiveBetween:typeof validateInclusiveBetween
validateExclusiveBetween:typeof validateExclusiveBetween
allowReset:typeof allowReset
denyReset:typeof denyReset
queryDbField:typeof queryDbField
queryDataField:typeof queryDataField
autoUpdate:typeof autoUpdate
autoDefault:typeof autoDefault
autoMap:typeof autoMap
autoIgnore:typeof autoIgnore
apiMember:typeof apiMember
apiAllowableValues:typeof apiAllowableValues
dataMember:typeof dataMember
input:typeof input
fieldCss:typeof fieldCss
uploadTo:typeof uploadTo
enumMember:typeof enumMember
// DataModelPropAttrs
// alias:typeof alias
// meta:typeof meta
priority:typeof priority
description:typeof description
primaryKey:typeof primaryKey
autoId:typeof autoId
autoIncrement:typeof autoIncrement
index:typeof index
compute:typeof compute
computed:typeof computed
persisted:typeof persisted
uniqueConstraint:typeof uniqueConstraint
addColumn:typeof addColumn
removeColumn:typeof removeColumn
belongTo:typeof belongTo
checkConstraint:typeof checkConstraint
customField:typeof customField
customSelect:typeof customSelect
customInsert:typeof customInsert
customUpdate:typeof customUpdate
decimalLength:typeof decimalLength
Default:typeof Default
enumAsInt:typeof enumAsInt
excludeMetadata:typeof excludeMetadata
excludeFromDescription:typeof excludeFromDescription
explicitAutoQuery:typeof explicitAutoQuery
foreignKey:typeof foreignKey
ignore:typeof ignore
ignoreOnUpdate:typeof ignoreOnUpdate
ignoreOnInsert:typeof ignoreOnInsert
ignoreDataMember:typeof ignoreDataMember
reference:typeof reference
referenceField:typeof referenceField
references:typeof references
required:typeof required
returnOnInsert:typeof returnOnInsert
rowVersion:typeof rowVersion
unique:typeof unique
ref:typeof ref
format:typeof format
intl:typeof intl
intlNumber:typeof intlNumber
intlDateTime:typeof intlDateTime
intlRelativeTime:typeof intlRelativeTime
}
export const Read : All
export const Write : All
export const Create : All
export const Update : All
export const Delete : All
}
export {}