@voxgig/apidef 5.10.0 → 6.0.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 +1 @@
1
- {"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/transform/select.ts"],"names":[],"mappings":";;;AAEA,uCAA+B;AAK/B,oCAA8B;AAqB9B,MAAM,eAAe,GAAc,KAAK,WACtC,GAAQ;IAER,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,CAAA;IACpC,MAAM,GAAG,GAAa,QAAQ,CAAC,IAAI,CAAC,WAAG,CAAC,CAAA;IAExC,IAAI,GAAG,GAAG,SAAS,CAAA;IAEnB,IAAA,eAAI,EAAC,GAAG,CAAC,MAAM,EAAE,CAAC,IAAiB,EAAE,QAAgB,EAAE,EAAE;QACvD,IAAA,eAAI,EAAC,IAAI,CAAC,EAAE,EAAE,CAAC,GAAY,EAAE,OAAe,EAAE,EAAE;YAC9C,IAAA,eAAI,EAAC,GAAG,CAAC,MAAM,EAAE,CAAC,OAAoB,EAAE,EAAE;gBACxC,MAAM,IAAI,GAAY,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;gBAC7C,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;YAChD,CAAC,CAAC,CAAA;YACF,IAAI,IAAI,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBAChD,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;YAC9B,CAAC;QACH,CAAC,CAAC,CAAA;QAEF,GAAG,IAAI,IAAI,CAAC,IAAI,GAAG,GAAG,CAAA;IACxB,CAAC,CAAC,CAAA;IAEF,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;AAC1B,CAAC,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
17
  const { apimodel, def } = ctx;
18
18
  const kit = apimodel.main[types_1.KIT];
19
- kit.info = def.info;
20
- kit.info.servers = def.servers ?? [];
19
+ kit.info = stringifyInfoScalars(def.info ?? {});
20
+ kit.info.servers = stringifyInfoScalars(def.servers ?? []);
21
21
  // Swagger 2.0
22
22
  if (def.host) {
23
23
  kit.info.servers.push({
24
24
  url: (def.schemes?.[0] ?? 'https') + '://' + (0, struct_1.join)([def.host, def.basePath], '/', true)
25
25
  });
26
26
  }
27
+ // A usable SDK requires a base URL. OpenAPI 3 puts it in `servers[].url`;
28
+ // Swagger 2 derives it from `host` + `basePath`. If neither yields a
29
+ // non-empty url, the generated SDK has no way to issue requests, so fail
30
+ // the apidef model build rather than emit broken code.
31
+ const firstServerUrl = kit.info.servers?.[0]?.url;
32
+ if (null == firstServerUrl || '' === String(firstServerUrl).trim()) {
33
+ throw new Error('apidef: no server URL found in API definition (servers[0].url is required).');
34
+ }
27
35
  return { ok: true, msg: 'top' };
28
36
  };
29
37
  exports.topTransform = topTransform;
38
+ // OpenAPI's `info` object (and the `servers` array) declares every scalar
39
+ // leaf as a string. YAML/JSON parsers don't enforce that — `version: 2`
40
+ // without quotes parses as the number 2, `version: true` as a boolean.
41
+ // Apidef's downstream schema (apidef.jsonic) unifies info fields as
42
+ // `string`, so non-string scalars cause an aontu unify failure during
43
+ // model resolution. Normalise scalar leaves to strings here, at the
44
+ // model-build boundary, rather than relax the schema.
45
+ function stringifyInfoScalars(node) {
46
+ if (null == node)
47
+ return node;
48
+ if (Array.isArray(node))
49
+ return node.map(stringifyInfoScalars);
50
+ if ('object' === typeof node) {
51
+ const out = {};
52
+ for (const [k, v] of Object.entries(node)) {
53
+ out[k] = stringifyInfoScalars(v);
54
+ }
55
+ return out;
56
+ }
57
+ if ('number' === typeof node || 'boolean' === typeof node) {
58
+ return String(node);
59
+ }
60
+ return node;
61
+ }
30
62
  // export type {
