@redocly/cli 2.57.0 → 2.58.1
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.
- package/README.md +2 -0
- package/THIRD_PARTY_NOTICES +45 -23
- package/lib/chunks/{YEACSN2C.js → 263OU3EK.js} +1 -1
- package/lib/chunks/2CAHRLJ3.js +22 -0
- package/lib/chunks/{FDOONAMV.js → 4R5JMLPR.js} +1 -1
- package/lib/chunks/{GVJFU4AP.js → 4U5QHDPF.js} +1 -1
- package/lib/chunks/{MZWBJKK2.js → 4WEATF5W.js} +1 -1
- package/lib/chunks/{7EB22KXX.js → 4Y6NCJUT.js} +1 -1
- package/lib/chunks/{XYKNLM5G.js → 5TPCSTMC.js} +1 -1
- package/lib/chunks/{R2FG6TUX.js → 6MXKU6BN.js} +1 -1
- package/lib/chunks/{OR3KBRCI.js → 6NXEK35A.js} +1 -1
- package/lib/chunks/6VBDC3HP.js +13 -0
- package/lib/chunks/{J3DL5HGI.js → 7HGHXQBL.js} +1 -1
- package/lib/chunks/{GHOLYNZA.js → 7INWM6QM.js} +1 -1
- package/lib/chunks/{VBHLPG5Q.js → AW5K6TIG.js} +1 -1
- package/lib/chunks/{H5OX3UOD.js → B2Q7DOT4.js} +1 -1
- package/lib/chunks/{UXFJO2OQ.js → BNNOQCQA.js} +1 -1
- package/lib/chunks/{XTTR5PBC.js → BQBQIRKC.js} +1 -1
- package/lib/chunks/{CWEET26O.js → BWDHENL3.js} +1 -1
- package/lib/chunks/{P7A7BCIN.js → CMHJY4T2.js} +1 -1
- package/lib/chunks/{LUW2ZJJO.js → CTTC32GG.js} +1 -1
- package/lib/chunks/{LI6IH6DJ.js → DEZGXWTS.js} +1 -1
- package/lib/chunks/{F57WBWGV.js → DTH2KLMU.js} +2 -2
- package/lib/chunks/{VT3BHT6S.js → ENBAORPS.js} +3 -3
- package/lib/chunks/{VIPV4IEH.js → FYDETXDC.js} +1 -1
- package/lib/chunks/{YDVOCOBI.js → GACZ2YWU.js} +1 -1
- package/lib/chunks/H4NHEW6K.js +9 -0
- package/lib/chunks/H4VN2RX3.js +7 -0
- package/lib/chunks/{ZVXAH4QD.js → H67F6VQQ.js} +1 -1
- package/lib/chunks/{65AQJO4M.js → IBYLYDST.js} +2 -2
- package/lib/chunks/{AOCVSFC3.js → IXAUPJML.js} +1 -1
- package/lib/chunks/JD3HIQIK.js +193 -0
- package/lib/chunks/{VUU57INZ.js → JFQX5N4D.js} +1 -1
- package/lib/chunks/{664FDTDV.js → JIN2S34E.js} +1 -1
- package/lib/chunks/{5FVKAWNE.js → K3GO5B32.js} +1 -1
- package/lib/chunks/{S5PUZGYS.js → K4HCHGLF.js} +1 -1
- package/lib/chunks/{3QGJWJKQ.js → K4MJBKZB.js} +1 -1
- package/lib/chunks/{YMDFCK3F.js → KIUUH6YY.js} +1 -1
- package/lib/chunks/{4SXCDBB7.js → KMRFAGWI.js} +1 -1
- package/lib/chunks/{SRCGYHDN.js → KRKCMWGM.js} +1 -1
- package/lib/chunks/{MKS4O6F4.js → LHKIMOHX.js} +2 -2
- package/lib/chunks/LRFPMBTV.js +7 -0
- package/lib/chunks/{X5NXRMUW.js → M7T6N7AK.js} +1 -1
- package/lib/chunks/ML6MFXCA.js +7 -0
- package/lib/chunks/{VE7VT5PT.js → MSKEZAFV.js} +1 -1
- package/lib/chunks/{D7WNH6Z5.js → MULE7RHG.js} +1 -1
- package/lib/chunks/{WKCOTH3C.js → MVXFJBMU.js} +1 -1
- package/lib/chunks/NMS2HUB3.js +7 -0
- package/lib/chunks/{GEWI247R.js → NX3RWANU.js} +1 -1
- package/lib/chunks/{EDU3YBRA.js → PI42YPSD.js} +1 -1
- package/lib/chunks/{52MXI4PU.js → PJXZKT3O.js} +1 -1
- package/lib/chunks/{Y2AFRRAT.js → PY4MYMQT.js} +1 -1
- package/lib/chunks/{DMW5VJBT.js → PZF2WPD3.js} +1 -1
- package/lib/chunks/Q4ESEW3O.js +160 -0
- package/lib/chunks/{YOBULQYM.js → QK7R3ZTY.js} +1 -1
- package/lib/chunks/{ZFJHZEI3.js → R2IHROCG.js} +1 -1
- package/lib/chunks/{N2GTHB37.js → ROQ7FTVG.js} +1 -1
- package/lib/chunks/RVRYLTME.js +17 -0
- package/lib/chunks/{ZBOUASE7.js → RW4XUFPU.js} +1 -1
- package/lib/chunks/SQUNMRDS.js +9 -0
- package/lib/chunks/T2G7FRCU.js +23 -0
- package/lib/chunks/{4HG5PCQA.js → TDNSQRQT.js} +1 -1
- package/lib/chunks/{QDSAT32N.js → TGAC4ILD.js} +1 -1
- package/lib/chunks/{7XKYPQPI.js → URZNERQS.js} +1 -1
- package/lib/chunks/{F5V42ZYY.js → V2PTVECL.js} +1 -1
- package/lib/chunks/{4JBK2BSL.js → VJQJVOIN.js} +1 -1
- package/lib/chunks/{IDI3SURO.js → WDWS64N7.js} +1 -1
- package/lib/chunks/{NALRPITK.js → WSDNWUOV.js} +1 -1
- package/lib/chunks/{JMFIKCPX.js → WYZDPMVU.js} +1 -1
- package/lib/chunks/{5UDC2SWY.js → XTW63JDM.js} +1 -1
- package/lib/chunks/YURX7H3N.js +15 -0
- package/lib/chunks/{DT66L2TO.js → YZRKJF2V.js} +1 -1
- package/lib/chunks/Z7JI42WA.js +31 -0
- package/lib/chunks/ZIIE7LXR.js +34 -0
- package/lib/chunks/index.aff +205 -0
- package/lib/chunks/index.dic +49569 -0
- package/lib/eject-assets/generators/cli/docs.ts +1 -1
- package/lib/eject-assets/generators/cli/engine-source.ts +1 -1
- package/lib/eject-assets/generators/cli/index.ts +2 -2
- package/lib/eject-assets/generators/cli/render.ts +1 -1
- package/lib/eject-assets/generators/go/client.ts +1 -1
- package/lib/eject-assets/generators/go/descriptor.ts +1 -1
- package/lib/eject-assets/generators/go/index.ts +2 -2
- package/lib/eject-assets/generators/go/models.ts +1 -1
- package/lib/eject-assets/generators/go/naming.ts +1 -1
- package/lib/eject-assets/generators/go/operations.ts +1 -1
- package/lib/eject-assets/generators/go/pagination.ts +1 -1
- package/lib/eject-assets/generators/go/types.ts +1 -1
- package/lib/eject-assets/generators/mock/faker.ts +1 -1
- package/lib/eject-assets/generators/mock/index.ts +2 -2
- package/lib/eject-assets/generators/mock/render.ts +1 -1
- package/lib/eject-assets/generators/mock/sample.ts +1 -1
- package/lib/eject-assets/generators/mock/values.ts +1 -1
- package/lib/eject-assets/generators/php/client.ts +1 -1
- package/lib/eject-assets/generators/php/descriptor.ts +1 -1
- package/lib/eject-assets/generators/php/index.ts +2 -2
- package/lib/eject-assets/generators/php/models.ts +1 -1
- package/lib/eject-assets/generators/php/naming.ts +1 -1
- package/lib/eject-assets/generators/php/operations.ts +1 -1
- package/lib/eject-assets/generators/php/pagination.ts +1 -1
- package/lib/eject-assets/generators/php/types.ts +1 -1
- package/lib/eject-assets/generators/python/client.ts +1 -1
- package/lib/eject-assets/generators/python/descriptor.ts +1 -1
- package/lib/eject-assets/generators/python/index.ts +2 -2
- package/lib/eject-assets/generators/python/models.ts +1 -1
- package/lib/eject-assets/generators/python/naming.ts +1 -1
- package/lib/eject-assets/generators/python/operations.ts +1 -1
- package/lib/eject-assets/generators/python/pagination.ts +1 -1
- package/lib/eject-assets/generators/python/types.ts +1 -1
- package/lib/eject-assets/generators/swr/index.ts +2 -2
- package/lib/eject-assets/generators/swr/render.ts +1 -1
- package/lib/eject-assets/generators/tanstack-query/index.ts +2 -2
- package/lib/eject-assets/generators/tanstack-query/render.ts +1 -1
- package/lib/eject-assets/generators/transformers/index.ts +2 -2
- package/lib/eject-assets/generators/transformers/render.ts +1 -1
- package/lib/eject-assets/generators/typescript/banner.ts +1 -1
- package/lib/eject-assets/generators/typescript/client.ts +1 -1
- package/lib/eject-assets/generators/typescript/descriptor.ts +1 -1
- package/lib/eject-assets/generators/typescript/index.ts +2 -2
- package/lib/eject-assets/generators/typescript/inline-runtime.ts +1 -1
- package/lib/eject-assets/generators/typescript/operation-signature.ts +1 -1
- package/lib/eject-assets/generators/typescript/operation-types.ts +1 -1
- package/lib/eject-assets/generators/typescript/operations.ts +1 -1
- package/lib/eject-assets/generators/typescript/response-headers.ts +1 -1
- package/lib/eject-assets/generators/typescript/type-guards.ts +1 -1
- package/lib/eject-assets/generators/typescript/types.ts +1 -1
- package/lib/eject-assets/generators/zod/index.ts +2 -2
- package/lib/eject-assets/generators/zod/schemas.ts +1 -1
- package/lib/index.js +66 -61
- package/package.json +1 -1
- package/lib/chunks/2PGNW76R.js +0 -11
- package/lib/chunks/3I7XLHPY.js +0 -45
- package/lib/chunks/ARDTVDGR.js +0 -22
- package/lib/chunks/K2ENYHHD.js +0 -7
- package/lib/chunks/LJPUHAWE.js +0 -13
- package/lib/chunks/M4YE5ALG.js +0 -193
- package/lib/chunks/OM4VGI2Q.js +0 -9
- package/lib/chunks/VYHYEZI5.js +0 -7
- package/lib/chunks/YFI3NLJF.js +0 -9
- package/lib/chunks/YUNIBLZR.js +0 -30
package/README.md
CHANGED
|
@@ -66,6 +66,8 @@ npx skills add https://redocly.com
|
|
|
66
66
|
- `redocly-cli` — day-to-day usage: lint, bundle, decorate, build docs, test, and generate a client.
|
|
67
67
|
- `redocly-lint-rules` — turn a check written in plain language into a built-in rule, a configurable rule, or a custom plugin.
|
|
68
68
|
It also covers migrating rules from other linters, such as Spectral.
|
|
69
|
+
- `recheck-lint` — run `redocly recheck` on the Markdown the assistant touched, fix what it finds, and never suppress findings to pass.
|
|
70
|
+
- `recheck-config` — write and tune the `recheck` block in `redocly.yaml` from measured counts, and adopt a baseline on a large document set.
|
|
69
71
|
|
|
70
72
|
## Common tasks
|
|
71
73
|
|
package/THIRD_PARTY_NOTICES
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
Third-party software bundled in @redocly/cli
|
|
2
2
|
|
|
3
|
+
============================================================
|
|
4
|
+
(MIT AND BSD)
|
|
5
|
+
|
|
6
|
+
Packages:
|
|
7
|
+
dictionary-en@4.0.0
|
|
8
|
+
|
|
9
|
+
License text:
|
|
10
|
+
(no license text found)
|
|
11
|
+
|
|
3
12
|
============================================================
|
|
4
13
|
(MPL-2.0 OR Apache-2.0)
|
|
5
14
|
|
|
@@ -655,16 +664,18 @@ Packages:
|
|
|
655
664
|
@redocly/ajv@8.18.3 — Copyright (c) 2015-2021 Evgeny Poberezkin
|
|
656
665
|
@redocly/cli-otel@0.3.7 — Copyright 2025 Redocly Inc, all rights reserved.
|
|
657
666
|
@redocly/config@0.22.0 — Copyright 2024 Redocly Inc.
|
|
658
|
-
@redocly/config@0.
|
|
667
|
+
@redocly/config@0.61.1 — Copyright 2024 Redocly Inc.
|
|
659
668
|
@redocly/openapi-core@1.34.20
|
|
660
669
|
agent-base@7.1.4 — Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
|
661
670
|
ajv-formats@3.0.1 — Copyright (c) 2020 Evgeny Poberezkin
|
|
662
671
|
ajv@8.20.0 — Copyright (c) 2015-2021 Evgeny Poberezkin
|
|
672
|
+
ansi-regex@6.4.0
|
|
663
673
|
ansi-styles@4.3.0
|
|
664
674
|
balanced-match@1.0.2 — Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
|
665
675
|
brace-expansion@2.1.4 — Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
|
666
676
|
call-me-maybe@1.0.2 — Copyright (c) 2015 Eric McCarthy
|
|
667
677
|
chalk@4.1.2
|
|
678
|
+
character-entities@2.0.2
|
|
668
679
|
classnames@2.5.1 — Copyright (c) 2018 Jed Watson
|
|
669
680
|
clsx@2.1.1
|
|
670
681
|
color-convert@2.0.1 — Copyright (c) 2011-2016 Heather Arthur <fayearthur@gmail.com>
|
|
@@ -675,17 +686,21 @@ Packages:
|
|
|
675
686
|
cookie@0.7.2 — Copyright (c) 2012-2014 Roman Shtylman <shtylman@gmail.com>
|
|
676
687
|
cross-spawn@7.0.6 — Copyright (c) 2018 Made With MOXY Lda <hello@moxy.studio>
|
|
677
688
|
debug@4.4.3 — Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca>
|
|
689
|
+
decode-named-character-reference@1.3.0
|
|
678
690
|
escalade@3.2.0
|
|
679
691
|
eventemitter3@5.0.1 — Copyright (c) 2014 Arnout Kazemier
|
|
680
692
|
eventsource-parser@3.1.1 — Copyright (c) 2026 Espen Hovlandsdal <espen@hovlandsdal.com>
|
|
681
693
|
eventsource@3.0.7 — Copyright (c) EventSource GitHub organisation
|
|
682
694
|
fast-deep-equal@3.1.3 — Copyright (c) 2017 Evgeny Poberezkin
|
|
683
695
|
fast-safe-stringify@2.1.1 — Copyright (c) 2016 David Mark Clements
|
|
696
|
+
fault@2.0.1
|
|
684
697
|
foreach@2.0.6 — Copyright (c) 2013 Manuel Stofer
|
|
698
|
+
get-east-asian-width@1.7.0
|
|
685
699
|
graphql@16.14.2 — Copyright (c) GraphQL Contributors
|
|
686
700
|
handlebars@4.7.9 — Copyright (C) 2011-2019 by Yehuda Katz
|
|
687
701
|
has-flag@4.0.0
|
|
688
702
|
https-proxy-agent@7.0.6 — Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
|
703
|
+
is-buffer@2.0.5 — Copyright (c) Feross Aboukhadijeh
|
|
689
704
|
js-levenshtein@1.1.6 — Copyright (c) 2017 Gustaf Andersson
|
|
690
705
|
js-tokens@4.0.0 — Copyright (c) 2014, 2015, 2016, 2017, 2018 Simon Lydell
|
|
691
706
|
js-yaml@4.3.2 — Copyright (C) 2011-2015 by Vitaly Puzrin
|
|
@@ -696,16 +711,41 @@ Packages:
|
|
|
696
711
|
leven@3.1.0
|
|
697
712
|
lunr@2.3.9 — Copyright (C) 2013 by Oliver Nightingale
|
|
698
713
|
mark.js@8.11.1 — Copyright (c) 2014–2018 Julian Kühnel
|
|
714
|
+
micromark-core-commonmark@2.0.4
|
|
715
|
+
micromark-extension-directive@4.0.0
|
|
716
|
+
micromark-extension-frontmatter@2.0.0
|
|
717
|
+
micromark-extension-gfm-autolink-literal@2.1.0
|
|
718
|
+
micromark-extension-gfm-footnote@2.1.0
|
|
719
|
+
micromark-extension-gfm-table@2.1.2
|
|
720
|
+
micromark-extension-math@3.1.0
|
|
721
|
+
micromark-factory-destination@2.0.1
|
|
722
|
+
micromark-factory-label@2.0.1
|
|
723
|
+
micromark-factory-space@2.1.0
|
|
724
|
+
micromark-factory-title@2.0.1
|
|
725
|
+
micromark-factory-whitespace@2.0.1
|
|
726
|
+
micromark-util-character@2.1.1
|
|
727
|
+
micromark-util-chunked@2.0.1
|
|
728
|
+
micromark-util-classify-character@2.0.1
|
|
729
|
+
micromark-util-combine-extensions@2.0.1
|
|
730
|
+
micromark-util-edit-map@1.0.0
|
|
731
|
+
micromark-util-html-tag-name@2.0.1
|
|
732
|
+
micromark-util-normalize-identifier@2.0.1
|
|
733
|
+
micromark-util-resolve-all@2.0.1
|
|
734
|
+
micromark-util-subtokenize@2.1.0
|
|
735
|
+
micromark-util-symbol@2.0.1
|
|
736
|
+
micromark@4.0.3
|
|
699
737
|
mobx-react-lite@4.1.1 — Copyright (c) 2015 Michel Weststrate
|
|
700
738
|
mobx-react@9.2.0 — Copyright (c) 2015 Michel Weststrate
|
|
701
739
|
mobx@6.12.3 — Copyright (c) 2015 Michel Weststrate
|
|
702
740
|
ms@2.1.3
|
|
741
|
+
nspell@2.1.5
|
|
703
742
|
object-assign@4.1.1
|
|
704
743
|
openapi-sampler@1.7.5 — Copyright (c) 2017 Roman Hotsiy <gotsijroman@gmail.com>
|
|
705
744
|
outdent@0.8.0 — Copyright (c) 2016 Andrew Bradley
|
|
706
745
|
path-key@3.1.1
|
|
707
746
|
perfect-scrollbar@1.5.6 — Copyright (c) 2012-2019 Hyunje Jun, MDBootstrap.com and other contributors
|
|
708
747
|
picomatch@4.0.4 — Copyright (c) 2017-present, Jon Schlinkert.
|
|
748
|
+
picomatch@4.0.7 — Copyright (c) 2017-present, Jon Schlinkert.
|
|
709
749
|
pkce-challenge@5.0.1 — Copyright (c) 2019
|
|
710
750
|
pluralize@8.0.0 — Copyright (c) 2013 Blake Embrey (hello@blakeembrey.com)
|
|
711
751
|
polished@4.3.1 — Copyright (c) 2016-Present Brian Hough and Maximilian Stoiber
|
|
@@ -720,6 +760,8 @@ Packages:
|
|
|
720
760
|
shebang-command@2.0.0
|
|
721
761
|
shebang-regex@3.0.0
|
|
722
762
|
slugify@1.4.7 — Copyright (c) Simeon Velichkov <simeonvelichkov@gmail.com>
|
|
763
|
+
string-width@8.3.0
|
|
764
|
+
strip-ansi@7.2.0
|
|
723
765
|
styled-components@6.4.2 — Copyright (c) 2016-present Glen Maddern and Maximilian Stoiber
|
|
724
766
|
stylis@4.3.6 — Copyright (c) 2016-present Sultan Tarimo
|
|
725
767
|
supports-color@7.2.0
|
|
@@ -739,28 +781,8 @@ unknown
|
|
|
739
781
|
|
|
740
782
|
Packages:
|
|
741
783
|
decko@1.2.0 — Copyright (c) 2017 Jason Miller
|
|
784
|
+
format@0.2.2
|
|
742
785
|
stickyfill@1.1.1 — Copyright (c) 2014 Oleg Korsunsky
|
|
743
786
|
|
|
744
787
|
License text:
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
Copyright (c) 2014 Oleg Korsunsky
|
|
748
|
-
Copyright (c) 2014 Automattic Inc.
|
|
749
|
-
|
|
750
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
751
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
752
|
-
in the Software without restriction, including without limitation the rights
|
|
753
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
754
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
755
|
-
furnished to do so, subject to the following conditions:
|
|
756
|
-
|
|
757
|
-
The above copyright notice and this permission notice shall be included in
|
|
758
|
-
all copies or substantial portions of the Software.
|
|
759
|
-
|
|
760
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
761
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
762
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
763
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
764
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
765
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
766
|
-
THE SOFTWARE.
|
|
788
|
+
(no license text found)
|
|
@@ -4,5 +4,5 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{
|
|
7
|
+
import{ga as t}from"./JD3HIQIK.js";import*as e from"node:process";var o=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],n=class{frames;currentFrame;intervalId;message;constructor(){this.frames=o,this.currentFrame=0,this.intervalId=null,this.message=""}showFrame(){t.info("\r"+this.frames[this.currentFrame]+" "+this.message),this.currentFrame=(this.currentFrame+1)%this.frames.length}start(r){if(this.message!==r){if(this.message=r,!e.stderr.isTTY){t.info(`${r}...
|
|
8
8
|
`);return}this.intervalId===null&&(this.intervalId=setInterval(()=>{this.showFrame()},100))}}stop(){this.intervalId!==null&&(clearInterval(this.intervalId),this.intervalId=null,t.info("\r")),this.message=""}};function h(i){i.stop(),e.stderr.isTTY&&t.info("\x1B[2K")}function m(i,r){let[s]=r.inFlight;if(!s)return;let a=r.inFlight.size>1?` (+${r.inFlight.size-1} more)`:"";i.start(`[${r.position}/${r.total}] ${r.action} ${s}${a}`)}export{n as a,h as b,m as c};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import{a as ye,e as ve,f as Se,g as we,h as O,i as Re,k,l as A,m as Ie,n as Pe,v as be,w as Oe}from"./MVXFJBMU.js";import{$ as E,J as ot,T as ce,W as at,X as pe,Y as g,Z as $,_ as de,aa as q,c as d,ca as S,ea as v,ga as R,ha as le,ia as fe,ja as me,ka as he,pa as ge,q as ae,v as ue}from"./JD3HIQIK.js";import{e as oe}from"./RFWIIJFG.js";import ke from"node:path";function I(t){return t?t.trim():""}function B(t){let e=I(t.operationId)||I(t.path);return[I(t.ruleId),I(t.severity),I(t.message),e,I(t.target),I(t.schemaPath)].join("")}var _=t=>pe(S(t));function ut(t){return t==="error"?"error":t==="warning"?"warning":"note"}function ct(t){if(t==null)return"";let e=String(t);return!e.includes(",")&&!e.includes('"')&&!e.includes(`
|
|
8
|
+
`)?e:`"${e.replace(/"/g,'""')}"`}function pt(t){return ke.isAbsolute(t)?ke.relative(process.cwd(),t)||".":t}function dt(t){if(!t)return null;let e=t.operationPathTemplate;return typeof e=="string"&&e.length>0?e:null}function lt(t){return Object.entries(t).sort((e,r)=>{let n=r[1]-e[1];return n!==0?n:e[0].localeCompare(r[0])})}function ft(t){let e=[],r=new Map;for(let n of t){let s=B({ruleId:n.ruleId,severity:n.severity,message:n.message,operationId:n.operationId,path:n.path,target:n.target,schemaPath:n.schemaPath}),i=r.get(s);if(i!==void 0){e[i].occurrences+=1;continue}r.set(s,e.length),e.push({finding:n,occurrences:1})}return e}function mt(t){let e=ft(t.findings).map(n=>({occurrences:n.occurrences,exchangeIndex:n.finding.exchangeIndex,ruleId:n.finding.ruleId,severity:n.finding.severity,category:n.finding.category,message:n.finding.message,operationId:n.finding.operationId,specSource:n.finding.specSource,target:n.finding.target,schemaPath:n.finding.schemaPath,dataPath:n.finding.dataPath,details:n.finding.details,method:n.finding.method,url:n.finding.url,path:n.finding.path,status:n.finding.status})),r={run:{id:t.runId,specSource:t.meta.specSource,trafficPath:t.meta.trafficPath,format:t.meta.format,matchMode:t.meta.matchMode,server:t.meta.server,totalExchanges:t.summary.totalExchanges,documentedExchanges:t.summary.documentedExchanges,undocumentedExchanges:t.summary.undocumentedExchanges,skippedExchanges:t.summary.skippedExchanges,findingsBySeverity:t.summary.findingsBySeverity,findingsByRule:t.summary.findingsByRule,totalProblems:t.summary.totalProblemGroups,durationMs:t.summary.durationMs},problems:e};return`${JSON.stringify(r,null,2)}
|
|
9
|
+
`}function ht(t){let e=["run_id","finding_id","exchange_index","severity","category","rule_id","message","method","path","url","status","operation_id","spec_source","target","schema_path","data_path"],r=t.findings.map(s=>[t.runId,s.id,s.exchangeIndex,s.severity,s.category,s.ruleId,s.message,s.method,s.path,s.url,s.status,s.operationId,s.specSource,s.target,s.schemaPath,s.dataPath]);return`${[e,...r].map(s=>s.map(ct).join(",")).join(`
|
|
10
|
+
`)}
|
|
11
|
+
`}function gt(t){let e=new Map;for(let s of t.findings)e.has(s.ruleId)||e.set(s.ruleId,{id:s.ruleId,name:s.ruleId,shortDescription:{text:`${s.category} detection`}});let r=t.findings.map(s=>{let i=s.specSource??s.url??void 0;return{ruleId:s.ruleId,level:ut(s.severity),message:{text:s.message},locations:i?[{physicalLocation:{artifactLocation:{uri:i}}}]:void 0,properties:{runId:t.runId,exchangeIndex:s.exchangeIndex,method:s.method,path:s.path,status:s.status,operationId:s.operationId,target:s.target,schemaPath:s.schemaPath,dataPath:s.dataPath}}}),n={$schema:"https://json.schemastore.org/sarif-2.1.0.json",version:"2.1.0",runs:[{tool:{driver:{name:"drift",rules:Array.from(e.values())}},results:r}]};return`${JSON.stringify(n,null,2)}
|
|
12
|
+
`}function yt(t){return t.findingsBySeverity.error+t.findingsBySeverity.warning+t.findingsBySeverity.info}function vt(t){return t>=500?$:t>=400?E:t>=300?q:t>=200?de:v}function St(t,e,r){let n=(f,h)=>e?h(f):f,s=f=>f==="error"?n("\u2716",$):f==="warning"?n("\u25B2",E):n("\u25CF",q),i=f=>f==="error"?n("ERROR",$):f==="warning"?n("WARN",E):n("INFO",q),{summary:o,meta:a}=t,c=yt(o),l=o.previewFindings.slice(0,r),u=[];if(u.push(n("\u250F\u2501 Drift Report",_)),u.push(`\u2503 Run: ${t.runId}`),u.push(`\u2503 Spec: ${a.specSource}`),u.push(`\u2503 Traffic: ${a.trafficPath}`),u.push(a.server?`\u2503 Server: ${a.server} (overrides description servers)`:`\u2503 Match mode: ${a.matchMode}`),u.push(`\u2503 Traffic format: ${a.format}${a.format==="auto"?" (auto-detect)":""}`),u.push(`\u2503 Exchanges: total=${o.totalExchanges} documented=${o.documentedExchanges} undocumented=${o.undocumentedExchanges}${o.skippedExchanges>0?` skipped=${o.skippedExchanges}`:""}`),u.push(`\u2503 Findings: total=${c} ${n(`error=${o.findingsBySeverity.error}`,$)} ${n(`warning=${o.findingsBySeverity.warning}`,E)} ${n(`info=${o.findingsBySeverity.info}`,q)}`),u.push(`\u2503 Problems: total=${o.totalProblemGroups}`),u.push(`\u2517 Duration: ${o.durationMs}ms`),c===0)return u.push(""),u.push(n("\u2714 No findings.",S)),`${u.join(`
|
|
13
|
+
`)}
|
|
14
|
+
`;u.push(""),u.push(n(`Types (${Object.keys(o.problemGroupsByRule).length})`,_));for(let[f,h]of lt(o.problemGroupsByRule)){let y=o.findingsByRule[f]??h;u.push(` ${n("\u2022",v)} ${f}: ${h} problems / ${y} findings`)}let m=new Map;for(let f of l)m.has(f.ruleId)||m.set(f.ruleId,[]),m.get(f.ruleId).push(f);let w=Array.from(m.keys()).sort((f,h)=>{let y=(o.problemGroupsByRule[h]??0)-(o.problemGroupsByRule[f]??0);return y!==0?y:f.localeCompare(h)});u.push(""),u.push(n(`Problems by type (showing first ${l.length} of ${o.totalProblemGroups})`,_));let j=0;for(let f of w){let h=m.get(f);if(!h||h.length===0)continue;let y=o.problemGroupsByRule[f]??h.length,Y=o.findingsByRule[f]??y;u.push(""),u.push(`${n("\u25C9",S)} ${n(f,_)} ${n(`(${h.length} problems shown / ${y} total, ${Y} findings)`,v)}`);for(let p of h){j+=1;let re=p.occurrences,nt=p.status!==void 0?n(String(p.status),vt(p.status)):n("-",v),rt=dt(p.details)??p.path,st=p.operationId?` ${n(p.operationId,g)}`:"";if(u.push(`${s(p.severity)} ${i(p.severity)} #${j}${re>1?` ${n(`\xD7${re}`,v)}`:""} ${n("\u2192",v)} ${p.message}`),u.push(` \u21B3 sample exchange=${p.exchangeIndex} ${n(p.method,S)} ${rt} (${nt})${st}`),u.push(""),u.push(` ${n(p.url,v)}`),(p.specSource||p.schemaPath||p.dataPath)&&(u.push(""),p.specSource&&u.push(` ${n("spec:",g)} ${n(pt(p.specSource),S)}`),p.schemaPath&&u.push(` ${n("schemaPath=",g)} ${n(p.schemaPath,g)}`),p.dataPath&&u.push(` ${n("dataPath=",g)} ${n(p.dataPath,S)}`)),p.details)if(u.push(""),p.ruleId==="security-baseline"&&typeof p.details.summary=="string")u.push(` ${n("security:",g)} ${p.details.summary}`);else if(p.ruleId==="owasp-api-top10"&&typeof p.details.summary=="string"){let x=typeof p.details.issueId=="string"?p.details.issueId:null,C=typeof p.details.issueTitle=="string"?p.details.issueTitle:null;u.push(` ${n("owasp:",g)} ${p.details.summary}`),(x||C)&&u.push(` ${n("issue:",g)} ${[x,C].filter(Boolean).join(" - ")}`)}else if(p.ruleId==="schema-consistency"&&typeof p.details.summary=="string"){let x=typeof p.details.path=="string"?p.details.path:null,C=typeof p.details.expected=="string"?p.details.expected:null,se=typeof p.details.actual=="string"?p.details.actual:null,ie=typeof p.details.suggestion=="string"?p.details.suggestion:null;if(u.push(` ${n("schema:",g)} ${p.details.summary}`),x&&u.push(` ${n("path:",g)} ${n(x,S)}`),C&&u.push(` ${n("expected:",g)} ${C}`),se&&u.push(` ${n("actual:",g)} ${se}`),ie){u.push(` ${n("hint:",g)}`);for(let it of ie.split(`
|
|
15
|
+
`))u.push(` ${it}`)}}else u.push(` ${n("details:",g)} ${JSON.stringify(p.details)}`);u.push("")}}let b=o.totalProblemGroups-l.length;return b>0?(u[u.length-1]!==""&&u.push(""),u.push(n(`\u2026 ${b} problems omitted from terminal output. Use --format json/csv/sarif for the complete export.`,v))):u[u.length-1]===""&&u.pop(),`${u.join(`
|
|
16
|
+
`)}
|
|
17
|
+
`}function Zn(t,e){let r=e.maxFindings??10;switch(e.format){case"json":return mt(t);case"csv":return ht(t);case"sarif":return gt(t);case"pretty":return St(t,e.color??!1,r);default:throw new Error(`Unsupported report format: ${e.format}`)}}import{randomUUID as Qe}from"node:crypto";function wt(t,e){let r=O(t||"/")||"/",n=O(e.basePath||"/")||"/";return n==="/"?r:r===n?"/":r.startsWith(`${n}/`)?r.slice(n.length)||"/":null}function Rt(t,e){return!t.host||!e?!0:t.host===e.toLowerCase()}function It(t){try{return decodeURIComponent(t)}catch{return t}}function Pt(t,e,r){let n=r==="strict-host"?e.host?20:5:0;return t.pathScore*10+n}function Ae(t,e){let r={};for(let n=0;n<t.pathParams.length;n+=1){let s=t.pathParams[n],i=e[n+1];s&&i!==void 0&&(r[s]=It(i))}return r}function bt(t,e){let r=O(e)||"/";for(let n of t){let s=n.pathRegex.exec(r);if(s)return{operation:n,pathParams:Ae(n,s)}}return null}function xe(t,e,r,n){let s=e.request.method.toLowerCase(),i=t.operationsByMethod.get(s);if(!i||i.length===0)return null;if(n!==void 0)return bt(i,n);let o=null;for(let a of i)for(let c of a.servers){if(r==="strict-host"&&!Rt(c,e.request.host))continue;let l=wt(e.request.path,c);if(!l)continue;let u=a.pathRegex.exec(l);if(!u)continue;let m={score:Pt(a,c,r),matched:{operation:a,pathParams:Ae(a,u)}};(!o||m.score>o.score)&&(o=m)}return o?.matched??null}var Ce=6,Ot=2e3,kt=50,At=5,xt=1e6,Ct=/(?:token|api[_-]?key|apikey|password|passwd|secret|authorization|jwt)/i,$t=/(?:password|passwd|secret|api[_-]?key|access[_-]?token|refresh[_-]?token|private[_-]?key|ssn|credit[_-]?card|card[_-]?number|cvv)/i,Et=new Set(["page","limit","offset","cursor","per_page","perpage","size","start","after","before"]),$e=4,qt=$e*2;function Tt(t){return t.length<=qt?"***":`${t.slice(0,$e)}\u2026`}function Ft(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function Mt(t){return typeof t=="string"||typeof t=="number"}function jt(t){let e=t.toLowerCase();return e.includes("secret")||e.includes("token")||e.includes("key")?e.startsWith("is")||e.startsWith("has")||e.startsWith("can")||e.startsWith("should")||e.startsWith("enable")||e.startsWith("allow"):!1}function Bt(t){if(typeof t=="number")return t===0||t===1;let e=t.trim().toLowerCase();return e==="true"||e==="false"||e==="0"||e==="1"}function _t(t){if(!d(t)&&!Array.isArray(t))return[];let e=[],r=[{value:t,path:""}],n=0;for(;r.length>0&&n<Ot&&e.length<Ce;){let s=r.pop();if(!s)break;if(n+=1,Array.isArray(s.value)){let i=Math.min(s.value.length,kt);for(let o=0;o<i;o+=1){let a=s.value[o];(d(a)||Array.isArray(a))&&r.push({value:a,path:`${s.path}/${o}`})}continue}if(d(s.value))for(let[i,o]of Object.entries(s.value)){let a=`${s.path}/${Ft(i)}`;if($t.test(i)&&Mt(o)){let c=String(o);if(jt(i)&&Bt(o))continue;if(c.length>0&&(e.push(a||"/"),e.length>=Ce))break}(d(o)||Array.isArray(o))&&r.push({value:o,path:a})}}return e}function Lt(t){for(let e of t.keys())if(Et.has(e.toLowerCase()))return!0;return!1}function P(t,e,r,n,s){return{ruleId:"owasp-api-top10",severity:n,category:"security",message:e,exchangeIndex:t.exchange.index,operationId:t.matchedOperation?.operation.operationId,specSource:t.matchedOperation?.operation.specSource,target:r,details:s}}function Nt(t){let e=[];for(let[r,n]of t.exchange.request.query.entries())if(Ct.test(r)&&(e.push({key:r,valuePreview:Tt(n)}),e.length>=At))break;return e.length===0?[]:[P(t,"Sensitive credential-like query parameters detected","request","warning",{issueId:"API2:2023",issueTitle:"Broken Authentication",summary:"Authentication data should not be passed via query parameters because it can leak via logs, browser history, and referrers.",sensitiveQueryParams:e})]}function zt(t){let e=t.exchange.response;if(!e)return[];let r=e.headers["access-control-allow-origin"]?.trim(),n=e.headers["access-control-allow-credentials"]?.trim().toLowerCase();return r!=="*"||n!=="true"?[]:[P(t,"Insecure CORS policy: wildcard origin with credentials enabled","response","error",{issueId:"API8:2023",issueTitle:"Security Misconfiguration",summary:'Access-Control-Allow-Origin is "*" while Access-Control-Allow-Credentials is true. Browsers may expose authenticated API responses to untrusted origins.',headers:{accessControlAllowOrigin:r,accessControlAllowCredentials:n}})]}function Vt(t){let e=t.exchange.response;if(!e)return[];let r=e.headers["set-cookie"];if(!r)return[];let n=[];for(let s of Se(r)){let i=new Set(s.split(";").slice(1).map(o=>o.split("=")[0].trim().toLowerCase()));t.exchange.request.protocol==="https:"&&!i.has("secure")&&n.push(P(t,'Set-Cookie header is missing "Secure" attribute',"response","warning",{issueId:"API2:2023",issueTitle:"Broken Authentication",summary:'Session cookies over HTTPS should include "Secure" to prevent transmission over plain HTTP.',setCookiePreview:s.slice(0,200)})),i.has("httponly")||n.push(P(t,'Set-Cookie header is missing "HttpOnly" attribute',"response","warning",{issueId:"API2:2023",issueTitle:"Broken Authentication",summary:'Session cookies should include "HttpOnly" to reduce risk of token theft via client-side script access.',setCookiePreview:s.slice(0,200)})),i.has("samesite")||n.push(P(t,'Set-Cookie header is missing "SameSite" attribute',"response","info",{issueId:"API8:2023",issueTitle:"Security Misconfiguration",summary:'Set "SameSite" on session cookies to reduce CSRF risk for state-changing requests.',setCookiePreview:s.slice(0,200)}))}return n}function Ht(t){let e=t.exchange.response;if(!e||e.bodyJson===void 0)return[];let r=_t(e.bodyJson);return r.length===0?[]:[P(t,"Potential sensitive data exposure in response payload","response","warning",{issueId:"API3:2019",issueTitle:"Excessive Data Exposure",summary:`Sensitive-looking fields detected in response payload: ${r.join(", ")}`,exposedPaths:r})]}function Dt(t){let e=t.exchange.response;return!e||e.status>=400||t.exchange.request.method!=="GET"?[]:!e.bodyText||e.bodyText.length<xt?[]:Lt(t.exchange.request.query)?[]:[P(t,"Large response without pagination parameters (possible resource-consumption risk)","response","info",{issueId:"API4:2023",issueTitle:"Unrestricted Resource Consumption",summary:"A large response was returned without common pagination query parameters. Consider explicit page/limit controls for large collections.",responseBytes:e.bodyText.length})]}var L=class{id="owasp-api-top10";analyze(e){return e.matchedOperation?[...Nt(e),...zt(e),...Vt(e),...Ht(e),...Dt(e)]:[]}};function N(t,e){let r=t.replace(/\{([^}]+)\}/g,(i,o)=>{let a=e?.[o];return a?.default!==void 0?String(a.default):Array.isArray(a?.enum)&&a.enum.length>0?String(a.enum[0]):""}),n=we(r),s=!!(n.host&&!ve(n.host));return{rawUrl:t,protocol:s?n.protocol:void 0,host:s?n.host.toLowerCase():void 0,basePath:O(n.pathname||"/")}}function Ee(t){return t?t.startsWith("/")?t:`/${t}`:"/"}function z(t,e){let r=`${Math.floor(t/100)}XX`;return[String(t),r,r.toLowerCase(),"default"].find(n=>e.includes(n))}function qe(t){if(!t)return{};let e={};for(let r of t.split(";")){let[n,...s]=r.trim().split("=");if(!n)continue;let i=s.join("=").trim();e[n]=i}return e}var Kt=/^([^[\]]+)\[([^[\]]+)\]$/;function Q(t){let e=t.match(Kt);return e?{parameterName:e[1],property:e[2]}:void 0}function Ut(t,e){let r;for(let[n,s]of e){let i=Q(n);i?.parameterName===t&&(r??={},r[i.property]=s)}return r}function V(t,e,r,n){switch(t.in){case"path":return r[t.name];case"query":{if(t.style==="deepObject")return Ut(t.name,e.query);let s=e.query.getAll(t.name);return s.length===0?void 0:(d(t.schema)?t.schema.type:void 0)==="array"||s.length>1?s:s[0]}case"header":return e.headers[t.name.toLowerCase()];case"cookie":return n[t.name];default:return}}var Te=200;function Fe(t){return t!==void 0&&t!==""}function Gt(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function Jt(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function Wt(t){return!t||t==="#"?"":t.startsWith("#")?t.slice(1):t}function X(t){let e=Wt(t);return!e||e==="/"?[]:e.split("/").slice(1).map(r=>Gt(r))}function Me(t,e){return`/${[...X(t),Jt(e)].join("/")}`}function Yt(t,e){let r=X(e),n=t;for(let s of r){if(Array.isArray(n)){let i=Number.parseInt(s,10);if(!Number.isInteger(i)||i<0||i>=n.length)return;n=n[i];continue}if(!d(n))return;n=n[s]}return n}function Z(t){let e=t.instancePath??"",r=t.params??{};return t.keyword==="required"&&typeof r.missingProperty=="string"?Me(e,r.missingProperty):t.keyword==="additionalProperties"&&typeof r.additionalProperty=="string"?Me(e,r.additionalProperty):e}function Qt(t){let e=X(t);if(e.length===0)return"root";let r=[];for(let n of e)/^\d+$/.test(n)?r.push(`[${n}]`):r.length===0?r.push(n):r.push(`.${n}`);return r.join("")}function Xt(t){if(t===void 0)return"[missing]";let e=JSON.stringify(t);return e?e.length>Te?`${e.slice(0,Te)}\u2026`:e:String(t)}function Zt(t){let e=t.params??{};if(t.keyword==="required"&&typeof e.missingProperty=="string")return`required field "${e.missingProperty}"`;if(t.keyword==="type"&&typeof e.type=="string")return`type "${e.type}"`;if(t.keyword==="additionalProperties")return"no additional undocumented properties";if(t.keyword==="format"&&typeof e.format=="string")return`format "${e.format}"`}function en(t,e,r){let n=t==="request"?"Request":"Response",s=e.params??{},i=Qt(r);return e.keyword==="required"&&typeof s.missingProperty=="string"?`${n} is missing required field "${i}".`:e.keyword==="additionalProperties"&&typeof s.additionalProperty=="string"?`${n} has undocumented field "${i}".`:e.keyword==="type"&&typeof s.type=="string"?`${n} field "${i}" must be ${s.type}.`:e.keyword==="enum"?`${n} field "${i}" has a value outside allowed enum values.`:e.keyword==="format"&&typeof s.format=="string"?`${n} field "${i}" does not match format "${s.format}".`:`${n} schema mismatch at "${i}": ${e.message??"validation error"}`}function Be(t,e,r){let n=Z(e),s=Yt(t,n);return{summary:en(r,e,n),keyword:e.keyword??null,path:n||"/",expected:Zt(e)??null,actual:Xt(s),suggestion:null,params:e.params??{},ajvMessage:e.message??"validation error"}}function tn(t,e,r,n){if(e==null||!t.schema)return;let s=r.validateSchema(t.schema,e,{coerce:!0});if(!s.valid)for(let i of s.errors){let o=Be(e,i,"request");n.push({ruleId:"schema-consistency",severity:"error",category:"schema",message:`Invalid ${t.in} parameter "${t.name}": ${typeof o.summary=="string"?o.summary:i.message??"schema mismatch"}`,exchangeIndex:r.exchange.index,operationId:r.matchedOperation?.operation.operationId,specSource:r.matchedOperation?.operation.specSource,target:"request",schemaPath:i.schemaPath,dataPath:Z(i),details:{...o,parameter:{name:t.name,in:t.in}}})}}function nn(t,e){let r=[],n={query:new Set,header:new Set,cookie:new Set},s=new Set;for(let i of e.operation.requestParameters)i.in==="header"?n.header.add(i.name.toLowerCase()):(i.in==="query"||i.in==="cookie")&&(n[i.in].add(i.name),i.in==="query"&&i.style==="deepObject"&&s.add(i.name));for(let i of new Set(t.exchange.request.query.keys())){if(n.query.has(i))continue;let o=Q(i);o&&s.has(o.parameterName)||r.push({ruleId:"schema-consistency",severity:"warning",category:"documentation",message:`Undocumented query parameter in traffic: "${i}"`,exchangeIndex:t.exchange.index,operationId:e.operation.operationId,specSource:e.operation.specSource,target:"request"})}for(let i of Object.keys(t.exchange.request.headers))Pe(i,t.ignoreHeaders)||n.header.has(i.toLowerCase())||r.push({ruleId:"schema-consistency",severity:"info",category:"documentation",message:`Undocumented header in traffic: "${i}"`,exchangeIndex:t.exchange.index,operationId:e.operation.operationId,specSource:e.operation.specSource,target:"request"});return r}function rn(t){let e=t.exchange.response;return e!==void 0&&e.status>=400&&e.status<500}function sn(t,e){let r=t.exchange.response;if(!r)return;let{responseStatuses:n,responseBodyContent:s}=e.operation,i=z(r.status,n);if(!(i===void 0||s[i]===void 0))return A(s[i],r.contentType)}function je(t,e,r,n){let s=r.validateSchema(t,e,{target:n});return s.valid?[]:s.errors.map(i=>{let o=Be(e,i,n);return{ruleId:"schema-consistency",severity:"error",category:"schema",message:typeof o.summary=="string"?o.summary:`Schema mismatch (${n}): ${i.message??"validation error"}`,exchangeIndex:r.exchange.index,operationId:r.matchedOperation?.operation.operationId,specSource:r.matchedOperation?.operation.specSource,target:n,schemaPath:i.schemaPath,dataPath:Z(i),details:o}})}var H=class{id="schema-consistency";analyze(e){let r=e.matchedOperation;if(!r)return[];let n=[];if(n.push(...nn(e,r)),!rn(e)){for(let c of r.operation.requestParameters){if(e.ignoreCookies&&c.in==="cookie")continue;let l=V(c,e.exchange.request,r.pathParams,e.cookies);if(c.required&&l==null){n.push({ruleId:this.id,severity:"error",category:"documentation",message:`Missing required ${c.in} parameter: "${c.name}"`,exchangeIndex:e.exchange.index,operationId:r.operation.operationId,specSource:r.operation.specSource,target:"request"});continue}tn(c,l,e,n)}let i=e.exchange.request.contentType,o=A(r.operation.requestBodyContent,i),a=Fe(e.exchange.request.bodyText);r.operation.requestBodyRequired&&!a&&n.push({ruleId:this.id,severity:"error",category:"documentation",message:"Missing required request body",exchangeIndex:e.exchange.index,operationId:r.operation.operationId,specSource:r.operation.specSource,target:"request"}),o&&a&&k(i)&&(e.exchange.request.bodyJson===void 0?n.push({ruleId:this.id,severity:"error",category:"schema",message:"Request body is not valid JSON for JSON content-type",exchangeIndex:e.exchange.index,operationId:r.operation.operationId,specSource:r.operation.specSource,target:"request"}):n.push(...je(o,e.exchange.request.bodyJson,e,"request")))}let s=sn(e,r);if(s&&e.exchange.response&&Fe(e.exchange.response.bodyText)){let i=e.exchange.response.contentType;k(i)&&(e.exchange.response.bodyJson===void 0?n.push({ruleId:this.id,severity:"error",category:"schema",message:"Response body is not valid JSON for JSON content-type",exchangeIndex:e.exchange.index,operationId:r.operation.operationId,specSource:r.operation.specSource,target:"response"}):n.push(...je(s,e.exchange.response.bodyJson,e,"response")))}return n}};function ee(t){if(!t)return null;let[e]=t.trim().split(/\s+/,1);return e?e.toLowerCase():null}function Le(t){return!!t.exchange.request.headers.authorization}function on(t,e){return t?t.split(";").map(r=>r.trim()).some(r=>r.startsWith(`${e}=`)):!1}function an(t,e){let r=t.matchedOperation?.operation;if(!r)return{schemeName:e,schemeType:"unknown",satisfied:!0,reason:"No matched OpenAPI operation."};let n=r.securitySchemes[e];if(!n)return{schemeName:e,schemeType:"missing",satisfied:!1,reason:"Security scheme is referenced but not defined in components.securitySchemes."};let s=String(n.type??"unknown");if(n.type==="apiKey"){let i=String(n.name??""),o=String(n.in??"header");if(!i)return{schemeName:e,schemeType:s,satisfied:!1,reason:'apiKey scheme is missing the "name" field in the OpenAPI spec.'};if(o==="header"){let a=!!t.exchange.request.headers[i.toLowerCase()];return{schemeName:e,schemeType:s,satisfied:a,reason:a?`Found required apiKey header "${i}".`:`Missing required apiKey header "${i}".`}}if(o==="query"){let a=t.exchange.request.query.has(i);return{schemeName:e,schemeType:s,satisfied:a,reason:a?`Found required apiKey query parameter "${i}".`:`Missing required apiKey query parameter "${i}".`}}if(o==="cookie"){if(t.ignoreCookies)return{schemeName:e,schemeType:s,satisfied:!0,skipped:!0,reason:`Skipped apiKey cookie "${i}" validation because --ignore-cookies is enabled.`};let a=on(t.exchange.request.headers.cookie,i);return{schemeName:e,schemeType:s,satisfied:a,reason:a?`Found required apiKey cookie "${i}".`:`Missing required apiKey cookie "${i}".`}}return{schemeName:e,schemeType:s,satisfied:!1,reason:`Unsupported apiKey location "${o}" in OpenAPI security scheme.`}}if(n.type==="http"){let i=t.exchange.request.headers.authorization;if(!i)return{schemeName:e,schemeType:s,satisfied:!1,reason:"Missing Authorization header."};let o=String(n.scheme??"").toLowerCase(),a=ee(i);if(!o)return{schemeName:e,schemeType:s,satisfied:!0,reason:"Authorization header is present and no specific HTTP auth scheme is documented."};if(!a)return{schemeName:e,schemeType:s,satisfied:!1,reason:"Authorization header is malformed and does not include an auth scheme."};let c=a===o;return{schemeName:e,schemeType:s,satisfied:c,reason:c?`Authorization uses expected "${o}" scheme.`:`Authorization uses "${a}" but "${o}" is required.`}}if(n.type==="oauth2"||n.type==="openIdConnect"){let i=t.exchange.request.headers.authorization;if(!i)return{schemeName:e,schemeType:s,satisfied:!1,reason:"Missing Authorization header for OAuth2/OpenID Connect scheme."};let o=ee(i),a=o==="bearer";return{schemeName:e,schemeType:s,satisfied:a,reason:a?"Authorization uses bearer token as expected for OAuth2/OpenID Connect.":`Authorization scheme "${o??"unknown"}" does not satisfy OAuth2/OpenID Connect (expected bearer).`}}return n.type==="mutualTLS"?{schemeName:e,schemeType:s,satisfied:!0,reason:"mutualTLS cannot be validated from HTTP traffic logs alone."}:{schemeName:e,schemeType:s,satisfied:!1,reason:`Unsupported security scheme type "${s}".`}}function un(t){let e=t.matchedOperation?.operation.security;if(!e)return{satisfied:!0,requirements:[]};if(e.length===0)return{satisfied:!0,requirements:[]};let r=e.map((n,s)=>{let i=Object.keys(n);if(i.length===0)return{requirementIndex:s,satisfied:!0,schemeResults:[]};let o=i.map(a=>an(t,a));return{requirementIndex:s,satisfied:o.every(a=>a.satisfied),schemeResults:o}});return{satisfied:r.some(n=>n.satisfied),requirements:r}}function cn(t){let e=[];for(let r of t.requirements)for(let n of r.schemeResults)n.satisfied||e.push({requirement:r.requirementIndex+1,schemeName:n.schemeName,reason:n.reason});return e}function _e(t){let e=[];for(let r of t.requirements)for(let n of r.schemeResults)n.skipped&&e.push({requirement:r.requirementIndex+1,schemeName:n.schemeName,reason:n.reason});return e}function pn(t){if(t.length===0)return"All documented security requirements are satisfied.";let e=new Map;for(let n of t){let s=e.get(n.requirement);s?s.push(n):e.set(n.requirement,[n])}let r=Array.from(e.entries()).sort((n,s)=>n[0]-s[0]).map(([n,s])=>{let i=s.map(a=>a.schemeName).join(" + "),o=s.map(a=>a.reason).join(" ");return`Option ${n} (${i}): ${o}`});return r.length===1?`Authentication check failed. ${r[0]}`:`None of the documented authentication options matched. Any one of these options would satisfy the OpenAPI security requirements: ${r.join(" | ")}`}function dn(t){return Array.from(t.exchange.request.query.keys()).filter(e=>{let r=e.toLowerCase();return r.includes("token")||r.includes("apikey")||r.includes("api_key")||r.includes("access_key")})}var ln=/^(?:(?:.+\.)?localhost|127(?:\.\d{1,3}){3}|::1)$/i;function fn(t){let e;try{e=new URL(t.url).hostname}catch{e=t.host?.replace(/:\d+$/,"")}return e?ln.test(e.replace(/^\[|\]$/g,"")):!1}function mn(t){if(t.exchange.request.protocol!=="http:"||!t.exchange.request.protocolKnown||fn(t.exchange.request))return{flag:!1,hasAuthHeader:!1,sensitiveQueryKeys:[]};let e=Le(t),r=dn(t);return{flag:e||r.length>0,hasAuthHeader:e,sensitiveQueryKeys:r}}var D=class{id="security-baseline";analyze(e){if(!e.matchedOperation)return[];let r=[],n=un(e);if(n.satisfied){let i=_e(n);i.length>0&&r.push({ruleId:this.id,severity:"info",category:"security",message:"Some documented cookie-based security checks were skipped",exchangeIndex:e.exchange.index,operationId:e.matchedOperation.operation.operationId,specSource:e.matchedOperation.operation.specSource,target:"request",details:{summary:i.map(o=>`Skipped option ${o.requirement} (${o.schemeName}): ${o.reason}`).join(" "),skippedChecks:i}})}else{let i=cn(n);r.push({ruleId:this.id,severity:"error",category:"security",message:"Request does not satisfy documented OpenAPI security requirements",exchangeIndex:e.exchange.index,operationId:e.matchedOperation.operation.operationId,specSource:e.matchedOperation.operation.specSource,target:"request",details:{summary:pn(i),failedChecks:i,skippedChecks:_e(n),authorizationScheme:ee(e.exchange.request.headers.authorization),hasAuthorizationHeader:Le(e)}})}let s=mn(e);return s.flag&&r.push({ruleId:this.id,severity:"warning",category:"security",message:"Potential credential exposure over insecure HTTP transport",exchangeIndex:e.exchange.index,operationId:e.matchedOperation.operation.operationId,specSource:e.matchedOperation.operation.specSource,target:"request",details:{protocol:e.exchange.request.protocol,hasAuthorizationHeader:s.hasAuthHeader,sensitiveQueryKeys:s.sensitiveQueryKeys}}),r}};var K=class{id="undocumented-endpoint";analyze(e){if(e.matchedOperation)return[];let{method:r,path:n,host:s}=e.exchange.request,o=e.matchMode==="strict-host"&&!e.hostCompatibleWithSpecServers?`Undocumented server: ${r} ${n} was sent to "${s}", which does not match any server in the description`:`Undocumented endpoint: ${r} ${n}`;return[{ruleId:this.id,severity:"error",category:"documentation",message:o,exchangeIndex:e.exchange.index,target:"request"}]}};var te={"undocumented-endpoint":()=>new K,"schema-consistency":()=>new H,"security-baseline":()=>new D,"owasp-api-top10":()=>new L},hn=Object.keys(te),gn=["undocumented-endpoint","schema-consistency","security-baseline"];function Ne(t){return!t||t.length===0?gn.map(e=>te[e]()):[...new Set(t)].map(e=>{let r=te[e];if(!r)throw new Error(`Unknown rule id: "${e}". Available rules: ${hn.join(", ")}`);return r()})}var He=oe(ot(),1);var De=oe(at(),1),ze=He.default,Ve=De.default;function ne(t,e){if(!d(t))return!1;let r=e==="request"?"readOnly":"writeOnly";return t[r]===!0||Array.isArray(t.allOf)&&t.allOf.some(n=>d(n)&&n[r]===!0)}function Ke(t,e,r,n=new WeakSet){if(!d(t)||n.has(t))return!1;n.add(t);let s=t.properties;return d(s)&&ne(s[e],r)?!0:[t.allOf,t.oneOf,t.anyOf].some(i=>Array.isArray(i)&&i.some(o=>Ke(o,e,r,n)))}var yn=new Set(["items","additionalItems","additionalProperties","unevaluatedItems","unevaluatedProperties","contains","propertyNames","not","if","then","else"]),vn=new Set(["allOf","anyOf","oneOf","prefixItems"]),Sn=new Set(["properties","patternProperties","dependentSchemas","$defs","definitions"]);function Ue(t,e,r=new WeakSet){if(!d(t))return t;if(r.has(t))return!0;r.add(t);let n=i=>Ue(i,e,r),s={};for(let[i,o]of Object.entries(t))yn.has(i)?s[i]=Array.isArray(o)?o.map(n):n(o):vn.has(i)&&Array.isArray(o)?s[i]=o.map(n):Sn.has(i)&&d(o)?s[i]=Object.fromEntries(Object.entries(o).map(([a,c])=>[a,n(c)])):s[i]=o;return Array.isArray(t.required)&&(s.required=t.required.filter(i=>typeof i!="string"||!Ke(t,i,e))),r.delete(t),s}var T=class{ajv;fallbackAjv;objectSchemaCaches={none:new WeakMap,request:new WeakMap,response:new WeakMap};scalarSchemaCache=new Map;constructor(e){let r={strict:!1,allErrors:!0,allowUnionTypes:!0,discriminator:!0,coerceTypes:e?.coerceTypes?"array":!1,validateFormats:!0,verbose:!0,formats:{enum:!0}};this.ajv=new ze(r),this.fallbackAjv=new ze({...r,discriminator:!1}),Ve(this.ajv),Ve(this.fallbackAjv)}validate(e,r,n){if(e===void 0)return{valid:!0,errors:[]};let s;try{s=this.getOrCompileValidator(e,n)}catch(a){return{valid:!1,errors:[{message:`Schema compilation failed: ${a.message}`}]}}let i=!!s(r),o=s.errors??[];return{valid:i,errors:o}}getOrCompileValidator(e,r){if(d(e)){let o=this.objectSchemaCaches[r??"none"],a=o.get(e);if(a)return a;let c=r?Ue(e,r):e,l=this.compileSchema(c);return o.set(e,l),l}let n=`${r??"none"}:${JSON.stringify(e)}`,s=this.scalarSchemaCache.get(n);if(s)return s;let i=this.compileSchema(e);return this.scalarSchemaCache.set(n,i),i}compileSchema(e){try{return this.ajv.compile(e)}catch{return this.fallbackAjv.compile(e)}}};function Ge(t){switch(t.kind){case"operation":return"operation";case"parameter":return`parameter:${t.in}:${t.name}`;case"response":return`response:${t.status}`;case"property":return`property:${t.target}:${t.status??""}:${t.path}`}}function G(t,e){let r=Ge(e);t.has(r)||t.set(r,{item:e,covered:!1})}function J(t,e){let r=t.get(Ge(e));r&&(r.covered=!0)}function Je(t,e){return t?`${t}.${e}`:e}function F(t,e,r,n,s){if(!(!d(t)||s.has(t))){s.add(t);for(let i of[t.allOf,t.oneOf,t.anyOf])if(Array.isArray(i))for(let o of i)F(o,e,r,n,s);if(d(t.properties))for(let[i,o]of Object.entries(t.properties)){if(ne(o,e.target))continue;let a=Je(r,i);G(n,{kind:"property",...e,path:a}),F(o,e,a,n,s)}d(t.items)&&F(t.items,e,`${r}[]`,n,s),s.delete(t)}}function M(t,e,r,n,s,i){if(!(!d(e)||i.has(e))){i.add(e);for(let o of[e.allOf,e.oneOf,e.anyOf])if(Array.isArray(o))for(let a of o)M(t,a,r,n,s,i);if(d(e.properties)&&d(t))for(let[o,a]of Object.entries(e.properties)){if(t[o]===void 0)continue;let c=Je(n,o);J(s,{kind:"property",...r,path:c}),M(t[o],a,r,c,s,i)}if(d(e.items)&&Array.isArray(t))for(let o of t)M(o,e.items,r,`${n}[]`,s,i);i.delete(e)}}function wn(t,e){let r=new Map;G(r,{kind:"operation"});for(let n of t.requestParameters)e&&n.in==="cookie"||G(r,{kind:"parameter",name:n.name,in:n.in});for(let[n,s]of Object.entries(t.requestBodyContent))k(n)&&F(s,{target:"request"},"",r,new Set);for(let n of t.responseStatuses){G(r,{kind:"response",status:n});for(let[s,i]of Object.entries(t.responseBodyContent[n]??{}))k(s)&&F(i,{target:"response",status:n},"",r,new Set)}return{operation:t,entries:r}}function Rn(t){return t.request.bodyJson!==void 0||t.response?.bodyJson!==void 0}function U(t,e){let r={covered:0,total:0};for(let n of t)for(let s of n.entries.values())s.item.kind===e&&(r.total+=1,s.covered&&(r.covered+=1));return r}function In(t){let e={method:t.operation.method.toUpperCase(),path:t.operation.pathTemplate,operationId:t.operation.operationId,missing:[],covered:[]};for(let r of t.entries.values())(r.covered?e.covered:e.missing).push(r.item);return e}var W=class{states=new Map;exchanges={total:0,matched:0,withBody:0};constructor(e){for(let r of e.openApiIndex.operationsByMethod.values())for(let n of r)this.states.set(n,wn(n,e.ignoreCookies))}record(e,r,n){if(this.exchanges.total+=1,!r)return;let s=this.states.get(r.operation);if(!s)return;this.exchanges.matched+=1,Rn(e)&&(this.exchanges.withBody+=1);let{operation:i,pathParams:o}=r,{entries:a}=s;J(a,{kind:"operation"});for(let u of i.requestParameters){let m=V(u,e.request,o,n);m!=null&&J(a,{kind:"parameter",name:u.name,in:u.in})}if(e.request.bodyJson!==void 0){let u=A(i.requestBodyContent,e.request.contentType);M(e.request.bodyJson,u,{target:"request"},"",a,new Set)}let c=e.response;if(!c)return;let l=z(c.status,i.responseStatuses);if(l!==void 0&&(J(a,{kind:"response",status:l}),c.bodyJson!==void 0)){let u=A(i.responseBodyContent[l]??{},c.contentType);M(c.bodyJson,u,{target:"response",status:l},"",a,new Set)}}finalize(){let e=Array.from(this.states.values()).sort((r,n)=>r.operation.pathTemplate.localeCompare(n.operation.pathTemplate)||r.operation.method.localeCompare(n.operation.method));return{exchanges:this.exchanges,totals:{operations:U(e,"operation"),parameters:U(e,"parameter"),properties:U(e,"property"),responses:U(e,"response")},operations:e.map(In)}}};var Pn=10,We={info:0,warning:1,error:2};function bn(){return{totalExchanges:0,documentedExchanges:0,undocumentedExchanges:0,skippedExchanges:0,hostCompatibleExchanges:0,findingsBySeverity:{info:0,warning:0,error:0},findingsByRule:{}}}function On(t,e){t.findingsBySeverity[e.severity]+=1,t.findingsByRule[e.ruleId]=(t.findingsByRule[e.ruleId]??0)+1}function kn(t,e){return{...t,id:Qe(),method:e.request.method,url:e.request.url,path:e.request.path,status:e.response?.status}}function An(t,e){return{exchangeIndex:t.exchangeIndex,ruleId:t.ruleId,severity:t.severity,category:t.category,message:t.message,occurrences:1,operationId:t.operationId,specSource:t.specSource,target:t.target,schemaPath:t.schemaPath,dataPath:t.dataPath,details:t.details,method:e.request.method,url:e.request.url,path:e.request.path,status:e.response?.status}}function xn(t,e){if(!e)return;t.operationId||(t.operationId=e.operation.operationId),t.specSource||(t.specSource=e.operation.specSource);let r=t.details??{};if(!d(r)){t.details={operationPathTemplate:e.operation.pathTemplate};return}typeof r.operationPathTemplate!="string"&&(r.operationPathTemplate=e.operation.pathTemplate),t.details=r}function Cn(t){let e=new Set,r=!1;for(let n of t.operationsByMethod.values())for(let s of n)for(let i of s.servers)i.host?e.add(i.host):r=!0;return{specServerHosts:e,hasHostlessSpecServer:r}}async function $n(t,e){let r=[];for(let n of t)try{let s=await n.analyze(e);s.length>0&&r.push(...s)}catch(s){R.warn(`Rule "${n.id}" failed to execute: ${s.message}
|
|
18
|
+
`)}return r}var Ye=class t{startedAt=Date.now();runId=Qe();previewLimit;rules;schemaValidator=new T;coercingSchemaValidator=new T({coerceTypes:!0});options;coverage;counters=bn();findings=[];previewFindings=[];problemGroupsByRule={};problemKeyStats=new Map;totalProblemGroups=0;server;ignoreHeaders;minSeverityRank;specServerHosts;hasHostlessSpecServer;constructor(e,r){this.options=e,this.rules=r,this.server=be(e.server),this.ignoreHeaders=e.ignoreHeaders?Ie(e.ignoreHeaders):void 0;let{specServerHosts:n,hasHostlessSpecServer:s}=Cn(e.openApiIndex);this.specServerHosts=n,this.hasHostlessSpecServer=s,this.minSeverityRank=We[e.minSeverity??"info"],this.previewLimit=e.previewFindingsLimit&&e.previewFindingsLimit>0?e.previewFindingsLimit:Pn,this.coverage=e.coverage?new W({openApiIndex:e.openApiIndex,ignoreCookies:e.ignoreCookies??!1}):void 0}static create(e){if(e.openApiIndex.loadedOperations===0)throw new Error("No OpenAPI operations available to validate traffic against.");return new t(e,Ne(e.activeRules))}async process(e){this.counters.totalExchanges+=1;let r=qe(e.request.headers.cookie),n;if(this.server!==void 0&&(n=Oe(e.request,this.server),n===void 0))return this.counters.skippedExchanges+=1,this.coverage?.record(e,null,r),[];let s=this.isHostCompatible(e.request.host);s&&(this.counters.hostCompatibleExchanges+=1);let i=xe(this.options.openApiIndex,e,this.options.matchMode,n);i?this.counters.documentedExchanges+=1:this.counters.undocumentedExchanges+=1,this.coverage?.record(e,i,r);let o=await $n(this.rules,{exchange:e,matchedOperation:i,matchMode:this.options.matchMode,hostCompatibleWithSpecServers:n!==void 0||s,ignoreCookies:this.options.ignoreCookies??!1,ignoreHeaders:this.ignoreHeaders,cookies:r,validateSchema:(c,l,u)=>u?.coerce?this.coercingSchemaValidator.validate(c,l,u?.target):this.schemaValidator.validate(c,l,u?.target)}),a=[];for(let c of o){if(We[c.severity]<this.minSeverityRank)continue;xn(c,i);let l=kn(c,e);this.findings.push(l),a.push(l),On(this.counters,c);let u=B({ruleId:c.ruleId,severity:c.severity,message:c.message,operationId:c.operationId,path:e.request.path,target:c.target,schemaPath:c.schemaPath}),m=this.problemKeyStats.get(u);if(m){m.occurrences+=1,m.previewIndex!==null&&(this.previewFindings[m.previewIndex].occurrences=m.occurrences);continue}if(this.totalProblemGroups+=1,this.problemGroupsByRule[c.ruleId]=(this.problemGroupsByRule[c.ruleId]??0)+1,this.previewFindings.length<this.previewLimit){let w=this.previewFindings.length;this.previewFindings.push(An(c,e)),this.problemKeyStats.set(u,{occurrences:1,previewIndex:w});continue}this.problemKeyStats.set(u,{occurrences:1,previewIndex:null})}return a}isHostCompatible(e){return!e||this.hasHostlessSpecServer||this.specServerHosts.has(e.toLowerCase())}finalize(){let e={runId:this.runId,totalExchanges:this.counters.totalExchanges,documentedExchanges:this.counters.documentedExchanges,undocumentedExchanges:this.counters.undocumentedExchanges,skippedExchanges:this.counters.skippedExchanges,hostCompatibleExchanges:this.counters.hostCompatibleExchanges,findingsBySeverity:this.counters.findingsBySeverity,findingsByRule:this.counters.findingsByRule,problemGroupsByRule:this.problemGroupsByRule,totalProblemGroups:this.totalProblemGroups,durationMs:Date.now()-this.startedAt,previewFindings:this.previewFindings,previewLimit:this.previewLimit,previewTruncated:this.totalProblemGroups>this.previewFindings.length};return{runId:this.runId,summary:e,findings:this.findings,coverage:this.coverage?.finalize()}}};import{stat as En}from"node:fs/promises";var qn=["get","put","post","delete","patch","head","options","trace"],Tn=new Set(["query","header","path","cookie"]),Fn=/^(default|[1-5](\d{2}|xx))$/i;function Mn(t){return qn.includes(t)}function jn(t){return Tn.has(t)}function Xe(t){if(!Array.isArray(t))return[];let e=[];for(let r of t){if(!d(r))continue;let n=r.in;typeof n!="string"||!jn(n)||e.push({name:String(r.name??""),in:n,required:!!r.required||n==="path",style:typeof r.style=="string"?r.style:void 0,schema:r.schema})}return e}function Ze(t){let e=t.in==="header";return`${t.in}:${e?t.name.toLowerCase():t.name}`}function Bn(t,e){let r=new Map;for(let n of t)r.set(Ze(n),n);for(let n of e)r.set(Ze(n),n);return Array.from(r.values())}function tt(t){let e={};if(!d(t))return e;for(let[r,n]of Object.entries(t))d(n)&&"schema"in n&&(e[r.toLowerCase()]=n.schema);return e}function _n(t){return d(t)?tt(t.content):{}}function Ln(t){let e={};for(let[r,n]of Object.entries(t))!d(n)||!("content"in n)||(e[r]=tt(n.content));return e}function Nn(t,e,r){let n=t??e??r;return!Array.isArray(n)||n.length===0?[N("/")]:n.map(s=>{if(!d(s))return N("/");let i=typeof s.url=="string"?s.url:"/",o=d(s.variables)?s.variables:void 0;return N(i,o)})}function zn(t,e,r){return r||`${t.toUpperCase()} ${e}`}function Vn(t){try{let e=fe(t.parsed);return le(e)==="oas3"?e:null}catch{return null}}function et(t){return Array.isArray(t)?t:void 0}function Hn(t,e){let r,n,s={},i="/",o=[],a;return{Root:{enter(c){r=c.servers,n=c.security;let l=d(c.components)?c.components.securitySchemes:void 0;s=d(l)?l:{}}},Paths:{PathItem:{enter(c,l){i=Ee(String(l.key)),o=Xe(c.parameters),a=c.servers},Operation:{enter(c,l){let u=String(l.key);if(!Mn(u))return;let m=Bn(o,Xe(c.parameters)),w=Re(i),j=Nn(c.servers,a,r),b=c.requestBody,f=d(c.responses)?Object.fromEntries(Object.entries(c.responses).filter(([Y])=>Fn.test(Y))):{},h={operationId:zn(u,i,typeof c.operationId=="string"?c.operationId:void 0),method:u,pathTemplate:i,pathRegex:w.regex,pathParams:w.params,pathScore:w.score,servers:j,requestParameters:m,requestBodyContent:_n(b),requestBodyRequired:d(b)&&!!b.required,responseStatuses:Object.keys(f),responseBodyContent:Ln(f),security:et(c.security)??et(n),securitySchemes:s,specSource:t},y=e.get(u)??[];y.push(h),e.set(u,y)}}}}}}function Dn(t,e,r,n,s){let i=ae(r.extendTypes(ue(e),e),r),o=new Map,a={problems:[],specVersion:e,config:r,visitorsData:{}},c=me([{severity:"warn",ruleId:"drift-index",visitor:Hn(n,s)}],i);he({document:t,rootType:i.Root,normalizedVisitors:c,resolvedRefMap:o,ctx:a})}function Kn(t){return`${t.host??""}|${t.basePath}`}function Un(t){for(let e of t.values()){let r=new Map;for(let n of e){let s=r.get(n.pathRegex.source)??[];s.push(n),r.set(n.pathRegex.source,s)}for(let n of r.values()){let s=new Map;for(let i of n)for(let o of i.servers){let a=Kn(o),c=s.get(a)??new Set;c.add(i.specSource),s.set(a,c)}for(let i of s.values())if(i.size>1){let[o]=n;R.warn(`"${o.method.toUpperCase()} ${o.pathTemplate}" is documented for the same server in multiple descriptions (${Array.from(i).join(", ")}). Matching traffic is validated against only one of them.
|
|
19
|
+
`);break}}}}function Gn(t,e){for(let n of t.values())n.sort((s,i)=>i.pathScore-s.pathScore);let r=Array.from(t.values()).reduce((n,s)=>n+s.length,0);return{operationsByMethod:t,loadedSpecs:e,loadedOperations:r}}async function Jn(t){return(await En(t)).isDirectory()?{specFiles:await ye(t),fromDirectory:!0}:{specFiles:[t],fromDirectory:!1}}async function Ur(t,e){let{specFiles:r,fromDirectory:n}=await Jn(t),s=new Map,i=new ce(e.resolve),o=0;for(let a of r){let c=await i.resolveDocument(null,a,!0);if(c instanceof Error){R.warn(`Failed to load OpenAPI description ${a}: ${c.message}
|
|
20
|
+
`);continue}let l=Vn(c);if(!l){n||R.warn(`Skipping ${a}: not an OpenAPI 3.x description.
|
|
21
|
+
`);continue}let u;try{let{bundle:m}=await ge({config:e,doc:c,externalRefResolver:i,dereference:!0});u=m}catch(m){R.warn(`Failed to bundle OpenAPI description ${a}: ${m.message}
|
|
22
|
+
`);continue}o+=1,Dn(u,l,e,a,s)}return o>1&&Un(s),Gn(s,o)}function Jr(t){return t.split(",").map(e=>e.trim()).filter(Boolean)}export{Zn as a,Ye as b,Ur as c,Jr as d};
|
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{
|
|
7
|
+
import{b as k,f as v}from"./ZIIE7LXR.js";import{K as A,L as S,M as y,T as f,U as w,ba as d,fa as l,ga as n,ia as x,ja as h,ka as O,ma as g,pa as b,q as u,v as p}from"./JD3HIQIK.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{performance as F}from"perf_hooks";function I(o){let t=Object.fromEntries(Object.entries(o).map(([s,{metric:e,total:r,counts:a}])=>[s,{metric:e,total:r,counts:a}]));n.output(JSON.stringify(t,null,2))}function P(o){let t=`| Feature | Count |
|
|
8
8
|
| --- | --- |
|
|
9
9
|
`,s=[];for(let{metric:e,total:r,counts:a}of Object.values(o)){t+=`| ${e} | ${r} |
|
|
10
10
|
`;let c=Object.entries(a??{});c.length&&s.push(`
|
|
@@ -4,5 +4,5 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{
|
|
7
|
+
import{u as o}from"./ZIIE7LXR.js";import{$ as t}from"./JD3HIQIK.js";var r=" ",a=" ";function g(i){let p=Math.max(...i.map(n=>o(n).length)),e=p+a.length*2,c=r+t("\u2551"+" ".repeat(e)+"\u2551");return["",r+t("\u2554"+"\u2550".repeat(e)+"\u2557"),c,...i.map(n=>{let h=" ".repeat(p-o(n).length);return`${r}${t("\u2551")}${a}${n}${h}${a}${t("\u2551")}`}),c,r+t("\u255A"+"\u2550".repeat(e)+"\u255D"),"",""].join(`
|
|
8
8
|
`)}export{g as a};
|
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as o,c as n}from"./HBUZKWXC.js";import{
|
|
7
|
+
import{a as o,c as n}from"./HBUZKWXC.js";import{ga as t}from"./JD3HIQIK.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{spawn as m}from"node:child_process";var j=async({argv:e})=>{t.info(`
|
|
8
8
|
Launching eject using NPX.
|
|
9
9
|
|
|
10
10
|
`);let{npxExecutableName:c,sanitize:r,shell:i}=n(),p=r(e.path,o),a=r(e["project-dir"],o);m(c,["-y","@redocly/realm","eject",`${e.type}`,p,`-d=${a}`,e.force?`--force=${e.force}`:""],{stdio:"inherit",shell:i}).on("error",s=>{throw t.info(`Eject launch failed: ${s.message}`),new Error("Eject launch failed.")})};export{j as handleEject};
|
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{
|
|
7
|
+
import{b as D}from"./ZIIE7LXR.js";import{T as C,U as j,ga as $,ia as k,ja as M,ka as S,ma as b,q as F,t as R,v as x}from"./JD3HIQIK.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{relative as I,resolve as U}from"node:path";var A=20;async function B({argv:o,config:t,collectSpecData:r}){let[{path:s}]=await D([o.api],t),n=new C(t.resolve),e=await n.resolveDocument(null,s,!0);r?.(e);let i=k(e.parsed),d=F(t.extendTypes(x(i),i),t),p=new Map,u=({source:l,pointer:c},f,N)=>{let v=`${l.absoluteRef}${c}`,y=p.get(v);if(!y){p.set(v,{absoluteRef:l.absoluteRef,pointer:c,types:[f],resolvesTo:N});return}y.types.includes(f)||y.types.push(f),y.resolvesTo||(y.resolvesTo=N)},m={any:{enter(l,{location:c,type:f}){u(c,f.name)}},ref(l,{location:c,type:f},N){u(c,f.name,N.location)}},h={problems:[],specVersion:i,config:t,visitorsData:{}},a=await j({rootDocument:e,rootType:d.Root,externalRefResolver:n});if(S({document:e,rootType:d.Root,normalizedVisitors:M([{severity:"warn",ruleId:"inspect-node-types",visitor:m}],d),resolvedRefMap:a,ctx:h}),o.pointer){let l=W(p,o.pointer,e.source.absoluteRef);o.parents?L(w(p,l,e.source.absoluteRef)):$.output(`${l.types.join(`
|
|
8
8
|
`)}
|
|
9
9
|
`);return}let g=[...p.values()];if(o.summary)V(g);else if(o.type){let l=o.type,c=g.filter(({types:f})=>f.includes(l));if(c.length===0)throw new b(`No nodes of type '${l}'. Run the command with --summary to see the types used in this description.`);o.parents?L(c.flatMap(f=>w(p,f,e.source.absoluteRef)),l):E(c)}else E(g)}function w(o,t,r,s=new Set){let n=`${t.absoluteRef}${t.pointer}`;if(s.has(n))return[[t]];s.add(n);let e=[],i=t.pointer.split("/");for(let p=1;p<i.length;p++){let u=p===1?"#/":i.slice(0,p).join("/");if(u===t.pointer)continue;let m=o.get(`${t.absoluteRef}${u}`);m&&e.push(m)}e.push(t);let d=[];e[0].absoluteRef===r&&e[0].pointer==="#/"&&d.push(e);for(let[p,u]of e.entries()){let m=[...o.values()].filter(a=>a.resolvesTo?.source.absoluteRef===u.absoluteRef&&a.resolvesTo.pointer===u.pointer),h=e.slice(p+1);for(let a of m)d.push(...w(o,a,r,s).map(g=>[...g,...h]))}return d.length?d:[e]}function L(o,t){let r=new Set(o.map(s=>s.map(({types:n})=>t&&n.includes(t)?t:n.join(", ")).join(" \u2192 ")));for(let s of r)$.output(`${s}
|
|
10
10
|
`)}function W(o,t,r){let[s,n]=t.split("#"),e=s?R(s)?s:U(process.cwd(),s):r,i=o.get(`${e}#${n||"/"}`);if(!i)throw new b(`No node at ${t}. ${z(o,e,`#${n||"/"}`,s)??`Check the pointer, and make sure the file is referenced from ${T(r)}.`}`);return i}function z(o,t,r,s){let n=r.split("/");for(let e=n.length-1;e>=1;e--){let i=e===1?"#/":n.slice(0,e).join("/"),d=o.get(`${t}${i}`);if(!d)continue;let p=n[e].toLowerCase(),u=e===1?"#/":`${i}/`,m=[...o.values()].filter(c=>c.absoluteRef===t&&c.pointer.startsWith(u)&&!c.pointer.slice(u.length).includes("/")),h=m.filter(c=>c.pointer.slice(u.length).toLowerCase().includes(p)),a=(h.length?h:m).map(c=>` ${s}${c.pointer}`),g=a.length-A;g>0&&(a.length=A,a.push(` \u2026and ${g} more`));let l=`The closest node is ${d.types.join(", ")} at ${s}${i}.`;return a.length?`${l} Did you mean:
|
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as o,b as t,c as e}from"./HBUZKWXC.js";import{
|
|
7
|
+
import{a as o,b as t,c as e}from"./HBUZKWXC.js";import{ga as r}from"./JD3HIQIK.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{spawn as p}from"node:child_process";var u=async({argv:n})=>{r.info(`
|
|
8
8
|
Launching translate using NPX.
|
|
9
9
|
|
|
10
10
|
`);let{npxExecutableName:s,sanitize:a,shell:i}=e(),l=a(n["project-dir"],o),c=a(n.locale,t);p(s,["-y","@redocly/realm","translate",c,`-d=${l}`],{stdio:"inherit",shell:i}).on("error",m=>{throw r.info(`Translate launch failed: ${m.message}`),new Error("Translate launch failed.")})};export{u as handleTranslations};
|
|
@@ -4,4 +4,4 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a}from"./
|
|
7
|
+
import{a}from"./VJQJVOIN.js";import"./FYDETXDC.js";import"./IBYLYDST.js";import"./WZXA5XPB.js";import"./JD3HIQIK.js";import"./NEWT5A6S.js";import"./LD5MEXEL.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{a as zodGenerator};
|
|
@@ -4,4 +4,4 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{c as a,d as b}from"./
|
|
7
|
+
import{c as a,d as b}from"./ROQ7FTVG.js";import"./IBYLYDST.js";import"./WZXA5XPB.js";import"./JD3HIQIK.js";import"./NEWT5A6S.js";import"./LD5MEXEL.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{b as generateClient,a as runGenerators};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import{b as A,c as F,d as S,e as l}from"./Z7JI42WA.js";import"./263OU3EK.js";import{e as $,g as x,n as I,o as P}from"./SQUNMRDS.js";import{f as p}from"./ZIIE7LXR.js";import"./LRUXN6H5.js";import{_ as w,ga as n,l as u}from"./JD3HIQIK.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";async function O({argv:t,config:o,version:c}){let h=performance.now(),j=Date.now(),{organization:g,project:d,"mount-path":z,verbose:D}=t,f=t.domain||x(),e,r,y,b,s=[];try{let i=$();if(e=P(t.files,(a,T)=>{n.warn(`File ${a} is overwritten by ${T}
|
|
8
|
+
`)}),!e.length)return p("push",h,"No files to upload");let m=await I({domain:f,apiKey:i,organization:g,project:d,mountPath:z,files:e,defaultBranch:t["default-branch"],commit:{message:t.message,branchName:t.branch,sha:t["commit-sha"],url:t["commit-url"],createdAt:t["created-at"],namespace:t.namespace,repository:t.repository,author:U(t.author)},version:c,replace:t.replace,onUploadStart:a=>{n.info(`Uploading to ${a.mountPath} ${e.length} ${u("file",e.length)}:
|
|
9
|
+
`)},onSunsetWarning:a=>s.push(a),onSlugDeprecated:S});r=m.pushId,y=m.organizationId,b=m.projectId}catch(i){l("push",s),F("\u2717 File upload failed.",i)}for(let i of e)n.info(w(`\u2713 ${i.name}
|
|
10
|
+
`));return n.info(`
|
|
11
|
+
`),n.info(`Push ID: ${r}
|
|
12
|
+
`),l("push",s),t["wait-for-deployment"]&&(n.info(`
|
|
13
|
+
`),await A({argv:{organization:y,project:b,pushId:r,wait:!0,domain:f,"max-execution-time":t["max-execution-time"],"start-time":j,"continue-on-deploy-failures":t["continue-on-deploy-failures"]},config:o,version:c})),D&&p("push",h,`${u("file",e.length)} uploaded to organization ${g}, project ${d}. Push ID: ${r}.`),{pushId:r}}function U(t){let o=t.match(/^(?<name>.+)\s<(?<email>[^<>]+)>$/);if(!o?.groups)throw new Error('Invalid author format. Use "Author Name <author@email.com>"');return{name:o.groups.name.trim(),email:o.groups.email.trim()}}export{O as handlePush};
|
|
@@ -4,6 +4,6 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a}from"./
|
|
7
|
+
import{a}from"./WYZDPMVU.js";import{ga as p}from"./JD3HIQIK.js";function g(t,r){let n=t.services.flatMap(e=>e.operations),s=n.filter(e=>e.sse!==void 0);s.length>0&&p.warn(`generate-client: ${r} skipped ${s.length} server-sent-events operation(s) \u2014 iterate the sdk's exported async generators directly: ${s.map(e=>e.name).join(", ")}.
|
|
8
8
|
`);let i=new Set(t.schemas.map(e=>e.name)),o=n.filter(e=>e.sse===void 0&&m(e,i));return o.length>0&&p.warn(`generate-client: ${r} skipped ${o.length} operation(s) whose variables type name collides with a schema \u2014 rename the schema or the operation: ${o.map(e=>e.name).join(", ")}.
|
|
9
9
|
`),n.filter(e=>e.sse===void 0&&!m(e,i))}function m(t,r){let n=a(t);return n.hasInputs&&r.has(n.variablesTypeName)}function x(t){return t.method==="get"||t.method==="head"}function u(t){return a(t).hasInputs}function f(t){return a(t).variablesTypeName}function $(t,r,n){let s=[];return a(t).hasInputs?s.push(r):n&&s.push("{}"),n&&s.push("{ ...init, envelope: undefined }"),`${t.name}(${s.join(", ")})`}function v(t,r,n){let s=t.map(e=>e.name).sort(),i=t.filter(u).map(f).sort();return n&&i.push("RequestOptions"),`import { ${[...s,...i.map(e=>`type ${e}`)].join(", ")} } from ${JSON.stringify(r)};`}export{g as a,x as b,u as c,f as d,$ as e,v as f};
|
|
@@ -4,4 +4,4 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a}from"./
|
|
7
|
+
import{a}from"./H67F6VQQ.js";import"./FYDETXDC.js";import"./IBYLYDST.js";import"./WZXA5XPB.js";import"./JD3HIQIK.js";import"./NEWT5A6S.js";import"./LD5MEXEL.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{a as mockGenerator};
|
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as c}from"./
|
|
7
|
+
import{a as c}from"./YZRKJF2V.js";import{h as s,l as a}from"./SQUNMRDS.js";import"./LRUXN6H5.js";import{_ as t,ga as e,ma as i}from"./JD3HIQIK.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";async function y({argv:r,config:l,version:d}){let o=s(l,r.residency);try{let n=new a(d);r.verbose&&(e.info(`OAuth client initialized.
|
|
8
8
|
`),e.info(`Local credentials file path: ${n.credentialsFilePath}
|
|
9
9
|
`)),await n.login(o,c),e.output(t(`\u2705 Logged in
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{c as U}from"./2U6O26CV.js";import{b as R,c as L,d as Y,f as se,g as K,h as oe,i as re}from"./
|
|
7
|
+
import{c as U}from"./2U6O26CV.js";import{b as R,c as L,d as Y,f as se,g as K,h as oe,i as re}from"./FYDETXDC.js";import{a as X,c as F,d as k,e as D,g as B,h as T,i as Z,j as ee,k as ne,l as H,n as te}from"./UW4UC7ZI.js";var M=F.python,j=class extends X{constructor(){super(" ")}typeName(n){return k(n,{style:"pascal",reserved:M})}memberName(n){let t=k(n,{style:"snake",reserved:M});return{identifier:t,renamed:t!==n}}identifier(n){return k(n,{style:"snake",reserved:M})}identifiers(n,t){return D(n,{style:"snake",reserved:M,taken:t})}constName(n){return k(n,{style:"screaming",reserved:M})}string(n){let t='"';for(let s of n){let r=s.codePointAt(0);s==="\\"?t+="\\\\":s==='"'?t+='\\"':s===`
|
|
8
8
|
`?t+="\\n":s==="\r"?t+="\\r":s===" "?t+="\\t":r<32||r===127?t+=`\\x${r.toString(16).padStart(2,"0")}`:r>=55296&&r<=57343?t+=`\\u${r.toString(16).padStart(4,"0")}`:t+=s}return t+'"'}literal(n){return n==null?"None":n===!0?"True":n===!1?"False":typeof n=="number"?String(n):typeof n=="string"?this.string(n):Array.isArray(n)?`[${n.map(s=>this.literal(s)).join(", ")}]`:`{${Object.entries(n).map(([s,r])=>`${this.string(s)}: ${this.literal(r)}`).join(", ")}}`}comment(n){for(let t of H(n))this.line(t===""?"#":`# ${t}`);return this}doc(n){let t=H(n);if(t.length===0)return this;if(t.length===1)return this.line(`"""${t[0]}"""`);this.line(`"""${t[0]}`);for(let s of t.slice(1))this.line(s);return this.line('"""')}};var N=F.python,f=new j;function O(e){return f.typeName(e)}function q(e){let{identifier:n,renamed:t}=f.memberName(e);return{python:n,renamed:t}}function I(e){let n=e.services.flatMap(s=>s.operations),t=D(n.map(s=>s.name),{style:"snake",reserved:N});return n.map((s,r)=>({op:s,ident:t[r]}))}var W=["self","body","headers","timeout","retry","idempotency_key"];function ae(e){return f.literal(e)}function ie(e){if(e!==void 0)return{style:e.style,...e.param!==void 0?{param:e.param}:{},...e.nextCursor!==void 0?{next_cursor:e.nextCursor}:{},...e.hasMore!==void 0?{has_more:e.hasMore}:{},...e.limitParam!==void 0?{limit_param:e.limitParam}:{},...e.items!==void 0?{items:e.items}:{}}}function ce(e,n){let t=new Set;return`[${(e.successResponseHeaders??[]).map(r=>{let a=k(r.name,{style:"snake",reserved:N}),c=a,i=2;for(;t.has(c);)c=`${a}_${i++}`;t.add(c);let m=te(r.schema,n);return`(${f.string(r.name)}, ${f.string(c)}, ${f.string(m)})`}).join(", ")}]`}function y(e,n="string"){if(Z(e))return`Optional[${y(ee(e),n)}]`;switch(e.kind){case"scalar":if(n==="Date"&&e.scalar==="string"){if(e.metadata?.format==="date-time")return"datetime";if(e.metadata?.format==="date")return"date"}return{string:"str",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"array":return`List[${y(e.items,n)}]`;case"record":return`Dict[str, ${y(e.value,n)}]`;case"ref":return O(e.name);case"literal":return`Literal[${f.literal(e.value)}]`;case"enum":return{string:"str",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"union":return`Union[${e.members.map(t=>y(t,n)).join(", ")}]`;case"null":return"None";case"omit":return O(e.base);case"object":case"intersection":case"unknown":return"Any"}}function G(e,n,t,s,r,a,c,i=!1){let m=D([...n.pathParams,...n.queryParams].map(S=>S.name),{style:"snake",reserved:N,taken:W}),l=n.pathParams.map((S,v)=>({param:S,python:m[v]})),o=n.queryParams.map((S,v)=>({param:S,python:m[n.pathParams.length+v]})),d=l.map(({param:S,python:v})=>`${v}: ${y(S.schema,a)}`),u=n.requestBody?[`body: ${y(n.requestBody.schema,a)}`]:[],$=[...o.map(({param:S,python:v})=>{let A=y(S.schema,a),E=A.startsWith("Optional[")?A:`Optional[${A}]`;return`${v}: ${E} = None`}),"headers: Optional[Dict[str, str]] = None","timeout: Optional[float] = None","retry: Optional[Dict[str, Any]] = None","idempotency_key: Any = None"],h=R(n),g=L(n),x=i?`Envelope[${h===void 0?"None":y(h,a)}]`:g!==void 0?`${r?"AsyncIterator":"Iterator"}[ServerSentEvent]`:s==="result"?"Result":h===void 0?"None":y(h,a),P=r&&g===void 0?"async def":"def",p=r?"await ":"",_=r?"send_async":"send",b=["self",...d,...u,"*",...$].join(", "),w=i?`${t}_with_headers`:t;e.block(`${P} ${w}(${b}) -> ${x}:`,()=>{e.doc(i?`Like ${t}(), returning an Envelope with the declared response headers.`:n.summary),e.line(`op = _OPERATIONS["${t}"]`),e.line('auth_headers, auth_query = resolve_auth(op.get("security") or [], self._auth)'),e.line("params: Dict[str, Any] = dict(auth_query)");for(let{param:E,python:C}of o)e.block(`if ${C} is not None:`,()=>{e.line(`params[${f.string(E.name)}] = encode(${C})`)});let S=l.map(({param:E,python:C})=>`${f.string(E.name)}: ${C}`).join(", ");if(e.line(`url = build_url(self._server_url, op["path"], {${S}})`),g!==void 0){let E=g.schema!==void 0&&g.schema.kind!=="unknown"?"json":"text";e.block("def _open(extra_headers: Dict[str, str]):",()=>{e.line('return self._http.stream(op["method"], url, headers={**auth_headers, **(headers or {}), **extra_headers}, params=params, timeout=timeout)')}),e.line(`return ${r?"aiter_sse":"iter_sse"}(_open, data_kind="${E}")`);return}Y(n)&&e.line("form_data, form_files = to_multipart(body)");let v=n.requestBody?Y(n)?", data=form_data, files=form_files":", json_body=encode(body)":"";e.line(`response = ${p}${_}(self._http, self._config, op, url, method=op["method"], headers={**auth_headers, **(headers or {})}, params=params${v}, timeout=timeout, retry=retry, idempotency_key=idempotency_key)`);let A=h===void 0?"None":`decode(${y(h,a)}, _safe_json(response))`;i?(e.block("if not response.is_success:",()=>{e.line("raise ApiError(url, response.status_code, response.reason_phrase, _safe_json(response))")}),e.line(`return Envelope(data=${A}, headers=read_envelope_headers(response, ${ce(n,c)}), response=response)`)):s==="result"?(e.block("if not response.is_success:",()=>{e.line("return Result(data=None, error=_safe_json(response), response=response)")}),e.line(`return Result(data=${A}, error=None, response=response)`)):(e.block("if not response.is_success:",()=>{e.line("raise ApiError(url, response.status_code, response.reason_phrase, _safe_json(response))")}),e.line(h===void 0?"return None":`return ${A}`))}),e.blank()}function le(e,n,t,s,r,a){let c=R(n),i=c===void 0?"Any":y(c,a),m=D([...n.pathParams,...n.queryParams].map(p=>p.name),{style:"snake",reserved:N,taken:W}),l=n.pathParams.map((p,_)=>({param:p,python:m[_]})),o=n.queryParams.map((p,_)=>({param:p,python:m[n.pathParams.length+_]})),d=l.map(({param:p,python:_})=>`${_}: ${y(p.schema,a)}`),u=[...o.map(({param:p,python:_})=>{let b=y(p.schema,a),w=b.startsWith("Optional[")?b:`Optional[${b}]`;return`${_}: ${w} = None`}),"headers: Optional[Dict[str, str]] = None","timeout: Optional[float] = None","retry: Optional[Dict[str, Any]] = None"],$=["self",...d,"*",...u].join(", "),h=s?"AsyncIterator":"Iterator",g=s?"aiter_pages":"iter_pages",x=s?"aiter_items":"iter_items",P=()=>{e.line("base: Dict[str, Any] = {}");for(let{param:b,python:w}of o)e.block(`if ${w} is not None:`,()=>{e.line(`base[${f.string(b.name)}] = encode(${w})`)});let p=s?"async def":"def",_=s?"await ":"";e.block(`${p} _page(page_params: Dict[str, Any]) -> Tuple[Any, Any]:`,()=>{e.line('auth_headers, auth_query = resolve_auth(op.get("security") or [], self._auth)');let b=l.map(({param:w,python:S})=>`${f.string(w.name)}: ${S}`).join(", ");e.line(`url = build_url(self._server_url, op["path"], {${b}})`),e.line(`response = ${_}${s?"send_async":"send"}(self._http, self._config, op, url, method=op["method"], headers={**auth_headers, **(headers or {})}, params={**page_params, **auth_query}, timeout=timeout, retry=retry)`),e.block("if not response.is_success:",()=>{e.line("raise ApiError(url, response.status_code, response.reason_phrase, _safe_json(response))")}),e.line("return _safe_json(response), response")})};s?(e.block(`async def ${t}_pages(${$}) -> ${h}[${i}]:`,()=>{e.line(`op = _OPERATIONS["${t}"]`),P(),e.block(`async for page in ${g}(_page, op["pagination"], base):`,()=>{e.line(i==="Any"?"yield page":`yield decode(${i}, page)`)})}),e.blank(),e.block(`async def ${t}_items(${$}) -> ${h}[${r}]:`,()=>{e.line(`op = _OPERATIONS["${t}"]`),P(),e.block(`async for item in ${x}(_page, op["pagination"], base):`,()=>{e.line(r==="Any"?"yield item":`yield decode(${r}, item)`)})})):(e.block(`def ${t}_pages(${$}) -> ${h}[${i}]:`,()=>{e.line(`op = _OPERATIONS["${t}"]`),P(),e.line(i==="Any"?`return ${g}(_page, op["pagination"], base)`:`return (decode(${i}, page) for page in ${g}(_page, op["pagination"], base))`)}),e.blank(),e.block(`def ${t}_items(${$}) -> ${h}[${r}]:`,()=>{e.line(`op = _OPERATIONS["${t}"]`),P(),e.line(r==="Any"?`return ${x}(_page, op["pagination"], base)`:`return (decode(${r}, item) for item in ${x}(_page, op["pagination"], base))`)})),e.blank()}function me(e){return se(e).map(t=>t.kind==="literal"?f.string(t.value):q(t.name).python).join(" + ")}function de(e,n){let t=n.servers??[];if(t.length===0)return;let s=new Set;e.block("class Servers:",()=>{e.line('"""The declared servers; variables default to the values from the description."""'),e.blank(),t.forEach((r,a)=>{let c=k(r.description??`server${a+1}`,{style:"snake",reserved:N});s.has(c)&&(c=`${c}_${a+1}`),s.add(c);let i=r.variables.map(m=>`${q(m.name).python}: str = ${f.string(m.default)}`);a>0&&e.blank(),e.line("@staticmethod"),e.block(`def ${c}(${i.join(", ")}) -> str:`,()=>{e.line(`return ${me(r)}`)})})}),e.blank()}function V(e,n,t,s,r,a,c){let i=s?"AsyncClient":"Client",m=s?"httpx.AsyncClient":"httpx.Client";e.block(`class ${i}:`,()=>{e.doc(`${s?"Async ":""}client for ${n.title} (${n.version}).`),e.block(`def __init__(self, server_url: str = ${f.string(a)}, *, auth: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, str]] = None, timeout: Optional[float] = None, retry: Optional[Dict[str, Any]] = None, middleware: Optional[List[Any]] = None, idempotency_key: Any = None, http_client: Optional[${m}] = None) -> None:`,()=>{e.line("self._server_url = server_url"),e.line("self._auth = auth or {}"),e.line("self._config: Dict[str, Any] = {"),e.indent(()=>{e.line('"headers": headers or {},'),e.line('"timeout": timeout,'),e.line('"retry": retry or {},'),e.line('"middleware": middleware or [],'),e.line('"idempotency_key": idempotency_key,')}),e.line("}"),e.line(`self._http = http_client or ${m}()`)}),e.blank();for(let{op:l,ident:o}of I(n)){G(e,l,o,t,s,c),L(l)===void 0&&(l.successResponseHeaders?.length??0)>0&&G(e,l,o,t,s,c,n,!0);let d=r.get(o);if(d!==void 0){let u=R(l),$=oe(u,typeof d.items=="string"?d.items:void 0,n);le(e,l,o,s,$===void 0?"Any":y($,c),c)}}}),e.blank()}function z(e){let n=new Map,t=new Set,s=[];for(let{name:a,schema:c}of e.schemas){let i=T(c,e);if(!(i===void 0||!i.cases.every(l=>B(l.schema,e)?.properties.some(o=>o.name===i.property)===!0))){for(let l of i.cases){let o=n.get(l.schemaName);if(o!==void 0&&o.value!==l.value){t.add(l.schemaName);continue}n.set(l.schemaName,{property:i.property,value:l.value})}s.push({name:a,property:i.property,members:i.cases.map(l=>l.schemaName)})}}let r=new Map;for(let a of s)a.members.some(c=>t.has(c))||r.set(a.name,q(a.property).python);for(let a of t)n.delete(a);return{pins:n,unions:r}}function fe(e,n,t,s,r,a,c){let i=r==="pydantic";i||e.line("@dataclass");let m=i?`class ${O(n)}(BaseModel):`:`class ${O(n)}:`;e.block(m,()=>{e.doc(a),i&&(e.line("model_config = ConfigDict(populate_by_name=True)"),e.blank());let l=[...t.filter(d=>d.required),...t.filter(d=>!d.required)],o=[];l.length===0&&e.line("pass");for(let d of l){let{python:u,renamed:$}=q(d.name);$&&!i&&o.push([u,d.name]);let h=$&&i?`alias=${f.string(d.name)}`:void 0,g=c?.property===d.name?`Literal[${f.literal(c.value)}]`:y(d.schema,s);if(d.required){let x=h===void 0?"":` = Field(${h})`;e.line(`${u}: ${g}${x}`)}else{let x=g.startsWith("Optional[")?g:`Optional[${g}]`,P=h===void 0?"None":`Field(default=None, ${h})`;e.line(`${u}: ${x} = ${P}`)}}if(o.length>0){e.blank(),e.line("# Python field name -> wire (JSON) name, for (de)serialization.");let d=o.map(([u,$])=>`"${u}": ${f.string($)}`).join(", ");e.line(`_field_map: ClassVar[Dict[str, str]] = {${d}}`)}}),e.blank(),e.blank()}function J(e,n="string",t="dataclass"){let s=new j,{pins:r,unions:a}=t==="pydantic"?z(e):{pins:new Map,unions:new Map};s.line("from __future__ import annotations"),s.blank(),t==="dataclass"&&s.line("from dataclasses import dataclass"),s.line("from enum import Enum");let c=["Any","AsyncIterator","Dict","Iterator","List","Literal","Optional","Tuple","Union"];t==="dataclass"&&c.splice(2,0,"ClassVar"),a.size>0&&c.unshift("Annotated"),s.line(`from typing import ${c.join(", ")}`),t==="pydantic"&&s.line("from pydantic import BaseModel, ConfigDict, Field"),n==="Date"&&s.line("from datetime import date, datetime"),s.blank(),s.blank();let i=[];for(let{name:m,schema:l}of e.schemas){let o=ne(l);if(o!==void 0){let d=o.scalar==="string"?"str, Enum":"int, Enum";s.block(`class ${O(m)}(${d}):`,()=>{s.doc(l.description),o.values.forEach((u,$)=>{s.line(`${o.memberNames[$]} = ${f.literal(u)}`)})}),s.blank(),s.blank();continue}if(l.kind==="object"||l.kind==="intersection"){let d=B(l,e);if(d!==void 0){fe(s,m,d.properties,n,t,d.description??l.description,r.get(m));continue}}i.push(()=>{let d=T(l,e);if(d!==void 0){let h=d.cases.map(g=>`${g.value} -> ${O(g.schemaName)}`).join(", ");s.line(`# Discriminated by "${d.property}": ${h}`)}let u=a.get(m),$=u===void 0?y(l,n):`Annotated[${y(l,n)}, Field(discriminator=${f.string(u)})]`;s.line(`${O(m)} = ${$}`),s.blank()})}for(let m of i)m();return s.toString()}function pe(e,n){let t=[];for(let{name:s,schema:r}of e.schemas){if(n.has(s))continue;let a=T(r,e);if(a===void 0)continue;let c=a.cases.map(i=>`${f.string(i.value)}: ${O(i.schemaName)}`).join(", ");t.push(`DISCRIMINATORS[${O(s)}] = (${f.string(a.property)}, {${c}})`)}return t}var nn={type:"object",properties:{models:{enum:["dataclass","pydantic"],default:"dataclass",description:"Model style: standard-library dataclasses (default, httpx is the only dependency), or pydantic BaseModel classes (adds pydantic)."}},additionalProperties:!1};function Q(e){let n=e.lastIndexOf("/")>=0?"/":"\\",t=e.lastIndexOf(n),s=t>=0?e.slice(0,t+1):"",r=(t>=0?e.slice(t+1):e).replace(/\.[^.]+$/,"");return`${s}${k(r,{style:"snake",reserved:N})}.py`}var tn=({model:e,output:n,banner:t,emit:s,options:r,pagination:a})=>{let c=s.errorMode??"throw",i=s.dateType??"string",m=r?.models??"dataclass",l=m==="pydantic"?z(e):void 0,o=new j;if(o.line(`# Generated by @redocly/client-generator (python) from "${e.title}" ${e.version}.`),o.line("# Do not edit by hand \u2014 regenerate with `redocly generate-client`."),o.line(m==="pydantic"?"# Requires Python >= 3.9, httpx, and pydantic: pip install httpx pydantic":"# Requires Python >= 3.9 and httpx: pip install httpx"),o.blank(),o.line(J(e,i,m).trimEnd()),o.blank(),o.blank(),de(o,e),s.runtime==="module"){o.line("# \u2500\u2500\u2500 Runtime (real modules beside this file, written by the same run) \u2500\u2500\u2500");for(let p of Object.keys(U))o.line(`from ${p.replace(/\.py$/,"")} import *`);o.blank(),o.blank()}else{o.line("# \u2500\u2500\u2500 Embedded runtime (@redocly/client-generator python runtime) \u2500\u2500\u2500");for(let p of Object.values(U)){let _=p.split(`
|
|
9
9
|
`).filter(b=>!b.startsWith("from __future__")&&!b.startsWith("from ._")).join(`
|
|
10
10
|
`).trim();o.line(_),o.blank()}o.blank()}let d=pe(e,new Set(l?.unions.keys()));if(d.length>0){o.line("# Discriminated unions dispatch by their property inside decode().");for(let p of d)o.line(p);o.blank()}o.block("def _safe_json(response: httpx.Response) -> Any:",()=>{o.block("try:",()=>{o.line("return response.json()")}),o.block("except Exception:",()=>{o.line("return None")})}),o.blank();let u=new Map;for(let{op:p,ident:_}of I(e))u.set(_,ie(a?.get(p.name)?.spec));o.line("_OPERATIONS = {"),o.indent(()=>{for(let{op:p,ident:_}of I(e)){let b={id:p.specName??p.name,method:p.method.toUpperCase(),path:p.path,...K(p,e).length>0?{security:K(p,e)}:{},...u.get(_)!==void 0?{pagination:u.get(_)}:{}};o.line(`"${_}": ${ae(b)},`)}}),o.line("}"),o.blank(),o.blank();let $=s.serverUrl??e.serverUrl??"";V(o,e,c,!1,u,$,i),V(o,e,c,!0,u,$,i);let h={path:Q(n.path),content:o.toString()};if(s.runtime!=="module")return[h];let g=t.map(p=>`# ${p}`).join(`
|
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as q}from"./
|
|
7
|
+
import{a as q}from"./YZRKJF2V.js";import{h as H,l as B,r as z,t as K,u as V,v as Z,w as _}from"./SQUNMRDS.js";import{b as J,d as M,e as Y,v as L}from"./ZIIE7LXR.js";import"./LRUXN6H5.js";import{$ as j,T as N,X as v,Z as O,_ as A,aa as b,ca as y,da as C,ea as R,ga as e,l as h,ma as w,na as D,sa as S,va as g}from"./JD3HIQIK.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{dirname as le}from"node:path";function W(r,t,o,n){n&&e.info(C(v(`
|
|
8
8
|
\u2611\uFE0F Achieved Level: ${y(o)}
|
|
9
9
|
|
|
10
10
|
`))),e.output(`<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -4,4 +4,4 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e}from"./
|
|
7
|
+
import{a,b,c,d,e}from"./PZF2WPD3.js";import"./2U6O26CV.js";import"./FYDETXDC.js";import"./IBYLYDST.js";import"./WZXA5XPB.js";import"./JD3HIQIK.js";import"./NEWT5A6S.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{e as goDocs,c as goGenerator,d as goSample,a as goType,b as renderGoModels};
|
|
@@ -4,4 +4,4 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
var e={name:"@redocly/cli",version:"2.
|
|
7
|
+
var e={name:"@redocly/cli",version:"2.58.1",description:"",license:"MIT",bin:{redocly:"bin/cli.js",openapi:"bin/cli.js"},type:"module",engines:{node:">=22.12.0 || >=20.19.0 <21.0.0",npm:">=10"},engineStrict:!0,scripts:{build:"node ./scripts/build.mjs","prepare:publish-dir":"node ./scripts/prepare-publish-dir.mjs","clean:publish-dir":`node -e "require('fs').rmSync('.publish', {recursive:true, force:true})"`},publishConfig:{directory:".publish"},repository:{type:"git",url:"git+https://github.com/Redocly/redocly-cli.git"},homepage:"https://github.com/Redocly/redocly-cli",keywords:["linter","OpenAPI","Swagger","OpenAPI linter","Swagger linter","AsyncAPI linter","Arazzo linter","oas"],contributors:["Roman Hotsiy <roman@redocly.com> (https://redocly.com/)"],devDependencies:{"@modelcontextprotocol/sdk":"^1.30.0","@opentelemetry/exporter-trace-otlp-http":"0.219.0","@opentelemetry/resources":"2.8.0","@opentelemetry/sdk-trace-node":"2.8.0","@opentelemetry/semantic-conventions":"1.41.1","@redocly/cli-otel":"0.3.7","@redocly/client-generator":"0.4.22","@redocly/openapi-core":"2.58.1","@redocly/recheck":"2.58.1","@redocly/respect-core":"2.58.1","@redocly/reunite-integration":"2.58.1","@types/cookie":"0.6.0","@types/har-format":"^1.2.16","@types/react":"^17.0.0 || ^18.2.21 || ^19.2.16","@types/react-dom":"^17.0.0 || ^18.2.7 || ^19.2.3","@types/semver":"^7.5.0","@types/set-cookie-parser":"2.4.10","@types/yargs":"17.0.32",colorette:"^1.2.0",cookie:"^0.7.2",dotenv:"16.4.7",esbuild:"^0.28.0",glob:"^13.0.5",handlebars:"^4.7.9",react:"^17.0.0 || ^18.2.0 || ^19.2.7","react-dom":"^17.0.0 || ^18.2.0 || ^19.2.7",redoc:"2.5.4",semver:"^7.5.2","set-cookie-parser":"^2.3.5","styled-components":"6.4.2",typescript:"6.0.2",ulid:"^3.0.1",undici:"^6.29.0",yargs:"17.0.1"}};var{version:c,name:i,engines:s}=e,n=e.devDependencies.redoc,p="sha384-w447zOpYfw/1Tv/5AK9NfHTlQIqE3RVR6KY62jCyy9zNDgO64cMwGGP1Fj0zJVf5";export{c as a,i as b,s as c,n as d,p as e};
|
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{
|
|
7
|
+
import{b as S,c as N,e as R,j as g,k as _,o as v,q as F,r as U,s as b,v as s}from"./ZIIE7LXR.js";import{$,_ as y,aa as i,ea as u,ga as n,na as k,pa as T,t as O,ta as B,ua as E}from"./JD3HIQIK.js";import{writeFileSync as L}from"fs";import{resolve as j}from"path";import{performance as q}from"perf_hooks";var P={};async function Y({argv:e,config:l,version:W,collectSpecData:G}){let A=await S(e.apis,l),a={errors:0,warnings:0,ignored:0},I=N(l);for(let{path:o,alias:c,output:J}of A)try{let d=q.now(),p=l.forAlias(c);p.skipPreprocessors(e["skip-preprocessor"]),p.skipDecorators(e["skip-decorator"]);let m=e.overlay??p.resolvedConfig.overlays?.map(t=>O(t)?t:j(I,t));m?.length&&(P.bundle_overlays_count=(P.bundle_overlays_count??0)+m.length),c===void 0?n.info(u(`bundling ${s(o)}...
|
|
8
8
|
`)):n.info(u(`bundling ${s(o)} using configuration for api '${c}'...
|
|
9
9
|
`));let{bundle:D,problems:w,...x}=await T({ref:o,config:p,dereference:e.dereferenced,removeUnusedComponents:e["remove-unused-components"],keepUrlRefs:e["keep-url-references"],componentRenamingConflicts:e["component-renaming-conflicts-severity"],componentNamesStrategy:e["component-names-strategy"],overlays:m,collectSpecData:G}),r=B(w),{outputFile:f,ext:K}=F({entrypoint:o,output:J,argvOutput:e.output,ext:e.ext,entries:e?.apis?.length||0});if(r.errors===0||e.force)if(f){let t=g(b(D.parsed),K,e.dereferenced);_(f,t)}else{let t=g(b(D.parsed),e.ext||"yaml",e.dereferenced);n.output(t)}a.errors+=r.errors,a.warnings+=r.warnings,a.ignored+=r.ignored,E(w,{format:"codeframe",totals:r,version:W,command:"bundle"}),e.metafile&&(A.length>1&&n.warn('[WARNING] "--metafile" cannot be used with multiple apis. Skipping...'),L(e.metafile,JSON.stringify(x),"utf-8"));let h=R(d);r.errors>0?e.force?n.info(`\u2753 Created a bundle for ${i(s(o))} at ${i(f||"stdout")} with errors ${y(h)}.
|
|
10
10
|
${$("Errors ignored because of --force")}.
|
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as P,b as y,c as $}from"./
|
|
7
|
+
import{a as P,b as y,c as $}from"./263OU3EK.js";import{ga as h,xa as x}from"./JD3HIQIK.js";function N(t){let e=t.trim(),n=e.match(/^```(?:ya?ml|json)?\s*\n([\s\S]*?)\n```$/);return n?n[1]:e}async function O(t,e){let r=(await x({source:t,config:e})).filter(o=>o.severity==="error");if(r.length>0){let o=r.slice(0,5).map(s=>`${s.ruleId}: ${s.message}`).join("; ");throw new Error(`the result has ${r.length} validation problem(s): ${o}`)}}import{spawn as T}from"node:child_process";import{mkdtemp as v}from"node:fs/promises";import{tmpdir as R}from"node:os";import S from"node:path";var I=3e5,a=class extends Error{},C;function L(){return C??=v(S.join(R(),"redocly-ai-")),C}async function w(t,e,n,r){let o=await L();return new Promise((s,u)=>{let i=T(t,e,{stdio:["pipe","pipe","pipe"],cwd:o,env:{...process.env,...r}}),l="",f="",g=!1,d=setTimeout(()=>{g=!0,i.kill("SIGKILL")},I);i.stdout.on("data",c=>{l+=c.toString()}),i.stderr.on("data",c=>{f+=c.toString()}),i.on("error",c=>{if(clearTimeout(d),c.code==="ENOENT"){u(new a(`Could not find the "${t}" CLI on PATH. Is it installed?`));return}u(c)}),i.on("close",c=>{if(clearTimeout(d),g){u(new Error(`The "${t}" CLI did not respond within ${I/1e3} seconds.`));return}s({stdout:l,stderr:f,code:c})}),i.stdin.on("error",()=>{}),i.stdin.end(n)})}async function A(t){let e=["-p","--output-format","text","--tools","","--strict-mcp-config","--setting-sources","","--no-session-persistence","--append-system-prompt",t.system];t.model&&e.push("--model",t.model);let{stdout:n,stderr:r,code:o}=await w("claude",e,t.user,{CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:"1"});if(o!==0)throw new Error(`claude CLI exited with code ${o}: ${r.trim()||n.trim()}`);if(!n.trim())throw new Error("claude CLI returned no output.");return{text:n}}async function b(t){let e=["exec","--skip-git-repo-check","--sandbox","read-only","-c","mcp_servers={}","-c","project_doc_max_bytes=0"];t.model&&e.push("--model",t.model),e.push("-");let n=`${t.system}
|
|
8
8
|
|
|
9
9
|
${t.user}`,{stdout:r,stderr:o,code:s}=await w("codex",e,n);if(s!==0)throw new Error(`codex CLI exited with code ${s}: ${o.trim()||r.trim()}`);if(!r.trim())throw new Error("codex CLI returned no output.");return{text:r}}async function _(t){let e=["-p","--output-format","text","--trust"];t.model&&e.push("--model",t.model);let n=`${t.system}
|
|
10
10
|
|
|
@@ -4,6 +4,6 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{b as m,j as C,o as a,p,q as T,r as l,s as h,t as f,u as d}from"./
|
|
7
|
+
import{b as m,j as C,o as a,p,q as T,r as l,s as h,t as f,u as d}from"./MVXFJBMU.js";import{c as g}from"./JD3HIQIK.js";import A from"node:path";function L(e,n){if(C(e)!=="application/x-www-form-urlencoded"||!Array.isArray(n))return;let o=new URLSearchParams;for(let s of n){if(!g(s))continue;let t=a(s.name);t!==void 0&&o.append(t,a(s.value)??"")}return o.size>0?o.toString():void 0}function K(e,n,o){let s=e?.request,t=e?.response;if(!s)return null;let r=s?.postData,i=a(r?.mimeType),u=r?.text??L(i,r?.params),c=a(r?.encoding),y=t?.content?.text,S=a(t?.content?.encoding),q=p(t?.status);return l({method:a(s?.method),url:a(s?.url),requestHeaders:s?.headers,requestBody:T(u,c),requestContentType:i,responseStatus:q===0?void 0:q,responseStatusText:a(t?.statusText),responseHeaders:t?.headers,responseBody:T(y,S),responseContentType:a(t?.content?.mimeType),startedAt:a(e?.startedDateTime),raw:e},n,o)}var b=class{id="har";canParse(n,o){if(A.extname(n).toLowerCase()===".har")return!0;let t=o.toLowerCase();return t.includes('"log"')&&t.includes('"entries"')}async*parse(n){let o=0;for await(let s of f(n,"log.entries")){let t=K(s,o,n);t&&(yield t),o+=1}}};import $ from"node:path";function H(e){let n=a(e.url??e.uri);if(n)return{url:n};let o=a(e.host??e.headers?.host),s=a(e.path??e.request_uri),t=a(e.scheme??e.forwarded_proto);return o&&s?{url:`${t??"http"}://${o}${s}`,schemeKnown:!!t}:{url:s,schemeKnown:!!t}}function z(e,n,o){let s=e?.request??e?.req??e?.http?.request;if(!s)return null;let t=e?.response??e?.res??e?.http?.response,r=t?.body??t?.raw_body??t?.payload??t?.data,i=s?.body??s?.raw_body??s?.payload??s?.data,{url:u,schemeKnown:c}=H(s);return l({method:a(s?.method??s?.http_method),url:u,schemeKnown:c,requestHeaders:s?.headers,requestBody:i,requestContentType:d(s?.headers),responseStatus:p(t?.status??t?.statusCode),responseHeaders:t?.headers,responseBody:r,responseContentType:d(t?.headers),startedAt:a(e?.started_at??e?.startedAt??e?.timestamp),raw:e},n,o)}var x=class{id="kong";canParse(n,o){if($.extname(n).toLowerCase()===".kong")return!0;let t=o.toLowerCase();return t.includes('"latencies"')||t.includes('"request"')&&t.includes('"response"')&&t.includes('"route"')}async*parse(n){let o=(await m(n,16)).trim().slice(0,1),s=0;if(o==="["){for await(let t of f(n)){let r=z(t,s,n);r&&(yield r),s+=1}return}for await(let t of h(n)){let r=z(t,s,n);r&&(yield r),s+=1}}};import R from"node:path";function U(e){return e?.request??e?.req??e?.httpRequest??e?.http?.request??e}function I(e){return e?.response??e?.res??e?.httpResponse??e?.http?.response}function O(e,n){let o=a(n?.url??n?.uri??n?.requestUrl??e?.url);if(o)return{url:o};let s=a(n?.host??n?.headers?.host??e?.host),t=a(n?.path??e?.path??n?.pathname),r=a(n?.scheme??e?.scheme);return s&&t?{url:`${r??"http"}://${s}${t}`,schemeKnown:!!r}:{url:t,schemeKnown:!!r}}function k(e,n,o){let s=U(e),t=I(e),r=s?.body??s?.bodyText??s?.payload??s?.data??s?.rawBody,i=t?.body??t?.bodyText??t?.payload??t?.data??t?.rawBody,{url:u,schemeKnown:c}=O(e,s);return l({method:a(s?.method??s?.httpMethod??e?.method??e?.httpMethod),url:u,schemeKnown:c,requestHeaders:s?.headers,requestBody:r,requestContentType:d(s?.headers),responseStatus:p(t?.status??t?.statusCode??e?.status??e?.statusCode),responseHeaders:t?.headers,responseBody:i,responseContentType:d(t?.headers),startedAt:a(e?.startedAt??e?.timestamp??e?.time),raw:e},n,o)}var w=class{id="ndjson";canParse(n,o){let s=R.extname(n).toLowerCase();if(s===".ndjson"||s===".jsonl"||s===".jsonlines")return!0;let t=o.lastIndexOf(`
|
|
8
8
|
`),i=(t===-1?o:o.slice(0,t)).split(`
|
|
9
9
|
`).map(u=>u.trim()).find(Boolean);if(!i?.startsWith("{")||!i.endsWith("}"))return!1;try{return JSON.parse(i),!0}catch{return!1}}async*parse(n){let o=0;for await(let s of h(n)){let t=k(s,o,n);t&&(yield t),o+=1}}};import J from"node:path";function P(e){if(!e)return{};let n=e.trim().split(/\s+/);return n.length<2?{}:{method:n[0],path:n[1],protocol:n[2]}}function W(e,n){let o=a(n?.url??n?.request_uri??n?.uri??e?.url??e?.request_url??e?.absolute_uri),s=P(a(e?.request??n?.request_line)),t=a(n?.request_uri??n?.uri??n?.path??e?.request_uri??e?.uri)??s.path;if(o?.startsWith("http://")||o?.startsWith("https://"))return{url:o};let r=a(n?.host??n?.headers?.host??e?.host??e?.http_host??e?.server_name??e?.vhost),i=a(e?.scheme??n?.scheme??e?.request_scheme),u=!!i;if(r&&(o||t)){let c=i??"http",y=o??t;return y?.startsWith("/")?{url:`${c}://${r}${y}`,schemeKnown:u}:{url:`${c}://${r}/${y}`,schemeKnown:u}}return{url:o??t,schemeKnown:u}}function E(e,n,o){let s=g(e?.request)?e.request:e,t=g(e?.response)?e.response:void 0,r=P(a(e?.request)),i=a(s?.method??s?.request_method??e?.request_method??e?.method)??r.method,{url:u,schemeKnown:c}=W(e,s);return l({method:i,url:u,schemeKnown:c,requestHeaders:s?.headers??s?.request_headers??e?.request_headers??e?.headers,requestBody:s?.body??s?.request_body??e?.request_body??e?.body,requestContentType:d(s?.headers??s?.request_headers??e?.request_headers),responseStatus:p(t?.status??t?.status_code??e?.status??e?.status_code??e?.response_status),responseHeaders:t?.headers??t?.response_headers??e?.response_headers??e?.headers_out,responseBody:t?.body??t?.response_body??e?.response_body,responseContentType:d(t?.headers??t?.response_headers??e?.response_headers),startedAt:a(e?.time_iso8601??e?.timestamp??e?.time??e?.time_local??e?.["@timestamp"]),raw:e},n,o)}async function*j(e){if((await m(e,16)).trim().slice(0,1)==="["){yield*f(e);return}for await(let o of h(e))yield o}var N=class{id="nginx-json";canParse(n,o){let s=J.extname(n).toLowerCase(),t=n.toLowerCase();if(s===".ndjson"&&t.includes("nginx"))return!0;let r=o.toLowerCase();return r.includes('"request_uri"')||r.includes('"time_iso8601"')||r.includes('"upstream_response_time"')||r.includes('"remote_addr"')}async*parse(n){let o=0;for await(let s of j(n)){let t=E(s,o,n);t&&(yield t),o+=1}}},_=class{id="apache-json";canParse(n,o){let s=J.extname(n).toLowerCase(),t=n.toLowerCase();if(s===".ndjson"&&t.includes("apache"))return!0;let r=o.toLowerCase();return r.includes('"request_method"')||r.includes('"request_uri"')||r.includes('"vhost"')||r.includes('"response_status"')}async*parse(n){let o=0;for await(let s of j(n)){let t=E(s,o,n);t&&(yield t),o+=1}}};var B=[new b,new x,new N,new _,new w];async function le(e,n){if(n!=="auto"){let s=B.find(t=>t.id===n);if(!s)throw new Error(`Unsupported parser format: ${n}`);return s}let o=await m(e);return B.find(s=>s.canParse(e,o))}export{le as a};
|