@scalar/api-reference 1.59.1 → 1.59.3
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/CHANGELOG.md +18 -0
- package/dist/blocks/scalar-info-block/components/InfoLinks.vue.d.ts.map +1 -1
- package/dist/blocks/scalar-info-block/components/InfoLinks.vue.js.map +1 -1
- package/dist/blocks/scalar-info-block/components/InfoLinks.vue.script.js +12 -7
- package/dist/blocks/scalar-info-block/components/InfoLinks.vue.script.js.map +1 -1
- package/dist/blocks/scalar-sdk-installation-instructions/components/SdkInstallationInstructions.vue.d.ts +13 -0
- package/dist/blocks/scalar-sdk-installation-instructions/components/SdkInstallationInstructions.vue.d.ts.map +1 -1
- package/dist/blocks/scalar-sdk-installation-instructions/components/SdkInstallationInstructions.vue.js +1 -1
- package/dist/blocks/scalar-sdk-installation-instructions/components/SdkInstallationInstructions.vue.js.map +1 -1
- package/dist/blocks/scalar-sdk-installation-instructions/components/SdkInstallationInstructions.vue.script.js +32 -8
- package/dist/blocks/scalar-sdk-installation-instructions/components/SdkInstallationInstructions.vue.script.js.map +1 -1
- package/dist/blocks/scalar-sdk-installation-instructions/helpers/renderable-sdks.d.ts +16 -7
- package/dist/blocks/scalar-sdk-installation-instructions/helpers/renderable-sdks.d.ts.map +1 -1
- package/dist/blocks/scalar-sdk-installation-instructions/helpers/renderable-sdks.js +33 -7
- package/dist/blocks/scalar-sdk-installation-instructions/helpers/renderable-sdks.js.map +1 -1
- package/dist/browser/chunks/AgentScalarChatInterface-Dv0uBVU9.js +27 -0
- package/dist/browser/chunks/ScalarTextInput.vue-ZmlutrTU.js +27 -0
- package/dist/browser/chunks/basic-shape-diamond.svg-BTEOT1FL.js +1 -1
- package/dist/browser/chunks/basic-shape-hexagon.svg-BSPzaCgF.js +1 -1
- package/dist/browser/chunks/basic-shape-primary-circle-ellipse-round.svg-DKmZ8UUU.js +1 -1
- package/dist/browser/chunks/basic-shape-primary-square-rectangle.svg-n2YRykHD.js +1 -1
- package/dist/browser/chunks/basic-shape-shield.svg-Bec9cJDA.js +1 -1
- package/dist/browser/chunks/browser-67K6wmG9.js +1 -1
- package/dist/browser/chunks/computer-device-desktop-monitor.svg-m6j893Hb.js +1 -1
- package/dist/browser/chunks/computer-device-desktop.svg-Dk1VVO7k.js +1 -1
- package/dist/browser/chunks/computer-device-laptop.svg-BNGVUCYS.js +1 -1
- package/dist/browser/chunks/computer-device-mobile-phone-android-samsung-back.svg-CC4UUTFw.js +1 -1
- package/dist/browser/chunks/computer-device-mobile-phone-android-samsung.svg-D8ExpMpL.js +1 -1
- package/dist/browser/chunks/computer-device-mobile-phone-iphone-x-back.svg-CLm7sgMM.js +1 -1
- package/dist/browser/chunks/computer-device-mobile-phone-iphone-x.svg-Xrttg6_7.js +1 -1
- package/dist/browser/chunks/computer-device-mobile-tablet-touch.svg-DQ2oTvOG.js +1 -1
- package/dist/browser/chunks/computer-device-mobile-tablet.svg-DCr0XlRc.js +1 -1
- package/dist/browser/chunks/computer-device-network-ethernet-cat6.svg-AK9l0iOl.js +1 -1
- package/dist/browser/chunks/computer-device-network-lan-www.svg-gUIdFBlE.js +1 -1
- package/dist/browser/chunks/computer-device-network-wifi-connection.svg-Be-EMm4e.js +1 -1
- package/dist/browser/chunks/computer-device-network-wifi-router.svg-Dc2VzyqK.js +1 -1
- package/dist/browser/chunks/ecology-science-erlenmeyer-flask.svg-DHgy7Jfd.js +1 -1
- package/dist/browser/chunks/image-flash-lightning.svg-EETR_y1q.js +1 -1
- package/dist/browser/chunks/image-picture-flower.svg-DN1AYzJU.js +1 -1
- package/dist/browser/chunks/interface-alert-exclamation-diamond.svg-C5NozMV_.js +1 -1
- package/dist/browser/chunks/interface-alert-exclamation-triangle-warning.svg-DaAg2fF5.js +1 -1
- package/dist/browser/chunks/interface-alert-information-circle.svg-ckkkt9Mv.js +1 -1
- package/dist/browser/chunks/interface-award-crown.svg-pjvn9hY-.js +1 -1
- package/dist/browser/chunks/interface-bookmark-tag.svg-r2r-lQq4.js +1 -1
- package/dist/browser/chunks/interface-bookmark.svg-BK9HKQBT.js +1 -1
- package/dist/browser/chunks/interface-calendar-date-one.svg-DNnF0M1I.js +1 -1
- package/dist/browser/chunks/interface-content-book-open-pages.svg-CQj_w9Vp.js +1 -1
- package/dist/browser/chunks/interface-content-book-page.svg-DppoeJRe.js +1 -1
- package/dist/browser/chunks/interface-content-file.svg-CvcD7OiY.js +1 -1
- package/dist/browser/chunks/interface-content-folder.svg-BmtS5I9A.js +1 -1
- package/dist/browser/chunks/interface-copy-clipboard.svg-Be6EI50X.js +1 -1
- package/dist/browser/chunks/interface-edit-attachment.svg-G5TKzpWX.js +1 -1
- package/dist/browser/chunks/interface-edit-binocular.svg-jzL-DvGB.js +1 -1
- package/dist/browser/chunks/interface-edit-magic-wand.svg-BOTlymvp.js +1 -1
- package/dist/browser/chunks/interface-edit-tool-paint-roller.svg-s9dwryx7.js +1 -1
- package/dist/browser/chunks/interface-edit-tool-pencil.svg-C7v0dbB3.js +1 -1
- package/dist/browser/chunks/interface-favorite-award.svg-CYHUgUG0.js +1 -1
- package/dist/browser/chunks/interface-favorite-flag.svg-C10zlKOb.js +1 -1
- package/dist/browser/chunks/interface-favorite-heart.svg-eoduXxlz.js +1 -1
- package/dist/browser/chunks/interface-favorite-star.svg-BSmxJetr.js +1 -1
- package/dist/browser/chunks/interface-favorite-stars-sparkles.svg-JTFLj3Ls.js +1 -1
- package/dist/browser/chunks/interface-hierarchy-flowchart.svg-Cg_Wy0kN.js +1 -1
- package/dist/browser/chunks/interface-home-house.svg-DytoGRnv.js +1 -1
- package/dist/browser/chunks/interface-hyperlink.svg-CuEfmmQI.js +1 -1
- package/dist/browser/chunks/interface-lighting-brightness.svg-DSK0h_Pa.js +1 -1
- package/dist/browser/chunks/interface-lock-closed.svg-Cn6TaLYv.js +1 -1
- package/dist/browser/chunks/interface-lock-open-unlock.svg-CVkG5-9W.js +1 -1
- package/dist/browser/chunks/interface-login-key.svg-y-cwwXjN.js +1 -1
- package/dist/browser/chunks/interface-search.svg-S-puVFJB.js +1 -1
- package/dist/browser/chunks/interface-setting-cog.svg-CTH4_lLg.js +1 -1
- package/dist/browser/chunks/interface-share-megaphone-bullhorn.svg-Pbp39MyC.js +1 -1
- package/dist/browser/chunks/interface-share-rocket.svg-BgCsIRZO.js +1 -1
- package/dist/browser/chunks/interface-share-satellite.svg-DAMN9d5G.js +1 -1
- package/dist/browser/chunks/interface-share-space-ship.svg-Dt-Mejxk.js +1 -1
- package/dist/browser/chunks/interface-share.svg-vFYTXSti.js +1 -1
- package/dist/browser/chunks/interface-signal-square.svg-DNG4LpAe.js +1 -1
- package/dist/browser/chunks/interface-time-clock-circle.svg-Bpz-nLxo.js +1 -1
- package/dist/browser/chunks/interface-time-hour-glass.svg-D7agfKsH.js +1 -1
- package/dist/browser/chunks/interface-users-multiple.svg-CkPJBBnG.js +1 -1
- package/dist/browser/chunks/interface-weather-moon.svg-CaTZFMPO.js +1 -1
- package/dist/browser/chunks/mail-chat-bubble-square.svg-DC8RIihp.js +1 -1
- package/dist/browser/chunks/mail-send-email-paper-airplane.svg-D8OLs9jz.js +1 -1
- package/dist/browser/chunks/mail-send-envelope.svg-CV33h5Sx.js +1 -1
- package/dist/browser/chunks/{modal-Crw1-pTJ.js → modal-Bh68oUy_.js} +2 -2
- package/dist/browser/chunks/modal-DHI6k89v.js +66 -0
- package/dist/browser/chunks/money-cashier-receipt.svg-CJL8C2gs.js +1 -1
- package/dist/browser/chunks/money-currency-dollar-pay.svg-VdBplCTx.js +1 -1
- package/dist/browser/chunks/money-graph-arrow-increase.svg-DcRov3zk.js +1 -1
- package/dist/browser/chunks/money-graph-bar-chart-increase.svg-Cc7KxjX-.js +1 -1
- package/dist/browser/chunks/nature-ecology-leaf.svg-DR3cTZxt.js +1 -1
- package/dist/browser/chunks/phone-telephone.svg-DyY0gUlk.js +1 -1
- package/dist/browser/chunks/programming-bug.svg-BHLT-Qhp.js +1 -1
- package/dist/browser/chunks/programming-cloud.svg-B6YW33ba.js +1 -1
- package/dist/browser/chunks/programming-computer-database-server.svg-B6o5Sdn-.js +1 -1
- package/dist/browser/chunks/programming-computer-database.svg-Cl7OVtpJ.js +1 -1
- package/dist/browser/chunks/programming-module-four-layout.svg-BQrerL1x.js +1 -1
- package/dist/browser/chunks/programming-module-three.svg-B2KTQzBM.js +1 -1
- package/dist/browser/chunks/programming-module.svg-CiID7kPm.js +1 -1
- package/dist/browser/chunks/programming-script-code.svg-D1M5rtkN.js +1 -1
- package/dist/browser/chunks/runtime-core.esm-bundler-Byrbbu5Q.js +1 -1
- package/dist/browser/chunks/shopping-cart.svg-BEegiIR9.js +1 -1
- package/dist/browser/chunks/shopping-gift-present.svg-BUHwuLix.js +1 -1
- package/dist/browser/chunks/shopping-shipping-box-parcel-package.svg-D6fxWdYx.js +1 -1
- package/dist/browser/chunks/tag-new-circle.svg-jsg1bGs0.js +1 -1
- package/dist/browser/chunks/travel-map-earth-globe.svg-ClbMiU-f.js +1 -1
- package/dist/browser/chunks/{vendor-Dp5Q6nDX.js → vendor-Cx_C-51y.js} +137 -137
- package/dist/browser/standalone.esm.js +21 -19
- package/dist/browser/standalone.js +244 -242
- package/dist/components/ApiReference.vue.js +1 -1
- package/dist/components/ApiReference.vue.js.map +1 -1
- package/dist/components/ApiReference.vue.script.js +3 -3
- package/dist/components/ApiReference.vue.script.js.map +1 -1
- package/dist/components/Content/Content.vue.d.ts.map +1 -1
- package/dist/components/Content/Content.vue.js.map +1 -1
- package/dist/components/Content/Content.vue.script.js +7 -1
- package/dist/components/Content/Content.vue.script.js.map +1 -1
- package/dist/components/Content/Operations/TraversedEntry.vue.d.ts.map +1 -1
- package/dist/components/Content/Operations/TraversedEntry.vue.js.map +1 -1
- package/dist/components/Content/Operations/TraversedEntry.vue.script.js +2 -1
- package/dist/components/Content/Operations/TraversedEntry.vue.script.js.map +1 -1
- package/dist/features/Search/helpers/create-search-index.d.ts.map +1 -1
- package/dist/features/Search/helpers/create-search-index.js +4 -3
- package/dist/features/Search/helpers/create-search-index.js.map +1 -1
- package/dist/helpers/id-routing.d.ts +6 -13
- package/dist/helpers/id-routing.d.ts.map +1 -1
- package/dist/helpers/id-routing.js +104 -34
- package/dist/helpers/id-routing.js.map +1 -1
- package/dist/style.css +32 -32
- package/dist/vue-styles.css +32 -32
- package/package.json +14 -12
- package/dist/browser/chunks/AgentScalarChatInterface-CPqxdcxM.js +0 -27
- package/dist/browser/chunks/ScalarTextInput.vue-4iBshoVm.js +0 -27
- package/dist/browser/chunks/modal-DuL3rNXj.js +0 -66
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TraversedEntry.vue.script.js","names":[],"sources":["../../../../src/components/Content/Operations/TraversedEntry.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ClientOptionGroup } from '@scalar/api-client/blocks/operation-code-sample'\nimport type { ApiReferenceConfigurationRaw } from '@scalar/types/api-reference'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { AuthStore } from '@scalar/workspace-store/entities/auth'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { MergedSecuritySchemes } from '@scalar/workspace-store/request-example'\nimport type {\n TraversedEntry,\n TraversedModels,\n TraversedOperation,\n TraversedSchema,\n TraversedTag,\n TraversedWebhook,\n} from '@scalar/workspace-store/schemas/navigation'\nimport type {\n OpenApiDocument,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport Model from '@/components/Content/Models/Model.vue'\nimport ModelTag from '@/components/Content/Models/ModelTag.vue'\nimport { Tag } from '@/components/Content/Tags'\nimport Lazy from '@/components/Lazy/Lazy.vue'\nimport { SectionContainer } from '@/components/Section'\nimport { Operation } from '@/features/Operation'\n\nconst {\n level = 0,\n clientOptions,\n document,\n authStore,\n entries,\n} = defineProps<{\n /** The auth store */\n authStore: AuthStore\n /** The level of depth */\n level?: number\n /** Traversed entries to render */\n entries: TraversedEntry[]\n /** The document object */\n document: OpenApiDocument\n /** The http client options for the dropdown */\n clientOptions: ClientOptionGroup[]\n /** The subset of the configuration object required for the operation component */\n options: Pick<\n ApiReferenceConfigurationRaw,\n | 'expandAllResponses'\n | 'hideTestRequestButton'\n | 'layout'\n | 'orderRequiredPropertiesFirst'\n | 'orderSchemaPropertiesBy'\n | 'expandAllSchemaProperties'\n | 'showOperationId'\n | 'hideModels'\n | 'modelsSectionLabel'\n >\n /** Currently selected server for the document */\n selectedServer: ServerObject | null\n /** The merged security schemes for the document and the authentication configuration */\n securitySchemes: MergedSecuritySchemes\n /** Currently selected http client for the document */\n selectedClient: WorkspaceStore['workspace']['x-scalar-default-client']\n /** Used to determine if an entry is collapsed */\n expandedItems: Record<string, boolean>\n /** The event bus for the handling all events. */\n eventBus: WorkspaceEventBus\n}>()\n\n/**\n * Type guards for different entry types\n */\nconst isTagGroup = (\n entry: TraversedEntry,\n): entry is TraversedTag & { isGroup: true } =>\n entry['type'] === 'tag' && entry.isGroup === true\n\nconst isTag = (\n entry: TraversedEntry,\n): entry is TraversedTag & { isGroup: false } =>\n entry['type'] === 'tag' && !isTagGroup(entry) && entry.id !== 'models'\n\nconst isOperation = (entry: TraversedEntry): entry is TraversedOperation =>\n entry['type'] === 'operation'\n\nconst isWebhook = (entry: TraversedEntry): entry is TraversedWebhook =>\n entry['type'] === 'webhook'\n\n/** Models are special form of tag entry */\nconst isModelsTag = (entry: TraversedEntry): entry is TraversedModels =>\n entry['type'] === 'models'\n\nconst isModel = (entry: TraversedEntry): entry is TraversedSchema =>\n entry['type'] === 'model'\n\nfunction getPathValue(entry: TraversedOperation | TraversedWebhook) {\n return isWebhook(entry)\n ? document.webhooks?.[entry.name]\n : document.paths?.[entry.path]\n}\n</script>\n\n<template>\n <!-- The key must be joined with the layout to force a re-render when the layout changes -->\n <!-- Without this we get a timing issue where the lazy bus is reset and the element is not rendered -->\n <Lazy\n v-for=\"entry in entries\"\n :id=\"entry.id\"\n :key=\"`${entry.id}-${options.layout}`\"\n :expanded=\"!!expandedItems[entry.id]\">\n <!-- Operation or Webhook -->\n <SectionContainer\n v-if=\"isOperation(entry) || isWebhook(entry)\"\n :omit=\"level !== 0\">\n <Operation\n :id=\"entry.id\"\n :authStore\n :clientOptions\n :document\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :isWebhook=\"isWebhook(entry)\"\n :method=\"entry.method\"\n :options=\"options\"\n :path=\"isWebhook(entry) ? entry.name : entry.path\"\n :pathValue=\"getPathValue(entry)\"\n :securitySchemes=\"securitySchemes\"\n :selectedClient=\"selectedClient\"\n :server=\"selectedServer\" />\n </SectionContainer>\n\n <!-- Webhook Group, Tag or Tag Group (only in classic layout) -->\n <Tag\n v-else-if=\"\n isTag(entry) || (isTagGroup(entry) && options.layout === 'classic')\n \"\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :isLoading=\"false\"\n :layout=\"options.layout\"\n :moreThanOneTag=\"entries.filter(isTag).length > 1\"\n :tag=\"entry\">\n <template v-if=\"'children' in entry && entry.children?.length\">\n <TraversedEntry\n :authStore\n :clientOptions\n :document\n :entries=\"entry.children\"\n :eventBus\n :expandedItems\n :level=\"level + 1\"\n :options\n :securitySchemes\n :selectedClient\n :selectedServer>\n </TraversedEntry>\n </template>\n </Tag>\n\n <!-- Display tag group entries for modern layout (flattened) -->\n <!--\n The wrapping element carries the tag group id so it remains a scroll\n target. Modern layout flattens groups and renders no header of their own,\n so without this anchor, selecting a tag group (from search or the sidebar)\n would have nothing to scroll to.\n -->\n <div\n v-else-if=\"isTagGroup(entry)\"\n :id=\"entry.id\">\n <TraversedEntry\n :authStore\n :clientOptions\n :document\n :entries=\"entry.children || []\"\n :eventBus\n :expandedItems\n :level=\"level + 1\"\n :options\n :securitySchemes\n :selectedClient\n :selectedServer>\n </TraversedEntry>\n </div>\n\n <!-- Models -->\n <ModelTag\n v-else-if=\"isModelsTag(entry) && document.components?.schemas\"\n :id=\"entry.id\"\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :layout=\"options.layout\"\n :modelsSectionLabel=\"options.modelsSectionLabel\">\n <TraversedEntry\n :authStore\n :clientOptions\n :document\n :entries=\"entry.children || []\"\n :eventBus\n :expandedItems=\"expandedItems\"\n :level=\"level + 1\"\n :options\n :securitySchemes\n :selectedClient\n :selectedServer>\n </TraversedEntry>\n </ModelTag>\n\n <Model\n v-else-if=\"isModel(entry) && document.components?.schemas?.[entry.name]\"\n :id=\"entry.id\"\n :document\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :name=\"entry.name\"\n :options\n :schema=\"getResolvedRef(document.components.schemas[entry.name])\">\n </Model>\n </Lazy>\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"TraversedEntry.vue.script.js","names":[],"sources":["../../../../src/components/Content/Operations/TraversedEntry.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ClientOptionGroup } from '@scalar/api-client/blocks/operation-code-sample'\nimport type { ApiReferenceConfigurationRaw } from '@scalar/types/api-reference'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { AuthStore } from '@scalar/workspace-store/entities/auth'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedPathItem } from '@scalar/workspace-store/helpers/for-each-path-item-operation'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { MergedSecuritySchemes } from '@scalar/workspace-store/request-example'\nimport type {\n TraversedEntry,\n TraversedModels,\n TraversedOperation,\n TraversedSchema,\n TraversedTag,\n TraversedWebhook,\n} from '@scalar/workspace-store/schemas/navigation'\nimport type {\n OpenApiDocument,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport Model from '@/components/Content/Models/Model.vue'\nimport ModelTag from '@/components/Content/Models/ModelTag.vue'\nimport { Tag } from '@/components/Content/Tags'\nimport Lazy from '@/components/Lazy/Lazy.vue'\nimport { SectionContainer } from '@/components/Section'\nimport { Operation } from '@/features/Operation'\n\nconst {\n level = 0,\n clientOptions,\n document,\n authStore,\n entries,\n} = defineProps<{\n /** The auth store */\n authStore: AuthStore\n /** The level of depth */\n level?: number\n /** Traversed entries to render */\n entries: TraversedEntry[]\n /** The document object */\n document: OpenApiDocument\n /** The http client options for the dropdown */\n clientOptions: ClientOptionGroup[]\n /** The subset of the configuration object required for the operation component */\n options: Pick<\n ApiReferenceConfigurationRaw,\n | 'expandAllResponses'\n | 'hideTestRequestButton'\n | 'layout'\n | 'orderRequiredPropertiesFirst'\n | 'orderSchemaPropertiesBy'\n | 'expandAllSchemaProperties'\n | 'showOperationId'\n | 'hideModels'\n | 'modelsSectionLabel'\n >\n /** Currently selected server for the document */\n selectedServer: ServerObject | null\n /** The merged security schemes for the document and the authentication configuration */\n securitySchemes: MergedSecuritySchemes\n /** Currently selected http client for the document */\n selectedClient: WorkspaceStore['workspace']['x-scalar-default-client']\n /** Used to determine if an entry is collapsed */\n expandedItems: Record<string, boolean>\n /** The event bus for the handling all events. */\n eventBus: WorkspaceEventBus\n}>()\n\n/**\n * Type guards for different entry types\n */\nconst isTagGroup = (\n entry: TraversedEntry,\n): entry is TraversedTag & { isGroup: true } =>\n entry['type'] === 'tag' && entry.isGroup === true\n\nconst isTag = (\n entry: TraversedEntry,\n): entry is TraversedTag & { isGroup: false } =>\n entry['type'] === 'tag' && !isTagGroup(entry) && entry.id !== 'models'\n\nconst isOperation = (entry: TraversedEntry): entry is TraversedOperation =>\n entry['type'] === 'operation'\n\nconst isWebhook = (entry: TraversedEntry): entry is TraversedWebhook =>\n entry['type'] === 'webhook'\n\n/** Models are special form of tag entry */\nconst isModelsTag = (entry: TraversedEntry): entry is TraversedModels =>\n entry['type'] === 'models'\n\nconst isModel = (entry: TraversedEntry): entry is TraversedSchema =>\n entry['type'] === 'model'\n\nfunction getPathValue(entry: TraversedOperation | TraversedWebhook) {\n return isWebhook(entry)\n ? getResolvedPathItem(document.webhooks?.[entry.name])\n : getResolvedPathItem(document.paths?.[entry.path])\n}\n</script>\n\n<template>\n <!-- The key must be joined with the layout to force a re-render when the layout changes -->\n <!-- Without this we get a timing issue where the lazy bus is reset and the element is not rendered -->\n <Lazy\n v-for=\"entry in entries\"\n :id=\"entry.id\"\n :key=\"`${entry.id}-${options.layout}`\"\n :expanded=\"!!expandedItems[entry.id]\">\n <!-- Operation or Webhook -->\n <SectionContainer\n v-if=\"isOperation(entry) || isWebhook(entry)\"\n :omit=\"level !== 0\">\n <Operation\n :id=\"entry.id\"\n :authStore\n :clientOptions\n :document\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :isWebhook=\"isWebhook(entry)\"\n :method=\"entry.method\"\n :options=\"options\"\n :path=\"isWebhook(entry) ? entry.name : entry.path\"\n :pathValue=\"getPathValue(entry)\"\n :securitySchemes=\"securitySchemes\"\n :selectedClient=\"selectedClient\"\n :server=\"selectedServer\" />\n </SectionContainer>\n\n <!-- Webhook Group, Tag or Tag Group (only in classic layout) -->\n <Tag\n v-else-if=\"\n isTag(entry) || (isTagGroup(entry) && options.layout === 'classic')\n \"\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :isLoading=\"false\"\n :layout=\"options.layout\"\n :moreThanOneTag=\"entries.filter(isTag).length > 1\"\n :tag=\"entry\">\n <template v-if=\"'children' in entry && entry.children?.length\">\n <TraversedEntry\n :authStore\n :clientOptions\n :document\n :entries=\"entry.children\"\n :eventBus\n :expandedItems\n :level=\"level + 1\"\n :options\n :securitySchemes\n :selectedClient\n :selectedServer>\n </TraversedEntry>\n </template>\n </Tag>\n\n <!-- Display tag group entries for modern layout (flattened) -->\n <!--\n The wrapping element carries the tag group id so it remains a scroll\n target. Modern layout flattens groups and renders no header of their own,\n so without this anchor, selecting a tag group (from search or the sidebar)\n would have nothing to scroll to.\n -->\n <div\n v-else-if=\"isTagGroup(entry)\"\n :id=\"entry.id\">\n <TraversedEntry\n :authStore\n :clientOptions\n :document\n :entries=\"entry.children || []\"\n :eventBus\n :expandedItems\n :level=\"level + 1\"\n :options\n :securitySchemes\n :selectedClient\n :selectedServer>\n </TraversedEntry>\n </div>\n\n <!-- Models -->\n <ModelTag\n v-else-if=\"isModelsTag(entry) && document.components?.schemas\"\n :id=\"entry.id\"\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :layout=\"options.layout\"\n :modelsSectionLabel=\"options.modelsSectionLabel\">\n <TraversedEntry\n :authStore\n :clientOptions\n :document\n :entries=\"entry.children || []\"\n :eventBus\n :expandedItems=\"expandedItems\"\n :level=\"level + 1\"\n :options\n :securitySchemes\n :selectedClient\n :selectedServer>\n </TraversedEntry>\n </ModelTag>\n\n <Model\n v-else-if=\"isModel(entry) && document.components?.schemas?.[entry.name]\"\n :id=\"entry.id\"\n :document\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :name=\"entry.name\"\n :options\n :schema=\"getResolvedRef(document.components.schemas[entry.name])\">\n </Model>\n </Lazy>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0EA,MAAM,cACJ,UAEA,MAAM,YAAY,SAAS,MAAM,YAAY;EAE/C,MAAM,SACJ,UAEA,MAAM,YAAY,SAAS,CAAC,WAAW,MAAM,IAAI,MAAM,OAAO;EAEhE,MAAM,eAAe,UACnB,MAAM,YAAY;EAEpB,MAAM,aAAa,UACjB,MAAM,YAAY;;EAGpB,MAAM,eAAe,UACnB,MAAM,YAAY;EAEpB,MAAM,WAAW,UACf,MAAM,YAAY;EAEpB,SAAS,aAAa,OAA8C;AAClE,UAAO,UAAU,MAAK,GAClB,oBAAoB,QAAA,SAAS,WAAW,MAAM,MAAK,GACnD,oBAAoB,QAAA,SAAS,QAAQ,MAAM,MAAK;;;;2BAOpD,mBAgHO,UAAA,MAAA,WA/GW,QAAA,UAAT,UAAK;wBADd,YAgHO,cAAA;KA9GJ,IAAI,MAAM;KACV,KAAG,GAAK,MAAM,GAAE,GAAI,QAAA,QAAQ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ACA,UAAA,QAAA;MACA,SAAS,MAAM,YAAQ,EAAA;MACvB,UAAA,QAAA;MACA,eAAA,QAAA;MACA,OAAO,QAAA,QAAK;MACZ,SAAA,QAAA;MACA,iBAAA,QAAA;MACA,gBAAA,QAAA;MACA,gBAAA,QAAA;;;;;;;;;;;;;4BAMQ,YAAY,MAAK,IAAK,QAAA,SAAS,YAAY,WAAA,WAAA,EADxD,YAoBW,kBAAA;;MAlBR,IAAI,MAAM;MACV,UAAA,QAAA;MACA,aAAW,CAAG,QAAA,cAAc,MAAM;MAClC,QAAQ,QAAA,QAAQ;MAChB,oBAAoB,QAAA,QAAQ;;6BAaZ,CAZjB,YAYiB,2BAAA;OAXd,WAAA,QAAA;OACA,eAAA,QAAA;OACA,UAAA,QAAA;OACA,SAAS,MAAM,YAAQ,EAAA;OACvB,UAAA,QAAA;OACA,eAAe,QAAA;OACf,OAAO,QAAA,QAAK;OACZ,SAAA,QAAA;OACA,iBAAA,QAAA;OACA,gBAAA,QAAA;OACA,gBAAA,QAAA;;;;;;;;;;;;;;;;;;;;;WAKQ,QAAQ,MAAK,IAAK,QAAA,SAAS,YAAY,UAAU,MAAM,SAAA,WAAA,EADpE,YASQ,eAAA;;MAPL,IAAI,MAAM;MACV,UAAA,QAAA;MACA,UAAA,QAAA;MACA,aAAW,CAAG,QAAA,cAAc,MAAM;MAClC,MAAM,MAAM;MACZ,SAAA,QAAA;MACA,QAAQ,MAAA,eAAc,CAAC,QAAA,SAAS,WAAW,QAAQ,MAAM,MAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-search-index.d.ts","sourceRoot":"","sources":["../../../../src/features/Search/helpers/create-search-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AACnG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"create-search-index.d.ts","sourceRoot":"","sources":["../../../../src/features/Search/helpers/create-search-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AACnG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAMlE,OAAO,KAAK,EAEV,eAAe,EAIhB,MAAM,8DAA8D,CAAA;AAErE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAWvD,qJAAqJ;AACrJ,KAAK,kBAAkB,GAAG,eAAe,GAAG,gBAAgB,CAAA;AA4E5D,KAAK,wBAAwB,GAAG;IAC9B,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;CACxC,CAAA;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,kBAAkB,GAAG,SAAS,EACxC,OAAO,CAAC,EAAE,wBAAwB,GACjC,QAAQ,EAAE,CAqBZ"}
|
|
@@ -4,6 +4,7 @@ import { DEFAULT_MODELS_SECTION_LABEL } from "@scalar/types/api-reference";
|
|
|
4
4
|
import { combineParams } from "@scalar/workspace-store/request-example";
|
|
5
5
|
import { isAsyncApiDocument, isOpenApiDocument } from "@scalar/workspace-store/schemas/type-guards";
|
|
6
6
|
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
7
|
+
import { getPathItemOperation, getResolvedPathItem } from "@scalar/workspace-store/helpers/for-each-path-item-operation";
|
|
7
8
|
//#region src/features/Search/helpers/create-search-index.ts
|
|
8
9
|
/**
|
|
9
10
|
* Resolves a schema from `components.schemas` for either document type.
|
|
@@ -72,8 +73,8 @@ function createSearchIndex(document, options) {
|
|
|
72
73
|
function addEntryToIndex(entry, index, document, modelsSectionTitle) {
|
|
73
74
|
const openApiDocument = isOpenApiDocument(document) ? document : void 0;
|
|
74
75
|
if (entry.type === "operation") {
|
|
75
|
-
const pathItem =
|
|
76
|
-
const operation = getResolvedRef(
|
|
76
|
+
const pathItem = getResolvedPathItem(openApiDocument?.paths?.[entry.path]);
|
|
77
|
+
const operation = getResolvedRef(getPathItemOperation(openApiDocument?.paths?.[entry.path], entry.method)) ?? {};
|
|
77
78
|
const operationWithPathParams = {
|
|
78
79
|
...operation,
|
|
79
80
|
parameters: combineParams(pathItem?.parameters, operation.parameters)
|
|
@@ -101,7 +102,7 @@ function addEntryToIndex(entry, index, document, modelsSectionTitle) {
|
|
|
101
102
|
return;
|
|
102
103
|
}
|
|
103
104
|
if (entry.type === "webhook") {
|
|
104
|
-
const webhook = getResolvedRef(openApiDocument?.webhooks?.[entry.name]
|
|
105
|
+
const webhook = getResolvedRef(getPathItemOperation(openApiDocument?.webhooks?.[entry.name], entry.method)) ?? {};
|
|
105
106
|
const webhookDescription = webhook.description || "";
|
|
106
107
|
index.push({
|
|
107
108
|
id: entry.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-search-index.js","names":[],"sources":["../../../../src/features/Search/helpers/create-search-index.ts"],"sourcesContent":["import { DEFAULT_MODELS_SECTION_LABEL, type ModelsSectionLabel } from '@scalar/types/api-reference'\nimport type { AsyncApiDocument } from '@scalar/types/asyncapi/3.1'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { combineParams } from '@scalar/workspace-store/request-example'\nimport type { TraversedEntry } from '@scalar/workspace-store/schemas/navigation'\nimport { isAsyncApiDocument, isOpenApiDocument } from '@scalar/workspace-store/schemas/type-guards'\nimport type {\n MediaTypeObject,\n OpenApiDocument,\n OperationObject,\n ResponsesObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport type { FuseData } from '@/features/Search/types'\nimport { getAsyncApiModelSchema } from '@/helpers/get-async-api-model-schema'\nimport {\n extractBodyDescriptions,\n extractBodyFieldNames,\n extractParameterDescriptions,\n extractParameterNames,\n extractSchemaDescriptions,\n extractSchemaFieldNames,\n} from '@/helpers/openapi'\n\n/** Documents the search index can ingest. AsyncAPI is supported for headings, tags, and models; channels/operations/messages are not indexed yet. */\ntype SearchableDocument = OpenApiDocument | AsyncApiDocument\n\n/**\n * Resolves a schema from `components.schemas` for either document type.\n *\n * OpenAPI and AsyncAPI keep reusable schemas in the same place, so model search entries can read\n * property names and descriptions from both. AsyncAPI entries need extra handling (ref siblings,\n * multi-format wrappers, boolean schemas), which lives in {@link getAsyncApiModelSchema}.\n */\nfunction getModelSchema(document: SearchableDocument | undefined, name: string): SchemaObject | undefined {\n if (isOpenApiDocument(document)) {\n return getResolvedRef(document.components?.schemas?.[name])\n }\n\n if (isAsyncApiDocument(document)) {\n return getAsyncApiModelSchema(document, name)\n }\n\n return undefined\n}\n\nfunction responseExampleValueToString(value: unknown): string {\n if (typeof value === 'string') {\n return value\n }\n\n try {\n return JSON.stringify(value)\n } catch (_error) {\n return ''\n }\n}\n\nfunction mediaTypeExamplesToStrings(mediaType: MediaTypeObject): string[] {\n const examplesFromNamedMap = Object.values(mediaType.examples ?? {})\n .flatMap((example) => {\n const resolvedExample = getResolvedRef(example)\n\n if (!resolvedExample || !('value' in resolvedExample)) {\n return []\n }\n\n return responseExampleValueToString(resolvedExample.value)\n })\n .filter((value) => value.length > 0)\n\n const mediaTypeExample =\n 'example' in mediaType && mediaType.example !== undefined ? responseExampleValueToString(mediaType.example) : ''\n\n return mediaTypeExample ? [mediaTypeExample, ...examplesFromNamedMap] : examplesFromNamedMap\n}\n\nfunction extractResponseExamples(responses: ResponsesObject | undefined): string[] {\n if (!responses) {\n return []\n }\n\n return Object.values(responses)\n .flatMap((response) => {\n const resolvedResponse = getResolvedRef(response)\n if (!resolvedResponse?.content) {\n return []\n }\n\n return Object.values(resolvedResponse.content).flatMap((mediaType) => {\n const resolvedMediaType = getResolvedRef(mediaType)\n if (!resolvedMediaType) {\n return []\n }\n\n return mediaTypeExamplesToStrings(resolvedMediaType)\n })\n })\n .filter((value) => value.length > 0)\n}\n\ntype CreateSearchIndexOptions = {\n modelsSectionLabel?: ModelsSectionLabel\n}\n\n/**\n * Create a search index from a list of entries.\n */\nexport function createSearchIndex(\n document: SearchableDocument | undefined,\n options?: CreateSearchIndexOptions,\n): FuseData[] {\n const index: FuseData[] = []\n const modelsSectionTitle = options?.modelsSectionLabel ?? DEFAULT_MODELS_SECTION_LABEL\n\n /**\n * Recursively processes entries and their children to build the search index.\n */\n function processEntries(entriesToProcess: TraversedEntry[]): void {\n entriesToProcess.forEach((entry) => {\n addEntryToIndex(entry, index, document, modelsSectionTitle)\n\n // Recursively process children if they exist\n if ('children' in entry && entry.children) {\n processEntries(entry.children)\n }\n })\n }\n\n processEntries(document?.['x-scalar-navigation']?.children ?? [])\n\n return index\n}\n\n/**\n * Adds a single entry to the search index, handling all entry types recursively.\n *\n * AsyncAPI documents contribute heading, tag, and model entries here. Their\n * channels, operations, and messages are not indexed yet.\n */\nfunction addEntryToIndex(\n entry: TraversedEntry,\n index: FuseData[],\n document: SearchableDocument | undefined,\n modelsSectionTitle: string,\n): void {\n // OpenAPI-only branches read fields that do not exist on AsyncAPI documents (paths, webhooks,\n // components.schemas). Narrow once here so each branch can dereference safely.\n const openApiDocument = isOpenApiDocument(document) ? document : undefined\n\n // Operation\n if (entry.type === 'operation') {\n const pathItem = getResolvedRef(openApiDocument?.paths?.[entry.path])\n const operation = (getResolvedRef(pathItem?.[entry.method]) ?? {}) as OperationObject\n const operationWithPathParams = {\n ...operation,\n parameters: combineParams(pathItem?.parameters, operation.parameters),\n }\n\n const parameters = extractParameterNames(operationWithPathParams.parameters ?? [])\n const parameterDescriptions = extractParameterDescriptions(operationWithPathParams.parameters ?? [])\n const body = extractBodyFieldNames(operationWithPathParams)\n const bodyDescriptions = extractBodyDescriptions(operationWithPathParams)\n const responseExamples = extractResponseExamples(operationWithPathParams.responses)\n\n index.push({\n type: 'operation',\n title: entry.title,\n id: entry.id,\n description: operationWithPathParams.description || '',\n method: entry.method,\n path: entry.path,\n body,\n bodyDescriptions,\n parameters,\n parameterDescriptions,\n responseExamples,\n operationId: operationWithPathParams.operationId,\n entry,\n })\n\n return\n }\n\n // Webhook\n if (entry.type === 'webhook') {\n const webhook = getResolvedRef(openApiDocument?.webhooks?.[entry.name]?.[entry.method]) ?? {}\n const webhookDescription = webhook.description || ''\n\n index.push({\n id: entry.id,\n type: 'webhook',\n title: entry.title,\n description: 'Webhook',\n method: entry.method,\n body: '',\n bodyDescriptions: webhookDescription ? [webhookDescription] : [],\n operationId: webhook.operationId,\n entry,\n })\n\n return\n }\n\n // Model\n if (entry.type === 'model') {\n const schema = getModelSchema(document, entry.name)\n const schemaDescription = schema?.description ?? ''\n const propertyNames = extractSchemaFieldNames(schema)\n const propertyDescriptions = extractSchemaDescriptions(schema)\n\n index.push({\n type: 'model',\n title: entry.title,\n description: modelsSectionTitle,\n id: entry.id,\n body: propertyNames,\n bodyDescriptions: schemaDescription ? [schemaDescription, ...propertyDescriptions] : propertyDescriptions,\n entry,\n })\n\n return\n }\n\n // Models heading\n if (entry.type === 'models') {\n index.push({\n id: entry.id,\n type: 'heading',\n title: entry.title,\n description: 'Heading',\n body: '',\n entry,\n })\n\n return\n }\n\n // Tag\n if (entry.type === 'tag' && entry.isWebhooks === true) {\n index.push({\n id: entry.id,\n type: 'heading',\n title: 'Webhooks',\n description: 'Heading',\n body: '',\n entry,\n })\n\n return\n }\n\n if (entry.type === 'tag' && entry.isGroup === false) {\n index.push({\n id: entry.id,\n title: entry.title,\n description: entry.description || '',\n type: 'tag',\n body: '',\n entry,\n })\n\n return\n }\n\n // Tag group\n if (entry.type === 'tag' && entry.isGroup === true) {\n index.push({\n id: entry.id,\n title: entry.title,\n description: 'Tag Group',\n type: 'tag',\n body: '',\n entry,\n })\n\n return\n }\n\n // Headings from info.description\n if (entry.type === 'text') {\n index.push({\n id: entry.id,\n type: 'heading',\n title: entry.title ?? '',\n description: 'Heading',\n body: '',\n entry,\n })\n\n return\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAmCA,SAAS,eAAe,UAA0C,MAAwC;AACxG,KAAI,kBAAkB,SAAS,CAC7B,QAA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1B,MAAM,SAAS,eAAe,UAAU,MAAM,KAAK;EACnD,MAAM,oBAAoB,QAAQ,eAAe;EACjD,MAAM,gBAAgB,wBAAwB,OAAO;EACrD,MAAM,uBAAuB,0BAA0B,OAAO;AAE9D,QAAM,KAAK;GACT,MAAM;GACN,OAAO,MAAM;GACb,aAAa;GACb,IAAI,MAAM;GACV,MAAM;GACN,kBAAkB,oBAAoB,CAAC,mBAAmB,GAAG,qBAAqB,GAAG;GACrF;GACD,CAAC;AAEF;;AAIF,KAAI,MAAM,SAAS,UAAU;AAC3B,QAAM,KAAK;GACT,IAAI,MAAM;GACV,MAAM;GACN,OAAO,MAAM;GACb,aAAa;GACb,MAAM;GACN;GACD,CAAC;AAEF;;AAIF,KAAI,MAAM,SAAS,SAAS,MAAM,eAAe,MAAM;AACrD,QAAM,KAAK;GACT,IAAI,MAAM;GACV,MAAM;GACN,OAAO;GACP,aAAa;GACb,MAAM;GACN;GACD,CAAC;AAEF;;AAGF,KAAI,MAAM,SAAS,SAAS,MAAM,YAAY,OAAO;AACnD,QAAM,KAAK;GACT,IAAI,MAAM;GACV,OAAO,MAAM;GACb,aAAa,MAAM,eAAe;GAClC,MAAM;GACN,MAAM;GACN;GACD,CAAC;AAEF;;AAIF,KAAI,MAAM,SAAS,SAAS,MAAM,YAAY,MAAM;AAClD,QAAM,KAAK;GACT,IAAI,MAAM;GACV,OAAO,MAAM;GACb,aAAa;GACb,MAAM;GACN,MAAM;GACN;GACD,CAAC;AAEF;;AAIF,KAAI,MAAM,SAAS,QAAQ;AACzB,QAAM,KAAK;GACT,IAAI,MAAM;GACV,MAAM;GACN,OAAO,MAAM,SAAS;GACtB,aAAa;GACb,MAAM;GACN;GACD,CAAC;AAEF"}
|
|
1
|
+
{"version":3,"file":"create-search-index.js","names":[],"sources":["../../../../src/features/Search/helpers/create-search-index.ts"],"sourcesContent":["import { DEFAULT_MODELS_SECTION_LABEL, type ModelsSectionLabel } from '@scalar/types/api-reference'\nimport type { AsyncApiDocument } from '@scalar/types/asyncapi/3.1'\nimport { getPathItemOperation, getResolvedPathItem } from '@scalar/workspace-store/helpers/for-each-path-item-operation'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { combineParams } from '@scalar/workspace-store/request-example'\nimport type { TraversedEntry } from '@scalar/workspace-store/schemas/navigation'\nimport { isAsyncApiDocument, isOpenApiDocument } from '@scalar/workspace-store/schemas/type-guards'\nimport type {\n MediaTypeObject,\n OpenApiDocument,\n OperationObject,\n ResponsesObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport type { FuseData } from '@/features/Search/types'\nimport { getAsyncApiModelSchema } from '@/helpers/get-async-api-model-schema'\nimport {\n extractBodyDescriptions,\n extractBodyFieldNames,\n extractParameterDescriptions,\n extractParameterNames,\n extractSchemaDescriptions,\n extractSchemaFieldNames,\n} from '@/helpers/openapi'\n\n/** Documents the search index can ingest. AsyncAPI is supported for headings, tags, and models; channels/operations/messages are not indexed yet. */\ntype SearchableDocument = OpenApiDocument | AsyncApiDocument\n\n/**\n * Resolves a schema from `components.schemas` for either document type.\n *\n * OpenAPI and AsyncAPI keep reusable schemas in the same place, so model search entries can read\n * property names and descriptions from both. AsyncAPI entries need extra handling (ref siblings,\n * multi-format wrappers, boolean schemas), which lives in {@link getAsyncApiModelSchema}.\n */\nfunction getModelSchema(document: SearchableDocument | undefined, name: string): SchemaObject | undefined {\n if (isOpenApiDocument(document)) {\n return getResolvedRef(document.components?.schemas?.[name])\n }\n\n if (isAsyncApiDocument(document)) {\n return getAsyncApiModelSchema(document, name)\n }\n\n return undefined\n}\n\nfunction responseExampleValueToString(value: unknown): string {\n if (typeof value === 'string') {\n return value\n }\n\n try {\n return JSON.stringify(value)\n } catch (_error) {\n return ''\n }\n}\n\nfunction mediaTypeExamplesToStrings(mediaType: MediaTypeObject): string[] {\n const examplesFromNamedMap = Object.values(mediaType.examples ?? {})\n .flatMap((example) => {\n const resolvedExample = getResolvedRef(example)\n\n if (!resolvedExample || !('value' in resolvedExample)) {\n return []\n }\n\n return responseExampleValueToString(resolvedExample.value)\n })\n .filter((value) => value.length > 0)\n\n const mediaTypeExample =\n 'example' in mediaType && mediaType.example !== undefined ? responseExampleValueToString(mediaType.example) : ''\n\n return mediaTypeExample ? [mediaTypeExample, ...examplesFromNamedMap] : examplesFromNamedMap\n}\n\nfunction extractResponseExamples(responses: ResponsesObject | undefined): string[] {\n if (!responses) {\n return []\n }\n\n return Object.values(responses)\n .flatMap((response) => {\n const resolvedResponse = getResolvedRef(response)\n if (!resolvedResponse?.content) {\n return []\n }\n\n return Object.values(resolvedResponse.content).flatMap((mediaType) => {\n const resolvedMediaType = getResolvedRef(mediaType)\n if (!resolvedMediaType) {\n return []\n }\n\n return mediaTypeExamplesToStrings(resolvedMediaType)\n })\n })\n .filter((value) => value.length > 0)\n}\n\ntype CreateSearchIndexOptions = {\n modelsSectionLabel?: ModelsSectionLabel\n}\n\n/**\n * Create a search index from a list of entries.\n */\nexport function createSearchIndex(\n document: SearchableDocument | undefined,\n options?: CreateSearchIndexOptions,\n): FuseData[] {\n const index: FuseData[] = []\n const modelsSectionTitle = options?.modelsSectionLabel ?? DEFAULT_MODELS_SECTION_LABEL\n\n /**\n * Recursively processes entries and their children to build the search index.\n */\n function processEntries(entriesToProcess: TraversedEntry[]): void {\n entriesToProcess.forEach((entry) => {\n addEntryToIndex(entry, index, document, modelsSectionTitle)\n\n // Recursively process children if they exist\n if ('children' in entry && entry.children) {\n processEntries(entry.children)\n }\n })\n }\n\n processEntries(document?.['x-scalar-navigation']?.children ?? [])\n\n return index\n}\n\n/**\n * Adds a single entry to the search index, handling all entry types recursively.\n *\n * AsyncAPI documents contribute heading, tag, and model entries here. Their\n * channels, operations, and messages are not indexed yet.\n */\nfunction addEntryToIndex(\n entry: TraversedEntry,\n index: FuseData[],\n document: SearchableDocument | undefined,\n modelsSectionTitle: string,\n): void {\n // OpenAPI-only branches read fields that do not exist on AsyncAPI documents (paths, webhooks,\n // components.schemas). Narrow once here so each branch can dereference safely.\n const openApiDocument = isOpenApiDocument(document) ? document : undefined\n\n // Operation\n if (entry.type === 'operation') {\n const pathItem = getResolvedPathItem(openApiDocument?.paths?.[entry.path])\n const operation = (getResolvedRef(getPathItemOperation(openApiDocument?.paths?.[entry.path], entry.method)) ??\n {}) as OperationObject\n const operationWithPathParams = {\n ...operation,\n parameters: combineParams(pathItem?.parameters, operation.parameters),\n }\n\n const parameters = extractParameterNames(operationWithPathParams.parameters ?? [])\n const parameterDescriptions = extractParameterDescriptions(operationWithPathParams.parameters ?? [])\n const body = extractBodyFieldNames(operationWithPathParams)\n const bodyDescriptions = extractBodyDescriptions(operationWithPathParams)\n const responseExamples = extractResponseExamples(operationWithPathParams.responses)\n\n index.push({\n type: 'operation',\n title: entry.title,\n id: entry.id,\n description: operationWithPathParams.description || '',\n method: entry.method,\n path: entry.path,\n body,\n bodyDescriptions,\n parameters,\n parameterDescriptions,\n responseExamples,\n operationId: operationWithPathParams.operationId,\n entry,\n })\n\n return\n }\n\n // Webhook\n if (entry.type === 'webhook') {\n const webhook = getResolvedRef(getPathItemOperation(openApiDocument?.webhooks?.[entry.name], entry.method)) ?? {}\n const webhookDescription = webhook.description || ''\n\n index.push({\n id: entry.id,\n type: 'webhook',\n title: entry.title,\n description: 'Webhook',\n method: entry.method,\n body: '',\n bodyDescriptions: webhookDescription ? [webhookDescription] : [],\n operationId: webhook.operationId,\n entry,\n })\n\n return\n }\n\n // Model\n if (entry.type === 'model') {\n const schema = getModelSchema(document, entry.name)\n const schemaDescription = schema?.description ?? ''\n const propertyNames = extractSchemaFieldNames(schema)\n const propertyDescriptions = extractSchemaDescriptions(schema)\n\n index.push({\n type: 'model',\n title: entry.title,\n description: modelsSectionTitle,\n id: entry.id,\n body: propertyNames,\n bodyDescriptions: schemaDescription ? [schemaDescription, ...propertyDescriptions] : propertyDescriptions,\n entry,\n })\n\n return\n }\n\n // Models heading\n if (entry.type === 'models') {\n index.push({\n id: entry.id,\n type: 'heading',\n title: entry.title,\n description: 'Heading',\n body: '',\n entry,\n })\n\n return\n }\n\n // Tag\n if (entry.type === 'tag' && entry.isWebhooks === true) {\n index.push({\n id: entry.id,\n type: 'heading',\n title: 'Webhooks',\n description: 'Heading',\n body: '',\n entry,\n })\n\n return\n }\n\n if (entry.type === 'tag' && entry.isGroup === false) {\n index.push({\n id: entry.id,\n title: entry.title,\n description: entry.description || '',\n type: 'tag',\n body: '',\n entry,\n })\n\n return\n }\n\n // Tag group\n if (entry.type === 'tag' && entry.isGroup === true) {\n index.push({\n id: entry.id,\n title: entry.title,\n description: 'Tag Group',\n type: 'tag',\n body: '',\n entry,\n })\n\n return\n }\n\n // Headings from info.description\n if (entry.type === 'text') {\n index.push({\n id: entry.id,\n type: 'heading',\n title: entry.title ?? '',\n description: 'Heading',\n body: '',\n entry,\n })\n\n return\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoCA,SAAS,eAAe,UAA0C,MAAwC;AACxG,KAAI,kBAAkB,SAAS,CAC7B,QAAO,eAAe,SAAS,YAAY,UAAU,MAAM;AAG7D,KAAI,mBAAmB,SAAS,CAC9B,QAAO,uBAAuB,UAAU,KAAK;;AAMjD,SAAS,6BAA6B,OAAwB;AAC5D,KAAI,OAAO,UAAU,SACnB,QAAO;AAGT,KAAI;AACF,SAAO,KAAK,UAAU,MAAM;UACrB,QAAQ;AACf,SAAO;;;AAIX,SAAS,2BAA2B,WAAsC;CACxE,MAAM,uBAAuB,OAAO,OAAO,UAAU,YAAY,EAAE,CAAC,CACjE,SAAS,YAAY;EACpB,MAAM,kBAAkB,eAAe,QAAQ;AAE/C,MAAI,CAAC,mBAAmB,EAAE,WAAW,iBACnC,QAAO,EAAE;AAGX,SAAO,6BAA6B,gBAAgB,MAAM;GAC1D,CACD,QAAQ,UAAU,MAAM,SAAS,EAAE;CAEtC,MAAM,mBACJ,aAAa,aAAa,UAAU,YAAY,KAAA,IAAY,6BAA6B,UAAU,QAAQ,GAAG;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AAM;GACN,OAAO;GACP,aAAa;GACb,MAAM;GACN;GACD,CAAC;AAEF;;AAGF,KAAI,MAAM,SAAS,SAAS,MAAM,YAAY,OAAO;AACnD,QAAM,KAAK;GACT,IAAI,MAAM;GACV,OAAO,MAAM;GACb,aAAa,MAAM,eAAe;GAClC,MAAM;GACN,MAAM;GACN;GACD,CAAC;AAEF;;AAIF,KAAI,MAAM,SAAS,SAAS,MAAM,YAAY,MAAM;AAClD,QAAM,KAAK;GACT,IAAI,MAAM;GACV,OAAO,MAAM;GACb,aAAa;GACb,MAAM;GACN,MAAM;GACN;GACD,CAAC;AAEF;;AAIF,KAAI,MAAM,SAAS,QAAQ;AACzB,QAAM,KAAK;GACT,IAAI,MAAM;GACV,MAAM;GACN,OAAO,MAAM,SAAS;GACtB,aAAa;GACb,MAAM;GACN;GACD,CAAC;AAEF"}
|
|
@@ -25,23 +25,16 @@ export declare const getIdFromUrl: (url: string | URL, basePath: string | undefi
|
|
|
25
25
|
*/
|
|
26
26
|
export declare const makeUrlFromId: (_id: string, basePath: string | undefined, isMultiDocument: boolean) => URL | undefined;
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* Rewrites navigation ids in a URL to their current form.
|
|
29
29
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* The regex is anchored to the legacy structural shape so unrelated `/model/` occurrences
|
|
35
|
-
* inside operation paths (e.g. `POST /model/train` for an AI/ML API → `default/POST/model/train`)
|
|
36
|
-
* and a tag literally named "model" are left alone.
|
|
37
|
-
*
|
|
38
|
-
* Trade-off: in single-document mode the URL strips the document slug, which makes
|
|
39
|
-
* `#tag/<slug>/model/<name>` ambiguous with an operation under a tag named "model".
|
|
40
|
-
* Single-doc tagged-model bookmarks are not rewritten — only top-level models.
|
|
30
|
+
* The URL is reduced to its routing-agnostic id (see {@link locateIdCarriers}), each redirect rule
|
|
31
|
+
* is applied in id-space (see {@link buildRedirects}), and the result is spliced back into the
|
|
32
|
+
* original location. This handles hash, hash-base-path, and path routing uniformly, so a new
|
|
33
|
+
* redirect only has to be added to the list once.
|
|
41
34
|
*
|
|
42
35
|
* Returns the canonicalized URL when a rewrite happens, or null otherwise.
|
|
43
36
|
*/
|
|
44
|
-
export declare const
|
|
37
|
+
export declare const redirectUrl: (url: string | URL, modelsSectionSlug: string, documentSlug: string, isMultiDocument: boolean, basePath?: string) => URL | null;
|
|
45
38
|
/** Extracts the schema parameters from the id if they are present */
|
|
46
39
|
export declare const getSchemaParamsFromId: (id: string) => {
|
|
47
40
|
rawId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-routing.d.ts","sourceRoot":"","sources":["../../src/helpers/id-routing.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,WAEhD,CAAA;
|
|
1
|
+
{"version":3,"file":"id-routing.d.ts","sourceRoot":"","sources":["../../src/helpers/id-routing.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,WAEhD,CAAA;AAyCD,mEAAmE;AACnE,eAAO,MAAM,aAAa,GAAI,UAAU,MAAM,GAAG,GAAG,EAAE,YAAY,MAAM,GAAG,SAAS,WAMnF,CAAA;AACD,mEAAmE;AACnE,eAAO,MAAM,aAAa,GAAI,UAAU,MAAM,GAAG,GAAG,EAAE,UAAU,MAAM,EAAE,YAAY,MAAM,GAAG,SAAS,WAYrG,CAAA;AAED,2DAA2D;AAC3D,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,GAAG,GAAG,EAAE,UAAU,MAAM,EAAE,YAAY,MAAM,GAAG,SAAS,WAW7G,CAAA;AAED,8DAA8D;AAC9D,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,GAAG,GAAG,EAAE,UAAU,MAAM,YAWvE,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,GAAG,GAAG,EAAE,UAAU,MAAM,GAAG,SAAS,EAAE,YAAY,MAAM,GAAG,SAAS,WAQ3G,CAAA;AAmBD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,EAAE,UAAU,MAAM,GAAG,SAAS,EAAE,iBAAiB,OAAO,oBAsBhG,CAAA;AAqKD;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,GACtB,KAAK,MAAM,GAAG,GAAG,EACjB,mBAAmB,MAAM,EACzB,cAAc,MAAM,EACpB,iBAAiB,OAAO,EACxB,WAAW,MAAM,KAChB,GAAG,GAAG,IAyBR,CAAA;AAED,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,GAAI,IAAI,MAAM,KAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAajF,CAAA"}
|
|
@@ -14,6 +14,16 @@ var stripBasePathPrefix = (value, basePath) => {
|
|
|
14
14
|
if (value.startsWith(`${basePath}/`)) return value.slice(basePath.length + 1);
|
|
15
15
|
return null;
|
|
16
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Builds the URL-encoded, slash-prefixed form of a sanitized base path.
|
|
19
|
+
*
|
|
20
|
+
* Each segment is encoded separately so the result matches how the browser stores
|
|
21
|
+
* `location.pathname` (which encodes within segments but leaves the slashes between them).
|
|
22
|
+
*/
|
|
23
|
+
var encodeBasePath = (sanitized) => {
|
|
24
|
+
if (!sanitized) return "";
|
|
25
|
+
return `/${sanitized.split("/").map((segment) => encodeURIComponent(segment)).join("/")}`;
|
|
26
|
+
};
|
|
17
27
|
/** Extracts an element id from the hash when using hash routing */
|
|
18
28
|
var getIdFromHash = (location, slugPrefix) => {
|
|
19
29
|
const url = typeof location === "string" ? new URL(location) : location;
|
|
@@ -22,8 +32,7 @@ var getIdFromHash = (location, slugPrefix) => {
|
|
|
22
32
|
/** Extracts an element id from the path when using path routing */
|
|
23
33
|
var getIdFromPath = (location, basePath, slugPrefix) => {
|
|
24
34
|
const url = typeof location === "string" ? new URL(location) : location;
|
|
25
|
-
const
|
|
26
|
-
const basePathWithSlash = sanitized ? `/${sanitized.split("/").map((segment) => encodeURIComponent(segment)).join("/")}` : "";
|
|
35
|
+
const basePathWithSlash = encodeBasePath(sanitizeBasePath(basePath));
|
|
27
36
|
if (url.pathname.startsWith(basePathWithSlash)) {
|
|
28
37
|
const remainder = url.pathname.slice(basePathWithSlash.length);
|
|
29
38
|
return applySlugPrefix(decodeURIComponent(remainder.startsWith("/") ? remainder.slice(1) : remainder), slugPrefix);
|
|
@@ -44,8 +53,7 @@ var matchesBasePath = (location, basePath) => {
|
|
|
44
53
|
const hash = decodeURIComponent(url.hash);
|
|
45
54
|
return hash === basePath || hash.startsWith(`${basePath}/`);
|
|
46
55
|
}
|
|
47
|
-
const
|
|
48
|
-
const basePathWithSlash = sanitized ? `/${sanitized.split("/").map((segment) => encodeURIComponent(segment)).join("/")}` : "";
|
|
56
|
+
const basePathWithSlash = encodeBasePath(sanitizeBasePath(basePath));
|
|
49
57
|
return url.pathname === basePathWithSlash || url.pathname.startsWith(`${basePathWithSlash}/`);
|
|
50
58
|
};
|
|
51
59
|
/**
|
|
@@ -90,44 +98,106 @@ var makeUrlFromId = (_id, basePath, isMultiDocument) => {
|
|
|
90
98
|
return url;
|
|
91
99
|
};
|
|
92
100
|
var escapeRegex = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
101
|
+
/** Carrier for an id that lives in the bare hash fragment (`#<id>`). */
|
|
102
|
+
var bareHashCarrier = (url) => ({
|
|
103
|
+
value: decodeURIComponent(url.hash.slice(1)),
|
|
104
|
+
write: (next) => {
|
|
105
|
+
url.hash = next;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
93
108
|
/**
|
|
94
|
-
*
|
|
109
|
+
* Locates the navigation id inside a URL regardless of the routing mode.
|
|
95
110
|
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
111
|
+
* The id can live in three places — the bare hash, a hash base path (`#<base>/<id>`), or the
|
|
112
|
+
* pathname after a path base path. Each carrier pairs the decoded id with a `write` callback, so
|
|
113
|
+
* callers edit ids in id-space without re-deriving the routing chrome for each mode.
|
|
99
114
|
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
115
|
+
* Multiple carriers are returned: the canonical location for the active routing mode comes first,
|
|
116
|
+
* followed by a legacy bare-hash carrier. Both path and hash-base-path routing include the bare hash
|
|
117
|
+
* so a stale `#default/model/User` bookmark (left over from before the base path was configured) is
|
|
118
|
+
* still canonicalized — the previous implementation rewrote such doc-slug-anchored hashes on every
|
|
119
|
+
* load regardless of the routing mode. Callers rewrite every carrier that matches, not just the
|
|
120
|
+
* first, so a legacy id sitting in both the pathname and the hash is cleaned up in one pass.
|
|
121
|
+
*/
|
|
122
|
+
var locateIdCarriers = (url, basePath) => {
|
|
123
|
+
if (typeof basePath !== "string") return [bareHashCarrier(url)];
|
|
124
|
+
if (isHashBasePath(basePath)) {
|
|
125
|
+
const base = sanitizeHashBasePath(basePath);
|
|
126
|
+
return [{
|
|
127
|
+
value: stripBasePathPrefix(decodeURIComponent(url.hash.slice(1)), base) ?? "",
|
|
128
|
+
write: (next) => {
|
|
129
|
+
url.hash = [base, next].filter(Boolean).join("/");
|
|
130
|
+
}
|
|
131
|
+
}, bareHashCarrier(url)];
|
|
132
|
+
}
|
|
133
|
+
const base = sanitizeBasePath(basePath);
|
|
134
|
+
const remainder = stripBasePathPrefix(url.pathname, encodeBasePath(base));
|
|
135
|
+
return [{
|
|
136
|
+
value: remainder === null ? "" : decodeURIComponent(remainder),
|
|
137
|
+
write: (next) => {
|
|
138
|
+
url.pathname = base ? `/${base}/${next}` : `/${next}`;
|
|
139
|
+
}
|
|
140
|
+
}, bareHashCarrier(url)];
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Applies redirect rules to an id and returns the first rewrite that changes it.
|
|
103
144
|
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
|
|
145
|
+
* Rules are tried in order and the search stops at the first match, so list more specific rules
|
|
146
|
+
* before more general ones. Returns the id unchanged when no rule applies.
|
|
147
|
+
*/
|
|
148
|
+
var applyIdRedirects = (id, redirects) => {
|
|
149
|
+
for (const { match, replace } of redirects) {
|
|
150
|
+
const next = typeof replace === "string" ? id.replace(match, replace) : id.replace(match, replace);
|
|
151
|
+
if (next !== id) return next;
|
|
152
|
+
}
|
|
153
|
+
return id;
|
|
154
|
+
};
|
|
155
|
+
/** Optional `(tag-group/<n>/)?tag/<slug>/` chrome that may sit in front of a section segment. */
|
|
156
|
+
var TAG_CHROME = "(?:(?:tag-group/[^/]+/)?tag/[^/]+/)?";
|
|
157
|
+
/**
|
|
158
|
+
* Builds the list of id redirects for the current document.
|
|
159
|
+
*
|
|
160
|
+
* Add an entry here to support a new redirect. Each rule runs against every URL shape (hash, hash
|
|
161
|
+
* base path, path) for free, because rules operate on routing-agnostic ids.
|
|
162
|
+
*/
|
|
163
|
+
var buildRedirects = ({ modelsSectionSlug, documentSlug, isMultiDocument }) => {
|
|
164
|
+
const escapedDoc = escapeRegex(documentSlug);
|
|
165
|
+
const documentPrefix = isMultiDocument ? `${escapedDoc}/${TAG_CHROME}` : `(?:${escapedDoc}/${TAG_CHROME})?`;
|
|
166
|
+
const renameSectionSegment = (from) => ({
|
|
167
|
+
match: new RegExp(`^(${documentPrefix})${escapeRegex(from)}/`),
|
|
168
|
+
replace: (_match, prefix) => `${prefix}${modelsSectionSlug}/`
|
|
169
|
+
});
|
|
170
|
+
const redirects = [renameSectionSegment("model")];
|
|
171
|
+
if (modelsSectionSlug !== "models") redirects.push(renameSectionSegment("models"));
|
|
172
|
+
return redirects;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Rewrites navigation ids in a URL to their current form.
|
|
176
|
+
*
|
|
177
|
+
* The URL is reduced to its routing-agnostic id (see {@link locateIdCarriers}), each redirect rule
|
|
178
|
+
* is applied in id-space (see {@link buildRedirects}), and the result is spliced back into the
|
|
179
|
+
* original location. This handles hash, hash-base-path, and path routing uniformly, so a new
|
|
180
|
+
* redirect only has to be added to the list once.
|
|
107
181
|
*
|
|
108
182
|
* Returns the canonicalized URL when a rewrite happens, or null otherwise.
|
|
109
183
|
*/
|
|
110
|
-
var
|
|
184
|
+
var redirectUrl = (url, modelsSectionSlug, documentSlug, isMultiDocument, basePath) => {
|
|
111
185
|
if (!documentSlug) return null;
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (newPathname === next.pathname && !isMultiDocument) newPathname = next.pathname.replace(new RegExp(`^(${basePrefix}\\/)model\\/`), replacement);
|
|
186
|
+
const target = new URL(typeof url === "string" ? url : url.toString());
|
|
187
|
+
const redirects = buildRedirects({
|
|
188
|
+
modelsSectionSlug,
|
|
189
|
+
documentSlug,
|
|
190
|
+
isMultiDocument
|
|
191
|
+
});
|
|
192
|
+
let didRedirect = false;
|
|
193
|
+
for (const carrier of locateIdCarriers(target, basePath)) {
|
|
194
|
+
const rewritten = applyIdRedirects(carrier.value, redirects);
|
|
195
|
+
if (rewritten !== carrier.value) {
|
|
196
|
+
carrier.write(rewritten);
|
|
197
|
+
didRedirect = true;
|
|
198
|
+
}
|
|
126
199
|
}
|
|
127
|
-
|
|
128
|
-
next.hash = newHash;
|
|
129
|
-
next.pathname = newPathname;
|
|
130
|
-
return next;
|
|
200
|
+
return didRedirect ? target : null;
|
|
131
201
|
};
|
|
132
202
|
/** Extracts the schema parameters from the id if they are present */
|
|
133
203
|
var getSchemaParamsFromId = (id) => {
|
|
@@ -142,6 +212,6 @@ var getSchemaParamsFromId = (id) => {
|
|
|
142
212
|
};
|
|
143
213
|
};
|
|
144
214
|
//#endregion
|
|
145
|
-
export { getIdFromUrl, getSchemaParamsFromId, makeUrlFromId, matchesBasePath,
|
|
215
|
+
export { getIdFromUrl, getSchemaParamsFromId, makeUrlFromId, matchesBasePath, redirectUrl };
|
|
146
216
|
|
|
147
217
|
//# sourceMappingURL=id-routing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-routing.js","names":[],"sources":["../../src/helpers/id-routing.ts"],"sourcesContent":["export const sanitizeBasePath = (basePath: string) => {\n return basePath.replace(/^\\/+|\\/+$/g, '')\n}\n\nconst isHashBasePath = (basePath: string) => basePath.startsWith('#')\n\nconst sanitizeHashBasePath = (basePath: string) => {\n return basePath.replace(/^#+/, '').replace(/\\/+$/g, '')\n}\n\nconst applySlugPrefix = (base: string, slugPrefix: string | undefined) => {\n return slugPrefix ? `${slugPrefix}${base ? '/' : ''}${base}` : base\n}\n\nconst stripBasePathPrefix = (value: string, basePath: string) => {\n if (value === basePath) {\n return ''\n }\n\n if (value.startsWith(`${basePath}/`)) {\n return value.slice(basePath.length + 1)\n }\n\n return null\n}\n\n/** Extracts an element id from the hash when using hash routing */\nexport const getIdFromHash = (location: string | URL, slugPrefix: string | undefined) => {\n const url = typeof location === 'string' ? new URL(location) : location\n\n const base = decodeURIComponent(url.hash.slice(1))\n\n return applySlugPrefix(base, slugPrefix)\n}\n/** Extracts an element id from the path when using path routing */\nexport const getIdFromPath = (location: string | URL, basePath: string, slugPrefix: string | undefined) => {\n const url = typeof location === 'string' ? new URL(location) : location\n const sanitized = sanitizeBasePath(basePath)\n\n // Construct the full basePath with leading slash and encode it for matching\n // We need to encode each segment separately to match how URLs encode pathnames\n const basePathWithSlash = sanitized\n ? `/${sanitized\n .split('/')\n .map((segment) => encodeURIComponent(segment))\n .join('/')}`\n : ''\n\n // Extract the portion after the basePath\n if (url.pathname.startsWith(basePathWithSlash)) {\n const remainder = url.pathname.slice(basePathWithSlash.length)\n const base = decodeURIComponent(remainder.startsWith('/') ? remainder.slice(1) : remainder)\n return applySlugPrefix(base, slugPrefix)\n }\n\n return slugPrefix ?? ''\n}\n\n/** Extracts an element id from a hash-prefixed basePath */\nexport const getIdFromHashBasePath = (location: string | URL, basePath: string, slugPrefix: string | undefined) => {\n const url = typeof location === 'string' ? new URL(location) : location\n const hash = decodeURIComponent(url.hash.slice(1))\n const sanitized = sanitizeHashBasePath(basePath)\n\n const remainder = stripBasePathPrefix(hash, sanitized)\n if (remainder !== null) {\n return applySlugPrefix(remainder, slugPrefix)\n }\n\n return slugPrefix ?? ''\n}\n\n/** Determines whether a URL matches the provided basePath. */\nexport const matchesBasePath = (location: string | URL, basePath: string) => {\n const url = typeof location === 'string' ? new URL(location) : location\n\n if (isHashBasePath(basePath)) {\n const hash = decodeURIComponent(url.hash)\n return hash === basePath || hash.startsWith(`${basePath}/`)\n }\n\n const sanitized = sanitizeBasePath(basePath)\n const basePathWithSlash = sanitized\n ? `/${sanitized\n .split('/')\n .map((segment) => encodeURIComponent(segment))\n .join('/')}`\n : ''\n\n return url.pathname === basePathWithSlash || url.pathname.startsWith(`${basePathWithSlash}/`)\n}\n\n/**\n * Extracts a navigation id from a URL based on the routing type\n *\n * @param url - The URL to extract the id from\n * @param basePath - The base path used in path routing\n * @param slugPrefix - If the document slug is not expected in the URL then we must prefix it\n */\nexport const getIdFromUrl = (url: string | URL, basePath: string | undefined, slugPrefix: string | undefined) => {\n if (typeof basePath !== 'string') {\n return getIdFromHash(url, slugPrefix)\n }\n\n return isHashBasePath(basePath)\n ? getIdFromHashBasePath(url, basePath, slugPrefix)\n : getIdFromPath(url, basePath, slugPrefix)\n}\n\n/**\n * Strips the first segment from an id and preserves trailing slashes\n * Used in single-document mode where the document slug is not needed in the URL\n *\n * @param id - The full id to process\n * @returns The id with the first segment removed, preserving trailing slash if present\n */\nconst stripFirstSegment = (id: string): string => {\n // For preserving trailing slash in the id\n const hasTrailingSlash = id.endsWith('/')\n const segments = id.split('/').filter(Boolean).slice(1)\n const result = segments.join('/')\n\n // Only preserve trailing slash if there's actual content\n return hasTrailingSlash && result ? `${result}/` : result\n}\n\n/**\n * Generate a new URL and applies the ID to the path or hash\n * depending on the type of routing used\n *\n * @param id - The id to apply to the URL\n * @param basePath - The base path used in path routing\n * @param isMultiDocument - Whether the document is multi-document or single-document. Single-document documents will strip the document slug from the id\n */\nexport const makeUrlFromId = (_id: string, basePath: string | undefined, isMultiDocument: boolean) => {\n if (typeof window === 'undefined') {\n return undefined\n }\n\n /** When there is only 1 document we don't need to include the document name in the URL */\n const id = isMultiDocument ? _id : stripFirstSegment(_id)\n const url = new URL(window.location.href)\n\n if (typeof basePath === 'string') {\n if (isHashBasePath(basePath)) {\n const base = sanitizeHashBasePath(basePath)\n url.hash = [base, id].filter(Boolean).join('/')\n } else {\n const base = sanitizeBasePath(basePath)\n url.pathname = `${base}/${id}`\n }\n } else {\n url.hash = id\n }\n\n return url\n}\n\nconst escapeRegex = (value: string) => value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\n/**\n * Rewrite legacy `/model/<name>` URL segments to the current section's slug.\n *\n * Earlier versions hardcoded `model/` (singular) as the prefix for individual schema entries\n * even though the section itself was `models/`. We now use the same plural slug for both,\n * so old bookmarks like `#default/model/User` would 404. This rewrites them in place.\n *\n * The regex is anchored to the legacy structural shape so unrelated `/model/` occurrences\n * inside operation paths (e.g. `POST /model/train` for an AI/ML API → `default/POST/model/train`)\n * and a tag literally named \"model\" are left alone.\n *\n * Trade-off: in single-document mode the URL strips the document slug, which makes\n * `#tag/<slug>/model/<name>` ambiguous with an operation under a tag named \"model\".\n * Single-doc tagged-model bookmarks are not rewritten — only top-level models.\n *\n * Returns the canonicalized URL when a rewrite happens, or null otherwise.\n */\nexport const redirectLegacyModelUrl = (\n url: string | URL,\n modelsSectionSlug: string,\n documentSlug: string,\n isMultiDocument: boolean,\n basePath?: string,\n): URL | null => {\n if (!documentSlug) {\n return null\n }\n\n const next = typeof url === 'string' ? new URL(url) : new URL(url.toString())\n const escapedDoc = escapeRegex(documentSlug)\n // Optional `(tag-group/<n>/)?tag/<slug>/` block in front of `model/`.\n const tagPrefix = '(?:(?:tag-group\\\\/[^/]+\\\\/)?tag\\\\/[^/]+\\\\/)?'\n const slugAnchoredHash = new RegExp(`^(#${escapedDoc}\\\\/${tagPrefix})model\\\\/`)\n const replacement = `$1${modelsSectionSlug}/`\n\n // Always try the slug-anchored form first — old bookmarks may include the doc slug\n // even in single-document mode.\n let newHash = next.hash.replace(slugAnchoredHash, replacement)\n if (newHash === next.hash && !isMultiDocument) {\n // Single-doc fallback: URL omits the doc slug (`#model/<name>`). We can only\n // safely rewrite top-level models here — `#tag/<slug>/model/<name>` is\n // ambiguous with an operation under a tag literally named \"model\".\n newHash = next.hash.replace(/^(#)model\\//, replacement)\n }\n\n let newPathname = next.pathname\n if (basePath !== undefined && !basePath.startsWith('#')) {\n const escapedBase = escapeRegex(sanitizeBasePath(basePath))\n const basePrefix = escapedBase ? `\\\\/${escapedBase}` : ''\n const slugAnchoredPath = new RegExp(`^(${basePrefix}\\\\/${escapedDoc}\\\\/${tagPrefix})model\\\\/`)\n newPathname = next.pathname.replace(slugAnchoredPath, replacement)\n if (newPathname === next.pathname && !isMultiDocument) {\n newPathname = next.pathname.replace(new RegExp(`^(${basePrefix}\\\\/)model\\\\/`), replacement)\n }\n }\n\n if (newHash === next.hash && newPathname === next.pathname) {\n return null\n }\n\n next.hash = newHash\n next.pathname = newPathname\n return next\n}\n\n/** Extracts the schema parameters from the id if they are present */\nexport const getSchemaParamsFromId = (id: string): { rawId: string; params: string } => {\n const matcher = id.match(/(.*)(\\.body\\.|\\.path\\.|\\.query\\.|\\.header\\.)(.*)/)\n\n if (matcher && typeof matcher[1] === 'string' && typeof matcher[2] === 'string') {\n return {\n rawId: matcher[1],\n params: matcher[2].slice(1) + matcher[3],\n }\n }\n return {\n rawId: id,\n params: '',\n }\n}\n"],"mappings":";AAAA,IAAa,oBAAoB,aAAqB;AACpD,QAAO,SAAS,QAAQ,cAAc,GAAG;;AAG3C,IAAM,kBAAkB,aAAqB,SAAS,WAAW,IAAI;AAErE,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AAQ;EACf,QAAQ,QAAQ,GAAG,MAAM,EAAE,GAAG,QAAQ;EACvC;AAEH,QAAO;EACL,OAAO;EACP,QAAQ;EACT"}
|
|
1
|
+
{"version":3,"file":"id-routing.js","names":[],"sources":["../../src/helpers/id-routing.ts"],"sourcesContent":["export const sanitizeBasePath = (basePath: string) => {\n return basePath.replace(/^\\/+|\\/+$/g, '')\n}\n\nconst isHashBasePath = (basePath: string) => basePath.startsWith('#')\n\nconst sanitizeHashBasePath = (basePath: string) => {\n return basePath.replace(/^#+/, '').replace(/\\/+$/g, '')\n}\n\nconst applySlugPrefix = (base: string, slugPrefix: string | undefined) => {\n return slugPrefix ? `${slugPrefix}${base ? '/' : ''}${base}` : base\n}\n\nconst stripBasePathPrefix = (value: string, basePath: string) => {\n if (value === basePath) {\n return ''\n }\n\n if (value.startsWith(`${basePath}/`)) {\n return value.slice(basePath.length + 1)\n }\n\n return null\n}\n\n/**\n * Builds the URL-encoded, slash-prefixed form of a sanitized base path.\n *\n * Each segment is encoded separately so the result matches how the browser stores\n * `location.pathname` (which encodes within segments but leaves the slashes between them).\n */\nconst encodeBasePath = (sanitized: string) => {\n if (!sanitized) {\n return ''\n }\n\n return `/${sanitized\n .split('/')\n .map((segment) => encodeURIComponent(segment))\n .join('/')}`\n}\n\n/** Extracts an element id from the hash when using hash routing */\nexport const getIdFromHash = (location: string | URL, slugPrefix: string | undefined) => {\n const url = typeof location === 'string' ? new URL(location) : location\n\n const base = decodeURIComponent(url.hash.slice(1))\n\n return applySlugPrefix(base, slugPrefix)\n}\n/** Extracts an element id from the path when using path routing */\nexport const getIdFromPath = (location: string | URL, basePath: string, slugPrefix: string | undefined) => {\n const url = typeof location === 'string' ? new URL(location) : location\n const basePathWithSlash = encodeBasePath(sanitizeBasePath(basePath))\n\n // Extract the portion after the basePath\n if (url.pathname.startsWith(basePathWithSlash)) {\n const remainder = url.pathname.slice(basePathWithSlash.length)\n const base = decodeURIComponent(remainder.startsWith('/') ? remainder.slice(1) : remainder)\n return applySlugPrefix(base, slugPrefix)\n }\n\n return slugPrefix ?? ''\n}\n\n/** Extracts an element id from a hash-prefixed basePath */\nexport const getIdFromHashBasePath = (location: string | URL, basePath: string, slugPrefix: string | undefined) => {\n const url = typeof location === 'string' ? new URL(location) : location\n const hash = decodeURIComponent(url.hash.slice(1))\n const sanitized = sanitizeHashBasePath(basePath)\n\n const remainder = stripBasePathPrefix(hash, sanitized)\n if (remainder !== null) {\n return applySlugPrefix(remainder, slugPrefix)\n }\n\n return slugPrefix ?? ''\n}\n\n/** Determines whether a URL matches the provided basePath. */\nexport const matchesBasePath = (location: string | URL, basePath: string) => {\n const url = typeof location === 'string' ? new URL(location) : location\n\n if (isHashBasePath(basePath)) {\n const hash = decodeURIComponent(url.hash)\n return hash === basePath || hash.startsWith(`${basePath}/`)\n }\n\n const basePathWithSlash = encodeBasePath(sanitizeBasePath(basePath))\n\n return url.pathname === basePathWithSlash || url.pathname.startsWith(`${basePathWithSlash}/`)\n}\n\n/**\n * Extracts a navigation id from a URL based on the routing type\n *\n * @param url - The URL to extract the id from\n * @param basePath - The base path used in path routing\n * @param slugPrefix - If the document slug is not expected in the URL then we must prefix it\n */\nexport const getIdFromUrl = (url: string | URL, basePath: string | undefined, slugPrefix: string | undefined) => {\n if (typeof basePath !== 'string') {\n return getIdFromHash(url, slugPrefix)\n }\n\n return isHashBasePath(basePath)\n ? getIdFromHashBasePath(url, basePath, slugPrefix)\n : getIdFromPath(url, basePath, slugPrefix)\n}\n\n/**\n * Strips the first segment from an id and preserves trailing slashes\n * Used in single-document mode where the document slug is not needed in the URL\n *\n * @param id - The full id to process\n * @returns The id with the first segment removed, preserving trailing slash if present\n */\nconst stripFirstSegment = (id: string): string => {\n // For preserving trailing slash in the id\n const hasTrailingSlash = id.endsWith('/')\n const segments = id.split('/').filter(Boolean).slice(1)\n const result = segments.join('/')\n\n // Only preserve trailing slash if there's actual content\n return hasTrailingSlash && result ? `${result}/` : result\n}\n\n/**\n * Generate a new URL and applies the ID to the path or hash\n * depending on the type of routing used\n *\n * @param id - The id to apply to the URL\n * @param basePath - The base path used in path routing\n * @param isMultiDocument - Whether the document is multi-document or single-document. Single-document documents will strip the document slug from the id\n */\nexport const makeUrlFromId = (_id: string, basePath: string | undefined, isMultiDocument: boolean) => {\n if (typeof window === 'undefined') {\n return undefined\n }\n\n /** When there is only 1 document we don't need to include the document name in the URL */\n const id = isMultiDocument ? _id : stripFirstSegment(_id)\n const url = new URL(window.location.href)\n\n if (typeof basePath === 'string') {\n if (isHashBasePath(basePath)) {\n const base = sanitizeHashBasePath(basePath)\n url.hash = [base, id].filter(Boolean).join('/')\n } else {\n const base = sanitizeBasePath(basePath)\n url.pathname = `${base}/${id}`\n }\n } else {\n url.hash = id\n }\n\n return url\n}\n\nconst escapeRegex = (value: string) => value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\n/**\n * A located navigation id: the decoded id plus a way to write a rewritten id back.\n */\ntype IdCarrier = {\n /** The decoded navigation id with all routing chrome (`#`, base path) removed. */\n value: string\n /** Splices `next` back into the location this id came from, preserving the URL shape. */\n write: (next: string) => void\n}\n\n/** Carrier for an id that lives in the bare hash fragment (`#<id>`). */\nconst bareHashCarrier = (url: URL): IdCarrier => ({\n value: decodeURIComponent(url.hash.slice(1)),\n write: (next) => {\n url.hash = next\n },\n})\n\n/**\n * Locates the navigation id inside a URL regardless of the routing mode.\n *\n * The id can live in three places — the bare hash, a hash base path (`#<base>/<id>`), or the\n * pathname after a path base path. Each carrier pairs the decoded id with a `write` callback, so\n * callers edit ids in id-space without re-deriving the routing chrome for each mode.\n *\n * Multiple carriers are returned: the canonical location for the active routing mode comes first,\n * followed by a legacy bare-hash carrier. Both path and hash-base-path routing include the bare hash\n * so a stale `#default/model/User` bookmark (left over from before the base path was configured) is\n * still canonicalized — the previous implementation rewrote such doc-slug-anchored hashes on every\n * load regardless of the routing mode. Callers rewrite every carrier that matches, not just the\n * first, so a legacy id sitting in both the pathname and the hash is cleaned up in one pass.\n */\nconst locateIdCarriers = (url: URL, basePath: string | undefined): IdCarrier[] => {\n // Hash routing: the id is the bare fragment.\n if (typeof basePath !== 'string') {\n return [bareHashCarrier(url)]\n }\n\n // Hash base path routing: the id follows a `#<base>/` prefix.\n if (isHashBasePath(basePath)) {\n const base = sanitizeHashBasePath(basePath)\n const hash = decodeURIComponent(url.hash.slice(1))\n\n return [\n {\n value: stripBasePathPrefix(hash, base) ?? '',\n write: (next) => {\n url.hash = [base, next].filter(Boolean).join('/')\n },\n },\n // Legacy fallback: an old bookmark may carry the id in the fragment without the base prefix.\n bareHashCarrier(url),\n ]\n }\n\n // Path routing: the id follows the (URL-encoded) base path in the pathname.\n const base = sanitizeBasePath(basePath)\n const remainder = stripBasePathPrefix(url.pathname, encodeBasePath(base))\n\n return [\n {\n value: remainder === null ? '' : decodeURIComponent(remainder),\n write: (next) => {\n // Assigning to `pathname` re-encodes characters, so we splice with the decoded base.\n url.pathname = base ? `/${base}/${next}` : `/${next}`\n },\n },\n // Legacy fallback: an old hash-routing bookmark may still carry the id in the fragment.\n bareHashCarrier(url),\n ]\n}\n\n/**\n * A single redirect rule, expressed in routing-agnostic id-space.\n *\n * Ids are navigation strings with all routing chrome (`#`, base path) stripped — see\n * {@link locateIdCarrier}. A rule is just the shape of an id rewrite: `match` is tested against the\n * id and `replace` follows the native `String.prototype.replace` contract, so a rule can be a plain\n * segment swap or an arbitrary replacer function. A rule that does not match leaves the id alone.\n */\ntype IdRedirect = {\n /** Pattern tested against the routing-agnostic id. */\n match: RegExp\n /** Replacement passed straight to `String.prototype.replace` (template string or replacer fn). */\n replace: string | ((substring: string, ...groups: string[]) => string)\n}\n\n/**\n * Applies redirect rules to an id and returns the first rewrite that changes it.\n *\n * Rules are tried in order and the search stops at the first match, so list more specific rules\n * before more general ones. Returns the id unchanged when no rule applies.\n */\nconst applyIdRedirects = (id: string, redirects: IdRedirect[]): string => {\n for (const { match, replace } of redirects) {\n // The ternary narrows the union so each `String.prototype.replace` overload type-checks.\n const next = typeof replace === 'string' ? id.replace(match, replace) : id.replace(match, replace)\n if (next !== id) {\n return next\n }\n }\n\n return id\n}\n\n/** Optional `(tag-group/<n>/)?tag/<slug>/` chrome that may sit in front of a section segment. */\nconst TAG_CHROME = '(?:(?:tag-group/[^/]+/)?tag/[^/]+/)?'\n\n/**\n * Runtime values the redirect rules are built from.\n *\n * The rules are data, but a few entries depend on per-document values (the configurable models\n * section slug, the active document slug, single- vs multi-document mode), so the list is built per\n * call rather than declared as a static constant.\n */\ntype RedirectContext = {\n /** Current (possibly customized) slug of the models section, e.g. `models` or `schemas`. */\n modelsSectionSlug: string\n /** Slug of the active document; legacy ids are anchored to it to avoid false positives. */\n documentSlug: string\n /** Multi-document ids always carry the doc slug; single-document bookmarks may omit it. */\n isMultiDocument: boolean\n}\n\n/**\n * Builds the list of id redirects for the current document.\n *\n * Add an entry here to support a new redirect. Each rule runs against every URL shape (hash, hash\n * base path, path) for free, because rules operate on routing-agnostic ids.\n */\nconst buildRedirects = ({ modelsSectionSlug, documentSlug, isMultiDocument }: RedirectContext): IdRedirect[] => {\n const escapedDoc = escapeRegex(documentSlug)\n // Keeping the tag chrome inside the doc-slug group is deliberate: a slug-less\n // `tag/<slug>/<segment>/<name>` is left alone, since once the document slug is stripped it is\n // ambiguous with an operation under a tag literally named after the segment.\n const documentPrefix = isMultiDocument ? `${escapedDoc}/${TAG_CHROME}` : `(?:${escapedDoc}/${TAG_CHROME})?`\n\n // Rewrites a leading `<from>/` section segment to the current models section slug. The trailing\n // `/` leaves an already-correct segment and operation paths such as `default/POST/model/train`\n // untouched.\n const renameSectionSegment = (from: string): IdRedirect => ({\n match: new RegExp(`^(${documentPrefix})${escapeRegex(from)}/`),\n replace: (_match, prefix) => `${prefix}${modelsSectionSlug}/`,\n })\n\n const redirects = [\n // Earlier versions hardcoded a singular `model/` prefix for individual schema entries even\n // though the section itself was plural, so old bookmarks like `default/model/User` would 404.\n renameSectionSegment('model'),\n ]\n\n // The models section used to live at the literal `models/`. Once a custom label moves it\n // elsewhere (e.g. `schemas/`), older `models/<name>` bookmarks must follow it. When the slug is\n // still the default `models` this would be a no-op, so only register it when it actually differs.\n if (modelsSectionSlug !== 'models') {\n redirects.push(renameSectionSegment('models'))\n }\n\n return redirects\n}\n\n/**\n * Rewrites navigation ids in a URL to their current form.\n *\n * The URL is reduced to its routing-agnostic id (see {@link locateIdCarriers}), each redirect rule\n * is applied in id-space (see {@link buildRedirects}), and the result is spliced back into the\n * original location. This handles hash, hash-base-path, and path routing uniformly, so a new\n * redirect only has to be added to the list once.\n *\n * Returns the canonicalized URL when a rewrite happens, or null otherwise.\n */\nexport const redirectUrl = (\n url: string | URL,\n modelsSectionSlug: string,\n documentSlug: string,\n isMultiDocument: boolean,\n basePath?: string,\n): URL | null => {\n if (!documentSlug) {\n return null\n }\n\n const target = new URL(typeof url === 'string' ? url : url.toString())\n const redirects = buildRedirects({ modelsSectionSlug, documentSlug, isMultiDocument })\n\n // Canonicalize every place the id might live. The carriers are distinct physical locations (the\n // pathname and the bare hash), so a single page load can carry a legacy id in more than one — for\n // example a path-routing URL whose stale hash still holds an old bookmark. Rewriting all of them\n // avoids the address bar showing a corrected path next to an outdated hash. A redirect rule is\n // anchored to the document slug, so it never matches the base-prefixed value of a fallback carrier,\n // which keeps carriers that happen to share a location (hash base path + bare hash) from clobbering\n // each other.\n let didRedirect = false\n for (const carrier of locateIdCarriers(target, basePath)) {\n const rewritten = applyIdRedirects(carrier.value, redirects)\n if (rewritten !== carrier.value) {\n carrier.write(rewritten)\n didRedirect = true\n }\n }\n\n return didRedirect ? target : null\n}\n\n/** Extracts the schema parameters from the id if they are present */\nexport const getSchemaParamsFromId = (id: string): { rawId: string; params: string } => {\n const matcher = id.match(/(.*)(\\.body\\.|\\.path\\.|\\.query\\.|\\.header\\.)(.*)/)\n\n if (matcher && typeof matcher[1] === 'string' && typeof matcher[2] === 'string') {\n return {\n rawId: matcher[1],\n params: matcher[2].slice(1) + matcher[3],\n }\n }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