31
63
  // GuideEntity,
32
64
  // }
@@ -1 +1 @@
1
- {"version":3,"file":"top.js","sourceRoot":"","sources":["../../src/transform/top.ts"],"names":[],"mappings":";;;AACA,2CAAqC;AAErC,oCAA8B;AAmB9B,6BAA6B;AAC7B,yCAAyC;AACzC,8BAA8B;AAC9B,gCAAgC;AAGhC,uBAAuB;AACvB,kBAAkB;AAClB,oCAAoC;AAEpC,uBAAuB;AACvB,iCAAiC;AACjC,IAAI;AAGJ,MAAM,YAAY,GAAG,KAAK,WACxB,GAAQ;IAER,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IAC7B,MAAM,GAAG,GAAa,QAAQ,CAAC,IAAI,CAAC,WAAG,CAAC,CAAA;IAExC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAA;IACnB,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,IAAI,EAAE,CAAA;IAEpC,cAAc;IACd,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;QACb,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YACpB,GAAG,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,GAAG,KAAK,GAAG,IAAA,aAAI,EAAC,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC;SACvF,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;AACjC,CAAC,CAAA;AAIC,oCAAY;AAId,gBAAgB;AAChB,iBAAiB;AACjB,IAAI"}
1
+ {"version":3,"file":"top.js","sourceRoot":"","sources":["../../src/transform/top.ts"],"names":[],"mappings":";;;AACA,2CAAqC;AAErC,oCAA8B;AAmB9B,6BAA6B;AAC7B,yCAAyC;AACzC,8BAA8B;AAC9B,gCAAgC;AAGhC,uBAAuB;AACvB,kBAAkB;AAClB,oCAAoC;AAEp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AsE;AACtE,oEAAoE;AACpE,sDAAsD;AACtD,SAAS,oBAAoB,CAAC,IAAS;IACrC,IAAI,IAAI,IAAI,IAAI;QAAE,OAAO,IAAI,CAAA;IAC7B,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;IAC9D,IAAI,QAAQ,KAAK,OAAO,IAAI,EAAE,CAAC;QAC7B,MAAM,GAAG,GAAwB,EAAE,CAAA;QACnC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1C,GAAG,CAAC,CAAC,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAA;QAClC,CAAC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;IACD,IAAI,QAAQ,KAAK,OAAO,IAAI,IAAI,SAAS,KAAK,OAAO,IAAI,EAAE,CAAC;QAC1D,OAAO,MAAM,CAAC,IAAI,CAAC,CAAA;IACrB,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAQD,gBAAgB;AAChB,iBAAiB;AACjB,IAAI"}
package/dist/types.d.ts CHANGED
@@ -1002,6 +1002,7 @@ type KitModel = {
1002
1002
  };
