oas 38.5.1 → 38.5.2

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 (37) hide show
  1. package/dist/analyzer/index.cjs +16 -16
  2. package/dist/analyzer/index.js +1 -1
  3. package/dist/{chunk-SMIO4Q5R.js → chunk-7LQKUYC7.js} +2 -2
  4. package/dist/{chunk-6D7GWVEH.js → chunk-A7BAE2SN.js} +4 -2
  5. package/dist/chunk-A7BAE2SN.js.map +1 -0
  6. package/dist/{chunk-VQNK3PSL.js → chunk-IV2FDFXA.js} +34 -10
  7. package/dist/chunk-IV2FDFXA.js.map +1 -0
  8. package/dist/{chunk-FRJT3NFM.cjs → chunk-JQGHPVGV.cjs} +72 -72
  9. package/dist/{chunk-FRJT3NFM.cjs.map → chunk-JQGHPVGV.cjs.map} +1 -1
  10. package/dist/{chunk-6GTPCWO5.cjs → chunk-MYFJ2GV3.cjs} +4 -2
  11. package/dist/chunk-MYFJ2GV3.cjs.map +1 -0
  12. package/dist/{chunk-EQK5HAUI.cjs → chunk-T4AJWZEL.cjs} +46 -22
  13. package/dist/chunk-T4AJWZEL.cjs.map +1 -0
  14. package/dist/{index-JqhiKm_-.d.cts → index-C4bupNyk.d.cts} +12 -0
  15. package/dist/{index-BTzc-Kc8.d.ts → index-C6OzXwLp.d.ts} +12 -0
  16. package/dist/index.cjs +38 -38
  17. package/dist/index.js +2 -2
  18. package/dist/operation/index.cjs +3 -3
  19. package/dist/operation/index.js +2 -2
  20. package/dist/pruner/index.cjs +4 -4
  21. package/dist/pruner/index.d.cts +1 -1
  22. package/dist/pruner/index.d.ts +1 -1
  23. package/dist/pruner/index.js +3 -3
  24. package/dist/reducer/index.cjs +7 -7
  25. package/dist/reducer/index.cjs.map +1 -1
  26. package/dist/reducer/index.d.cts +4 -4
  27. package/dist/reducer/index.d.ts +4 -4
  28. package/dist/reducer/index.js +6 -6
  29. package/dist/reducer/index.js.map +1 -1
  30. package/dist/utils.cjs +2 -2
  31. package/dist/utils.js +1 -1
  32. package/package.json +3 -3
  33. package/dist/chunk-6D7GWVEH.js.map +0 -1
  34. package/dist/chunk-6GTPCWO5.cjs.map +0 -1
  35. package/dist/chunk-EQK5HAUI.cjs.map +0 -1
  36. package/dist/chunk-VQNK3PSL.js.map +0 -1
  37. /package/dist/{chunk-SMIO4Q5R.js.map → chunk-7LQKUYC7.js.map} +0 -0
@@ -3,11 +3,12 @@ import {
3
3
  } from "./chunk-QTPMJRIE.js";
