okai 0.0.8 → 0.0.10

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/cs-apis.js CHANGED
@@ -1,5 +1,5 @@
1
- import { getGroupName, splitCase } from "./utils.js";
2
- import { CSharpGenerator } from "./cs-gen.js";
1
+ import { getGroupName, splitCase } from "./utils";
2
+ import { CSharpGenerator } from "./cs-gen";
3
3
  export class CSharpApiGenerator extends CSharpGenerator {
4
4
  toApiClass(op) {
5
5
  const cls = op.request;
package/dist/cs-ast.js CHANGED
@@ -1,5 +1,5 @@
1
- import { plural, toPascalCase } from "./utils.js";
2
- import { Icons } from "./icons.js";
1
+ import { plural, toPascalCase } from "./utils";
2
+ import { Icons } from "./icons";
3
3
  const sys = (name, genericArgs) => ({ name, namespace: "System", genericArgs });
4
4
  const sysObj = sys("object");
5
5
  const sysDictObj = { name: "Dictionary", genericArgs: ["string", "object"], namespace: "System.Collections.Generic" };
@@ -62,6 +62,10 @@ export class CSharpAst {
62
62
  return toPascalCase(tsName);
63
63
  }
64
64
  csharpType(type, propName) {
65
+ if (type.endsWith('[]')) {
66
+ const elType = this.csharpType(type.substring(0, type.length - 2), propName);
67
+ return Object.assign({}, elType, { name: elType.name + '[]' });
68
+ }
65
69
  if (propName) {
66
70
  if (type === "number") {
67
71
  if (this.decimalTypeProps.some(x => propName.toLowerCase().includes(x))) {
@@ -231,21 +235,24 @@ export class CSharpAst {
231
235
  idProp = { name: 'Id', type: 'int', isPrimaryKey: true, isValueType: true, namespace: 'System' };
232
236
  refType.properties?.unshift(idProp);
233
237
  }
234
- const fkProp = {
235
- name: fkId,
236
- type: idProp.type,
237
- namespace: idProp.namespace,
238
- attributes: [{
239
- name: "References",
240
- constructorArgs: [{
241
- name: "type",
242
- type: "Type",
243
- value: `typeof(${p.type})`
244
- }],
245
- args: []
246
- }]
247
- };
248
- type.properties.splice(i, 0, fkProp);
238
+ // Only add if FK Id prop does not already exist
239
+ if (!type.properties.find(x => x.name === fkId)) {
240
+ const fkProp = {
241
+ name: fkId,
242
+ type: idProp.type,
243
+ namespace: idProp.namespace,
244
+ attributes: [{
245
+ name: "References",
246
+ constructorArgs: [{
247
+ name: "type",
248
+ type: "Type",
249
+ value: `typeof(${p.type})`
250
+ }],
251
+ args: []
252
+ }]
253
+ };
254
+ type.properties.splice(i, 0, fkProp);
255
+ }
249
256
  if (!p.attributes)
250
257
  p.attributes = [];
251
258
  p.attributes.push({ name: "Reference" });
package/dist/index.js CHANGED
@@ -518,6 +518,8 @@ function chooseFile(ctx, info, gist) {
518
518
  const fullTsdPath = path.join(info.slnDir, relativeServiceModelDir, tsdFileName);
519
519
  const fullApiPath = path.join(info.slnDir, relativeServiceModelDir, apiFileName);
520
520
  const fullMigrationPath = path.join(info.slnDir, relativeMigrationDir, migrationFileName);
521
+ const clearScreen = blessed.screen();
522
+ clearScreen.render();
521
523
  if (!fs.existsSync(path.dirname(fullTsdPath))) {
522
524
  console.log(`Directory does not exist: ${path.dirname(fullTsdPath)}`);
523
525
  process.exit(0);
@@ -535,7 +537,7 @@ function chooseFile(ctx, info, gist) {
535
537
  }
536
538
  const script = path.basename(process.argv[1]);
537
539
  console.log(`\nTo regenerate classes, update '${tsdFileName}' then run:`);
538
- console.log(`$ ${script} ${tsdFileName}`);
540
+ console.log(`$ ${script} ${tsdFileName}\n\n`);
539
541
  process.exit(0);
540
542
  }
541
543
  function writeFile(info, filename, content) {
package/dist/ts-ast.js CHANGED
@@ -12,14 +12,6 @@ export function toTypeScriptSrc(msg) {
12
12
  return msg;
13
13
  }
14
14
  }
15
- // export function toAst(typescriptSrc:string) {
16
- // const parsed = parseTypeScriptSource(typescriptSrc)
17
- // return parsed
18
- // }
19
- // export function toAst(src:string) {
20
- // const parsed = TypeScriptMultiParser.parse(src)
21
- // return parsed
22
- // }
23
15
  export function toAst(src) {
24
16
  const parser = new TypeScriptParser();
25
17
  return parser.parse(src);
package/dist/ts-parser.js CHANGED
@@ -33,6 +33,8 @@ export class TypeScriptParser {
33
33
  const props = [];
34
34
  const lines = this.cleanBody(classBody).split('\n');
35
35
  lines.forEach((line, index) => {
36
+ if (line.trim().startsWith('//'))
37
+ return;
36
38
  const match = line.match(TypeScriptParser.PROPERTY_PATTERN);
37
39
  if (match?.groups) {
38
40
  const member = {
package/dist/utils.js CHANGED
@@ -80,6 +80,9 @@ export function plural(word, amount) {
80
80
  }
81
81
  return word;
82
82
  }
83
+ export function indentLines(src, indent = ' ') {
84
+ return src.split('\n').map(x => indent + x).join('\n');
85
+ }
83
86
  export function requestKey(date) {
84
87
  return `requests/${timestampKey(date)}`;
85
88
  }
@@ -90,9 +93,6 @@ export function timestampKey(date) {
90
93
  const timestamp = date.valueOf();
91
94
  return `${year}/${month}/${day}/${timestamp}`;
92
95
  }
93
- export function indentLines(src, indent = ' ') {
94
- return src.split('\n').map(x => indent + x).join('\n');
95
- }
96
96
  export function trimStart(str, chars = ' ') {
97
97
  const cleanStr = String(str);
98
98
  const charsToTrim = new Set(chars);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "okai",
3
3
  "type": "module",
4
- "version": "0.0.8",
4
+ "version": "0.0.10",
5
5
  "bin": "./dist/okai.js",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",