@voxgig/apidef 1.3.0 → 1.5.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.
@@ -1,5 +0,0 @@
1
- import type { TransformCtx, TransformSpec } from '../transform';
2
- declare function fieldTransform(ctx: TransformCtx, tspec: TransformSpec, model: any, def: any): Promise<{
3
- ok: boolean;
4
- }>;
5
- export { fieldTransform };
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fieldTransform = fieldTransform;
4
- const jostraca_1 = require("jostraca");
5
- const transform_1 = require("../transform");
6
- async function fieldTransform(ctx, tspec, model, def) {
7
- const { guide: { guide } } = ctx;
8
- (0, jostraca_1.each)(guide.entity, (guideEntity) => {
9
- const entityModel = model.main.api.entity[guideEntity.key$];
10
- (0, jostraca_1.each)(guideEntity.path, (guidePath) => {
11
- const pathdef = def.paths[guidePath.key$];
12
- (0, jostraca_1.each)(guidePath.op, (op) => {
13
- if ('load' === op.key$) {
14
- fieldbuild(entityModel, pathdef, op, guidePath, guideEntity, model);
15
- }
16
- });
17
- });
18
- });
19
- return { ok: true };
20
- }
21
- function fieldbuild(entityModel, pathdef, op, path, entity, model) {
22
- // console.log('FB-A', op, pathdef)
23
- let fieldSets = (0, jostraca_1.getx)(pathdef.get, 'responses 200 content "application/json" schema');
24
- if (fieldSets) {
25
- if (Array.isArray(fieldSets.allOf)) {
26
- fieldSets = fieldSets.allOf;
27
- }
28
- else if (fieldSets.properties) {
29
- fieldSets = [fieldSets];
30
- }
31
- }
32
- (0, jostraca_1.each)(fieldSets, (fieldSet) => {
33
- (0, jostraca_1.each)(fieldSet.properties, (property) => {
34
- // console.log(property)
35
- const field = (entityModel.field[property.key$] = entityModel.field[property.key$] || {});
36
- field.name = property.key$;
37
- (0, transform_1.fixName)(field, field.name);
38
- field.type = property.type;
39
- (0, transform_1.fixName)(field, field.type, 'type');
40
- field.short = property.description;
41
- // console.log('FB-ID', field.name, entityModel.param)
42
- });
43
- });
44
- // Guess id field name using GET path param
45
- if ('load' === op.key$) {
46
- const getdef = pathdef.get;
47
- const getparams = getdef.parameters || [];
48
- if (1 === getparams.length) {
49
- if (entityModel.op.load.path.match(RegExp('\\{' + getdef.parameters[0].name + '\\}$'))) {
50
- entityModel.id.field = getdef.parameters[0].name;
51
- }
52
- }
53
- }
54
- }
55
- //# sourceMappingURL=fieldTransform.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fieldTransform.js","sourceRoot":"","sources":["../../src/transform/fieldTransform.ts"],"names":[],"mappings":";;AAyFE,wCAAc;AAvFhB,uCAAqC;AAIrC,4CAAsC;AAItC,KAAK,UAAU,cAAc,CAC3B,GAAiB,EACjB,KAAoB,EACpB,KAAU,EACV,GAAQ;IAER,MAAM,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,GAAG,GAAG,CAAA;IAEhC,IAAA,eAAI,EAAC,KAAK,CAAC,MAAM,EAAE,CAAC,WAAgB,EAAE,EAAE;QAEtC,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;QAC3D,IAAA,eAAI,EAAC,WAAW,CAAC,IAAI,EAAE,CAAC,SAAc,EAAE,EAAE;YACxC,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;YAEzC,IAAA,eAAI,EAAC,SAAS,CAAC,EAAE,EAAE,CAAC,EAAO,EAAE,EAAE;gBAE7B,IAAI,MAAM,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;oBACvB,UAAU,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,CAAC,CAAA;gBACrE,CAAC;YAEH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,OAAO,EAAE,EAAE,EAAE,I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EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAA;QAC1B,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,IAAI,EAAE,CAAA;QACzC,IAAI,CAAC,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;YAC3B,IAAI,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC;gBACvF,WAAW,CAAC,EAAE,CAAC,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;YAClD,CAAC;QACH,CAAC;IACH,CAAC;AAEH,CAAC"}
@@ -1,41 +0,0 @@
1
-
2
- guide: control: transform: &: {
3
- order: string
4
- }
5
-
6
- guide: control: transform: openapi: {
7
- order: *`
8
-
9
- top,
10
- entity,
11
- operation,
12
- field,
13
- manual,
14
-
15
- ` | string
16
- }
17
-
18
-
19
- guide: transform: &: {
20
- name: .$KEY
21
- load: string
22
- }
23
-
24
- guide: transform: {
25
- top: {}
26
- entity: {}
27
- operation: {}
28
- field: {}
29
- manual: {}
30
- }
31
-
32
-
33
- guide: entity: &: {
34
- name: .$KEY
35
- path: &: {
36
- op: {}
37
- }
38
- }
39
-
40
-
41
- guide: manual: {}