@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.
Files changed (56) hide show
  1. package/dist/apidef.d.ts +2 -2
  2. package/dist/apidef.js +2 -2
  3. package/dist/apidef.js.map +1 -1
  4. package/dist/builder/entity/entity.d.ts +5 -1
  5. package/dist/builder/entity/entity.js +17 -1
  6. package/dist/builder/entity/entity.js.map +1 -1
  7. package/dist/builder/flow/flowHeuristic01.js +14 -14
  8. package/dist/builder/flow/flowHeuristic01.js.map +1 -1
  9. package/dist/model.d.ts +35 -33
  10. package/dist/resolved.d.ts +10 -6
  11. package/dist/resolved.js +65 -15
  12. package/dist/resolved.js.map +1 -1
  13. package/dist/transform/args.js +19 -19
  14. package/dist/transform/args.js.map +1 -1
  15. package/dist/transform/clean.js +4 -0
  16. package/dist/transform/clean.js.map +1 -1
  17. package/dist/transform/contract.d.ts +0 -2
  18. package/dist/transform/contract.js +6 -75
  19. package/dist/transform/contract.js.map +1 -1
  20. package/dist/transform/entity.d.ts +2 -1
  21. package/dist/transform/entity.js +13 -1
  22. package/dist/transform/entity.js.map +1 -1
  23. package/dist/transform/field.js +64 -64
  24. package/dist/transform/field.js.map +1 -1
  25. package/dist/transform/flowstep.js +42 -42
  26. package/dist/transform/flowstep.js.map +1 -1
  27. package/dist/transform/graphql.js +8 -8
  28. package/dist/transform/graphql.js.map +1 -1
  29. package/dist/transform/operation.js +9 -9
  30. package/dist/transform/operation.js.map +1 -1
  31. package/dist/transform/select.js +13 -13
  32. package/dist/transform/select.js.map +1 -1
  33. package/dist/tsconfig.tsbuildinfo +1 -1
  34. package/dist/types.d.ts +1 -1
  35. package/dist/utility.d.ts +2 -1
  36. package/dist/utility.js +5 -0
  37. package/dist/utility.js.map +1 -1
  38. package/model/apidef.aon +128 -183
  39. package/model/guide.aon +3 -2
  40. package/package.json +5 -3
  41. package/src/apidef.ts +4 -3
  42. package/src/builder/entity/entity.ts +18 -1
  43. package/src/builder/flow/flowHeuristic01.ts +14 -14
  44. package/src/model.ts +36 -37
  45. package/src/resolved.ts +62 -17
  46. package/src/transform/args.ts +20 -20
  47. package/src/transform/clean.ts +5 -0
  48. package/src/transform/contract.ts +6 -71
  49. package/src/transform/entity.ts +13 -1
  50. package/src/transform/field.ts +66 -69
  51. package/src/transform/flowstep.ts +42 -42
  52. package/src/transform/graphql.ts +8 -8
  53. package/src/transform/operation.ts +9 -9
  54. package/src/transform/select.ts +13 -13
  55. package/src/types.ts +1 -1
  56. package/src/utility.ts +7 -0
@@ -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.orig]
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.select
65
- const margs: any = mpoint.args
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).kind
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.reqd) {
78
+ if (reqdonly && !marg.r) {
79
79
  return
80
80
  }
81
- if (!select.exist.includes(marg.name)) {
82
- select.exist.push(marg.name)
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.orig] ?? (gent as any).field?.[mpoint.orig]
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.select.exist.join('\t'))
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.select.exist.length - a.select.exist.length
121
+ let order = b.q.exist.length - a.q.exist.length
122
122
  if (0 === order) {
123
- if (null != a.select.$action && null != b.select.$action) {
124
- order = a.select.$action < b.select.$action ? -1 :
125
- a.select.$action > b.select.$action ? 1 : 0
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,