@skmtc/core 0.45.0 → 0.47.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 (187) hide show
  1. package/esm/anchors/attribute.js +3 -2
  2. package/esm/context/CoreContext.d.ts +1 -1
  3. package/esm/context/CoreContext.js +1 -1
  4. package/esm/context/GenerateContext.d.ts +13 -10
  5. package/esm/context/GenerateContext.js +36 -25
  6. package/esm/context/ParseContext.d.ts +3 -0
  7. package/esm/context/ParseContext.js +151 -39
  8. package/esm/context/generateTypes.d.ts +7 -6
  9. package/esm/dsl/GeneratorKeys.d.ts +21 -15
  10. package/esm/dsl/GeneratorKeys.js +16 -11
  11. package/esm/dsl/Inserted.d.ts +1 -1
  12. package/esm/dsl/Inserted.js +1 -1
  13. package/esm/dsl/model/ModelDriver.d.ts +6 -5
  14. package/esm/dsl/model/ModelDriver.js +22 -20
  15. package/esm/dsl/model/toModelEntry.d.ts +18 -18
  16. package/esm/dsl/model/toModelEntry.js +9 -9
  17. package/esm/dsl/model/toModelProjectionBase.d.ts +17 -16
  18. package/esm/dsl/model/toModelProjectionBase.js +12 -8
  19. package/esm/dsl/model/types.d.ts +26 -17
  20. package/esm/dsl/operation/gql/toGqlOperationProjectionBase.d.ts +2 -2
  21. package/esm/dsl/operation/gql/toGqlOperationProjectionBase.js +2 -2
  22. package/esm/dsl/operation/oas/toOasOperationProjectionBase.d.ts +2 -2
  23. package/esm/dsl/operation/oas/toOasOperationProjectionBase.js +2 -2
  24. package/esm/dsl/webhook/toWebhookProjectionBase.d.ts +2 -2
  25. package/esm/dsl/webhook/toWebhookProjectionBase.js +2 -2
  26. package/esm/helpers/collateExamples.js +35 -17
  27. package/esm/helpers/refFns.d.ts +108 -43
  28. package/esm/helpers/refFns.js +166 -57
  29. package/esm/mod.d.ts +1 -0
  30. package/esm/mod.js +1 -0
  31. package/esm/oas/document/Document.d.ts +6 -0
  32. package/esm/oas/document/Document.js +44 -2
  33. package/esm/oas/intersection/Intersection.d.ts +122 -0
  34. package/esm/oas/intersection/Intersection.js +266 -0
  35. package/esm/oas/mediaType/jsonMediaType.d.ts +1 -1
  36. package/esm/oas/mediaType/jsonMediaType.js +3 -3
  37. package/esm/oas/ref/DanglingRefError.d.ts +5 -2
  38. package/esm/oas/ref/DanglingRefError.js +4 -3
  39. package/esm/oas/ref/Ref.d.ts +23 -12
  40. package/esm/oas/ref/Ref.js +68 -72
  41. package/esm/oas/requestBody/RequestBody.d.ts +1 -1
  42. package/esm/oas/requestBody/RequestBody.js +1 -1
  43. package/esm/oas/response/Response.d.ts +1 -1
  44. package/esm/oas/response/Response.js +1 -1
  45. package/esm/oas/schema/Schema.d.ts +4 -2
  46. package/esm/oas/schema/siblings.d.ts +10 -2
  47. package/esm/oas/schema/siblings.js +87 -22
  48. package/esm/oas/schemaPath/traverseSchema.d.ts +2 -0
  49. package/esm/oas/schemaPath/traverseSchema.js +51 -5
  50. package/esm/parse/allOfSystem.d.ts +3 -0
  51. package/esm/parse/allOfSystem.js +2 -1
  52. package/esm/parse/keptIntersection.d.ts +53 -0
  53. package/esm/parse/keptIntersection.js +155 -0
  54. package/esm/parse/keptRefs.d.ts +23 -0
  55. package/esm/parse/keptRefs.js +59 -0
  56. package/esm/parse/toCyclicRefs.d.ts +8 -0
  57. package/esm/parse/toCyclicRefs.js +126 -0
  58. package/esm/parse/toDeclaredTypes.d.ts +20 -0
  59. package/esm/parse/toDeclaredTypes.js +43 -0
  60. package/esm/parse/v3-0/_merge-all-of/merge-intersection.js +8 -4
  61. package/esm/parse/v3-0/_merge-all-of/merge-union.js +7 -1
  62. package/esm/parse/v3-0/_merge-all-of/merge.js +13 -0
  63. package/esm/parse/v3-0/_merge-all-of/types.d.ts +3 -0
  64. package/esm/parse/v3-0/intersection/toIntersection.d.ts +12 -0
  65. package/esm/parse/v3-0/intersection/toIntersection.js +61 -0
  66. package/esm/parse/v3-0/ref/toRefTargetV3.d.ts +23 -0
  67. package/esm/parse/v3-0/ref/toRefTargetV3.js +70 -0
  68. package/esm/parse/v3-0/schema/toSchemasV3.js +13 -1
  69. package/esm/parse/v3-1/_merge-all-of/merge-intersection.js +8 -4
  70. package/esm/parse/v3-1/_merge-all-of/merge-union.js +7 -1
  71. package/esm/parse/v3-1/_merge-all-of/merge.js +13 -0
  72. package/esm/parse/v3-1/_merge-all-of/types.d.ts +3 -0
  73. package/esm/parse/v3-1/intersection/toIntersection.d.ts +12 -0
  74. package/esm/parse/v3-1/intersection/toIntersection.js +61 -0
  75. package/esm/parse/v3-1/ref/toRefTargetV3.d.ts +23 -0
  76. package/esm/parse/v3-1/ref/toRefTargetV3.js +70 -0
  77. package/esm/parse/v3-1/schema/toSchemasV3.js +15 -2
  78. package/esm/parse/v3-2/_merge-all-of/merge-intersection.js +8 -4
  79. package/esm/parse/v3-2/_merge-all-of/merge-union.js +7 -1
  80. package/esm/parse/v3-2/_merge-all-of/merge.js +13 -0
  81. package/esm/parse/v3-2/_merge-all-of/types.d.ts +3 -0
  82. package/esm/parse/v3-2/intersection/toIntersection.d.ts +12 -0
  83. package/esm/parse/v3-2/intersection/toIntersection.js +61 -0
  84. package/esm/parse/v3-2/ref/toRefTargetV3.d.ts +23 -0
  85. package/esm/parse/v3-2/ref/toRefTargetV3.js +70 -0
  86. package/esm/parse/v3-2/schema/toSchemasV3.js +15 -2
  87. package/esm/types/GeneratorType.d.ts +1 -1
  88. package/esm/types/ProjectionOptions.d.ts +1 -1
  89. package/esm/types/ProjectionOptions.js +1 -1
  90. package/esm/types/RefName.d.ts +3 -3
  91. package/esm/types/Settings.d.ts +9 -0
  92. package/esm/types/Settings.js +2 -1
  93. package/esm/types/TypeSystem.d.ts +20 -5
  94. package/package.json +1 -1
  95. package/script/anchors/attribute.js +3 -2
  96. package/script/context/CoreContext.d.ts +1 -1
  97. package/script/context/CoreContext.js +1 -1
  98. package/script/context/GenerateContext.d.ts +13 -10
  99. package/script/context/GenerateContext.js +36 -25
  100. package/script/context/ParseContext.d.ts +3 -0
  101. package/script/context/ParseContext.js +150 -38
  102. package/script/context/generateTypes.d.ts +7 -6
  103. package/script/dsl/GeneratorKeys.d.ts +21 -15
  104. package/script/dsl/GeneratorKeys.js +16 -11
  105. package/script/dsl/Inserted.d.ts +1 -1
  106. package/script/dsl/Inserted.js +1 -1
  107. package/script/dsl/model/ModelDriver.d.ts +6 -5
  108. package/script/dsl/model/ModelDriver.js +22 -20
  109. package/script/dsl/model/toModelEntry.d.ts +18 -18
  110. package/script/dsl/model/toModelEntry.js +9 -9
  111. package/script/dsl/model/toModelProjectionBase.d.ts +17 -16
  112. package/script/dsl/model/toModelProjectionBase.js +12 -8
  113. package/script/dsl/model/types.d.ts +26 -17
  114. package/script/dsl/operation/gql/toGqlOperationProjectionBase.d.ts +2 -2
  115. package/script/dsl/operation/gql/toGqlOperationProjectionBase.js +2 -2
  116. package/script/dsl/operation/oas/toOasOperationProjectionBase.d.ts +2 -2
  117. package/script/dsl/operation/oas/toOasOperationProjectionBase.js +2 -2
  118. package/script/dsl/webhook/toWebhookProjectionBase.d.ts +2 -2
  119. package/script/dsl/webhook/toWebhookProjectionBase.js +2 -2
  120. package/script/helpers/collateExamples.js +35 -17
  121. package/script/helpers/refFns.d.ts +108 -43
  122. package/script/helpers/refFns.js +180 -59
  123. package/script/mod.d.ts +1 -0
  124. package/script/mod.js +1 -0
  125. package/script/oas/document/Document.d.ts +6 -0
  126. package/script/oas/document/Document.js +44 -2
  127. package/script/oas/intersection/Intersection.d.ts +122 -0
  128. package/script/oas/intersection/Intersection.js +270 -0
  129. package/script/oas/mediaType/jsonMediaType.d.ts +1 -1
  130. package/script/oas/mediaType/jsonMediaType.js +3 -3
  131. package/script/oas/ref/DanglingRefError.d.ts +5 -2
  132. package/script/oas/ref/DanglingRefError.js +4 -3
  133. package/script/oas/ref/Ref.d.ts +23 -12
  134. package/script/oas/ref/Ref.js +67 -71
  135. package/script/oas/requestBody/RequestBody.d.ts +1 -1
  136. package/script/oas/requestBody/RequestBody.js +1 -1
  137. package/script/oas/response/Response.d.ts +1 -1
  138. package/script/oas/response/Response.js +1 -1
  139. package/script/oas/schema/Schema.d.ts +4 -2
  140. package/script/oas/schema/siblings.d.ts +10 -2
  141. package/script/oas/schema/siblings.js +89 -23
  142. package/script/oas/schemaPath/traverseSchema.d.ts +2 -0
  143. package/script/oas/schemaPath/traverseSchema.js +50 -4
  144. package/script/parse/allOfSystem.d.ts +3 -0
  145. package/script/parse/allOfSystem.js +2 -1
  146. package/script/parse/keptIntersection.d.ts +53 -0
  147. package/script/parse/keptIntersection.js +164 -0
  148. package/script/parse/keptRefs.d.ts +23 -0
  149. package/script/parse/keptRefs.js +63 -0
  150. package/script/parse/toCyclicRefs.d.ts +8 -0
  151. package/script/parse/toCyclicRefs.js +130 -0
  152. package/script/parse/toDeclaredTypes.d.ts +20 -0
  153. package/script/parse/toDeclaredTypes.js +48 -0
  154. package/script/parse/v3-0/_merge-all-of/merge-intersection.js +8 -4
  155. package/script/parse/v3-0/_merge-all-of/merge-union.js +7 -1
  156. package/script/parse/v3-0/_merge-all-of/merge.js +13 -0
  157. package/script/parse/v3-0/_merge-all-of/types.d.ts +3 -0
  158. package/script/parse/v3-0/intersection/toIntersection.d.ts +12 -0
  159. package/script/parse/v3-0/intersection/toIntersection.js +65 -0
  160. package/script/parse/v3-0/ref/toRefTargetV3.d.ts +23 -0
  161. package/script/parse/v3-0/ref/toRefTargetV3.js +74 -0
  162. package/script/parse/v3-0/schema/toSchemasV3.js +13 -1
  163. package/script/parse/v3-1/_merge-all-of/merge-intersection.js +8 -4
  164. package/script/parse/v3-1/_merge-all-of/merge-union.js +7 -1
  165. package/script/parse/v3-1/_merge-all-of/merge.js +13 -0
  166. package/script/parse/v3-1/_merge-all-of/types.d.ts +3 -0
  167. package/script/parse/v3-1/intersection/toIntersection.d.ts +12 -0
  168. package/script/parse/v3-1/intersection/toIntersection.js +65 -0
  169. package/script/parse/v3-1/ref/toRefTargetV3.d.ts +23 -0
  170. package/script/parse/v3-1/ref/toRefTargetV3.js +74 -0
  171. package/script/parse/v3-1/schema/toSchemasV3.js +15 -2
  172. package/script/parse/v3-2/_merge-all-of/merge-intersection.js +8 -4
  173. package/script/parse/v3-2/_merge-all-of/merge-union.js +7 -1
  174. package/script/parse/v3-2/_merge-all-of/merge.js +13 -0
  175. package/script/parse/v3-2/_merge-all-of/types.d.ts +3 -0
  176. package/script/parse/v3-2/intersection/toIntersection.d.ts +12 -0
  177. package/script/parse/v3-2/intersection/toIntersection.js +65 -0
  178. package/script/parse/v3-2/ref/toRefTargetV3.d.ts +23 -0
  179. package/script/parse/v3-2/ref/toRefTargetV3.js +74 -0
  180. package/script/parse/v3-2/schema/toSchemasV3.js +15 -2
  181. package/script/types/GeneratorType.d.ts +1 -1
  182. package/script/types/ProjectionOptions.d.ts +1 -1
  183. package/script/types/ProjectionOptions.js +1 -1
  184. package/script/types/RefName.d.ts +3 -3
  185. package/script/types/Settings.d.ts +9 -0
  186. package/script/types/Settings.js +2 -1
  187. package/script/types/TypeSystem.d.ts +20 -5
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
2
7
  var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
