@voxgig/apidef 2.4.1 → 3.1.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 (108) hide show
  1. package/dist/apidef.d.ts +7 -2
  2. package/dist/apidef.js +190 -114
  3. package/dist/apidef.js.map +1 -1
  4. package/dist/builder/entity/entity.d.ts +3 -0
  5. package/dist/builder/entity/{apiEntity.js → entity.js} +12 -9
  6. package/dist/builder/entity/entity.js.map +1 -0
  7. package/dist/builder/entity/info.d.ts +3 -0
  8. package/dist/builder/entity/info.js +22 -0
  9. package/dist/builder/entity/info.js.map +1 -0
  10. package/dist/builder/entity.js +7 -21
  11. package/dist/builder/entity.js.map +1 -1
  12. package/dist/builder/flow/flowHeuristic01.js +21 -11
  13. package/dist/builder/flow/flowHeuristic01.js.map +1 -1
  14. package/dist/builder/flow.d.ts +2 -1
  15. package/dist/builder/flow.js +39 -12
  16. package/dist/builder/flow.js.map +1 -1
  17. package/dist/def.d.ts +62 -0
  18. package/dist/def.js +4 -0
  19. package/dist/def.js.map +1 -0
  20. package/dist/desc.d.ts +87 -0
  21. package/dist/desc.js +4 -0
  22. package/dist/desc.js.map +1 -0
  23. package/dist/guide/guide.d.ts +2 -1
  24. package/dist/guide/guide.js +161 -30
  25. package/dist/guide/guide.js.map +1 -1
  26. package/dist/guide/heuristic01.d.ts +2 -1
  27. package/dist/guide/heuristic01.js +1122 -234
  28. package/dist/guide/heuristic01.js.map +1 -1
  29. package/dist/model.d.ts +90 -0
  30. package/dist/model.js +4 -0
  31. package/dist/model.js.map +1 -0
  32. package/dist/parse.d.ts +4 -3
  33. package/dist/parse.js +40 -46
  34. package/dist/parse.js.map +1 -1
  35. package/dist/resolver.js +2 -1
  36. package/dist/resolver.js.map +1 -1
  37. package/dist/transform/args.d.ts +3 -0
  38. package/dist/transform/args.js +54 -0
  39. package/dist/transform/args.js.map +1 -0
  40. package/dist/transform/clean.d.ts +2 -2
  41. package/dist/transform/clean.js +28 -3
  42. package/dist/transform/clean.js.map +1 -1
  43. package/dist/transform/entity.d.ts +9 -1
  44. package/dist/transform/entity.js +57 -41
  45. package/dist/transform/entity.js.map +1 -1
  46. package/dist/transform/field.d.ts +1 -1
  47. package/dist/transform/field.js +89 -65
  48. package/dist/transform/field.js.map +1 -1
  49. package/dist/transform/flow.d.ts +3 -0
  50. package/dist/transform/flow.js +26 -0
  51. package/dist/transform/flow.js.map +1 -0
  52. package/dist/transform/flowstep.d.ts +3 -0
  53. package/dist/transform/flowstep.js +145 -0
  54. package/dist/transform/flowstep.js.map +1 -0
  55. package/dist/transform/operation.d.ts +3 -3
  56. package/dist/transform/operation.js +101 -296
  57. package/dist/transform/operation.js.map +1 -1
  58. package/dist/transform/select.d.ts +3 -0
  59. package/dist/transform/select.js +65 -0
  60. package/dist/transform/select.js.map +1 -0
  61. package/dist/transform/top.js +24 -2
  62. package/dist/transform/top.js.map +1 -1
  63. package/dist/transform.d.ts +1 -1
  64. package/dist/transform.js +4 -0
  65. package/dist/transform.js.map +1 -1
  66. package/dist/tsconfig.tsbuildinfo +1 -1
  67. package/dist/types.d.ts +115 -14
  68. package/dist/types.js +4 -2
  69. package/dist/types.js.map +1 -1
  70. package/dist/utility.d.ts +34 -2
  71. package/dist/utility.js +444 -6
  72. package/dist/utility.js.map +1 -1
  73. package/model/apidef.jsonic +76 -1
  74. package/model/guide.jsonic +14 -44
  75. package/package.json +19 -16
  76. package/src/apidef.ts +258 -122
  77. package/src/builder/entity/{apiEntity.ts → entity.ts} +18 -11
  78. package/src/builder/entity/info.ts +53 -0
  79. package/src/builder/entity.ts +9 -35
  80. package/src/builder/flow/flowHeuristic01.ts +46 -12
  81. package/src/builder/flow.ts +54 -13
  82. package/src/def.ts +91 -0
  83. package/src/desc.ts +154 -0
  84. package/src/guide/guide.ts +208 -134
  85. package/src/guide/heuristic01.ts +1653 -272
  86. package/src/model.ts +143 -0
  87. package/src/parse.ts +50 -59
  88. package/src/resolver.ts +3 -1
  89. package/src/schematron.ts.off +317 -0
  90. package/src/transform/args.ts +98 -0
  91. package/src/transform/clean.ts +45 -11
  92. package/src/transform/entity.ts +96 -50
  93. package/src/transform/field.ts +136 -75
  94. package/src/transform/flow.ts +59 -0
  95. package/src/transform/flowstep.ts +242 -0
  96. package/src/transform/operation.ts +119 -419
  97. package/src/transform/select.ts +119 -0
  98. package/src/transform/top.ts +46 -4
  99. package/src/transform.ts +8 -4
  100. package/src/types.ts +181 -5
  101. package/src/utility.ts +567 -9
  102. package/dist/builder/entity/apiEntity.d.ts +0 -3
  103. package/dist/builder/entity/apiEntity.js.map +0 -1
  104. package/dist/builder/entity/def.d.ts +0 -3
  105. package/dist/builder/entity/def.js +0 -19
  106. package/dist/builder/entity/def.js.map +0 -1
  107. package/src/builder/entity/def.ts +0 -44
  108. package/src/guide.ts.off +0 -136