4
4
  import {
5
5
  Operation
6
- } from "./chunk-SMIO4Q5R.js";
6
+ } from "./chunk-7LQKUYC7.js";
7
7
  import {
8
8
  decodePointer,
9
+ encodePointer,
9
10
  supportedMethods
10
- } from "./chunk-6D7GWVEH.js";
11
+ } from "./chunk-A7BAE2SN.js";
11
12
  import {
12
13
  isOpenAPI31,
13
14
  isRef
@@ -226,7 +227,7 @@ var OpenAPITransformer = class {
226
227
  if ("security" in this.definition) {
227
228
  Object.values(this.definition.security || {}).forEach((sec) => {
228
229
  Object.keys(sec).forEach((scheme) => {
229
- this.$refs.add(`#/components/securitySchemes/${scheme}`);
230
+ this.retainSecurityScheme(scheme);
230
231
  });
231
232
  });
232
233
  }
@@ -253,8 +254,9 @@ var OpenAPITransformer = class {
253
254
  if ("components" in this.definition) {
254
255
  Object.keys(this.definition.components || {}).forEach((componentType) => {
255
256
  Object.keys(this.definition.components?.[componentType] || {}).forEach((component) => {
256
- const refIsUsed = this.$refs.has(`#/components/${componentType}/${component}`) || Array.from(this.$refs).some((ref) => {
257
- return ref.startsWith(`#/components/${componentType}/${component}/`);
257
+ const componentPointer = `#/components/${componentType}/${encodePointer(component)}`;
258
+ const refIsUsed = this.$refs.has(componentPointer) || Array.from(this.$refs).some((ref) => {
259
+ return ref.startsWith(`${componentPointer}/`);
258
260
  });
259
261
  if (!refIsUsed) {
260
262
  delete this.definition.components?.[componentType]?.[component];
@@ -378,6 +380,26 @@ var OpenAPITransformer = class {
378
380
  }
379
381
  return { name, retention: "container" };
380
382
  }
383
+ /**
384
+ * If a Path Item we must keep is itself a `$ref`, retain that target and walk it for further
385
+ * `$ref`s. `#/paths/~1foo/get/…` (and the webhook equivalent) do not resolve through a
386
+ * ref-only `/foo` via JSON Pointer, so without this the component is deleted while `/foo`
387
+ * remains as a dangling `$ref`.
388
+ */
389
+ retainReferencedPathItem(pathItem) {
390
+ if (!isRef(pathItem) || this.$refs.has(pathItem.$ref)) {
391
+ return;
392
+ }
393
+ this.$refs.add(pathItem.$ref);
394
+ this.accumulateUsedRefs(this.definition, this.$refs, pathItem.$ref);
395
+ }
396
+ /**
397
+ * Record a security scheme so component cleanup keeps it. Scheme names are JSON-Pointer-encoded
398
+ * so they match the same form used for authored `$ref`s (`foo/bar` → `foo~1bar`).
399
+ */
400
+ retainSecurityScheme(scheme) {
401
+ this.$refs.add(`#/components/securitySchemes/${encodePointer(scheme)}`);
402
+ }
381
403
  /** Record a `#/paths` `$ref` so the target Path Item or operation is not dropped. */
382
404
  recordPathRef($ref) {
383
405
  const parsed = this.parsePathRef($ref);
@@ -393,6 +415,7 @@ var OpenAPITransformer = class {
393
415
  this.retainPathContainers.add(pathLC);
394
416
  this.accumulateContainerFieldRefs(this.findPathItem(parsed.path));
395
417
  }
418
+ this.retainReferencedPathItem(this.findPathItem(parsed.path));
396
419
  }
397
420
  /** Record a `#/webhooks` `$ref` so the target webhook Path Item or operation is not dropped. */
398
421
  recordWebhookRef($ref) {
@@ -409,6 +432,7 @@ var OpenAPITransformer = class {
409
432
  this.retainWebhookContainers.add(nameLC);
410
433
  this.accumulateContainerFieldRefs(this.findWebhook(parsed.name));
411
434
  }
435
+ this.retainReferencedPathItem(this.findWebhook(parsed.name));
412
436
  }
413
437
  /** Look up a Path Item by its path, ignoring key casing. */
414
438
  findPathItem(path) {
@@ -583,7 +607,7 @@ var OpenAPITransformer = class {
583
607
  });
584
608
  Object.values(operation.security || {}).forEach((sec) => {
585
609
  Object.keys(sec).forEach((scheme) => {
586
- this.$refs.add(`#/components/securitySchemes/${scheme}`);
610
+ this.retainSecurityScheme(scheme);
587
611
  });
588
612
  });
589
613
  });
@@ -642,7 +666,7 @@ var OpenAPITransformer = class {
642
666
  });
643
667
  Object.values(operation.security || {}).forEach((sec) => {
644
668
  Object.keys(sec).forEach((scheme) => {
645
- this.$refs.add(`#/components/securitySchemes/${scheme}`);
669
+ this.retainSecurityScheme(scheme);
646
670
  });
647
671
  });
648
672
  });
@@ -702,7 +726,7 @@ var OpenAPITransformer = class {
702
726
  if ("security" in operation) {
703
727
  Object.values(operation.security || {}).forEach((sec) => {
704
728
  Object.keys(sec).forEach((scheme) => {
705
- this.$refs.add(`#/components/securitySchemes/${scheme}`);
729
+ this.retainSecurityScheme(scheme);
706
730
  });
707
731
  });
708
732
  }
@@ -781,7 +805,7 @@ var OpenAPITransformer = class {
781
805
  });
782
806
  Object.values(operation.security || {}).forEach((sec) => {
783
807
  Object.keys(sec).forEach((scheme) => {
784
- this.$refs.add(`#/components/securitySchemes/${scheme}`);
808
+ this.retainSecurityScheme(scheme);
785
809
  });
786
810
  });
787
811
  });
@@ -798,4 +822,4 @@ var OpenAPITransformer = class {
798
822
  export {
799
823
  OpenAPITransformer
800
824
  };
801
- //# sourceMappingURL=chunk-VQNK3PSL.js.map
825
+ //# sourceMappingURL=chunk-IV2FDFXA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/transformer/index.ts","../src/lib/transformer/operation-selection.ts"],"sourcesContent":["import type {\n ComponentsObject,\n HttpMethods,\n OASDocument,\n OperationObject,\n PathItemObject,\n TagObject,\n} from '../../types.js';\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\nimport jsonPointer from 'jsonpointer';\n\nimport { query } from '../../analyzer/util.js';\nimport { Operation } from '../../operation/index.js';\nimport { isOpenAPI31, isRef } from '../../types.js';\nimport { supportedMethods } from '../../utils.js';\nimport { decodePointer, encodePointer } from '../refs.js';\n\nimport { OperationSelection } from './operation-selection.js';\n\ninterface OpenAPITransformerOptions {\n /** Whether selected paths, operations, and webhooks should be retained or removed. */\n mode: 'prune' | 'reduce';\n}\n\n/**\n * Internal engine for selecting operations and transforming an OpenAPI definition down to its\n * reachable paths, webhooks, components, and tags.\n */\nexport class OpenAPITransformer {\n private definition: OASDocument;\n\n private readonly mode: 'prune' | 'reduce';\n\n /**\n * A collection of `$ref` pointers that are used within our transformed API definition. This is\n * used to ensure that all referenced schemas are retained in our resulting API definition. Not\n * retaining them would result in an invalid OpenAPI definition.\n */\n private $refs: Set<string> = new Set();\n\n /**\n * A collection of OpenAPI tags that are used within the transformed API definition.\n */\n private usedTags: Set<string> = new Set();\n\n /**\n * A collection of OpenAPI paths and operations that are cross-referenced from any other paths\n * and operations that we're retaining. This collection is used to ensure that those operations\n * are retained in our resulting API definition. Not retaining them would result in an invalid\n * OpenAPI definition.\n *\n * A `*` method means the entire Path Item is referenced (e.g. `$ref: '#/paths/~1pets'`).\n */\n private retainPathMethods: Set<`${string}|${string}`> = new Set();\n\n /**\n * Paths whose Path Item *fields* (parameters, servers, summary, …) are referenced without\n * targeting a specific operation. The path container must remain even if every HTTP operation is\n * filtered out.\n */\n private retainPathContainers: Set<string> = new Set();\n\n /**\n * A collection of OpenAPI webhook names and methods that are cross-referenced from any other\n * schemas. This collection, like `retainPathMethods`, is used to ensure that those operations are\n * retained in our resulting API definition. Not retaining them would result in an invalid\n * OpenAPI definition.\n *\n * A `*` method means the entire webhook Path Item is referenced (e.g. `$ref: '#/webhooks/newPet'`).\n */\n private retainWebhookMethods: Set<`${string}|${string}`> = new Set();\n\n /**\n * Webhooks whose Path Item fields are referenced without targeting a specific operation.\n */\n private retainWebhookContainers: Set<string> = new Set();\n\n /** An array of OpenAPI tags selected for the current transformation. */\n private tagSelection: string[] = [];\n\n /** A collection of operation IDs selected for the current transformation. */\n private operationIdSelection = new Set<string>();\n\n /** A collection of OpenAPI paths and operations selected for the current transformation. */\n private pathSelection = new OperationSelection();\n\n /** A collection of OpenAPI webhooks selected for the current transformation. */\n private webhookSelection = new OperationSelection();\n\n private hasTagSelection: boolean = false;\n private hasOperationIdSelection: boolean = false;\n private hasPathSelection: boolean = false;\n private hasWebhookSelection: boolean = false;\n\n /**\n * @param definition OpenAPI definition to transform.\n * @param options Transformation mode.\n */\n protected constructor(definition: OASDocument, options: OpenAPITransformerOptions) {\n this.definition = structuredClone(definition);\n this.mode = options.mode;\n }\n\n /**\n * Select an OpenAPI tag. Operations with this tag are retained when reducing and removed when\n * pruning. Tag casing does not matter.\n *\n * @param tag Tag to select.\n */\n protected selectTag(tag: string): void {\n this.tagSelection.push(tag.toLowerCase());\n }\n\n /**\n * Select an entire OpenAPI path and all operations that it contains. Selected paths are retained\n * when reducing and removed when pruning. Path casing does not matter.\n *\n * @param path Path to select.\n */\n protected selectPath(path: string): void {\n this.pathSelection.addAll(path);\n }\n\n /**\n * Select a single OpenAPI operation. Selected operations are retained when reducing and removed\n * when pruning. Path and method casing does not matter.\n *\n * In reduce mode, selecting an operation after its entire path replaces the all-operation\n * selection with that operation and any operations selected afterward. Prune mode keeps the\n * entire path selected.\n *\n * @param path Path containing the operation.\n * @param method HTTP method of the operation to select.\n */\n protected selectOperation(path: string, method: string): void {\n if (this.mode === 'reduce' && this.pathSelection.matchesAll(path)) {\n this.pathSelection.clear(path);\n }\n\n this.pathSelection.addOperation(path, method);\n }\n\n /**\n * Select an OpenAPI operation by its operation ID. IDs are matched exactly and are generated\n * from the operation path and method when one is not authored in the definition.\n *\n * @param operationId Operation ID to select.\n */\n protected selectOperationId(operationId: string): void {\n this.operationIdSelection.add(operationId);\n }\n\n /**\n * Select an OpenAPI webhook or one of its operations. Selected webhooks are retained when\n * reducing and removed when pruning. Webhook and method casing does not matter.\n *\n * @param webhookName Webhook to select.\n * @param method Optional HTTP method of an individual webhook operation to select.\n */\n protected selectWebhook(webhookName: string, method?: string): void {\n if (!method) {\n this.webhookSelection.addAll(webhookName);\n return;\n }\n\n if (this.mode === 'reduce' && this.webhookSelection.matchesAll(webhookName)) {\n this.webhookSelection.clear(webhookName);\n }\n\n this.webhookSelection.addOperation(webhookName, method);\n }\n\n /** Transform the OpenAPI definition according to the configured mode and selections. */\n protected transform(): OASDocument {\n if (!this.definition.openapi) {\n throw new Error('Sorry, only OpenAPI definitions are supported.');\n }\n\n this.hasTagSelection = Boolean(this.tagSelection.length);\n this.hasOperationIdSelection = this.operationIdSelection.size > 0;\n this.hasPathSelection = this.pathSelection.hasSelections;\n this.hasWebhookSelection = this.webhookSelection.hasSelections;\n\n // Retain any root-level security definitions, regardless if they're used or not on operations\n // that we're retaining.\n if ('security' in this.definition) {\n Object.values(this.definition.security || {}).forEach(sec => {\n Object.keys(sec).forEach(scheme => {\n this.retainSecurityScheme(scheme);\n });\n });\n }\n\n this.walkPaths();\n this.walkWebhooks();\n\n // Recursively accumulate any components that are in use.\n this.$refs.forEach($ref => {\n this.accumulateUsedRefs(this.definition, this.$refs, $ref);\n });\n\n this.$refs.forEach(ref => {\n this.recordPathRef(ref);\n this.recordWebhookRef(ref);\n });\n\n /**\n * @fixme Resolve referenced Path Items so their operations can be transformed individually.\n * Targets of those `$ref`s are already retained (see `retainReferencedPathItem`).\n */\n this.transformPaths();\n this.transformWebhooks();\n\n // Require at least one path or one webhook in the result.\n const hasPaths = Boolean(this.definition.paths && Object.keys(this.definition.paths).length);\n const hasWebhooks = Boolean(\n 'webhooks' in this.definition && this.definition.webhooks && Object.keys(this.definition.webhooks).length,\n );\n\n // If we don't have any paths or webhooks left, retain the reducer's no-match error to help catch\n // invalid selections. An empty definition is valid OpenAPI so we allow it when pruning.\n if (this.mode === 'reduce' && !hasPaths && !hasWebhooks) {\n throw new Error(\n 'All paths and webhooks in the API definition were removed. Did you supply the right path, operation, or webhook to reduce by?',\n );\n }\n\n // Remove any unused components.\n if ('components' in this.definition) {\n Object.keys(this.definition.components || {}).forEach(componentType => {\n Object.keys(this.definition.components?.[componentType as keyof ComponentsObject] || {}).forEach(component => {\n // Authored `$ref`s JSON-Pointer-encode `/` and `~` in the component name\n // (`foo/bar` → `foo~1bar`). Compare against that encoded form or cleanup\n // deletes a still-referenced target.\n const componentPointer = `#/components/${componentType}/${encodePointer(component)}`;\n const refIsUsed =\n this.$refs.has(componentPointer) ||\n Array.from(this.$refs).some(ref => {\n // Because you can have a `$ref` like `#/components/examples/event-min/value`, which\n // would be accumulated via our `$refs` query, we want to make sure we account for them.\n // If we don't look for these then we'll end up removing them from the transformed\n // definition, resulting in data loss and schema corruption.\n return ref.startsWith(`${componentPointer}/`);\n });\n\n if (!refIsUsed) {\n delete this.definition.components?.[componentType as keyof ComponentsObject]?.[component];\n }\n });\n\n // If this component group is now empty, delete it.\n if (!Object.keys(this.definition.components?.[componentType as keyof ComponentsObject] || {}).length) {\n delete this.definition.components?.[componentType as keyof ComponentsObject];\n }\n });\n\n // If this path no longer has any components, delete it.\n if (!Object.keys(this.definition.components || {}).length) {\n delete this.definition.components;\n }\n }\n\n // Remove any unused tags.\n if ('tags' in this.definition) {\n this.definition.tags = (this.definition.tags ?? []).filter((tag): tag is TagObject => {\n return Boolean(tag) && this.usedTags.has(tag.name);\n });\n\n if (!this.definition.tags?.length) {\n delete this.definition.tags;\n }\n }\n\n return this.definition;\n }\n\n /**\n * Recursively process a `$ref` pointer and accumulate any other `$ref` pointers that it or its\n * children use. This handles circular references by skipping `$ref` pointers we have already seen.\n * Additionally when a `$ref` points to `#/paths` we record the used path + method so we can\n * retain cross-operation references within the transformed definition.\n *\n * @param schema JSON Schema object to look for and accumulate any `$ref` pointers that it may have.\n * @param $refs Known set of `$ref` pointers.\n * @param $ref `$ref` pointer to fetch a schema from out of the supplied schema.\n */\n private accumulateUsedRefs(schema: Record<string, unknown>, $refs: Set<string>, $ref: string): void {\n // Record `$ref` pointers aimed at `#/paths` or `#/webhooks` so we can retain any\n // cross-operation or Path Item references.\n this.recordPathRef($ref);\n this.recordWebhookRef($ref);\n\n let $refSchema: unknown;\n if (typeof $ref === 'string') $refSchema = jsonPointer.get(schema, $ref.substring(1));\n if ($refSchema === undefined) {\n // If the schema we have wasn't fully dereferenced or bundled for whatever reason and this\n // `$ref` that we have doesn't exist here we shouldn't try to search for more `$ref` pointers\n // in a schema that doesn't exist.\n return;\n }\n\n this.queryForRefPointers($refSchema).forEach(({ value: currRef }) => {\n // Because it's possible to have a schema property named `$ref` that is not a `$ref` pointer,\n // which our JSONPath query would pick up as a false positive, we want to exclude that from\n // `$ref` matching as it's not a reference pointer.\n const foundRef = this.toRefString(currRef);\n if (!foundRef) {\n return;\n }\n\n // If we've already processed this `$ref` then don't send us into an infinite loop of processing\n // circular references.\n if ($refs.has(foundRef)) {\n return;\n }\n\n $refs.add(foundRef);\n this.accumulateUsedRefs(schema, $refs, foundRef);\n });\n }\n\n /**\n * Query a JSON Schema object for any `$ref` pointers using JSONPath and return any pointers that\n * exist.\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc9535}\n * @param schema JSON Schema object to look for any `$ref` pointers within it.\n */\n private queryForRefPointers(schema: any) {\n return query([\"$..['$ref']\"], schema);\n }\n\n /**\n * Normalize a value from a `jsonpath-plus` `$ref` query to a `$ref` pointer because JSONPath\n * queries may return the property value or the parent.\n *\n */\n private toRefString(value: unknown): string | null {\n if (typeof value === 'string') {\n return value;\n } else if (value && typeof value === 'object' && '$ref' in value && typeof value.$ref === 'string') {\n return value.$ref;\n }\n\n return null;\n }\n\n /**\n * If the given `$ref` points into a path, classify how that path must be retained:\n *\n * - `#/paths/~1pets` — the entire Path Item (operations included)\n * - `#/paths/~1pets/get/...` — a single operation\n * - `#/paths/~1pets/parameters/...` — a Path Item field, so the container must remain\n */\n private parsePathRef(\n $ref: string,\n ):\n | { path: string; retention: 'all' }\n | { path: string; retention: 'operation'; method: string }\n | { path: string; retention: 'container' }\n | null {\n if (typeof $ref !== 'string' || !$ref.startsWith('#/paths/')) {\n return null;\n }\n\n const match = $ref.match(/^#\\/paths\\/([^/]+)(?:\\/([^/]+))?(?:\\/|$)/);\n if (!match?.[1]) {\n return null;\n }\n\n const path = decodePointer(match[1]);\n const segment = match[2];\n if (!segment) {\n return { path, retention: 'all' };\n }\n\n if (supportedMethods.includes(segment.toLowerCase() as HttpMethods)) {\n return { path, method: segment, retention: 'operation' };\n }\n\n return { path, retention: 'container' };\n }\n\n /**\n * If the given `$ref` points into webhooks, classify how that webhook must be retained. Same\n * retention rules as {@link parsePathRef}.\n */\n private parseWebhookRef(\n $ref: string,\n ):\n | { name: string; retention: 'all' }\n | { name: string; retention: 'operation'; method: string }\n | { name: string; retention: 'container' }\n | null {\n if (typeof $ref !== 'string' || !$ref.startsWith('#/webhooks/')) {\n return null;\n }\n\n const match = $ref.match(/^#\\/webhooks\\/([^/]+)(?:\\/([^/]+))?(?:\\/|$)/);\n if (!match?.[1]) {\n return null;\n }\n\n const name = decodePointer(match[1]);\n const segment = match[2];\n if (!segment) {\n return { name, retention: 'all' };\n }\n\n if (supportedMethods.includes(segment.toLowerCase() as HttpMethods)) {\n return { name, method: segment, retention: 'operation' };\n }\n\n return { name, retention: 'container' };\n }\n\n /**\n * If a Path Item we must keep is itself a `$ref`, retain that target and walk it for further\n * `$ref`s. `#/paths/~1foo/get/…` (and the webhook equivalent) do not resolve through a\n * ref-only `/foo` via JSON Pointer, so without this the component is deleted while `/foo`\n * remains as a dangling `$ref`.\n */\n private retainReferencedPathItem(pathItem: PathItemObject | undefined): void {\n if (!isRef(pathItem) || this.$refs.has(pathItem.$ref)) {\n return;\n }\n\n this.$refs.add(pathItem.$ref);\n this.accumulateUsedRefs(this.definition, this.$refs, pathItem.$ref);\n }\n\n /**\n * Record a security scheme so component cleanup keeps it. Scheme names are JSON-Pointer-encoded\n * so they match the same form used for authored `$ref`s (`foo/bar` → `foo~1bar`).\n */\n private retainSecurityScheme(scheme: string): void {\n this.$refs.add(`#/components/securitySchemes/${encodePointer(scheme)}`);\n }\n\n /** Record a `#/paths` `$ref` so the target Path Item or operation is not dropped. */\n private recordPathRef($ref: string): void {\n const parsed = this.parsePathRef($ref);\n if (!parsed) {\n return;\n }\n\n const pathLC = parsed.path.toLowerCase();\n if (parsed.retention === 'all') {\n this.retainPathMethods.add(`${pathLC}|*`);\n } else if (parsed.retention === 'operation') {\n this.retainPathMethods.add(`${pathLC}|${parsed.method.toLowerCase()}`);\n } else if (!this.retainPathContainers.has(pathLC)) {\n // Field-level pointers keep every sibling Path Item field, so walk those fields for\n // component `$ref`s. Traversing only the pointed-to entry would let component cleanup\n // delete a sibling's target and leave a dangling pointer.\n this.retainPathContainers.add(pathLC);\n this.accumulateContainerFieldRefs(this.findPathItem(parsed.path));\n }\n\n this.retainReferencedPathItem(this.findPathItem(parsed.path));\n }\n\n /** Record a `#/webhooks` `$ref` so the target webhook Path Item or operation is not dropped. */\n private recordWebhookRef($ref: string): void {\n const parsed = this.parseWebhookRef($ref);\n if (!parsed) {\n return;\n }\n\n const nameLC = parsed.name.toLowerCase();\n if (parsed.retention === 'all') {\n this.retainWebhookMethods.add(`${nameLC}|*`);\n } else if (parsed.retention === 'operation') {\n this.retainWebhookMethods.add(`${nameLC}|${parsed.method.toLowerCase()}`);\n } else if (!this.retainWebhookContainers.has(nameLC)) {\n this.retainWebhookContainers.add(nameLC);\n this.accumulateContainerFieldRefs(this.findWebhook(parsed.name));\n }\n\n this.retainReferencedPathItem(this.findWebhook(parsed.name));\n }\n\n /** Look up a Path Item by its path, ignoring key casing. */\n private findPathItem(path: string): PathItemObject | undefined {\n const pathLC = path.toLowerCase();\n const key = Object.keys(this.definition.paths || {}).find(candidate => candidate.toLowerCase() === pathLC);\n return key ? this.definition.paths?.[key] : undefined;\n }\n\n /** Look up a webhook Path Item by name, ignoring key casing. */\n private findWebhook(name: string): PathItemObject | undefined {\n if (!isOpenAPI31(this.definition) || !this.definition.webhooks) {\n return undefined;\n }\n\n const nameLC = name.toLowerCase();\n const key = Object.keys(this.definition.webhooks).find(candidate => candidate.toLowerCase() === nameLC);\n return key ? (this.definition.webhooks[key] as PathItemObject | undefined) : undefined;\n }\n\n /**\n * Accumulate `$ref` pointers from the Path Item fields we keep when a container is retained\n * (parameters, servers, summary, … — everything except HTTP operations).\n */\n private accumulateContainerFieldRefs(pathItem: PathItemObject | undefined): void {\n if (!pathItem) {\n return;\n }\n\n if (isRef(pathItem)) {\n this.$refs.add(pathItem.$ref);\n this.accumulateUsedRefs(this.definition, this.$refs, pathItem.$ref);\n return;\n }\n\n Object.entries(pathItem).forEach(([key, value]) => {\n if (supportedMethods.includes(key.toLowerCase() as HttpMethods) || value === undefined) {\n return;\n }\n\n this.queryForRefPointers(value).forEach(({ value: ref }) => {\n const refStr = this.toRefString(ref);\n if (!refStr) {\n return;\n }\n\n this.$refs.add(refStr);\n this.accumulateUsedRefs(this.definition, this.$refs, refStr);\n });\n });\n }\n\n /** Whether any `$ref` requires this path (or one of its operations) to remain. */\n private isPathRetainedByRef(pathLC: string): boolean {\n return (\n this.retainPathContainers.has(pathLC) ||\n Array.from(this.retainPathMethods).some(key => key.startsWith(`${pathLC}|`))\n );\n }\n\n /** Whether a `$ref` requires this specific path operation — or the entire Path Item — to remain. */\n private isPathOperationRetainedByRef(pathLC: string, methodLC: string): boolean {\n return this.retainPathMethods.has(`${pathLC}|*`) || this.retainPathMethods.has(`${pathLC}|${methodLC}`);\n }\n\n /**\n * Whether the path container must remain after its operations have been filtered. Whole-path\n * `$ref`s also keep the container (and its operations).\n */\n private isPathContainerKept(pathLC: string): boolean {\n return this.retainPathContainers.has(pathLC) || this.retainPathMethods.has(`${pathLC}|*`);\n }\n\n /** Whether any `$ref` requires this webhook (or one of its operations) to remain. */\n private isWebhookRetainedByRef(nameLC: string): boolean {\n return (\n this.retainWebhookContainers.has(nameLC) ||\n Array.from(this.retainWebhookMethods).some(key => key.startsWith(`${nameLC}|`))\n );\n }\n\n /** Whether a `$ref` requires this specific webhook operation — or the entire webhook — to remain. */\n private isWebhookOperationRetainedByRef(nameLC: string, methodLC: string): boolean {\n return this.retainWebhookMethods.has(`${nameLC}|*`) || this.retainWebhookMethods.has(`${nameLC}|${methodLC}`);\n }\n\n /**\n * Whether the webhook container must remain after its operations have been filtered.\n */\n private isWebhookContainerKept(nameLC: string): boolean {\n return this.retainWebhookContainers.has(nameLC) || this.retainWebhookMethods.has(`${nameLC}|*`);\n }\n\n /** Determine whether a path or webhook is excluded in the current transformation mode. */\n private isContainerExcluded(selection: OperationSelection, key: string): boolean {\n if (this.mode === 'prune') {\n return selection.matchesAll(key);\n }\n\n return !selection.has(key);\n }\n\n /**\n * Determine whether an operation passes the configured filters before cross-operation references\n * are considered.\n */\n private shouldRetainOperation(\n selection: OperationSelection,\n key: string,\n method: string,\n operation: OperationObject,\n ): boolean {\n if (this.mode === 'reduce') {\n // Reduction filters intersect, so an operation must match every configured filter.\n if (selection.hasSelections && !selection.matches(key, method)) return false;\n if (\n this.hasOperationIdSelection &&\n !this.operationIdSelection.has(Operation.getOperationId(key, method, operation))\n ) {\n return false;\n }\n if (this.hasTagSelection && !(operation.tags || []).some(tag => this.tagSelection.includes(tag.toLowerCase()))) {\n return false;\n }\n } else {\n // Pruning filters are additive, so matching any configured filter removes an operation.\n if (selection.hasSelections && selection.matches(key, method)) return false;\n if (\n this.hasOperationIdSelection &&\n this.operationIdSelection.has(Operation.getOperationId(key, method, operation))\n ) {\n return false;\n }\n if (this.hasTagSelection && (operation.tags || []).some(tag => this.tagSelection.includes(tag.toLowerCase()))) {\n return false;\n }\n }\n\n // No configured filter excluded this operation, so retain it in the transformed definition.\n return true;\n }\n\n /** Determine whether a path item contains at least one HTTP operation. */\n private hasOperations(pathItem: PathItemObject | undefined): boolean {\n return Boolean(pathItem && supportedMethods.some(method => method in pathItem));\n }\n\n /**\n * Accumulate any `$ref` pointers that are used by common Path Item parameters.\n *\n * @param parameters Common Path Item parameters to inspect for `$ref` pointers.\n */\n private accumulateParameterRefs(parameters: PathItemObject['parameters'] | undefined): void {\n if (!parameters) {\n return;\n }\n\n this.queryForRefPointers(parameters).forEach(({ value: ref }) => {\n const refStr = this.toRefString(ref);\n if (!refStr) {\n return;\n }\n\n this.$refs.add(refStr);\n this.accumulateUsedRefs(this.definition, this.$refs, refStr);\n });\n }\n\n /**\n * Walk through the `paths` in our OpenAPI definition and determine which operations we want to\n * retain. Accumulate any `$ref` pointers that they use so their referenced schemas can also be\n * retained in our resulting API definition.\n *\n */\n private walkPaths(): void {\n if (!('paths' in this.definition) || !this.definition.paths) {\n return;\n }\n\n Object.keys(this.definition.paths).forEach(path => {\n // When only webhooks were requested (no path/operation filter), ignore all paths, but don't\n // delete them yet because a selected webhook may reference one of their operations. We'll\n // remove any that aren't referenced later.\n if (this.mode === 'reduce' && this.hasWebhookSelection && !this.hasPathSelection) {\n return;\n } else if (this.hasPathSelection && this.isContainerExcluded(this.pathSelection, path)) {\n return;\n }\n\n const pathItem = this.definition.paths?.[path];\n\n /**\n * Referenced Path Items that remain in the result are preserved intact rather than partially\n * transformed. Retain the target and continue walking any local sibling fields so that we\n * retain their dependencies too.\n * @fixme Resolve referenced Path Items so their operations can be transformed individually.\n */\n if (isRef(pathItem)) {\n this.$refs.add(pathItem.$ref);\n this.accumulateUsedRefs(this.definition, this.$refs, pathItem.$ref);\n }\n\n // If this Path Item has no operations then it will remain in our resulting API definition,\n // so we need to retain any components referenced by its common parameters.\n if (!this.hasOperations(pathItem)) {\n this.accumulateParameterRefs(pathItem?.parameters);\n }\n\n Object.keys(pathItem || {}).forEach(method => {\n // Only process operations and retain any common path-level common properties like\n // `parameters`, `servers`, `summary`, etc.\n if (method === 'parameters' || !supportedMethods.includes(method.toLowerCase() as HttpMethods)) {\n return;\n }\n\n const operation = this.definition.paths?.[path]?.[method as HttpMethods] as OperationObject;\n if (!operation) {\n throw new Error(`Operation \\`${method} ${path}\\` not found`);\n }\n\n // If this operation isn't part of our resulting API definition then ignore it. We'll\n // remove it later.\n if (!this.shouldRetainOperation(this.pathSelection, path, method, operation)) {\n return;\n }\n\n (operation.tags || []).forEach((tag: string) => {\n this.usedTags.add(tag);\n });\n\n // Skipped by the `method === 'parameters'` guard above; accumulate here so refs are only\n // retained when at least one operation on this path passes all filters.\n this.accumulateParameterRefs(pathItem?.parameters);\n\n this.queryForRefPointers(operation).forEach(({ value: ref }) => {\n const refStr = this.toRefString(ref);\n if (!refStr) {\n return;\n }\n\n this.$refs.add(refStr);\n\n // Re-run through any `$ref` pointers that we found within this operation and search for\n // any `$ref` pointers that they also may be using. This also records `#/paths` and\n // `#/webhooks` targets so they are retained.\n this.accumulateUsedRefs(this.definition, this.$refs, refStr);\n });\n\n Object.values(operation.security || {}).forEach(sec => {\n Object.keys(sec).forEach(scheme => {\n this.retainSecurityScheme(scheme);\n });\n });\n });\n });\n }\n\n /**\n * Walk through the `webhooks` in our OpenAPI definition and determine which operations we want\n * to retain. Accumulate any `$ref` pointers that they use so their referenced schemas can also be\n * retained in our resulting API definition.\n *\n */\n private walkWebhooks() {\n if (!isOpenAPI31(this.definition)) {\n return;\n } else if (!('webhooks' in this.definition) || !this.definition.webhooks) {\n return;\n }\n\n const definition = this.definition satisfies OpenAPIV3_1.Document;\n\n Object.keys(definition.webhooks || {}).forEach(webhookName => {\n if (this.hasWebhookSelection && this.isContainerExcluded(this.webhookSelection, webhookName)) {\n return;\n }\n\n const webhook: PathItemObject | undefined = definition.webhooks?.[webhookName];\n if (!webhook || typeof webhook !== 'object') {\n return;\n }\n\n /**\n * Referenced webhook Path Items that remain in the result are preserved intact rather than\n * partially transformed. Retain the target and continue walking any local sibling fields so\n * that we retain their dependencies too.\n * @fixme Resolve referenced Path Items so their operations can be transformed individually.\n */\n if (typeof webhook.$ref === 'string') {\n this.$refs.add(webhook.$ref);\n this.accumulateUsedRefs(definition, this.$refs, webhook.$ref);\n }\n\n // If this webhook has no operations then it will remain in our resulting API definition, so\n // we need to retain any components referenced by its common parameters.\n if (!this.hasOperations(webhook)) {\n this.accumulateParameterRefs(webhook.parameters);\n }\n\n Object.keys(webhook).forEach(method => {\n // Only process operations and retain any common path-level common properties like\n // `parameters`, `servers`, `summary`, etc.\n if (method === 'parameters' || !supportedMethods.includes(method.toLowerCase() as HttpMethods)) {\n return;\n }\n\n const operation = webhook[method as HttpMethods] as OperationObject;\n if (!operation) {\n throw new Error(`Webhook operation \\`${method} ${webhookName}\\` not found`);\n }\n\n // If this operation isn't part of our resulting API definition then ignore it. We'll\n // remove it later.\n if (!this.shouldRetainOperation(this.webhookSelection, webhookName, method, operation)) {\n return;\n }\n\n (operation.tags || []).forEach((tag: string) => {\n this.usedTags.add(tag);\n });\n\n // Skipped by the `method === 'parameters'` guard above; accumulate here so refs are only\n // retained when at least one operation on this webhook passes all filters.\n this.accumulateParameterRefs(webhook.parameters);\n\n this.queryForRefPointers(operation).forEach(({ value: ref }) => {\n const refStr = this.toRefString(ref);\n if (!refStr) {\n return;\n }\n\n this.$refs.add(refStr);\n this.accumulateUsedRefs(definition, this.$refs, refStr);\n });\n\n Object.values(operation.security || {}).forEach(sec => {\n Object.keys(sec).forEach(scheme => {\n this.retainSecurityScheme(scheme);\n });\n });\n });\n });\n }\n\n /**\n * Transform our `paths` object according to the paths and operations that we've selected.\n */\n private transformPaths(): void {\n if (!('paths' in this.definition) || !this.definition.paths) {\n return;\n }\n\n Object.keys(this.definition.paths).forEach(path => {\n const pathLC = path.toLowerCase();\n const excludePathItem =\n (this.hasPathSelection && this.isContainerExcluded(this.pathSelection, path)) ||\n (this.mode === 'reduce' && this.hasWebhookSelection && !this.hasPathSelection);\n\n if (this.mode === 'prune' && excludePathItem) {\n if (this.isPathRetainedByRef(pathLC)) {\n throw new Error(`Cannot remove path \\`${path}\\` because one of its operations is referenced.`);\n }\n\n delete this.definition.paths?.[path];\n return;\n }\n\n const pathItem = this.definition.paths?.[path];\n\n /**\n * Referenced Path Items are preserved intact during operation-level filtering. If the whole\n * Path Item is excluded, remove it unless a surviving operation references it.\n * @fixme Resolve referenced Path Items so their operations can be transformed individually.\n */\n if (isRef(pathItem)) {\n if (excludePathItem && !this.isPathRetainedByRef(pathLC)) {\n delete this.definition.paths?.[path];\n }\n\n return;\n }\n\n let removedOperation = false;\n Object.keys(pathItem || {}).forEach(method => {\n const methodLC = method.toLowerCase();\n\n // Only process operations and retain any common path-level common properties like\n // `parameters`, `servers`, `summary`, etc.\n if (method === 'parameters' || !supportedMethods.includes(methodLC as HttpMethods)) {\n return;\n }\n\n const retainedByRef = this.isPathOperationRetainedByRef(pathLC, methodLC);\n\n const operation = this.definition.paths?.[path]?.[method as HttpMethods];\n if (!operation) {\n throw new Error(`Operation \\`${method} ${path}\\` not found`);\n }\n\n if (excludePathItem || !this.shouldRetainOperation(this.pathSelection, path, method, operation)) {\n if (this.mode === 'prune' && retainedByRef) {\n throw new Error(`Cannot remove operation \\`${method.toUpperCase()} ${path}\\` because it is referenced.`);\n }\n\n if (!retainedByRef) {\n delete this.definition.paths?.[path]?.[method as HttpMethods];\n removedOperation = true;\n return;\n }\n }\n\n // This operation remains in the transformed definition, so retain any components\n // referenced by its common Path Item parameters.\n this.accumulateParameterRefs(pathItem?.parameters);\n\n // Accumulate a list of used tags so we can filter out any ones that we don't need later.\n if ('tags' in operation) {\n operation.tags?.forEach((tag: string) => {\n this.usedTags.add(tag);\n });\n }\n\n // Accumulate any used operation-level security schemas that we need to retain.\n if ('security' in operation) {\n Object.values(operation.security || {}).forEach(sec => {\n Object.keys(sec).forEach(scheme => {\n this.retainSecurityScheme(scheme);\n });\n });\n }\n });\n\n // If filtering removed every operation from this path then remove its path-level properties\n // as well. We leave path items that were authored without operations untouched.\n if (\n !this.isPathContainerKept(pathLC) &&\n (((removedOperation || (this.mode === 'reduce' && excludePathItem)) && !this.hasOperations(pathItem)) ||\n (this.mode === 'reduce' && !Object.keys(this.definition.paths?.[path] || {}).length))\n ) {\n delete this.definition.paths?.[path];\n }\n });\n\n // If we don't have any paths left then retain the reducer's no-match error. An empty Paths\n // Object is valid OpenAPI so we allow it when pruning.\n if (!Object.keys(this.definition.paths || {}).length) {\n if (this.mode === 'reduce' && !(this.definition.webhooks && Object.keys(this.definition.webhooks).length)) {\n throw new Error(\n 'All paths in the API definition were removed. Did you supply the right path name to reduce by?',\n );\n }\n\n if (this.definition.webhooks && Object.keys(this.definition.webhooks).length) {\n delete this.definition.paths;\n }\n }\n }\n\n /**\n * Transform our `webhooks` object according to the webhooks and operations that we've selected.\n */\n private transformWebhooks(): void {\n if (!isOpenAPI31(this.definition)) {\n return;\n } else if (!('webhooks' in this.definition) || !this.definition.webhooks) {\n return;\n }\n\n const definition = this.definition satisfies OpenAPIV3_1.Document;\n\n Object.keys(definition.webhooks || {}).forEach(webhookName => {\n const nameLC = webhookName.toLowerCase();\n const excludeWebhook = this.hasWebhookSelection && this.isContainerExcluded(this.webhookSelection, webhookName);\n\n if (this.mode === 'prune' && excludeWebhook) {\n if (this.isWebhookRetainedByRef(nameLC)) {\n throw new Error(`Cannot remove webhook \\`${webhookName}\\` because one of its operations is referenced.`);\n }\n\n delete definition.webhooks?.[webhookName];\n return;\n }\n\n const webhook = definition.webhooks?.[webhookName];\n if (!webhook || typeof webhook !== 'object') {\n return;\n }\n\n /**\n * Referenced webhook Path Items are preserved intact during operation-level filtering. If\n * the whole webhook is excluded, remove it unless a surviving operation references it.\n * @fixme Resolve referenced Path Items so their operations can be transformed individually.\n */\n if (isRef(webhook)) {\n if (excludeWebhook && !this.isWebhookRetainedByRef(nameLC)) {\n delete definition.webhooks?.[webhookName];\n }\n\n return;\n }\n\n let removedOperation = false;\n Object.keys(webhook).forEach(method => {\n const methodLC = method.toLowerCase();\n if (method === 'parameters' || !supportedMethods.includes(methodLC as HttpMethods)) {\n return;\n }\n\n const operation = webhook[method as HttpMethods];\n if (!operation) {\n throw new Error(`Webhook operation \\`${method} ${webhookName}\\` not found`);\n }\n\n const retainedByRef = this.isWebhookOperationRetainedByRef(nameLC, methodLC);\n if (excludeWebhook || !this.shouldRetainOperation(this.webhookSelection, webhookName, method, operation)) {\n if (this.mode === 'prune' && retainedByRef) {\n throw new Error(\n `Cannot remove operation \\`${method.toUpperCase()} ${webhookName}\\` because it is referenced.`,\n );\n }\n\n if (!retainedByRef) {\n delete webhook[method as HttpMethods];\n removedOperation = true;\n return;\n }\n }\n\n // This operation remains in the transformed definition, so retain any components\n // referenced by its common Path Item parameters.\n this.accumulateParameterRefs(webhook.parameters);\n\n (operation.tags || []).forEach((tag: string) => {\n this.usedTags.add(tag);\n });\n\n Object.values(operation.security || {}).forEach(sec => {\n Object.keys(sec).forEach(scheme => {\n this.retainSecurityScheme(scheme);\n });\n });\n });\n\n if (\n !this.isWebhookContainerKept(nameLC) &&\n (((removedOperation || (this.mode === 'reduce' && excludeWebhook)) && !this.hasOperations(webhook)) ||\n (this.mode === 'reduce' && !Object.keys(definition.webhooks?.[webhookName] || {}).length))\n ) {\n delete definition.webhooks?.[webhookName];\n }\n });\n\n if (definition.webhooks && !Object.keys(definition.webhooks).length) {\n delete definition.webhooks;\n }\n }\n}\n","/**\n * Track selected HTTP operations within OpenAPI paths or webhooks. Container keys and HTTP methods\n * are matched without regard to casing.\n */\nexport class OperationSelection {\n private selections: Map<string, '*' | Set<string>> = new Map();\n\n /** Whether any paths or webhooks have been selected. */\n get hasSelections(): boolean {\n return this.selections.size > 0;\n }\n\n /**\n * Select every operation within a path or webhook.\n *\n * @param key Path or webhook key whose operations should be selected.\n */\n addAll(key: string): void {\n this.selections.set(this.normalize(key), '*');\n }\n\n /**\n * Add an operation to the selection for a path or webhook. If every operation for the key is\n * already selected, that selection remains unchanged.\n *\n * @param key Path or webhook key that contains the operation.\n * @param method HTTP method of the operation to select.\n */\n addOperation(key: string, method: string): void {\n const normalizedKey = this.normalize(key);\n const normalizedMethod = this.normalize(method);\n const selection = this.selections.get(normalizedKey);\n\n if (selection === '*') {\n return;\n }\n\n if (selection instanceof Set) {\n selection.add(normalizedMethod);\n return;\n }\n\n this.selections.set(normalizedKey, new Set([normalizedMethod]));\n }\n\n /**\n * Clear every operation selection for a path or webhook.\n *\n * @param key Path or webhook key to clear.\n */\n clear(key: string): void {\n this.selections.delete(this.normalize(key));\n }\n\n /**\n * Determine whether a path or webhook has any selected operations.\n *\n * @param key Path or webhook key to check.\n */\n has(key: string): boolean {\n return this.selections.has(this.normalize(key));\n }\n\n /**\n * Determine whether every operation within a path or webhook is selected.\n *\n * @param key Path or webhook key to check.\n */\n matchesAll(key: string): boolean {\n return this.selections.get(this.normalize(key)) === '*';\n }\n\n /**\n * Determine whether an operation is selected.\n *\n * @param key Path or webhook key that contains the operation.\n * @param method HTTP method of the operation to check.\n */\n matches(key: string, method: string): boolean {\n const selection = this.selections.get(this.normalize(key));\n return selection === '*' || Boolean(selection?.has(this.normalize(method)));\n }\n\n /** Normalize path, webhook, and method casing for comparisons. */\n private normalize(value: string): string {\n return value.toLowerCase();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAUA,OAAO,iBAAiB;;;ACNjB,IAAM,qBAAN,MAAyB;AAAA,EACtB,aAA6C,oBAAI,IAAI;AAAA;AAAA,EAG7D,IAAI,gBAAyB;AAC3B,WAAO,KAAK,WAAW,OAAO;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,KAAmB;AACxB,SAAK,WAAW,IAAI,KAAK,UAAU,GAAG,GAAG,GAAG;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,aAAa,KAAa,QAAsB;AAC9C,UAAM,gBAAgB,KAAK,UAAU,GAAG;AACxC,UAAM,mBAAmB,KAAK,UAAU,MAAM;AAC9C,UAAM,YAAY,KAAK,WAAW,IAAI,aAAa;AAEnD,QAAI,cAAc,KAAK;AACrB;AAAA,IACF;AAEA,QAAI,qBAAqB,KAAK;AAC5B,gBAAU,IAAI,gBAAgB;AAC9B;AAAA,IACF;AAEA,SAAK,WAAW,IAAI,eAAe,oBAAI,IAAI,CAAC,gBAAgB,CAAC,CAAC;AAAA,EAChE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,KAAmB;AACvB,SAAK,WAAW,OAAO,KAAK,UAAU,GAAG,CAAC;AAAA,EAC5C;AAAA;AAAA;AAAA;AAA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