@sdk-it/spec 0.44.0 → 0.46.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 (121) hide show
  1. package/dist/index.d.ts +5 -3
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +9 -3
  4. package/dist/index.js.map +2 -2
  5. package/dist/lib/find-polymorphic-varients.d.ts.map +1 -1
  6. package/dist/lib/find-polymorphic-varients.js +5 -10
  7. package/dist/lib/find-polymorphic-varients.js.map +2 -2
  8. package/dist/lib/for-each-operation.d.ts +11 -3
  9. package/dist/lib/for-each-operation.d.ts.map +1 -1
  10. package/dist/lib/for-each-operation.js +23 -15
  11. package/dist/lib/for-each-operation.js.map +2 -2
  12. package/dist/lib/format-name.d.ts.map +1 -1
  13. package/dist/lib/format-name.js +0 -1
  14. package/dist/lib/format-name.js.map +2 -2
  15. package/dist/lib/ir.d.ts +2 -2
  16. package/dist/lib/ir.d.ts.map +1 -1
  17. package/dist/lib/ir.js +6 -120
  18. package/dist/lib/ir.js.map +2 -2
  19. package/dist/lib/is.d.ts.map +1 -1
  20. package/dist/lib/is.js +1 -3
  21. package/dist/lib/is.js.map +2 -2
  22. package/dist/lib/loaders/postman/postman-converter.d.ts.map +1 -1
  23. package/dist/lib/loaders/postman/postman-converter.js +1 -11
  24. package/dist/lib/loaders/postman/postman-converter.js.map +2 -2
  25. package/dist/lib/options.d.ts +7 -45
  26. package/dist/lib/options.d.ts.map +1 -1
  27. package/dist/lib/options.js +26 -28
  28. package/dist/lib/options.js.map +2 -2
  29. package/dist/lib/overview-docs/overview-pagination.d.ts +1 -1
  30. package/dist/lib/overview-docs/overview-pagination.d.ts.map +1 -1
  31. package/dist/lib/overview-docs/overview-pagination.js +1 -1
  32. package/dist/lib/overview-docs/overview-pagination.js.map +2 -2
  33. package/dist/lib/pagination/guess-pagination.d.ts.map +1 -1
  34. package/dist/lib/pagination/guess-pagination.js.map +2 -2
  35. package/dist/lib/pagination/pagination-result.d.ts.map +1 -1
  36. package/dist/lib/pagination/pagination-result.js +15 -5
  37. package/dist/lib/pagination/pagination-result.js.map +2 -2
  38. package/dist/lib/pagination/pagination.d.ts.map +1 -1
  39. package/dist/lib/pagination/pagination.js +7 -6
  40. package/dist/lib/pagination/pagination.js.map +2 -2
  41. package/dist/lib/processing-plugins/canonicalize-spec.d.ts +3 -0
  42. package/dist/lib/processing-plugins/canonicalize-spec.d.ts.map +1 -0
  43. package/dist/lib/processing-plugins/canonicalize-spec.js +29 -0
  44. package/dist/lib/processing-plugins/canonicalize-spec.js.map +7 -0
  45. package/dist/lib/processing-plugins/create-default-processing-plugins.d.ts +5 -0
  46. package/dist/lib/processing-plugins/create-default-processing-plugins.d.ts.map +1 -0
  47. package/dist/lib/processing-plugins/create-default-processing-plugins.js +30 -0
  48. package/dist/lib/processing-plugins/create-default-processing-plugins.js.map +7 -0
  49. package/dist/lib/processing-plugins/enrich-examples.d.ts +25 -0
  50. package/dist/lib/processing-plugins/enrich-examples.d.ts.map +1 -0
  51. package/dist/lib/processing-plugins/enrich-examples.js +93 -0
  52. package/dist/lib/processing-plugins/enrich-examples.js.map +7 -0
  53. package/dist/lib/processing-plugins/extract-inline-schemas.d.ts +3 -0
  54. package/dist/lib/processing-plugins/extract-inline-schemas.d.ts.map +1 -0
  55. package/dist/lib/processing-plugins/extract-inline-schemas.js +14 -0
  56. package/dist/lib/processing-plugins/extract-inline-schemas.js.map +7 -0
  57. package/dist/lib/processing-plugins/extract-overview-docs.d.ts +3 -0
  58. package/dist/lib/processing-plugins/extract-overview-docs.d.ts.map +1 -0
  59. package/dist/lib/processing-plugins/extract-overview-docs.js +13 -0
  60. package/dist/lib/processing-plugins/extract-overview-docs.js.map +7 -0
  61. package/dist/lib/processing-plugins/index.d.ts +14 -0
  62. package/dist/lib/processing-plugins/index.d.ts.map +1 -0
  63. package/dist/lib/processing-plugins/index.js +14 -0
  64. package/dist/lib/processing-plugins/index.js.map +7 -0
  65. package/dist/lib/processing-plugins/infer-pagination.d.ts +3 -0
  66. package/dist/lib/processing-plugins/infer-pagination.d.ts.map +1 -0
  67. package/dist/lib/processing-plugins/infer-pagination.js +21 -0
  68. package/dist/lib/processing-plugins/infer-pagination.js.map +7 -0
  69. package/dist/lib/processing-plugins/normalize-operation-ids.d.ts +3 -0
  70. package/dist/lib/processing-plugins/normalize-operation-ids.d.ts.map +1 -0
  71. package/dist/lib/processing-plugins/normalize-operation-ids.js +74 -0
  72. package/dist/lib/processing-plugins/normalize-operation-ids.js.map +7 -0
  73. package/dist/lib/processing-plugins/normalize-parameters.d.ts +3 -0
  74. package/dist/lib/processing-plugins/normalize-parameters.d.ts.map +1 -0
  75. package/dist/lib/processing-plugins/normalize-parameters.js +29 -0
  76. package/dist/lib/processing-plugins/normalize-parameters.js.map +7 -0
  77. package/dist/lib/processing-plugins/normalize-paths.d.ts +3 -0
  78. package/dist/lib/processing-plugins/normalize-paths.d.ts.map +1 -0
  79. package/dist/lib/processing-plugins/normalize-paths.js +67 -0
  80. package/dist/lib/processing-plugins/normalize-paths.js.map +7 -0
  81. package/dist/lib/processing-plugins/normalize-request-bodies.d.ts +3 -0
  82. package/dist/lib/processing-plugins/normalize-request-bodies.d.ts.map +1 -0
  83. package/dist/lib/processing-plugins/normalize-request-bodies.js +44 -0
  84. package/dist/lib/processing-plugins/normalize-request-bodies.js.map +7 -0
  85. package/dist/lib/processing-plugins/normalize-responses.d.ts +3 -0
  86. package/dist/lib/processing-plugins/normalize-responses.d.ts.map +1 -0
  87. package/dist/lib/processing-plugins/normalize-responses.js +38 -0
  88. package/dist/lib/processing-plugins/normalize-responses.js.map +7 -0
  89. package/dist/lib/processing-plugins/normalize-schemas.d.ts +3 -0
  90. package/dist/lib/processing-plugins/normalize-schemas.d.ts.map +1 -0
  91. package/dist/lib/processing-plugins/normalize-schemas.js +13 -0
  92. package/dist/lib/processing-plugins/normalize-schemas.js.map +7 -0
  93. package/dist/lib/processing-plugins/normalize-tags.d.ts +3 -0
  94. package/dist/lib/processing-plugins/normalize-tags.d.ts.map +1 -0
  95. package/dist/lib/processing-plugins/normalize-tags.js +18 -0
  96. package/dist/lib/processing-plugins/normalize-tags.js.map +7 -0
  97. package/dist/lib/processing.d.ts +33 -0
  98. package/dist/lib/processing.d.ts.map +1 -0
  99. package/dist/lib/processing.js +41 -0
  100. package/dist/lib/processing.js.map +7 -0
  101. package/dist/lib/reserved-keywords.d.ts.map +1 -1
  102. package/dist/lib/reserved-keywords.js +18 -1
  103. package/dist/lib/reserved-keywords.js.map +2 -2
  104. package/dist/lib/tag.js +2 -2
  105. package/dist/lib/tag.js.map +2 -2
  106. package/dist/lib/tune-request-body.d.ts.map +1 -1
  107. package/dist/lib/tune-request-body.js +22 -12
  108. package/dist/lib/tune-request-body.js.map +2 -2
  109. package/dist/lib/tune-response.d.ts.map +1 -1
  110. package/dist/lib/tune-response.js +16 -12
  111. package/dist/lib/tune-response.js.map +2 -2
  112. package/dist/lib/tune.d.ts.map +1 -1
  113. package/dist/lib/tune.js +31 -7
  114. package/dist/lib/tune.js.map +2 -2
  115. package/dist/lib/types.d.ts +4 -1
  116. package/dist/lib/types.d.ts.map +1 -1
  117. package/dist/lib/walk-schemas.d.ts +8 -0
  118. package/dist/lib/walk-schemas.d.ts.map +1 -0
  119. package/dist/lib/walk-schemas.js +51 -0
  120. package/dist/lib/walk-schemas.js.map +7 -0
  121. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/lib/pagination/pagination.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,EAAE,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAG5D,wBAAgB,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,cAAc,EAAE,oBAAoB,OAwB1E"}
