@scalar/workspace-store 0.40.2 → 0.40.4
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 +13 -0
- package/dist/client.d.ts +7 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +820 -681
- package/dist/entities/auth/index.js +96 -101
- package/dist/entities/auth/schema.d.ts +10 -0
- package/dist/entities/auth/schema.d.ts.map +1 -1
- package/dist/entities/auth/schema.js +42 -116
- package/dist/entities/history/index.js +80 -60
- package/dist/entities/history/schema.js +94 -88
- package/dist/events/bus.js +146 -93
- package/dist/events/definitions/analytics.js +1 -1
- package/dist/events/definitions/auth.js +1 -1
- package/dist/events/definitions/common.js +1 -1
- package/dist/events/definitions/cookie.js +1 -1
- package/dist/events/definitions/document.js +1 -1
- package/dist/events/definitions/environment.js +1 -1
- package/dist/events/definitions/hooks.js +1 -1
- package/dist/events/definitions/index.js +1 -1
- package/dist/events/definitions/meta.js +1 -1
- package/dist/events/definitions/operation.js +1 -1
- package/dist/events/definitions/server.js +1 -1
- package/dist/events/definitions/tabs.js +1 -1
- package/dist/events/definitions/tag.js +1 -1
- package/dist/events/definitions/ui.js +1 -1
- package/dist/events/definitions/workspace.js +1 -1
- package/dist/events/index.js +3 -9
- package/dist/events/listeners.js +20 -22
- package/dist/events/old-definitions.js +15 -12
- package/dist/helpers/deep-clone.js +33 -17
- package/dist/helpers/detect-changes-proxy.js +95 -57
- package/dist/helpers/general.js +78 -23
- package/dist/helpers/generate-unique-value.js +77 -45
- package/dist/helpers/get-fetch.js +12 -10
- package/dist/helpers/get-resolved-ref.js +11 -10
- package/dist/helpers/is-non-optional-security-requirement.js +3 -6
- package/dist/helpers/merge-object.js +71 -30
- package/dist/helpers/overrides-proxy.js +98 -58
- package/dist/helpers/unpack-proxy.js +60 -58
- package/dist/mutators/auth.js +358 -230
- package/dist/mutators/cookie.js +59 -42
- package/dist/mutators/document.js +104 -66
- package/dist/mutators/environment.js +97 -72
- package/dist/mutators/helpers.js +9 -13
- package/dist/mutators/index.js +62 -49
- package/dist/mutators/operation/body.js +88 -57
- package/dist/mutators/operation/extensions.js +20 -12
- package/dist/mutators/operation/helpers/fetch-request-to-har.js +144 -107
- package/dist/mutators/operation/helpers/fetch-response-to-har.js +143 -95
- package/dist/mutators/operation/helpers/get-parameter-position.js +12 -12
- package/dist/mutators/operation/helpers/har-to-operation.js +169 -132
- package/dist/mutators/operation/helpers/sync-path-parameters.js +109 -60
- package/dist/mutators/operation/history.js +60 -64
- package/dist/mutators/operation/index.js +25 -49
- package/dist/mutators/operation/operation.js +349 -240
- package/dist/mutators/operation/parameters.js +157 -93
- package/dist/mutators/server.js +213 -152
- package/dist/mutators/tabs.js +173 -130
- package/dist/mutators/tag.js +131 -97
- package/dist/mutators/workspace.js +72 -42
- package/dist/navigation/get-navigation-options.js +97 -84
- package/dist/navigation/helpers/get-openapi-object.js +46 -29
- package/dist/navigation/helpers/get-operation-entries.js +72 -32
- package/dist/navigation/helpers/get-parent-entry.js +16 -12
- package/dist/navigation/helpers/get-tag-entries.js +56 -29
- package/dist/navigation/helpers/get-tag.js +22 -23
- package/dist/navigation/helpers/get-x-keys.js +13 -9
- package/dist/navigation/helpers/traverse-description.js +90 -72
- package/dist/navigation/helpers/traverse-document.js +111 -98
- package/dist/navigation/helpers/traverse-examples.js +35 -31
- package/dist/navigation/helpers/traverse-paths.js +118 -106
- package/dist/navigation/helpers/traverse-schemas.js +65 -64
- package/dist/navigation/helpers/traverse-tags.js +158 -129
- package/dist/navigation/helpers/traverse-webhooks.js +96 -90
- package/dist/navigation/helpers/update-order-ids.js +59 -51
- package/dist/navigation/helpers/utils.js +71 -21
- package/dist/navigation/index.js +5 -13
- package/dist/navigation/types.js +1 -1
- package/dist/persistence/index.js +283 -285
- package/dist/persistence/indexdb.js +263 -126
- package/dist/plugins/bundler/helpers.js +21 -12
- package/dist/plugins/bundler/index.d.ts +7 -0
- package/dist/plugins/bundler/index.d.ts.map +1 -1
- package/dist/plugins/bundler/index.js +305 -171
- package/dist/plugins/client/index.js +1 -5
- package/dist/plugins/client/persistence.js +95 -90
- package/dist/resolve.js +18 -25
- package/dist/schemas/compose.js +6 -7
- package/dist/schemas/extensions/document/x-internal.js +3 -7
- package/dist/schemas/extensions/document/x-scalar-environments.js +16 -22
- package/dist/schemas/extensions/document/x-scalar-icon.js +3 -7
- package/dist/schemas/extensions/document/x-scalar-ignore.js +3 -7
- package/dist/schemas/extensions/document/x-scalar-is-dirty.js +21 -8
- package/dist/schemas/extensions/document/x-scalar-original-document-hash.js +17 -8
- package/dist/schemas/extensions/document/x-scalar-registry-meta.js +15 -21
- package/dist/schemas/extensions/document/x-scalar-sdk-installation.js +5 -13
- package/dist/schemas/extensions/document/x-scalar-watch-mode.js +4 -8
- package/dist/schemas/extensions/document/x-tags.js +3 -7
- package/dist/schemas/extensions/example/x-disabled.js +17 -7
- package/dist/schemas/extensions/general/x-scalar-active-environment.js +4 -7
- package/dist/schemas/extensions/general/x-scalar-cookies.js +9 -14
- package/dist/schemas/extensions/general/x-scalar-order.js +8 -7
- package/dist/schemas/extensions/operation/index.js +4 -23
- package/dist/schemas/extensions/operation/x-badge.js +42 -50
- package/dist/schemas/extensions/operation/x-code-samples.js +8 -12
- package/dist/schemas/extensions/operation/x-draft-examples.js +3 -7
- package/dist/schemas/extensions/operation/x-post-response.js +18 -7
- package/dist/schemas/extensions/operation/x-scalar-disable-parameters.js +57 -13
- package/dist/schemas/extensions/operation/x-scalar-selected-content-type.js +9 -7
- package/dist/schemas/extensions/operation/x-scalar-stability.js +15 -14
- package/dist/schemas/extensions/parameter/x-global.js +12 -7
- package/dist/schemas/extensions/schema/x-additional-properties-name.js +10 -7
- package/dist/schemas/extensions/schema/x-enum-descriptions.js +17 -12
- package/dist/schemas/extensions/schema/x-enum-varnames.js +21 -8
- package/dist/schemas/extensions/schema/x-examples.js +3 -7
- package/dist/schemas/extensions/schema/x-variable.js +3 -7
- package/dist/schemas/extensions/security/index.js +1 -1
- package/dist/schemas/extensions/security/x-default-scopes.js +16 -7
- package/dist/schemas/extensions/security/x-scalar-credentials-location.js +16 -7
- package/dist/schemas/extensions/security/x-scalar-security-body.js +14 -7
- package/dist/schemas/extensions/security/x-scalar-security-query.js +14 -7
- package/dist/schemas/extensions/security/x-scalar-security-secrets.js +66 -37
- package/dist/schemas/extensions/security/x-tokenName.js +11 -7
- package/dist/schemas/extensions/security/x-use-pkce.js +6 -10
- package/dist/schemas/extensions/server/x-scalar-selected-server.js +3 -7
- package/dist/schemas/extensions/tag/index.js +1 -1
- package/dist/schemas/extensions/tag/x-display-name.js +11 -7
- package/dist/schemas/extensions/tag/x-tag-groups.js +13 -15
- package/dist/schemas/extensions/workspace/index.js +2 -11
- package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js +13 -7
- package/dist/schemas/extensions/workspace/x-scalar-tabs.js +15 -13
- package/dist/schemas/extensions.js +11 -15
- package/dist/schemas/inmemory-workspace.d.ts +6 -0
- package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
- package/dist/schemas/inmemory-workspace.js +13 -21
- package/dist/schemas/navigation.js +48 -85
- package/dist/schemas/reference-config/appearance.js +15 -22
- package/dist/schemas/reference-config/features.js +14 -21
- package/dist/schemas/reference-config/index.d.ts +2 -0
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/index.js +42 -44
- package/dist/schemas/reference-config/meta.js +11 -18
- package/dist/schemas/reference-config/routing.js +7 -14
- package/dist/schemas/reference-config/settings.d.ts +2 -0
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.js +10 -17
- package/dist/schemas/typebox-coerce.js +23 -6
- package/dist/schemas/v3.1/strict/callback.js +6 -12
- package/dist/schemas/v3.1/strict/components.js +26 -48
- package/dist/schemas/v3.1/strict/contact.js +9 -12
- package/dist/schemas/v3.1/strict/discriminator.js +11 -10
- package/dist/schemas/v3.1/strict/encoding.js +15 -12
- package/dist/schemas/v3.1/strict/example.js +11 -13
- package/dist/schemas/v3.1/strict/external-documentation.js +7 -10
- package/dist/schemas/v3.1/strict/header.js +27 -28
- package/dist/schemas/v3.1/strict/info.js +10 -16
- package/dist/schemas/v3.1/strict/license.js +9 -12
- package/dist/schemas/v3.1/strict/link.js +22 -19
- package/dist/schemas/v3.1/strict/media-type.js +17 -16
- package/dist/schemas/v3.1/strict/oauth-flow.js +28 -62
- package/dist/schemas/v3.1/strict/oauthflows.js +14 -20
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +70 -0
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.js +126 -210
- package/dist/schemas/v3.1/strict/operation.js +16 -43
- package/dist/schemas/v3.1/strict/parameter.d.ts +6 -0
- package/dist/schemas/v3.1/strict/parameter.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/parameter.js +29 -35
- package/dist/schemas/v3.1/strict/path-item.js +36 -40
- package/dist/schemas/v3.1/strict/paths.js +8 -11
- package/dist/schemas/v3.1/strict/ref-definitions.js +76 -100
- package/dist/schemas/v3.1/strict/reference.js +18 -21
- package/dist/schemas/v3.1/strict/request-body.js +8 -16
- package/dist/schemas/v3.1/strict/response.js +12 -16
- package/dist/schemas/v3.1/strict/responses.js +13 -11
- package/dist/schemas/v3.1/strict/schema.js +149 -157
- package/dist/schemas/v3.1/strict/security-requirement.js +13 -12
- package/dist/schemas/v3.1/strict/security-scheme.js +29 -41
- package/dist/schemas/v3.1/strict/server-variable.js +9 -12
- package/dist/schemas/v3.1/strict/server.js +10 -13
- package/dist/schemas/v3.1/strict/tag.js +11 -20
- package/dist/schemas/v3.1/strict/type-guards.js +20 -20
- package/dist/schemas/v3.1/strict/xml.js +17 -16
- package/dist/schemas/workspace-specification/index.js +11 -23
- package/dist/schemas/workspace-specification/info.js +4 -8
- package/dist/schemas/workspace.d.ts +6 -0
- package/dist/schemas/workspace.d.ts.map +1 -1
- package/dist/schemas/workspace.js +25 -51
- package/dist/schemas.js +2 -6
- package/dist/server.js +286 -176
- package/dist/workspace-plugin.js +1 -1
- package/package.json +13 -19
- package/dist/client.js.map +0 -7
- package/dist/entities/auth/index.js.map +0 -7
- package/dist/entities/auth/schema.js.map +0 -7
- package/dist/entities/history/index.js.map +0 -7
- package/dist/entities/history/schema.js.map +0 -7
- package/dist/events/bus.js.map +0 -7
- package/dist/events/definitions/analytics.js.map +0 -7
- package/dist/events/definitions/auth.js.map +0 -7
- package/dist/events/definitions/common.js.map +0 -7
- package/dist/events/definitions/cookie.js.map +0 -7
- package/dist/events/definitions/document.js.map +0 -7
- package/dist/events/definitions/environment.js.map +0 -7
- package/dist/events/definitions/hooks.js.map +0 -7
- package/dist/events/definitions/index.js.map +0 -7
- package/dist/events/definitions/meta.js.map +0 -7
- package/dist/events/definitions/operation.js.map +0 -7
- package/dist/events/definitions/server.js.map +0 -7
- package/dist/events/definitions/tabs.js.map +0 -7
- package/dist/events/definitions/tag.js.map +0 -7
- package/dist/events/definitions/ui.js.map +0 -7
- package/dist/events/definitions/workspace.js.map +0 -7
- package/dist/events/index.js.map +0 -7
- package/dist/events/listeners.js.map +0 -7
- package/dist/events/old-definitions.js.map +0 -7
- package/dist/helpers/apply-selective-updates.d.ts +0 -19
- package/dist/helpers/apply-selective-updates.d.ts.map +0 -1
- package/dist/helpers/apply-selective-updates.js +0 -37
- package/dist/helpers/apply-selective-updates.js.map +0 -7
- package/dist/helpers/deep-clone.js.map +0 -7
- package/dist/helpers/detect-changes-proxy.js.map +0 -7
- package/dist/helpers/general.js.map +0 -7
- package/dist/helpers/generate-unique-value.js.map +0 -7
- package/dist/helpers/get-fetch.js.map +0 -7
- package/dist/helpers/get-resolved-ref.js.map +0 -7
- package/dist/helpers/is-non-optional-security-requirement.js.map +0 -7
- package/dist/helpers/merge-object.js.map +0 -7
- package/dist/helpers/overrides-proxy.js.map +0 -7
- package/dist/helpers/unpack-proxy.js.map +0 -7
- package/dist/mutators/auth.js.map +0 -7
- package/dist/mutators/cookie.js.map +0 -7
- package/dist/mutators/document.js.map +0 -7
- package/dist/mutators/environment.js.map +0 -7
- package/dist/mutators/helpers.js.map +0 -7
- package/dist/mutators/index.js.map +0 -7
- package/dist/mutators/operation/body.js.map +0 -7
- package/dist/mutators/operation/extensions.js.map +0 -7
- package/dist/mutators/operation/helpers/fetch-request-to-har.js.map +0 -7
- package/dist/mutators/operation/helpers/fetch-response-to-har.js.map +0 -7
- package/dist/mutators/operation/helpers/get-parameter-position.js.map +0 -7
- package/dist/mutators/operation/helpers/har-to-operation.js.map +0 -7
- package/dist/mutators/operation/helpers/sync-path-parameters.js.map +0 -7
- package/dist/mutators/operation/history.js.map +0 -7
- package/dist/mutators/operation/index.js.map +0 -7
- package/dist/mutators/operation/operation.js.map +0 -7
- package/dist/mutators/operation/parameters.js.map +0 -7
- package/dist/mutators/server.js.map +0 -7
- package/dist/mutators/tabs.js.map +0 -7
- package/dist/mutators/tag.js.map +0 -7
- package/dist/mutators/workspace.js.map +0 -7
- package/dist/navigation/get-navigation-options.js.map +0 -7
- package/dist/navigation/helpers/get-openapi-object.js.map +0 -7
- package/dist/navigation/helpers/get-operation-entries.js.map +0 -7
- package/dist/navigation/helpers/get-parent-entry.js.map +0 -7
- package/dist/navigation/helpers/get-tag-entries.js.map +0 -7
- package/dist/navigation/helpers/get-tag.js.map +0 -7
- package/dist/navigation/helpers/get-x-keys.js.map +0 -7
- package/dist/navigation/helpers/traverse-description.js.map +0 -7
- package/dist/navigation/helpers/traverse-document.js.map +0 -7
- package/dist/navigation/helpers/traverse-examples.js.map +0 -7
- package/dist/navigation/helpers/traverse-paths.js.map +0 -7
- package/dist/navigation/helpers/traverse-schemas.js.map +0 -7
- package/dist/navigation/helpers/traverse-tags.js.map +0 -7
- package/dist/navigation/helpers/traverse-webhooks.js.map +0 -7
- package/dist/navigation/helpers/update-order-ids.js.map +0 -7
- package/dist/navigation/helpers/utils.js.map +0 -7
- package/dist/navigation/index.js.map +0 -7
- package/dist/navigation/types.js.map +0 -7
- package/dist/persistence/index.js.map +0 -7
- package/dist/persistence/indexdb.js.map +0 -7
- package/dist/plugins/bundler/helpers.js.map +0 -7
- package/dist/plugins/bundler/index.js.map +0 -7
- package/dist/plugins/client/index.js.map +0 -7
- package/dist/plugins/client/persistence.js.map +0 -7
- package/dist/resolve.js.map +0 -7
- package/dist/schemas/compose.js.map +0 -7
- package/dist/schemas/extensions/document/x-internal.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-environments.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-icon.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-ignore.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-is-dirty.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-original-document-hash.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-registry-meta.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-sdk-installation.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-watch-mode.js.map +0 -7
- package/dist/schemas/extensions/document/x-tags.js.map +0 -7
- package/dist/schemas/extensions/example/x-disabled.js.map +0 -7
- package/dist/schemas/extensions/general/x-scalar-active-environment.js.map +0 -7
- package/dist/schemas/extensions/general/x-scalar-cookies.js.map +0 -7
- package/dist/schemas/extensions/general/x-scalar-order.js.map +0 -7
- package/dist/schemas/extensions/operation/index.js.map +0 -7
- package/dist/schemas/extensions/operation/x-badge.js.map +0 -7
- package/dist/schemas/extensions/operation/x-code-samples.js.map +0 -7
- package/dist/schemas/extensions/operation/x-draft-examples.js.map +0 -7
- package/dist/schemas/extensions/operation/x-post-response.js.map +0 -7
- package/dist/schemas/extensions/operation/x-scalar-disable-parameters.js.map +0 -7
- package/dist/schemas/extensions/operation/x-scalar-selected-content-type.js.map +0 -7
- package/dist/schemas/extensions/operation/x-scalar-stability.js.map +0 -7
- package/dist/schemas/extensions/parameter/x-global.js.map +0 -7
- package/dist/schemas/extensions/schema/x-additional-properties-name.js.map +0 -7
- package/dist/schemas/extensions/schema/x-enum-descriptions.js.map +0 -7
- package/dist/schemas/extensions/schema/x-enum-varnames.js.map +0 -7
- package/dist/schemas/extensions/schema/x-examples.js.map +0 -7
- package/dist/schemas/extensions/schema/x-variable.js.map +0 -7
- package/dist/schemas/extensions/security/index.js.map +0 -7
- package/dist/schemas/extensions/security/x-default-scopes.js.map +0 -7
- package/dist/schemas/extensions/security/x-scalar-credentials-location.js.map +0 -7
- package/dist/schemas/extensions/security/x-scalar-security-body.js.map +0 -7
- package/dist/schemas/extensions/security/x-scalar-security-query.js.map +0 -7
- package/dist/schemas/extensions/security/x-scalar-security-secrets.js.map +0 -7
- package/dist/schemas/extensions/security/x-tokenName.js.map +0 -7
- package/dist/schemas/extensions/security/x-use-pkce.js.map +0 -7
- package/dist/schemas/extensions/server/x-scalar-selected-server.js.map +0 -7
- package/dist/schemas/extensions/tag/index.js.map +0 -7
- package/dist/schemas/extensions/tag/x-display-name.js.map +0 -7
- package/dist/schemas/extensions/tag/x-tag-groups.js.map +0 -7
- package/dist/schemas/extensions/workspace/index.js.map +0 -7
- package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js.map +0 -7
- package/dist/schemas/extensions/workspace/x-scalar-tabs.js.map +0 -7
- package/dist/schemas/extensions.js.map +0 -7
- package/dist/schemas/inmemory-workspace.js.map +0 -7
- package/dist/schemas/navigation.js.map +0 -7
- package/dist/schemas/reference-config/appearance.js.map +0 -7
- package/dist/schemas/reference-config/features.js.map +0 -7
- package/dist/schemas/reference-config/index.js.map +0 -7
- package/dist/schemas/reference-config/meta.js.map +0 -7
- package/dist/schemas/reference-config/routing.js.map +0 -7
- package/dist/schemas/reference-config/settings.js.map +0 -7
- package/dist/schemas/typebox-coerce.js.map +0 -7
- package/dist/schemas/v3.1/strict/callback.js.map +0 -7
- package/dist/schemas/v3.1/strict/components.js.map +0 -7
- package/dist/schemas/v3.1/strict/contact.js.map +0 -7
- package/dist/schemas/v3.1/strict/discriminator.js.map +0 -7
- package/dist/schemas/v3.1/strict/encoding.js.map +0 -7
- package/dist/schemas/v3.1/strict/example.js.map +0 -7
- package/dist/schemas/v3.1/strict/external-documentation.js.map +0 -7
- package/dist/schemas/v3.1/strict/header.js.map +0 -7
- package/dist/schemas/v3.1/strict/info.js.map +0 -7
- package/dist/schemas/v3.1/strict/license.js.map +0 -7
- package/dist/schemas/v3.1/strict/link.js.map +0 -7
- package/dist/schemas/v3.1/strict/media-type.js.map +0 -7
- package/dist/schemas/v3.1/strict/oauth-flow.js.map +0 -7
- package/dist/schemas/v3.1/strict/oauthflows.js.map +0 -7
- package/dist/schemas/v3.1/strict/openapi-document.js.map +0 -7
- package/dist/schemas/v3.1/strict/operation.js.map +0 -7
- package/dist/schemas/v3.1/strict/parameter.js.map +0 -7
- package/dist/schemas/v3.1/strict/path-item.js.map +0 -7
- package/dist/schemas/v3.1/strict/paths.js.map +0 -7
- package/dist/schemas/v3.1/strict/ref-definitions.js.map +0 -7
- package/dist/schemas/v3.1/strict/reference.js.map +0 -7
- package/dist/schemas/v3.1/strict/request-body.js.map +0 -7
- package/dist/schemas/v3.1/strict/response.js.map +0 -7
- package/dist/schemas/v3.1/strict/responses.js.map +0 -7
- package/dist/schemas/v3.1/strict/schema.js.map +0 -7
- package/dist/schemas/v3.1/strict/security-requirement.js.map +0 -7
- package/dist/schemas/v3.1/strict/security-scheme.js.map +0 -7
- package/dist/schemas/v3.1/strict/server-variable.js.map +0 -7
- package/dist/schemas/v3.1/strict/server.js.map +0 -7
- package/dist/schemas/v3.1/strict/tag.js.map +0 -7
- package/dist/schemas/v3.1/strict/type-guards.js.map +0 -7
- package/dist/schemas/v3.1/strict/xml.js.map +0 -7
- package/dist/schemas/workspace-specification/index.js.map +0 -7
- package/dist/schemas/workspace-specification/info.js.map +0 -7
- package/dist/schemas/workspace.js.map +0 -7
- package/dist/schemas.js.map +0 -7
- package/dist/server.js.map +0 -7
- package/dist/workspace-plugin.js.map +0 -7
|
@@ -1,111 +1,123 @@
|
|
|
1
|
-
import { isHttpMethod } from
|
|
2
|
-
import { objectKeys } from
|
|
3
|
-
import { escapeJsonPointer } from
|
|
4
|
-
import { getResolvedRef } from
|
|
5
|
-
import { traverseOperationExamples } from
|
|
6
|
-
import { XScalarStabilityValues } from
|
|
7
|
-
import { getTag } from
|
|
8
|
-
const isDeprecatedOperation = (operation) => {
|
|
9
|
-
|
|
1
|
+
import { isHttpMethod } from '@scalar/helpers/http/is-http-method';
|
|
2
|
+
import { objectKeys } from '@scalar/helpers/object/object-keys';
|
|
3
|
+
import { escapeJsonPointer } from '@scalar/json-magic/helpers/escape-json-pointer';
|
|
4
|
+
import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
|
|
5
|
+
import { traverseOperationExamples } from '../../navigation/helpers/traverse-examples.js';
|
|
6
|
+
import { XScalarStabilityValues } from '../../schemas/extensions/operation/index.js';
|
|
7
|
+
import { getTag } from './get-tag.js';
|
|
8
|
+
export const isDeprecatedOperation = (operation) => {
|
|
9
|
+
return operation.deprecated || operation['x-scalar-stability'] === XScalarStabilityValues.Deprecated;
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Creates a traversed operation entry from an OpenAPI operation object.
|
|
13
|
+
*
|
|
14
|
+
* @param ref - JSON pointer reference to the operation in the OpenAPI document
|
|
15
|
+
* @param operation - The OpenAPI operation object
|
|
16
|
+
* @param method - HTTP method of the operation
|
|
17
|
+
* @param path - API path of the operation, defaults to 'Unknown'
|
|
18
|
+
* @param tag - Tag object associated with the operation
|
|
19
|
+
* @param entitiesMap - Map to store operation IDs and titles for mobile header navigation
|
|
20
|
+
* @param getOperationId - Function to generate unique IDs for operations
|
|
21
|
+
* @returns A traversed operation entry with ID, title, path, method and reference
|
|
22
|
+
*/
|
|
23
|
+
const createOperationEntry = ({ ref, operation, method, path, generateId, parentId, parentTag, }) => {
|
|
24
|
+
const id = generateId({
|
|
25
|
+
type: 'operation',
|
|
26
|
+
operation,
|
|
27
|
+
parentTag,
|
|
28
|
+
method: method,
|
|
29
|
+
path: path,
|
|
30
|
+
parentId: parentId,
|
|
31
|
+
});
|
|
32
|
+
const title = operation.summary?.trim() ? operation.summary : path;
|
|
33
|
+
const isDeprecated = isDeprecatedOperation(operation);
|
|
34
|
+
const examples = traverseOperationExamples(operation).map((example) => ({
|
|
35
|
+
type: 'example',
|
|
36
|
+
id: generateId({
|
|
37
|
+
type: 'example',
|
|
38
|
+
parentId: id,
|
|
39
|
+
name: example,
|
|
40
|
+
}),
|
|
41
|
+
title: example,
|
|
42
|
+
name: example,
|
|
43
|
+
}));
|
|
44
|
+
const entry = {
|
|
45
|
+
id,
|
|
46
|
+
title,
|
|
47
|
+
path,
|
|
48
|
+
method,
|
|
49
|
+
ref,
|
|
50
|
+
type: 'operation',
|
|
51
|
+
isDeprecated,
|
|
52
|
+
children: examples.length ? examples : undefined,
|
|
53
|
+
};
|
|
54
|
+
return entry;
|
|
51
55
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Traverses the paths in an OpenAPI document to build a map of operations organized by tags.
|
|
58
|
+
*
|
|
59
|
+
* This function processes each path and its operations to:
|
|
60
|
+
* - Filter out internal operations (marked with x-internal) and operations to ignore (marked with x-scalar-ignore)
|
|
61
|
+
* - Group operations by their tags
|
|
62
|
+
* - Collect operations without tags to be added at the document level
|
|
63
|
+
* - Generate unique references and IDs for each operation
|
|
64
|
+
*
|
|
65
|
+
* TODO: filter out internal and scalar-ignore tags
|
|
66
|
+
*
|
|
67
|
+
* @param content - The OpenAPI document to traverse
|
|
68
|
+
* @param tagsDict - Dictionary mapping tag names to their OpenAPI tag objects
|
|
69
|
+
* @param entitiesMap - Map to store operation IDs and titles for mobile header navigation
|
|
70
|
+
* @param getOperationId - Function to generate unique IDs for operations
|
|
71
|
+
* @returns Object containing the tagsMap and an array of untagged operations
|
|
72
|
+
*/
|
|
73
|
+
export const traversePaths = ({ document, tagsMap, generateId, documentId, }) => {
|
|
74
|
+
const untaggedOperations = [];
|
|
75
|
+
// Traverse paths
|
|
76
|
+
Object.entries(document.paths ?? {}).forEach(([path, pathItemObject]) => {
|
|
77
|
+
const pathKeys = objectKeys(pathItemObject ?? {}).filter((key) => isHttpMethod(key));
|
|
78
|
+
pathKeys.forEach((method) => {
|
|
79
|
+
const _operation = pathItemObject?.[method];
|
|
80
|
+
const operation = getResolvedRef(_operation);
|
|
81
|
+
if (!operation) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// Skip if the operation is internal or scalar-ignore
|
|
85
|
+
if (operation['x-internal'] || operation['x-scalar-ignore'] || !isHttpMethod(method)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const ref = `#/paths/${escapeJsonPointer(path)}/${method}`;
|
|
89
|
+
// Traverse tags
|
|
90
|
+
if (operation.tags?.length) {
|
|
91
|
+
operation.tags.forEach((tagName) => {
|
|
92
|
+
const { tag, id: tagId } = getTag({
|
|
93
|
+
tagsMap,
|
|
94
|
+
name: tagName,
|
|
95
|
+
documentId,
|
|
96
|
+
generateId,
|
|
97
|
+
});
|
|
98
|
+
tagsMap.get(tagName)?.entries.push(createOperationEntry({
|
|
99
|
+
ref,
|
|
100
|
+
operation,
|
|
101
|
+
method,
|
|
102
|
+
path,
|
|
103
|
+
parentTag: { tag, id: tagId },
|
|
104
|
+
generateId,
|
|
105
|
+
parentId: tagId,
|
|
106
|
+
}));
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
// Collect operations without tags (no parentTag)
|
|
111
|
+
untaggedOperations.push(createOperationEntry({
|
|
112
|
+
ref,
|
|
113
|
+
operation,
|
|
114
|
+
method,
|
|
115
|
+
path,
|
|
116
|
+
generateId,
|
|
117
|
+
parentId: documentId,
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
90
120
|
});
|
|
91
|
-
} else {
|
|
92
|
-
untaggedOperations.push(
|
|
93
|
-
createOperationEntry({
|
|
94
|
-
ref,
|
|
95
|
-
operation,
|
|
96
|
-
method,
|
|
97
|
-
path,
|
|
98
|
-
generateId,
|
|
99
|
-
parentId: documentId
|
|
100
|
-
})
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
121
|
});
|
|
104
|
-
|
|
105
|
-
return { untaggedOperations };
|
|
106
|
-
};
|
|
107
|
-
export {
|
|
108
|
-
isDeprecatedOperation,
|
|
109
|
-
traversePaths
|
|
122
|
+
return { untaggedOperations };
|
|
110
123
|
};
|
|
111
|
-
//# sourceMappingURL=traverse-paths.js.map
|
|
@@ -1,67 +1,68 @@
|
|
|
1
|
-
import { getResolvedRef } from
|
|
2
|
-
import { getTag } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
title
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
|
|
2
|
+
import { getTag } from '../../navigation/helpers/get-tag.js';
|
|
3
|
+
/** Creates a traversed schema entry from an OpenAPI schema object.
|
|
4
|
+
*
|
|
5
|
+
* @param ref - JSON pointer reference to the schema in the OpenAPI document
|
|
6
|
+
* @param name - Name of the schema, defaults to 'Unknown'
|
|
7
|
+
* @param entriesMap - Map to store schema IDs and titles for mobile header navigation
|
|
8
|
+
* @param getModelId - Function to generate unique IDs for schemas
|
|
9
|
+
* @returns A traversed schema entry with ID, title, name and reference
|
|
10
|
+
*/
|
|
11
|
+
const createSchemaEntry = ({ ref, name, generateId, parentTag, _schema, parentId, }) => {
|
|
12
|
+
const id = generateId({ name, type: 'model', parentTag, parentId, schema: _schema });
|
|
13
|
+
const schema = getResolvedRef(_schema);
|
|
14
|
+
// Use schema.title if available, otherwise fall back to name
|
|
15
|
+
// @see https://json-schema.org/draft/2020-12/json-schema-core#section-4.3.5
|
|
16
|
+
const title = (schema && 'title' in schema && schema.title) || name;
|
|
17
|
+
const entry = {
|
|
18
|
+
id,
|
|
19
|
+
title,
|
|
20
|
+
name,
|
|
21
|
+
ref,
|
|
22
|
+
type: 'model',
|
|
23
|
+
};
|
|
24
|
+
return entry;
|
|
22
25
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
/** Traverses the schemas in an OpenAPI document to build an array of model entries.
|
|
27
|
+
*
|
|
28
|
+
* This function processes each schema in components.schemas to:
|
|
29
|
+
* - Filter out internal schemas (marked with x-internal) and schemas to ignore (marked with x-scalar-ignore)
|
|
30
|
+
* - Create model entries with unique references and IDs
|
|
31
|
+
* - Store model IDs and titles for mobile header navigation
|
|
32
|
+
*/
|
|
33
|
+
export const traverseSchemas = ({ document, tagsMap, generateId, documentId, }) => {
|
|
34
|
+
const schemas = document.components?.schemas ?? {};
|
|
35
|
+
const untagged = [];
|
|
36
|
+
// biome-ignore lint/suspicious/useGuardForIn: we do have an if statement after de-ref
|
|
37
|
+
for (const name in schemas) {
|
|
38
|
+
const schema = getResolvedRef(schemas[name]);
|
|
39
|
+
if (schema?.['x-internal'] || schema?.['x-scalar-ignore'] || !Object.hasOwn(schemas, name)) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const ref = `#/components/schemas/${name}`;
|
|
43
|
+
// Add to tags
|
|
44
|
+
if (schema?.['x-tags']) {
|
|
45
|
+
schema['x-tags'].forEach((tagName) => {
|
|
46
|
+
const { tag, id: tagId } = getTag({ tagsMap, name: tagName, documentId, generateId });
|
|
47
|
+
tagsMap.get(tagName)?.entries.push(createSchemaEntry({
|
|
48
|
+
ref,
|
|
49
|
+
name,
|
|
50
|
+
generateId,
|
|
51
|
+
parentTag: { tag, id: tagId },
|
|
52
|
+
parentId: documentId,
|
|
53
|
+
}));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
// Add to untagged
|
|
57
|
+
else {
|
|
58
|
+
untagged.push(createSchemaEntry({
|
|
59
|
+
ref,
|
|
60
|
+
name,
|
|
61
|
+
generateId,
|
|
62
|
+
_schema: getResolvedRef(schemas[name]),
|
|
63
|
+
parentId: documentId,
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
35
66
|
}
|
|
36
|
-
|
|
37
|
-
if (schema?.["x-tags"]) {
|
|
38
|
-
schema["x-tags"].forEach((tagName) => {
|
|
39
|
-
const { tag, id: tagId } = getTag({ tagsMap, name: tagName, documentId, generateId });
|
|
40
|
-
tagsMap.get(tagName)?.entries.push(
|
|
41
|
-
createSchemaEntry({
|
|
42
|
-
ref,
|
|
43
|
-
name,
|
|
44
|
-
generateId,
|
|
45
|
-
parentTag: { tag, id: tagId },
|
|
46
|
-
parentId: documentId
|
|
47
|
-
})
|
|
48
|
-
);
|
|
49
|
-
});
|
|
50
|
-
} else {
|
|
51
|
-
untagged.push(
|
|
52
|
-
createSchemaEntry({
|
|
53
|
-
ref,
|
|
54
|
-
name,
|
|
55
|
-
generateId,
|
|
56
|
-
_schema: getResolvedRef(schemas[name]),
|
|
57
|
-
parentId: documentId
|
|
58
|
-
})
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return untagged;
|
|
63
|
-
};
|
|
64
|
-
export {
|
|
65
|
-
traverseSchemas
|
|
67
|
+
return untagged;
|
|
66
68
|
};
|
|
67
|
-
//# sourceMappingURL=traverse-schemas.js.map
|
|
@@ -1,137 +1,166 @@
|
|
|
1
|
-
import { sortByOrder } from
|
|
2
|
-
import { unpackProxyObject } from
|
|
3
|
-
import { getXKeysFromObject } from
|
|
4
|
-
import { getTag } from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
import { sortByOrder } from '@scalar/object-utils/arrays';
|
|
2
|
+
import { unpackProxyObject } from '../../helpers/unpack-proxy.js';
|
|
3
|
+
import { getXKeysFromObject } from '../../navigation/helpers/get-x-keys.js';
|
|
4
|
+
import { getTag } from './get-tag.js';
|
|
5
|
+
/** Creates a traversed tag entry from an OpenAPI tag object.
|
|
6
|
+
*
|
|
7
|
+
* @param tag - The OpenAPI tag object
|
|
8
|
+
* @param entriesMap - Map to store tag IDs and titles for mobile header navigation
|
|
9
|
+
* @param getTagId - Function to generate unique IDs for tags
|
|
10
|
+
* @param children - Array of child entries (operations, webhooks, etc.)
|
|
11
|
+
* @param isGroup - Whether this tag represents a group of tags
|
|
12
|
+
* @returns A traversed tag entry with ID, title, name and children
|
|
13
|
+
*/
|
|
14
|
+
const createTagEntry = ({ tag, generateId, children, isGroup = false, parentId, }) => {
|
|
15
|
+
const id = generateId({
|
|
16
|
+
type: 'tag',
|
|
17
|
+
tag,
|
|
18
|
+
parentId,
|
|
19
|
+
});
|
|
20
|
+
const title = tag['x-displayName'] ?? tag.name ?? 'Untitled Tag';
|
|
21
|
+
// Update the order of the children based on the items
|
|
22
|
+
// This will ensure that the sort order is always in sync with the items
|
|
23
|
+
tag['x-scalar-order'] = children.map((child) => child.id);
|
|
24
|
+
const entry = {
|
|
25
|
+
id,
|
|
26
|
+
title,
|
|
27
|
+
name: tag.name || title,
|
|
28
|
+
description: tag.description,
|
|
29
|
+
children,
|
|
30
|
+
isGroup,
|
|
31
|
+
isWebhooks: false,
|
|
32
|
+
type: 'tag',
|
|
33
|
+
xKeys: getXKeysFromObject(unpackProxyObject(tag)),
|
|
34
|
+
};
|
|
35
|
+
return entry;
|
|
31
36
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
/** Sorts and processes tags to create a hierarchical structure of tag entries.
|
|
38
|
+
*
|
|
39
|
+
* This function handles:
|
|
40
|
+
* - Sorting tags alphabetically or using a custom sort function
|
|
41
|
+
* - Sorting operations within tags by title, method, or custom function
|
|
42
|
+
* - Filtering out internal and ignored tags
|
|
43
|
+
* - Creating tag entries with their associated operations
|
|
44
|
+
*
|
|
45
|
+
* @param _keys - Array of tag keys to process
|
|
46
|
+
* @param tagsMap - Map of tags and their entries
|
|
47
|
+
* @param tagsDict - Dictionary of OpenAPI tags by name
|
|
48
|
+
* @param titlesMap - Map of titles for the mobile header
|
|
49
|
+
* @param options - Sorting and ID generation options
|
|
50
|
+
* @returns Array of processed and sorted tag entries
|
|
51
|
+
*/
|
|
52
|
+
/** Sorts tags and returns entries */
|
|
53
|
+
const getSortedTagEntries = ({ _keys, tagsMap, options: { tagsSorter, operationsSorter, generateId }, documentId, sortOrder, }) => {
|
|
54
|
+
/**
|
|
55
|
+
* Process each tag and its entries:
|
|
56
|
+
* - Skip internal and ignored tags
|
|
57
|
+
* - Sort operations within tags
|
|
58
|
+
* - Create tag entries with sorted operations
|
|
59
|
+
*/
|
|
60
|
+
const entries = _keys.flatMap((key) => {
|
|
61
|
+
const { tag, entries } = getTag({ tagsMap, name: key, documentId, generateId });
|
|
62
|
+
// Skip if the tag is internal or scalar-ignore
|
|
63
|
+
if (tag['x-internal'] || tag['x-scalar-ignore']) {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
const sortOrder = tag['x-scalar-order'];
|
|
67
|
+
if (sortOrder === undefined) {
|
|
68
|
+
// Alpha sort
|
|
69
|
+
if (operationsSorter === 'alpha') {
|
|
70
|
+
entries.sort((a, b) => (a.type === 'operation' && b.type === 'operation' ? a.title.localeCompare(b.title) : 0));
|
|
71
|
+
}
|
|
72
|
+
// Method sort
|
|
73
|
+
else if (operationsSorter === 'method') {
|
|
74
|
+
entries.sort((a, b) => a.type === 'operation' && b.type === 'operation' ? a.method.localeCompare(b.method) : 0);
|
|
75
|
+
}
|
|
76
|
+
// Custom sort
|
|
77
|
+
else if (typeof operationsSorter === 'function') {
|
|
78
|
+
entries.sort((a, b) => {
|
|
79
|
+
// Guard against tags
|
|
80
|
+
if (!(a.type === 'operation' || a.type === 'webhook') || !(b.type === 'operation' || b.type === 'webhook')) {
|
|
81
|
+
return 0;
|
|
82
|
+
}
|
|
83
|
+
// Handle webhooks as well as operations
|
|
84
|
+
const pathA = a.type === 'operation' ? a.path : a.name;
|
|
85
|
+
const pathB = b.type === 'operation' ? b.path : b.name;
|
|
86
|
+
return operationsSorter({ method: a.method, path: pathA, ref: a.ref, httpVerb: a.method }, { method: b.method, path: pathB, ref: b.ref, httpVerb: b.method });
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return createTagEntry({
|
|
91
|
+
tag,
|
|
92
|
+
generateId,
|
|
93
|
+
children: sortOrder ? sortByOrder(entries, sortOrder, 'id') : entries,
|
|
94
|
+
parentId: documentId,
|
|
95
|
+
isGroup: false,
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
// If a custom 'x-scalar-order' is specified in the tag, sort the entries by this order using sortByOrder
|
|
99
|
+
if (sortOrder) {
|
|
100
|
+
return sortByOrder(entries, sortOrder, 'id');
|
|
43
101
|
}
|
|
44
|
-
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const pathA = a.type === "operation" ? a.path : a.name;
|
|
58
|
-
const pathB = b.type === "operation" ? b.path : b.name;
|
|
59
|
-
return operationsSorter(
|
|
60
|
-
{ method: a.method, path: pathA, ref: a.ref, httpVerb: a.method },
|
|
61
|
-
{ method: b.method, path: pathB, ref: b.ref, httpVerb: b.method }
|
|
62
|
-
);
|
|
102
|
+
// Alpha sort
|
|
103
|
+
if (tagsSorter === 'alpha') {
|
|
104
|
+
entries.sort((a, b) => {
|
|
105
|
+
const nameA = getTag({
|
|
106
|
+
tagsMap,
|
|
107
|
+
name: a.title,
|
|
108
|
+
documentId,
|
|
109
|
+
generateId,
|
|
110
|
+
}).tag['x-displayName'] ||
|
|
111
|
+
a.title ||
|
|
112
|
+
'Untitled Tag';
|
|
113
|
+
const nameB = getTag({ tagsMap, name: b.title, documentId, generateId }).tag['x-displayName'] || b.title || 'Untitled Tag';
|
|
114
|
+
return nameA.localeCompare(nameB);
|
|
63
115
|
});
|
|
64
|
-
}
|
|
65
116
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
isGroup: false
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
if (sortOrder) {
|
|
75
|
-
return sortByOrder(entries, sortOrder, "id");
|
|
76
|
-
}
|
|
77
|
-
if (tagsSorter === "alpha") {
|
|
78
|
-
entries.sort((a, b) => {
|
|
79
|
-
const nameA = getTag({
|
|
80
|
-
tagsMap,
|
|
81
|
-
name: a.title,
|
|
82
|
-
documentId,
|
|
83
|
-
generateId
|
|
84
|
-
}).tag["x-displayName"] || a.title || "Untitled Tag";
|
|
85
|
-
const nameB = getTag({ tagsMap, name: b.title, documentId, generateId }).tag["x-displayName"] || b.title || "Untitled Tag";
|
|
86
|
-
return nameA.localeCompare(nameB);
|
|
87
|
-
});
|
|
88
|
-
} else if (typeof tagsSorter === "function") {
|
|
89
|
-
entries.sort(
|
|
90
|
-
(a, b) => tagsSorter(
|
|
91
|
-
getTag({ tagsMap, name: a.name, documentId, generateId }).tag,
|
|
92
|
-
getTag({ tagsMap, name: b.name, documentId, generateId }).tag
|
|
93
|
-
)
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
return entries;
|
|
117
|
+
// Custom sort
|
|
118
|
+
else if (typeof tagsSorter === 'function') {
|
|
119
|
+
entries.sort((a, b) => tagsSorter(getTag({ tagsMap, name: a.name, documentId, generateId }).tag, getTag({ tagsMap, name: b.name, documentId, generateId }).tag));
|
|
120
|
+
}
|
|
121
|
+
return entries;
|
|
97
122
|
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Traverses the tags map to create navigation entries, handling both grouped and ungrouped tags.
|
|
125
|
+
*
|
|
126
|
+
* This function processes the OpenAPI document's tags to:
|
|
127
|
+
* - Handle tag groups if specified via x-tagGroups
|
|
128
|
+
* - Sort tags and their operations according to provided sorters
|
|
129
|
+
* - Create navigation entries for each tag or tag group
|
|
130
|
+
*/
|
|
131
|
+
export const traverseTags = ({ document, tagsMap, documentId, options: { generateId, tagsSorter, operationsSorter }, }) => {
|
|
132
|
+
// x-tagGroups
|
|
133
|
+
if (document['x-tagGroups']) {
|
|
134
|
+
const tagGroups = document['x-tagGroups'];
|
|
135
|
+
return tagGroups.flatMap((tagGroup) => {
|
|
136
|
+
const entries = getSortedTagEntries({
|
|
137
|
+
_keys: tagGroup.tags,
|
|
138
|
+
tagsMap,
|
|
139
|
+
options: { tagsSorter, operationsSorter, generateId },
|
|
140
|
+
documentId: documentId,
|
|
141
|
+
sortOrder: tagGroup['x-scalar-order'],
|
|
142
|
+
});
|
|
143
|
+
// Try to update the sort order of the tag group to keep it in sync with the items
|
|
144
|
+
tagGroup['x-scalar-order'] = entries.map((entry) => entry.id);
|
|
145
|
+
return entries.length
|
|
146
|
+
? createTagEntry({
|
|
147
|
+
tag: tagGroup,
|
|
148
|
+
generateId,
|
|
149
|
+
children: entries,
|
|
150
|
+
parentId: documentId,
|
|
151
|
+
isGroup: true,
|
|
152
|
+
})
|
|
153
|
+
: [];
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
// Ungrouped regular tags
|
|
157
|
+
const keys = Array.from(tagsMap.keys());
|
|
158
|
+
const tags = getSortedTagEntries({
|
|
159
|
+
_keys: keys,
|
|
109
160
|
tagsMap,
|
|
110
|
-
options: { tagsSorter, operationsSorter
|
|
111
|
-
documentId,
|
|
112
|
-
sortOrder:
|
|
113
|
-
});
|
|
114
|
-
tagGroup["x-scalar-order"] = entries.map((entry) => entry.id);
|
|
115
|
-
return entries.length ? createTagEntry({
|
|
116
|
-
tag: tagGroup,
|
|
117
|
-
generateId,
|
|
118
|
-
children: entries,
|
|
119
|
-
parentId: documentId,
|
|
120
|
-
isGroup: true
|
|
121
|
-
}) : [];
|
|
161
|
+
options: { generateId, tagsSorter, operationsSorter },
|
|
162
|
+
documentId: documentId,
|
|
163
|
+
sortOrder: document['x-scalar-order'],
|
|
122
164
|
});
|
|
123
|
-
|
|
124
|
-
const keys = Array.from(tagsMap.keys());
|
|
125
|
-
const tags = getSortedTagEntries({
|
|
126
|
-
_keys: keys,
|
|
127
|
-
tagsMap,
|
|
128
|
-
options: { generateId, tagsSorter, operationsSorter },
|
|
129
|
-
documentId,
|
|
130
|
-
sortOrder: document["x-scalar-order"]
|
|
131
|
-
});
|
|
132
|
-
return tags;
|
|
133
|
-
};
|
|
134
|
-
export {
|
|
135
|
-
traverseTags
|
|
165
|
+
return tags;
|
|
136
166
|
};
|
|
137
|
-
//# sourceMappingURL=traverse-tags.js.map
|