@scalar/workspace-store 0.11.0 → 0.14.0
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 +71 -0
- package/README.md +60 -7
- package/dist/client.d.ts +253 -32
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +181 -279
- package/dist/client.js.map +2 -2
- package/dist/helpers/apply-selective-updates.d.ts +2 -2
- package/dist/helpers/apply-selective-updates.d.ts.map +1 -1
- package/dist/helpers/apply-selective-updates.js +2 -2
- package/dist/helpers/apply-selective-updates.js.map +2 -2
- package/dist/helpers/deep-clone.d.ts +21 -0
- package/dist/helpers/deep-clone.d.ts.map +1 -0
- package/dist/helpers/deep-clone.js +18 -0
- package/dist/helpers/deep-clone.js.map +7 -0
- package/dist/helpers/get-resolved-ref.d.ts +19 -0
- package/dist/helpers/get-resolved-ref.d.ts.map +1 -0
- package/dist/helpers/get-resolved-ref.js +13 -0
- package/dist/helpers/get-resolved-ref.js.map +7 -0
- package/dist/helpers/merge-object.d.ts +9 -1
- package/dist/helpers/merge-object.d.ts.map +1 -1
- package/dist/helpers/merge-object.js +10 -2
- package/dist/helpers/merge-object.js.map +2 -2
- package/dist/helpers/overrides-proxy.d.ts +43 -1
- package/dist/helpers/overrides-proxy.d.ts.map +1 -1
- package/dist/helpers/overrides-proxy.js +2 -2
- package/dist/helpers/overrides-proxy.js.map +2 -2
- package/dist/mutators/helpers.d.ts +2 -34830
- package/dist/mutators/helpers.d.ts.map +1 -1
- package/dist/mutators/helpers.js.map +2 -2
- package/dist/mutators/request-example.d.ts.map +1 -1
- package/dist/mutators/request-example.js +4 -7
- package/dist/mutators/request-example.js.map +2 -2
- package/dist/navigation/helpers/traverse-document.js +2 -2
- package/dist/navigation/helpers/traverse-document.js.map +2 -2
- package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-paths.js +8 -5
- package/dist/navigation/helpers/traverse-paths.js.map +2 -2
- package/dist/navigation/helpers/traverse-schemas.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-schemas.js +8 -5
- package/dist/navigation/helpers/traverse-schemas.js.map +2 -2
- package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-webhooks.js +9 -5
- package/dist/navigation/helpers/traverse-webhooks.js.map +2 -2
- package/dist/navigation/types.d.ts +3 -3
- package/dist/navigation/types.d.ts.map +1 -1
- package/dist/plugins.d.ts +93 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +107 -0
- package/dist/plugins.js.map +7 -0
- package/dist/schemas/extensions/document/x-internal.d.ts +4 -0
- package/dist/schemas/extensions/document/x-internal.d.ts.map +1 -0
- package/dist/schemas/extensions/document/x-internal.js +8 -0
- package/dist/schemas/extensions/document/x-internal.js.map +7 -0
- package/dist/schemas/extensions/document/x-scalar-icon.d.ts +4 -0
- package/dist/schemas/extensions/document/x-scalar-icon.d.ts.map +1 -0
- package/dist/schemas/extensions/document/x-scalar-icon.js +8 -0
- package/dist/schemas/extensions/document/x-scalar-icon.js.map +7 -0
- package/dist/schemas/extensions/document/x-scalar-ignore.d.ts +4 -0
- package/dist/schemas/extensions/document/x-scalar-ignore.d.ts.map +1 -0
- package/dist/schemas/extensions/document/x-scalar-ignore.js +8 -0
- package/dist/schemas/extensions/document/x-scalar-ignore.js.map +7 -0
- package/dist/schemas/extensions/document/x-scalar-sdk-installation.d.ts +8 -0
- package/dist/schemas/extensions/document/x-scalar-sdk-installation.d.ts.map +1 -0
- package/dist/schemas/extensions/document/x-scalar-sdk-installation.js +16 -0
- package/dist/schemas/extensions/document/x-scalar-sdk-installation.js.map +7 -0
- package/dist/schemas/extensions/operation/x-badge.d.ts +58 -0
- package/dist/schemas/extensions/operation/x-badge.d.ts.map +1 -0
- package/dist/schemas/extensions/operation/x-badge.js +41 -0
- package/dist/schemas/extensions/operation/x-badge.js.map +7 -0
- package/dist/schemas/extensions/operation/x-code-samples.d.ts +23 -0
- package/dist/schemas/extensions/operation/x-code-samples.d.ts.map +1 -0
- package/dist/schemas/extensions/operation/x-code-samples.js +16 -0
- package/dist/schemas/extensions/operation/x-code-samples.js.map +7 -0
- package/dist/schemas/extensions/operation/x-post-response.d.ts +19 -0
- package/dist/schemas/extensions/operation/x-post-response.d.ts.map +1 -0
- package/dist/schemas/extensions/operation/x-post-response.js +8 -0
- package/dist/schemas/extensions/operation/x-post-response.js.map +7 -0
- package/dist/schemas/extensions/operation/x-scalar-stability.d.ts +18 -0
- package/dist/schemas/extensions/operation/x-scalar-stability.d.ts.map +1 -0
- package/dist/schemas/extensions/operation/x-scalar-stability.js +16 -0
- package/dist/schemas/extensions/operation/x-scalar-stability.js.map +7 -0
- package/dist/schemas/extensions/schema/x-additional-properties-name.d.ts +11 -0
- package/dist/schemas/extensions/schema/x-additional-properties-name.d.ts.map +1 -0
- package/dist/schemas/extensions/schema/x-additional-properties-name.js +8 -0
- package/dist/schemas/extensions/schema/x-additional-properties-name.js.map +7 -0
- package/dist/schemas/extensions/schema/x-enum-descriptions.d.ts +17 -0
- package/dist/schemas/extensions/schema/x-enum-descriptions.d.ts.map +1 -0
- package/dist/schemas/extensions/schema/x-enum-descriptions.js +8 -0
- package/dist/schemas/extensions/schema/x-enum-descriptions.js.map +7 -0
- package/dist/schemas/extensions/schema/x-variable.d.ts +4 -0
- package/dist/schemas/extensions/schema/x-variable.d.ts.map +1 -0
- package/dist/schemas/extensions/schema/x-variable.js +8 -0
- package/dist/schemas/extensions/schema/x-variable.js.map +7 -0
- package/dist/schemas/extensions/security/x-scalar-credentials-location.d.ts +17 -0
- package/dist/schemas/extensions/security/x-scalar-credentials-location.d.ts.map +1 -0
- package/dist/schemas/extensions/security/x-scalar-credentials-location.js +8 -0
- package/dist/schemas/extensions/security/x-scalar-credentials-location.js.map +7 -0
- package/dist/schemas/extensions/security/x-scalar-redirect-uri.d.ts +4 -0
- package/dist/schemas/extensions/security/x-scalar-redirect-uri.d.ts.map +1 -0
- package/dist/schemas/extensions/security/x-scalar-redirect-uri.js +8 -0
- package/dist/schemas/extensions/security/x-scalar-redirect-uri.js.map +7 -0
- package/dist/schemas/extensions/security/x-scalar-security-body.d.ts +15 -0
- package/dist/schemas/extensions/security/x-scalar-security-body.d.ts.map +1 -0
- package/dist/schemas/extensions/security/x-scalar-security-body.js +8 -0
- package/dist/schemas/extensions/security/x-scalar-security-body.js.map +7 -0
- package/dist/schemas/extensions/security/x-scalar-security-query.d.ts +15 -0
- package/dist/schemas/extensions/security/x-scalar-security-query.d.ts.map +1 -0
- package/dist/schemas/extensions/security/x-scalar-security-query.js +8 -0
- package/dist/schemas/extensions/security/x-scalar-security-query.js.map +7 -0
- package/dist/schemas/extensions/security/x-scalar-security-secrets.d.ts +18 -0
- package/dist/schemas/extensions/security/x-scalar-security-secrets.d.ts.map +1 -0
- package/dist/schemas/extensions/security/x-scalar-security-secrets.js +13 -0
- package/dist/schemas/extensions/security/x-scalar-security-secrets.js.map +7 -0
- package/dist/schemas/extensions/security/x-tokenName.d.ts +12 -0
- package/dist/schemas/extensions/security/x-tokenName.d.ts.map +1 -0
- package/dist/schemas/extensions/security/x-tokenName.js +8 -0
- package/dist/schemas/extensions/security/x-tokenName.js.map +7 -0
- package/dist/schemas/extensions/security/x-use-pkce.d.ts +7 -0
- package/dist/schemas/extensions/security/x-use-pkce.d.ts.map +1 -0
- package/dist/schemas/extensions/security/x-use-pkce.js +13 -0
- package/dist/schemas/extensions/security/x-use-pkce.js.map +7 -0
- package/dist/schemas/extensions/tag/x-display-name.d.ts +12 -0
- package/dist/schemas/extensions/tag/x-display-name.d.ts.map +1 -0
- package/dist/schemas/extensions/tag/x-display-name.js +8 -0
- package/dist/schemas/extensions/tag/x-display-name.js.map +7 -0
- package/dist/schemas/extensions/tag/x-tag-groups.d.ts +28 -0
- package/dist/schemas/extensions/tag/x-tag-groups.d.ts.map +1 -0
- package/dist/schemas/extensions/tag/x-tag-groups.js +19 -0
- package/dist/schemas/extensions/tag/x-tag-groups.js.map +7 -0
- package/dist/schemas/inmemory-workspace.d.ts +144 -8
- package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
- package/dist/schemas/inmemory-workspace.js +13 -2
- package/dist/schemas/inmemory-workspace.js.map +2 -2
- package/dist/schemas/reference-config/index.d.ts +12 -4
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/index.js +0 -6
- package/dist/schemas/reference-config/index.js.map +2 -2
- package/dist/schemas/reference-config/settings.d.ts +12 -1
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.js +9 -2
- package/dist/schemas/reference-config/settings.js.map +2 -2
- package/dist/schemas/typebox-coerce.d.ts.map +1 -1
- package/dist/schemas/typebox-coerce.js +1 -3
- package/dist/schemas/typebox-coerce.js.map +2 -2
- package/dist/schemas/typebox-types.d.ts +14 -0
- package/dist/schemas/typebox-types.d.ts.map +1 -0
- package/dist/schemas/typebox-types.js +19 -0
- package/dist/schemas/typebox-types.js.map +7 -0
- package/dist/schemas/v3.1/loose/callback.d.ts +10 -0
- package/dist/schemas/v3.1/loose/callback.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/callback.js +11 -0
- package/dist/schemas/v3.1/loose/callback.js.map +7 -0
- package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-cookies.d.ts +16 -0
- package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-cookies.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-cookies.js +13 -0
- package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-cookies.js.map +7 -0
- package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-environments.d.ts +27 -0
- package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-environments.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-environments.js +23 -0
- package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-environments.js.map +7 -0
- package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-request-example.d.ts +38 -0
- package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-request-example.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-request-example.js +45 -0
- package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-request-example.js.map +7 -0
- package/dist/schemas/v3.1/loose/components.d.ts +43 -0
- package/dist/schemas/v3.1/loose/components.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/components.js +41 -0
- package/dist/schemas/v3.1/loose/components.js.map +7 -0
- package/dist/schemas/v3.1/loose/contact.d.ts +10 -0
- package/dist/schemas/v3.1/loose/contact.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/contact.js +13 -0
- package/dist/schemas/v3.1/loose/contact.js.map +7 -0
- package/dist/schemas/v3.1/loose/discriminator.d.ts +12 -0
- package/dist/schemas/v3.1/loose/discriminator.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/discriminator.js +11 -0
- package/dist/schemas/v3.1/loose/discriminator.js.map +7 -0
- package/dist/schemas/v3.1/loose/encoding.d.ts +15 -0
- package/dist/schemas/v3.1/loose/encoding.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/encoding.js +12 -0
- package/dist/schemas/v3.1/loose/encoding.js.map +7 -0
- package/dist/schemas/v3.1/loose/example.d.ts +16 -0
- package/dist/schemas/v3.1/loose/example.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/example.js +15 -0
- package/dist/schemas/v3.1/loose/example.js.map +7 -0
- package/dist/schemas/v3.1/loose/external-documentation.d.ts +8 -0
- package/dist/schemas/v3.1/loose/external-documentation.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/external-documentation.js +11 -0
- package/dist/schemas/v3.1/loose/external-documentation.js.map +7 -0
- package/dist/schemas/v3.1/loose/header.d.ts +355 -0
- package/dist/schemas/v3.1/loose/header.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/header.js +43 -0
- package/dist/schemas/v3.1/loose/header.js.map +7 -0
- package/dist/schemas/v3.1/loose/info.d.ts +48 -0
- package/dist/schemas/v3.1/loose/info.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/info.js +29 -0
- package/dist/schemas/v3.1/loose/info.js.map +7 -0
- package/dist/schemas/v3.1/loose/license.d.ts +10 -0
- package/dist/schemas/v3.1/loose/license.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/license.js +13 -0
- package/dist/schemas/v3.1/loose/license.js.map +7 -0
- package/dist/schemas/v3.1/loose/link.d.ts +30 -0
- package/dist/schemas/v3.1/loose/link.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/link.js +20 -0
- package/dist/schemas/v3.1/loose/link.js.map +7 -0
- package/dist/schemas/v3.1/loose/media-header-encoding.d.ts +1012 -0
- package/dist/schemas/v3.1/loose/media-header-encoding.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/media-header-encoding.js +19 -0
- package/dist/schemas/v3.1/loose/media-header-encoding.js.map +7 -0
- package/dist/schemas/v3.1/loose/media-type.d.ts +161 -0
- package/dist/schemas/v3.1/loose/media-type.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/media-type.js +18 -0
- package/dist/schemas/v3.1/loose/media-type.js.map +7 -0
- package/dist/schemas/v3.1/loose/oauth-flow.d.ts +95 -0
- package/dist/schemas/v3.1/loose/oauth-flow.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/oauth-flow.js +57 -0
- package/dist/schemas/v3.1/loose/oauth-flow.js.map +7 -0
- package/dist/schemas/v3.1/loose/oauthflows.d.ts +43 -0
- package/dist/schemas/v3.1/loose/oauthflows.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/oauthflows.js +21 -0
- package/dist/schemas/v3.1/loose/oauthflows.js.map +7 -0
- package/dist/schemas/v3.1/loose/openapi-document.d.ts +115 -0
- package/dist/schemas/v3.1/loose/openapi-document.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/openapi-document.js +64 -0
- package/dist/schemas/v3.1/loose/openapi-document.js.map +7 -0
- package/dist/schemas/v3.1/loose/operation.d.ts +1645 -0
- package/dist/schemas/v3.1/loose/operation.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/operation.js +61 -0
- package/dist/schemas/v3.1/loose/operation.js.map +7 -0
- package/dist/schemas/v3.1/loose/parameter.d.ts +1074 -0
- package/dist/schemas/v3.1/loose/parameter.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/parameter.js +54 -0
- package/dist/schemas/v3.1/loose/parameter.js.map +7 -0
- package/dist/schemas/v3.1/loose/path-item.d.ts +551 -0
- package/dist/schemas/v3.1/loose/path-item.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/path-item.js +42 -0
- package/dist/schemas/v3.1/loose/path-item.js.map +7 -0
- package/dist/schemas/v3.1/loose/path-operations.d.ts +2196 -0
- package/dist/schemas/v3.1/loose/path-operations.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/path-operations.js +21 -0
- package/dist/schemas/v3.1/loose/path-operations.js.map +7 -0
- package/dist/schemas/v3.1/loose/paths.d.ts +20 -0
- package/dist/schemas/v3.1/loose/paths.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/paths.js +11 -0
- package/dist/schemas/v3.1/loose/paths.js.map +7 -0
- package/dist/schemas/v3.1/loose/reference.d.ts +26 -0
- package/dist/schemas/v3.1/loose/reference.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/reference.js +24 -0
- package/dist/schemas/v3.1/loose/reference.js.map +7 -0
- package/dist/schemas/v3.1/loose/request-body.d.ts +339 -0
- package/dist/schemas/v3.1/loose/request-body.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/request-body.js +14 -0
- package/dist/schemas/v3.1/loose/request-body.js.map +7 -0
- package/dist/schemas/v3.1/loose/response.d.ts +698 -0
- package/dist/schemas/v3.1/loose/response.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/response.js +18 -0
- package/dist/schemas/v3.1/loose/response.js.map +7 -0
- package/dist/schemas/v3.1/loose/responses.d.ts +710 -0
- package/dist/schemas/v3.1/loose/responses.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/responses.js +11 -0
- package/dist/schemas/v3.1/loose/responses.js.map +7 -0
- package/dist/schemas/v3.1/loose/schema.d.ts +373 -0
- package/dist/schemas/v3.1/loose/schema.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/schema.js +146 -0
- package/dist/schemas/v3.1/loose/schema.js.map +7 -0
- package/dist/schemas/v3.1/loose/security-requirement.d.ts +11 -0
- package/dist/schemas/v3.1/loose/security-requirement.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/security-requirement.js +10 -0
- package/dist/schemas/v3.1/loose/security-requirement.js.map +7 -0
- package/dist/schemas/v3.1/loose/security-scheme.d.ts +169 -0
- package/dist/schemas/v3.1/loose/security-scheme.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/security-scheme.js +64 -0
- package/dist/schemas/v3.1/loose/security-scheme.js.map +7 -0
- package/dist/schemas/v3.1/loose/server-variable.d.ts +10 -0
- package/dist/schemas/v3.1/loose/server-variable.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/server-variable.js +13 -0
- package/dist/schemas/v3.1/loose/server-variable.js.map +7 -0
- package/dist/schemas/v3.1/loose/server.d.ts +14 -0
- package/dist/schemas/v3.1/loose/server.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/server.js +14 -0
- package/dist/schemas/v3.1/loose/server.js.map +7 -0
- package/dist/schemas/v3.1/loose/tag.d.ts +19 -0
- package/dist/schemas/v3.1/loose/tag.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/tag.js +23 -0
- package/dist/schemas/v3.1/loose/tag.js.map +7 -0
- package/dist/schemas/v3.1/loose/xml.d.ts +18 -0
- package/dist/schemas/v3.1/loose/xml.d.ts.map +1 -0
- package/dist/schemas/v3.1/loose/xml.js +17 -0
- package/dist/schemas/v3.1/loose/xml.js.map +7 -0
- package/dist/schemas/v3.1/strict/callback.d.ts +1 -8
- package/dist/schemas/v3.1/strict/callback.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/callback.js +5 -10
- package/dist/schemas/v3.1/strict/callback.js.map +2 -2
- package/dist/schemas/v3.1/strict/components.d.ts +24 -28
- package/dist/schemas/v3.1/strict/components.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/components.js +35 -32
- package/dist/schemas/v3.1/strict/components.js.map +2 -2
- package/dist/schemas/v3.1/strict/contact.d.ts +2 -2
- package/dist/schemas/v3.1/strict/contact.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/contact.js +8 -13
- package/dist/schemas/v3.1/strict/contact.js.map +2 -2
- package/dist/schemas/v3.1/strict/discriminator.d.ts +2 -2
- package/dist/schemas/v3.1/strict/discriminator.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/discriminator.js +6 -11
- package/dist/schemas/v3.1/strict/discriminator.js.map +2 -2
- package/dist/schemas/v3.1/strict/encoding.d.ts +3 -10
- package/dist/schemas/v3.1/strict/encoding.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/encoding.js +7 -12
- package/dist/schemas/v3.1/strict/encoding.js.map +2 -2
- package/dist/schemas/v3.1/strict/example.d.ts +2 -2
- package/dist/schemas/v3.1/strict/example.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/example.js +10 -15
- package/dist/schemas/v3.1/strict/example.js.map +2 -2
- package/dist/schemas/v3.1/strict/external-documentation.d.ts +2 -2
- package/dist/schemas/v3.1/strict/external-documentation.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/external-documentation.js +6 -11
- package/dist/schemas/v3.1/strict/external-documentation.js.map +2 -2
- package/dist/schemas/v3.1/strict/header.d.ts +292 -54
- package/dist/schemas/v3.1/strict/header.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/header.js +14 -17
- package/dist/schemas/v3.1/strict/header.js.map +2 -2
- package/dist/schemas/v3.1/strict/info.d.ts +11 -5
- package/dist/schemas/v3.1/strict/info.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/info.js +2 -2
- package/dist/schemas/v3.1/strict/info.js.map +2 -2
- package/dist/schemas/v3.1/strict/license.d.ts +2 -2
- package/dist/schemas/v3.1/strict/license.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/license.js +8 -13
- package/dist/schemas/v3.1/strict/license.js.map +2 -2
- package/dist/schemas/v3.1/strict/link.d.ts +6 -6
- package/dist/schemas/v3.1/strict/link.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/link.js +14 -19
- package/dist/schemas/v3.1/strict/link.js.map +2 -2
- package/dist/schemas/v3.1/strict/media-header-encoding.d.ts +1389 -164
- package/dist/schemas/v3.1/strict/media-header-encoding.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/media-type.d.ts +145 -19
- package/dist/schemas/v3.1/strict/media-type.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/media-type.js +13 -20
- package/dist/schemas/v3.1/strict/media-type.js.map +2 -2
- package/dist/schemas/v3.1/strict/oauth-flow.d.ts +24 -8
- package/dist/schemas/v3.1/strict/oauth-flow.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/oauth-flow.js +9 -9
- package/dist/schemas/v3.1/strict/oauth-flow.js.map +2 -2
- package/dist/schemas/v3.1/strict/oauthflows.d.ts +12 -4
- package/dist/schemas/v3.1/strict/oauthflows.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/oauthflows.js +10 -13
- package/dist/schemas/v3.1/strict/oauthflows.js.map +2 -2
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +7 -5
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.js +0 -2
- package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
- package/dist/schemas/v3.1/strict/operation.d.ts +4711 -343
- package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/operation.js +40 -35
- package/dist/schemas/v3.1/strict/operation.js.map +2 -2
- package/dist/schemas/v3.1/strict/parameter.d.ts +1226 -164
- package/dist/schemas/v3.1/strict/parameter.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/parameter.js +23 -25
- package/dist/schemas/v3.1/strict/parameter.js.map +2 -2
- package/dist/schemas/v3.1/strict/path-item.d.ts +1320 -102
- package/dist/schemas/v3.1/strict/path-item.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/path-item.js +35 -40
- package/dist/schemas/v3.1/strict/path-item.js.map +2 -2
- package/dist/schemas/v3.1/strict/path-operations.d.ts +10601 -11739
- package/dist/schemas/v3.1/strict/path-operations.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/path-operations.js +3 -1
- package/dist/schemas/v3.1/strict/path-operations.js.map +2 -2
- package/dist/schemas/v3.1/strict/paths.d.ts +3 -5514
- package/dist/schemas/v3.1/strict/paths.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/paths.js +4 -9
- package/dist/schemas/v3.1/strict/paths.js.map +2 -2
- package/dist/schemas/v3.1/strict/reference.d.ts +12 -5
- package/dist/schemas/v3.1/strict/reference.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/reference.js +4 -4
- package/dist/schemas/v3.1/strict/reference.js.map +2 -2
- package/dist/schemas/v3.1/strict/request-body.d.ts +468 -56
- package/dist/schemas/v3.1/strict/request-body.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/request-body.js +8 -13
- package/dist/schemas/v3.1/strict/request-body.js.map +2 -2
- package/dist/schemas/v3.1/strict/response.d.ts +1121 -130
- package/dist/schemas/v3.1/strict/response.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/response.js +11 -16
- package/dist/schemas/v3.1/strict/response.js.map +2 -2
- package/dist/schemas/v3.1/strict/responses.d.ts +2352 -139
- package/dist/schemas/v3.1/strict/responses.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/responses.js +4 -6
- package/dist/schemas/v3.1/strict/responses.js.map +2 -2
- package/dist/schemas/v3.1/strict/schema.d.ts +232 -15
- package/dist/schemas/v3.1/strict/schema.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/schema.js +206 -31
- package/dist/schemas/v3.1/strict/schema.js.map +2 -2
- package/dist/schemas/v3.1/strict/security-requirement.d.ts +1 -1
- package/dist/schemas/v3.1/strict/security-requirement.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/security-requirement.js +4 -9
- package/dist/schemas/v3.1/strict/security-requirement.js.map +2 -2
- package/dist/schemas/v3.1/strict/security-scheme.d.ts +56 -26
- package/dist/schemas/v3.1/strict/security-scheme.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/security-scheme.js +11 -8
- package/dist/schemas/v3.1/strict/security-scheme.js.map +2 -2
- package/dist/schemas/v3.1/strict/server-variable.d.ts +2 -2
- package/dist/schemas/v3.1/strict/server-variable.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/server-variable.js +8 -13
- package/dist/schemas/v3.1/strict/server-variable.js.map +2 -2
- package/dist/schemas/v3.1/strict/server.d.ts +4 -4
- package/dist/schemas/v3.1/strict/server.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/server.js +8 -13
- package/dist/schemas/v3.1/strict/server.js.map +2 -2
- package/dist/schemas/v3.1/strict/tag.d.ts +7 -3
- package/dist/schemas/v3.1/strict/tag.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/tag.js +6 -8
- package/dist/schemas/v3.1/strict/tag.js.map +2 -2
- package/dist/schemas/v3.1/strict/xml.d.ts +2 -2
- package/dist/schemas/v3.1/strict/xml.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/xml.js +12 -17
- package/dist/schemas/v3.1/strict/xml.js.map +2 -2
- package/dist/schemas/workspace-specification/config.d.ts +10 -2
- package/dist/schemas/workspace-specification/config.d.ts.map +1 -1
- package/dist/schemas/workspace-specification/index.d.ts +39 -13
- package/dist/schemas/workspace-specification/index.d.ts.map +1 -1
- package/dist/schemas/workspace.d.ts +63 -34
- package/dist/schemas/workspace.d.ts.map +1 -1
- package/dist/schemas/workspace.js +1 -0
- package/dist/schemas/workspace.js.map +2 -2
- package/dist/server.d.ts +2 -3290
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +2 -2
- package/dist/types.d.ts +0 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +22 -12
- package/dist/helpers/proxy.d.ts +0 -63
- package/dist/helpers/proxy.d.ts.map +0 -1
- package/dist/helpers/proxy.js +0 -107
- package/dist/helpers/proxy.js.map +0 -7
- package/dist/schemas/v3.1/strict/extensions.d.ts +0 -4
- package/dist/schemas/v3.1/strict/extensions.d.ts.map +0 -1
- package/dist/schemas/v3.1/strict/extensions.js +0 -6
- package/dist/schemas/v3.1/strict/extensions.js.map +0 -7
- package/dist/schemas/v3.1/type-guard.d.ts +0 -10
- package/dist/schemas/v3.1/type-guard.d.ts.map +0 -1
- package/dist/schemas/v3.1/type-guard.js +0 -7
- package/dist/schemas/v3.1/type-guard.js.map +0 -7
package/dist/client.js
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import YAML from "yaml";
|
|
2
2
|
import { reactive } from "vue";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { upgrade } from "@scalar/openapi-parser";
|
|
4
|
+
import { createMagicProxy, getRaw } from "@scalar/json-magic/magic-proxy";
|
|
5
5
|
import { applySelectiveUpdates } from "./helpers/apply-selective-updates.js";
|
|
6
|
-
import {
|
|
6
|
+
import { isObject, safeAssign } from "./helpers/general.js";
|
|
7
7
|
import { getValueByPath } from "./helpers/json-path-utils.js";
|
|
8
8
|
import { mergeObjects } from "./helpers/merge-object.js";
|
|
9
|
-
import { createMagicProxy, getRaw } from "./helpers/proxy.js";
|
|
10
9
|
import { createNavigation } from "./navigation/index.js";
|
|
11
10
|
import { extensions } from "./schemas/extensions.js";
|
|
12
11
|
import { coerceValue } from "./schemas/typebox-coerce.js";
|
|
13
|
-
import { OpenAPIDocumentSchema } from "./schemas/v3.1/strict/openapi-document.js";
|
|
12
|
+
import { OpenAPIDocumentSchema as OpenAPIDocumentSchemaStrict } from "./schemas/v3.1/strict/openapi-document.js";
|
|
13
|
+
import { OpenAPIDocumentSchema as OpenAPIDocumentSchemaLoose } from "./schemas/v3.1/loose/openapi-document.js";
|
|
14
14
|
import { defaultReferenceConfig } from "./schemas/reference-config/index.js";
|
|
15
15
|
import { InMemoryWorkspaceSchema } from "./schemas/inmemory-workspace.js";
|
|
16
16
|
import { createOverridesProxy } from "./helpers/overrides-proxy.js";
|
|
17
|
+
import { bundle } from "@scalar/json-magic/bundle";
|
|
18
|
+
import { fetchUrls } from "@scalar/json-magic/bundle/plugins/browser";
|
|
19
|
+
import { apply, diff, merge } from "@scalar/json-magic/diff";
|
|
20
|
+
import { externalValueResolver, loadingStatus, refsEverywhere, restoreOriginalRefs } from "./plugins.js";
|
|
21
|
+
import { Value } from "@sinclair/typebox/value";
|
|
22
|
+
import { deepClone } from "./helpers/deep-clone.js";
|
|
23
|
+
import { measureAsync, measureSync } from "@scalar/helpers/testing/measure";
|
|
17
24
|
const defaultConfig = {
|
|
18
25
|
"x-scalar-reference-config": defaultReferenceConfig
|
|
19
26
|
};
|
|
@@ -26,11 +33,19 @@ async function loadDocument(workspaceDocument) {
|
|
|
26
33
|
data: workspaceDocument.document
|
|
27
34
|
};
|
|
28
35
|
}
|
|
36
|
+
const getDocumentSource = (input) => {
|
|
37
|
+
if ("url" in input) {
|
|
38
|
+
return input.url;
|
|
39
|
+
}
|
|
40
|
+
return void 0;
|
|
41
|
+
};
|
|
29
42
|
const createWorkspaceStore = (workspaceProps) => {
|
|
30
43
|
const originalDocuments = {};
|
|
31
44
|
const intermediateDocuments = {};
|
|
32
45
|
const documentConfigs = {};
|
|
33
46
|
const overrides = {};
|
|
47
|
+
const documentMeta = {};
|
|
48
|
+
const extraDocumentConfigurations = {};
|
|
34
49
|
const workspace = reactive({
|
|
35
50
|
...workspaceProps?.meta,
|
|
36
51
|
documents: {},
|
|
@@ -49,96 +64,128 @@ const createWorkspaceStore = (workspaceProps) => {
|
|
|
49
64
|
function getActiveDocumentName() {
|
|
50
65
|
return workspace[extensions.workspace.activeDocument] ?? Object.keys(workspace.documents)[0] ?? "";
|
|
51
66
|
}
|
|
52
|
-
function saveDocument(documentName) {
|
|
67
|
+
async function saveDocument(documentName) {
|
|
53
68
|
const intermediateDocument = intermediateDocuments[documentName];
|
|
54
69
|
const workspaceDocument = workspace.documents[documentName];
|
|
55
70
|
if (!workspaceDocument) {
|
|
56
71
|
return;
|
|
57
72
|
}
|
|
58
|
-
const updatedDocument =
|
|
73
|
+
const updatedDocument = getRaw(workspaceDocument);
|
|
59
74
|
if (!intermediateDocument || !updatedDocument) {
|
|
60
75
|
return;
|
|
61
76
|
}
|
|
62
|
-
const
|
|
77
|
+
const updatedWithOriginalRefs = await bundle(deepClone(updatedDocument), {
|
|
78
|
+
plugins: [restoreOriginalRefs()],
|
|
79
|
+
treeShake: false,
|
|
80
|
+
urlMap: true
|
|
81
|
+
});
|
|
82
|
+
const excludedDiffs = applySelectiveUpdates(intermediateDocument, updatedWithOriginalRefs);
|
|
63
83
|
return excludedDiffs;
|
|
64
84
|
}
|
|
65
|
-
function
|
|
85
|
+
async function addInMemoryDocument(input) {
|
|
66
86
|
const { name, meta } = input;
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
87
|
+
const cloned = measureSync("deepClone", () => deepClone(input.document));
|
|
88
|
+
const inputDocument = measureSync("upgrade", () => upgrade(cloned).specification);
|
|
89
|
+
measureSync("initialize", () => {
|
|
90
|
+
if (input.initialize !== false) {
|
|
91
|
+
originalDocuments[name] = deepClone({ ...inputDocument });
|
|
92
|
+
intermediateDocuments[name] = deepClone({ ...inputDocument });
|
|
93
|
+
documentConfigs[name] = input.config ?? {};
|
|
94
|
+
overrides[name] = input.overrides ?? {};
|
|
95
|
+
documentMeta[name] = { documentSource: input.documentSource };
|
|
96
|
+
extraDocumentConfigurations[name] = { fetch: input.fetch };
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
const strictDocument = createMagicProxy({ ...inputDocument, ...meta });
|
|
100
|
+
if (strictDocument[extensions.document.navigation] === void 0) {
|
|
101
|
+
await measureAsync(
|
|
102
|
+
"bundle",
|
|
103
|
+
async () => await bundle(getRaw(strictDocument), {
|
|
104
|
+
treeShake: false,
|
|
105
|
+
plugins: [
|
|
106
|
+
fetchUrls({
|
|
107
|
+
fetch: extraDocumentConfigurations[name]?.fetch ?? workspaceProps?.fetch
|
|
108
|
+
}),
|
|
109
|
+
externalValueResolver(),
|
|
110
|
+
refsEverywhere()
|
|
111
|
+
// TODO: investigate problems with type: {} properties
|
|
112
|
+
// cleanUp(),
|
|
113
|
+
],
|
|
114
|
+
urlMap: true,
|
|
115
|
+
origin: documentMeta[name]?.documentSource
|
|
116
|
+
// use the document origin (if provided) as the base URL for resolution
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
const coerced = measureSync(
|
|
120
|
+
"coerceValue",
|
|
121
|
+
() => coerceValue(OpenAPIDocumentSchemaStrict, deepClone(strictDocument))
|
|
122
|
+
);
|
|
123
|
+
measureAsync("mergeObjects", async () => mergeObjects(strictDocument, coerced));
|
|
124
|
+
}
|
|
125
|
+
const isValid = Value.Check(OpenAPIDocumentSchemaStrict, strictDocument);
|
|
126
|
+
if (!isValid) {
|
|
127
|
+
throw "Invalid document provided! Please check your input document. It has some invalid refs.";
|
|
74
128
|
}
|
|
75
|
-
|
|
76
|
-
|
|
129
|
+
if (strictDocument[extensions.document.navigation] === void 0) {
|
|
130
|
+
const showModels = input.config?.["x-scalar-reference-config"]?.features?.showModels;
|
|
131
|
+
strictDocument[extensions.document.navigation] = createNavigation(strictDocument, {
|
|
132
|
+
...input.config?.["x-scalar-reference-config"] ?? {},
|
|
133
|
+
hideModels: showModels === void 0 ? void 0 : !showModels
|
|
134
|
+
}).entries;
|
|
135
|
+
}
|
|
136
|
+
workspace.documents[name] = createOverridesProxy(strictDocument, input.overrides);
|
|
77
137
|
}
|
|
78
138
|
async function addDocument(input) {
|
|
79
139
|
const { name, meta } = input;
|
|
80
|
-
const resolve = await
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
140
|
+
const resolve = await measureAsync(
|
|
141
|
+
"loadDocument",
|
|
142
|
+
async () => await loadDocument({ ...input, fetch: input.fetch ?? workspaceProps?.fetch })
|
|
143
|
+
);
|
|
144
|
+
await measureAsync("addDocument", async () => {
|
|
145
|
+
if (!resolve.ok) {
|
|
146
|
+
console.error(`Failed to fetch document '${name}': request was not successful`);
|
|
147
|
+
workspace.documents[name] = {
|
|
148
|
+
...meta,
|
|
149
|
+
openapi: "3.1.0",
|
|
150
|
+
info: {
|
|
151
|
+
title: `Document '${name}' could not be loaded`,
|
|
152
|
+
version: "unknown"
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (!isObject(resolve.data)) {
|
|
158
|
+
console.error(`Failed to load document '${name}': response data is not a valid object`);
|
|
159
|
+
workspace.documents[name] = {
|
|
160
|
+
...meta,
|
|
161
|
+
openapi: "3.1.0",
|
|
162
|
+
info: {
|
|
163
|
+
title: `Document '${name}' could not be loaded`,
|
|
164
|
+
version: "unknown"
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
await addInMemoryDocument({ ...input, document: resolve.data, documentSource: getDocumentSource(input) });
|
|
170
|
+
});
|
|
106
171
|
}
|
|
107
|
-
|
|
172
|
+
const getDocumentConfiguration = (name) => {
|
|
173
|
+
return mergeObjects(
|
|
174
|
+
mergeObjects(defaultConfig, workspaceProps?.config ?? {}),
|
|
175
|
+
documentConfigs[name] ?? {}
|
|
176
|
+
);
|
|
177
|
+
};
|
|
108
178
|
const visitedNodesCache = /* @__PURE__ */ new Set();
|
|
109
179
|
return {
|
|
110
|
-
/**
|
|
111
|
-
* Returns the reactive workspace object with an additional activeDocument getter
|
|
112
|
-
*/
|
|
113
180
|
get workspace() {
|
|
114
181
|
return workspace;
|
|
115
182
|
},
|
|
116
|
-
/**
|
|
117
|
-
* Updates a specific metadata field in the workspace
|
|
118
|
-
* @param key - The metadata field to update
|
|
119
|
-
* @param value - The new value for the field
|
|
120
|
-
* @example
|
|
121
|
-
* // Update the workspace title
|
|
122
|
-
* update('x-scalar-active-document', 'document-name')
|
|
123
|
-
*/
|
|
124
183
|
update(key, value) {
|
|
125
184
|
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
126
185
|
throw new Error("Invalid key: cannot modify prototype");
|
|
127
186
|
}
|
|
128
187
|
Object.assign(workspace, { [key]: value });
|
|
129
188
|
},
|
|
130
|
-
/**
|
|
131
|
-
* Updates a specific metadata field in a document
|
|
132
|
-
* @param name - The name of the document to update ('active' or a specific document name)
|
|
133
|
-
* @param key - The metadata field to update
|
|
134
|
-
* @param value - The new value for the field
|
|
135
|
-
* @throws Error if the specified document doesn't exist
|
|
136
|
-
* @example
|
|
137
|
-
* // Update the auth of the active document
|
|
138
|
-
* updateDocument('active', 'x-scalar-active-auth', 'Bearer')
|
|
139
|
-
* // Update the auth of a specific document
|
|
140
|
-
* updateDocument('document-name', 'x-scalar-active-auth', 'Bearer')
|
|
141
|
-
*/
|
|
142
189
|
updateDocument(name, key, value) {
|
|
143
190
|
const currentDocument = workspace.documents[name === "active" ? getActiveDocumentName() : name];
|
|
144
191
|
if (!currentDocument) {
|
|
@@ -146,41 +193,22 @@ const createWorkspaceStore = (workspaceProps) => {
|
|
|
146
193
|
}
|
|
147
194
|
Object.assign(currentDocument, { [key]: value });
|
|
148
195
|
},
|
|
149
|
-
|
|
150
|
-
* Replaces the content of a specific document in the workspace with the provided input.
|
|
151
|
-
* This method computes the difference between the current document and the new input,
|
|
152
|
-
* then applies only the necessary changes in place. The updates are applied atomically,
|
|
153
|
-
* ensuring the document is updated in a single operation.
|
|
154
|
-
*
|
|
155
|
-
* @param documentName - The name of the document to update.
|
|
156
|
-
* @param input - The new content to apply to the document (as a plain object).
|
|
157
|
-
* @example
|
|
158
|
-
* // Replace the content of the 'api' document with new data
|
|
159
|
-
* store.replaceDocument('api', {
|
|
160
|
-
* openapi: '3.1.0',
|
|
161
|
-
* info: { title: 'Updated API', version: '1.0.1' },
|
|
162
|
-
* paths: {},
|
|
163
|
-
* })
|
|
164
|
-
*/
|
|
165
|
-
replaceDocument(documentName, input) {
|
|
196
|
+
async replaceDocument(documentName, input) {
|
|
166
197
|
const currentDocument = workspace.documents[documentName];
|
|
167
198
|
if (!currentDocument) {
|
|
168
199
|
return console.error(`Document '${documentName}' does not exist in the workspace.`);
|
|
169
200
|
}
|
|
170
|
-
|
|
171
|
-
|
|
201
|
+
await addInMemoryDocument({
|
|
202
|
+
name: documentName,
|
|
203
|
+
document: input,
|
|
204
|
+
// Preserve the current metadata
|
|
205
|
+
meta: {
|
|
206
|
+
"x-scalar-active-auth": currentDocument["x-scalar-active-auth"],
|
|
207
|
+
"x-scalar-active-server": currentDocument["x-scalar-active-server"]
|
|
208
|
+
},
|
|
209
|
+
initialize: false
|
|
210
|
+
});
|
|
172
211
|
},
|
|
173
|
-
/**
|
|
174
|
-
* Resolves a reference in the active document by following the provided path and resolving any external $ref references.
|
|
175
|
-
* This method traverses the document structure following the given path and resolves any $ref references it encounters.
|
|
176
|
-
* During resolution, it sets a loading status and updates the reference with the resolved content.
|
|
177
|
-
*
|
|
178
|
-
* @param path - Array of strings representing the path to the reference (e.g. ['paths', '/users', 'get', 'responses', '200'])
|
|
179
|
-
* @throws Error if the path is invalid or empty
|
|
180
|
-
* @example
|
|
181
|
-
* // Resolve a reference in the active document
|
|
182
|
-
* resolve(['paths', '/users', 'get', 'responses', '200'])
|
|
183
|
-
*/
|
|
184
212
|
resolve: async (path) => {
|
|
185
213
|
const activeDocument = workspace.activeDocument;
|
|
186
214
|
const target = getValueByPath(activeDocument, path);
|
|
@@ -193,93 +221,15 @@ const createWorkspaceStore = (workspaceProps) => {
|
|
|
193
221
|
return bundle(target, {
|
|
194
222
|
root: activeDocument,
|
|
195
223
|
treeShake: false,
|
|
196
|
-
plugins: [fetchUrls()],
|
|
197
|
-
urlMap:
|
|
198
|
-
hooks: {
|
|
199
|
-
onResolveStart: (node) => {
|
|
200
|
-
node["$status"] = "loading";
|
|
201
|
-
},
|
|
202
|
-
onResolveError: (node) => {
|
|
203
|
-
node["$status"] = "error";
|
|
204
|
-
}
|
|
205
|
-
},
|
|
224
|
+
plugins: [fetchUrls(), loadingStatus(), externalValueResolver()],
|
|
225
|
+
urlMap: true,
|
|
206
226
|
visitedNodes: visitedNodesCache
|
|
207
227
|
});
|
|
208
228
|
},
|
|
209
|
-
/**
|
|
210
|
-
* Adds a new document to the workspace
|
|
211
|
-
* @param document - The document content to add. This should be a valid OpenAPI/Swagger document or other supported format
|
|
212
|
-
* @param meta - Metadata for the document, including its name and other properties defined in WorkspaceDocumentMeta
|
|
213
|
-
* @example
|
|
214
|
-
* // Add a new OpenAPI document to the workspace
|
|
215
|
-
* store.addDocument({
|
|
216
|
-
* name: 'name',
|
|
217
|
-
* document: {
|
|
218
|
-
* openapi: '3.0.0',
|
|
219
|
-
* info: { title: 'title' },
|
|
220
|
-
* },
|
|
221
|
-
* meta: {
|
|
222
|
-
* 'x-scalar-active-auth': 'Bearer',
|
|
223
|
-
* 'x-scalar-active-server': 'production'
|
|
224
|
-
* }
|
|
225
|
-
* })
|
|
226
|
-
*/
|
|
227
229
|
addDocument,
|
|
228
|
-
/**
|
|
229
|
-
* Similar to addDocument but requires and in-mem object to be provided and loads the document synchronously
|
|
230
|
-
* @param document - The document content to add. This should be a valid OpenAPI/Swagger document or other supported format
|
|
231
|
-
* @param meta - Metadata for the document, including its name and other properties defined in WorkspaceDocumentMeta
|
|
232
|
-
* @example
|
|
233
|
-
* // Add a new OpenAPI document to the workspace
|
|
234
|
-
* store.addDocument({
|
|
235
|
-
* name: 'name',
|
|
236
|
-
* document: {
|
|
237
|
-
* openapi: '3.0.0',
|
|
238
|
-
* info: { title: 'title' },
|
|
239
|
-
* },
|
|
240
|
-
* meta: {
|
|
241
|
-
* 'x-scalar-active-auth': 'Bearer',
|
|
242
|
-
* 'x-scalar-active-server': 'production'
|
|
243
|
-
* }
|
|
244
|
-
* })
|
|
245
|
-
*/
|
|
246
|
-
addDocumentSync,
|
|
247
|
-
/**
|
|
248
|
-
* Returns the merged configuration for the active document.
|
|
249
|
-
*
|
|
250
|
-
* This getter merges configurations in the following order of precedence:
|
|
251
|
-
* 1. Document-specific configuration (highest priority)
|
|
252
|
-
* 2. Workspace-level configuration
|
|
253
|
-
* 3. Default configuration (lowest priority)
|
|
254
|
-
*
|
|
255
|
-
* The active document is determined by the workspace's activeDocument extension,
|
|
256
|
-
* falling back to the first document if none is specified.
|
|
257
|
-
*/
|
|
258
230
|
get config() {
|
|
259
|
-
return
|
|
260
|
-
mergeObjects(defaultConfig, workspaceProps?.config ?? {}),
|
|
261
|
-
documentConfigs[getActiveDocumentName()] ?? {}
|
|
262
|
-
);
|
|
231
|
+
return getDocumentConfiguration(getActiveDocumentName());
|
|
263
232
|
},
|
|
264
|
-
/**
|
|
265
|
-
* Exports the specified document in the requested format.
|
|
266
|
-
*
|
|
267
|
-
* This method serializes the most recently saved local version of the document (from the intermediateDocuments map)
|
|
268
|
-
* to either JSON or YAML. The exported document reflects the last locally saved state, including any edits
|
|
269
|
-
* that have been saved but not yet synced to a remote registry. Runtime/in-memory changes that have not been saved
|
|
270
|
-
* will not be included.
|
|
271
|
-
*
|
|
272
|
-
* @param documentName - The name of the document to export.
|
|
273
|
-
* @param format - The output format: 'json' for a JSON string, or 'yaml' for a YAML string.
|
|
274
|
-
* @returns The document as a string in the requested format, or undefined if the document does not exist.
|
|
275
|
-
*
|
|
276
|
-
* @example
|
|
277
|
-
* // Export a document as JSON
|
|
278
|
-
* const jsonString = store.exportDocument('api', 'json')
|
|
279
|
-
*
|
|
280
|
-
* // Export a document as YAML
|
|
281
|
-
* const yamlString = store.exportDocument('api', 'yaml')
|
|
282
|
-
*/
|
|
283
233
|
exportDocument: (documentName, format) => {
|
|
284
234
|
const intermediateDocument = intermediateDocuments[documentName];
|
|
285
235
|
if (!intermediateDocument) {
|
|
@@ -290,78 +240,22 @@ const createWorkspaceStore = (workspaceProps) => {
|
|
|
290
240
|
}
|
|
291
241
|
return YAML.stringify(intermediateDocument);
|
|
292
242
|
},
|
|
293
|
-
/**
|
|
294
|
-
* Saves the current state of the specified document to the intermediate documents map.
|
|
295
|
-
*
|
|
296
|
-
* This function captures the latest (reactive) state of the document from the workspace and
|
|
297
|
-
* applies its changes to the corresponding entry in the `intermediateDocuments` map.
|
|
298
|
-
* The `intermediateDocuments` map represents the most recently "saved" local version of the document,
|
|
299
|
-
* which may include edits not yet synced to the remote registry.
|
|
300
|
-
*
|
|
301
|
-
* The update is performed in-place. A deep clone of the current document
|
|
302
|
-
* state is used to avoid mutating the reactive object directly.
|
|
303
|
-
*
|
|
304
|
-
* @param documentName - The name of the document to save.
|
|
305
|
-
* @returns An array of diffs that were excluded from being applied (such as changes to ignored keys),
|
|
306
|
-
* or undefined if the document does not exist or cannot be updated.
|
|
307
|
-
*
|
|
308
|
-
* @example
|
|
309
|
-
* // Save the current state of the document named 'api'
|
|
310
|
-
* const excludedDiffs = store.saveDocument('api')
|
|
311
|
-
*/
|
|
312
243
|
saveDocument,
|
|
313
|
-
|
|
314
|
-
* Restores the specified document to its last locally saved state.
|
|
315
|
-
*
|
|
316
|
-
* This method updates the current reactive document (in the workspace) with the contents of the
|
|
317
|
-
* corresponding intermediate document (from the `intermediateDocuments` map), effectively discarding
|
|
318
|
-
* any unsaved in-memory changes and reverting to the last saved version.
|
|
319
|
-
* Vue reactivity is preserved by updating the existing reactive object in place.
|
|
320
|
-
*
|
|
321
|
-
* **Warning:** This operation will discard all unsaved (in-memory) changes to the specified document.
|
|
322
|
-
*
|
|
323
|
-
* @param documentName - The name of the document to restore.
|
|
324
|
-
* @returns void
|
|
325
|
-
*
|
|
326
|
-
* @example
|
|
327
|
-
* // Restore the document named 'api' to its last saved state
|
|
328
|
-
* store.revertDocumentChanges('api')
|
|
329
|
-
*/
|
|
330
|
-
revertDocumentChanges(documentName) {
|
|
244
|
+
async revertDocumentChanges(documentName) {
|
|
331
245
|
const workspaceDocument = workspace.documents[documentName];
|
|
332
|
-
|
|
246
|
+
const intermediate = intermediateDocuments[documentName];
|
|
247
|
+
if (!workspaceDocument || !intermediate) {
|
|
333
248
|
return;
|
|
334
249
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
applySelectiveUpdates(updatedDocument, intermediateDocument);
|
|
250
|
+
await addInMemoryDocument({
|
|
251
|
+
name: documentName,
|
|
252
|
+
document: intermediate,
|
|
253
|
+
initialize: false
|
|
254
|
+
});
|
|
341
255
|
},
|
|
342
|
-
/**
|
|
343
|
-
* Commits the specified document.
|
|
344
|
-
*
|
|
345
|
-
* This method is intended to finalize and persist the current state of the document,
|
|
346
|
-
* potentially syncing it with a remote registry or marking it as the latest committed version.
|
|
347
|
-
*
|
|
348
|
-
* @param documentName - The name of the document to commit.
|
|
349
|
-
* @remarks
|
|
350
|
-
* The actual commit logic is not implemented yet.
|
|
351
|
-
*/
|
|
352
256
|
commitDocument(documentName) {
|
|
353
257
|
console.warn(`Commit operation for document '${documentName}' is not implemented yet.`);
|
|
354
258
|
},
|
|
355
|
-
/**
|
|
356
|
-
* Serializes the current workspace state to a JSON string for backup, persistence, or sharing.
|
|
357
|
-
*
|
|
358
|
-
* This method exports all workspace documents (removing Vue reactivity proxies), workspace metadata,
|
|
359
|
-
* document configurations, and both the original and intermediate document states. The resulting JSON
|
|
360
|
-
* can be imported later to fully restore the workspace to this exact state, including all documents
|
|
361
|
-
* and their configurations.
|
|
362
|
-
*
|
|
363
|
-
* @returns A JSON string representing the complete workspace state.
|
|
364
|
-
*/
|
|
365
259
|
exportWorkspace() {
|
|
366
260
|
return JSON.stringify({
|
|
367
261
|
documents: {
|
|
@@ -370,60 +264,36 @@ const createWorkspaceStore = (workspaceProps) => {
|
|
|
370
264
|
name,
|
|
371
265
|
// Extract the raw document data for export, removing any Vue reactivity wrappers.
|
|
372
266
|
// When importing, the document can be wrapped again in a magic proxy.
|
|
373
|
-
|
|
267
|
+
getRaw(doc)
|
|
374
268
|
])
|
|
375
269
|
)
|
|
376
270
|
},
|
|
377
271
|
meta: workspaceProps?.meta ?? {},
|
|
378
272
|
documentConfigs,
|
|
379
273
|
originalDocuments,
|
|
380
|
-
intermediateDocuments
|
|
274
|
+
intermediateDocuments,
|
|
275
|
+
overrides,
|
|
276
|
+
documentMeta
|
|
381
277
|
});
|
|
382
278
|
},
|
|
383
|
-
/**
|
|
384
|
-
* Imports a workspace from a serialized JSON string.
|
|
385
|
-
*
|
|
386
|
-
* This method parses the input string using the InMemoryWorkspaceSchema,
|
|
387
|
-
* then updates the current workspace state, including documents, metadata,
|
|
388
|
-
* and configuration, with the imported values.
|
|
389
|
-
*
|
|
390
|
-
* @param input - The serialized workspace JSON string to import.
|
|
391
|
-
*/
|
|
392
279
|
loadWorkspace(input) {
|
|
393
280
|
const result = coerceValue(InMemoryWorkspaceSchema, JSON.parse(input));
|
|
394
281
|
safeAssign(
|
|
395
282
|
workspace.documents,
|
|
396
|
-
Object.fromEntries(
|
|
283
|
+
Object.fromEntries(
|
|
284
|
+
Object.entries(result.documents).map(([name, doc]) => [
|
|
285
|
+
name,
|
|
286
|
+
createOverridesProxy(createMagicProxy(doc), result.overrides[name])
|
|
287
|
+
])
|
|
288
|
+
)
|
|
397
289
|
);
|
|
398
290
|
safeAssign(originalDocuments, result.originalDocuments);
|
|
399
291
|
safeAssign(intermediateDocuments, result.intermediateDocuments);
|
|
400
292
|
safeAssign(documentConfigs, result.documentConfigs);
|
|
293
|
+
safeAssign(overrides, result.overrides);
|
|
401
294
|
safeAssign(workspace, result.meta);
|
|
295
|
+
safeAssign(documentMeta, result.documentMeta);
|
|
402
296
|
},
|
|
403
|
-
/**
|
|
404
|
-
* Imports a workspace from a WorkspaceSpecification object.
|
|
405
|
-
*
|
|
406
|
-
* This method assigns workspace metadata and adds all documents defined in the specification.
|
|
407
|
-
* Each document is added using its $ref and optional overrides.
|
|
408
|
-
*
|
|
409
|
-
* @example
|
|
410
|
-
* ```ts
|
|
411
|
-
* await store.importWorkspaceFromSpecification({
|
|
412
|
-
* documents: {
|
|
413
|
-
* api: { $ref: '/specs/api.yaml' },
|
|
414
|
-
* petstore: { $ref: '/specs/petstore.yaml' }
|
|
415
|
-
* },
|
|
416
|
-
* overrides: {
|
|
417
|
-
* api: { config: { features: { showModels: true } } }
|
|
418
|
-
* },
|
|
419
|
-
* info: { title: 'My Workspace' },
|
|
420
|
-
* workspace: 'v1',
|
|
421
|
-
* "x-scalar-dark-mode": true
|
|
422
|
-
* })
|
|
423
|
-
* ```
|
|
424
|
-
*
|
|
425
|
-
* @param specification - The workspace specification to import.
|
|
426
|
-
*/
|
|
427
297
|
importWorkspaceFromSpecification: (specification) => {
|
|
428
298
|
const { documents, overrides: overrides2, info, workspace: workspaceVersion, ...meta } = specification;
|
|
429
299
|
safeAssign(workspace, meta);
|
|
@@ -432,6 +302,38 @@ const createWorkspaceStore = (workspaceProps) => {
|
|
|
432
302
|
([name, doc]) => addDocument({ url: doc.$ref, name, overrides: overrides2?.[name] })
|
|
433
303
|
)
|
|
434
304
|
);
|
|
305
|
+
},
|
|
306
|
+
rebaseDocument: (documentName, newDocumentOrigin, resolvedConflicts) => {
|
|
307
|
+
const newOrigin = coerceValue(OpenAPIDocumentSchemaLoose, upgrade(newDocumentOrigin).specification);
|
|
308
|
+
const originalDocument = originalDocuments[documentName];
|
|
309
|
+
const intermediateDocument = intermediateDocuments[documentName];
|
|
310
|
+
const activeDocument = workspace.documents[documentName] ? getRaw(workspace.documents[documentName]) : void 0;
|
|
311
|
+
if (!originalDocument || !intermediateDocument || !activeDocument) {
|
|
312
|
+
return console.error("[ERROR]: Specified document is missing or internal corrupted workspace state");
|
|
313
|
+
}
|
|
314
|
+
const changelogAA = diff(originalDocument, newOrigin);
|
|
315
|
+
const changelogAB = diff(originalDocument, intermediateDocument);
|
|
316
|
+
const changesA = merge(changelogAA, changelogAB);
|
|
317
|
+
if (resolvedConflicts === void 0) {
|
|
318
|
+
return changesA.conflicts;
|
|
319
|
+
}
|
|
320
|
+
const changesetA = changesA.diffs.concat(resolvedConflicts);
|
|
321
|
+
const newIntermediateDocument = apply(deepClone(originalDocument), changesetA);
|
|
322
|
+
intermediateDocuments[documentName] = newIntermediateDocument;
|
|
323
|
+
originalDocuments[documentName] = newOrigin;
|
|
324
|
+
const changelogBA = diff(intermediateDocument, newIntermediateDocument);
|
|
325
|
+
const changelogBB = diff(intermediateDocument, activeDocument);
|
|
326
|
+
const changesB = merge(changelogBA, changelogBB);
|
|
327
|
+
const changesetB = changesB.diffs.concat(changesB.conflicts.flatMap((it) => it[0]));
|
|
328
|
+
const newActiveDocument = coerceValue(
|
|
329
|
+
OpenAPIDocumentSchemaStrict,
|
|
330
|
+
apply(deepClone(newIntermediateDocument), changesetB)
|
|
331
|
+
);
|
|
332
|
+
workspace.documents[documentName] = createOverridesProxy(
|
|
333
|
+
createMagicProxy({ ...newActiveDocument }),
|
|
334
|
+
overrides[documentName]
|
|
335
|
+
);
|
|
336
|
+
return;
|
|
435
337
|
}
|
|
436
338
|
};
|
|
437
339
|
};
|