8
  if (kind === "m") throw new TypeError("Private method is not writable");
4
9
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
11
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
12
  };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _ParseContext_instances, _ParseContext_refConsumers, _ParseContext_refErrors, _ParseContext_oasRefs, _ParseContext_rootFrames, _ParseContext_removeComponent, _ParseContext_removeConsumer, _ParseContext_removePathParameterConsumer, _ParseContext_toRawComponentParameter, _ParseContext_logDependencyIssue, _ParseContext_toDocumentTrail, _ParseContext_checkRefs, _ParseContext_toRefError, _ParseContext_toLoopOf, _ParseContext_removeHolder;
13
+ var _ParseContext_instances, _ParseContext_refConsumers, _ParseContext_refErrors, _ParseContext_oasRefs, _ParseContext_refTargets, _ParseContext_refTarget, _ParseContext_keptRefs, _ParseContext_issueIdentities, _ParseContext_rootFrames, _ParseContext_removeComponent, _ParseContext_parseRefTargets, _ParseContext_inRefTarget, _ParseContext_addIssue, _ParseContext_removeConsumer, _ParseContext_removePathParameterConsumer, _ParseContext_logDependencyIssue, _ParseContext_toDocumentTrail, _ParseContext_checkRefs, _ParseContext_toRefError, _ParseContext_toLoopOf, _ParseContext_removeHolder;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.ParseContext = void 0;
16
16
  /**
@@ -42,22 +42,55 @@ const GqlDocument_js_1 = require("../gql/document/GqlDocument.js");
42
42
  const parseGqlDocument_js_1 = require("../gql/document/parseGqlDocument.js");
43
43
  const StackTrail_js_1 = require("./StackTrail.js");
44
44
  const isPlainObject_js_1 = require("../parse/isPlainObject.js");
45
+ const keptRefs_js_1 = require("../parse/keptRefs.js");
45
46
  const pathParameters_js_1 = require("../parse/pathParameters.js");
46
47
  const SerializedError_js_1 = require("../types/SerializedError.js");
48
+ const tryParseAt_js_1 = require("./tryParseAt.js");
47
49
  const DanglingRefError_js_1 = require("../oas/ref/DanglingRefError.js");
48
50
  const refFns_js_1 = require("../helpers/refFns.js");
51
+ const toRefTargetV3_js_1 = require("../parse/v3-0/ref/toRefTargetV3.js");
52
+ const toRefTargetV3_js_2 = require("../parse/v3-1/ref/toRefTargetV3.js");
53
+ const toRefTargetV3_js_3 = require("../parse/v3-2/ref/toRefTargetV3.js");
49
54
  /**
50
- * The key a `$ref`'s consumers and errors are kept under. A
51
- * `#/components/<bucket>/…` ref is keyed by the name it resolves (`toRefName`
52
- * unescapes it), which is the key `StackTrail.toStackRef()` gives that
55
+ * The key a `$ref`'s consumers and errors are kept under. A component ref
56
+ * (`#/components/<bucket>/<name>`) is keyed by the name it resolves,
57
+ * unescaped, which is the key `StackTrail.toStackRef()` gives that
53
58
  * component's own errors: `#/components/schemas/Foo%20Bar` is kept under
54
- * `#/components/schemas/Foo Bar`. Any other `$ref` is its own key.
59
+ * `#/components/schemas/Foo Bar`. Any other ref is keyed by its whole
60
+ * pointer in one spelling (`toRefPointer`), which is also the key its
61
+ * parsed target is kept under.
55
62
  */
