@scalar/workspace-store 0.40.2 → 0.40.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 +7 -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.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.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.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.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.js +126 -210
- package/dist/schemas/v3.1/strict/operation.js +16 -43
- package/dist/schemas/v3.1/strict/parameter.js +27 -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.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,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Utility function to extract all keys starting with 'x-' (OpenAPI extensions) from an object.
|
|
3
|
+
*
|
|
4
|
+
* @param object - The object from which to extract extension keys.
|
|
5
|
+
* @returns An object containing only the entries whose keys start with 'x-'.
|
|
6
|
+
*/
|
|
7
|
+
export const getXKeysFromObject = (object) => {
|
|
8
|
+
if (!object) {
|
|
9
|
+
// Return an empty object if input is undefined or null
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
// Filter and return only the entries whose keys start with 'x-'
|
|
13
|
+
return Object.fromEntries(Object.entries(object).filter(([key]) => key.startsWith('x-')));
|
|
6
14
|
};
|
|
7
|
-
export {
|
|
8
|
-
getXKeysFromObject
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=get-x-keys.js.map
|
|
@@ -1,78 +1,96 @@
|
|
|
1
|
-
import { getHeadingsFromMarkdown, getLowestHeadingLevel } from
|
|
1
|
+
import { getHeadingsFromMarkdown, getLowestHeadingLevel } from '../../navigation/helpers/utils.js';
|
|
2
2
|
const DEFAULT_DESCRIPTION_ENTRY = {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
TITLE: 'Introduction',
|
|
4
|
+
SLUG: 'introduction',
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
depth: heading.depth,
|
|
29
|
-
slug: heading.slug,
|
|
30
|
-
parentId,
|
|
31
|
-
info,
|
|
32
|
-
value: heading.value
|
|
33
|
-
});
|
|
34
|
-
const entry = {
|
|
35
|
-
id,
|
|
36
|
-
title: heading.value,
|
|
37
|
-
type: "text"
|
|
38
|
-
};
|
|
39
|
-
entries.push(entry);
|
|
40
|
-
descriptionHeadingsEntry = entry;
|
|
41
|
-
}
|
|
42
|
-
for (const heading of headings) {
|
|
43
|
-
if (heading.depth !== lowestLevel && heading.depth !== lowestLevel + 1) {
|
|
44
|
-
continue;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a hierarchical navigation structure from markdown headings in an OpenAPI description.
|
|
8
|
+
*
|
|
9
|
+
* The function processes markdown headings to create a two-level navigation tree:
|
|
10
|
+
* - Level 1: Main sections (based on the lowest heading level found)
|
|
11
|
+
* - Level 2: Subsections (one level deeper than the main sections)
|
|
12
|
+
*
|
|
13
|
+
* If the description starts with content rather than a heading, an "Introduction" section
|
|
14
|
+
* is automatically added as the first entry.
|
|
15
|
+
*
|
|
16
|
+
* @param description - The markdown description text to process
|
|
17
|
+
* @param generateId - Function to generate unique IDs for headings
|
|
18
|
+
* @param parentId - The ID of the parent entry
|
|
19
|
+
* @param info - OpenAPI Info Object
|
|
20
|
+
*
|
|
21
|
+
* @returns Array of TraversedDescription entries with their hierarchy
|
|
22
|
+
*/
|
|
23
|
+
export const traverseDescription = ({ generateId, parentId, info, }) => {
|
|
24
|
+
const description = info.description?.trim();
|
|
25
|
+
// No description, return empty array
|
|
26
|
+
if (!description) {
|
|
27
|
+
return [];
|
|
45
28
|
}
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
29
|
+
const headings = getHeadingsFromMarkdown(description);
|
|
30
|
+
const lowestLevel = getLowestHeadingLevel(headings);
|
|
31
|
+
const entries = [];
|
|
32
|
+
let descriptionHeadingsEntry = null;
|
|
33
|
+
let currentParent = null;
|
|
34
|
+
// Add "Introduction" as the first heading
|
|
35
|
+
if (!description.startsWith('#')) {
|
|
36
|
+
const heading = {
|
|
37
|
+
depth: 1,
|
|
38
|
+
value: DEFAULT_DESCRIPTION_ENTRY.TITLE,
|
|
39
|
+
slug: DEFAULT_DESCRIPTION_ENTRY.SLUG,
|
|
40
|
+
};
|
|
41
|
+
const id = generateId({
|
|
42
|
+
type: 'text',
|
|
43
|
+
depth: heading.depth,
|
|
44
|
+
slug: heading.slug,
|
|
45
|
+
parentId: parentId,
|
|
46
|
+
info,
|
|
47
|
+
value: heading.value,
|
|
48
|
+
});
|
|
49
|
+
const entry = {
|
|
50
|
+
id,
|
|
51
|
+
title: heading.value,
|
|
52
|
+
type: 'text',
|
|
53
|
+
};
|
|
54
|
+
// Push to entries
|
|
66
55
|
entries.push(entry);
|
|
67
|
-
|
|
68
|
-
currentParent = entry;
|
|
69
|
-
} else if (currentParent) {
|
|
70
|
-
currentParent.children?.push(entry);
|
|
56
|
+
descriptionHeadingsEntry = entry;
|
|
71
57
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
58
|
+
// Go through each heading
|
|
59
|
+
for (const heading of headings) {
|
|
60
|
+
// Skip if not a main or sub heading
|
|
61
|
+
if (heading.depth !== lowestLevel && heading.depth !== lowestLevel + 1) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const entry = {
|
|
65
|
+
id: generateId({
|
|
66
|
+
type: 'text',
|
|
67
|
+
depth: heading.depth,
|
|
68
|
+
slug: heading.slug,
|
|
69
|
+
parentId: parentId,
|
|
70
|
+
info: info,
|
|
71
|
+
value: heading.value,
|
|
72
|
+
}),
|
|
73
|
+
title: heading.value,
|
|
74
|
+
type: 'text',
|
|
75
|
+
};
|
|
76
|
+
if (heading.depth === lowestLevel) {
|
|
77
|
+
entry.children = [];
|
|
78
|
+
// Add to description headings to the 'Introduction' entry
|
|
79
|
+
if (descriptionHeadingsEntry) {
|
|
80
|
+
if (!descriptionHeadingsEntry.children) {
|
|
81
|
+
descriptionHeadingsEntry.children = [];
|
|
82
|
+
}
|
|
83
|
+
descriptionHeadingsEntry.children.push(entry);
|
|
84
|
+
}
|
|
85
|
+
// If no 'Introduction' entry, add to entries
|
|
86
|
+
else {
|
|
87
|
+
entries.push(entry);
|
|
88
|
+
}
|
|
89
|
+
currentParent = entry;
|
|
90
|
+
}
|
|
91
|
+
else if (currentParent) {
|
|
92
|
+
currentParent.children?.push(entry);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return entries;
|
|
77
96
|
};
|
|
78
|
-
//# sourceMappingURL=traverse-description.js.map
|
|
@@ -1,102 +1,115 @@
|
|
|
1
|
-
import { unpackProxyObject } from
|
|
2
|
-
import { getNavigationOptions } from
|
|
3
|
-
import { traverseDescription } from
|
|
4
|
-
import { traversePaths } from
|
|
5
|
-
import { traverseSchemas } from
|
|
6
|
-
import { traverseTags } from
|
|
7
|
-
import { traverseWebhooks } from
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
parentId: documentId,
|
|
24
|
-
info: document.info
|
|
25
|
-
});
|
|
26
|
-
const { untaggedOperations } = traversePaths({ document, tagsMap, generateId, documentId });
|
|
27
|
-
const untaggedWebhooksParentId = generateId({
|
|
28
|
-
type: "webhook",
|
|
29
|
-
name: "",
|
|
30
|
-
parentId: documentId
|
|
31
|
-
});
|
|
32
|
-
const untaggedWebhooks = traverseWebhooks({
|
|
33
|
-
document,
|
|
34
|
-
generateId,
|
|
35
|
-
tagsMap,
|
|
36
|
-
untaggedWebhooksParentId,
|
|
37
|
-
documentId
|
|
38
|
-
});
|
|
39
|
-
const tagsEntries = traverseTags({
|
|
40
|
-
document,
|
|
41
|
-
tagsMap,
|
|
42
|
-
documentId,
|
|
43
|
-
options: { tagsSorter, operationsSorter, generateId }
|
|
44
|
-
});
|
|
45
|
-
entries.push(...tagsEntries);
|
|
46
|
-
entries.push(...untaggedOperations);
|
|
47
|
-
if (untaggedWebhooks.length) {
|
|
48
|
-
entries.push({
|
|
49
|
-
type: "tag",
|
|
50
|
-
id: untaggedWebhooksParentId,
|
|
51
|
-
title: "Webhooks",
|
|
52
|
-
name: "Webhooks",
|
|
53
|
-
children: untaggedWebhooks,
|
|
54
|
-
isGroup: false,
|
|
55
|
-
isWebhooks: true
|
|
1
|
+
import { unpackProxyObject } from '../../helpers/unpack-proxy.js';
|
|
2
|
+
import { getNavigationOptions } from '../../navigation/get-navigation-options.js';
|
|
3
|
+
import { traverseDescription } from './traverse-description.js';
|
|
4
|
+
import { traversePaths } from './traverse-paths.js';
|
|
5
|
+
import { traverseSchemas } from './traverse-schemas.js';
|
|
6
|
+
import { traverseTags } from './traverse-tags.js';
|
|
7
|
+
import { traverseWebhooks } from './traverse-webhooks.js';
|
|
8
|
+
/**
|
|
9
|
+
* Traverses an OpenAPI Document to generate navigation structure and metadata.
|
|
10
|
+
*
|
|
11
|
+
* This function processes the OpenAPI document to create:
|
|
12
|
+
* - A hierarchical navigation structure for the sidebar
|
|
13
|
+
* - A mapping of IDs to titles for mobile header navigation
|
|
14
|
+
* - Tag-based organization of operations and webhooks
|
|
15
|
+
* - Optional schema/model documentation
|
|
16
|
+
*/
|
|
17
|
+
export const traverseDocument = (documentName, document, options) => {
|
|
18
|
+
const { hideModels, tagsSorter, operationsSorter, generateId } = getNavigationOptions(documentName, options);
|
|
19
|
+
const documentId = generateId({
|
|
20
|
+
type: 'document',
|
|
21
|
+
info: document.info,
|
|
22
|
+
name: documentName,
|
|
56
23
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
24
|
+
/** Map of tags and their entries */
|
|
25
|
+
const tagsMap = new Map(document.tags?.map((tag) => [
|
|
26
|
+
tag.name ?? 'Untitled Tag',
|
|
27
|
+
{ id: generateId({ type: 'tag', tag, parentId: documentId }), parentId: documentId, tag, entries: [] },
|
|
28
|
+
]) ?? []);
|
|
29
|
+
/** Generate entries for the document info description field */
|
|
30
|
+
const entries = traverseDescription({
|
|
31
|
+
generateId,
|
|
32
|
+
parentId: documentId,
|
|
33
|
+
info: document.info,
|
|
64
34
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}),
|
|
72
|
-
title: "Models",
|
|
73
|
-
name: "Models",
|
|
74
|
-
children: untaggedModels
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
const sortOrder = document["x-scalar-order"];
|
|
79
|
-
if (sortOrder) {
|
|
80
|
-
entries.sort((a, b) => {
|
|
81
|
-
const indexA = sortOrder.indexOf(a.id);
|
|
82
|
-
const indexB = sortOrder.indexOf(b.id);
|
|
83
|
-
const safeIndexA = indexA === -1 ? Number.POSITIVE_INFINITY : indexA;
|
|
84
|
-
const safeIndexB = indexB === -1 ? Number.POSITIVE_INFINITY : indexB;
|
|
85
|
-
return safeIndexA - safeIndexB;
|
|
35
|
+
/** Traverse all the document path */
|
|
36
|
+
const { untaggedOperations } = traversePaths({ document, tagsMap, generateId, documentId });
|
|
37
|
+
const untaggedWebhooksParentId = generateId({
|
|
38
|
+
type: 'webhook',
|
|
39
|
+
name: '',
|
|
40
|
+
parentId: documentId,
|
|
86
41
|
});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
42
|
+
const untaggedWebhooks = traverseWebhooks({
|
|
43
|
+
document,
|
|
44
|
+
generateId,
|
|
45
|
+
tagsMap,
|
|
46
|
+
untaggedWebhooksParentId,
|
|
47
|
+
documentId,
|
|
48
|
+
});
|
|
49
|
+
const tagsEntries = traverseTags({
|
|
50
|
+
document,
|
|
51
|
+
tagsMap,
|
|
52
|
+
documentId,
|
|
53
|
+
options: { tagsSorter, operationsSorter, generateId },
|
|
54
|
+
});
|
|
55
|
+
// Add tagged operations, webhooks and tagGroups
|
|
56
|
+
entries.push(...tagsEntries);
|
|
57
|
+
// Add untagged operations
|
|
58
|
+
entries.push(...untaggedOperations);
|
|
59
|
+
// Add untagged webhooks
|
|
60
|
+
if (untaggedWebhooks.length) {
|
|
61
|
+
entries.push({
|
|
62
|
+
type: 'tag',
|
|
63
|
+
id: untaggedWebhooksParentId,
|
|
64
|
+
title: 'Webhooks',
|
|
65
|
+
name: 'Webhooks',
|
|
66
|
+
children: untaggedWebhooks,
|
|
67
|
+
isGroup: false,
|
|
68
|
+
isWebhooks: true,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
// Add models if they are not hidden
|
|
72
|
+
if (!hideModels && document.components?.schemas) {
|
|
73
|
+
const untaggedModels = traverseSchemas({
|
|
74
|
+
documentId,
|
|
75
|
+
document,
|
|
76
|
+
generateId,
|
|
77
|
+
tagsMap,
|
|
78
|
+
});
|
|
79
|
+
if (untaggedModels.length) {
|
|
80
|
+
entries.push({
|
|
81
|
+
type: 'models',
|
|
82
|
+
id: generateId({
|
|
83
|
+
type: 'model',
|
|
84
|
+
parentId: documentId,
|
|
85
|
+
}),
|
|
86
|
+
title: 'Models',
|
|
87
|
+
name: 'Models',
|
|
88
|
+
children: untaggedModels,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const sortOrder = document['x-scalar-order'];
|
|
93
|
+
// Try to sort the entries using the x-scalar-order
|
|
94
|
+
if (sortOrder) {
|
|
95
|
+
entries.sort((a, b) => {
|
|
96
|
+
const indexA = sortOrder.indexOf(a.id);
|
|
97
|
+
const indexB = sortOrder.indexOf(b.id);
|
|
98
|
+
// If an id is not found, treat it as "infinity" so those items go last.
|
|
99
|
+
const safeIndexA = indexA === -1 ? Number.POSITIVE_INFINITY : indexA;
|
|
100
|
+
const safeIndexB = indexB === -1 ? Number.POSITIVE_INFINITY : indexB;
|
|
101
|
+
return safeIndexA - safeIndexB;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
// Now update the sort order of the entries
|
|
105
|
+
document['x-scalar-order'] = unpackProxyObject(entries.map((entry) => entry.id));
|
|
106
|
+
const documentTitle = document.info?.title?.trim() || 'Untitled Document';
|
|
107
|
+
return {
|
|
108
|
+
id: documentId,
|
|
109
|
+
type: 'document',
|
|
110
|
+
title: documentTitle,
|
|
111
|
+
name: documentName,
|
|
112
|
+
children: entries,
|
|
113
|
+
icon: document['x-scalar-icon'],
|
|
114
|
+
};
|
|
101
115
|
};
|
|
102
|
-
//# sourceMappingURL=traverse-document.js.map
|
|
@@ -1,34 +1,38 @@
|
|
|
1
|
-
import { getResolvedRef } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Object.keys(mediaType.examples ?? {}).forEach((key) => {
|
|
18
|
-
examples.add(key);
|
|
19
|
-
});
|
|
1
|
+
import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
|
|
2
|
+
/**
|
|
3
|
+
* Traverse the OpenAPI operation object and extract all example values.
|
|
4
|
+
*
|
|
5
|
+
* @param operation - The OpenAPI operation object to extract examples from
|
|
6
|
+
*/
|
|
7
|
+
export const traverseOperationExamples = (operation) => {
|
|
8
|
+
// Add all examples from draft examples
|
|
9
|
+
const examples = new Set(operation['x-draft-examples'] ?? []);
|
|
10
|
+
// Add all examples from request bodies
|
|
11
|
+
if (operation.requestBody) {
|
|
12
|
+
const requestBody = getResolvedRef(operation.requestBody);
|
|
13
|
+
Object.values(requestBody.content ?? {}).forEach((mediaType) => {
|
|
14
|
+
Object.keys(mediaType.examples ?? {}).forEach((key) => {
|
|
15
|
+
examples.add(key);
|
|
16
|
+
});
|
|
20
17
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
}
|
|
19
|
+
// Add all examples from parameters
|
|
20
|
+
if (operation.parameters) {
|
|
21
|
+
operation.parameters.forEach((_parameter) => {
|
|
22
|
+
const parameter = getResolvedRef(_parameter) ?? {};
|
|
23
|
+
if ('content' in parameter && parameter.content) {
|
|
24
|
+
Object.values(parameter.content).forEach((mediaType) => {
|
|
25
|
+
Object.keys(mediaType.examples ?? {}).forEach((key) => {
|
|
26
|
+
examples.add(key);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if ('examples' in parameter && parameter.examples) {
|
|
31
|
+
Object.keys(parameter.examples ?? {}).forEach((key) => {
|
|
32
|
+
examples.add(key);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
25
35
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
return Array.from(examples);
|
|
36
|
+
}
|
|
37
|
+
return Array.from(examples);
|
|
30
38
|
};
|
|
31
|
-
export {
|
|
32
|
-
traverseOperationExamples
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=traverse-examples.js.map
|