okai 0.0.35 → 0.0.36
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/index.js +4 -2
- package/dist/info.js +2 -0
- package/dist/ts-once.js +13 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -471,8 +471,10 @@ Options:
|
|
471
471
|
}
|
472
472
|
if (command.type === "prompt") {
|
473
473
|
try {
|
474
|
-
if (!info.serviceModelDir)
|
475
|
-
|
474
|
+
if (!info.serviceModelDir) {
|
475
|
+
console.log("Could not find ServiceModel directory, ensure okai is run within the context of a ServiceStack App");
|
476
|
+
process.exit(1);
|
477
|
+
}
|
476
478
|
console.log(`Generating new APIs and Tables for: ${command.prompt}...`);
|
477
479
|
const gist = await fetchGistFiles(command);
|
478
480
|
// const projectGist = convertToProjectGist(info, gist)
|
package/dist/info.js
CHANGED
package/dist/ts-once.js
CHANGED
@@ -7,6 +7,7 @@ export function createTdAstFromAIAst(tsAst, gropName) {
|
|
7
7
|
replaceIds(tsAst);
|
8
8
|
tsAst.classes.forEach(cls => {
|
9
9
|
// replaceUserRefs(cls)
|
10
|
+
replaceUserBaseClass(cls);
|
10
11
|
rewriteDuplicateTypePropNames(cls);
|
11
12
|
rewriteSelfReferencingIds(cls);
|
12
13
|
convertToAuditBase(cls);
|
@@ -86,6 +87,16 @@ export function transformUserRefs(tsAst, info) {
|
|
86
87
|
tsAst.classes = tsAst.classes.filter(x => x.name !== 'User');
|
87
88
|
}
|
88
89
|
}
|
90
|
+
function replaceUserBaseClass(type) {
|
91
|
+
if (type.extends === 'User') {
|
92
|
+
type.extends = 'AuditBase';
|
93
|
+
let idProp = type.properties?.find(x => x.name.toLowerCase() === 'id');
|
94
|
+
if (!idProp) {
|
95
|
+
idProp = { name: 'id', type: 'number' };
|
96
|
+
type.properties?.unshift(idProp);
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
89
100
|
function rewriteDuplicateTypePropNames(type) {
|
90
101
|
const duplicateTypePropMap = {
|
91
102
|
note: 'content',
|
@@ -111,8 +122,8 @@ export function addCustomInputs(cls) {
|
|
111
122
|
if (!prop.annotations)
|
112
123
|
prop.annotations = [];
|
113
124
|
prop.annotations.push({
|
114
|
-
name: "
|
115
|
-
args: {
|
125
|
+
name: "intlNumber",
|
126
|
+
args: { currency: "USD" }
|
116
127
|
});
|
117
128
|
}
|
118
129
|
}
|