@@ -6,38 +6,45 @@ import { each, File, Folder, Content } from 'jostraca'
6
6
 
7
7
 
8
8
  import type {
9
+ KitModel,
9
10
  ApiDefOptions,
10
11
  } from '../../types'
11
12
 
12
13
  import {
13
- formatJsonSrc,
14
+ KIT
15
+ } from '../../types'
16
+
17
+ import {
18
+ formatJSONIC,
14
19
  } from '../../utility'
15
20
 
16
21
 
17
22
 
18
- function resolveApiEntity(
23
+ function resolveEntity(
19
24
  apimodel: any,
20
25
  opts: ApiDefOptions,
21
26
  ) {
27
+ const kit: KitModel = apimodel.main[KIT]
28
+
22
29
  const barrel = [
23
30
  '# Entity Models\n'
24
31
  ]
25
32
 
26
33
  const entityFiles: { name: string, src: string }[] = []
27
34
 
28
- each(apimodel.main.api.entity, ((entity: any, entityName: string) => {
35
+ each(kit.entity, ((entity: any, entityName: string) => {
29
36
  const entityFile = (null == opts.outprefix ? '' : opts.outprefix) + entityName + '.jsonic'
30
37
 
31
- const entityJSON =
32
- JSON.stringify(entity, null, 2)
38
+ let entityJSONIC = formatJSONIC(entity).trim()
39
+ entityJSONIC = entityJSONIC.substring(1, entityJSONIC.length - 1)
33
40
 
34
41
  const fieldAliasesSrc = fieldAliases(entity)
35
42
 
36
43
  const entitySrc =
37
44
  `# Entity: ${entity.name}\n\n` +
38
- `main: api: entity: ${entity.name}: {\n\n` +
45
+ `main: ${KIT}: entity: ${entity.name}: {\n\n` +
39
46
  ` alias: field: ${fieldAliasesSrc}\n` +
40
- formatJsonSrc(entityJSON.substring(1, entityJSON.length - 1)) +
47
+ entityJSONIC +
41
48
  '\n\n}\n'
42
49
 
43
50
  entityFiles.push({ name: entityFile, src: entitySrc })
@@ -45,10 +52,10 @@ function resolveApiEntity(
45
52
  barrel.push(`@"${Path.basename(entityFile)}"`)
46
53
  }))
47
54
 
48
- const indexFile = (null == opts.outprefix ? '' : opts.outprefix) + 'api-entity-index.jsonic'
55
+ const indexFile = (null == opts.outprefix ? '' : opts.outprefix) + 'entity-index.jsonic'
49
56
 
50
57
  return function apiEntityBuilder() {
51
- Folder({ name: 'api' }, () => {
58
+ Folder({ name: 'entity' }, () => {
52
59
  each(entityFiles, (entityFile) => {
53
60
  File({ name: entityFile.name }, () => Content(entityFile.src))
54
61
  })
@@ -56,9 +63,9 @@ function resolveApiEntity(
56
63
  File({ name: indexFile }, () => Content(barrel.join('\n')))
57
64
  })
58
65
  }
59
-
60
66
  }
61
67
 
68
+
62
69
  function fieldAliases(entity: any) {
63
70
  // HEURISTIC: id may be name_id or nameId
64
71
  const fieldAliases =
@@ -84,5 +91,5 @@ function fieldAliases(entity: any) {
84
91
 
85
92
 
86
93
  export {
87
- resolveApiEntity
94
+ resolveEntity
88
95
  }
@@ -0,0 +1,53 @@
1
+ /* Copyright (c) 2025 Voxgig, MIT License */
2
+
3
+
4
+ import { formatJSONIC } from '../../utility'
5
+
6
+
7
+ import type {
8
+ KitModel,
9
+
10
+ ApiDefOptions,
11
+ ApiModel,
12
+ } from '../../types'
13
+
14
+ import {
15
+ KIT
16
+ } from '../../types'
17
+
18
+ import {
19
+ File,
20
+ Folder,
21
+ Content
22
+ } from 'jostraca'
23
+
24
+
25
+ function resolveInfo(
26
+ apimodel: any,
27
+ opts: ApiDefOptions,
28
+ ) {
29
+ const kit: KitModel = apimodel.main[KIT]
30
+
31
+ const infoFile =
32
+ (null == opts.outprefix ? '' : opts.outprefix) + 'api-info.jsonic'
33
+
34
+ const modelInfo = { main: { kit: { info: kit.info } } }
35
+
36
+ let modelDefSrc = formatJSONIC(modelInfo)
37
+
38
+ modelDefSrc =
39
+ '# API Information\n\n' +
40
+ modelDefSrc.substring(1, modelDefSrc.length - 1).replace(/\n /g, '\n')
41
+
42
+ return function infoBuilder() {
43
+ Folder({ name: 'api' }, () => {
44
+ File({ name: infoFile }, () => Content(modelDefSrc))
45
+ })
46
+ }
47
+
48
+ }
49
+
50
+
51
+ export {
52
+ resolveInfo
53
+ }
@@ -1,54 +1,28 @@
1
1
  /* Copyright (c) 2025 Voxgig, MIT License */
2
2
 
3
- import Path from 'node:path'
4
-
5
- // import { each } from 'jostraca'
6
-
7
-
8
- // import type {
9
- // ApiDefOptions,
10
- // Log,
11
- // FsUtil,
12
- // } from '../types'
13
-
14
-
15
- // import {
16
- // writeChanged
17
- // } from '../utility'
18
-
19
3
 
20
4
  import {
21
- resolveApiEntity
22
- } from './entity/apiEntity'
5
+ resolveEntity
6
+ } from './entity/entity'
23
7
 
24
8
  import {
25
- resolveDef
26
- } from './entity/def'
27
-
28
- // import {
29
- // resolveSdkEntity
30
- // } from './entity/sdkEntity'
31
-
9
+ resolveInfo
10
+ } from './entity/info'
32
11
 
33
12
 
34
13
  async function makeEntityBuilder(ctx: any) {
35
14
  const { apimodel, opts } = ctx
36
15
 
37
- const apiEntityBuilder = resolveApiEntity(apimodel, opts)
38
- const defBuilder = resolveDef(apimodel, opts)
39
- // const sdkEntityBuilder = resolveSdkEntity(apimodel, opts)
16
+ const entityBuilder = resolveEntity(apimodel, opts)
17
+ const infoBuilder = resolveInfo(apimodel, opts)
40
18
 
41
- return function entityBuilder() {
42
- apiEntityBuilder()
43
- defBuilder()
44
- // sdkEntityBuilder()
19
+ return function fullEntityBuilder() {
20
+ entityBuilder()
21
+ infoBuilder()
45
22
  }
46
23
  }
47
24
 
48
25
 
49
-
50
-
51
-
52
26
  export {
53
27
  makeEntityBuilder
54
28
  }
@@ -3,6 +3,27 @@ import { size } from '@voxgig/struct'
3
3
 
4
4
  import { each, names } from 'jostraca'
5
5
 
6
+ import { getelem } from '@voxgig/struct'
7
+
8
+
9
+ import type {
10
+ KitModel
11
+ } from '../../types'
12
+
13
+ import {
14
+ KIT
15
+ } from '../../types'
16
+
17
+ import type {
18
+ ModelEntity,
19
+ ModelOp,
20
+ ModelAlt,
21
+ } from '../../model'
22
+
23
+ import {
24
+ nom
25
+ } from '../../utility'
26
+
6
27
 
7
28
  async function flowHeuristic01(ctx: any): Promise<any[]> {
8
29
  let entity = ctx.guide.entity
@@ -21,10 +42,12 @@ async function flowHeuristic01(ctx: any): Promise<any[]> {
21
42
 
22
43
  function resolveBasicEntityFlow(ctx: any, entity: any) {
23
44
  const { apimodel, model } = ctx
24
- const apiEntity = apimodel.main.api.entity[entity.name]
45
+ const kit: KitModel = apimodel.main[KIT]
46
+
47
+ const apiEntity: ModelEntity = kit.entity[entity.name]
25
48
 
26
49
  const flow: any = {
27
- name: 'Basic' + apiEntity.Name + 'Flow'
50
+ name: 'Basic' + nom(apiEntity, 'Name') + 'Flow'
28
51
  }
29
52
 
30
53
  const refs = [
@@ -39,7 +62,7 @@ function resolveBasicEntityFlow(ctx: any, entity: any) {
39
62
  name: flow.name,
40
63
  active: true,
41
64
  param: {
42
- [`${model.NAME}_TEST_${apiEntity.NAME}_ENTID`]: idmap,
65
+ [`${model.NAME}_TEST_${nom(apiEntity, 'NAME')}_ENTID`]: idmap,
43
66
  [`${model.NAME}_TEST_LIVE`]: "FALSE",
44
67
  [`${model.NAME}_TEST_EXPLAIN`]: "FALSE",
45
68
  },
@@ -56,8 +79,8 @@ function resolveBasicEntityFlow(ctx: any, entity: any) {
56
79
  const id = idmap[ref]
57
80
  const ent: any = data[id] = {}
58
81
 
59
- let num = (i * size(apiEntity.field) * 10)
60
- each(apiEntity.field, (field) => {
82
+ let num = (i * size(apiEntity.fields) * 10)
83
+ each(apiEntity.fields, (field) => {
61
84
  ent[field.name] =
62
85
  'number' === field.type ? num :
63
86
  'boolean' === field.type ? 0 === num % 2 :
@@ -77,11 +100,15 @@ function resolveBasicEntityFlow(ctx: any, entity: any) {
77
100
  let name
78
101
 
79
102
  const am: any = {}
103
+ const entop = apiEntity.op ?? {}
104
+
105
+
106
+ if (entop.load) {
80
107
 
81
- if (apiEntity.op.load) {
108
+ const alt = findMainLoadAlt(entop.load)
82
109
 
83
110
  // Get additional required match properties
84
- each(apiEntity.op.load.param, (param: any) => {
111
+ each(alt?.args.param, (param: any) => {
85
112
  if (param.required) {
86
113
  let ancestorName = param.name
87
114
  let ancestorEntity = apimodel.main.api.entity[ancestorName]
@@ -98,7 +125,7 @@ function resolveBasicEntityFlow(ctx: any, entity: any) {
98
125
  am[param.name] =
99
126
  `\`dm$=p.${model.NAME}_TEST_${ancestorEntity.NAME}_ENTID.${ancestorEntity.name}01\``
100
127
 
101
- data[`${apiEntity.NAME}01`][param.name] = ancestorEntity.NAME + '01'
128
+ data[`${nom(apiEntity, 'NAME')}01`][param.name] = ancestorEntity.NAME + '01'
102
129
  }
103
130
  }
104
131
  })
@@ -111,7 +138,7 @@ function resolveBasicEntityFlow(ctx: any, entity: any) {
111
138
  entity: `${apiEntity.name}`,
112
139
  action: 'load',
113
140
  match: {
114
- id: `\`dm$=p.${model.NAME}_TEST_${apiEntity.NAME}_ENTID.${apiEntity.name}01\``,
141
+ id: `\`dm$=p.${model.NAME}_TEST_${nom(apiEntity, 'NAME')}_ENTID.${apiEntity.name}01\``,
115
142
  ...am,
116
143
  },
117
144
  valid: {
@@ -122,7 +149,7 @@ function resolveBasicEntityFlow(ctx: any, entity: any) {
122
149
  })
123
150
  }
124
151
 
125
- if (apiEntity.op.update && apiEntity.op.load) {
152
+ if (entop.update && entop.load) {
126
153
  num++
127
154
  name = `update_${apiEntity.name}${num}`
128
155
  const id = idmap[`${apiEntity.name}01`]
@@ -151,7 +178,7 @@ function resolveBasicEntityFlow(ctx: any, entity: any) {
151
178
  entity: `${apiEntity.name}`,
152
179
  action: 'load',
153
180
  match: {
154
- id: `\`dm$=p.${model.NAME}_TEST_${apiEntity.NAME}_ENTID.${apiEntity.name}01\``,
181
+ id: `\`dm$=p.${model.NAME}_TEST_${nom(apiEntity, 'NAME')}_ENTID.${apiEntity.name}01\``,
155
182
  ...am,
156
183
  },
157
184
  valid: {
@@ -169,11 +196,18 @@ function resolveBasicEntityFlow(ctx: any, entity: any) {
169
196
  }
170
197
 
171
198
 
199
+ function findMainLoadAlt(op: ModelOp): ModelAlt | undefined {
200
+ let cands = op.alts.filter(a => '{id}' === getelem(a.parts, -1))
201
+ return cands[0]
202
+ }
203
+
204
+
172
205
  function makeUpdateData(name: string, apiEntity: any, flow: any, id: string) {
173
206
  const ud: any = {}
174
207
  const data = flow.model.test.entity[apiEntity.name]
175
208
 
176
- const dataFields = each(apiEntity.field).filter(f => 'id' !== f.name && !f.name.includes('_id'))
209
+ const dataFields =
210
+ each(apiEntity.field).filter(f => 'id' !== f.name && !f.name.includes('_id'))
177
211
  const stringFields = each(dataFields).filter(f => 'string' === f.type)
178
212
 
179
213
  if (0 < size(stringFields)) {
@@ -1,9 +1,20 @@
1
1
 
2
+ // TODO: move this to sdkgen
3
+
4
+
2
5
  import Path from 'node:path'
3
6
 
4
7
  import { File, Content, Folder, each } from 'jostraca'
5
8
 
9
+
10
+ import {
11
+ ApiDefContext,
12
+ KIT,
13
+ } from '../types'
14
+
15
+
6
16
  import {
17
+ nom,
7
18
  formatJsonSrc,
8
19
  } from '../utility'
9
20
 
@@ -11,18 +22,44 @@ import {
11
22
  import { flowHeuristic01 } from './flow/flowHeuristic01'
12
23
 
13
24
 
14
- async function makeFlowBuilder(ctx: any) {
15
- let flows: any[] = []
25
+ async function makeFlowBuilder(ctx: ApiDefContext): Promise<Function> {
26
+ const { apimodel, opts } = ctx
27
+
28
+ const flows = apimodel.main[KIT].flow
29
+
30
+ let flowBuilder = () => {
31
+ ctx.warn({
32
+ step: 'flow',
33
+ note: 'Unable to generate flow definitions as flows were not resolved.'
34
+ })
35
+ }
16
36
 
37
+ /*
17
38
  if ('heuristic01' === ctx.opts.strategy) {
18
- flows = await flowHeuristic01(ctx)
39
+ try {
40
+ flows = await flowHeuristic01(ctx)
41
+ }
42
+ catch (err: any) {
43
+ err.foo = { x: 1, y: [2] }
44
+ err.foo.z = err.foo
45
+ ctx.warn({
46
+ step: 'flow',
47
+ note: 'Unable to resolve flows due to unexpected error: ' + err.message,
48
+ err,
49
+ })
50
+ return flowBuilder
51
+ }
19
52
  }
20
53
  else {
21
- throw new Error('Unknown guide strategy: ' + ctx.opts.strategy)
54
+ ctx.warn({
55
+ step: 'flow',
56
+ note: 'Unable to resolve flows: unknown guide strategy: ' + ctx.opts.strategy
57
+ })
58
+ return flowBuilder
22
59
  }
60
+ */
23
61
 
24
-
25
- return function flowBuilder() {
62
+ flowBuilder = () => {
26
63
 
27
64
  Folder({ name: 'flow' }, () => {
28
65
  const barrel = [
@@ -33,13 +70,13 @@ async function makeFlowBuilder(ctx: any) {
33
70
  let flowfile =
34
71
  Path.join(ctx.opts.folder, 'flow',
35
72
  (null == ctx.opts.outprefix ? '' : ctx.opts.outprefix) +
36
- flow.Name + '.jsonic')
73
+ flow.name + '.jsonic')
37
74
 
38
- let flowModelSrc = formatJsonSrc(JSON.stringify(flow.model, null, 2))
75
+ let flowModelSrc = formatJsonSrc(JSON.stringify(flow, null, 2))
39
76
 
40
- let flowsrc = `# ${flow.Name}
77
+ let flowsrc = `# ${nom(flow, 'Name')}
41
78
 
42
- main: sdk: flow: ${flow.Name}:
79
+ main: ${KIT}: flow: ${flow.name}:
43
80
  ` + flowModelSrc
44
81
 
45
82
  barrel.push(`@"${Path.basename(flowfile)}"`)
@@ -47,11 +84,15 @@ main: sdk: flow: ${flow.Name}:
47
84
  File({ name: Path.basename(flowfile) }, () => Content(flowsrc))
48
85
  })
49
86
 
50
- File({
51
- name: (null == ctx.opts.outprefix ? '' : ctx.opts.outprefix) + 'flow-index.jsonic'
52
- }, () => Content(barrel.join('\n')))
87
+ const barrelFile = (null == ctx.opts.outprefix ? '' : ctx.opts.outprefix) + 'flow-index.jsonic'
88
+
89
+ const barrelContent = barrel.join('\n')
90
+
91
+ File({ name: barrelFile }, () => Content(barrelContent))
53
92
  })
54
93
  }
94
+
95
+ return flowBuilder
55
96
  }
56
97
 
57
98
 
package/src/def.ts ADDED
@@ -0,0 +1,91 @@
1
+ /* Copyright (c) 2024-2025 Voxgig, MIT License */
2
+
3
+ // Consolidated definitions for OpenAPI/Swagger API definition types
4
+
5
+
6
+ type PathDef = {
7
+ summary?: string
8
+ description?: string
9
+ get?: MethodDef
10
+ put?: MethodDef
11
+ post?: MethodDef
12
+ delete?: MethodDef
13
+ options?: MethodDef
14
+ head?: MethodDef
15
+ patch?: MethodDef
16
+ trace?: MethodDef
17
+ servers?: ServerDef[]
18
+ parameters?: ParameterDef[]
19
+ tags?: any
20
+ }
21
+
22
+
23
+ type MethodDef = {
24
+ tags?: string[]
25
+ summary?: string
26
+ description?: string
27
+ operationId?: string
28
+ parameters?: ParameterDef[]
29
+ // requestBody?: RequestBodyObject | ReferenceDef
30
+ // responses: Record<string, ResponseObject | ReferenceDef>
31
+ // callbacks?: Record<string, CallbackObject | ReferenceDef>
32
+ deprecated?: boolean
33
+ // security?: SecurityRequirementDef[]
34
+ servers?: ServerDef[]
35
+ }
36
+
37
+
38
+ type ServerDef = {
39
+ url: string
40
+ description?: string
41
+ variables?: Record<string, ServerVariableDef>
42
+ }
43
+
44
+
45
+ type ServerVariableDef = {
46
+ enum?: string[]
47
+ default: string
48
+ description?: string
49
+ }
50
+
51
+
52
+ type ParameterDef = {
53
+ name: string
54
+ in: "query" | "header" | "path" | "cookie"
55
+ description?: string
56
+ required?: boolean
57
+ deprecated?: boolean
58
+ schema?: SchemaDef
59
+ nullable?: boolean
60
+ example?: any
61
+ // examples?: Record<string, ExampleObject | ReferenceDef>
62
+ }
63
+
64
+
65
+ type SchemaDef = {
66
+ title?: string
67
+ description?: string
68
+ type?: string
69
+ format?: string
70
+ enum?: any[]
71
+ items?: SchemaDef
72
+ properties?: Record<string, SchemaDef>
73
+ required?: string[]
74
+ additionalProperties?: boolean | SchemaDef
75
+ allOf?: SchemaDef[]
76
+ oneOf?: SchemaDef[]
77
+ anyOf?: SchemaDef[]
78
+ nullable?: boolean
79
+ default?: any
80
+ example?: any
81
+ }
82
+
83
+
84
+ export type {
85
+ PathDef,
86
+ MethodDef,
87
+ ServerDef,
88
+ ServerVariableDef,
89
+ ParameterDef,
90
+ SchemaDef,
91
+ }
package/src/desc.ts ADDED
@@ -0,0 +1,154 @@
1
+ /* Copyright (c) 2024-2025 Voxgig, MIT License */
2
+
3
+ // Consolidated intermediate analysis types for OpenAPI definition processing
4
+
5
+ import type { PathMatch } from './utility'
6
+ import type { MethodName } from './types'
7
+ import type { ParameterDef } from './def'
8
+
9
+
10
+
11
+ // // Intermediate Guide types used during analysis
12
+ // type GuidePathRename = {
13
+ // param?: Record<string, string>
14
+ // }
15
+
16
+ // type GuideOp = {
17
+ // method: MethodName
18
+ // }
19
+
20
+ // type GuidePath = {
21
+ // rename?: GuidePathRename
22
+ // op?: Record<string, GuideOp>
23
+ // }
24
+
25
+
26
+ // Component analysis description
27
+ type CmpDesc = {
28
+ namedesc?: any,
29
+ path_rate: number,
30
+ method_rate: number,
31
+ }
32
+
33
+
34
+ // Basic method description from types.ts (renamed to avoid conflict)
35
+ type BasicMethodDesc = {
36
+ name: MethodName,
37
+ def: Record<string, any>,
38
+ path: string,
39
+ }
40
+
41
+
42
+ // Detailed method analysis description from heuristic01.ts
43
+ type MethodDesc = {
44
+ path: string
45
+ method: string
46
+ summary: string
47
+ tags: string[]
48
+ parameters: any[]
49
+ responses: Record<string, any>
50
+ requestBody: Record<string, any>
51
+ MethodEntity: MethodEntityDesc
52
+ }
53
+
54
+
55
+ // Method entity relationship analysis
56
+ type MethodEntityDesc = {
57
+ ref: string
58
+
59
+ cmp: string | null
60
+ origcmp: string | null
61
+ origcmpref: string | null
62
+
63
+ why_cmp: string[]
64
+ cmpoccur: number
65
+ path_rate: number
66
+ method_rate: number
67
+ entname: string
68
+ why_op: string[]
69
+ rename: Record<string, any>
70
+ why_rename: Record<string, any>
71
+ rename_orig: string[]
72
+ opname: string
73
+ why_opname: string[]
74
+
75
+ pm?: any
76
+ }
77
+
78
+
79
+ // Entity analysis description
80
+ type EntityDesc = {
81
+ name: string
82
+ origname: string
83
+ plural: string
84
+ path: Record<string, EntityPathDesc>
85
+ alias: Record<string, string>,
86
+ cmp: CmpDesc
87
+ }
88
+
89
+
90
+ // Entity path relationship analysis
91
+ type EntityPathDesc = {
92
+ op: Record<string, any>
93
+ pm: PathMatch
94
+
95
+ rename: {
96
+ param: Record<string, string>
97
+ }
98
+ why_rename: {
99
+ why_param: Record<string, string[]>
100
+ }
101
+
102
+ action: Record<string, {
103
+ why_action: string[]
104
+ }>
105
+
106
+ why_action: Record<string, string[]>
107
+
108
+ why_ent: string[]
109
+ why_path: string[]
110
+ }
111
+
112
+
113
+ // Path analysis description
114
+ type PathDesc = {
115
+ orig: string
116
+ method: MethodName
117
+ parts: string[]
118
+ // rename: GuidePathRename
119
+ rename: {
120
+ param?: Record<string, any>
121
+ }
122
+ // op: GuidePath["op"]
123
+ op: Record<string, {
124
+ method: any
125
+ transform: {
126
+ req?: any
127
+ res?: any
128
+ }
129
+ }>
130
+ def: {
131
+ parameters?: ParameterDef[]
132
+ }
133
+ }
134
+
135
+
136
+ // Operation analysis description
137
+ type OpDesc = {
138
+ paths: PathDesc[]
139
+ }
140
+
141
+
142
+ export type {
143
+ // GuidePathRename,
144
+ // GuideOp,
145
+ // GuidePath,
146
+ CmpDesc,
147
+ BasicMethodDesc,
148
+ MethodDesc,
149
+ MethodEntityDesc,
150
+ EntityDesc,
151
+ EntityPathDesc,
152
+ PathDesc,
153
+ OpDesc,
154
+ }