1
+ {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/lib/pagination/pagination.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,EAAE,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAG5D,wBAAgB,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,cAAc,EAAE,oBAAoB,OAgC1E"}
@@ -1,14 +1,15 @@
1
1
  import { followRef, isRef } from "@sdk-it/core/ref.js";
2
+ import { isSuccessStatusCode } from "../is.js";
2
3
  import { guessPagination } from "./guess-pagination.js";
3
4
  function toPagination(spec, tunedOperation) {
4
5
  if (tunedOperation["x-pagination"]) {
5
6
  return tunedOperation["x-pagination"];
6
7
  }
7
- const schema = getResponseContentSchema(
8
- spec,
9
- tunedOperation.responses["200"],
10
- "application/json"
8
+ const successResponse = Object.entries(tunedOperation.responses).find(
9
+ ([status]) => isSuccessStatusCode(status) && Number.isInteger(Number(status))
11
10
  );
11
+ const statusCode = successResponse ? Number(successResponse[0]) : void 0;
12
+ const schema = successResponse ? getResponseContentSchema(spec, successResponse[1], "application/json") : void 0;
12
13
  const pagination = guessPagination(
13
14
  tunedOperation,
14
15
  tunedOperation.requestBody ? getRequestContentSchema(
@@ -18,8 +19,8 @@ function toPagination(spec, tunedOperation) {
18
19
  ) : void 0,
19
20
  schema
20
21
  );
21
- if (pagination && pagination.type !== "none" && schema) {
22
- return { ...pagination, statusCode: 200 };
22
+ if (pagination && pagination.type !== "none" && schema && statusCode !== void 0) {
23
+ return { ...pagination, statusCode };
23
24
  }
24
25
  return void 0;
25
26
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/pagination/pagination.ts"],
4
- "sourcesContent": ["import type {\n RequestBodyObject,\n ResponseObject,\n SchemaObject,\n} from 'openapi3-ts/oas31';\n\nimport { followRef, isRef } from '@sdk-it/core/ref.js';\n\nimport type { IR, TunedOperationObject } from '../types.js';\nimport { guessPagination } from './guess-pagination.js';\n\nexport function toPagination(spec: IR, tunedOperation: TunedOperationObject) {\n if (tunedOperation['x-pagination']) {\n return tunedOperation['x-pagination'];\n }\n const schema = getResponseContentSchema(\n spec,\n tunedOperation.responses['200'],\n 'application/json',\n );\n const pagination = guessPagination(\n tunedOperation,\n tunedOperation.requestBody\n ? getRequestContentSchema(\n spec,\n tunedOperation.requestBody,\n 'application/json',\n )\n : undefined,\n schema,\n );\n if (pagination && pagination.type !== 'none' && schema) {\n return { ...pagination, statusCode: 200 };\n }\n return undefined;\n}\n\nfunction getResponseContentSchema(\n spec: IR,\n response: ResponseObject,\n type: string,\n) {\n if (!response) {\n return undefined;\n }\n const content = response.content;\n if (!content) {\n return undefined;\n }\n for (const contentType in content) {\n if (contentType.toLowerCase() === type.toLowerCase()) {\n return isRef(content[contentType].schema)\n ? followRef<SchemaObject>(spec, content[contentType].schema.$ref)\n : content[contentType].schema;\n }\n }\n return undefined;\n}\n\nfunction getRequestContentSchema(\n spec: IR,\n requestBody: RequestBodyObject,\n type: string,\n) {\n const content = requestBody.content;\n if (!content) {\n return undefined;\n }\n for (const contentType in content) {\n if (contentType.toLowerCase() === type.toLowerCase()) {\n return isRef(content[contentType].schema)\n ? followRef<SchemaObject>(spec, content[contentType].schema.$ref)\n : content[contentType].schema;\n }\n }\n return undefined;\n}\n"],
5
- "mappings": "AAMA,SAAS,WAAW,aAAa;AAGjC,SAAS,uBAAuB;AAEzB,SAAS,aAAa,MAAU,gBAAsC;AAC3E,MAAI,eAAe,cAAc,GAAG;AAClC,WAAO,eAAe,cAAc;AAAA,EACtC;AACA,QAAM,SAAS;AAAA,IACb;AAAA,IACA,eAAe,UAAU,KAAK;AAAA,IAC9B;AAAA,EACF;AACA,QAAM,aAAa;AAAA,IACjB;AAAA,IACA,eAAe,cACX;AAAA,MACE;AAAA,MACA,eAAe;AAAA,MACf;AAAA,IACF,IACA;AAAA,IACJ;AAAA,EACF;AACA,MAAI,cAAc,WAAW,SAAS,UAAU,QAAQ;AACtD,WAAO,EAAE,GAAG,YAAY,YAAY,IAAI;AAAA,EAC1C;AACA,SAAO;AACT;AAEA,SAAS,yBACP,MACA,UACA,MACA;AACA,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AACA,QAAM,UAAU,SAAS;AACzB,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AACA,aAAW,eAAe,SAAS;AACjC,QAAI,YAAY,YAAY,MAAM,KAAK,YAAY,GAAG;AACpD,aAAO,MAAM,QAAQ,WAAW,EAAE,MAAM,IACpC,UAAwB,MAAM,QAAQ,WAAW,EAAE,OAAO,IAAI,IAC9D,QAAQ,WAAW,EAAE;AAAA,IAC3B;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,wBACP,MACA,aACA,MACA;AACA,QAAM,UAAU,YAAY;AAC5B,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AACA,aAAW,eAAe,SAAS;AACjC,QAAI,YAAY,YAAY,MAAM,KAAK,YAAY,GAAG;AACpD,aAAO,MAAM,QAAQ,WAAW,EAAE,MAAM,IACpC,UAAwB,MAAM,QAAQ,WAAW,EAAE,OAAO,IAAI,IAC9D,QAAQ,WAAW,EAAE;AAAA,IAC3B;AAAA,EACF;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["import type {\n RequestBodyObject,\n ResponseObject,\n SchemaObject,\n} from 'openapi3-ts/oas31';\n\nimport { followRef, isRef } from '@sdk-it/core/ref.js';\n\nimport { isSuccessStatusCode } from '../is.js';\nimport type { IR, TunedOperationObject } from '../types.js';\nimport { guessPagination } from './guess-pagination.js';\n\nexport function toPagination(spec: IR, tunedOperation: TunedOperationObject) {\n if (tunedOperation['x-pagination']) {\n return tunedOperation['x-pagination'];\n }\n const successResponse = Object.entries(tunedOperation.responses).find(\n ([status]) =>\n isSuccessStatusCode(status) && Number.isInteger(Number(status)),\n );\n const statusCode = successResponse ? Number(successResponse[0]) : undefined;\n const schema = successResponse\n ? getResponseContentSchema(spec, successResponse[1], 'application/json')\n : undefined;\n const pagination = guessPagination(\n tunedOperation,\n tunedOperation.requestBody\n ? getRequestContentSchema(\n spec,\n tunedOperation.requestBody,\n 'application/json',\n )\n : undefined,\n schema,\n );\n if (\n pagination &&\n pagination.type !== 'none' &&\n schema &&\n statusCode !== undefined\n ) {\n return { ...pagination, statusCode };\n }\n return undefined;\n}\n\nfunction getResponseContentSchema(\n spec: IR,\n response: ResponseObject,\n type: string,\n) {\n if (!response) {\n return undefined;\n }\n const content = response.content;\n if (!content) {\n return undefined;\n }\n for (const contentType in content) {\n if (contentType.toLowerCase() === type.toLowerCase()) {\n return isRef(content[contentType].schema)\n ? followRef<SchemaObject>(spec, content[contentType].schema.$ref)\n : content[contentType].schema;\n }\n }\n return undefined;\n}\n\nfunction getRequestContentSchema(\n spec: IR,\n requestBody: RequestBodyObject,\n type: string,\n) {\n const content = requestBody.content;\n if (!content) {\n return undefined;\n }\n for (const contentType in content) {\n if (contentType.toLowerCase() === type.toLowerCase()) {\n return isRef(content[contentType].schema)\n ? followRef<SchemaObject>(spec, content[contentType].schema.$ref)\n : content[contentType].schema;\n }\n }\n return undefined;\n}\n"],
5
+ "mappings": "AAMA,SAAS,WAAW,aAAa;AAEjC,SAAS,2BAA2B;AAEpC,SAAS,uBAAuB;AAEzB,SAAS,aAAa,MAAU,gBAAsC;AAC3E,MAAI,eAAe,cAAc,GAAG;AAClC,WAAO,eAAe,cAAc;AAAA,EACtC;AACA,QAAM,kBAAkB,OAAO,QAAQ,eAAe,SAAS,EAAE;AAAA,IAC/D,CAAC,CAAC,MAAM,MACN,oBAAoB,MAAM,KAAK,OAAO,UAAU,OAAO,MAAM,CAAC;AAAA,EAClE;AACA,QAAM,aAAa,kBAAkB,OAAO,gBAAgB,CAAC,CAAC,IAAI;AAClE,QAAM,SAAS,kBACX,yBAAyB,MAAM,gBAAgB,CAAC,GAAG,kBAAkB,IACrE;AACJ,QAAM,aAAa;AAAA,IACjB;AAAA,IACA,eAAe,cACX;AAAA,MACE;AAAA,MACA,eAAe;AAAA,MACf;AAAA,IACF,IACA;AAAA,IACJ;AAAA,EACF;AACA,MACE,cACA,WAAW,SAAS,UACpB,UACA,eAAe,QACf;AACA,WAAO,EAAE,GAAG,YAAY,WAAW;AAAA,EACrC;AACA,SAAO;AACT;AAEA,SAAS,yBACP,MACA,UACA,MACA;AACA,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AACA,QAAM,UAAU,SAAS;AACzB,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AACA,aAAW,eAAe,SAAS;AACjC,QAAI,YAAY,YAAY,MAAM,KAAK,YAAY,GAAG;AACpD,aAAO,MAAM,QAAQ,WAAW,EAAE,MAAM,IACpC,UAAwB,MAAM,QAAQ,WAAW,EAAE,OAAO,IAAI,IAC9D,QAAQ,WAAW,EAAE;AAAA,IAC3B;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,wBACP,MACA,aACA,MACA;AACA,QAAM,UAAU,YAAY;AAC5B,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AACA,aAAW,eAAe,SAAS;AACjC,QAAI,YAAY,YAAY,MAAM,KAAK,YAAY,GAAG;AACpD,aAAO,MAAM,QAAQ,WAAW,EAAE,MAAM,IACpC,UAAwB,MAAM,QAAQ,WAAW,EAAE,OAAO,IAAI,IAC9D,QAAQ,WAAW,EAAE;AAAA,IAC3B;AAAA,EACF;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,3 @@
1
+ import type { ProcessingPlugin } from '../processing.js';
2
+ export declare function canonicalizeSpec(): ProcessingPlugin;
3
+ //# sourceMappingURL=canonicalize-spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonicalize-spec.d.ts","sourceRoot":"","sources":["../../../src/lib/processing-plugins/canonicalize-spec.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAWzD,wBAAgB,gBAAgB,IAAI,gBAAgB,CAiBnD"}
@@ -0,0 +1,29 @@
1
+ import { walkSchemas } from "../walk-schemas.js";
2
+ function sortRecord(record) {
3
+ return Object.fromEntries(
4
+ Object.entries(record).sort(
5
+ ([left], [right]) => left < right ? -1 : left > right ? 1 : 0
6
+ )
7
+ );
8
+ }
9
+ function canonicalizeSpec() {
10
+ return {
11
+ name: "canonicalize-spec",
12
+ process({ spec }) {
13
+ spec.components.schemas = sortRecord(spec.components.schemas);
14
+ for (const { schema } of walkSchemas(spec)) {
15
+ if (schema.properties) {
16
+ schema.properties = sortRecord(schema.properties);
17
+ }
18
+ const extraProperties = schema["x-properties"];
19
+ if (extraProperties) {
20
+ schema["x-properties"] = sortRecord(extraProperties);
21
+ }
22
+ }
23
+ }
24
+ };
25
+ }
26
+ export {
27
+ canonicalizeSpec
28
+ };
29
+ //# sourceMappingURL=canonicalize-spec.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/processing-plugins/canonicalize-spec.ts"],
4
+ "sourcesContent": ["import type { SchemaObject } from 'openapi3-ts/oas31';\n\nimport type { ProcessingPlugin } from '../processing.js';\nimport { walkSchemas } from '../walk-schemas.js';\n\nfunction sortRecord<T>(record: Record<string, T>): Record<string, T> {\n return Object.fromEntries(\n Object.entries(record).sort(([left], [right]) =>\n left < right ? -1 : left > right ? 1 : 0,\n ),\n );\n}\n\nexport function canonicalizeSpec(): ProcessingPlugin {\n return {\n name: 'canonicalize-spec',\n process({ spec }) {\n spec.components.schemas = sortRecord(spec.components.schemas);\n for (const { schema } of walkSchemas(spec)) {\n if (schema.properties) {\n schema.properties = sortRecord(schema.properties);\n }\n const extraProperties = schema['x-properties'] as\n Record<string, SchemaObject> | undefined;\n if (extraProperties) {\n schema['x-properties'] = sortRecord(extraProperties);\n }\n }\n },\n };\n}\n"],
5
+ "mappings": "AAGA,SAAS,mBAAmB;AAE5B,SAAS,WAAc,QAA8C;AACnE,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,MAAM,EAAE;AAAA,MAAK,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,MACzC,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI;AAAA,IACzC;AAAA,EACF;AACF;AAEO,SAAS,mBAAqC;AACnD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ,EAAE,KAAK,GAAG;AAChB,WAAK,WAAW,UAAU,WAAW,KAAK,WAAW,OAAO;AAC5D,iBAAW,EAAE,OAAO,KAAK,YAAY,IAAI,GAAG;AAC1C,YAAI,OAAO,YAAY;AACrB,iBAAO,aAAa,WAAW,OAAO,UAAU;AAAA,QAClD;AACA,cAAM,kBAAkB,OAAO,cAAc;AAE7C,YAAI,iBAAiB;AACnB,iBAAO,cAAc,IAAI,WAAW,eAAe;AAAA,QACrD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,5 @@
1
+ import type { ProcessingPlugin } from '../processing.js';
2
+ export declare function createDefaultProcessingPlugins(options?: {
3
+ verbose?: boolean;
4
+ }): ProcessingPlugin[];
5
+ //# sourceMappingURL=create-default-processing-plugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-default-processing-plugins.d.ts","sourceRoot":"","sources":["../../../src/lib/processing-plugins/create-default-processing-plugins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAazD,wBAAgB,8BAA8B,CAC5C,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,GAClC,gBAAgB,EAAE,CAcpB"}
@@ -0,0 +1,30 @@
1
+ import { canonicalizeSpec } from "./canonicalize-spec.js";
2
+ import { extractInlineSchemas } from "./extract-inline-schemas.js";
3
+ import { extractOverviewDocsPlugin } from "./extract-overview-docs.js";
4
+ import { inferPagination } from "./infer-pagination.js";
5
+ import { normalizeOperationIds } from "./normalize-operation-ids.js";
6
+ import { normalizeParameters } from "./normalize-parameters.js";
7
+ import { normalizePaths } from "./normalize-paths.js";
8
+ import { normalizeRequestBodies } from "./normalize-request-bodies.js";
9
+ import { normalizeResponses } from "./normalize-responses.js";
10
+ import { normalizeSchemas } from "./normalize-schemas.js";
11
+ import { normalizeTags } from "./normalize-tags.js";
12
+ function createDefaultProcessingPlugins(options = {}) {
13
+ return [
14
+ normalizePaths(),
15
+ normalizeOperationIds(),
16
+ normalizeTags(),
17
+ normalizeParameters(),
18
+ normalizeResponses(),
19
+ normalizeRequestBodies(),
20
+ inferPagination(),
21
+ normalizeSchemas(),
22
+ ...options.verbose ? [extractInlineSchemas()] : [],
23
+ extractOverviewDocsPlugin(),
24
+ canonicalizeSpec()
25
+ ];
26
+ }
27
+ export {
28
+ createDefaultProcessingPlugins
29
+ };
30
+ //# sourceMappingURL=create-default-processing-plugins.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/processing-plugins/create-default-processing-plugins.ts"],
4
+ "sourcesContent": ["import type { ProcessingPlugin } from '../processing.js';\nimport { canonicalizeSpec } from './canonicalize-spec.js';\nimport { extractInlineSchemas } from './extract-inline-schemas.js';\nimport { extractOverviewDocsPlugin } from './extract-overview-docs.js';\nimport { inferPagination } from './infer-pagination.js';\nimport { normalizeOperationIds } from './normalize-operation-ids.js';\nimport { normalizeParameters } from './normalize-parameters.js';\nimport { normalizePaths } from './normalize-paths.js';\nimport { normalizeRequestBodies } from './normalize-request-bodies.js';\nimport { normalizeResponses } from './normalize-responses.js';\nimport { normalizeSchemas } from './normalize-schemas.js';\nimport { normalizeTags } from './normalize-tags.js';\n\nexport function createDefaultProcessingPlugins(\n options: { verbose?: boolean } = {},\n): ProcessingPlugin[] {\n return [\n normalizePaths(),\n normalizeOperationIds(),\n normalizeTags(),\n normalizeParameters(),\n normalizeResponses(),\n normalizeRequestBodies(),\n inferPagination(),\n normalizeSchemas(),\n ...(options.verbose ? [extractInlineSchemas()] : []),\n extractOverviewDocsPlugin(),\n canonicalizeSpec(),\n ];\n}\n"],
5
+ "mappings": "AACA,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AACrC,SAAS,iCAAiC;AAC1C,SAAS,uBAAuB;AAChC,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAEvB,SAAS,+BACd,UAAiC,CAAC,GACd;AACpB,SAAO;AAAA,IACL,eAAe;AAAA,IACf,sBAAsB;AAAA,IACtB,cAAc;AAAA,IACd,oBAAoB;AAAA,IACpB,mBAAmB;AAAA,IACnB,uBAAuB;AAAA,IACvB,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,GAAI,QAAQ,UAAU,CAAC,qBAAqB,CAAC,IAAI,CAAC;AAAA,IAClD,0BAA0B;AAAA,IAC1B,iBAAiB;AAAA,EACnB;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,25 @@
1
+ import type { OperationObject, SchemaObject } from 'openapi3-ts/oas31';
2
+ import type { ProcessingPlugin } from '../processing.js';
3
+ import type { IR } from '../types.js';
4
+ export interface ExampleEnrichmentInput {
5
+ spec: IR;
6
+ operation: OperationObject;
7
+ method: string;
8
+ path: string;
9
+ direction: 'request' | 'response';
10
+ mediaType: string;
11
+ schema: SchemaObject;
12
+ statusCode?: string;
13
+ signal?: AbortSignal;
14
+ }
15
+ export interface ExampleValidationInput extends ExampleEnrichmentInput {
16
+ value: unknown;
17
+ }
18
+ export interface ExampleEnrichmentOptions {
19
+ name?: string;
20
+ overwrite?: boolean;
21
+ generate(input: ExampleEnrichmentInput): unknown | Promise<unknown>;
22
+ validate(input: ExampleValidationInput): boolean | Promise<boolean>;
23
+ }
24
+ export declare function enrichExamples(options: ExampleEnrichmentOptions): ProcessingPlugin;
25
+ //# sourceMappingURL=enrich-examples.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enrich-examples.d.ts","sourceRoot":"","sources":["../../../src/lib/processing-plugins/enrich-examples.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EAGf,YAAY,EACb,MAAM,mBAAmB,CAAC;AAK3B,OAAO,KAAK,EAAwB,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,EAAE,CAAC;IACT,SAAS,EAAE,eAAe,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,SAAS,GAAG,UAAU,CAAC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,YAAY,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,sBAAuB,SAAQ,sBAAsB;IACpE,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACpE,QAAQ,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACrE;AAgDD,wBAAgB,cAAc,CAC5B,OAAO,EAAE,wBAAwB,GAChC,gBAAgB,CAyDlB"}
@@ -0,0 +1,93 @@
1
+ import { resolveRef } from "@sdk-it/core/ref.js";
2
+ import { iterateOperations } from "../for-each-operation.js";
3
+ function hasAuthoredExample(media) {
4
+ return Object.prototype.hasOwnProperty.call(media, "example") || Object.keys(media.examples ?? {}).length > 0;
5
+ }
6
+ async function enrichMediaType(input, options, report) {
7
+ const { media, ...target } = input;
8
+ if (!media.schema || !options.overwrite && hasAuthoredExample(media)) {
9
+ return;
10
+ }
11
+ target.signal?.throwIfAborted();
12
+ const schema = resolveRef(target.spec, media.schema);
13
+ const enrichmentInput = { ...target, schema };
14
+ const value = await options.generate(enrichmentInput);
15
+ target.signal?.throwIfAborted();
16
+ if (!await options.validate({ ...enrichmentInput, value })) {
17
+ report({
18
+ severity: "warning",
19
+ code: "generated-example-invalid",
20
+ message: `Discarded an invalid generated ${target.direction} example`,
21
+ path: `${target.method.toUpperCase()} ${target.path}`
22
+ });
23
+ return;
24
+ }
25
+ media.example = value;
26
+ report({
27
+ severity: "info",
28
+ code: "example-generated",
29
+ message: `Generated a schema-valid ${target.direction} example`,
30
+ path: `${target.method.toUpperCase()} ${target.path}`
31
+ });
32
+ }
33
+ function enrichExamples(options) {
34
+ return {
35
+ name: options.name ?? "enrich-examples",
36
+ async process({ spec, report, signal }) {
37
+ for (const { entry, operation } of iterateOperations(spec)) {
38
+ if (operation.requestBody) {
39
+ const requestBody = resolveRef(
40
+ spec,
41
+ operation.requestBody
42
+ );
43
+ for (const [mediaType, media] of Object.entries(
44
+ requestBody.content
45
+ )) {
46
+ await enrichMediaType(
47
+ {
48
+ spec,
49
+ operation,
50
+ method: entry.method,
51
+ path: entry.path,
52
+ direction: "request",
53
+ mediaType,
54
+ media,
55
+ signal
56
+ },
57
+ options,
58
+ report
59
+ );
60
+ }
61
+ }
62
+ for (const [statusCode, responseOrRef] of Object.entries(
63
+ operation.responses ?? {}
64
+ )) {
65
+ const response = resolveRef(spec, responseOrRef);
66
+ for (const [mediaType, media] of Object.entries(
67
+ response.content ?? {}
68
+ )) {
69
+ await enrichMediaType(
70
+ {
71
+ spec,
72
+ operation,
73
+ method: entry.method,
74
+ path: entry.path,
75
+ direction: "response",
76
+ statusCode,
77
+ mediaType,
78
+ media,
79
+ signal
80
+ },
81
+ options,
82
+ report
83
+ );
84
+ }
85
+ }
86
+ }
87
+ }
88
+ };
89
+ }
90
+ export {
91
+ enrichExamples
92
+ };
93
+ //# sourceMappingURL=enrich-examples.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/processing-plugins/enrich-examples.ts"],
4
+ "sourcesContent": ["import type {\n MediaTypeObject,\n OperationObject,\n RequestBodyObject,\n ResponseObject,\n SchemaObject,\n} from 'openapi3-ts/oas31';\n\nimport { resolveRef } from '@sdk-it/core/ref.js';\n\nimport { iterateOperations } from '../for-each-operation.js';\nimport type { ProcessingDiagnostic, ProcessingPlugin } from '../processing.js';\nimport type { IR } from '../types.js';\n\nexport interface ExampleEnrichmentInput {\n spec: IR;\n operation: OperationObject;\n method: string;\n path: string;\n direction: 'request' | 'response';\n mediaType: string;\n schema: SchemaObject;\n statusCode?: string;\n signal?: AbortSignal;\n}\n\nexport interface ExampleValidationInput extends ExampleEnrichmentInput {\n value: unknown;\n}\n\nexport interface ExampleEnrichmentOptions {\n name?: string;\n overwrite?: boolean;\n generate(input: ExampleEnrichmentInput): unknown | Promise<unknown>;\n validate(input: ExampleValidationInput): boolean | Promise<boolean>;\n}\n\nfunction hasAuthoredExample(media: MediaTypeObject): boolean {\n return (\n Object.prototype.hasOwnProperty.call(media, 'example') ||\n Object.keys(media.examples ?? {}).length > 0\n );\n}\n\nasync function enrichMediaType(\n input: Omit<ExampleEnrichmentInput, 'schema'> & {\n media: MediaTypeObject;\n },\n options: ExampleEnrichmentOptions,\n report: (\n diagnostic: Omit<ProcessingDiagnostic, 'plugin'>,\n ) => ProcessingDiagnostic,\n) {\n const { media, ...target } = input;\n if (!media.schema || (!options.overwrite && hasAuthoredExample(media))) {\n return;\n }\n\n target.signal?.throwIfAborted();\n const schema = resolveRef<SchemaObject>(target.spec, media.schema);\n const enrichmentInput = { ...target, schema };\n const value = await options.generate(enrichmentInput);\n target.signal?.throwIfAborted();\n\n if (!(await options.validate({ ...enrichmentInput, value }))) {\n report({\n severity: 'warning',\n code: 'generated-example-invalid',\n message: `Discarded an invalid generated ${target.direction} example`,\n path: `${target.method.toUpperCase()} ${target.path}`,\n });\n return;\n }\n\n media.example = value;\n report({\n severity: 'info',\n code: 'example-generated',\n message: `Generated a schema-valid ${target.direction} example`,\n path: `${target.method.toUpperCase()} ${target.path}`,\n });\n}\n\nexport function enrichExamples(\n options: ExampleEnrichmentOptions,\n): ProcessingPlugin {\n return {\n name: options.name ?? 'enrich-examples',\n async process({ spec, report, signal }) {\n for (const { entry, operation } of iterateOperations(spec)) {\n if (operation.requestBody) {\n const requestBody = resolveRef<RequestBodyObject>(\n spec,\n operation.requestBody,\n );\n for (const [mediaType, media] of Object.entries(\n requestBody.content,\n )) {\n await enrichMediaType(\n {\n spec,\n operation,\n method: entry.method,\n path: entry.path,\n direction: 'request',\n mediaType,\n media,\n signal,\n },\n options,\n report,\n );\n }\n }\n\n for (const [statusCode, responseOrRef] of Object.entries(\n operation.responses ?? {},\n )) {\n const response = resolveRef<ResponseObject>(spec, responseOrRef);\n for (const [mediaType, media] of Object.entries(\n response.content ?? {},\n )) {\n await enrichMediaType(\n {\n spec,\n operation,\n method: entry.method,\n path: entry.path,\n direction: 'response',\n statusCode,\n mediaType,\n media,\n signal,\n },\n options,\n report,\n );\n }\n }\n }\n },\n };\n}\n"],
5
+ "mappings": "AAQA,SAAS,kBAAkB;AAE3B,SAAS,yBAAyB;AA2BlC,SAAS,mBAAmB,OAAiC;AAC3D,SACE,OAAO,UAAU,eAAe,KAAK,OAAO,SAAS,KACrD,OAAO,KAAK,MAAM,YAAY,CAAC,CAAC,EAAE,SAAS;AAE/C;AAEA,eAAe,gBACb,OAGA,SACA,QAGA;AACA,QAAM,EAAE,OAAO,GAAG,OAAO,IAAI;AAC7B,MAAI,CAAC,MAAM,UAAW,CAAC,QAAQ,aAAa,mBAAmB,KAAK,GAAI;AACtE;AAAA,EACF;AAEA,SAAO,QAAQ,eAAe;AAC9B,QAAM,SAAS,WAAyB,OAAO,MAAM,MAAM,MAAM;AACjE,QAAM,kBAAkB,EAAE,GAAG,QAAQ,OAAO;AAC5C,QAAM,QAAQ,MAAM,QAAQ,SAAS,eAAe;AACpD,SAAO,QAAQ,eAAe;AAE9B,MAAI,CAAE,MAAM,QAAQ,SAAS,EAAE,GAAG,iBAAiB,MAAM,CAAC,GAAI;AAC5D,WAAO;AAAA,MACL,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS,kCAAkC,OAAO,SAAS;AAAA,MAC3D,MAAM,GAAG,OAAO,OAAO,YAAY,CAAC,IAAI,OAAO,IAAI;AAAA,IACrD,CAAC;AACD;AAAA,EACF;AAEA,QAAM,UAAU;AAChB,SAAO;AAAA,IACL,UAAU;AAAA,IACV,MAAM;AAAA,IACN,SAAS,4BAA4B,OAAO,SAAS;AAAA,IACrD,MAAM,GAAG,OAAO,OAAO,YAAY,CAAC,IAAI,OAAO,IAAI;AAAA,EACrD,CAAC;AACH;AAEO,SAAS,eACd,SACkB;AAClB,SAAO;AAAA,IACL,MAAM,QAAQ,QAAQ;AAAA,IACtB,MAAM,QAAQ,EAAE,MAAM,QAAQ,OAAO,GAAG;AACtC,iBAAW,EAAE,OAAO,UAAU,KAAK,kBAAkB,IAAI,GAAG;AAC1D,YAAI,UAAU,aAAa;AACzB,gBAAM,cAAc;AAAA,YAClB;AAAA,YACA,UAAU;AAAA,UACZ;AACA,qBAAW,CAAC,WAAW,KAAK,KAAK,OAAO;AAAA,YACtC,YAAY;AAAA,UACd,GAAG;AACD,kBAAM;AAAA,cACJ;AAAA,gBACE;AAAA,gBACA;AAAA,gBACA,QAAQ,MAAM;AAAA,gBACd,MAAM,MAAM;AAAA,gBACZ,WAAW;AAAA,gBACX;AAAA,gBACA;AAAA,gBACA;AAAA,cACF;AAAA,cACA;AAAA,cACA;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAEA,mBAAW,CAAC,YAAY,aAAa,KAAK,OAAO;AAAA,UAC/C,UAAU,aAAa,CAAC;AAAA,QAC1B,GAAG;AACD,gBAAM,WAAW,WAA2B,MAAM,aAAa;AAC/D,qBAAW,CAAC,WAAW,KAAK,KAAK,OAAO;AAAA,YACtC,SAAS,WAAW,CAAC;AAAA,UACvB,GAAG;AACD,kBAAM;AAAA,cACJ;AAAA,gBACE;AAAA,gBACA;AAAA,gBACA,QAAQ,MAAM;AAAA,gBACd,MAAM,MAAM;AAAA,gBACZ,WAAW;AAAA,gBACX;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,cACF;AAAA,cACA;AAAA,cACA;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ import type { ProcessingPlugin } from '../processing.js';
2
+ export declare function extractInlineSchemas(): ProcessingPlugin;
3
+ //# sourceMappingURL=extract-inline-schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract-inline-schemas.d.ts","sourceRoot":"","sources":["../../../src/lib/processing-plugins/extract-inline-schemas.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGzD,wBAAgB,oBAAoB,IAAI,gBAAgB,CAQvD"}
@@ -0,0 +1,14 @@
1
+ import { expandSpec } from "../tune.js";
2
+ function extractInlineSchemas() {
3
+ return {
4
+ name: "extract-inline-schemas",
5
+ process({ spec }) {
6
+ const refs = [];
7
+ expandSpec(spec, spec.components.schemas, refs);
8
+ }
9
+ };
10
+ }
11
+ export {
12
+ extractInlineSchemas
13
+ };
14
+ //# sourceMappingURL=extract-inline-schemas.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/processing-plugins/extract-inline-schemas.ts"],
4
+ "sourcesContent": ["import type { SchemaObject } from 'openapi3-ts/oas31';\n\nimport type { ProcessingPlugin } from '../processing.js';\nimport { expandSpec } from '../tune.js';\n\nexport function extractInlineSchemas(): ProcessingPlugin {\n return {\n name: 'extract-inline-schemas',\n process({ spec }) {\n const refs: { name: string; value: SchemaObject }[] = [];\n expandSpec(spec, spec.components.schemas, refs);\n },\n };\n}\n"],
5
+ "mappings": "AAGA,SAAS,kBAAkB;AAEpB,SAAS,uBAAyC;AACvD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ,EAAE,KAAK,GAAG;AAChB,YAAM,OAAgD,CAAC;AACvD,iBAAW,MAAM,KAAK,WAAW,SAAS,IAAI;AAAA,IAChD;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ import type { ProcessingPlugin } from '../processing.js';
2
+ export declare function extractOverviewDocsPlugin(): ProcessingPlugin;
3
+ //# sourceMappingURL=extract-overview-docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract-overview-docs.d.ts","sourceRoot":"","sources":["../../../src/lib/processing-plugins/extract-overview-docs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,wBAAgB,yBAAyB,IAAI,gBAAgB,CAO5D"}
@@ -0,0 +1,13 @@
1
+ import { extractOverviewDocs } from "../overview-docs/overview-docs.js";
2
+ function extractOverviewDocsPlugin() {
3
+ return {
4
+ name: "extract-overview-docs",
5
+ process({ spec }) {
6
+ spec["x-docs"] = extractOverviewDocs(spec);
7
+ }
8
+ };
9
+ }
10
+ export {
11
+ extractOverviewDocsPlugin
12
+ };
13
+ //# sourceMappingURL=extract-overview-docs.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/processing-plugins/extract-overview-docs.ts"],
4
+ "sourcesContent": ["import { extractOverviewDocs } from '../overview-docs/overview-docs.js';\nimport type { ProcessingPlugin } from '../processing.js';\n\nexport function extractOverviewDocsPlugin(): ProcessingPlugin {\n return {\n name: 'extract-overview-docs',\n process({ spec }) {\n spec['x-docs'] = extractOverviewDocs(spec);\n },\n };\n}\n"],
5
+ "mappings": "AAAA,SAAS,2BAA2B;AAG7B,SAAS,4BAA8C;AAC5D,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ,EAAE,KAAK,GAAG;AAChB,WAAK,QAAQ,IAAI,oBAAoB,IAAI;AAAA,IAC3C;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,14 @@
1
+ export * from './canonicalize-spec.js';
2
+ export * from './create-default-processing-plugins.js';
3
+ export * from './enrich-examples.js';
4
+ export * from './extract-inline-schemas.js';
5
+ export * from './extract-overview-docs.js';
6
+ export * from './infer-pagination.js';
7
+ export * from './normalize-operation-ids.js';
8
+ export * from './normalize-parameters.js';
9
+ export * from './normalize-paths.js';
10
+ export * from './normalize-request-bodies.js';
11
+ export * from './normalize-responses.js';
12
+ export * from './normalize-schemas.js';
13
+ export * from './normalize-tags.js';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/processing-plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,wCAAwC,CAAC;AACvD,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,14 @@
1
+ export * from "./canonicalize-spec.js";
2
+ export * from "./create-default-processing-plugins.js";
3
+ export * from "./enrich-examples.js";
4
+ export * from "./extract-inline-schemas.js";
5
+ export * from "./extract-overview-docs.js";
6
+ export * from "./infer-pagination.js";
7
+ export * from "./normalize-operation-ids.js";
8
+ export * from "./normalize-parameters.js";
9
+ export * from "./normalize-paths.js";
10
+ export * from "./normalize-request-bodies.js";
11
+ export * from "./normalize-responses.js";
12
+ export * from "./normalize-schemas.js";
13
+ export * from "./normalize-tags.js";
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/processing-plugins/index.ts"],
4
+ "sourcesContent": ["export * from './canonicalize-spec.js';\nexport * from './create-default-processing-plugins.js';\nexport * from './enrich-examples.js';\nexport * from './extract-inline-schemas.js';\nexport * from './extract-overview-docs.js';\nexport * from './infer-pagination.js';\nexport * from './normalize-operation-ids.js';\nexport * from './normalize-parameters.js';\nexport * from './normalize-paths.js';\nexport * from './normalize-request-bodies.js';\nexport * from './normalize-responses.js';\nexport * from './normalize-schemas.js';\nexport * from './normalize-tags.js';\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ import type { ProcessingPlugin } from '../processing.js';
2
+ export declare function inferPagination(): ProcessingPlugin;
3
+ //# sourceMappingURL=infer-pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infer-pagination.d.ts","sourceRoot":"","sources":["../../../src/lib/processing-plugins/infer-pagination.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGzD,wBAAgB,eAAe,IAAI,gBAAgB,CAclD"}
@@ -0,0 +1,21 @@
1
+ import { iterateOperations } from "../for-each-operation.js";
2
+ import { toPagination } from "../pagination/pagination.js";
3
+ function inferPagination() {
4
+ return {
5
+ name: "infer-pagination",
6
+ process({ spec, options }) {
7
+ for (const { operation } of iterateOperations(spec)) {
8
+ const tunedOperation = operation;
9
+ if (options.pagination.enabled && options.pagination.guess) {
10
+ tunedOperation["x-pagination"] = toPagination(spec, tunedOperation);
11
+ } else {
12
+ delete tunedOperation["x-pagination"];
13
+ }
14
+ }
15
+ }
16
+ };
17
+ }
18
+ export {
19
+ inferPagination
20
+ };
21
+ //# sourceMappingURL=infer-pagination.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/processing-plugins/infer-pagination.ts"],
4
+ "sourcesContent": ["import { iterateOperations } from '../for-each-operation.js';\nimport { toPagination } from '../pagination/pagination.js';\nimport type { ProcessingPlugin } from '../processing.js';\nimport type { TunedOperationObject } from '../types.js';\n\nexport function inferPagination(): ProcessingPlugin {\n return {\n name: 'infer-pagination',\n process({ spec, options }) {\n for (const { operation } of iterateOperations(spec)) {\n const tunedOperation = operation as TunedOperationObject;\n if (options.pagination.enabled && options.pagination.guess) {\n tunedOperation['x-pagination'] = toPagination(spec, tunedOperation);\n } else {\n delete tunedOperation['x-pagination'];\n }\n }\n },\n };\n}\n"],
5
+ "mappings": "AAAA,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAItB,SAAS,kBAAoC;AAClD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ,EAAE,MAAM,QAAQ,GAAG;AACzB,iBAAW,EAAE,UAAU,KAAK,kBAAkB,IAAI,GAAG;AACnD,cAAM,iBAAiB;AACvB,YAAI,QAAQ,WAAW,WAAW,QAAQ,WAAW,OAAO;AAC1D,yBAAe,cAAc,IAAI,aAAa,MAAM,cAAc;AAAA,QACpE,OAAO;AACL,iBAAO,eAAe,cAAc;AAAA,QACtC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ import type { ProcessingPlugin } from '../processing.js';
2
+ export declare function normalizeOperationIds(): ProcessingPlugin;
3
+ //# sourceMappingURL=normalize-operation-ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-operation-ids.d.ts","sourceRoot":"","sources":["../../../src/lib/processing-plugins/normalize-operation-ids.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AA2CzD,wBAAgB,qBAAqB,IAAI,gBAAgB,CA0CxD"}
@@ -0,0 +1,74 @@
1
+ import { iterateOperations } from "../for-each-operation.js";
2
+ import { toResource } from "../guess/guess-resource.js";
3
+ function findUniqueOperationId(usedOperationIds, initialId, choices, formatter) {
4
+ let counter = 1;
5
+ let uniqueOperationId = formatter(initialId);
6
+ while (usedOperationIds.has(uniqueOperationId)) {
7
+ const prependIndex = Math.min(counter - 1, choices.length - 1);
8
+ const prefix = choices[prependIndex];
9
+ uniqueOperationId = formatter(
10
+ prependIndex < choices.length - 1 ? `${prefix}${initialId.charAt(0).toUpperCase() + initialId.slice(1)}` : `${prefix}${initialId.charAt(0).toUpperCase() + initialId.slice(1)}${counter - choices.length + 1}`
11
+ );
12
+ counter++;
13
+ }
14
+ return uniqueOperationId;
15
+ }
16
+ function normalizeOperationIdentifier(value) {
17
+ const normalized = value.trim().replace(/[^A-Za-z0-9]+/g, " ").replace(
18
+ /(?:^|\s+)([A-Za-z0-9])/g,
19
+ (_, character) => character.toUpperCase()
20
+ ).replace(/^([A-Z])/, (character) => character.toLowerCase());
21
+ if (!normalized) {
22
+ return "operation";
23
+ }
24
+ if (/^[A-Za-z]/.test(normalized)) {
25
+ return normalized;
26
+ }
27
+ return `operation${normalized.charAt(0).toUpperCase()}${normalized.slice(1)}`;
28
+ }
29
+ function normalizeOperationIds() {
30
+ return {
31
+ name: "normalize-operation-ids",
32
+ process({ spec, options, report }) {
33
+ const usedOperationIds = /* @__PURE__ */ new Set();
34
+ for (const { entry, operation } of iterateOperations(spec)) {
35
+ const originalOperationId = operation.operationId;
36
+ const { name } = toResource(operation, entry.path, entry.method);
37
+ const operationTag = options.tag(operation, entry.path);
38
+ const operationId = findUniqueOperationId(
39
+ usedOperationIds,
40
+ normalizeOperationIdentifier(
41
+ options.operationId(operation, entry.path, entry.method)
42
+ ),
43
+ [
44
+ operationTag,
45
+ entry.method,
46
+ entry.path.split("/").filter(Boolean).join("")
47
+ ],
48
+ (candidate) => normalizeOperationIdentifier(
49
+ options.operationId(
50
+ { ...operation, operationId: candidate },
51
+ entry.path,
52
+ entry.method
53
+ )
54
+ )
55
+ );
56
+ usedOperationIds.add(operationId);
57
+ operation.operationId = operationId;
58
+ operation["x-fn-name"] = name;
59
+ if (operationId !== originalOperationId) {
60
+ report({
61
+ severity: "info",
62
+ code: "operation-id-normalized",
63
+ message: `Normalized operation ID ${originalOperationId ?? "<missing>"} to ${operationId}`,
64
+ path: `${entry.method.toUpperCase()} ${entry.path}`
65
+ });
66
+ }
67
+ }
68
+ }
69
+ };
70
+ }
71
+ export {
72
+ normalizeOperationIds
73
+ };
74
+ //# sourceMappingURL=normalize-operation-ids.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/processing-plugins/normalize-operation-ids.ts"],
4
+ "sourcesContent": ["import { iterateOperations } from '../for-each-operation.js';\nimport { toResource } from '../guess/guess-resource.js';\nimport type { ProcessingPlugin } from '../processing.js';\n\nfunction findUniqueOperationId(\n usedOperationIds: Set<string>,\n initialId: string,\n choices: string[],\n formatter: (id: string) => string,\n) {\n let counter = 1;\n let uniqueOperationId = formatter(initialId);\n\n while (usedOperationIds.has(uniqueOperationId)) {\n const prependIndex = Math.min(counter - 1, choices.length - 1);\n const prefix = choices[prependIndex];\n uniqueOperationId = formatter(\n prependIndex < choices.length - 1\n ? `${prefix}${initialId.charAt(0).toUpperCase() + initialId.slice(1)}`\n : `${prefix}${initialId.charAt(0).toUpperCase() + initialId.slice(1)}${counter - choices.length + 1}`,\n );\n counter++;\n }\n\n return uniqueOperationId;\n}\n\nfunction normalizeOperationIdentifier(value: string): string {\n const normalized = value\n .trim()\n .replace(/[^A-Za-z0-9]+/g, ' ')\n .replace(/(?:^|\\s+)([A-Za-z0-9])/g, (_, character: string) =>\n character.toUpperCase(),\n )\n .replace(/^([A-Z])/, (character) => character.toLowerCase());\n\n if (!normalized) {\n return 'operation';\n }\n if (/^[A-Za-z]/.test(normalized)) {\n return normalized;\n }\n return `operation${normalized.charAt(0).toUpperCase()}${normalized.slice(1)}`;\n}\n\nexport function normalizeOperationIds(): ProcessingPlugin {\n return {\n name: 'normalize-operation-ids',\n process({ spec, options, report }) {\n const usedOperationIds = new Set<string>();\n for (const { entry, operation } of iterateOperations(spec)) {\n const originalOperationId = operation.operationId;\n const { name } = toResource(operation, entry.path, entry.method);\n const operationTag = options.tag(operation, entry.path);\n const operationId = findUniqueOperationId(\n usedOperationIds,\n normalizeOperationIdentifier(\n options.operationId(operation, entry.path, entry.method),\n ),\n [\n operationTag,\n entry.method,\n entry.path.split('/').filter(Boolean).join(''),\n ],\n (candidate) =>\n normalizeOperationIdentifier(\n options.operationId(\n { ...operation, operationId: candidate },\n entry.path,\n entry.method,\n ),\n ),\n );\n usedOperationIds.add(operationId);\n operation.operationId = operationId;\n operation['x-fn-name'] = name;\n if (operationId !== originalOperationId) {\n report({\n severity: 'info',\n code: 'operation-id-normalized',\n message: `Normalized operation ID ${originalOperationId ?? '<missing>'} to ${operationId}`,\n path: `${entry.method.toUpperCase()} ${entry.path}`,\n });\n }\n }\n },\n };\n}\n"],
5
+ "mappings": "AAAA,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAG3B,SAAS,sBACP,kBACA,WACA,SACA,WACA;AACA,MAAI,UAAU;AACd,MAAI,oBAAoB,UAAU,SAAS;AAE3C,SAAO,iBAAiB,IAAI,iBAAiB,GAAG;AAC9C,UAAM,eAAe,KAAK,IAAI,UAAU,GAAG,QAAQ,SAAS,CAAC;AAC7D,UAAM,SAAS,QAAQ,YAAY;AACnC,wBAAoB;AAAA,MAClB,eAAe,QAAQ,SAAS,IAC5B,GAAG,MAAM,GAAG,UAAU,OAAO,CAAC,EAAE,YAAY,IAAI,UAAU,MAAM,CAAC,CAAC,KAClE,GAAG,MAAM,GAAG,UAAU,OAAO,CAAC,EAAE,YAAY,IAAI,UAAU,MAAM,CAAC,CAAC,GAAG,UAAU,QAAQ,SAAS,CAAC;AAAA,IACvG;AACA;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,6BAA6B,OAAuB;AAC3D,QAAM,aAAa,MAChB,KAAK,EACL,QAAQ,kBAAkB,GAAG,EAC7B;AAAA,IAAQ;AAAA,IAA2B,CAAC,GAAG,cACtC,UAAU,YAAY;AAAA,EACxB,EACC,QAAQ,YAAY,CAAC,cAAc,UAAU,YAAY,CAAC;AAE7D,MAAI,CAAC,YAAY;AACf,WAAO;AAAA,EACT;AACA,MAAI,YAAY,KAAK,UAAU,GAAG;AAChC,WAAO;AAAA,EACT;AACA,SAAO,YAAY,WAAW,OAAO,CAAC,EAAE,YAAY,CAAC,GAAG,WAAW,MAAM,CAAC,CAAC;AAC7E;AAEO,SAAS,wBAA0C;AACxD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ,EAAE,MAAM,SAAS,OAAO,GAAG;AACjC,YAAM,mBAAmB,oBAAI,IAAY;AACzC,iBAAW,EAAE,OAAO,UAAU,KAAK,kBAAkB,IAAI,GAAG;AAC1D,cAAM,sBAAsB,UAAU;AACtC,cAAM,EAAE,KAAK,IAAI,WAAW,WAAW,MAAM,MAAM,MAAM,MAAM;AAC/D,cAAM,eAAe,QAAQ,IAAI,WAAW,MAAM,IAAI;AACtD,cAAM,cAAc;AAAA,UAClB;AAAA,UACA;AAAA,YACE,QAAQ,YAAY,WAAW,MAAM,MAAM,MAAM,MAAM;AAAA,UACzD;AAAA,UACA;AAAA,YACE;AAAA,YACA,MAAM;AAAA,YACN,MAAM,KAAK,MAAM,GAAG,EAAE,OAAO,OAAO,EAAE,KAAK,EAAE;AAAA,UAC/C;AAAA,UACA,CAAC,cACC;AAAA,YACE,QAAQ;AAAA,cACN,EAAE,GAAG,WAAW,aAAa,UAAU;AAAA,cACvC,MAAM;AAAA,cACN,MAAM;AAAA,YACR;AAAA,UACF;AAAA,QACJ;AACA,yBAAiB,IAAI,WAAW;AAChC,kBAAU,cAAc;AACxB,kBAAU,WAAW,IAAI;AACzB,YAAI,gBAAgB,qBAAqB;AACvC,iBAAO;AAAA,YACL,UAAU;AAAA,YACV,MAAM;AAAA,YACN,SAAS,2BAA2B,uBAAuB,WAAW,OAAO,WAAW;AAAA,YACxF,MAAM,GAAG,MAAM,OAAO,YAAY,CAAC,IAAI,MAAM,IAAI;AAAA,UACnD,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ import type { ProcessingPlugin } from '../processing.js';
2
+ export declare function normalizeParameters(): ProcessingPlugin;
3
+ //# sourceMappingURL=normalize-parameters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-parameters.d.ts","sourceRoot":"","sources":["../../../src/lib/processing-plugins/normalize-parameters.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,wBAAgB,mBAAmB,IAAI,gBAAgB,CAsBtD"}
@@ -0,0 +1,29 @@
1
+ import { resolveRef } from "@sdk-it/core/ref.js";
2
+ import { iterateOperations } from "../for-each-operation.js";
3
+ function normalizeParameters() {
4
+ return {
5
+ name: "normalize-parameters",
6
+ process({ spec }) {
7
+ const pathItems = /* @__PURE__ */ new Set();
8
+ for (const { operation, pathItem } of iterateOperations(spec)) {
9
+ pathItems.add(pathItem);
10
+ const parameters = /* @__PURE__ */ new Map();
11
+ for (const parameterOrRef of [
12
+ ...pathItem.parameters ?? [],
13
+ ...operation.parameters ?? []
14
+ ]) {
15
+ const parameter = resolveRef(spec, parameterOrRef);
16
+ parameters.set(`${parameter.in}:${parameter.name}`, parameter);
17
+ }
18
+ operation.parameters = [...parameters.values()];
19
+ }
20
+ for (const pathItem of pathItems) {
21
+ delete pathItem.parameters;
22
+ }
23
+ }
24
+ };
25
+ }
26
+ export {
27
+ normalizeParameters
28
+ };
29
+ //# sourceMappingURL=normalize-parameters.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/processing-plugins/normalize-parameters.ts"],
4
+ "sourcesContent": ["import type { ParameterObject, PathItemObject } from 'openapi3-ts/oas31';\n\nimport { resolveRef } from '@sdk-it/core/ref.js';\n\nimport { iterateOperations } from '../for-each-operation.js';\nimport type { ProcessingPlugin } from '../processing.js';\n\nexport function normalizeParameters(): ProcessingPlugin {\n return {\n name: 'normalize-parameters',\n process({ spec }) {\n const pathItems = new Set<PathItemObject>();\n for (const { operation, pathItem } of iterateOperations(spec)) {\n pathItems.add(pathItem);\n const parameters = new Map<string, ParameterObject>();\n for (const parameterOrRef of [\n ...(pathItem.parameters ?? []),\n ...(operation.parameters ?? []),\n ]) {\n const parameter = resolveRef<ParameterObject>(spec, parameterOrRef);\n parameters.set(`${parameter.in}:${parameter.name}`, parameter);\n }\n operation.parameters = [...parameters.values()];\n }\n for (const pathItem of pathItems) {\n delete pathItem.parameters;\n }\n },\n };\n}\n"],
5
+ "mappings": "AAEA,SAAS,kBAAkB;AAE3B,SAAS,yBAAyB;AAG3B,SAAS,sBAAwC;AACtD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ,EAAE,KAAK,GAAG;AAChB,YAAM,YAAY,oBAAI,IAAoB;AAC1C,iBAAW,EAAE,WAAW,SAAS,KAAK,kBAAkB,IAAI,GAAG;AAC7D,kBAAU,IAAI,QAAQ;AACtB,cAAM,aAAa,oBAAI,IAA6B;AACpD,mBAAW,kBAAkB;AAAA,UAC3B,GAAI,SAAS,cAAc,CAAC;AAAA,UAC5B,GAAI,UAAU,cAAc,CAAC;AAAA,QAC/B,GAAG;AACD,gBAAM,YAAY,WAA4B,MAAM,cAAc;AAClE,qBAAW,IAAI,GAAG,UAAU,EAAE,IAAI,UAAU,IAAI,IAAI,SAAS;AAAA,QAC/D;AACA,kBAAU,aAAa,CAAC,GAAG,WAAW,OAAO,CAAC;AAAA,MAChD;AACA,iBAAW,YAAY,WAAW;AAChC,eAAO,SAAS;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ import type { ProcessingPlugin } from '../processing.js';
2
+ export declare function normalizePaths(): ProcessingPlugin;
3
+ //# sourceMappingURL=normalize-paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-paths.d.ts","sourceRoot":"","sources":["../../../src/lib/processing-plugins/normalize-paths.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,wBAAgB,cAAc,IAAI,gBAAgB,CAgEjD"}