@voxgig/apidef 5.8.1 → 5.8.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/parse.js +12 -0
- package/dist/parse.js.map +1 -1
- package/dist/transform/args.js +9 -2
- package/dist/transform/args.js.map +1 -1
- package/dist/transform/entity.js +21 -1
- package/dist/transform/entity.js.map +1 -1
- package/dist/transform/flowstep.js +120 -10
- package/dist/transform/flowstep.js.map +1 -1
- package/dist/transform/operation.js +8 -5
- package/dist/transform/operation.js.map +1 -1
- package/package.json +1 -1
- package/src/parse.ts +13 -0
- package/src/transform/args.ts +9 -2
- package/src/transform/entity.ts +24 -2
- package/src/transform/flowstep.ts +119 -11
- package/src/transform/operation.ts +8 -7
package/dist/parse.js
CHANGED
|
@@ -63,6 +63,18 @@ async function parseOpenAPI(source, _meta) {
|
|
|
63
63
|
if (null == parsed.components) {
|
|
64
64
|
parsed.components = {};
|
|
65
65
|
}
|
|
66
|
+
// Normalize path keys: jsonic's YAML parser leaves the surrounding double
|
|
67
|
+
// quotes IN the key for explicit-key form (`? "..."`). gitlab uses this for
|
|
68
|
+
// long paths and as a result every downstream split('/') sees a literal
|
|
69
|
+
// quote character at the head/tail of the path, breaking URL substitution.
|
|
70
|
+
if (parsed.paths && 'object' === typeof parsed.paths) {
|
|
71
|
+
const cleaned = {};
|
|
72
|
+
for (const [k, v] of Object.entries(parsed.paths)) {
|
|
73
|
+
const stripped = k.replace(/^"+|"+$/g, '');
|
|
74
|
+
cleaned[stripped] = v;
|
|
75
|
+
}
|
|
76
|
+
parsed.paths = cleaned;
|
|
77
|
+
}
|
|
66
78
|
// Single-pass: add x-ref properties and resolve $ref pointers together.
|
|
67
79
|
addXRefsAndResolve(parsed, parsed);
|
|
68
80
|
const def = (0, util_1.decircular)(parsed);
|
package/dist/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../src/parse.ts"],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AAC,IAAI,CAAC,GAAG,CAClC,CAAA;IACH,CAAC;AACH,CAAC"}
|
package/dist/transform/args.js
CHANGED
|
@@ -33,9 +33,16 @@ const ARG_KIND = {
|
|
|
33
33
|
function resolveArgs(ment, mop, mtarget, argdefs) {
|
|
34
34
|
const touchedKeys = new Set();
|
|
35
35
|
(0, jostraca_1.each)(argdefs, (argdef) => {
|
|
36
|
-
|
|
36
|
+
// Spec name as written (e.g. `dataType`) is what the rename map is keyed
|
|
37
|
+
// by; the snakified form is the user-friendly runtime identifier.
|
|
38
|
+
const specName = (0, utility_1.normalizeFieldName)(argdef.name);
|
|
39
|
+
const orig = (0, utility_1.depluralize)((0, jostraca_1.snakify)(specName));
|
|
37
40
|
const kind = ARG_KIND[argdef.in] ?? 'query';
|
|
38
|
-
|
|
41
|
+
// Rename map can be keyed by either the spec original (camelCase) or by
|
|
42
|
+
// the snakified form depending on which path went through heuristic01.
|
|
43
|
+
// Try both before falling through to `orig`.
|
|
44
|
+
const renameMap = mtarget.rename[kind];
|
|
45
|
+
const name = renameMap?.[specName] ?? renameMap?.[orig] ?? orig;
|
|
39
46
|
const marg = {
|
|
40
47
|
name,
|
|
41
48
|
orig,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/transform/args.ts"],"names":[],"mappings":";;;AAEA,uCAAwC;AAIxC,wCAAqG;AAGrG,oCAA8B;AAoB9B,MAAM,aAAa,GAAc,KAAK,WACpC,GAAQ;IAER,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IAC7B,MAAM,GAAG,GAAa,QAAQ,CAAC,IAAI,CAAC,WAAG,CAAC,CAAA;IAExC,IAAI,GAAG,GAAG,OAAO,CAAA;IAGjB,IAAA,eAAI,EAAC,GAAG,CAAC,MAAM,EAAE,CAAC,IAAiB,EAAE,OAAe,EAAE,EAAE;QACtD,IAAA,eAAI,EAAC,IAAI,CAAC,EAAE,EAAE,CAAC,G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,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACxF,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,OAAO,CAAC,IAAI,CAAC,GAAgC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IAC3D,CAAC;AACH,CAAC"}
|
package/dist/transform/entity.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.resolvePathList = resolvePathList;
|
|
|
5
5
|
exports.buildRelations = buildRelations;
|
|
6
6
|
const jostraca_1 = require("jostraca");
|
|
7
7
|
const types_1 = require("../types");
|
|
8
|
+
const utility_1 = require("../utility");
|
|
8
9
|
const entityTransform = async function (ctx) {
|
|
9
10
|
const { apimodel, guide } = ctx;
|
|
10
11
|
const kit = apimodel.main[types_1.KIT];
|
|
@@ -36,7 +37,26 @@ function resolvePathList(guideEntity, def) {
|
|
|
36
37
|
const rename = guidePath.rename ?? {};
|
|
37
38
|
(0, jostraca_1.each)(rename.param, (param) => {
|
|
38
39
|
const pI = parts.indexOf('{' + param.key$ + '}');
|
|
39
|
-
|
|
40
|
+
if (pI >= 0)
|
|
41
|
+
parts[pI] = '{' + param.val$ + '}';
|
|
42
|
+
});
|
|
43
|
+
// Implicit snake_case normalization for any path placeholder that wasn't
|
|
44
|
+
// explicitly renamed. apidef's args transform snake-cases param names
|
|
45
|
+
// (e.g. spec `platformKey` → param.name `platform_key`); without
|
|
46
|
+
// normalizing the placeholder to match, runtime URL substitution by
|
|
47
|
+
// param.name fails to fill `{platformKey}`.
|
|
48
|
+
rename.param = rename.param ?? {};
|
|
49
|
+
parts.forEach((part, i) => {
|
|
50
|
+
const m = part.match(/^\{(.+)\}$/);
|
|
51
|
+
if (!m)
|
|
52
|
+
return;
|
|
53
|
+
const placeholder = m[1];
|
|
54
|
+
const snake = (0, utility_1.depluralize)((0, jostraca_1.snakify)((0, utility_1.normalizeFieldName)(placeholder)));
|
|
55
|
+
if (snake !== placeholder && rename.param[placeholder] === undefined) {
|
|
56
|
+
;
|
|
57
|
+
rename.param[placeholder] = snake;
|
|
58
|
+
parts[i] = '{' + snake + '}';
|
|
59
|
+
}
|
|
40
60
|
});
|
|
41
61
|
const pathdesc = {
|
|
42
62
|
orig,
|
|
@@ -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":";;;AAyJE,0CAAe;AACf,wCAAc;AAxJhB,uCAAwC;AAIxC,oCAA8B;AAiB9B,wCAGmB;AAInB,MAAM,eAAe,GAAc,KAAK,WACtC,GAAQ;IAER,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,GAAG,CAAA;IAC/B,MAAM,GAAG,GAAa,QAAQ,CAAC,IAAI,CAAC,WAAG,CAAC,CAAA;IAExC,IAAI,GAAG,GAAG,EAAE,CAAA;IAEZ,IAAA,eAAI,EAAC,KAAK,CAAC,MAAM,EAAE,CAAC,WAAwB,EAAE,OAAe,EAAE,EAAE;QAC/D,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;QAEvD,MAAM,MAAM,GAAG,eAAe,CAAC,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,CAAA;QACpD,MAAM,SAAS,GAAG,cAAc,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;QAErD,MAAM,QAAQ,GAAgB;YAC5B,IAAI,EAAE,OAAO;YACb,EAAE,EAAE,EAAE;YACN,MAAM,EAAE,EAAE;YACV,EAAE,EAAE;gBACF,IAAI,EAAE,IAAI;gB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6 +3,45 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.flowstepTransform = void 0;
|
|
4
4
|
const jostraca_1 = require("jostraca");
|
|
5
5
|
const struct_1 = require("@voxgig/struct");
|
|
6
|
+
// Detect a path-parameter that is in fact the entity's own id, after URL
|
|
7
|
+
// renaming. Three ways an identity can show up:
|
|
8
|
+
// 1. The param literally has name 'id' (the common case for e.g. /things/{id}).
|
|
9
|
+
// 2. The param's lower-camelCase name appears in `point.rename.param` mapping
|
|
10
|
+
// to 'id' — e.g. `{connectionId: 'id'}` for `/companies/{company_id}/connections/{id}`.
|
|
11
|
+
// In this case the param's own name is `connection_id` (apidef snake-cased
|
|
12
|
+
// it), which doesn't equal 'id' but the placeholder in `parts` is `{id}`.
|
|
13
|
+
// 3. Positional convention: for singleton ops (load/update/remove), the
|
|
14
|
+
// LAST `{X}` placeholder in the path is the entity's own id. Catches
|
|
15
|
+
// cases where the entity name and path placeholder differ in spelling
|
|
16
|
+
// (e.g. entity `enviroment` vs path `/environments/{environment_id}`)
|
|
17
|
+
// and apidef therefore didn't synthesize a rename-to-id.
|
|
18
|
+
//
|
|
19
|
+
// Without this helper, the flow generator double-counts the entity's id —
|
|
20
|
+
// emitting it as both `srcdatavar.id` AND a separate body field — which the
|
|
21
|
+
// in-memory test mock then requires to match a non-existent field on the
|
|
22
|
+
// stored entity.
|
|
23
|
+
function isEntityIdParam(point, param, opname) {
|
|
24
|
+
if ('id' === param?.name)
|
|
25
|
+
return true;
|
|
26
|
+
const renameMap = point?.rename?.param;
|
|
27
|
+
if (renameMap && param?.name) {
|
|
28
|
+
const camel = (0, jostraca_1.lcf)((0, jostraca_1.camelify)(param.name));
|
|
29
|
+
if ('id' === renameMap[camel])
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
if ('update' === opname || 'load' === opname || 'remove' === opname) {
|
|
33
|
+
const parts = point?.parts || [];
|
|
34
|
+
let last = null;
|
|
35
|
+
for (const p of parts) {
|
|
36
|
+
const m = String(p).match(/^\{(.+)\}$/);
|
|
37
|
+
if (m)
|
|
38
|
+
last = m[1];
|
|
39
|
+
}
|
|
40
|
+
if (last && last === param?.name)
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
6
45
|
const types_1 = require("../types");
|
|
7
46
|
const flowstepTransform = async function (ctx) {
|
|
8
47
|
const { apimodel, guide } = ctx;
|
|
@@ -66,26 +105,97 @@ function newFlowStep(opname, args) {
|
|
|
66
105
|
valid: args.valid ?? [],
|
|
67
106
|
};
|
|
68
107
|
}
|
|
108
|
+
// Reverse-lookup: given a point with rename.param like {spaceId: 'id'} or
|
|
109
|
+
// {space_id: 'id'}, return the snake_case ORIGINAL name (e.g. 'space_id') of
|
|
110
|
+
// any param whose URL placeholder is now `{id}`. Returns null when no
|
|
111
|
+
// rename-to-id is recorded — the literal `id` then represents the entity's
|
|
112
|
+
// own id and createStep should skip it.
|
|
113
|
+
function originalSnakeNameOfRenamedId(point) {
|
|
114
|
+
const renameMap = point?.rename?.param || {};
|
|
115
|
+
for (const [src, dst] of Object.entries(renameMap)) {
|
|
116
|
+
if ('id' === dst) {
|
|
117
|
+
const srcStr = String(src);
|
|
118
|
+
// Already snake_case? Use as-is. Otherwise convert to snake form.
|
|
119
|
+
return srcStr.includes('_') ? srcStr : (srcStr.replace(/[A-Z]/g, m => '_' + m.toLowerCase()).replace(/^_/, ''));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
69
124
|
const createStep = (opmap, flow, ent, args) => {
|
|
70
125
|
if (null != opmap.create) {
|
|
71
126
|
// Use last point as most generic
|
|
72
127
|
const point = (0, struct_1.getelem)(opmap.create.points, -1);
|
|
73
128
|
const step = newFlowStep('create', args);
|
|
74
129
|
(0, jostraca_1.each)(point.args.params, (param) => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
130
|
+
if ('id' === param.name) {
|
|
131
|
+
// For CREATE, `id` in the path is NOT the entity's own id (entity is
|
|
132
|
+
// being created here — its id doesn't exist yet). It's some parent's
|
|
133
|
+
// id renamed by apidef's path normalization (e.g. `space_id` → `id`
|
|
134
|
+
// in `/spaces/{id}/space_memberships` for SpaceMembership). Recover
|
|
135
|
+
// the original snake_case name so the test seeds the parent's id
|
|
136
|
+
// into both the created entity's data AND the URL.
|
|
137
|
+
const origName = originalSnakeNameOfRenamedId(point);
|
|
138
|
+
if (origName) {
|
|
139
|
+
step.match[origName] = args.input?.[origName] ?? origName.replace(/_id/, '') + '01';
|
|
140
|
+
}
|
|
141
|
+
// If there's no rename-from, this is genuinely the entity's id — skip
|
|
142
|
+
// (the create call generates it).
|
|
143
|
+
return;
|
|
78
144
|
}
|
|
145
|
+
step.match[param.name] = args.input?.[param.name] ?? param.name.replace(/_id/, '') + '01';
|
|
79
146
|
});
|
|
147
|
+
// Also seed any path-param fields required by other ops (typically LIST
|
|
148
|
+
// through a sibling parent path), so the in-memory test mock can find
|
|
149
|
+
// the just-created entity when a later step queries by those fields.
|
|
150
|
+
// Without this, a metric created at /pages/{page_id}/metrics/data lacks
|
|
151
|
+
// the page_access_user_id field required by
|
|
152
|
+
// /pages/{page_id}/page_access_users/{page_access_user_id}/metrics LIST.
|
|
153
|
+
seedRelatedOpParams(opmap, point, step);
|
|
80
154
|
flow.step.push(step);
|
|
81
155
|
}
|
|
82
156
|
};
|
|
157
|
+
function seedRelatedOpParams(opmap, createPoint, step) {
|
|
158
|
+
const otherOps = ['list', 'load', 'update', 'remove'];
|
|
159
|
+
for (const opname of otherOps) {
|
|
160
|
+
const op = opmap[opname];
|
|
161
|
+
if (!op?.points)
|
|
162
|
+
continue;
|
|
163
|
+
for (const point of op.points) {
|
|
164
|
+
const params = point?.args?.params || [];
|
|
165
|
+
for (const param of params) {
|
|
166
|
+
if (!param?.name)
|
|
167
|
+
continue;
|
|
168
|
+
if (isEntityIdParam(point, param, opname))
|
|
169
|
+
continue;
|
|
170
|
+
if (step.match[param.name] !== undefined)
|
|
171
|
+
continue;
|
|
172
|
+
// For renamed-from-id params on CREATE's chosen point we'd already
|
|
173
|
+
// have set the snake-case origin; don't double-write.
|
|
174
|
+
if ('id' === param.name)
|
|
175
|
+
continue;
|
|
176
|
+
step.match[param.name] =
|
|
177
|
+
param.name.replace(/_id/, '') + '01';
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
83
182
|
const listStep = (opmap, flow, ent, args) => {
|
|
84
183
|
if (null != opmap.list) {
|
|
85
184
|
// Use last point as most generic
|
|
86
185
|
const point = (0, struct_1.getelem)(opmap.list.points, -1);
|
|
87
186
|
const step = newFlowStep('list', args);
|
|
88
187
|
(0, jostraca_1.each)(point.args.params, (param) => {
|
|
188
|
+
if ('id' === param.name) {
|
|
189
|
+
// For LIST, `id` in the path is a parent's id renamed by apidef
|
|
190
|
+
// (LIST doesn't address a single entity by id). Recover the original
|
|
191
|
+
// snake_case name so test code references a real idmap entry rather
|
|
192
|
+
// than landing on the bogus `id01` default.
|
|
193
|
+
const origName = originalSnakeNameOfRenamedId(point);
|
|
194
|
+
if (origName) {
|
|
195
|
+
step.match[origName] = args.input?.[origName] ?? origName.replace(/_id/, '') + '01';
|
|
196
|
+
}
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
89
199
|
step.match[param.name] = args.input?.[param.name] ?? param.name.replace(/_id/, '') + '01';
|
|
90
200
|
});
|
|
91
201
|
flow.step.push(step);
|
|
@@ -97,12 +207,12 @@ const updateStep = (opmap, flow, ent, args) => {
|
|
|
97
207
|
const point = (0, struct_1.getelem)(opmap.update.points, -1);
|
|
98
208
|
const step = newFlowStep('update', args);
|
|
99
209
|
(0, jostraca_1.each)(point.args.params, (param) => {
|
|
100
|
-
if ('
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
step.data[param.name] = args.input?.[param.name] ?? param.name.replace(/_id/, '') + '01';
|
|
210
|
+
if (isEntityIdParam(point, param, 'update')) {
|
|
211
|
+
// Entity's own id — supplied at test time via the loaded/created
|
|
212
|
+
// entity's id field, not as a separate body parameter. Skip.
|
|
213
|
+
return;
|
|
105
214
|
}
|
|
215
|
+
step.data[param.name] = args.input?.[param.name] ?? param.name.replace(/_id/, '') + '01';
|
|
106
216
|
});
|
|
107
217
|
flow.step.push(step);
|
|
108
218
|
}
|
|
@@ -113,7 +223,7 @@ const loadStep = (opmap, flow, ent, args) => {
|
|
|
113
223
|
const point = (0, struct_1.getelem)(opmap.load.points, -1);
|
|
114
224
|
const step = newFlowStep('load', args);
|
|
115
225
|
(0, jostraca_1.each)(point.args.params, (param) => {
|
|
116
|
-
if ('
|
|
226
|
+
if (isEntityIdParam(point, param, 'load')) {
|
|
117
227
|
step.match.id = args.input?.id ?? ent.name + '01';
|
|
118
228
|
}
|
|
119
229
|
else {
|
|
@@ -129,7 +239,7 @@ const removeStep = (opmap, flow, ent, args) => {
|
|
|
129
239
|
const point = (0, struct_1.getelem)(opmap.remove.points, -1);
|
|
130
240
|
const step = newFlowStep('remove', args);
|
|
131
241
|
(0, jostraca_1.each)(point.args.params, (param) => {
|
|
132
|
-
if ('
|
|
242
|
+
if (isEntityIdParam(point, param, 'remove')) {
|
|
133
243
|
step.match.id = args.input?.id ?? ent.name + '01';
|
|
134
244
|
}
|
|
135
245
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowstep.js","sourceRoot":"","sources":["../../src/transform/flowstep.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"flowstep.js","sourceRoot":"","sources":["../../src/transform/flowstep.ts"],"names":[],"mappings":";;;AAEA,uCAA8C;AAI9C,2CAAwC;AAOxC,yEAAyE;AACzE,gDAAgD;AAChD,kFAAkF;AAClF,gFAAgF;AAChF,6FAA6F;AAC7F,gFAAgF;AAChF,+EAA+E;AAC/E,0EAA0E;AAC1E,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,8DAA8D;AA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{
|
|
90
|
-
|
|
90
|
+
// Renames already applied by entity.ts resolvePathList — re-applying
|
|
91
|
+
// here corrupted paths for any spec where rename map maps an old
|
|
92
|
+
// name to a value that another rename maps to a different new name
|
|
93
|
+
// (e.g. gitlab `/groups/{id}/badges/{badge_id}` with rename
|
|
94
|
+
// `{badge_id: 'id', id: 'project_id'}` ended up as
|
|
95
|
+
// `/groups/{project_id}/badges/{project_id}` — the second pass
|
|
96
|
+
// rewrote the freshly-renamed `{id}` into `{project_id}` again).
|
|
97
|
+
const parts = p.parts;
|
|
91
98
|
const mtarget = {
|
|
92
99
|
orig: p.orig,
|
|
93
100
|
parts,
|
|
@@ -107,8 +114,4 @@ function resolveOp(opname, gent) {
|
|
|
107
114
|
}
|
|
108
115
|
return mop;
|
|
109
116
|
}
|
|
110
|
-
function applyRename(pathdesc) {
|
|
111
|
-
const prn = pathdesc.rename?.param ?? {};
|
|
112
|
-
return pathdesc.parts.map(p => '{' === p[0] ? (prn[p.substring(1, p.length - 1)] ?? p) : p);
|
|
113
|
-
}
|
|
114
117
|
//# sourceMappingURL=operation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../src/transform/operation.ts"],"names":[],"mappings":";;;AAEA,uCAA+B;AAK/B,oCAIiB;AAejB,MAAM,kBAAkB,GAAc,KAAK,WACzC,GAAQ;IAER,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,GAAG,CAAA;IAC/B,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,WAAG,CAAC,CAAA;IAE9B,IAAI,GAAG,GAAG,YAAY,CAAA;IAEtB,IAAA,eAAI,EAAC,KAAK,CAAC,MAAM,EAAE,CAAC,IAAiB,EAAE,OAAe,EAAE,EAAE;QACxD,UAAU,CAAC,IAAI,CAAC,CAAA;QAEhB,MAAM,GAAG,GAAe;YACtB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,SAAS;YACf,MAAM,EAAE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19 @@ async function parseOpenAPI(source: any, _meta?: any) {
|
|
|
84
84
|
parsed.components = {}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
// Normalize path keys: jsonic's YAML parser leaves the surrounding double
|
|
88
|
+
// quotes IN the key for explicit-key form (`? "..."`). gitlab uses this for
|
|
89
|
+
// long paths and as a result every downstream split('/') sees a literal
|
|
90
|
+
// quote character at the head/tail of the path, breaking URL substitution.
|
|
91
|
+
if (parsed.paths && 'object' === typeof parsed.paths) {
|
|
92
|
+
const cleaned: Record<string, any> = {}
|
|
93
|
+
for (const [k, v] of Object.entries(parsed.paths)) {
|
|
94
|
+
const stripped = k.replace(/^"+|"+$/g, '')
|
|
95
|
+
cleaned[stripped] = v
|
|
96
|
+
}
|
|
97
|
+
parsed.paths = cleaned
|
|
98
|
+
}
|
|
99
|
+
|
|
87
100
|
// Single-pass: add x-ref properties and resolve $ref pointers together.
|
|
88
101
|
addXRefsAndResolve(parsed, parsed)
|
|
89
102
|
|
package/src/transform/args.ts
CHANGED
|
@@ -71,9 +71,16 @@ function resolveArgs(ment: ModelEntity, mop: ModelOp, mtarget: ModelTarget, argd
|
|
|
71
71
|
const touchedKeys = new Set<string>()
|
|
72
72
|
|
|
73
73
|
each(argdefs, (argdef: ParameterDef) => {
|
|
74
|
-
|
|
74
|
+
// Spec name as written (e.g. `dataType`) is what the rename map is keyed
|
|
75
|
+
// by; the snakified form is the user-friendly runtime identifier.
|
|
76
|
+
const specName = normalizeFieldName(argdef.name)
|
|
77
|
+
const orig = depluralize(snakify(specName))
|
|
75
78
|
const kind = ARG_KIND[argdef.in] ?? 'query'
|
|
76
|
-
|
|
79
|
+
// Rename map can be keyed by either the spec original (camelCase) or by
|
|
80
|
+
// the snakified form depending on which path went through heuristic01.
|
|
81
|
+
// Try both before falling through to `orig`.
|
|
82
|
+
const renameMap = mtarget.rename[kind]
|
|
83
|
+
const name = renameMap?.[specName] ?? renameMap?.[orig] ?? orig
|
|
77
84
|
const marg: ModelArg = {
|
|
78
85
|
name,
|
|
79
86
|
orig,
|
package/src/transform/entity.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
import { each } from 'jostraca'
|
|
3
|
+
import { each, snakify } from 'jostraca'
|
|
4
4
|
|
|
5
5
|
import type { TransformResult, Transform } from '../transform'
|
|
6
6
|
|
|
@@ -21,6 +21,11 @@ import type {
|
|
|
21
21
|
ModelEntity,
|
|
22
22
|
} from '../model'
|
|
23
23
|
|
|
24
|
+
import {
|
|
25
|
+
depluralize,
|
|
26
|
+
normalizeFieldName,
|
|
27
|
+
} from '../utility'
|
|
28
|
+
|
|
24
29
|
|
|
25
30
|
|
|
26
31
|
const entityTransform: Transform = async function(
|
|
@@ -67,7 +72,24 @@ function resolvePathList(guideEntity: GuideEntity, def: { paths: Record<string,
|
|
|
67
72
|
|
|
68
73
|
each(rename.param, (param: any) => {
|
|
69
74
|
const pI = parts.indexOf('{' + param.key$ + '}')
|
|
70
|
-
parts[pI] = '{' + param.val$ + '}'
|
|
75
|
+
if (pI >= 0) parts[pI] = '{' + param.val$ + '}'
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
// Implicit snake_case normalization for any path placeholder that wasn't
|
|
79
|
+
// explicitly renamed. apidef's args transform snake-cases param names
|
|
80
|
+
// (e.g. spec `platformKey` → param.name `platform_key`); without
|
|
81
|
+
// normalizing the placeholder to match, runtime URL substitution by
|
|
82
|
+
// param.name fails to fill `{platformKey}`.
|
|
83
|
+
rename.param = (rename.param as any) ?? {}
|
|
84
|
+
parts.forEach((part: string, i: number) => {
|
|
85
|
+
const m = part.match(/^\{(.+)\}$/)
|
|
86
|
+
if (!m) return
|
|
87
|
+
const placeholder = m[1]
|
|
88
|
+
const snake = depluralize(snakify(normalizeFieldName(placeholder)))
|
|
89
|
+
if (snake !== placeholder && (rename.param as any)[placeholder] === undefined) {
|
|
90
|
+
; (rename.param as any)[placeholder] = snake
|
|
91
|
+
parts[i] = '{' + snake + '}'
|
|
92
|
+
}
|
|
71
93
|
})
|
|
72
94
|
|
|
73
95
|
const pathdesc: PathDesc = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
import { each } from 'jostraca'
|
|
3
|
+
import { each, camelify, lcf } from 'jostraca'
|
|
4
4
|
|
|
5
5
|
import type { TransformResult, Transform } from '../transform'
|
|
6
6
|
|
|
@@ -10,6 +10,43 @@ import {
|
|
|
10
10
|
nom,
|
|
11
11
|
} from '../utility'
|
|
12
12
|
|
|
13
|
+
|
|
14
|
+
// Detect a path-parameter that is in fact the entity's own id, after URL
|
|
15
|
+
// renaming. Three ways an identity can show up:
|
|
16
|
+
// 1. The param literally has name 'id' (the common case for e.g. /things/{id}).
|
|
17
|
+
// 2. The param's lower-camelCase name appears in `point.rename.param` mapping
|
|
18
|
+
// to 'id' — e.g. `{connectionId: 'id'}` for `/companies/{company_id}/connections/{id}`.
|
|
19
|
+
// In this case the param's own name is `connection_id` (apidef snake-cased
|
|
20
|
+
// it), which doesn't equal 'id' but the placeholder in `parts` is `{id}`.
|
|
21
|
+
// 3. Positional convention: for singleton ops (load/update/remove), the
|
|
22
|
+
// LAST `{X}` placeholder in the path is the entity's own id. Catches
|
|
23
|
+
// cases where the entity name and path placeholder differ in spelling
|
|
24
|
+
// (e.g. entity `enviroment` vs path `/environments/{environment_id}`)
|
|
25
|
+
// and apidef therefore didn't synthesize a rename-to-id.
|
|
26
|
+
//
|
|
27
|
+
// Without this helper, the flow generator double-counts the entity's id —
|
|
28
|
+
// emitting it as both `srcdatavar.id` AND a separate body field — which the
|
|
29
|
+
// in-memory test mock then requires to match a non-existent field on the
|
|
30
|
+
// stored entity.
|
|
31
|
+
function isEntityIdParam(point: any, param: any, opname?: string): boolean {
|
|
32
|
+
if ('id' === param?.name) return true
|
|
33
|
+
const renameMap = point?.rename?.param
|
|
34
|
+
if (renameMap && param?.name) {
|
|
35
|
+
const camel = lcf(camelify(param.name))
|
|
36
|
+
if ('id' === renameMap[camel]) return true
|
|
37
|
+
}
|
|
38
|
+
if ('update' === opname || 'load' === opname || 'remove' === opname) {
|
|
39
|
+
const parts: any[] = point?.parts || []
|
|
40
|
+
let last: string | null = null
|
|
41
|
+
for (const p of parts) {
|
|
42
|
+
const m = String(p).match(/^\{(.+)\}$/)
|
|
43
|
+
if (m) last = m[1]
|
|
44
|
+
}
|
|
45
|
+
if (last && last === param?.name) return true
|
|
46
|
+
}
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
|
|
13
50
|
import { KIT } from '../types'
|
|
14
51
|
|
|
15
52
|
import type { KitModel } from '../types'
|
|
@@ -116,6 +153,24 @@ function newFlowStep(opname: OpName, args: Record<string, any>): ModelEntityFlow
|
|
|
116
153
|
}
|
|
117
154
|
|
|
118
155
|
|
|
156
|
+
// Reverse-lookup: given a point with rename.param like {spaceId: 'id'} or
|
|
157
|
+
// {space_id: 'id'}, return the snake_case ORIGINAL name (e.g. 'space_id') of
|
|
158
|
+
// any param whose URL placeholder is now `{id}`. Returns null when no
|
|
159
|
+
// rename-to-id is recorded — the literal `id` then represents the entity's
|
|
160
|
+
// own id and createStep should skip it.
|
|
161
|
+
function originalSnakeNameOfRenamedId(point: any): string | null {
|
|
162
|
+
const renameMap = point?.rename?.param || {}
|
|
163
|
+
for (const [src, dst] of Object.entries(renameMap)) {
|
|
164
|
+
if ('id' === dst) {
|
|
165
|
+
const srcStr = String(src)
|
|
166
|
+
// Already snake_case? Use as-is. Otherwise convert to snake form.
|
|
167
|
+
return srcStr.includes('_') ? srcStr : (srcStr.replace(/[A-Z]/g, m => '_' + m.toLowerCase()).replace(/^_/, ''))
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return null
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
|
|
119
174
|
const createStep: MakeFlowStep = (
|
|
120
175
|
opmap: any,
|
|
121
176
|
flow: ModelEntityFlow,
|
|
@@ -128,17 +183,59 @@ const createStep: MakeFlowStep = (
|
|
|
128
183
|
const step = newFlowStep('create', args)
|
|
129
184
|
|
|
130
185
|
each(point.args.params, (param: any) => {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
186
|
+
if ('id' === param.name) {
|
|
187
|
+
// For CREATE, `id` in the path is NOT the entity's own id (entity is
|
|
188
|
+
// being created here — its id doesn't exist yet). It's some parent's
|
|
189
|
+
// id renamed by apidef's path normalization (e.g. `space_id` → `id`
|
|
190
|
+
// in `/spaces/{id}/space_memberships` for SpaceMembership). Recover
|
|
191
|
+
// the original snake_case name so the test seeds the parent's id
|
|
192
|
+
// into both the created entity's data AND the URL.
|
|
193
|
+
const origName = originalSnakeNameOfRenamedId(point)
|
|
194
|
+
if (origName) {
|
|
195
|
+
step.match[origName] = args.input?.[origName] ?? origName.replace(/_id/, '') + '01'
|
|
196
|
+
}
|
|
197
|
+
// If there's no rename-from, this is genuinely the entity's id — skip
|
|
198
|
+
// (the create call generates it).
|
|
199
|
+
return
|
|
134
200
|
}
|
|
201
|
+
step.match[param.name] = args.input?.[param.name] ?? param.name.replace(/_id/, '') + '01'
|
|
135
202
|
})
|
|
136
203
|
|
|
204
|
+
// Also seed any path-param fields required by other ops (typically LIST
|
|
205
|
+
// through a sibling parent path), so the in-memory test mock can find
|
|
206
|
+
// the just-created entity when a later step queries by those fields.
|
|
207
|
+
// Without this, a metric created at /pages/{page_id}/metrics/data lacks
|
|
208
|
+
// the page_access_user_id field required by
|
|
209
|
+
// /pages/{page_id}/page_access_users/{page_access_user_id}/metrics LIST.
|
|
210
|
+
seedRelatedOpParams(opmap, point, step)
|
|
211
|
+
|
|
137
212
|
flow.step.push(step)
|
|
138
213
|
}
|
|
139
214
|
}
|
|
140
215
|
|
|
141
216
|
|
|
217
|
+
function seedRelatedOpParams(opmap: any, createPoint: any, step: ModelEntityFlowStep) {
|
|
218
|
+
const otherOps = ['list', 'load', 'update', 'remove']
|
|
219
|
+
for (const opname of otherOps) {
|
|
220
|
+
const op = opmap[opname]
|
|
221
|
+
if (!op?.points) continue
|
|
222
|
+
for (const point of op.points) {
|
|
223
|
+
const params: any[] = point?.args?.params || []
|
|
224
|
+
for (const param of params) {
|
|
225
|
+
if (!param?.name) continue
|
|
226
|
+
if (isEntityIdParam(point, param, opname as any)) continue
|
|
227
|
+
if (step.match[param.name] !== undefined) continue
|
|
228
|
+
// For renamed-from-id params on CREATE's chosen point we'd already
|
|
229
|
+
// have set the snake-case origin; don't double-write.
|
|
230
|
+
if ('id' === param.name) continue
|
|
231
|
+
step.match[param.name] =
|
|
232
|
+
param.name.replace(/_id/, '') + '01'
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
|
|
142
239
|
const listStep: MakeFlowStep = (
|
|
143
240
|
opmap: any,
|
|
144
241
|
flow: ModelEntityFlow,
|
|
@@ -151,6 +248,17 @@ const listStep: MakeFlowStep = (
|
|
|
151
248
|
const step = newFlowStep('list', args)
|
|
152
249
|
|
|
153
250
|
each(point.args.params, (param: any) => {
|
|
251
|
+
if ('id' === param.name) {
|
|
252
|
+
// For LIST, `id` in the path is a parent's id renamed by apidef
|
|
253
|
+
// (LIST doesn't address a single entity by id). Recover the original
|
|
254
|
+
// snake_case name so test code references a real idmap entry rather
|
|
255
|
+
// than landing on the bogus `id01` default.
|
|
256
|
+
const origName = originalSnakeNameOfRenamedId(point)
|
|
257
|
+
if (origName) {
|
|
258
|
+
step.match[origName] = args.input?.[origName] ?? origName.replace(/_id/, '') + '01'
|
|
259
|
+
}
|
|
260
|
+
return
|
|
261
|
+
}
|
|
154
262
|
step.match[param.name] = args.input?.[param.name] ?? param.name.replace(/_id/, '') + '01'
|
|
155
263
|
})
|
|
156
264
|
|
|
@@ -171,12 +279,12 @@ const updateStep: MakeFlowStep = (
|
|
|
171
279
|
const step = newFlowStep('update', args)
|
|
172
280
|
|
|
173
281
|
each(point.args.params, (param: any) => {
|
|
174
|
-
if ('
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
step.data[param.name] = args.input?.[param.name] ?? param.name.replace(/_id/, '') + '01'
|
|
282
|
+
if (isEntityIdParam(point, param, 'update')) {
|
|
283
|
+
// Entity's own id — supplied at test time via the loaded/created
|
|
284
|
+
// entity's id field, not as a separate body parameter. Skip.
|
|
285
|
+
return
|
|
179
286
|
}
|
|
287
|
+
step.data[param.name] = args.input?.[param.name] ?? param.name.replace(/_id/, '') + '01'
|
|
180
288
|
})
|
|
181
289
|
|
|
182
290
|
flow.step.push(step)
|
|
@@ -196,7 +304,7 @@ const loadStep: MakeFlowStep = (
|
|
|
196
304
|
const step = newFlowStep('load', args)
|
|
197
305
|
|
|
198
306
|
each(point.args.params, (param: any) => {
|
|
199
|
-
if ('
|
|
307
|
+
if (isEntityIdParam(point, param, 'load')) {
|
|
200
308
|
step.match.id = args.input?.id ?? ent.name + '01'
|
|
201
309
|
}
|
|
202
310
|
else {
|
|
@@ -221,7 +329,7 @@ const removeStep: MakeFlowStep = (
|
|
|
221
329
|
const step = newFlowStep('remove', args)
|
|
222
330
|
|
|
223
331
|
each(point.args.params, (param: any) => {
|
|
224
|
-
if ('
|
|
332
|
+
if (isEntityIdParam(point, param, 'remove')) {
|
|
225
333
|
step.match.id = args.input?.id ?? ent.name + '01'
|
|
226
334
|
}
|
|
227
335
|
else {
|
|
@@ -137,7 +137,14 @@ function resolveOp(opname: OpName, gent: GuideEntity): undefined | ModelOp {
|
|
|
137
137
|
mop = {
|
|
138
138
|
name: opname,
|
|
139
139
|
points: opdesc.paths.map((p: PathDesc) => {
|
|
140
|
-
|
|
140
|
+
// Renames already applied by entity.ts resolvePathList — re-applying
|
|
141
|
+
// here corrupted paths for any spec where rename map maps an old
|
|
142
|
+
// name to a value that another rename maps to a different new name
|
|
143
|
+
// (e.g. gitlab `/groups/{id}/badges/{badge_id}` with rename
|
|
144
|
+
// `{badge_id: 'id', id: 'project_id'}` ended up as
|
|
145
|
+
// `/groups/{project_id}/badges/{project_id}` — the second pass
|
|
146
|
+
// rewrote the freshly-renamed `{id}` into `{project_id}` again).
|
|
147
|
+
const parts = p.parts
|
|
141
148
|
|
|
142
149
|
const mtarget: ModelTarget = {
|
|
143
150
|
orig: p.orig,
|
|
@@ -162,12 +169,6 @@ function resolveOp(opname: OpName, gent: GuideEntity): undefined | ModelOp {
|
|
|
162
169
|
}
|
|
163
170
|
|
|
164
171
|
|
|
165
|
-
function applyRename(pathdesc: PathDesc): string[] {
|
|
166
|
-
const prn: Record<string, string> = pathdesc.rename?.param ?? {}
|
|
167
|
-
return pathdesc.parts.map(p => '{' === p[0] ? (prn[p.substring(1, p.length - 1)] ?? p) : p)
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
172
|
|
|
172
173
|
|
|
173
174
|
export {
|