@voxgig/apidef 2.0.0 → 2.1.0

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.
Files changed (48) hide show
  1. package/dist/apidef.js +14 -20
  2. package/dist/apidef.js.map +1 -1
  3. package/dist/builder/flow/flowHeuristic01.js +37 -9
  4. package/dist/builder/flow/flowHeuristic01.js.map +1 -1
  5. package/dist/builder/flow.js +3 -3
  6. package/dist/builder/flow.js.map +1 -1
  7. package/dist/guide/heuristic01.js +197 -117
  8. package/dist/guide/heuristic01.js.map +1 -1
  9. package/dist/guide.js +37 -11
  10. package/dist/guide.js.map +1 -1
  11. package/dist/parse.d.ts +2 -1
  12. package/dist/parse.js +81 -3
  13. package/dist/parse.js.map +1 -1
  14. package/dist/transform/clean.d.ts +3 -0
  15. package/dist/transform/clean.js +16 -0
  16. package/dist/transform/clean.js.map +1 -0
  17. package/dist/transform/entity.js +21 -2
  18. package/dist/transform/entity.js.map +1 -1
  19. package/dist/transform/field.js +24 -1
  20. package/dist/transform/field.js.map +1 -1
  21. package/dist/transform/operation.js +131 -47
  22. package/dist/transform/operation.js.map +1 -1
  23. package/dist/transform.d.ts +1 -8
  24. package/dist/transform.js +121 -95
  25. package/dist/transform.js.map +1 -1
  26. package/dist/tsconfig.tsbuildinfo +1 -1
  27. package/dist/types.d.ts +9 -0
  28. package/dist/types.js +3 -2
  29. package/dist/types.js.map +1 -1
  30. package/dist/utility.d.ts +7 -1
  31. package/dist/utility.js +85 -32
  32. package/dist/utility.js.map +1 -1
  33. package/model/apidef.jsonic +1 -0
  34. package/package.json +8 -9
  35. package/src/apidef.ts +23 -33
  36. package/src/builder/flow/flowHeuristic01.ts +44 -9
  37. package/src/builder/flow.ts +4 -3
  38. package/src/guide/heuristic01.ts +281 -124
  39. package/src/guide.ts +49 -14
  40. package/src/parse.ts +106 -4
  41. package/src/transform/clean.ts +28 -0
  42. package/src/transform/entity.ts +26 -3
  43. package/src/transform/field.ts +27 -1
  44. package/src/transform/operation.ts +203 -64
  45. package/src/transform.ts +29 -23
  46. package/src/types.ts +3 -2
  47. package/src/utility.ts +113 -1
  48. package/src/builder/flow/flowHeuristic01.ts~ +0 -45
package/dist/types.d.ts CHANGED
@@ -21,6 +21,7 @@ declare const ModelShape: {
21
21
  def: {};
22
22
  api: {
23
23
  guide: {};
24
+ entity: {};
24
25
  };
25
26
  };
26
27
  };
@@ -32,6 +33,7 @@ declare const ModelShape: {
32
33
  def: {};
33
34
  api: {
34
35
  guide: {};
36
+ entity: {};
35
37
  };
36
38
  };
37
39
  };
@@ -81,6 +83,7 @@ declare const ModelShape: {
81
83
  def: {};
82
84
  api: {
83
85
  guide: {};
86
+ entity: {};
84
87
  };
85
88
  };
86
89
  }>;
@@ -116,6 +119,7 @@ declare const OpenModelShape: {
116
119
  def: {};
117
120
  api: {
118
121
  guide: {};
122
+ entity: {};
119
123
  };
120
124
  };
121
125
  };
@@ -127,6 +131,7 @@ declare const OpenModelShape: {
127
131
  def: {};
128
132
  api: {
129
133
  guide: {};
134
+ entity: {};
130
135
  };
131
136
  };
132
137
  };
@@ -176,6 +181,7 @@ declare const OpenModelShape: {
176
181
  def: {};
177
182
  api: {
178
183
  guide: {};
184
+ entity: {};
179
185
  };
180
186
  };
181
187
  }>;
@@ -234,6 +240,7 @@ declare const OpenModelShape: {
234
240
  def: {};
235
241
  api: {
236
242
  guide: {};
243
+ entity: {};
237
244
  };
238
245
  };
