@voxgig/apidef 2.4.0 → 3.0.2
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/apidef.d.ts +5 -1
- package/dist/apidef.js +197 -112
- package/dist/apidef.js.map +1 -1
- package/dist/builder/entity/entity.d.ts +3 -0
- package/dist/builder/entity/{apiEntity.js → entity.js} +12 -9
- package/dist/builder/entity/entity.js.map +1 -0
- package/dist/builder/entity/info.d.ts +3 -0
- package/dist/builder/entity/info.js +22 -0
- package/dist/builder/entity/info.js.map +1 -0
- package/dist/builder/entity.js +7 -21
- package/dist/builder/entity.js.map +1 -1
- package/dist/builder/flow/flowHeuristic01.js +21 -11
- package/dist/builder/flow/flowHeuristic01.js.map +1 -1
- package/dist/builder/flow.d.ts +2 -1
- package/dist/builder/flow.js +29 -4
- package/dist/builder/flow.js.map +1 -1
- package/dist/def.d.ts +62 -0
- package/dist/def.js +4 -0
- package/dist/def.js.map +1 -0
- package/dist/desc.d.ts +89 -0
- package/dist/desc.js +4 -0
- package/dist/desc.js.map +1 -0
- package/dist/guide/guide.d.ts +2 -1
- package/dist/guide/guide.js +161 -30
- package/dist/guide/guide.js.map +1 -1
- package/dist/guide/heuristic01.d.ts +2 -1
- package/dist/guide/heuristic01.js +1120 -234
- package/dist/guide/heuristic01.js.map +1 -1
- package/dist/model.d.ts +55 -0
- package/dist/model.js +4 -0
- package/dist/model.js.map +1 -0
- package/dist/parse.d.ts +1 -2
- package/dist/parse.js +8 -47
- package/dist/parse.js.map +1 -1
- package/dist/transform/args.d.ts +3 -0
- package/dist/transform/args.js +58 -0
- package/dist/transform/args.js.map +1 -0
- package/dist/transform/clean.js +27 -3
- package/dist/transform/clean.js.map +1 -1
- package/dist/transform/entity.d.ts +11 -3
- package/dist/transform/entity.js +57 -41
- package/dist/transform/entity.js.map +1 -1
- package/dist/transform/field.d.ts +3 -3
- package/dist/transform/field.js +90 -65
- package/dist/transform/field.js.map +1 -1
- package/dist/transform/operation.d.ts +1 -1
- package/dist/transform/operation.js +94 -296
- package/dist/transform/operation.js.map +1 -1
- package/dist/transform/select.d.ts +3 -0
- package/dist/transform/select.js +44 -0
- package/dist/transform/select.js.map +1 -0
- package/dist/transform/top.d.ts +9 -0
- package/dist/transform/top.js +11 -2
- package/dist/transform/top.js.map +1 -1
- package/dist/transform.js +4 -0
- package/dist/transform.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +112 -19
- package/dist/types.js +4 -2
- package/dist/types.js.map +1 -1
- package/dist/utility.d.ts +30 -2
- package/dist/utility.js +381 -6
- package/dist/utility.js.map +1 -1
- package/model/apidef.jsonic +75 -1
- package/model/guide.jsonic +14 -44
- package/package.json +19 -14
- package/src/apidef.ts +264 -121
- package/src/builder/entity/{apiEntity.ts → entity.ts} +18 -11
- package/src/builder/entity/info.ts +53 -0
- package/src/builder/entity.ts +9 -35
- package/src/builder/flow/flowHeuristic01.ts +46 -12
- package/src/builder/flow.ts +39 -5
- package/src/def.ts +91 -0
- package/src/desc.ts +143 -0
- package/src/guide/guide.ts +207 -134
- package/src/guide/heuristic01.ts +1651 -272
- package/src/model.ts +98 -0
- package/src/parse.ts +5 -61
- package/src/schematron.ts.off +317 -0
- package/src/transform/args.ts +102 -0
- package/src/transform/clean.ts +43 -8
- package/src/transform/entity.ts +100 -51
- package/src/transform/field.ts +150 -71
- package/src/transform/operation.ts +118 -414
- package/src/transform/select.ts +90 -0
- package/src/transform/top.ts +76 -3
- package/src/transform.ts +4 -0
- package/src/types.ts +185 -5
- package/src/utility.ts +481 -9
- package/dist/builder/entity/apiEntity.d.ts +0 -3
- package/dist/builder/entity/apiEntity.js.map +0 -1
- package/dist/builder/entity/def.d.ts +0 -3
- package/dist/builder/entity/def.js +0 -19
- package/dist/builder/entity/def.js.map +0 -1
- package/src/builder/entity/def.ts +0 -44
- package/src/guide.ts.off +0 -136
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.flowHeuristic01 = flowHeuristic01;
|
|
4
4
|
const struct_1 = require("@voxgig/struct");
|
|
5
5
|
const jostraca_1 = require("jostraca");
|
|
6
|
+
const struct_2 = require("@voxgig/struct");
|
|
7
|
+
const types_1 = require("../../types");
|
|
8
|
+
const utility_1 = require("../../utility");
|
|
6
9
|
async function flowHeuristic01(ctx) {
|
|
7
10
|
let entity = ctx.guide.entity;
|
|
8
11
|
const flows = [];
|
|
@@ -13,9 +16,10 @@ async function flowHeuristic01(ctx) {
|
|
|
13
16
|
}
|
|
14
17
|
function resolveBasicEntityFlow(ctx, entity) {
|
|
15
18
|
const { apimodel, model } = ctx;
|
|
16
|
-
const
|
|
19
|
+
const kit = apimodel.main[types_1.KIT];
|
|
20
|
+
const apiEntity = kit.entity[entity.name];
|
|
17
21
|
const flow = {
|
|
18
|
-
name: 'Basic' + apiEntity
|
|
22
|
+
name: 'Basic' + (0, utility_1.nom)(apiEntity, 'Name') + 'Flow'
|
|
19
23
|
};
|
|
20
24
|
const refs = [
|
|
21
25
|
`${apiEntity.name}01`,
|
|
@@ -27,7 +31,7 @@ function resolveBasicEntityFlow(ctx, entity) {
|
|
|
27
31
|
name: flow.name,
|
|
28
32
|
active: true,
|
|
29
33
|
param: {
|
|
30
|
-
[`${model.NAME}_TEST_${apiEntity
|
|
34
|
+
[`${model.NAME}_TEST_${(0, utility_1.nom)(apiEntity, 'NAME')}_ENTID`]: idmap,
|
|
31
35
|
[`${model.NAME}_TEST_LIVE`]: "FALSE",
|
|
32
36
|
[`${model.NAME}_TEST_EXPLAIN`]: "FALSE",
|
|
33
37
|
},
|
|
@@ -39,8 +43,8 @@ function resolveBasicEntityFlow(ctx, entity) {
|
|
|
39
43
|
refs.map((ref, i) => {
|
|
40
44
|
const id = idmap[ref];
|
|
41
45
|
const ent = data[id] = {};
|
|
42
|
-
let num = (i * (0, struct_1.size)(apiEntity.
|
|
43
|
-
(0, jostraca_1.each)(apiEntity.
|
|
46
|
+
let num = (i * (0, struct_1.size)(apiEntity.fields) * 10);
|
|
47
|
+
(0, jostraca_1.each)(apiEntity.fields, (field) => {
|
|
44
48
|
ent[field.name] =
|
|
45
49
|
'number' === field.type ? num :
|
|
46
50
|
'boolean' === field.type ? 0 === num % 2 :
|
|
@@ -55,9 +59,11 @@ function resolveBasicEntityFlow(ctx, entity) {
|
|
|
55
59
|
let num = 0;
|
|
56
60
|
let name;
|
|
57
61
|
const am = {};
|
|
58
|
-
|
|
62
|
+
const entop = apiEntity.op ?? {};
|
|
63
|
+
if (entop.load) {
|
|
64
|
+
const alt = findMainLoadAlt(entop.load);
|
|
59
65
|
// Get additional required match properties
|
|
60
|
-
(0, jostraca_1.each)(
|
|
66
|
+
(0, jostraca_1.each)(alt?.args.param, (param) => {
|
|
61
67
|
if (param.required) {
|
|
62
68
|
let ancestorName = param.name;
|
|
63
69
|
let ancestorEntity = apimodel.main.api.entity[ancestorName];
|
|
@@ -71,7 +77,7 @@ function resolveBasicEntityFlow(ctx, entity) {
|
|
|
71
77
|
};
|
|
72
78
|
am[param.name] =
|
|
73
79
|
`\`dm$=p.${model.NAME}_TEST_${ancestorEntity.NAME}_ENTID.${ancestorEntity.name}01\``;
|
|
74
|
-
data[`${apiEntity
|
|
80
|
+
data[`${(0, utility_1.nom)(apiEntity, 'NAME')}01`][param.name] = ancestorEntity.NAME + '01';
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
83
|
});
|
|
@@ -82,7 +88,7 @@ function resolveBasicEntityFlow(ctx, entity) {
|
|
|
82
88
|
entity: `${apiEntity.name}`,
|
|
83
89
|
action: 'load',
|
|
84
90
|
match: {
|
|
85
|
-
id: `\`dm$=p.${model.NAME}_TEST_${apiEntity
|
|
91
|
+
id: `\`dm$=p.${model.NAME}_TEST_${(0, utility_1.nom)(apiEntity, 'NAME')}_ENTID.${apiEntity.name}01\``,
|
|
86
92
|
...am,
|
|
87
93
|
},
|
|
88
94
|
valid: {
|
|
@@ -92,7 +98,7 @@ function resolveBasicEntityFlow(ctx, entity) {
|
|
|
92
98
|
}
|
|
93
99
|
});
|
|
94
100
|
}
|
|
95
|
-
if (
|
|
101
|
+
if (entop.update && entop.load) {
|
|
96
102
|
num++;
|
|
97
103
|
name = `update_${apiEntity.name}${num}`;
|
|
98
104
|
const id = idmap[`${apiEntity.name}01`];
|
|
@@ -119,7 +125,7 @@ function resolveBasicEntityFlow(ctx, entity) {
|
|
|
119
125
|
entity: `${apiEntity.name}`,
|
|
120
126
|
action: 'load',
|
|
121
127
|
match: {
|
|
122
|
-
id: `\`dm$=p.${model.NAME}_TEST_${apiEntity
|
|
128
|
+
id: `\`dm$=p.${model.NAME}_TEST_${(0, utility_1.nom)(apiEntity, 'NAME')}_ENTID.${apiEntity.name}01\``,
|
|
123
129
|
...am,
|
|
124
130
|
},
|
|
125
131
|
valid: {
|
|
@@ -132,6 +138,10 @@ function resolveBasicEntityFlow(ctx, entity) {
|
|
|
132
138
|
}
|
|
133
139
|
return flow;
|
|
134
140
|
}
|
|
141
|
+
function findMainLoadAlt(op) {
|
|
142
|
+
let cands = op.alts.filter(a => '{id}' === (0, struct_2.getelem)(a.parts, -1));
|
|
143
|
+
return cands[0];
|
|
144
|
+
}
|
|
135
145
|
function makeUpdateData(name, apiEntity, flow, id) {
|
|
136
146
|
const ud = {};
|
|
137
147
|
const data = flow.model.test.entity[apiEntity.name];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowHeuristic01.js","sourceRoot":"","sources":["../../../src/builder/flow/flowHeuristic01.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"flowHeuristic01.js","sourceRoot":"","sources":["../../../src/builder/flow/flowHeuristic01.ts"],"names":[],"mappings":";;AAwOE,0CAAe;AAvOjB,2CAAqC;AAErC,uCAAsC;AAEtC,2CAAwC;AAOxC,uCAEoB;AAQpB,2CAEsB;AAGtB,KAAK,UAAU,eAAe,CAAC,GAAQ;IACrC,IAAI,MAAM,GAAG,GAAG,CAAC,K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__importDefault) || function (mod) {
|
|
3
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
5
|
};
|
|
@@ -6,17 +7,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
7
|
exports.makeFlowBuilder = makeFlowBuilder;
|
|
7
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
9
|
const jostraca_1 = require("jostraca");
|
|
10
|
+
const types_1 = require("../types");
|
|
9
11
|
const utility_1 = require("../utility");
|
|
10
12
|
const flowHeuristic01_1 = require("./flow/flowHeuristic01");
|
|
11
13
|
async function makeFlowBuilder(ctx) {
|
|
12
14
|
let flows = [];
|
|
15
|
+
let flowBuilder = () => {
|
|
16
|
+
ctx.warn({
|
|
17
|
+
step: 'flow',
|
|
18
|
+
note: 'Unable to generate flow definitions as flows were not resolved.'
|
|
19
|
+
});
|
|
20
|
+
};
|
|
13
21
|
if ('heuristic01' === ctx.opts.strategy) {
|
|
14
|
-
|
|
22
|
+
try {
|
|
23
|
+
flows = await (0, flowHeuristic01_1.flowHeuristic01)(ctx);
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
err.foo = { x: 1, y: [2] };
|
|
27
|
+
err.foo.z = err.foo;
|
|
28
|
+
ctx.warn({
|
|
29
|
+
step: 'flow',
|
|
30
|
+
note: 'Unable to resolve flows due to unexpected error: ' + err.message,
|
|
31
|
+
err,
|
|
32
|
+
});
|
|
33
|
+
return flowBuilder;
|
|
34
|
+
}
|
|
15
35
|
}
|
|
16
36
|
else {
|
|
17
|
-
|
|
37
|
+
ctx.warn({
|
|
38
|
+
step: 'flow',
|
|
39
|
+
note: 'Unable to resolve flows: unknown guide strategy: ' + ctx.opts.strategy
|
|
40
|
+
});
|
|
41
|
+
return flowBuilder;
|
|
18
42
|
}
|
|
19
|
-
|
|
43
|
+
flowBuilder = () => {
|
|
20
44
|
(0, jostraca_1.Folder)({ name: 'flow' }, () => {
|
|
21
45
|
const barrel = [
|
|
22
46
|
'# Flows\n'
|
|
@@ -27,7 +51,7 @@ async function makeFlowBuilder(ctx) {
|
|
|
27
51
|
let flowModelSrc = (0, utility_1.formatJsonSrc)(JSON.stringify(flow.model, null, 2));
|
|
28
52
|
let flowsrc = `# ${flow.Name}
|
|
29
53
|
|
|
30
|
-
main:
|
|
54
|
+
main: ${types_1.KIT}: flow: ${flow.Name}:
|
|
31
55
|
` + flowModelSrc;
|
|
32
56
|
barrel.push(`@"${node_path_1.default.basename(flowfile)}"`);
|
|
33
57
|
(0, jostraca_1.File)({ name: node_path_1.default.basename(flowfile) }, () => (0, jostraca_1.Content)(flowsrc));
|
|
@@ -37,5 +61,6 @@ main: sdk: flow: ${flow.Name}:
|
|
|
37
61
|
}, () => (0, jostraca_1.Content)(barrel.join('\n')));
|
|
38
62
|
});
|
|
39
63
|
};
|
|
64
|
+
return flowBuilder;
|
|
40
65
|
}
|
|
41
66
|
//# sourceMappingURL=flow.js.map
|
package/dist/builder/flow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow.js","sourceRoot":"","sources":["../../src/builder/flow.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"flow.js","sourceRoot":"","sources":["../../src/builder/flow.ts"],"names":[],"mappings":";AACA,4BAA4B;;;;;AA4F1B,0CAAe;AAzFjB,0DAA4B;AAE5B,uCAAsD;AAGtD,oCAGiB;AAGjB,wCAEmB;AAGnB,4DAAwD;AAGxD,KAAK,UAAU,eAAe,CAAC,GAAkB;IAC/C,IAAI,KAAK,GAAU,EAAE,CAAA;IACrB,IAAI,WAAW,GAAG,GAAG,EAAE;QACrB,GAAG,CAAC,IAAI,CAAC;YACP,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,iEAAiE;SACxE,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,IAAI,aAAa,KAAK,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACxC,IAAI,CAAC;YACH,KAAK,GAAG,MAAM,IAAA,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,IAAI,OAAO,GAAG,KAAK,IAAI,CAAC,IAAI;;QAE5B,WAAG,WAAW,IAAI,CAAC,IAAI;CAC9B,GAAG,YAAY,CAAA;gBAER,MAAM,CAAC,IAAI,CAAC,KAAK,mBAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;gBAE5C,IAAA,eAAI,EAAC,EAAE,IAAI,EAAE,mBAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,IAAA,kBAAO,EAAC,OAAO,CAAC,CAAC,CAAA;YACjE,CAAC,CAAC,CAAA;YAEF,IAAA,eAAI,EAAC;gBACH,IAAI,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,mBAAmB;aACnF,EAAE,GAAG,EAAE,CAAC,IAAA,kBAAO,EAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACtC,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,OAAO,WAAW,CAAA;AACpB,CAAC"}
|
package/dist/def.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
type PathDef = {
|
|
2
|
+
summary?: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
get?: MethodDef;
|
|
5
|
+
put?: MethodDef;
|
|
6
|
+
post?: MethodDef;
|
|
7
|
+
delete?: MethodDef;
|
|
8
|
+
options?: MethodDef;
|
|
9
|
+
head?: MethodDef;
|
|
10
|
+
patch?: MethodDef;
|
|
11
|
+
trace?: MethodDef;
|
|
12
|
+
servers?: ServerDef[];
|
|
13
|
+
parameters?: ParameterDef[];
|
|
14
|
+
tags?: any;
|
|
15
|
+
};
|
|
16
|
+
type MethodDef = {
|
|
17
|
+
tags?: string[];
|
|
18
|
+
summary?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
operationId?: string;
|
|
21
|
+
parameters?: ParameterDef[];
|
|
22
|
+
deprecated?: boolean;
|
|
23
|
+
servers?: ServerDef[];
|
|
24
|
+
};
|
|
25
|
+
type ServerDef = {
|
|
26
|
+
url: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
variables?: Record<string, ServerVariableDef>;
|
|
29
|
+
};
|
|
30
|
+
type ServerVariableDef = {
|
|
31
|
+
enum?: string[];
|
|
32
|
+
default: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
};
|
|
35
|
+
type ParameterDef = {
|
|
36
|
+
name: string;
|
|
37
|
+
in: "query" | "header" | "path" | "cookie";
|
|
38
|
+
description?: string;
|
|
39
|
+
required?: boolean;
|
|
40
|
+
deprecated?: boolean;
|
|
41
|
+
schema?: SchemaDef;
|
|
42
|
+
nullable?: boolean;
|
|
43
|
+
example?: any;
|
|
44
|
+
};
|
|
45
|
+
type SchemaDef = {
|
|
46
|
+
title?: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
type?: string;
|
|
49
|
+
format?: string;
|
|
50
|
+
enum?: any[];
|
|
51
|
+
items?: SchemaDef;
|
|
52
|
+
properties?: Record<string, SchemaDef>;
|
|
53
|
+
required?: string[];
|
|
54
|
+
additionalProperties?: boolean | SchemaDef;
|
|
55
|
+
allOf?: SchemaDef[];
|
|
56
|
+
oneOf?: SchemaDef[];
|
|
57
|
+
anyOf?: SchemaDef[];
|
|
58
|
+
nullable?: boolean;
|
|
59
|
+
default?: any;
|
|
60
|
+
example?: any;
|
|
61
|
+
};
|
|
62
|
+
export type { PathDef, MethodDef, ServerDef, ServerVariableDef, ParameterDef, SchemaDef, };
|
package/dist/def.js
ADDED
package/dist/def.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"def.js","sourceRoot":"","sources":["../src/def.ts"],"names":[],"mappings":";AAAA,iDAAiD"}
|
package/dist/desc.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { PathMatch } from './utility';
|
|
2
|
+
import type { MethodName } from './types';
|
|
3
|
+
import type { ParameterDef } from './def';
|
|
4
|
+
type GuidePathRename = {
|
|
5
|
+
param?: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
type GuideOp = {
|
|
8
|
+
method: MethodName;
|
|
9
|
+
};
|
|
10
|
+
type GuidePath = {
|
|
11
|
+
rename?: GuidePathRename;
|
|
12
|
+
op?: Record<string, GuideOp>;
|
|
13
|
+
};
|
|
14
|
+
type CmpDesc = {
|
|
15
|
+
namedesc?: any;
|
|
16
|
+
path_rate: number;
|
|
17
|
+
method_rate: number;
|
|
18
|
+
};
|
|
19
|
+
type BasicMethodDesc = {
|
|
20
|
+
name: MethodName;
|
|
21
|
+
def: Record<string, any>;
|
|
22
|
+
path: string;
|
|
23
|
+
};
|
|
24
|
+
type MethodDesc = {
|
|
25
|
+
path: string;
|
|
26
|
+
method: string;
|
|
27
|
+
summary: string;
|
|
28
|
+
tags: string[];
|
|
29
|
+
parameters: any[];
|
|
30
|
+
responses: Record<string, any>;
|
|
31
|
+
requestBody: Record<string, any>;
|
|
32
|
+
MethodEntity: MethodEntityDesc;
|
|
33
|
+
};
|
|
34
|
+
type MethodEntityDesc = {
|
|
35
|
+
ref: string;
|
|
36
|
+
cmp: string | null;
|
|
37
|
+
origcmp: string | null;
|
|
38
|
+
origcmpref: string | null;
|
|
39
|
+
why_cmp: string[];
|
|
40
|
+
cmpoccur: number;
|
|
41
|
+
path_rate: number;
|
|
42
|
+
method_rate: number;
|
|
43
|
+
entname: string;
|
|
44
|
+
why_op: string[];
|
|
45
|
+
rename: Record<string, any>;
|
|
46
|
+
why_rename: Record<string, any>;
|
|
47
|
+
rename_orig: string[];
|
|
48
|
+
opname: string;
|
|
49
|
+
why_opname: string[];
|
|
50
|
+
pm?: any;
|
|
51
|
+
};
|
|
52
|
+
type EntityDesc = {
|
|
53
|
+
name: string;
|
|
54
|
+
origname: string;
|
|
55
|
+
plural: string;
|
|
56
|
+
path: Record<string, EntityPathDesc>;
|
|
57
|
+
alias: Record<string, string>;
|
|
58
|
+
cmp: CmpDesc;
|
|
59
|
+
};
|
|
60
|
+
type EntityPathDesc = {
|
|
61
|
+
op: Record<string, any>;
|
|
62
|
+
pm: PathMatch;
|
|
63
|
+
rename: {
|
|
64
|
+
param: Record<string, string>;
|
|
65
|
+
};
|
|
66
|
+
why_rename: {
|
|
67
|
+
why_param: Record<string, string[]>;
|
|
68
|
+
};
|
|
69
|
+
action: Record<string, {
|
|
70
|
+
why_action: string[];
|
|
71
|
+
}>;
|
|
72
|
+
why_action: Record<string, string[]>;
|
|
73
|
+
why_ent: string[];
|
|
74
|
+
why_path: string[];
|
|
75
|
+
};
|
|
76
|
+
type PathDesc = {
|
|
77
|
+
orig: string;
|
|
78
|
+
method: MethodName;
|
|
79
|
+
parts: string[];
|
|
80
|
+
rename: GuidePathRename;
|
|
81
|
+
op: GuidePath["op"];
|
|
82
|
+
def: {
|
|
83
|
+
parameters?: ParameterDef[];
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
type OpDesc = {
|
|
87
|
+
paths: PathDesc[];
|
|
88
|
+
};
|
|
89
|
+
export type { GuidePathRename, GuideOp, GuidePath, CmpDesc, BasicMethodDesc, MethodDesc, MethodEntityDesc, EntityDesc, EntityPathDesc, PathDesc, OpDesc, };
|
package/dist/desc.js
ADDED
package/dist/desc.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"desc.js","sourceRoot":"","sources":["../src/desc.ts"],"names":[],"mappings":";AAAA,iDAAiD"}
|
package/dist/guide/guide.d.ts
CHANGED
package/dist/guide/guide.js
CHANGED
|
@@ -12,11 +12,11 @@ const heuristic01_1 = require("./heuristic01");
|
|
|
12
12
|
const utility_1 = require("../utility");
|
|
13
13
|
// Log non-fatal wierdness.
|
|
14
14
|
const dlog = (0, utility_1.getdlog)('apidef', __filename);
|
|
15
|
+
const aontu = new aontu_1.Aontu();
|
|
15
16
|
async function buildGuide(ctx) {
|
|
17
|
+
const log = ctx.log;
|
|
16
18
|
const errs = [];
|
|
17
|
-
// console.log(ctx)
|
|
18
19
|
const folder = node_path_1.default.resolve(ctx.opts.folder);
|
|
19
|
-
// console.log('GUIDE folder', folder)
|
|
20
20
|
try {
|
|
21
21
|
const basejres = await buildBaseGuide(ctx);
|
|
22
22
|
}
|
|
@@ -25,61 +25,126 @@ async function buildGuide(ctx) {
|
|
|
25
25
|
}
|
|
26
26
|
handleErrors(ctx, errs);
|
|
27
27
|
let src = '';
|
|
28
|
-
let
|
|
28
|
+
let guidepath = node_path_1.default.join(folder, 'guide', (null == ctx.opts.outprefix ? '' : ctx.opts.outprefix) + 'guide.jsonic');
|
|
29
|
+
log.info({
|
|
30
|
+
point: 'generate-guide',
|
|
31
|
+
note: guidepath.replace(process.cwd(), '.'),
|
|
32
|
+
guidepath,
|
|
33
|
+
});
|
|
29
34
|
try {
|
|
30
|
-
src = ctx.fs.readFileSync(
|
|
35
|
+
src = ctx.fs.readFileSync(guidepath, 'utf8');
|
|
31
36
|
}
|
|
32
37
|
catch (err) {
|
|
33
38
|
errs.push(err);
|
|
34
39
|
}
|
|
35
40
|
handleErrors(ctx, errs);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
if (0 === errs.length) {
|
|
42
|
+
const opts = {
|
|
43
|
+
path: guidepath,
|
|
44
|
+
fs: ctx.fs,
|
|
45
|
+
errs,
|
|
46
|
+
};
|
|
47
|
+
const guideModel = aontu.generate(src, opts);
|
|
48
|
+
// console.log('GUIDE-MODEL', guideModel, errs)
|
|
49
|
+
// console.dir(guideModel, { depth: null })
|
|
50
|
+
handleErrors(ctx, errs);
|
|
51
|
+
return guideModel;
|
|
52
|
+
}
|
|
47
53
|
}
|
|
48
54
|
function handleErrors(ctx, errs) {
|
|
49
55
|
if (0 < errs.length) {
|
|
50
|
-
|
|
56
|
+
const topmsg = [];
|
|
57
|
+
const stacks = [];
|
|
51
58
|
for (let err of errs) {
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
err = err instanceof Error ? err :
|
|
60
|
+
err.err instanceof Error ? err.err :
|
|
61
|
+
Array.isArray(err.err) && null != err.err[0] ? err.err[0] :
|
|
62
|
+
err;
|
|
63
|
+
const msg = 'string' === typeof err?.message ? err.message :
|
|
64
|
+
err instanceof Error ? err.message : '' + err;
|
|
65
|
+
topmsg.push(msg);
|
|
66
|
+
stacks.push('' + err.stack);
|
|
54
67
|
}
|
|
55
|
-
|
|
68
|
+
const summary = new Error(`SUMMARY (${errs.length} errors): ` + topmsg.join(' | '));
|
|
69
|
+
summary.stack = stacks.join('\n');
|
|
70
|
+
ctx.log.error(summary);
|
|
71
|
+
summary.errs = () => errs;
|
|
72
|
+
throw summary;
|
|
56
73
|
}
|
|
57
74
|
}
|
|
58
75
|
async function buildBaseGuide(ctx) {
|
|
59
|
-
let baseguide
|
|
76
|
+
let baseguide;
|
|
60
77
|
if ('heuristic01' === ctx.opts.strategy) {
|
|
61
78
|
baseguide = await (0, heuristic01_1.heuristic01)(ctx);
|
|
62
79
|
}
|
|
63
80
|
else {
|
|
64
81
|
throw new Error('Unknown guide strategy: ' + ctx.opts.strategy);
|
|
65
82
|
}
|
|
83
|
+
// console.dir(baseguide, { depth: null })
|
|
66
84
|
const guideBlocks = [
|
|
67
85
|
'# Guide',
|
|
68
86
|
'',
|
|
69
87
|
'guide: {',
|
|
70
88
|
];
|
|
71
|
-
|
|
89
|
+
const metrics = baseguide.metrics;
|
|
90
|
+
// TODO: these should influence the IS_ENTCMP_METHOD_RATE etc. values
|
|
91
|
+
const epr = 0 < metrics.count.path ? (metrics.count.entity / metrics.count.path).toFixed(3) : -1;
|
|
92
|
+
const emr = 0 < metrics.count.method ? (metrics.count.entity / metrics.count.method).toFixed(3) : -1;
|
|
93
|
+
ctx.log.info({
|
|
94
|
+
point: 'metrics',
|
|
95
|
+
metrics,
|
|
96
|
+
note: `epr=${epr} emr=${emr} ` +
|
|
97
|
+
`(entity=${metrics.count.entity} ` +
|
|
98
|
+
`paths=${metrics.count.path} methods=${metrics.count.method})`
|
|
99
|
+
});
|
|
100
|
+
validateBaseBuide(ctx, baseguide);
|
|
101
|
+
const sw = (s) => ctx.opts.why?.show ? s : '';
|
|
102
|
+
const qs = (v) => JSON.stringify(v);
|
|
103
|
+
const qt = (v) => '(' + qs(v) + ')';
|
|
104
|
+
guideBlocks.push(` metrics: count: entity: ${metrics.count.entity}
|
|
105
|
+
metrics: count: path: ${metrics.count.path}
|
|
106
|
+
metrics: count: method: ${metrics.count.method}`);
|
|
107
|
+
// NOTE: items(...) sorts the iteration elements, so the generated model code
|
|
108
|
+
// is deterministic.
|
|
109
|
+
(0, struct_1.items)(baseguide.entity).map(([entname, entity]) => {
|
|
72
110
|
guideBlocks.push(`
|
|
73
|
-
entity: ${
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
111
|
+
entity: ${entname}: {`
|
|
112
|
+
// sw(0 < entity.why_name.length ? ' # name:' + entity.why_name.join(';') : '')
|
|
113
|
+
);
|
|
114
|
+
// NOTE: items(...) sorts the paths
|
|
115
|
+
(0, struct_1.items)(entity.path).map(([pathstr, path]) => {
|
|
116
|
+
(0, utility_1.debugpath)(pathstr, null, 'BASE-GUIDE', entname, pathstr, (0, utility_1.formatJSONIC)(path, { hsepd: 0, $: true, color: true }));
|
|
117
|
+
guideBlocks.push(` path: ${qs(pathstr)}: {` +
|
|
118
|
+
sw(0 < path.why_path.length ?
|
|
119
|
+
' # ent=' + entname + ';' +
|
|
120
|
+
(entity.orig !== entname && null != entity.orig ? 'orig=' + entity.orig + ';' : '') +
|
|
121
|
+
path.why_path.join(';') : ''));
|
|
122
|
+
if (!(0, struct_1.isempty)(path.action)) {
|
|
123
|
+
(0, struct_1.items)(path.action).map(([actname, actdesc]) => {
|
|
124
|
+
guideBlocks.push(` action: ${qs(actname)}: {}` +
|
|
125
|
+
sw(0 < actdesc.why_action.length ?
|
|
126
|
+
' # ' + actdesc.why_action.join(';') : ''));
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
if (!(0, struct_1.isempty)(path.rename?.param)) {
|
|
130
|
+
(0, struct_1.items)(path.rename.param).map(([psrc, rp]) => {
|
|
131
|
+
guideBlocks.push(` rename: param: ${qs(psrc)}: *${qs(rp.target)}` +
|
|
132
|
+
sw(0 < rp.why_rename.length ?
|
|
133
|
+
' # ' + rp.why_rename.join(';') : ''));
|
|
134
|
+
});
|
|
135
|
+
}
|
|
78
136
|
(0, struct_1.items)(path.op).map(([opname, op]) => {
|
|
79
|
-
guideBlocks.push(`
|
|
80
|
-
(0 < op.why_op.length ? '
|
|
81
|
-
if (op.transform
|
|
82
|
-
guideBlocks.push(
|
|
137
|
+
guideBlocks.push(` op: ${opname}: method: *${op.method}` +
|
|
138
|
+
sw(0 < op.why_op.length ? ' # ' + op.why_op : ''));
|
|
139
|
+
if (null != op.transform.req) {
|
|
140
|
+
guideBlocks.push(
|
|
141
|
+
// ` op: ${opname}: transform: res: *${qt(op.transform.res)}|top`)
|
|
142
|
+
` op: ${opname}: transform: res: *${qt(op.transform.res)}|top`);
|
|
143
|
+
}
|
|
144
|
+
if (null != op.transform.res) {
|
|
145
|
+
guideBlocks.push(
|
|
146
|
+
// ` op: ${opname}: transform: res: *${qt(op.transform.res)}|top`)
|
|
147
|
+
` op: ${opname}: transform: res: *${qt(op.transform.res)}|top`);
|
|
83
148
|
}
|
|
84
149
|
});
|
|
85
150
|
guideBlocks.push(` }`);
|
|
@@ -104,4 +169,70 @@ async function buildBaseGuide(ctx) {
|
|
|
104
169
|
}, root);
|
|
105
170
|
return jres;
|
|
106
171
|
}
|
|
172
|
+
function validateBaseBuide(ctx, baseguide) {
|
|
173
|
+
const srcm = {};
|
|
174
|
+
// Each orig path.
|
|
175
|
+
(0, jostraca_1.each)(ctx.def.paths, (pdef) => {
|
|
176
|
+
const pathStr = pdef.key$;
|
|
177
|
+
// Each orig method.
|
|
178
|
+
(0, jostraca_1.each)(pdef, (mdef) => {
|
|
179
|
+
if (mdef.key$.match(/^get|post|put|patch|delete|head|options$/i)) {
|
|
180
|
+
let key = pathStr + ' ' + mdef.key$.toUpperCase();
|
|
181
|
+
let desc = (srcm[key] = (srcm[key] || { c: 0 }));
|
|
182
|
+
desc.c++;
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
const genm = {};
|
|
187
|
+
// Each entity.
|
|
188
|
+
(0, jostraca_1.each)(baseguide.entity, (entm) => {
|
|
189
|
+
if ((0, struct_1.isempty)(entm.path)) {
|
|
190
|
+
ctx.warn({
|
|
191
|
+
note: `No paths defined for entity=${entm.name}`,
|
|
192
|
+
entm,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
// Each path.
|
|
196
|
+
(0, jostraca_1.each)(entm.path, (pathm, pathStr) => {
|
|
197
|
+
if ((0, struct_1.isempty)(pathm.op)) {
|
|
198
|
+
ctx.warn({
|
|
199
|
+
note: `No operations defined for entity=${entm.name} path=${pathStr}`,
|
|
200
|
+
path: pathStr,
|
|
201
|
+
entm,
|
|
202
|
+
pathm,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
// Each op.
|
|
206
|
+
(0, jostraca_1.each)(pathm.op, (odef) => {
|
|
207
|
+
let key = pathStr + ' ' + odef.method;
|
|
208
|
+
let desc = (genm[key] = (genm[key] || { c: 0 }));
|
|
209
|
+
desc.c++;
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
const srcp = Object.keys(srcm).sort()
|
|
214
|
+
.reduce((a, k) => (a.push(k + ':c=' + srcm[k].c), a), []);
|
|
215
|
+
const genp = Object.keys(genm).sort()
|
|
216
|
+
.reduce((a, k) => (a.push(k + ':c=' + genm[k].c), a), []);
|
|
217
|
+
// Check that all paths have been assigned to entities.
|
|
218
|
+
if (srcp.join(';') !== genp.join(';')) {
|
|
219
|
+
console.log(' ', 'SRC-PATH'.padEnd(60, ' '), 'GEN-PATH');
|
|
220
|
+
for (let i = 0, j = 0; i < srcp.length || j < genp.length; i++, j++) {
|
|
221
|
+
let srcps = srcp[i];
|
|
222
|
+
let genps = genp[j];
|
|
223
|
+
let prefix = ' ';
|
|
224
|
+
if (srcps !== genps) {
|
|
225
|
+
prefix = ' *** ';
|
|
226
|
+
if (srcps === genp[j + 1]) {
|
|
227
|
+
j++;
|
|
228
|
+
}
|
|
229
|
+
else if (genps === srcp[i + 1]) {
|
|
230
|
+
i++;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
console.log(prefix, srcps.padEnd(60, ' '), genps);
|
|
234
|
+
}
|
|
235
|
+
throw new Error('PATH MISMATCH');
|
|
236
|
+
}
|
|
237
|
+
}
|
|
107
238
|
//# sourceMappingURL=guide.js.map
|