okai 0.0.23 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +16 -5
- package/dist/cs-apis.js +6 -9
- package/dist/cs-ast.js +432 -306
- package/dist/cs-gen.js +15 -9
- package/dist/cs-migrations.js +14 -5
- package/dist/index.js +80 -38
- package/dist/info.js +76 -0
- package/dist/ts-ast.js +32 -1
- package/dist/ts-once.js +240 -0
- package/dist/ts-parser.js +36 -27
- package/dist/tsd-gen.js +18 -81
- package/dist/utils.js +26 -1
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
@@ -8,6 +8,17 @@ declare global {
|
|
8
8
|
deletedBy?: string
|
9
9
|
}
|
10
10
|
|
11
|
+
// Assume User DTO exists
|
12
|
+
export class User {
|
13
|
+
id: string
|
14
|
+
userName: string
|
15
|
+
email: string
|
16
|
+
firstName: string
|
17
|
+
lastName: string
|
18
|
+
displayName: string
|
19
|
+
profileUrl: string
|
20
|
+
}
|
21
|
+
|
11
22
|
export type TypeOf = `typeof(${string})`
|
12
23
|
export type InputAttrOptions = { type?:string, value?:string, placeholder?:string, help?:string, label?:string, title?:string, size?:string,
|
13
24
|
pattern?:string, readOnly?:boolean, required?:boolean, disabled?:boolean, autocomplete?:string, autofocus?:string,
|
@@ -98,9 +109,9 @@ declare global {
|
|
98
109
|
export function validateExactLength(length:number) : ClassFieldDecoratorDef
|
99
110
|
export function validateMinimumLength(min:number) : ClassFieldDecoratorDef
|
100
111
|
export function validateMaximumLength(max:number) : ClassFieldDecoratorDef
|
101
|
-
export function
|
112
|
+
export function validateLessThan(value:number) : ClassFieldDecoratorDef
|
102
113
|
export function validateLessThanOrEqual(value:number) : ClassFieldDecoratorDef
|
103
|
-
export function
|
114
|
+
export function validateGreaterThan(value:number) : ClassFieldDecoratorDef
|
104
115
|
export function validateGreaterThanOrEqual(value:number) : ClassFieldDecoratorDef
|
105
116
|
export function validateScalePrecision(scale:number, precision:number) : ClassFieldDecoratorDef
|
106
117
|
export function validateRegularExpression(pattern:string) : ClassFieldDecoratorDef
|
@@ -141,7 +152,7 @@ declare global {
|
|
141
152
|
export function ignoreOnUpdate() : ClassFieldDecoratorDef
|
142
153
|
export function ignoreOnInsert() : ClassFieldDecoratorDef
|
143
154
|
export function ignoreDataMember() : ClassFieldDecoratorDef
|
144
|
-
export function reference() : ClassFieldDecoratorDef
|
155
|
+
export function reference(opt?:{ selfId?:string, refId?:string, refLabel?:string }) : ClassFieldDecoratorDef
|
145
156
|
export function referenceField(model:TypeOf, id?:string, field?:string) : ClassFieldDecoratorDef
|
146
157
|
export function references(type:TypeOf) : ClassFieldDecoratorDef
|
147
158
|
export function required() : ClassFieldDecoratorDef
|
@@ -264,9 +275,9 @@ declare global {
|
|
264
275
|
validateExactLength:typeof validateExactLength
|
265
276
|
validateMinimumLength:typeof validateMinimumLength
|
266
277
|
validateMaximumLength:typeof validateMaximumLength
|
267
|
-
|
278
|
+
validateLessThan:typeof validateLessThan
|
268
279
|
validateLessThanOrEqual:typeof validateLessThanOrEqual
|
269
|
-
|
280
|
+
validateGreaterThan:typeof validateGreaterThan
|
270
281
|
validateGreaterThanOrEqual:typeof validateGreaterThanOrEqual
|
271
282
|
validateScalePrecision:typeof validateScalePrecision
|
272
283
|
validateRegularExpression:typeof validateRegularExpression
|
package/dist/cs-apis.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { getGroupName
|
1
|
+
import { getGroupName } from "./utils.js";
|
2
2
|
import { CSharpGenerator } from "./cs-gen.js";
|
3
3
|
export class CSharpApiGenerator extends CSharpGenerator {
|
4
4
|
toApiClass(op) {
|
@@ -78,14 +78,6 @@ export class CSharpApiGenerator extends CSharpGenerator {
|
|
78
78
|
}
|
79
79
|
generate(ast) {
|
80
80
|
const groupName = getGroupName(ast);
|
81
|
-
const friendlyGroupName = splitCase(groupName);
|
82
|
-
ast.operations.forEach(op => {
|
83
|
-
if (op.request.attributes?.find(x => x.name === 'Tag'))
|
84
|
-
return;
|
85
|
-
if (!op.tags)
|
86
|
-
op.tags = [];
|
87
|
-
op.tags.push(friendlyGroupName);
|
88
|
-
});
|
89
81
|
this.namespaces = Array.from(ast.namespaces);
|
90
82
|
this.apis = ast.operations.map(x => this.toApiClass(x));
|
91
83
|
this.classes = ast.types.filter(t => !t.isEnum).map(x => this.toClass(x));
|
@@ -123,3 +115,8 @@ export class CSharpApiGenerator extends CSharpGenerator {
|
|
123
115
|
return { [`MyApp.ServiceModel/${fileName}`]: cs };
|
124
116
|
}
|
125
117
|
}
|
118
|
+
export function toCSharpApis(csAst) {
|
119
|
+
const csFiles = new CSharpApiGenerator().generate(csAst);
|
120
|
+
const cs = csFiles[Object.keys(csFiles)[0]];
|
121
|
+
return cs;
|
122
|
+
}
|