@voxgig/apidef 8.12.1 → 8.14.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/dist/apidef.d.ts +2 -2
- package/dist/apidef.js +2 -2
- package/dist/apidef.js.map +1 -1
- package/dist/builder/entity/entity.d.ts +5 -1
- package/dist/builder/entity/entity.js +17 -1
- package/dist/builder/entity/entity.js.map +1 -1
- package/dist/builder/flow/flowHeuristic01.js +14 -14
- package/dist/builder/flow/flowHeuristic01.js.map +1 -1
- package/dist/model.d.ts +35 -33
- package/dist/resolved.d.ts +10 -6
- package/dist/resolved.js +65 -15
- package/dist/resolved.js.map +1 -1
- package/dist/transform/args.js +19 -19
- package/dist/transform/args.js.map +1 -1
- package/dist/transform/clean.js +4 -0
- package/dist/transform/clean.js.map +1 -1
- package/dist/transform/contract.d.ts +0 -2
- package/dist/transform/contract.js +6 -75
- package/dist/transform/contract.js.map +1 -1
- package/dist/transform/entity.d.ts +2 -1
- package/dist/transform/entity.js +13 -1
- package/dist/transform/entity.js.map +1 -1
- package/dist/transform/field.js +64 -64
- package/dist/transform/field.js.map +1 -1
- package/dist/transform/flowstep.js +42 -42
- package/dist/transform/flowstep.js.map +1 -1
- package/dist/transform/graphql.js +8 -8
- package/dist/transform/graphql.js.map +1 -1
- package/dist/transform/operation.js +9 -9
- package/dist/transform/operation.js.map +1 -1
- package/dist/transform/select.js +13 -13
- package/dist/transform/select.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utility.d.ts +2 -1
- package/dist/utility.js +5 -0
- package/dist/utility.js.map +1 -1
- package/model/apidef.aon +128 -183
- package/model/guide.aon +3 -2
- package/package.json +5 -3
- package/src/apidef.ts +4 -3
- package/src/builder/entity/entity.ts +18 -1
- package/src/builder/flow/flowHeuristic01.ts +14 -14
- package/src/model.ts +36 -37
- package/src/resolved.ts +62 -17
- package/src/transform/args.ts +20 -20
- package/src/transform/clean.ts +5 -0
- package/src/transform/contract.ts +6 -71
- package/src/transform/entity.ts +13 -1
- package/src/transform/field.ts +66 -69
- package/src/transform/flowstep.ts +42 -42
- package/src/transform/graphql.ts +8 -8
- package/src/transform/operation.ts +9 -9
- package/src/transform/select.ts +13 -13
- package/src/types.ts +1 -1
- package/src/utility.ts +7 -0
package/src/transform/select.ts
CHANGED
|
@@ -39,7 +39,7 @@ const selectTransform: Transform = async function(
|
|
|
39
39
|
each(mop.points, (mpoint: ModelPoint) => {
|
|
40
40
|
// GraphQL defs have no `paths`; the lookup is only passed through to
|
|
41
41
|
// an unused parameter, so skip it rather than dereference undefined.
|
|
42
|
-
const pdef: PathDef = def.paths?.[mpoint.
|
|
42
|
+
const pdef: PathDef = def.paths?.[mpoint.o]
|
|
43
43
|
resolveSelect(guide, ment, mop, mpoint, pdef)
|
|
44
44
|
})
|
|
45
45
|
if (null != mop.points && 0 < mop.points.length) {
|
|
@@ -61,8 +61,8 @@ function resolveSelect(
|
|
|
61
61
|
mpoint: ModelPoint,
|
|
62
62
|
_pdef: PathDef
|
|
63
63
|
) {
|
|
64
|
-
const select: any = mpoint.
|
|
65
|
-
const margs: any = mpoint.
|
|
64
|
+
const select: any = mpoint.q
|
|
65
|
+
const margs: any = mpoint.g
|
|
66
66
|
|
|
67
67
|
const argkinds = ['params', 'query', 'header', 'cookie']
|
|
68
68
|
|
|
@@ -71,15 +71,15 @@ function resolveSelect(
|
|
|
71
71
|
// after, filters) as params, and requiring those for selection would make
|
|
72
72
|
// list() unusable without supplying every pagination argument. Only
|
|
73
73
|
// required arguments identify a point.
|
|
74
|
-
const reqdonly = 'graphql' === (mpoint as any).
|
|
74
|
+
const reqdonly = 'graphql' === (mpoint as any).k
|
|
75
75
|
|
|
76
76
|
argkinds.map((kind: string) => {
|
|
77
77
|
each(margs[kind], (marg: ModelArg) => {
|
|
78
|
-
if (reqdonly && !marg.
|
|
78
|
+
if (reqdonly && !marg.r) {
|
|
79
79
|
return
|
|
80
80
|
}
|
|
81
|
-
if (!select.exist.includes(marg.
|
|
82
|
-
select.exist.push(marg.
|
|
81
|
+
if (!select.exist.includes(marg.n)) {
|
|
82
|
+
select.exist.push(marg.n)
|
|
83
83
|
}
|
|
84
84
|
})
|
|
85
85
|
})
|
|
@@ -88,7 +88,7 @@ function resolveSelect(
|
|
|
88
88
|
|
|
89
89
|
const gent = guide.entity[ment.name]
|
|
90
90
|
// REST guides key entries by path, GraphQL guides by root field.
|
|
91
|
-
const gpath = gent.path?.[mpoint.
|
|
91
|
+
const gpath = gent.path?.[mpoint.o] ?? (gent as any).field?.[mpoint.o]
|
|
92
92
|
|
|
93
93
|
if (null == gpath) {
|
|
94
94
|
return
|
|
@@ -113,16 +113,16 @@ function sortPoints(
|
|
|
113
113
|
// Cache joined exist strings to avoid recomputing on every comparison.
|
|
114
114
|
const existCache = new Map<ModelPoint, string>()
|
|
115
115
|
for (const pt of mop.points) {
|
|
116
|
-
existCache.set(pt, pt.
|
|
116
|
+
existCache.set(pt, pt.q.exist.join('\t'))
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
mop.points.sort((a: ModelPoint, b: ModelPoint) => {
|
|
120
120
|
// longest exist len first
|
|
121
|
-
let order = b.
|
|
121
|
+
let order = b.q.exist.length - a.q.exist.length
|
|
122
122
|
if (0 === order) {
|
|
123
|
-
if (null != a.
|
|
124
|
-
order = a.
|
|
125
|
-
a.
|
|
123
|
+
if (null != a.q.$action && null != b.q.$action) {
|
|
124
|
+
order = a.q.$action < b.q.$action ? -1 :
|
|
125
|
+
a.q.$action > b.q.$action ? 1 : 0
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
if (0 === order) {
|
package/src/types.ts
CHANGED
|
@@ -298,7 +298,7 @@ type GuideRenameParam = {
|
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
type GuidePathOp = {
|
|
301
|
-
live?: Record<string, any>
|
|
301
|
+
live?: boolean | Record<string, any>
|
|
302
302
|
contract?: Record<string, any>
|
|
303
303
|
method: string
|
|
304
304
|
// GraphQL root-field ops carry the operation type instead of relying on
|
package/src/utility.ts
CHANGED
|
@@ -1068,6 +1068,12 @@ function inferFieldType(name: string, specType: string): string {
|
|
|
1068
1068
|
}
|
|
1069
1069
|
|
|
1070
1070
|
|
|
1071
|
+
function humanTitle(name: string): string {
|
|
1072
|
+
return snakify(name).split('_').filter(Boolean)
|
|
1073
|
+
.map(word => word[0].toUpperCase() + word.slice(1)).join(' ')
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
|
|
1071
1077
|
function normalizeFieldName(s: string): string {
|
|
1072
1078
|
if (null == s || '' === s) return ''
|
|
1073
1079
|
return s
|
|
@@ -1738,6 +1744,7 @@ export {
|
|
|
1738
1744
|
ensureMinEntityName,
|
|
1739
1745
|
inferFieldType,
|
|
1740
1746
|
normalizeFieldName,
|
|
1747
|
+
humanTitle,
|
|
1741
1748
|
prefixLeadingDigit,
|
|
1742
1749
|
debugpath,
|
|
1743
1750
|
debugpathOn,
|