@voxgig/apidef 1.1.1 → 1.3.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.
- package/bin/voxgig-apidef +0 -2
- package/dist/apidef.d.ts +26 -13
- package/dist/apidef.js +114 -146
- package/dist/apidef.js.map +1 -1
- package/dist/parse.d.ts +2 -0
- package/dist/parse.js +26 -0
- package/dist/parse.js.map +1 -0
- package/dist/transform/entity.d.ts +2 -5
- package/dist/transform/entity.js +16 -8
- package/dist/transform/entity.js.map +1 -1
- package/dist/transform/field.d.ts +2 -5
- package/dist/transform/field.js +11 -8
- package/dist/transform/field.js.map +1 -1
- package/dist/transform/manual.d.ts +2 -5
- package/dist/transform/manual.js +5 -4
- package/dist/transform/manual.js.map +1 -1
- package/dist/transform/operation.d.ts +2 -5
- package/dist/transform/operation.js +83 -7
- package/dist/transform/operation.js.map +1 -1
- package/dist/transform/top.d.ts +2 -5
- package/dist/transform/top.js +7 -7
- package/dist/transform/top.js.map +1 -1
- package/dist/transform.d.ts +71 -5
- package/dist/transform.js +45 -9
- package/dist/transform.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/model/apidef.jsonic +44 -0
- package/package.json +11 -11
- package/src/apidef.ts +117 -171
- package/src/parse.ts +36 -0
- package/src/transform/entity.ts +22 -9
- package/src/transform/field.ts +12 -8
- package/src/transform/manual.ts +10 -3
- package/src/transform/operation.ts +105 -9
- package/src/transform/top.ts +11 -5
- package/src/transform.ts +60 -11
- /package/model/{guide.jsonic → guide.jsonic.off} +0 -0
package/bin/voxgig-apidef
CHANGED
package/dist/apidef.d.ts
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { Pino } from '@voxgig/util';
|
|
2
2
|
type ApiDefOptions = {
|
|
3
|
+
def?: string;
|
|
3
4
|
fs?: any;
|
|
4
5
|
pino?: ReturnType<typeof Pino>;
|
|
5
6
|
debug?: boolean | string;
|
|
7
|
+
folder?: string;
|
|
8
|
+
meta?: Record<string, any>;
|
|
9
|
+
outprefix?: string;
|
|
6
10
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
declare function ApiDef(opts: ApiDefOptions): {
|
|
12
|
+
generate: (spec: any) => Promise<{
|
|
13
|
+
ok: boolean;
|
|
14
|
+
name: string;
|
|
15
|
+
processResult: {
|
|
16
|
+
ok: boolean;
|
|
17
|
+
msg: string;
|
|
18
|
+
results: import("./transform").TransformResult[];
|
|
19
|
+
};
|
|
20
|
+
apimodel?: undefined;
|
|
21
|
+
} | {
|
|
17
22
|
ok: boolean;
|
|
18
|
-
|
|
23
|
+
name: string;
|
|
24
|
+
apimodel: {
|
|
19
25
|
main: {
|
|
20
26
|
api: {
|
|
21
27
|
entity: {};
|
|
@@ -23,7 +29,14 @@ declare function ApiDef(opts?: ApiDefOptions): {
|
|
|
23
29
|
def: {};
|
|
24
30
|
};
|
|
25
31
|
};
|
|
26
|
-
|
|
32
|
+
processResult?: undefined;
|
|
33
|
+
}>;
|
|
27
34
|
};
|
|
28
|
-
|
|
35
|
+
declare namespace ApiDef {
|
|
36
|
+
var makeBuild: (opts: ApiDefOptions) => Promise<{
|
|
37
|
+
(model: any, build: any, ctx: any): Promise<any>;
|
|
38
|
+
step: string;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
export type { ApiDefOptions, };
|
|
29
42
|
export { ApiDef, };
|
package/dist/apidef.js
CHANGED
|
@@ -16,13 +16,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
16
16
|
}) : function(o, v) {
|
|
17
17
|
o["default"] = v;
|
|
18
18
|
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
26
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
38
|
};
|
|
@@ -30,55 +40,67 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
30
40
|
exports.ApiDef = ApiDef;
|
|
31
41
|
const Fs = __importStar(require("node:fs"));
|
|
32
42
|
const node_path_1 = __importDefault(require("node:path"));
|
|
43
|
+
const node_util_1 = require("node:util");
|
|
33
44
|
const openapi_core_1 = require("@redocly/openapi-core");
|
|
34
|
-
const
|
|
35
|
-
const aontu_1 = require("aontu");
|
|
45
|
+
const gubu_1 = require("gubu");
|
|
36
46
|
const util_1 = require("@voxgig/util");
|
|
37
47
|
const transform_1 = require("./transform");
|
|
38
|
-
|
|
48
|
+
const ModelShape = (0, gubu_1.Gubu)({
|
|
49
|
+
def: String,
|
|
50
|
+
main: {
|
|
51
|
+
guide: {},
|
|
52
|
+
sdk: {},
|
|
53
|
+
def: {},
|
|
54
|
+
api: {},
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const OpenModelShape = (0, gubu_1.Gubu)((0, gubu_1.Open)(ModelShape));
|
|
58
|
+
const BuildShape = (0, gubu_1.Gubu)({
|
|
59
|
+
spec: {
|
|
60
|
+
base: '',
|
|
61
|
+
path: '',
|
|
62
|
+
debug: '',
|
|
63
|
+
use: {},
|
|
64
|
+
res: [],
|
|
65
|
+
require: '',
|
|
66
|
+
log: {},
|
|
67
|
+
fs: (0, gubu_1.Any)()
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const OpenBuildShape = (0, gubu_1.Gubu)((0, gubu_1.Open)(BuildShape));
|
|
71
|
+
function ApiDef(opts) {
|
|
39
72
|
const fs = opts.fs || Fs;
|
|
40
73
|
const pino = (0, util_1.prettyPino)('apidef', opts);
|
|
41
74
|
const log = pino.child({ cmp: 'apidef' });
|
|
42
|
-
async function watch(spec) {
|
|
43
|
-
log.info({ point: 'watch-start' });
|
|
44
|
-
log.debug({ point: 'watch-spec', spec });
|
|
45
|
-
await generate(spec);
|
|
46
|
-
const fsw = new chokidar_1.FSWatcher();
|
|
47
|
-
fsw.on('change', (...args) => {
|
|
48
|
-
log.trace({ watch: 'change', file: args[0] });
|
|
49
|
-
generate(spec);
|
|
50
|
-
});
|
|
51
|
-
log.trace({ watch: 'add', what: 'def', file: spec.def });
|
|
52
|
-
fsw.add(spec.def);
|
|
53
|
-
log.trace({ watch: 'add', what: 'guide', file: spec.guide });
|
|
54
|
-
fsw.add(spec.guide);
|
|
55
|
-
}
|
|
56
75
|
async function generate(spec) {
|
|
57
76
|
const start = Date.now();
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
77
|
+
const model = OpenModelShape(spec.model);
|
|
78
|
+
const build = OpenBuildShape(spec.build);
|
|
79
|
+
const buildspec = build.spec;
|
|
80
|
+
let defpath = model.def;
|
|
81
|
+
// TOOD: defpath should be independently defined
|
|
82
|
+
defpath = node_path_1.default.join(buildspec.base, '..', 'def', defpath);
|
|
83
|
+
log.info({
|
|
84
|
+
point: 'generate-start',
|
|
85
|
+
note: defpath.replace(process.cwd(), '.'), defpath, start
|
|
86
|
+
});
|
|
62
87
|
// TODO: Validate spec
|
|
63
88
|
const ctx = {
|
|
64
89
|
log,
|
|
65
90
|
spec,
|
|
66
|
-
guide: {},
|
|
67
91
|
opts,
|
|
68
92
|
util: { fixName: transform_1.fixName },
|
|
69
|
-
defpath: node_path_1.default.dirname(defpath)
|
|
93
|
+
defpath: node_path_1.default.dirname(defpath),
|
|
94
|
+
model,
|
|
70
95
|
};
|
|
71
|
-
const guide = await resolveGuide(spec, opts);
|
|
72
|
-
if (null == guide) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
log.debug({ point: 'guide', guide });
|
|
76
|
-
ctx.guide = guide;
|
|
77
96
|
const transformSpec = await (0, transform_1.resolveTransforms)(ctx);
|
|
78
|
-
log.debug({
|
|
97
|
+
log.debug({
|
|
98
|
+
point: 'transform', spec: transformSpec,
|
|
99
|
+
note: log.levelVal <= 20 ? (0, node_util_1.inspect)(transformSpec) : ''
|
|
100
|
+
});
|
|
79
101
|
let source;
|
|
80
102
|
try {
|
|
81
|
-
source = fs.readFileSync(
|
|
103
|
+
source = fs.readFileSync(defpath, 'utf8');
|
|
82
104
|
}
|
|
83
105
|
catch (err) {
|
|
84
106
|
log.error({ read: 'fail', what: 'def', file: defpath, err });
|
|
@@ -97,7 +119,7 @@ function ApiDef(opts = {}) {
|
|
|
97
119
|
log.error({ parse: 'fail', what: 'openapi', file: defpath, err });
|
|
98
120
|
throw err;
|
|
99
121
|
}
|
|
100
|
-
const
|
|
122
|
+
const apimodel = {
|
|
101
123
|
main: {
|
|
102
124
|
api: {
|
|
103
125
|
entity: {}
|
|
@@ -105,38 +127,40 @@ function ApiDef(opts = {}) {
|
|
|
105
127
|
def: {},
|
|
106
128
|
},
|
|
107
129
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
catch (err) {
|
|
120
|
-
log.error({ process: 'fail', what: 'transform', err });
|
|
121
|
-
throw err;
|
|
130
|
+
const def = bundle.bundle.parsed;
|
|
131
|
+
const processResult = await (0, transform_1.processTransforms)(ctx, transformSpec, apimodel, def);
|
|
132
|
+
if (!processResult.ok) {
|
|
133
|
+
log.error({
|
|
134
|
+
fail: 'process', point: 'transform-result',
|
|
135
|
+
result: processResult, note: processResult.msg,
|
|
136
|
+
err: processResult.results[0]?.err
|
|
137
|
+
});
|
|
138
|
+
return { ok: false, name: 'apidef', processResult };
|
|
122
139
|
}
|
|
123
|
-
const modelapi = { main: { api:
|
|
140
|
+
const modelapi = { main: { api: apimodel.main.api } };
|
|
124
141
|
let modelSrc = JSON.stringify(modelapi, null, 2);
|
|
125
|
-
modelSrc =
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
142
|
+
modelSrc =
|
|
143
|
+
'# GENERATED FILE - DO NOT EDIT\n\n' +
|
|
144
|
+
modelSrc.substring(1, modelSrc.length - 1).replace(/\n /g, '\n');
|
|
145
|
+
const modelPath = node_path_1.default.normalize(spec.config.model);
|
|
146
|
+
// console.log('modelPath', modelPath)
|
|
147
|
+
writeChanged('api-model', modelPath, modelSrc);
|
|
148
|
+
const modelBasePath = node_path_1.default.dirname(modelPath);
|
|
149
|
+
const defFilePath = node_path_1.default.join(modelBasePath, (null == opts.outprefix ? '' : opts.outprefix) + 'def-generated.jsonic');
|
|
150
|
+
const modelDef = { main: { def: apimodel.main.def } };
|
|
130
151
|
let modelDefSrc = JSON.stringify(modelDef, null, 2);
|
|
131
|
-
modelDefSrc =
|
|
152
|
+
modelDefSrc =
|
|
153
|
+
'# GENERATED FILE - DO NOT EDIT\n\n' +
|
|
154
|
+
modelDefSrc.substring(1, modelDefSrc.length - 1).replace(/\n /g, '\n');
|
|
132
155
|
writeChanged('def-model', defFilePath, modelDefSrc);
|
|
133
156
|
log.info({ point: 'generate-end', note: 'success', break: true });
|
|
134
157
|
return {
|
|
135
158
|
ok: true,
|
|
136
|
-
|
|
159
|
+
name: 'apidef',
|
|
160
|
+
apimodel,
|
|
137
161
|
};
|
|
138
162
|
}
|
|
139
|
-
function writeChanged(
|
|
163
|
+
function writeChanged(point, path, content) {
|
|
140
164
|
let exists = false;
|
|
141
165
|
let changed = false;
|
|
142
166
|
let action = '';
|
|
@@ -149,10 +173,11 @@ function ApiDef(opts = {}) {
|
|
|
149
173
|
existingContent = fs.readFileSync(path, 'utf8');
|
|
150
174
|
}
|
|
151
175
|
changed = existingContent !== content;
|
|
176
|
+
// console.log('WC', changed, path, existingContent, content)
|
|
152
177
|
log.info({
|
|
153
|
-
point: 'write-' +
|
|
154
|
-
note: 'changed
|
|
155
|
-
write: 'file',
|
|
178
|
+
point: 'write-' + point,
|
|
179
|
+
note: (changed ? '' : 'not-') + 'changed ' + path,
|
|
180
|
+
write: 'file', skip: !changed, exists, changed,
|
|
156
181
|
contentLength: content.length, file: path
|
|
157
182
|
});
|
|
158
183
|
if (changed) {
|
|
@@ -162,94 +187,37 @@ function ApiDef(opts = {}) {
|
|
|
162
187
|
}
|
|
163
188
|
catch (err) {
|
|
164
189
|
log.error({
|
|
165
|
-
fail: action,
|
|
190
|
+
fail: action, point, file: path, exists, changed,
|
|
166
191
|
contentLength: content.length, err
|
|
167
192
|
});
|
|
193
|
+
err.__logged__ = true;
|
|
168
194
|
throw err;
|
|
169
195
|
}
|
|
170
196
|
}
|
|
171
|
-
async function resolveGuide(spec, _opts) {
|
|
172
|
-
if (null == spec.guide) {
|
|
173
|
-
spec.guide = spec.def + '-guide.jsonic';
|
|
174
|
-
}
|
|
175
|
-
const path = node_path_1.default.normalize(spec.guide);
|
|
176
|
-
let src;
|
|
177
|
-
let action = '';
|
|
178
|
-
let exists = false;
|
|
179
|
-
try {
|
|
180
|
-
action = 'exists';
|
|
181
|
-
let exists = fs.existsSync(path);
|
|
182
|
-
log.debug({ read: 'file', what: 'guide', file: path, exists });
|
|
183
|
-
if (exists) {
|
|
184
|
-
action = 'read';
|
|
185
|
-
src = fs.readFileSync(path, 'utf8');
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
src = `
|
|
189
|
-
# API Specification Transform Guide
|
|
190
|
-
|
|
191
|
-
@"@voxgig/apidef/model/guide.jsonic"
|
|
192
|
-
|
|
193
|
-
guide: entity: {
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
guide: control: transform: openapi: order: \`
|
|
198
|
-
top,
|
|
199
|
-
entity,
|
|
200
|
-
operation,
|
|
201
|
-
field,
|
|
202
|
-
manual,
|
|
203
|
-
\`
|
|
204
|
-
|
|
205
|
-
`;
|
|
206
|
-
action = 'write';
|
|
207
|
-
fs.writeFileSync(path, src);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
catch (err) {
|
|
211
|
-
log.error({ fail: action, what: 'guide', file: path, exists, err });
|
|
212
|
-
throw err;
|
|
213
|
-
}
|
|
214
|
-
const aopts = { path };
|
|
215
|
-
const root = (0, aontu_1.Aontu)(src, aopts);
|
|
216
|
-
const hasErr = root.err && 0 < root.err.length;
|
|
217
|
-
if (hasErr) {
|
|
218
|
-
for (let serr of root.err) {
|
|
219
|
-
let err = new Error('Guide model: ' + serr.msg);
|
|
220
|
-
err.cause$ = [serr];
|
|
221
|
-
if ('syntax' === serr.why) {
|
|
222
|
-
err.uxmsg$ = true;
|
|
223
|
-
}
|
|
224
|
-
log.error({ fail: 'parse', point: 'guide-parse', file: path, err });
|
|
225
|
-
if (err.uxmsg$) {
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
err.rooterrs$ = root.err;
|
|
230
|
-
throw err;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
let genctx = new aontu_1.Context({ root });
|
|
235
|
-
const guide = spec.guideModel = root.gen(genctx);
|
|
236
|
-
// TODO: collect all errors
|
|
237
|
-
if (genctx.err && 0 < genctx.err.length) {
|
|
238
|
-
const err = new Error('Guide build error:\n' +
|
|
239
|
-
(genctx.err.map((pe) => pe.msg)).join('\n'));
|
|
240
|
-
log.error({ fail: 'build', what: 'guide', file: path, err });
|
|
241
|
-
err.errs = () => genctx.err;
|
|
242
|
-
throw err;
|
|
243
|
-
}
|
|
244
|
-
const pathParts = node_path_1.default.parse(path);
|
|
245
|
-
spec.guideModelPath = node_path_1.default.join(pathParts.dir, pathParts.name + '.json');
|
|
246
|
-
const updatedSrc = JSON.stringify(guide, null, 2);
|
|
247
|
-
writeChanged('guide-model', spec.guideModelPath, updatedSrc);
|
|
248
|
-
return guide;
|
|
249
|
-
}
|
|
250
197
|
return {
|
|
251
|
-
watch,
|
|
252
198
|
generate,
|
|
253
199
|
};
|
|
254
200
|
}
|
|
201
|
+
ApiDef.makeBuild = async function (opts) {
|
|
202
|
+
let apidef = undefined;
|
|
203
|
+
const outprefix = null == opts.outprefix ? '' : opts.outprefix;
|
|
204
|
+
const config = {
|
|
205
|
+
def: opts.def || 'no-def',
|
|
206
|
+
kind: 'openapi3',
|
|
207
|
+
model: opts.folder ?
|
|
208
|
+
(opts.folder + '/' + outprefix + 'api-generated.jsonic') : 'no-model',
|
|
209
|
+
meta: opts.meta || {},
|
|
210
|
+
};
|
|
211
|
+
const build = async function (model, build, ctx) {
|
|
212
|
+
if (null == apidef) {
|
|
213
|
+
apidef = ApiDef({
|
|
214
|
+
...opts,
|
|
215
|
+
pino: build.log,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return await apidef.generate({ model, build, config });
|
|
219
|
+
};
|
|
220
|
+
build.step = 'pre';
|
|
221
|
+
return build;
|
|
222
|
+
};
|
|
255
223
|
//# sourceMappingURL=apidef.js.map
|
package/dist/apidef.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apidef.js","sourceRoot":"","sources":["../src/apidef.ts"],"names":[],"mappings":";AAAA,4CAA4C
|
|
1
|
+
{"version":3,"file":"apidef.js","sourceRoot":"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dist/parse.d.ts
ADDED
package/dist/parse.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Copyright (c) 2024 Voxgig, MIT License */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.parse = parse;
|
|
5
|
+
const openapi_core_1 = require("@redocly/openapi-core");
|
|
6
|
+
async function parse(kind, source) {
|
|
7
|
+
if ('OpenAPI' === kind) {
|
|
8
|
+
return parseOpenAPI(source);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
throw new Error('@voxgig/apidef-parse: unknown kind: ' + kind);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async function parseOpenAPI(source) {
|
|
15
|
+
const config = await (0, openapi_core_1.createConfig)({});
|
|
16
|
+
let bundle;
|
|
17
|
+
bundle = await (0, openapi_core_1.bundleFromString)({
|
|
18
|
+
source,
|
|
19
|
+
config,
|
|
20
|
+
dereference: true,
|
|
21
|
+
});
|
|
22
|
+
// console.dir(bundle.bundle, { depth: 1 })
|
|
23
|
+
const def = bundle.bundle.parsed;
|
|
24
|
+
return def;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":";AAAA,4CAA4C;;AAkC1C,sBAAK;AAhCP,wDAAsE;AAGtE,KAAK,UAAU,KAAK,CAAC,IAAY,EAAE,MAAW;IAC5C,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,OAAO,YAAY,CAAC,MAAM,CAAC,CAAA;IAC7B,CAAC;SACI,CAAC;QACJ,MAAM,IAAI,KAAK,CAAC,sCAAsC,GAAG,IAAI,CAAC,CAAA;IAChE,CAAC;AACH,CAAC;AAGD,KAAK,UAAU,YAAY,CAAC,MAAW;IACrC,MAAM,MAAM,GAAG,MAAM,IAAA,2BAAY,EAAC,EAAE,CAAC,CAAA;IACrC,IAAI,MAAM,CAAA;IAEV,MAAM,GAAG,MAAM,IAAA,+BAAgB,EAAC;QAC9B,MAAM;QACN,MAAM;QACN,WAAW,EAAE,IAAI;KAClB,CAAC,CAAA;IAEF,2CAA2C;IAE3C,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAA;IAEhC,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare
|
|
3
|
-
ok: boolean;
|
|
4
|
-
msg: string;
|
|
5
|
-
}>;
|
|
1
|
+
import type { Transform } from '../transform';
|
|
2
|
+
declare const entityTransform: Transform;
|
|
6
3
|
export { entityTransform };
|
package/dist/transform/entity.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.entityTransform =
|
|
3
|
+
exports.entityTransform = void 0;
|
|
4
4
|
const jostraca_1 = require("jostraca");
|
|
5
5
|
const transform_1 = require("../transform");
|
|
6
|
-
async function
|
|
7
|
-
const { guide: { guide } } = ctx;
|
|
6
|
+
const entityTransform = async function (ctx, guide, tspec, model, def) {
|
|
8
7
|
let msg = '';
|
|
8
|
+
// console.log('DEF', def)
|
|
9
|
+
// console.log('GUIDE', guide)
|
|
9
10
|
(0, jostraca_1.each)(guide.entity, (guideEntity) => {
|
|
10
|
-
const
|
|
11
|
+
const entityName = guideEntity.key$;
|
|
12
|
+
ctx.log.debug({ point: 'guide-entity', note: entityName });
|
|
13
|
+
const entityModel = model.main.api.entity[entityName] = {
|
|
11
14
|
op: {},
|
|
12
15
|
field: {},
|
|
13
16
|
cmd: {},
|
|
@@ -18,12 +21,16 @@ async function entityTransform(ctx, tspec, model, def) {
|
|
|
18
21
|
};
|
|
19
22
|
(0, transform_1.fixName)(entityModel, guideEntity.key$);
|
|
20
23
|
(0, jostraca_1.each)(guideEntity.path, (guidePath) => {
|
|
21
|
-
const
|
|
24
|
+
const path = guidePath.key$;
|
|
25
|
+
const pathdef = def.paths[path];
|
|
26
|
+
// console.log('APIDEF FIND PATH', guidePath.key$, Object.keys(def.paths),
|
|
27
|
+
// Object.keys(def.paths).includes(guidePath.key$))
|
|
22
28
|
if (null == pathdef) {
|
|
23
|
-
throw new Error('
|
|
29
|
+
throw new Error('path not found in OpenAPI: ' + path +
|
|
24
30
|
' (entity: ' + guideEntity.name + ')');
|
|
25
31
|
}
|
|
26
|
-
|
|
32
|
+
// TODO: is this needed?
|
|
33
|
+
guidePath.parts$ = path.split('/');
|
|
27
34
|
guidePath.params$ = guidePath.parts$
|
|
28
35
|
.filter((p) => p.startsWith('{'))
|
|
29
36
|
.map((p) => p.substring(1, p.length - 1));
|
|
@@ -31,5 +38,6 @@ async function entityTransform(ctx, tspec, model, def) {
|
|
|
31
38
|
msg += guideEntity.name + ' ';
|
|
32
39
|
});
|
|
33
40
|
return { ok: true, msg };
|
|
34
|
-
}
|
|
41
|
+
};
|
|
42
|
+
exports.entityTransform = entityTransform;
|
|
35
43
|
//# sourceMappingURL=entity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity.js","sourceRoot":"","sources":["../../src/transform/entity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entity.js","sourceRoot":"","sources":["../../src/transform/entity.ts"],"names":[],"mappings":";;;AAEA,uCAA+B;AAI/B,4CAAsC;AAGtC,MAAM,eAAe,GAAc,KAAK,WACtC,GAAiB,EACjB,KAAY,EACZ,KAAoB,EACpB,KAAU,EACV,GAAQ;IAER,IAAI,GAAG,GAAG,EAAE,CAAA;IAEZ,0BAA0B;IAC1B,8BAA8B;IAE9B,IAAA,eAAI,EAAC,KAAK,CAAC,MAAM,EAAE,CAAC,WAAgB,EAAE,EAAE;QACtC,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAA;QACnC,GAAG,CAAC,GAAG,CAAC,KAA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CAAA;IAEF,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;AAC1B,CAAC,CAAA;AAIC,0CAAe"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare
|
|
3
|
-
ok: boolean;
|
|
4
|
-
msg: string;
|
|
5
|
-
}>;
|
|
1
|
+
import type { Transform } from '../transform';
|
|
2
|
+
declare const fieldTransform: Transform;
|
|
6
3
|
export { fieldTransform };
|
package/dist/transform/field.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fieldTransform =
|
|
3
|
+
exports.fieldTransform = void 0;
|
|
4
4
|
const jostraca_1 = require("jostraca");
|
|
5
5
|
const transform_1 = require("../transform");
|
|
6
|
-
async function
|
|
7
|
-
const { guide: { guide } } = ctx;
|
|
6
|
+
const fieldTransform = async function (ctx, guide, tspec, model, def) {
|
|
8
7
|
let msg = 'fields: ';
|
|
9
8
|
(0, jostraca_1.each)(guide.entity, (guideEntity) => {
|
|
10
|
-
const
|
|
9
|
+
const entityName = guideEntity.key$;
|
|
10
|
+
const entityModel = model.main.api.entity[entityName];
|
|
11
11
|
let fieldCount = 0;
|
|
12
12
|
(0, jostraca_1.each)(guideEntity.path, (guidePath) => {
|
|
13
|
-
const
|
|
13
|
+
const path = guidePath.key$;
|
|
14
|
+
const pathdef = def.paths[path];
|
|
14
15
|
(0, jostraca_1.each)(guidePath.op, (op) => {
|
|
15
|
-
|
|
16
|
+
const opname = op.key$;
|
|
17
|
+
if ('load' === opname) {
|
|
16
18
|
fieldCount = fieldbuild(entityModel, pathdef, op, guidePath, guideEntity, model);
|
|
17
19
|
}
|
|
18
20
|
});
|
|
@@ -20,7 +22,8 @@ async function fieldTransform(ctx, tspec, model, def) {
|
|
|
20
22
|
msg += guideEntity.name + '=' + fieldCount + ' ';
|
|
21
23
|
});
|
|
22
24
|
return { ok: true, msg };
|
|
23
|
-
}
|
|
25
|
+
};
|
|
26
|
+
exports.fieldTransform = fieldTransform;
|
|
24
27
|
function fieldbuild(entityModel, pathdef, op, path, entity, model) {
|
|
25
28
|
// console.log('FB-A', op, pathdef)
|
|
26
29
|
let fieldCount = 0;
|
|
@@ -85,7 +88,7 @@ guide: transform: customField: {
|
|
|
85
88
|
guide: entity: {
|
|
86
89
|
pet: path: {
|
|
87
90
|
'/pet/{petId}': {
|
|
88
|
-
op:{ load: 'get', create: 'post',
|
|
91
|
+
op:{ load: 'get', create: 'post', update: 'put' }
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
94
|
pet: test: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.js","sourceRoot":"","sources":["../../src/transform/field.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"field.js","sourceRoot":"","sources":["../../src/transform/field.ts"],"names":[],"mappings":";;;AAEA,uCAAqC;AAIrC,4CAAsC;AAItC,MAAM,cAAc,GAAc,KAAK,WACrC,GAAiB,EACjB,KAAY,EACZ,KAAoB,EACpB,KAAU,EACV,GAAQ;IAGR,IAAI,GAAG,GAAG,UAAU,CAAA;IAEpB,IAAA,eAAI,EAAC,KAAK,CAAC,MAAM,EAAE,CAAC,WAAgB,EAAE,EAAE;QACtC,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAA;QACnC,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;QAErD,IAAI,UAAU,GAAG,CAAC,CAAA;QAClB,IAAA,eAAI,EAAC,WAAW,CAAC,IAAI,EAAE,CAAC,SAAc,EAAE,EAAE;YACxC,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAA;YAC3B,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YAE/B,IAAA,eAAI,EAAC,SAAS,CAAC,EAAE,EAAE,CA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';
|
|
2
|
-
declare
|
|
3
|
-
ok: boolean;
|
|
4
|
-
msg: string;
|
|
5
|
-
}>;
|
|
1
|
+
import type { TransformCtx, TransformSpec, TransformResult, Guide } from '../transform';
|
|
2
|
+
declare const manualTransform: (ctx: TransformCtx, guide: Guide, tspec: TransformSpec, model: any, def: any) => Promise<TransformResult>;
|
|
6
3
|
export { manualTransform };
|