okai 0.0.33 → 0.0.35
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 +2 -2
- package/dist/cs-ast.js +26 -3
- package/dist/index.js +13 -11
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
@@ -125,7 +125,7 @@ declare global {
|
|
125
125
|
export function route(path:string, opt?:{ summary?:string, notes?:string, verbs?:string, priority?:number, matches?:string, }|string) : ClassDecoratorDef
|
126
126
|
export function icon(opt?:{ svg?:string, uri?:string, alt?:string, cls?:string, }) : ClassDecoratorDef
|
127
127
|
export function field(opt?:InputAttrOptions & { name?:string, fieldCss?:string, inputCss?:string, labelCss?:string, }) : ClassDecoratorDef
|
128
|
-
export function tag(name
|
128
|
+
export function tag(name?:string) : ClassDecoratorDef
|
129
129
|
export function worker(name:string) : ClassDecoratorDef
|
130
130
|
export function notes(notes:string) : ClassDecoratorDef
|
131
131
|
export function namedConnection(name:string) : ClassDecoratorDef
|
@@ -167,7 +167,7 @@ declare global {
|
|
167
167
|
export function flags() : ClassDecoratorDef
|
168
168
|
export function enumMember(opt:{ value:string }) : ClassFieldDecoratorDef
|
169
169
|
|
170
|
-
export function validate(validator
|
170
|
+
export function validate(validator?:string) : ClassFieldDecoratorDef
|
171
171
|
export function validateNull() : ClassFieldDecoratorDef
|
172
172
|
export function validateEmpty() : ClassFieldDecoratorDef
|
173
173
|
export function validateEmail() : ClassFieldDecoratorDef
|
package/dist/cs-ast.js
CHANGED
@@ -648,8 +648,9 @@ export class CSharpAst {
|
|
648
648
|
else if (prop.type === 'List`1' && this.commonValueTypes.includes(prop.genericArgs[0])) {
|
649
649
|
prop.attributes.push(...inputTagAttrs);
|
650
650
|
}
|
651
|
-
const emptyValidateAttr = prop.attributes
|
652
|
-
|
651
|
+
const emptyValidateAttr = prop.attributes
|
652
|
+
.find(x => x.name.toLowerCase() === 'validate' && !x.constructorArgs?.length && !x.args?.length);
|
653
|
+
if (emptyValidateAttr) {
|
653
654
|
prop.attributes = prop.attributes.filter(x => x !== emptyValidateAttr);
|
654
655
|
}
|
655
656
|
}
|
@@ -708,6 +709,11 @@ export class CSharpAst {
|
|
708
709
|
prop.attributes.push(...inputTagAttrs);
|
709
710
|
}
|
710
711
|
}
|
712
|
+
const emptyValidateAttr = prop.attributes
|
713
|
+
.find(x => x.name.toLowerCase() === 'validate' && !x.constructorArgs?.length && !x.args?.length);
|
714
|
+
if (emptyValidateAttr) {
|
715
|
+
prop.attributes = prop.attributes.filter(x => x !== emptyValidateAttr);
|
716
|
+
}
|
711
717
|
}
|
712
718
|
if (isAuditBase) {
|
713
719
|
updateApi.requiresAuth = true;
|
@@ -838,6 +844,7 @@ export const Transforms = {
|
|
838
844
|
addAutoIncrementAttrs,
|
839
845
|
addIconsToKnownTypes,
|
840
846
|
hideReferenceProperties,
|
847
|
+
removeEmptyAttributes,
|
841
848
|
],
|
842
849
|
};
|
843
850
|
export function toMetadataTypes(ast, transforms) {
|
@@ -919,6 +926,22 @@ export function replaceIds(gen) {
|
|
919
926
|
}
|
920
927
|
}
|
921
928
|
}
|
929
|
+
export function removeEmptyAttributes(gen) {
|
930
|
+
const removeEmptyAttrsNamed = ['icon', 'description', 'notes', 'tag', 'icon', 'alias']; // 'validate' removed in gen APIs
|
931
|
+
const filterEmptyAttrs = (attrs) => attrs.filter(x => !(removeEmptyAttrsNamed.includes(x.name.toLowerCase()) && !x.constructorArgs?.length && !x.args?.length));
|
932
|
+
for (const type of gen.classes) {
|
933
|
+
if (type.attributes) {
|
934
|
+
type.attributes = filterEmptyAttrs(type.attributes);
|
935
|
+
}
|
936
|
+
if (type.properties) {
|
937
|
+
for (const prop of type.properties) {
|
938
|
+
if (prop.attributes) {
|
939
|
+
prop.attributes = filterEmptyAttrs(prop.attributes);
|
940
|
+
}
|
941
|
+
}
|
942
|
+
}
|
943
|
+
}
|
944
|
+
}
|
922
945
|
export function convertReferenceTypes(gen) {
|
923
946
|
for (const type of gen.classes) {
|
924
947
|
for (let i = 0; i < type.properties.length; i++) {
|
@@ -1061,7 +1084,7 @@ export function addIconsToKnownTypes(gen) {
|
|
1061
1084
|
const existingIcon = type.attributes.find(x => x.name === 'Icon');
|
1062
1085
|
if (existingIcon) {
|
1063
1086
|
// remove empty icon
|
1064
|
-
if (existingIcon.constructorArgs?.
|
1087
|
+
if (existingIcon.constructorArgs?.length === 0 && existingIcon.args?.length === 0) {
|
1065
1088
|
type.attributes = type.attributes.filter(x => x !== existingIcon);
|
1066
1089
|
}
|
1067
1090
|
return;
|
package/dist/index.js
CHANGED
@@ -751,17 +751,7 @@ function chooseFile(ctx, info, gist, comamnd) {
|
|
751
751
|
const apiTypesPath = path.join(info.slnDir, relativeServiceModelDir, `api.d.ts`);
|
752
752
|
const apiFile = path.join(import.meta.dirname, 'api.d.ts');
|
753
753
|
fs.writeFileSync(apiTypesPath, fs.readFileSync(apiFile, 'utf-8'));
|
754
|
-
let uiFileName = null;
|
755
|
-
if (info.uiMjsDir) {
|
756
|
-
uiFileName = `${res.groupName}.mjs`;
|
757
|
-
const uiGroupPath = path.join(info.uiMjsDir, uiFileName);
|
758
|
-
const uiVueGen = new UiMjsGroupGenerator();
|
759
|
-
const uiGroupSrc = uiVueGen.generate(res.csAst, res.groupName);
|
760
|
-
fs.writeFileSync(uiGroupPath, uiGroupSrc);
|
761
|
-
const uiIndexGen = new UiMjsIndexGenerator();
|
762
|
-
const uiIndexSrc = uiIndexGen.generate(fs.readdirSync(info.uiMjsDir));
|
763
|
-
fs.writeFileSync(path.join(info.uiMjsDir, `index.mjs`), uiIndexSrc);
|
764
|
-
}
|
754
|
+
let uiFileName = info.uiMjsDir ? `${res.groupName}.mjs` : null;
|
765
755
|
const tsdContent = createTsdFile(info, {
|
766
756
|
prompt: titleBar.content.replaceAll('/*', '').replaceAll('*/', ''),
|
767
757
|
apiFileName,
|
@@ -783,6 +773,18 @@ function chooseFile(ctx, info, gist, comamnd) {
|
|
783
773
|
fs.writeFileSync(fullApiPath, apiContent, { encoding: 'utf-8' });
|
784
774
|
console.log(`Saved: ${fullApiPath}`);
|
785
775
|
}
|
776
|
+
if (info.uiMjsDir) {
|
777
|
+
const uiGroupPath = path.join(info.uiMjsDir, uiFileName);
|
778
|
+
const uiVueGen = new UiMjsGroupGenerator();
|
779
|
+
const uiGroupSrc = uiVueGen.generate(res.csAst, res.groupName);
|
780
|
+
fs.writeFileSync(uiGroupPath, uiGroupSrc);
|
781
|
+
console.log(`Saved: ${uiGroupPath}`);
|
782
|
+
const uiIndexGen = new UiMjsIndexGenerator();
|
783
|
+
const uiIndexSrc = uiIndexGen.generate(fs.readdirSync(info.uiMjsDir));
|
784
|
+
const uiIndexPath = path.join(info.uiMjsDir, `index.mjs`);
|
785
|
+
fs.writeFileSync(uiIndexPath, uiIndexSrc);
|
786
|
+
console.log(`Saved: ${uiIndexPath}`);
|
787
|
+
}
|
786
788
|
if (fs.existsSync(path.dirname(fullMigrationPath))) {
|
787
789
|
fs.writeFileSync(fullMigrationPath, migrationContent, { encoding: 'utf-8' });
|
788
790
|
console.log(`Saved: ${fullMigrationPath}`);
|