56
- const toRefKey = ($ref) => {
57
- // The last segment is not empty, so `toRefName` does not throw.
58
- const bucket = /^#\/components\/([^/]+)\/.*[^/]$/.exec($ref)?.[1];
59
- return bucket === undefined ? $ref : `#/components/${bucket}/${(0, refFns_js_1.toRefName)($ref)}`;
63
+ const toRefKey = ({ refName, refPath }) => {
64
+ const bucket = (0, refFns_js_1.toRefPathBucket)(refPath);
65
+ return bucket === undefined ? (0, refFns_js_1.toRefPointer)({ refName, refPath }) : `#/components/${bucket}/${refName}`;
60
66
  };
67
+ /** The issue logged when a ref target's parser throws. */
68
+ const toInvalidType = (refType) => {
69
+ switch (refType) {
70
+ case 'schema':
71
+ return 'INVALID_SCHEMA';
72
+ case 'requestBody':
73
+ return 'INVALID_REQUEST_BODY';
74
+ case 'parameter':
75
+ return 'INVALID_PARAMETER';
76
+ case 'response':
77
+ case 'link':
78
+ // A link has no type of its own: in the document's walk its response reports it.
79
+ return 'INVALID_RESPONSE';
80
+ case 'example':
81
+ return 'INVALID_EXAMPLE';
82
+ case 'header':
83
+ return 'INVALID_HEADER';
84
+ case 'securityScheme':
85
+ return 'INVALID_SECURITY_SCHEME';
86
+ default: {
87
+ const _exhaustive = refType;
88
+ throw new Error(`Unhandled ref type: ${_exhaustive}`);
89
+ }
90
+ }
91
+ };
92
+ /** Two issues with the same level, type, location and message are the same issue. */
93
+ const toIssueIdentity = (issue) => [issue.level, issue.type, issue.location, issue.message].join('\u0000');
61
94
  /** The stored form of an issue: an error's `cause` as a `SerializedError`. */
62
95
  const toParseIssue = (issue) => {
63
96
  if (issue.level !== 'error') {
@@ -134,6 +167,18 @@ class ParseContext {
134
167
  );
135
168
  /** Each OAS ref and the place it is written, which `#checkRefs` resolves once the document is parsed. */
136
169
  _ParseContext_oasRefs.set(this, []
170
+ /** The key (`toRefKey`) of each ref target `#parseRefTargets` parsed. */
171
+ );
172
+ /** The key (`toRefKey`) of each ref target `#parseRefTargets` parsed. */
173
+ _ParseContext_refTargets.set(this, new Set()
174
+ /** The key of the ref target `#inRefTarget` runs for; `undefined` in the document's own walk. */
175
+ );
176
+ /** The key of the ref target `#inRefTarget` runs for; `undefined` in the document's own walk. */
177
+ _ParseContext_refTarget.set(this, void 0);
178
+ /** {@link keptRefs}, once a merge has asked for it. */
179
+ _ParseContext_keptRefs.set(this, void 0);
180
+ /** What identifies each issue logged so far (`toIssueIdentity`). */
181
+ _ParseContext_issueIdentities.set(this, new Set()
137
182
  /**
138
183
  * Frames of the trail `parse()` was called with (`[traceId, spanId,
139
184
  * 'parse']` through `toArtifacts`). Every trail built during the walk
@@ -197,6 +242,13 @@ class ParseContext {
197
242
  }
198
243
  return this.protocol.documentObject;
199
244
  }
245
+ /** The refs of the document that a merge keeps as refs (`system.intersections`); `undefined` under `merge`. */
246
+ get keptRefs() {
247
+ __classPrivateFieldSet(this, _ParseContext_keptRefs, __classPrivateFieldGet(this, _ParseContext_keptRefs, "f") ?? {
248
+ value: (0, keptRefs_js_1.toKeptRefs)({ documentObject: this.documentObject, setting: this.system.intersections })
249
+ }, "f");
250
+ return __classPrivateFieldGet(this, _ParseContext_keptRefs, "f").value;
251
+ }
200
252
  /** GQL-only accessor; throws if called on an OAS context. */
201
253
  get schema() {
202
254
  if (this.protocol.type !== 'gql') {
@@ -263,6 +315,7 @@ class ParseContext {
263
315
  stackTrail,
264
316
  context: this
265
317
  });
318
+ __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_parseRefTargets).call(this, toRefTargetV3_js_1.toRefTargetV3);
266
319
  break;
267
320
  case '3.1':
268
321
  oasState.oasDocument.fields = (0, toDocumentFieldsV3_js_2.toDocumentFieldsV3)({
@@ -270,6 +323,7 @@ class ParseContext {
270
323
  stackTrail,
271
324
  context: this
272
325
  });
326
+ __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_parseRefTargets).call(this, toRefTargetV3_js_2.toRefTargetV3);
273
327
  break;
274
328
  case '3.2':
275
329
  oasState.oasDocument.fields = (0, toDocumentFieldsV3_js_3.toDocumentFieldsV3)({
@@ -277,6 +331,7 @@ class ParseContext {
277
331
  stackTrail,
278
332
  context: this
279
333
  });
334
+ __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_parseRefTargets).call(this, toRefTargetV3_js_3.toRefTargetV3);
280
335
  break;
281
336
  default: {
282
337
  const _exhaustive = dialect;
@@ -330,7 +385,15 @@ class ParseContext {
330
385
  pending.forEach(({ refKey }) => __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_removeComponent).call(this, refKey));
331
386
  // `pending` grows while it is walked: each removed component queues its own consumers.
332
387
  for (const { refKey, rootCause } of pending) {
333
- for (const consumer of __classPrivateFieldGet(this, _ParseContext_refConsumers, "f").get(refKey) ?? []) {
388
+ for (const { consumer, refTarget } of __classPrivateFieldGet(this, _ParseContext_refConsumers, "f").get(refKey) ?? []) {
389
+ // The ref is inside a ref target: the target is removed, and what refers to it next.
390
+ if (refTarget !== undefined) {
391
+ if (this.oasDocument.removeRefTarget(refTarget) !== undefined) {
392
+ __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_inRefTarget).call(this, refTarget, () => __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_logDependencyIssue).call(this, { location: consumer.toString(), refKey, rootCause }));
393
+ pending.push({ refKey: refTarget, rootCause });
394
+ }
395
+ continue;
396
+ }
334
397
  const documentTrail = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toDocumentTrail).call(this, consumer);
335
398
  const removedLocations = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_removeConsumer).call(this, consumer, documentTrail);
336
399
  removedLocations.forEach(location => __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_logDependencyIssue).call(this, { location, refKey, rootCause }));
@@ -375,12 +438,13 @@ class ParseContext {
375
438
  * would use type names or qualified field paths.
376
439
  */
377
440
  registerRef(consumer, refKey) {
441
+ const refConsumer = { consumer, refTarget: __classPrivateFieldGet(this, _ParseContext_refTarget, "f") };
378
442
  const existing = __classPrivateFieldGet(this, _ParseContext_refConsumers, "f").get(refKey);
379
443
  if (existing) {
380
- existing.push(consumer);
444
+ existing.push(refConsumer);
381
445
  }
382
446
  else {
383
- __classPrivateFieldGet(this, _ParseContext_refConsumers, "f").set(refKey, [consumer]);
447
+ __classPrivateFieldGet(this, _ParseContext_refConsumers, "f").set(refKey, [refConsumer]);
384
448
  }
385
449
  }
386
450
  /**
@@ -390,8 +454,8 @@ class ParseContext {
390
454
  * resolve it there.
391
455
  */
392
456
  registerOasRef(consumer, ref) {
393
- this.registerRef(consumer, toRefKey(ref.$ref));
394
- __classPrivateFieldGet(this, _ParseContext_oasRefs, "f").push({ consumer, ref });
457
+ this.registerRef(consumer, toRefKey(ref));
458
+ __classPrivateFieldGet(this, _ParseContext_oasRefs, "f").push({ consumer, ref, refTarget: __classPrivateFieldGet(this, _ParseContext_refTarget, "f") });
395
459
  }
396
460
  /**
397
461
  * What a merge reads in place of a `$ref` that names nothing: an `allOf`
@@ -451,8 +515,8 @@ class ParseContext {
451
515
  * manifest).
452
516
  */
453
517
  logIssueAt(issue, parent) {
454
- this.issues.push(toParseIssue(issue));
455
- if (!this.silent) {
518
+ const added = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_addIssue).call(this, toParseIssue(issue));
519
+ if (added && !this.silent) {
456
520
  this.logger.warn({
457
521
  protocol: issue.protocol,
458
522
  level: issue.level,
@@ -486,7 +550,7 @@ class ParseContext {
486
550
  // points at. No-op for non-component trails (and for GQL
487
551
  // trails) because `toStackRef` returns `undefined` and
488
552
  // `registerRefError` ignores undefined refs.
489
- this.registerRefError(issue.cause ?? issue.message, __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toDocumentTrail).call(this, stackTrail).toStackRef(), location);
553
+ this.registerRefError(issue.cause ?? issue.message, __classPrivateFieldGet(this, _ParseContext_refTarget, "f") ?? __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toDocumentTrail).call(this, stackTrail).toStackRef(), location);
490
554
  this.logIssueAt({
491
555
  protocol,
492
556
  level: 'error',
@@ -569,14 +633,65 @@ class ParseContext {
569
633
  }
570
634
  }
571
635
  exports.ParseContext = ParseContext;
572
- _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMap(), _ParseContext_oasRefs = new WeakMap(), _ParseContext_rootFrames = new WeakMap(), _ParseContext_instances = new WeakSet(), _ParseContext_removeComponent = function _ParseContext_removeComponent(refKey) {
636
+ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMap(), _ParseContext_oasRefs = new WeakMap(), _ParseContext_refTargets = new WeakMap(), _ParseContext_refTarget = new WeakMap(), _ParseContext_keptRefs = new WeakMap(), _ParseContext_issueIdentities = new WeakMap(), _ParseContext_rootFrames = new WeakMap(), _ParseContext_instances = new WeakSet(), _ParseContext_removeComponent = function _ParseContext_removeComponent(refKey) {
573
637
  if (this.protocol.type !== 'oas') {
574
638
  return;
575
639
  }
640
+ if (__classPrivateFieldGet(this, _ParseContext_refTargets, "f").has(refKey)) {
641
+ this.protocol.oasDocument.removeRefTarget(refKey);
642
+ return;
643
+ }
576
644
  const match = /^#\/components\/([^/]+)\/(.+)$/.exec(refKey);
577
645
  if (match) {
578
646
  this.protocol.oasDocument.removeItem(new StackTrail_js_1.StackTrail(['components', match[1], match[2]]));
579
647
  }
648
+ }, _ParseContext_parseRefTargets = function _ParseContext_parseRefTargets(toRefTarget) {
649
+ if (this.protocol.type !== 'oas') {
650
+ return;
651
+ }
652
+ const { oasDocument, documentObject } = this.protocol;
653
+ for (const { ref } of __classPrivateFieldGet(this, _ParseContext_oasRefs, "f")) {
654
+ const key = toRefKey(ref);
655
+ // A ref to a component, of its own kind or not, is resolved in
656
+ // `components`; `#checkRefs` reports one of the wrong kind.
657
+ if (ref.refName === '' || (0, refFns_js_1.toRefPathBucket)(ref.refPath) !== undefined || __classPrivateFieldGet(this, _ParseContext_refTargets, "f").has(key)) {
658
+ continue;
659
+ }
660
+ const value = (0, refFns_js_1.toRawRefTarget)(documentObject, ref);
661
+ if (!(0, isPlainObject_js_1.isPlainObject)(value)) {
662
+ continue;
663
+ }
664
+ __classPrivateFieldGet(this, _ParseContext_refTargets, "f").add(key);
665
+ const parent = new StackTrail_js_1.StackTrail([...__classPrivateFieldGet(this, _ParseContext_rootFrames, "f"), ...(0, refFns_js_1.toRefPathSegments)(ref.refPath)]);
666
+ const target = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_inRefTarget).call(this, key, () => (0, tryParseAt_js_1.tryParseAt)({
667
+ stackTrail: parent,
668
+ key: ref.refName,
669
+ context: this,
670
+ type: toInvalidType(ref.refType),
671
+ parent: value,
672
+ fn: () => toRefTarget({ refType: ref.refType, name: ref.refName, value, stackTrail: parent, context: this })
673
+ }));
674
+ if (target !== undefined) {
675
+ oasDocument.setRefTarget(key, target);
676
+ }
677
+ }
678
+ }, _ParseContext_inRefTarget = function _ParseContext_inRefTarget(key, fn) {
679
+ const previous = __classPrivateFieldGet(this, _ParseContext_refTarget, "f");
680
+ __classPrivateFieldSet(this, _ParseContext_refTarget, key, "f");
681
+ try {
682
+ return fn();
683
+ }
684
+ finally {
685
+ __classPrivateFieldSet(this, _ParseContext_refTarget, previous, "f");
686
+ }
687
+ }, _ParseContext_addIssue = function _ParseContext_addIssue(issue) {
688
+ const identity = toIssueIdentity(issue);
689
+ if (__classPrivateFieldGet(this, _ParseContext_refTarget, "f") !== undefined && __classPrivateFieldGet(this, _ParseContext_issueIdentities, "f").has(identity)) {
690
+ return false;
691
+ }
692
+ __classPrivateFieldGet(this, _ParseContext_issueIdentities, "f").add(identity);
693
+ this.issues.push(issue);
694
+ return true;
580
695
  }, _ParseContext_removeConsumer = function _ParseContext_removeConsumer(consumer, documentTrail) {
581
696
  switch (this.protocol.type) {
582
697
  case 'oas': {
@@ -615,7 +730,9 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
615
730
  : [];
616
731
  const rawEntry = rawEntries[Number(index)];
617
732
  const entryRef = (0, isPlainObject_js_1.isPlainObject)(rawEntry) && typeof rawEntry.$ref === 'string' ? rawEntry.$ref : undefined;
618
- const nameAndIn = (0, pathParameters_js_1.toNameAndIn)(entryRef === undefined ? rawEntry : __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toRawComponentParameter).call(this, entryRef));
733
+ const nameAndIn = (0, pathParameters_js_1.toNameAndIn)(entryRef === undefined
734
+ ? rawEntry
735
+ : (0, refFns_js_1.toRawRefTarget)(documentObject, (0, refFns_js_1.toRefParts)({ $ref: entryRef })));
619
736
  const broken = [{ location: documentTrail.toString(), message: '', ...nameAndIn }];
620
737
  const operations = first === 'paths'
621
738
  ? oasDocument.operations.filter(({ path }) => path === second)
@@ -637,13 +754,6 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
637
754
  : [new StackTrail_js_1.StackTrail([...prefix, first, second, method]).toString()];
638
755
  });
639
756
  return removedLocations;
640
- }, _ParseContext_toRawComponentParameter = function _ParseContext_toRawComponentParameter($ref) {
641
- if (this.protocol.type !== 'oas') {
642
- return undefined;
643
- }
644
- const match = /^#\/components\/parameters\/(.+)$/.exec($ref);
645
- const parameters = this.protocol.documentObject.components?.parameters;
646
- return match && (0, isPlainObject_js_1.isPlainObject)(parameters) ? parameters[match[1]] : undefined;
647
757
  }, _ParseContext_logDependencyIssue = function _ParseContext_logDependencyIssue({ location, refKey, rootCause }) {
648
758
  const { error } = rootCause;
649
759
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -651,7 +761,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
651
761
  const message = `Depends on '${refKey}', removed because of the error${at}: ${errorMessage}`;
652
762
  switch (this.protocol.type) {
653
763
  case 'oas':
654
- this.issues.push({
764
+ __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_addIssue).call(this, {
655
765
  protocol: 'oas',
656
766
  level: 'error',
657
767
  type: 'INVALID_DEPENDENCY_REF',
@@ -661,7 +771,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
661
771
  });
662
772
  break;
663
773
  case 'gql':
664
- this.issues.push({
774
+ __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_addIssue).call(this, {
665
775
  protocol: 'gql',
666
776
  level: 'error',
667
777
  type: 'INVALID_DEPENDENCY_REF',
@@ -683,8 +793,8 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
683
793
  rootFrames.every((frame, index) => frames[index] === frame);
684
794
  return startsWithRoot ? new StackTrail_js_1.StackTrail(frames.slice(rootFrames.length)) : stackTrail;
685
795
  }, _ParseContext_checkRefs = function _ParseContext_checkRefs() {
686
- __classPrivateFieldGet(this, _ParseContext_oasRefs, "f").forEach(({ consumer, ref }) => {
687
- if (__classPrivateFieldGet(this, _ParseContext_refErrors, "f").has(toRefKey(ref.$ref))) {
796
+ __classPrivateFieldGet(this, _ParseContext_oasRefs, "f").forEach(({ consumer, ref, refTarget }) => __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_inRefTarget).call(this, refTarget, () => {
797
+ if (__classPrivateFieldGet(this, _ParseContext_refErrors, "f").has(toRefKey(ref))) {
688
798
  return;
689
799
  }
690
800
  const error = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toRefError).call(this, ref);
@@ -694,6 +804,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
694
804
  __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_removeHolder).call(this, {
695
805
  consumer,
696
806
  ref,
807
+ refTarget,
697
808
  error,
698
809
  type: 'REF_TYPE_MISMATCH',
699
810
  message: `${message}, so what holds it is removed.`
@@ -712,13 +823,14 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
712
823
  __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_removeHolder).call(this, {
713
824
  consumer,
714
825
  ref,
826
+ refTarget,
715
827
  error,
716
828
  type: 'DANGLING_REF',
717
829
  message: `${error.message}, so what holds it is removed. To keep it, list '${ref.refType}' in system.danglingRefs.`
718
830
  });
719
831
  }
720
832
  }
721
- });
833
+ }));
722
834
  }, _ParseContext_toRefError = function _ParseContext_toRefError(ref) {
723
835
  try {
724
836
  ref.resolveOnce();
@@ -737,7 +849,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
737
849
  // A ref further on names nothing or the wrong kind: it reports that itself.
738
850
  return undefined;
739
851
  }
740
- }, _ParseContext_removeHolder = function _ParseContext_removeHolder({ consumer, ref, error, type, message }) {
852
+ }, _ParseContext_removeHolder = function _ParseContext_removeHolder({ consumer, ref, refTarget, error, type, message }) {
741
853
  this.logIssueNoKey({
742
854
  level: 'error',
743
855
  message,
@@ -747,7 +859,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
747
859
  type
748
860
  });
749
861
  const documentTrail = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toDocumentTrail).call(this, consumer);
750
- if (documentTrail.toStackRef() !== undefined) {
862
+ if (refTarget !== undefined || documentTrail.toStackRef() !== undefined) {
751
863
  return;
752
864
  }
753
865
  const location = consumer.toString();
@@ -17,7 +17,7 @@ import type { OasRef } from '../oas/ref/Ref.js';
17
17
  import type { OasVoid } from '../oas/void/Void.js';
18
18
  import type { ModelProjection, NormalizedModelProjection } from '../dsl/model/types.js';
19
19
  import type { ContentSettings } from '../dsl/ContentSettings.js';
20
- import type { RefName } from '../types/RefName.js';
20
+ import type { RefParts } from '../helpers/refFns.js';
21
21
  import type { SchemaToNonRef, TypeSystemOutput } from '../types/TypeSystem.js';
22
22
  import type { FileBase } from '../dsl/FileBase.js';
23
23
  import type { ImportBase } from '../dsl/ImportBase.js';
@@ -170,8 +170,8 @@ export type AnyOasDocument = OpenAPIV2.Document | OpenAPIV3.Document | OpenAPIV3
170
170
  *
171
171
  * - `WILDCARD_MEDIA_TYPE` (`warning`) — the body has no JSON media type
172
172
  * (see `isJsonMediaType`) and is read from `*\/*` as JSON, since its schema
173
- * there is an object, array, union or `$ref`. The document does not say the
174
- * format; springdoc writes `*\/*` for every response.
173
+ * there is an object, array, union, intersection or `$ref`. The document
174
+ * does not say the format; springdoc writes `*\/*` for every response.
175
175
  * - `NO_JSON_MEDIA_TYPE` (`debug`) — no lookup without a media type reads the
176
176
  * body, and its keys include a range: `application/*`, or `*\/*` with a
177
177
  * scalar schema (a text body or a file). A body with only specific
@@ -341,7 +341,8 @@ export type FindDefinitionArgs = PickArgs & {
341
341
  * @template EnrichmentType - Optional enrichment type for the model
342
342
  */
343
343
  export type BuildModelSettingsArgs<V extends GeneratedValue, EnrichmentType = undefined, ProjectionOptions = undefined> = {
344
- refName: RefName;
344
+ /** The model's ref; an `OasRef` fits it. */
345
+ ref: RefParts;
345
346
  projection: ModelProjection<V, EnrichmentType, ProjectionOptions>;
346
347
  /**
347
348
  * Model variant whose enrichment / identifier / export path
@@ -475,12 +476,12 @@ export type GenerateContextType = {
475
476
  addFile: <File extends FileBase>(file: File) => File;
476
477
  insertOperation: <V extends GeneratedValue, EnrichmentType = undefined, ProjectionOptions = undefined>(args: InsertOperationArgs<V, EnrichmentType, ProjectionOptions>) => Inserted<V, EnrichmentType>;
477
478
  insertNormalizedModel: <V extends GeneratedValue, Schema extends OasSchema | OasRef<'schema'> | OasVoid, EnrichmentType, ProjectionOptions = undefined>(projection: NormalizedModelProjection<V, EnrichmentType, ProjectionOptions>, { schema, fallbackName, destinationPath }: InsertNormalizedModelArgs<Schema>, ...rest: ProjectionOptionsRest<InsertNormalizedModelOptions<ProjectionOptions>, ProjectionOptions>) => InsertNormalizedModelReturn<V, Schema>;
478
- insertModel: <V extends GeneratedValue, EnrichmentType, ProjectionOptions = undefined>(projection: ModelProjection<V, EnrichmentType, ProjectionOptions>, refName: RefName, ...rest: ProjectionOptionsRest<InsertModelOptions<ProjectionOptions>, ProjectionOptions>) => Inserted<V, EnrichmentType>;
479
+ insertModel: <V extends GeneratedValue, EnrichmentType, ProjectionOptions = undefined>(projection: ModelProjection<V, EnrichmentType, ProjectionOptions>, ref: RefParts, ...rest: ProjectionOptionsRest<InsertModelOptions<ProjectionOptions>, ProjectionOptions>) => Inserted<V, EnrichmentType>;
479
480
  toOperationContentSettings: <V extends GeneratedValue, EnrichmentType, ProjectionOptions>(args: ToOperationSettingsArgs<V, EnrichmentType, ProjectionOptions>) => ContentSettings<EnrichmentType>;
480
481
  insertWebhook: <V extends GeneratedValue, EnrichmentType = undefined, ProjectionOptions = undefined>(args: InsertWebhookArgs<V, EnrichmentType, ProjectionOptions>) => Inserted<V, EnrichmentType>;
481
482
  toWebhookContentSettings: <V extends GeneratedValue, EnrichmentType, ProjectionOptions>(args: ToWebhookSettingsArgs<V, EnrichmentType, ProjectionOptions>) => ContentSettings<EnrichmentType>;
482
483
  toModelContentSettings: <V extends GeneratedValue, EnrichmentType, ProjectionOptions>(args: BuildModelSettingsArgs<V, EnrichmentType, ProjectionOptions>) => ContentSettings<EnrichmentType>;
483
- resolveSchemaRefOnce: (refName: RefName) => OasSchema | OasRef<'schema'>;
484
+ resolveSchemaRefOnce: (ref: RefParts) => OasSchema | OasRef<'schema'>;
484
485
  /** The Definition named `name` in `exportPath` (or inside the declaration `into`), or `undefined`. */
485
486
  findDefinition: ({ name, exportPath, into }: FindDefinitionArgs) => DefinitionBase | undefined;
486
487
  /**
@@ -56,7 +56,7 @@
56
56
  *
57
57
  * const modelKey = toModelGeneratorKey({
58
58
  * generatorId: 'typescript-models',
59
- * refName: 'User' as RefName,
59
+ * ref: { refName: 'User' as RefName, refPath: '#/components/schemas' },
60
60
  * variant: 'main'
61
61
  * });
62
62
  * ```
@@ -68,8 +68,8 @@ import type { OasOperation } from '../oas/operation/Operation.js';
68
68
  import type { OasWebhook } from '../oas/webhook/Webhook.js';
69
69
  import type { GqlOperation, GqlRootKind } from '../gql/operation/GqlOperation.js';
70
70
  import type { Brand } from '../types/Brand.js';
71
- import type { RefName } from '../types/RefName.js';
72
71
  import { type Method } from '../types/Method.js';
72
+ import { type RefParts } from '../helpers/refFns.js';
73
73
  /**
74
74
  * Template literal type for OAS operation generator keys before branding.
75
75
  * Format: `generatorId|path|method|variant`
@@ -93,7 +93,8 @@ export type NakedOasOperationGeneratorKey = `${string}|${string}|${Method}|${str
93
93
  export type NakedGqlOperationGeneratorKey = `${string}|${GqlRootKind}|${string}|${string}`;
94
94
  /**
95
95
  * Template literal type for model generator keys before branding.
96
- * Format: `generatorId|refName|variant`
96
+ * Format: `generatorId|modelKey|variant`, where the model key is a component's
97
+ * `refName`, or the whole pointer of a ref into the document's content
97
98
  * (e.g., 'typescript-models|User|main',
98
99
  * 'zod-schemas|Customer|coercive').
99
100
  *
@@ -207,7 +208,7 @@ export type GeneratorOnlyKey = Brand<string, 'GeneratorOnlyKey'>;
207
208
  * // Model generator key
208
209
  * const modelKey: GeneratorKey = toModelGeneratorKey({
209
210
  * generatorId: 'typescript-types',
210
- * refName: 'User',
211
+ * ref: { refName: 'User', refPath: '#/components/schemas' },
211
212
  * variant: 'main'
212
213
  * });
213
214
  *
@@ -376,8 +377,12 @@ export declare const toGqlOperationGeneratorKey: ({ generatorId, variant, ...res
376
377
  type ToModelGeneratorKeyArgs = {
377
378
  /** Unique identifier for the generator */
378
379
  generatorId: string;
379
- /** Reference name of the schema model */
380
- refName: RefName;
380
+ /**
381
+ * The model's ref. A component's key holds its `refName`; any other
382
+ * target's key holds its whole pointer (`toModelKey`), so two targets that
383
+ * share a `refName` get two keys.
384
+ */
385
+ ref: RefParts;
381
386
  /** Model variant name — omitted means `'main'` */
382
387
  variant?: string;
383
388
  };
@@ -387,7 +392,8 @@ type ToModelGeneratorKeyArgs = {
387
392
  *
388
393
  * Model generator keys uniquely identify generators processing specific
389
394
  * OpenAPI schema models for a given variant. The key format is:
390
- * `generatorId|refName|variant`.
395
+ * `generatorId|modelKey|variant`: a component's `refName`, or the whole
396
+ * pointer of any other target, with `%` and `|` escaped.
391
397
  *
392
398
  * @param args - Model generator key arguments
393
399
  * @returns A branded ModelGeneratorKey
@@ -396,20 +402,20 @@ type ToModelGeneratorKeyArgs = {
396
402
  * ```typescript
397
403
  * const key = toModelGeneratorKey({
398
404
  * generatorId: 'typescript-interfaces',
399
- * refName: 'User',
405
+ * ref: { refName: 'User', refPath: '#/components/schemas' },
400
406
  * variant: 'main'
401
407
  * });
402
408
  * // Result: 'typescript-interfaces|User|main' (branded)
403
409
  *
404
410
  * const coercive = toModelGeneratorKey({
405
411
  * generatorId: 'zod-schemas',
406
- * refName: 'CreateUserRequest',
412
+ * ref: { refName: 'CreateUserRequest', refPath: '#/components/schemas' },
407
413
  * variant: 'coercive'
408
414
  * });
409
415
  * // Result: 'zod-schemas|CreateUserRequest|coercive' (branded)
410
416
  * ```
411
417
  */
412
- export declare const toModelGeneratorKey: ({ generatorId, refName, variant }: ToModelGeneratorKeyArgs) => ModelGeneratorKey;
418
+ export declare const toModelGeneratorKey: ({ generatorId, ref, variant }: ToModelGeneratorKeyArgs) => ModelGeneratorKey;
413
419
  /**
414
420
  * Arguments for {@link toGeneratorOnlyKey}.
415
421
  */
@@ -532,7 +538,7 @@ export declare const isGqlOperationGeneratorKey: (arg: unknown) => arg is GqlOpe
532
538
  * const obj = fromGeneratorKey(key);
533
539
  * console.log(obj.type); // 'model'
534
540
  * console.log(obj.generatorId); // 'zod-schemas'
535
- * console.log(obj.refName); // 'User'
541
+ * console.log(obj.ref.refName); // 'User'
536
542
  * console.log(obj.variant); // 'main'
537
543
  * }
538
544
  * ```
@@ -582,7 +588,7 @@ export declare const isGeneratorOnlyKey: (arg: unknown) => arg is GeneratorOnlyK
582
588
  *
583
589
  * const modelKey = toModelGeneratorKey({
584
590
  * generatorId: 'typescript-types',
585
- * refName: 'User',
591
+ * ref: { refName: 'User', refPath: '#/components/schemas' },
586
592
  * variant: 'main'
587
593
  * });
588
594
  * console.log(toGeneratorId(modelKey)); // 'typescript-types'
@@ -650,8 +656,8 @@ export type GeneratorKeyObject = {
650
656
  type: 'model';
651
657
  /** Generator identifier */
652
658
  generatorId: string;
653
- /** Schema reference name */
654
- refName: string;
659
+ /** The model's ref: a component's, or a ref into the document's content */
660
+ ref: RefParts;
655
661
  /** Model variant name */
656
662
  variant: string;
657
663
  } | {
@@ -689,7 +695,7 @@ export type GeneratorKeyObject = {
689
695
  *
690
696
  * if (parsed.type === 'model') {
691
697
  * console.log(parsed.generatorId); // 'zod-schemas'
692
- * console.log(parsed.refName); // 'User'
698
+ * console.log(parsed.ref.refName); // 'User'
693
699
  * console.log(parsed.variant); // 'main'
694
700
  * }
695
701
  * ```
@@ -59,7 +59,7 @@ exports.fromGeneratorKey = exports.toGeneratorId = exports.isGeneratorOnlyKey =
59
59
  *
60
60
  * const modelKey = toModelGeneratorKey({
61
61
  * generatorId: 'typescript-models',
62
- * refName: 'User' as RefName,
62
+ * ref: { refName: 'User' as RefName, refPath: '#/components/schemas' },
63
63
  * variant: 'main'
64
64
  * });
65
65
  * ```
@@ -69,6 +69,7 @@ exports.fromGeneratorKey = exports.toGeneratorId = exports.isGeneratorOnlyKey =
69
69
  require("../_dnt.polyfills.js");
70
70
  const Method_js_1 = require("../types/Method.js");
71
71
  const Variant_js_1 = require("../types/Variant.js");
72
+ const refFns_js_1 = require("../helpers/refFns.js");
72
73
  const GQL_ROOT_KINDS = ['query', 'mutation', 'subscription'];
73
74
  const isGqlRootKind = (value) => GQL_ROOT_KINDS.includes(value);
74
75
  /**
@@ -176,7 +177,8 @@ exports.toGqlOperationGeneratorKey = toGqlOperationGeneratorKey;
176
177
  *
177
178
  * Model generator keys uniquely identify generators processing specific
178
179
  * OpenAPI schema models for a given variant. The key format is:
179
- * `generatorId|refName|variant`.
180
+ * `generatorId|modelKey|variant`: a component's `refName`, or the whole
181
+ * pointer of any other target, with `%` and `|` escaped.
180
182
  *
181
183
  * @param args - Model generator key arguments
182
184
  * @returns A branded ModelGeneratorKey
@@ -185,21 +187,24 @@ exports.toGqlOperationGeneratorKey = toGqlOperationGeneratorKey;
185
187
  * ```typescript
186
188
  * const key = toModelGeneratorKey({
187
189
  * generatorId: 'typescript-interfaces',
188
- * refName: 'User',
190
+ * ref: { refName: 'User', refPath: '#/components/schemas' },
189
191
  * variant: 'main'
190
192
  * });
191
193
  * // Result: 'typescript-interfaces|User|main' (branded)
192
194
  *
193
195
  * const coercive = toModelGeneratorKey({
194
196
  * generatorId: 'zod-schemas',
195
- * refName: 'CreateUserRequest',
197
+ * ref: { refName: 'CreateUserRequest', refPath: '#/components/schemas' },
196
198
  * variant: 'coercive'
197
199
  * });
198
200
  * // Result: 'zod-schemas|CreateUserRequest|coercive' (branded)
199
201
  * ```
200
202
  */
201
- const toModelGeneratorKey = ({ generatorId, refName, variant = Variant_js_1.DEFAULT_VARIANT }) => {
202
- const nakedKey = `${generatorId}|${refName}|${variant}`;
203
+ const toModelGeneratorKey = ({ generatorId, ref, variant = Variant_js_1.DEFAULT_VARIANT }) => {
204
+ const modelKey = (0, refFns_js_1.toModelKey)(ref);
205
+ // A pointer can hold `|` (a property named `a|b`). A component's key stays its bare name.
206
+ const segment = (0, refFns_js_1.isPointerKey)(modelKey) ? escapeKeySegment(modelKey) : modelKey;
207
+ const nakedKey = `${generatorId}|${segment}|${variant}`;
203
208
  return nakedKey;
204
209
  };
205
210
  exports.toModelGeneratorKey = toModelGeneratorKey;
@@ -418,7 +423,7 @@ exports.isGqlOperationGeneratorKey = isGqlOperationGeneratorKey;
418
423
  * const obj = fromGeneratorKey(key);
419
424
  * console.log(obj.type); // 'model'
420
425
  * console.log(obj.generatorId); // 'zod-schemas'
421
- * console.log(obj.refName); // 'User'
426
+ * console.log(obj.ref.refName); // 'User'
422
427
  * console.log(obj.variant); // 'main'
423
428
  * }
424
429
  * ```
@@ -494,7 +499,7 @@ exports.isGeneratorOnlyKey = isGeneratorOnlyKey;
494
499
  *
495
500
  * const modelKey = toModelGeneratorKey({
496
501
  * generatorId: 'typescript-types',
497
- * refName: 'User',
502
+ * ref: { refName: 'User', refPath: '#/components/schemas' },
498
503
  * variant: 'main'
499
504
  * });
500
505
  * console.log(toGeneratorId(modelKey)); // 'typescript-types'
@@ -553,7 +558,7 @@ exports.toGeneratorId = toGeneratorId;
553
558
  *
554
559
  * if (parsed.type === 'model') {
555
560
  * console.log(parsed.generatorId); // 'zod-schemas'
556
- * console.log(parsed.refName); // 'User'
561
+ * console.log(parsed.ref.refName); // 'User'
557
562
  * console.log(parsed.variant); // 'main'
558
563
  * }
559
564
  * ```
@@ -598,8 +603,8 @@ const fromGeneratorKey = (generatorKey) => {
598
603
  };
599
604
  }
600
605
  if ((0, exports.isModelGeneratorKey)(generatorKey)) {
601
- const [generatorId, refName, variant] = generatorKey.split('|');
602
- return { type: 'model', generatorId, refName, variant };
606
+ const [generatorId, modelKey, variant] = generatorKey.split('|');
607
+ return { type: 'model', generatorId, ref: (0, refFns_js_1.fromModelKey)((0, refFns_js_1.isPointerKey)(modelKey) ? unescapeKeySegment(modelKey) : modelKey), variant };
603
608
  }
604
609
  return { type: 'generator-only', generatorId: generatorKey };
605
610
  };
@@ -53,7 +53,7 @@ type ConstructorArgs<V extends GeneratedValue, EnrichmentType> = {
53
53
  * const identifier = userModel.toName(); // 'User'
54
54
  *
55
55
  * return new Definition({
56
- * identifier: createType(this.refName),
56
+ * identifier: createType(this.ref.refName),
57
57
  * value: {
58
58
  * generatorKey: this.generatorKey,
59
59
  * content: `export interface Order { user: ${userTypeName}; }`
@@ -41,7 +41,7 @@ exports.Inserted = void 0;
41
41
  * const identifier = userModel.toName(); // 'User'
42
42
  *
43
43
  * return new Definition({
44
- * identifier: createType(this.refName),
44
+ * identifier: createType(this.ref.refName),
45
45
  * value: {
46
46
  * generatorKey: this.generatorKey,
47
47
  * content: `export interface Order { user: ${userTypeName}; }`