okai 0.0.9 → 0.0.11

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-ast.js CHANGED
@@ -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
@@ -537,7 +537,7 @@ function chooseFile(ctx, info, gist) {
537
537
  }
538
538
  const script = path.basename(process.argv[1]);
539
539
  console.log(`\nTo regenerate classes, update '${tsdFileName}' then run:`);
540
- console.log(`$ ${script} ${tsdFileName}`);
540
+ console.log(`$ ${script} ${tsdFileName}\n\n`);
541
541
  process.exit(0);
542
542
  }
543
543
  function writeFile(info, filename, content) {
package/dist/okai.js CHANGED
File without changes
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.9",
4
+ "version": "0.0.11",
5
5
  "bin": "./dist/okai.js",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -12,7 +12,7 @@
12
12
  "import": "./dist/index.js"
13
13
  },
14
14
  "scripts": {
15
- "build": "bun run clean && tsc",
15
+ "build": "bun run clean && tsc && chmod +x ./dist/okai.js",
16
16
  "build-bun": "bun run clean && bun build.ts",
17
17
  "clean": "shx rm -rf ./dist",
18
18
  "test": "bun test --",