1003
1003
  type ApiDefResult = {
1004
1004
  ok: boolean;
1005
+ reload?: boolean;
1005
1006
  start: number;
1006
1007
  end: number;
1007
1008
  steps: string[];
@@ -1102,4 +1103,4 @@ type GuidePathOp = {
1102
1103
  export { KIT, OpenControlShape, OpenModelShape, OpenBuildShape, };
1103
1104
  export type { Guide, GuideMetrics, GuideEntity, GuidePath, GuidePathAction, GuideRenameParam, GuidePathOp, KitModel, MethodName, TypeName, Log, FsUtil, ApiDefOptions, ApiDefResult, Control, Model, Build, ApiModel, ApiDefContext, Warner, Metrics, };
1104
1105
  export type { CmpDesc, BasicMethodDesc, MethodDesc, MethodEntityDesc, EntityDesc, EntityPathDesc, PathDesc, OpDesc, } from './desc';
1105
- export type { OpName, ModelEntityRelations, ModelOpMap, ModelFieldOp, ModelField, ModelArg, ModelTarget, ModelOp, ModelEntity, } from './model';
1106
+ export type { OpName, ModelEntityRelations, ModelOpMap, ModelFieldOp, ModelField, ModelArg, ModelPoint, ModelOp, ModelEntity, } from './model';
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,4CAA4C;;;AAK5C,iCAAwC;AAGxC,MAAM,GAAG,GAAG,KAAK,CAAA;AAyOf,kBAAG;AAzML,MAAM,YAAY,GAAG,IAAA,aAAK,EAAC;IACzB,IAAI,EAAE;QACJ,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAI;KACf;CACF,CAAC,CAAA;AACF,MAAM,gBAAgB,GAAG,IAAA,aAAK,EAAC,IAAA,YAAI,EAAC,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;AAkMrE,4CAAgB;AA5LlB,MAAM,UAAU,GAAG,IAAA,aAAK,EAAC;IACvB,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,MAAM;IACX,IAAI,EAAE;QACJ,CAAC,GAAG,CAAC,EAAE,EAAE;QACT,GAAG,EAAE,EAAE;QACP,GAAG,EAAE;YACH,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,EAAE;SACX;KACF;CACF,CAAC,CAAA;AACF,MAAM,cAAc,GAAG,IAAA,aAAK,EAAC,IAAA,YAAI,EAAC,UAAU,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;AAiL/D,wCAAc;AA5KhB,MAAM,UAAU,GAAG,IAAA,aAAK,EAAC;IACvB,IAAI,EAAE;QACJ,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,EAAE;QACR,KAAK,EA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,OAAO,EAAE,CAAC,CAAA;AAqL/D,wCAAc;AAhLhB,MAAM,UAAU,GAAG,IAAA,aAAK,EAAC;IACvB,IAAI,EAAE;QACJ,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,EAAE;QACT,GAAG,EAAE,EAAE;QACP,GAAG,EAAE,EAAE;QACP,OAAO,EAAE,EAAE;QACX,GAAG,EAAE,EAAE;QACP,EAAE,EAAE,IAAA,WAAG,GAAE;QACT,MAAM,EAAE,KAAK;QACb,SAAS,EAAE,EAAE;QACb,KAAK,EAAE;YACL,GAAG,EAAE,IAAI;YACT,GAAG,EAAE,IAAI;YACT,GAAG,EAAE,IAAI;SACV;KACF;CACF,CAAC,CAAA;AACF,MAAM,cAAc,GAAG,IAAA,aAAK,EAAC,IAAA,YAAI,EAAC,UAAU,CAAC,CAAC,CAAA;AA8J5C,wCAAc"}
@@ -10,8 +10,11 @@ main: kit: entity: &: {
10
10
 
11
11
  name: key()
12
12
  active: *true
13
-
14
- id: {
13
+
14
+ # Present only when the spec models an id for this entity (response /
15
+ # request schema declares one, or examples imply one). Public APIs that
16
+ # return payloads without an id leave this undefined.
17
+ id?: {
15
18
  field: string
16
19
  name: string
17
20
  }
@@ -41,13 +44,46 @@ main: kit: entity: &: {
41
44
 
42
45
  parts: [ &: string ]
43
46
 
47
+ # Each arg kind (path params, query, header, cookie) has the same
48
+ # element shape. `kind` is constrained to the kind tag matching the
49
+ # array it appears in; `example` is optional and captures a spec-
50
+ # provided example value used by test generators.
44
51
  args: {
45
- params: [ &: {
52
+ params?: [ &: {
53
+ active: *true
54
+ kind: 'param'
55
+ name: string
56
+ orig?: string
57
+ reqd: boolean
58
+ type: top
59
+ example?: top
60
+ } ]
61
+ query?: [ &: {
62
+ active: *true
63
+ kind: 'query'
64
+ name: string
65
+ orig?: string
66
+ reqd: boolean
67
+ type: top
68
+ example?: top
69
+ } ]
70
+ header?: [ &: {
71
+ active: *true
72
+ kind: 'header'
73
+ name: string
74
+ orig?: string
75
+ reqd: boolean
76
+ type: top
77
+ example?: top
78
+ } ]
79
+ cookie?: [ &: {
46
80
  active: *true
47
- kind: string
81
+ kind: 'cookie'
48
82
  name: string
83
+ orig?: string
49
84
  reqd: boolean
50
85
  type: top
86
+ example?: top
51
87
  } ]
52
88
  }
53
89
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voxgig/apidef",
3
- "version": "5.10.0",
3
+ "version": "6.0.0",
4
4
  "main": "dist/apidef.js",
5
5
  "type": "commonjs",
6
6
  "types": "dist/apidef.d.ts",
@@ -40,7 +40,7 @@
40
40
  "LICENSE"
41
41
  ],
42
42
  "devDependencies": {
43
- "@types/node": "25.6.0",
43
+ "@types/node": "25.6.2",
44
44
  "typescript": "6.0.3"
45
45
  },
46
46
  "peerDependencies": {
package/src/apidef.ts CHANGED
@@ -284,8 +284,21 @@ function ApiDef(opts: ApiDefOptions) {
284
284
  warn.history.map(n => formatJSONIC(n)).join('\n\n'))
285
285
  }
286
286
 
287
+ // apidef writes model source files (entity, flow, guide jsonics) into
288
+ // .sdk/model/. Downstream actions (sdkgen, etc.) read those via
289
+ // sdk.jsonic @-includes, so voxgig-model has to re-resolve the model
290
+ // before the post-step actions run. Signal reload whenever jostraca
291
+ // wrote or merged any files; if nothing changed on disk,
292
+ // voxgig-model's resolveModel cache short-circuits the re-read.
293
+ const jfiles = jres?.files
294
+ const reload = !!jfiles && (
295
+ (jfiles.written?.length ?? 0) > 0 ||
296
+ (jfiles.merged?.length ?? 0) > 0
297
+ )
298
+
287
299
  return {
288
300
  ok: true,
301
+ reload,
289
302
  err: null,
290
303
  start,
291
304
  end: Date.now(),
@@ -398,17 +411,22 @@ export type {
398
411
 
399
412
  export type {
400
413
  OpName,
414
+ ArgKind,
415
+ NamesCluster,
401
416
  ModelEntityRelations,
402
417
  ModelOpMap,
403
418
  ModelFieldOp,
404
419
  ModelField,
405
420
  ModelArg,
406
- ModelTarget,
421
+ ModelPoint,
407
422
  ModelOp,
408
423
  ModelEntity,
409
424
  Model,
410
425
  ModelEntityFlow,
411
426
  ModelEntityFlowStep,
427
+ ModelEntityFlowStepInput,
428
+ ModelEntityFlowStepValidator,
429
+ ModelEntityFlowStepSpec,
412
430
  } from './model'
413
431
 
414
432
 
@@ -17,7 +17,7 @@ import {
17
17
  import type {
18
18
  ModelEntity,
19
19
  ModelOp,
20
- ModelTarget,
20
+ ModelPoint,
21
21
  } from '../../model'
22
22
 
23
23
  import {
@@ -196,7 +196,7 @@ function resolveBasicEntityFlow(ctx: any, entity: any) {
196
196
  }
197
197
 
198
198
 
199
- function findMainLoadPoint(op: ModelOp): ModelTarget | undefined {
199
+ function findMainLoadPoint(op: ModelOp): ModelPoint | undefined {
200
200
  let cands = op.points.filter(a => '{id}' === getelem(a.parts, -1))
201
201
  return cands[0]
202
202
  }
package/src/model.ts CHANGED
@@ -9,18 +9,41 @@ import type { MethodName } from './types'
9
9
  type OpName = 'load' | 'list' | 'create' | 'update' | 'remove' | 'patch' | 'head' | 'options'
10
10
 
11
11
 
12
- type Model = {
12
+ // Argument kinds supported on operation points.
13
+ type ArgKind = 'param' | 'query' | 'header' | 'cookie'
14
+
15
+
16
+ // jostraca's `names()` helper sticks several stylised forms of the project
17
+ // name onto an object: `name`, `Name`, `NAME`, plus snake/dash variants.
18
+ // Templates that reach for any of these expect the cluster to be present.
19
+ type NamesCluster = {
13
20
  name: string
21
+ Name: string
22
+ NAME: string
23
+ }
24
+
25
+
26
+ // Top-level unified API model produced by apidef + voxgig-model. Templates
27
+ // access the kit through `model.main.kit.<thing>`. The `info`, `config`,
28
+ // `feature`, and `target` kits remain `any` for now because their shapes are
29
+ // less stable than entity/flow — Phase 2 of the refactor types them.
30
+ type Model = NamesCluster & {
14
31
  origin?: string
32
+ def?: string
15
33
 
16
- const: {
17
- // TODO: remove
18
- Name: string
34
+ const: NamesCluster & {
35
+ year?: number
19
36
  }
20
37
 
21
38
  main: {
22
39
  kit: {
40
+ info: any
41
+ config: any
23
42
  entity: Record<string, ModelEntity>
43
+ feature: Record<string, any>
44
+ flow: Record<string, ModelEntityFlow>
45
+ target: Record<string, any>
46
+ option?: Record<string, any>
24
47
  }
25
48
  }
26
49
  }
@@ -52,18 +75,27 @@ type ModelField = {
52
75
  }
53
76
 
54
77
 
55
- // Operation argument/parameter definition
78
+ // Operation argument/parameter definition.
79
+ // `example` captures a value the spec advertises (parameter `example`,
80
+ // the first entry of `examples`, or `schema.example`/`schema.default`).
81
+ // Test generators use this for required params in live test setup so the
82
+ // generated request actually satisfies the API contract.
56
83
  type ModelArg = {
57
84
  name: string
58
85
  orig: string
59
86
  type: any // @voxgig/struct validation schema
60
- kind: 'param' | 'query' | 'header' | 'cookie'
87
+ kind: ArgKind
61
88
  reqd: boolean
89
+ example?: any
62
90
  }
63
91
 
64
92
 
65
- // Point implementation of an operation
66
- type ModelTarget = {
93
+ // One concrete HTTP endpoint that can satisfy an operation. An entity op
94
+ // (load/list/create/...) carries an array of these — apidef chooses
95
+ // between them at runtime via `select.exist` matching against reqmatch /
96
+ // reqdata. (Originally named `ModelTarget`; renamed for consistency with
97
+ // the field name `points` and the runtime utility `MakePoint`.)
98
+ type ModelPoint = {
67
99
  orig: string
68
100
  method: MethodName
69
101
  parts: string[]
@@ -93,19 +125,31 @@ type ModelTarget = {
93
125
  // Operation definition
94
126
  type ModelOp = {
95
127
  name: OpName
96
- points: ModelTarget[]
128
+ points: ModelPoint[]
97
129
  }
98
130
 
99
131
 
100
- // Entity definition - core model entity with operations and fields
132
+ // Entity definition - core model entity with operations and fields.
133
+ // `id` is present only when the OpenAPI response/request schema declares
134
+ // (or examples imply) an `id` field on the entity. Public APIs that return
135
+ // payloads without an id (e.g. read-only feeds) leave it undefined.
136
+ //
137
+ // `Name`, `NAME` etc. are stamped on by jostraca's `names()` helper after
138
+ // apidef hands the model to the generator. They're typed as optional here
139
+ // so apidef's transform code can construct entities without them; template
140
+ // code should reach for them through `nom(entity, 'Name')` rather than
141
+ // direct property access, which both works pre-`names()` and lets us
142
+ // remove the optional later.
101
143
  type ModelEntity = {
102
- name: string,
103
- op: ModelOpMap,
104
- fields: ModelField[],
105
- id: {
106
- name: string,
107
- field: string,
108
- },
144
+ name: string
145
+ Name?: string
146
+ NAME?: string
147
+ op: ModelOpMap
148
+ fields: ModelField[]
149
+ id?: {
150
+ name: string
151
+ field: string
152
+ }
109
153
  relations: ModelEntityRelations
110
154
  }
111
155
 
@@ -116,36 +160,69 @@ type ModelEntityFlow = {
116
160
  kind: string
117
161
  // args: Record<string, string>
118
162
  step: ModelEntityFlowStep[]
163
+ active?: boolean
164
+ }
165
+
166
+
167
+ // Per-step input cluster. Test-generators name the variables they emit by
168
+ // reading these slots, falling back to derived defaults. All fields are
169
+ // optional — `newFlowStep` in transform/flowstep.ts guarantees the input
170
+ // object itself exists, so consumers don't need to null-check `step.input`.
171
+ type ModelEntityFlowStepInput = {
172
+ ref?: string
173
+ entvar?: string
174
+ matchvar?: string
175
+ datavar?: string
176
+ listvar?: string
177
+ resdatavar?: string
178
+ markdefvar?: string
179
+ srcdatavar?: string
180
+ suffix?: string
181
+ textfield?: string
182
+ id?: any
183
+ [extra: string]: any
184
+ }
185
+
186
+
187
+ // Validators and specs are user-supplied callables identified by the
188
+ // `apply` discriminator; `def` is the validator-specific options bag.
189
+ type ModelEntityFlowStepValidator = {
190
+ apply: string
191
+ def: Record<string, any>
192
+ }
193
+
194
+ type ModelEntityFlowStepSpec = {
195
+ apply: string
196
+ def: Record<string, any>
119
197
  }
120
198
 
121
199
 
122
200
  type ModelEntityFlowStep = {
123
201
  op: OpName
124
- input: Record<string, any>
202
+ input: ModelEntityFlowStepInput
125
203
  match: Record<string, any>
126
204
  data: Record<string, any>
127
- spec: {
128
- apply: string
129
- def: Record<string, any>
130
- }[]
131
- valid: {
132
- apply: string
133
- def: Record<string, any>
134
- }[]
205
+ spec: ModelEntityFlowStepSpec[]
206
+ valid: ModelEntityFlowStepValidator[]
135
207
  }
136
208
 
137
209
 
138
210
  export type {
139
211
  OpName,
212
+ ArgKind,
213
+ NamesCluster,
140
214
  Model,
141
215
  ModelEntityRelations,
142
216
  ModelOpMap,
143
217
  ModelFieldOp,
144
218
  ModelField,
145
219
  ModelArg,
146
- ModelTarget,
220
+ ModelPoint,
147
221
  ModelOp,
148
222
  ModelEntity,
149
223
  ModelEntityFlow,
150
224
  ModelEntityFlowStep,
225
+ ModelEntityFlowStepInput,
226
+ ModelEntityFlowStepValidator,
227
+ ModelEntityFlowStepSpec,
151
228
  }
@@ -21,7 +21,7 @@ import type {
21
21
  OpName,
22
22
  ModelOp,
23
23
  ModelEntity,
24
- ModelTarget,
24
+ ModelPoint,
25
25
  ModelArg,
26
26
  } from '../model'
27
27
 
@@ -38,16 +38,16 @@ const argsTransform: Transform = async function(
38
38
 
39
39
  each(kit.entity, (ment: ModelEntity, entname: string) => {
40
40
  each(ment.op, (mop: ModelOp, opname: OpName) => {
41
- each(mop.points, (mtarget: ModelTarget) => {
41
+ each(mop.points, (mpoint: ModelPoint) => {
42
42
  const argdefs: ParameterDef[] = []
43
43
 
44
- const pathdef: PathDef = def.paths[mtarget.orig]
44
+ const pathdef: PathDef = def.paths[mpoint.orig]
45
45
  argdefs.push(...(pathdef.parameters ?? []))
46
46
 
47
- const opdef: MethodDef = (pathdef as any)[mtarget.method.toLowerCase()]
47
+ const opdef: MethodDef = (pathdef as any)[mpoint.method.toLowerCase()]
48
48
  argdefs.push(...(opdef?.parameters ?? []))
49
49
 
50
- resolveArgs(ment, mop, mtarget, argdefs)
50
+ resolveArgs(ment, mop, mpoint, argdefs)
51
51
  })
52
52
 
53
53
  })
@@ -67,7 +67,7 @@ const ARG_KIND: Record<string, ModelArg["kind"]> = {
67
67
  }
68
68
 
69
69
 
70
- function resolveArgs(ment: ModelEntity, mop: ModelOp, mtarget: ModelTarget, argdefs: ParameterDef[]) {
70
+ function resolveArgs(ment: ModelEntity, mop: ModelOp, mpoint: ModelPoint, argdefs: ParameterDef[]) {
71
71
  const touchedKeys = new Set<string>()
72
72
 
73
73
  each(argdefs, (argdef: ParameterDef) => {
@@ -79,7 +79,7 @@ function resolveArgs(ment: ModelEntity, mop: ModelOp, mtarget: ModelTarget, argd
79
79
  // Rename map can be keyed by either the spec original (camelCase) or by
80
80
  // the snakified form depending on which path went through heuristic01.
81
81
  // Try both before falling through to `orig`.
82
- const renameMap = mtarget.rename[kind]
82
+ const renameMap = mpoint.rename[kind]
83
83
  const name = renameMap?.[specName] ?? renameMap?.[orig] ?? orig
84
84
  const marg: ModelArg = {
85
85
  name,
@@ -89,12 +89,17 @@ function resolveArgs(ment: ModelEntity, mop: ModelOp, mtarget: ModelTarget, argd
89
89
  reqd: !!argdef.required
90
90
  }
91
91
 
92
+ const example = resolveArgExample(argdef)
93
+ if (undefined !== example) {
94
+ marg.example = example
95
+ }
96
+
92
97
  if (argdef.nullable) {
93
98
  marg.type = ['`$ONE`', '`$NULL`', marg.type]
94
99
  }
95
100
 
96
- const argsKey = (marg.kind === 'param' ? 'params' : marg.kind) as keyof typeof mtarget.args
97
- let kindargs = (mtarget.args[argsKey] = mtarget.args[argsKey] ?? [])
101
+ const argsKey = (marg.kind === 'param' ? 'params' : marg.kind) as keyof typeof mpoint.args
102
+ let kindargs = (mpoint.args[argsKey] = mpoint.args[argsKey] ?? [])
98
103
  kindargs.push(marg)
99
104
  touchedKeys.add(argsKey)
100
105
  })
@@ -102,11 +107,39 @@ function resolveArgs(ment: ModelEntity, mop: ModelOp, mtarget: ModelTarget, argd
102
107
  // Sort once after all args are collected
103
108
  const cmp = (a: ModelArg, b: ModelArg) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0
104
109
  for (const key of touchedKeys) {
105
- mtarget.args[key as keyof typeof mtarget.args]?.sort(cmp)
110
+ mpoint.args[key as keyof typeof mpoint.args]?.sort(cmp)
106
111
  }
107
112
  }
108
113
 
109
114
 
115
+ // OpenAPI lets specs advertise example values four ways:
116
+ // parameter.example (single value, OAS 3.0+)
117
+ // parameter.examples (named-example object, take first .value)
118
+ // parameter.schema.example (single value on the schema)
119
+ // parameter.schema.default (default value)
120
+ // Pick the first one we find so test generators can produce valid live
121
+ // requests even when the parameter is required and has no other source.
122
+ function resolveArgExample(argdef: any): any {
123
+ if (undefined !== argdef?.example) return argdef.example
124
+
125
+ const examples = argdef?.examples
126
+ if (examples && 'object' === typeof examples) {
127
+ for (const v of Object.values(examples)) {
128
+ if (v && 'object' === typeof v && undefined !== (v as any).value) {
129
+ return (v as any).value
130
+ }
131
+ }
132
+ }
133
+
134
+ const schema = argdef?.schema
135
+ if (schema) {
136
+ if (undefined !== schema.example) return schema.example
137
+ if (undefined !== schema.default) return schema.default
138
+ }
139
+
140
+ return undefined
141
+ }
142
+
110
143
 
111
144
  export {
112
145
  argsTransform,