239
246
  };
@@ -245,6 +252,7 @@ declare const OpenModelShape: {
245
252
  def: {};
246
253
  api: {
247
254
  guide: {};
255
+ entity: {};
248
256
  };
249
257
  };
250
258
  };
@@ -294,6 +302,7 @@ declare const OpenModelShape: {
294
302
  def: {};
295
303
  api: {
296
304
  guide: {};
305
+ entity: {};
297
306
  };
298
307
  };
299
308
  }>;
package/dist/types.js CHANGED
@@ -10,11 +10,12 @@ const ModelShape = (0, gubu_1.Gubu)({
10
10
  sdk: {},
11
11
  def: {},
12
12
  api: {
13
- guide: {}
13
+ guide: {},
14
+ entity: {},
14
15
  },
15
16
  }
16
17
  });
17
- const OpenModelShape = (0, gubu_1.Gubu)((0, gubu_1.Open)(ModelShape));
18
+ const OpenModelShape = (0, gubu_1.Gubu)((0, gubu_1.Open)(ModelShape), { name: 'Model' });
18
19
  exports.OpenModelShape = OpenModelShape;
19
20
  const BuildShape = (0, gubu_1.Gubu)({
20
21
  spec: {
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,4CAA4C;;;AAK5C,+BAAsC;AAmBtC,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC;IACtB,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,MAAM;IACX,IAAI,EAAE;QACJ,GAAG,EAAE,EAAE;QACP,GAAG,EAAE,EAAE;QACP,GAAG,EAAE;YACH,KAAK,EAAE,EAAE;SACV;KACF;CACF,CAAC,CAAA;AACF,MAAM,cAAc,GAAG,IAAA,WAAI,EAAC,IAAA,WAAI,EAAC,UAAU,CAAC,CAAC,CAAA;AAuC3C,wCAAc;AAlChB,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC;IACtB,IAAI,EAAE;QACJ,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,EAAE;QACT,GAAG,EAAE,EAAE;QACP,GAAG,EAAE,EAAE;QACP,OAAO,EAAE,EAAE;QACX,GAAG,EAAE,EAAE;QACP,EAAE,EAAE,IAAA,UAAG,GAAE;QACT,KAAK,EAAE;YACL,GAAG,EAAE,IAAI;YACT,GAAG,EAAE,IAAI;YACT,GAAG,EAAE,IAAI;SACV;KACF;CACF,CAAC,CAAA;AACF,MAAM,cAAc,GAAG,IAAA,WAAI,EAAC,IAAA,WAAI,EAAC,UAAU,CAAC,CAAC,CAAA;AAkB3C,wCAAc"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,4CAA4C;;;AAK5C,+BAAsC;AAmBtC,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC;IACtB,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,MAAM;IACX,IAAI,EAAE;QACJ,GAAG,EAAE,EAAE;QACP,GAAG,EAAE,EAAE;QACP,GAAG,EAAE;YACH,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,EAAE;SACX;KACF;CACF,CAAC,CAAA;AACF,MAAM,cAAc,GAAG,IAAA,WAAI,EAAC,IAAA,WAAI,EAAC,UAAU,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;AAuC9D,wCAAc;AAlChB,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC;IACtB,IAAI,EAAE;QACJ,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,EAAE;QACT,GAAG,EAAE,EAAE;QACP,GAAG,EAAE,EAAE;QACP,OAAO,EAAE,EAAE;QACX,GAAG,EAAE,EAAE;QACP,EAAE,EAAE,IAAA,UAAG,GAAE;QACT,KAAK,EAAE;YACL,GAAG,EAAE,IAAI;YACT,GAAG,EAAE,IAAI;YACT,GAAG,EAAE,IAAI;SACV;KACF;CACF,CAAC,CAAA;AACF,MAAM,cAAc,GAAG,IAAA,WAAI,EAAC,IAAA,WAAI,EAAC,UAAU,CAAC,CAAC,CAAA;AAkB3C,wCAAc"}
package/dist/utility.d.ts CHANGED
@@ -1,4 +1,10 @@
1
1
  import type { FsUtil, Log } from './types';
2
+ declare function getdlog(tagin?: string, filepath?: string): ((...args: any[]) => void) & {
3
+ tag: string;
4
+ file: string;
5
+ log: (fp?: string) => any[];
6
+ };
2
7
  declare function loadFile(path: string, what: string, fs: FsUtil, log: Log): string;
3
8
  declare function formatJsonSrc(jsonsrc: string): string;
4
- export { loadFile, formatJsonSrc };
9
+ declare function depluralize(word: string): string;
10
+ export { getdlog, loadFile, formatJsonSrc, depluralize, };
package/dist/utility.js CHANGED
@@ -3,9 +3,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getdlog = getdlog;
6
7
  exports.loadFile = loadFile;
7
8
  exports.formatJsonSrc = formatJsonSrc;
9
+ exports.depluralize = depluralize;
8
10
  const node_path_1 = __importDefault(require("node:path"));
11
+ function getdlog(tagin, filepath) {
12
+ const tag = tagin || '-';
13
+ const file = node_path_1.default.basename(filepath || '-');
14
+ const g = global;
15
+ g.__dlog__ = (g.__dlog__ || []);
16
+ const dlog = (...args) => g.__dlog__.push([tag, file, Date.now(), ...args]);
17
+ dlog.tag = tag;
18
+ dlog.file = file;
19
+ dlog.log = (filepath, f) => (f = null == filepath ? null : node_path_1.default.basename(filepath),
20
+ g.__dlog__.filter((n) => n[0] === tag && (null == f || n[2] === f)));
21
+ return dlog;
22
+ }
9
23
  function loadFile(path, what, fs, log) {
10
24
  try {
11
25
  const source = fs.readFileSync(path, 'utf8');
@@ -19,41 +33,80 @@ function loadFile(path, what, fs, log) {
19
33
  function formatJsonSrc(jsonsrc) {
20
34
  return jsonsrc
21
35
  .replace(/"([a-zA-Z_][a-zA-Z_0-9]*)": /g, '$1: ')
22
- .replace(/},/g, '}\n');
36
+ .replace(/},/g, '}\n')
37
+ // .replace(/([a-zA-Z_][a-zA-Z_0-9]*)_COMMENT:/g, '# $1')
38
+ .replace(/\n(\s*)([a-zA-Z_][a-zA-Z_0-9]*)_COMMENT:\s*"(.*)",/g, '\n\n$1# $2 $3');
23
39
  }
24
- function writeChanged(point, path, content, fs, log, flags) {
25
- let exists = false;
26
- let changed = false;
27
- flags = flags || {};
28
- flags.update = null == flags.update ? true : !!flags.update;
29
- let action = '';
30
- try {
31
- let existingContent = '';
32
- path = node_path_1.default.normalize(path);
33
- exists = fs.existsSync(path);
34
- if (exists) {
35
- action = 'read';
36
- existingContent = fs.readFileSync(path, 'utf8');
37
- }
38
- changed = existingContent !== content;
39
- action = flags.update ? 'write' : 'skip';
40
- log.info({
41
- point: 'write-' + point,
42
- note: (changed ? '' : 'not-') + 'changed ' + path,
43
- write: 'file', skip: !changed, exists, changed,
44
- contentLength: content.length, file: path
45
- });
46
- if (!exists || (changed && flags.update)) {
47
- fs.writeFileSync(path, content);
40
+ function depluralize(word) {
41
+ if (!word || word.length === 0) {
42
+ return word;
43
+ }
44
+ // Common irregular plurals
45
+ const irregulars = {
46
+ 'analyses': 'analysis',
47
+ 'appendices': 'appendix',
48
+ 'axes': 'axis',
49
+ 'children': 'child',
50
+ 'courses': 'course',
51
+ 'crises': 'crisis',
52
+ 'criteria': 'criterion',
53
+ 'data': 'datum',
54
+ 'diagnoses': 'diagnosis',
55
+ 'feet': 'foot',
56
+ 'furnace': 'furnaces',
57
+ 'geese': 'goose',
58
+ 'horses': 'horse',
59
+ 'house': 'houses',
60
+ 'indices': 'index',
61
+ 'license': 'licenses',
62
+ 'matrices': 'matrix',
63
+ 'men': 'man',
64
+ 'mice': 'mouse',
65
+ 'notice': 'notices',
66
+ 'oases': 'oasis',
67
+ 'people': 'person',
68
+ 'phenomena': 'phenomenon',
69
+ 'practice': 'practices',
70
+ 'promise': 'promises',
71
+ 'teeth': 'tooth',
72
+ 'theses': 'thesis',
73
+ 'vertices': 'vertex',
74
+ 'women': 'woman',
75
+ };
76
+ if (irregulars[word]) {
77
+ return irregulars[word];
78
+ }
79
+ // Rules for regular plurals (applied in order)
80
+ if (word.endsWith('ies') && word.length > 3) {
81
+ return word.slice(0, -3) + 'y';
82
+ }
83
+ // -ies -> -y (cities -> city)
84
+ if (word.endsWith('ies') && word.length > 3) {
85
+ return word.slice(0, -3) + 'y';
86
+ }
87
+ // -ves -> -f or -fe (wolves -> wolf, knives -> knife)
88
+ if (word.endsWith('ves')) {
89
+ const stem = word.slice(0, -3);
90
+ // Check if it should be -fe (like knife, wife, life)
91
+ if (['kni', 'wi', 'li'].includes(stem)) {
92
+ return stem + 'fe';
48
93
  }
94
+ return stem + 'f';
49
95
  }
50
- catch (err) {
51
- log.error({
52
- fail: action, point, file: path, exists, changed,
53
- contentLength: content.length, err
54
- });
55
- err.__logged__ = true;
56
- throw err;
96
+ // -oes -> -o (potatoes -> potato)
97
+ if (word.endsWith('oes')) {
98
+ return word.slice(0, -2);
99
+ }
100
+ // -ses, -xes, -zes, -shes, -ches -> remove -es (boxes -> box)
101
+ if (word.endsWith('ses') || word.endsWith('xes') || word.endsWith('zes') ||
102
+ word.endsWith('shes') || word.endsWith('ches')) {
103
+ return word.slice(0, -2);
104
+ }
105
+ // -s -> remove -s (cats -> cat)
106
+ if (word.endsWith('s') && !word.endsWith('ss')) {
107
+ return word.slice(0, -1);
57
108
  }
109
+ // If none of the rules apply, return as is
110
+ return word;
58
111
  }
59
112
  //# sourceMappingURL=utility.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utility.js","sourceRoot":"","sources":["../src/utility.ts"],"names":[],"mappings":";;;;;AA+EE,4BAAQ;AACR,sCAAa;AA/Ef,0DAA4B;AAS5B,SAAS,QAAQ,CAAC,IAAY,EAAE,IAAY,EAAE,EAAU,EAAE,GAAQ;IAChE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QAC5C,OAAO,MAAM,CAAA;IACf,CAAC;IACD,OAAO,GAAQ,EAAE,CAAC;QAChB,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAA;QAC5C,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC;AAGD,SAAS,aAAa,CAAC,OAAe;IACpC,OAAO,OAAO;SACX,OAAO,CAAC,+BAA+B,EAAE,MAAM,CAAC;SAChD,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AAC1B,CAAC;AAGD,SAAS,YAAY,CACnB,KAAa,EAAE,IAAY,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AI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACvC,OAAO,IAAI,GAAG,IAAI,CAAA;QACpB,CAAC;QACD,OAAO,IAAI,GAAG,GAAG,CAAA;IACnB,CAAC;IAED,kCAAkC;IAClC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC;IAED,8DAA8D;IAC9D,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QACtE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACjD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC;IAED,gCAAgC;IAChC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC;IAED,2CAA2C;IAC3C,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -7,6 +7,7 @@ main: api: guide: control: {
7
7
  entity,
8
8
  operation,
9
9
  field,
10
+ clean,
10
11
  ` | string,
11
12
 
12
13
  element: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voxgig/apidef",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "main": "dist/apidef.js",
5
5
  "type": "commonjs",
6
6
  "types": "dist/apidef.d.ts",
@@ -41,23 +41,22 @@
41
41
  "devDependencies": {
42
42
  "@hapi/code": "^9.0.3",
43
43
  "@types/js-yaml": "^4.0.9",
44
- "@types/node": "24.0.7",
44
+ "@types/node": "24.1.0",
45
45
  "aontu": "^0.28.0",
46
- "esbuild": "^0.25.5",
47
46
  "json-schema-to-ts": "^3.1.1",
48
- "memfs": "^4.17.2",
47
+ "memfs": "^4.24.0",
49
48
  "patch-package": "^8.0.0",
50
49
  "typescript": "^5.8.3"
51
50
  },
52
51
  "dependencies": {
53
- "@redocly/openapi-core": "^1.34.3",
54
- "@voxgig/struct": "^0.0.3",
55
- "@voxgig/util": "^0.0.10",
52
+ "@redocly/openapi-core": "^1.34.5",
53
+ "@voxgig/struct": "^0.0.6",
54
+ "@voxgig/util": "^0.2.0",
56
55
  "chokidar": "^4.0.3",
57
56
  "gubu": "^9.0.0",
58
- "jostraca": "^0.20.0",
57
+ "jostraca": "^0.23.0",
59
58
  "pino": "^9.7.0",
60
- "pino-pretty": "^13.0.0",
59
+ "pino-pretty": "^13.1.1",
61
60
  "sonic-boom": "^4.2.0"
62
61
  }
63
62
  }
package/src/apidef.ts CHANGED
@@ -28,13 +28,12 @@ import {
28
28
 
29
29
 
30
30
  import {
31
- parse
31
+ parse,
32
+ rewrite,
32
33
  } from './parse'
33
34
 
34
35
 
35
36
  import {
36
- resolveTransforms,
37
- processTransforms,
38
37
  fixName,
39
38
  } from './transform'
40
39
 
@@ -46,20 +45,25 @@ import {
46
45
 
47
46
  import {
48
47
  loadFile,
48
+ getdlog,
49
49
  } from './utility'
50
50
 
51
-
52
51
  import { topTransform } from './transform/top'
53
52
  import { entityTransform } from './transform/entity'
54
53
  import { operationTransform } from './transform/operation'
55
54
  import { fieldTransform } from './transform/field'
55
+ import { cleanTransform } from './transform/clean'
56
56
 
57
57
  import { makeEntityBuilder } from './builder/entity'
58
58
  import { makeFlowBuilder } from './builder/flow'
59
59
 
60
+ // Log non-fatal wierdness.
61
+ const dlog = getdlog('apidef', __filename)
62
+
60
63
 
61
64
  function ApiDef(opts: ApiDefOptions) {
62
65
 
66
+
63
67
  // TODO: gubu opts!
64
68
  const fs = opts.fs || Fs
65
69
  const pino = prettyPino('apidef', opts)
@@ -70,9 +74,7 @@ function ApiDef(opts: ApiDefOptions) {
70
74
 
71
75
  async function generate(spec: any) {
72
76
  const start = Date.now()
73
-
74
- // console.log('APIDEF GENERATE')
75
- // console.dir(spec, { depth: null })
77
+ // dlog('start')
76
78
 
77
79
  const model: Model = OpenModelShape(spec.model)
78
80
  const build: Build = OpenBuildShape(spec.build)
@@ -115,9 +117,15 @@ function ApiDef(opts: ApiDefOptions) {
115
117
 
116
118
  const defsrc = loadFile(defpath, 'def', fs, log)
117
119
 
118
- const def = await parse('OpenAPI', defsrc, { file: defpath })
120
+ let def = await parse('OpenAPI', defsrc, { file: defpath })
121
+
122
+ def = rewrite(def)
123
+
124
+ fs.writeFileSync(defpath + '.full.json', JSON.stringify(def, null, 2))
125
+
119
126
  ctx.def = def
120
127
 
128
+
121
129
  const guideBuilder = await resolveGuide(ctx)
122
130
 
123
131
 
@@ -127,38 +135,15 @@ function ApiDef(opts: ApiDefOptions) {
127
135
  entity: entityTransform,
128
136
  operation: operationTransform,
129
137
  field: fieldTransform,
138
+ clean: cleanTransform,
130
139
  })
131
140
 
132
- // log.debug({
133
- // point: 'transform', spec: transformSpec,
134
- // note: log.levelVal <= 20 ? inspect(transformSpec) : ''
135
- // })
136
-
137
- // const processResult = await processTransforms(ctx, transforms, apimodel, def)
138
-
139
- // if (!processResult.ok) {
140
- // log.error({
141
- // fail: 'process', point: 'transform-result',
142
- // result: processResult, note: processResult.msg,
143
- // err: processResult.results[0]?.err
144
- // })
145
-
146
- // return { ok: false, name: 'apidef', processResult }
147
- // }
148
-
149
-
150
141
  const builders = await resolveElements(ctx, 'builder', 'standard', {
151
142
  entity: makeEntityBuilder,
152
143
  flow: makeFlowBuilder,
153
144
  })
154
145
 
155
146
 
156
-
157
- // const entityBuilder = resolveEntity(apimodel, spec, opts)
158
-
159
- // const entityBuilder = await resolveEntity(ctx)
160
- // const flowBuilder = await resolveFlows(ctx)
161
-
162
147
  const jostraca = Jostraca({
163
148
  now: spec.now,
164
149
  fs: () => fs,
@@ -184,7 +169,12 @@ function ApiDef(opts: ApiDefOptions) {
184
169
  existing: { txt: { merge: true } }
185
170
  }, root)
186
171
 
187
- // console.log('JRES', jres)
172
+ const dlogs = dlog.log()
173
+ if (0 < dlogs.length) {
174
+ for (let dlogentry of dlogs) {
175
+ log.debug({ point: 'generate-warning', dlogentry, note: String(dlogentry) })
176
+ }
177
+ }
188
178
 
189
179
  log.info({ point: 'generate-end', note: 'success', break: true })
190
180
 
@@ -24,7 +24,7 @@ function resolveBasicEntityFlow(ctx: any, entity: any) {
24
24
  const apiEntity = apimodel.main.api.entity[entity.name]
25
25
 
26
26
  const flow: any = {
27
- name: 'Basic' + apiEntity.Name
27
+ name: 'Basic' + apiEntity.Name + 'Flow'
28
28
  }
29
29
 
30
30
  const refs = [
@@ -36,18 +36,21 @@ function resolveBasicEntityFlow(ctx: any, entity: any) {
36
36
  const idmap = refs.reduce((a: any, ref) => (a[ref] = ref.toUpperCase(), a), {})
37
37
 
38
38
  flow.model = ({
39
- name: flow.Name,
39
+ name: flow.name,
40
+ active: true,
40
41
  param: {
41
- [`${model.NAME}_TEST_${apiEntity.NAME}_ENTID`]: idmap
42
+ [`${model.NAME}_TEST_${apiEntity.NAME}_ENTID`]: idmap,
43
+ [`${model.NAME}_TEST_LIVE`]: "FALSE",
44
+ [`${model.NAME}_TEST_EXPLAIN`]: "FALSE",
42
45
  },
43
- test: { entity: { [apiEntity.Name]: {} } },
46
+ test: { entity: { [apiEntity.name]: {} } },
44
47
  step: []
45
48
  } as any)
46
49
 
47
50
  names(flow, flow.name)
48
51
 
49
52
 
50
- const data = flow.model.test.entity[apiEntity.Name]
53
+ const data = flow.model.test.entity[apiEntity.name]
51
54
 
52
55
  refs.map((ref, i) => {
53
56
  const id = idmap[ref]
@@ -73,7 +76,34 @@ function resolveBasicEntityFlow(ctx: any, entity: any) {
73
76
  let num = 0
74
77
  let name
75
78
 
79
+ const am: any = {}
80
+
76
81
  if (apiEntity.op.load) {
82
+
83
+ // Get additional required match properties
84
+ each(apiEntity.op.load.param, (param: any) => {
85
+ if (param.required) {
86
+ let ancestorName = param.name
87
+ let ancestorEntity = apimodel.main.api.entity[ancestorName]
88
+
89
+ if (null == ancestorEntity) {
90
+ ancestorName = ancestorName.replace('_id', '')
91
+ ancestorEntity = apimodel.main.api.entity[ancestorName]
92
+ }
93
+
94
+ if (ancestorEntity && ancestorName !== apiEntity.name) {
95
+ flow.model.param[`${model.NAME}_TEST_${ancestorEntity.NAME}_ENTID`] = {
96
+ [ancestorEntity.name + '01']: ancestorEntity.NAME + '01'
97
+ }
98
+ am[param.name] =
99
+ `\`dm$=p.${model.NAME}_TEST_${ancestorEntity.NAME}_ENTID.${ancestorEntity.name}01\``
100
+
101
+ data[`${apiEntity.NAME}01`][param.name] = ancestorEntity.NAME + '01'
102
+ }
103
+ }
104
+ })
105
+
106
+
77
107
  name = `load_${apiEntity.name}${num}`
78
108
  steps.push({
79
109
  name,
@@ -81,11 +111,13 @@ function resolveBasicEntityFlow(ctx: any, entity: any) {
81
111
  entity: `${apiEntity.name}`,
82
112
  action: 'load',
83
113
  match: {
84
- id: `\`dm$=p.${model.NAME}_TEST_${apiEntity.NAME}_ENTID.${apiEntity.name}01\``
114
+ id: `\`dm$=p.${model.NAME}_TEST_${apiEntity.NAME}_ENTID.${apiEntity.name}01\``,
115
+ ...am,
85
116
  },
86
117
  valid: {
87
118
  '`$OPEN`': true,
88
- id: `\`dm$=s.${name}.match.id\``
119
+ id: `\`dm$=s.${name}.match.id\``,
120
+ ...am,
89
121
  }
90
122
  })
91
123
  }
@@ -105,6 +137,7 @@ function resolveBasicEntityFlow(ctx: any, entity: any) {
105
137
  valid: {
106
138
  '`$OPEN`': true,
107
139
  id: `\`dm$=s.${loadref}.match.id\``,
140
+ ...am,
108
141
  ...valid
109
142
  }
110
143
  })
@@ -118,11 +151,13 @@ function resolveBasicEntityFlow(ctx: any, entity: any) {
118
151
  entity: `${apiEntity.name}`,
119
152
  action: 'load',
120
153
  match: {
121
- id: `\`dm$=p.${model.NAME}_TEST_${apiEntity.NAME}_ENTID.${apiEntity.name}01\``
154
+ id: `\`dm$=p.${model.NAME}_TEST_${apiEntity.NAME}_ENTID.${apiEntity.name}01\``,
155
+ ...am,
122
156
  },
123
157
  valid: {
124
158
  '`$OPEN`': true,
125
159
  id: `\`dm$=s.${loadref}.match.id\``,
160
+ ...am,
126
161
  ...valid
127
162
  }
128
163
  })
@@ -136,7 +171,7 @@ function resolveBasicEntityFlow(ctx: any, entity: any) {
136
171
 
137
172
  function makeUpdateData(name: string, apiEntity: any, flow: any, id: string) {
138
173
  const ud: any = {}
139
- const data = flow.model.test.entity[apiEntity.Name]
174
+ const data = flow.model.test.entity[apiEntity.name]
140
175
 
141
176
  const dataFields = each(apiEntity.field).filter(f => 'id' !== f.name && !f.name.includes('_id'))
142
177
  const stringFields = each(dataFields).filter(f => 'string' === f.type)
@@ -21,6 +21,7 @@ async function makeFlowBuilder(ctx: any) {
21
21
  throw new Error('Unknown guide strategy: ' + ctx.opts.strategy)
22
22
  }
23
23
 
24
+
24
25
  return function flowBuilder() {
25
26
 
26
27
  Folder({ name: 'flow' }, () => {
@@ -32,13 +33,13 @@ async function makeFlowBuilder(ctx: any) {
32
33
  let flowfile =
33
34
  Path.join(ctx.opts.folder, 'flow',
34
35
  (null == ctx.opts.outprefix ? '' : ctx.opts.outprefix) +
35
- flow.Name + 'Flow.jsonic')
36
+ flow.Name + '.jsonic')
36
37
 
37
38
  let flowModelSrc = formatJsonSrc(JSON.stringify(flow.model, null, 2))
38
39
 
39
- let flowsrc = `# ${flow.Name}Flow
40
+ let flowsrc = `# ${flow.Name}
40
41
 
41
- main: sdk: flow: ${flow.Name}Flow:
42
+ main: sdk: flow: ${flow.Name}:
42
43
  ` + flowModelSrc
43
44
 
44
45
  barrel.push(`@"${Path.basename(flowfile)}"`)