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 CHANGED
@@ -471,8 +471,10 @@ Options:
471
471
  }
472
472
  if (command.type === "prompt") {
473
473
  try {
474
- if (!info.serviceModelDir)
475
- throw new Error("Could not find ServiceModel directory");
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
@@ -136,6 +136,8 @@ export function parseUserDtoType(cs) {
136
136
  };
137
137
  }
138
138
  function walk(dir, fileList = [], opt) {
139
+ if (!dir)
140
+ return fileList;
139
141
  const files = fs.readdirSync(dir);
140
142
  for (const file of files) {
141
143
  const filePath = path.join(dir, file);
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: "IntlNumber",
115
- args: { Currency: "NumberCurrency.USD" }
125
+ name: "intlNumber",
126
+ args: { currency: "USD" }
116
127
  });
117
128
  }
118
129
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "okai",
3
3
  "type": "module",
4
- "version": "0.0.35",
4
+ "version": "0.0.36",
5
5
  "bin": "./dist/okai.js",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",