@voxgig/apidef 8.13.0 → 8.15.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 (67) hide show
  1. package/bin/voxgig-apidef +1 -174
  2. package/dist/apidef.d.ts +2 -2
  3. package/dist/apidef.js +2 -2
  4. package/dist/apidef.js.map +1 -1
  5. package/dist/builder/entity/entity.d.ts +5 -1
  6. package/dist/builder/entity/entity.js +17 -1
  7. package/dist/builder/entity/entity.js.map +1 -1
  8. package/dist/builder/flow/flowHeuristic01.js +14 -14
  9. package/dist/builder/flow/flowHeuristic01.js.map +1 -1
  10. package/dist/cli.d.ts +38 -0
  11. package/dist/cli.js +279 -0
  12. package/dist/cli.js.map +1 -0
  13. package/dist/guide/guide.js +8 -5
  14. package/dist/guide/guide.js.map +1 -1
  15. package/dist/model.d.ts +35 -33
  16. package/dist/resolved.d.ts +10 -6
  17. package/dist/resolved.js +65 -15
  18. package/dist/resolved.js.map +1 -1
  19. package/dist/transform/args.js +19 -19
  20. package/dist/transform/args.js.map +1 -1
  21. package/dist/transform/clean.js +4 -0
  22. package/dist/transform/clean.js.map +1 -1
  23. package/dist/transform/contract.d.ts +0 -2
  24. package/dist/transform/contract.js +6 -75
  25. package/dist/transform/contract.js.map +1 -1
  26. package/dist/transform/entity.d.ts +2 -1
  27. package/dist/transform/entity.js +13 -1
  28. package/dist/transform/entity.js.map +1 -1
  29. package/dist/transform/field.js +64 -64
  30. package/dist/transform/field.js.map +1 -1
  31. package/dist/transform/flowstep.js +42 -42
  32. package/dist/transform/flowstep.js.map +1 -1
  33. package/dist/transform/graphql.js +8 -8
  34. package/dist/transform/graphql.js.map +1 -1
  35. package/dist/transform/operation.js +9 -9
  36. package/dist/transform/operation.js.map +1 -1
  37. package/dist/transform/select.js +13 -13
  38. package/dist/transform/select.js.map +1 -1
  39. package/dist/transform/top.js +1 -1
  40. package/dist/transform/top.js.map +1 -1
  41. package/dist/tsconfig.tsbuildinfo +1 -1
  42. package/dist/types.d.ts +1 -1
  43. package/dist/utility.d.ts +2 -1
  44. package/dist/utility.js +6 -1
  45. package/dist/utility.js.map +1 -1
  46. package/model/apidef.aon +128 -157
  47. package/model/guide.aon +3 -2
  48. package/package.json +5 -3
  49. package/src/apidef.ts +4 -3
  50. package/src/builder/entity/entity.ts +18 -1
  51. package/src/builder/flow/flowHeuristic01.ts +14 -14
  52. package/src/cli.ts +341 -0
  53. package/src/guide/guide.ts +8 -4
  54. package/src/model.ts +36 -37
  55. package/src/resolved.ts +62 -17
  56. package/src/transform/args.ts +20 -20
  57. package/src/transform/clean.ts +5 -0
  58. package/src/transform/contract.ts +6 -71
  59. package/src/transform/entity.ts +13 -1
  60. package/src/transform/field.ts +66 -69
  61. package/src/transform/flowstep.ts +42 -42
  62. package/src/transform/graphql.ts +8 -8
  63. package/src/transform/operation.ts +9 -9
  64. package/src/transform/select.ts +13 -13
  65. package/src/transform/top.ts +1 -1
  66. package/src/types.ts +1 -1
  67. package/src/utility.ts +8 -1
@@ -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) {
@@ -40,7 +40,7 @@ const topTransform = async function(
40
40
  // Guarantee at least one sentence of API description. Many specs (e.g. the
41
41
  // readme.io-hosted Bluefin APIs) ship a placeholder `info.description` of
42
42
  // "." — letterless, useless prose. When the description is empty or has no
43
- // letters, synthesise a sentence from the title so the api-info.aontu (and
43
+ // letters, synthesise a sentence from the title so the api-info.aon (and
44
44
  // the docs generated from it) never carry an empty/degenerate description.
45
45
  kit.info.description = ensureDescription(kit.info)
46
46
 
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
@@ -1135,7 +1141,7 @@ const CMP_RESULT_VERBS = [
1135
1141
 
1136
1142
  const CMP_PREFIXES = ['get_', 'post_', 'put_', 'delete_', 'patch_']
1137
1143
 
1138
- // A guide node (entity, path or op) is active unless guide.aontu explicitly
1144
+ // A guide node (entity, path or op) is active unless guide.aon explicitly
1139
1145
  // says otherwise. `active` has always been declared in the guide model and
1140
1146
  // documented as the escape hatch for a misclassified entity; this is the
1141
1147
  // single place that decides what it means, so entity/flow/operation transforms
@@ -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,