@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
package/dist/mutators/cookie.js
CHANGED
|
@@ -1,46 +1,63 @@
|
|
|
1
|
-
import { xScalarCookieSchema } from
|
|
2
|
-
import { coerceValue } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { xScalarCookieSchema } from '../schemas/extensions/general/x-scalar-cookies.js';
|
|
2
|
+
import { coerceValue } from '../schemas/typebox-coerce.js';
|
|
3
|
+
/**
|
|
4
|
+
* Adds OR updates a cookie to the document or workspace.
|
|
5
|
+
*
|
|
6
|
+
* @param document - current document if available
|
|
7
|
+
* @param workspace - current workspace if available
|
|
8
|
+
* @param payload - The cookie configuration to add or update
|
|
9
|
+
* @param index - Optional index for updating an existing cookie
|
|
10
|
+
* @param collectionType - Whether this is for a document or workspace
|
|
11
|
+
* @returns the parsed cookie that was added or updated or undefined if the collection is not found
|
|
12
|
+
*/
|
|
13
|
+
export const upsertCookie = (collection, { payload, index }) => {
|
|
14
|
+
if (!collection) {
|
|
15
|
+
return;
|
|
13
16
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
if (!collection['x-scalar-cookies']) {
|
|
18
|
+
collection['x-scalar-cookies'] = [];
|
|
19
|
+
}
|
|
20
|
+
if (index !== undefined) {
|
|
21
|
+
// Update existing cookie at index
|
|
22
|
+
if (index < 0 || index >= collection['x-scalar-cookies'].length) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
// Ensure we parse the payload but keep the existing cookie data
|
|
26
|
+
const parsed = coerceValue(xScalarCookieSchema, {
|
|
27
|
+
...collection['x-scalar-cookies'][index],
|
|
28
|
+
...payload,
|
|
29
|
+
});
|
|
30
|
+
// Update
|
|
31
|
+
collection['x-scalar-cookies'][index] = parsed;
|
|
32
|
+
return parsed;
|
|
33
|
+
}
|
|
34
|
+
// Add new cookie
|
|
35
|
+
const parsed = coerceValue(xScalarCookieSchema, payload);
|
|
36
|
+
collection['x-scalar-cookies'].push(parsed);
|
|
37
|
+
return parsed;
|
|
34
38
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Deletes a cookie from the document or workspace by index.
|
|
41
|
+
*
|
|
42
|
+
* @param document - current document if available
|
|
43
|
+
* @param workspace - current workspace if available
|
|
44
|
+
* @param index - Index of the cookie to delete
|
|
45
|
+
* @param collectionType - Whether this is for a document or workspace
|
|
46
|
+
* @returns true if the cookie was deleted, false otherwise
|
|
47
|
+
*/
|
|
48
|
+
export const deleteCookie = (collection, { index }) => {
|
|
49
|
+
if (!collection || !collection['x-scalar-cookies']) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
if (index < 0 || index >= collection['x-scalar-cookies'].length) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
collection['x-scalar-cookies'].splice(index, 1);
|
|
56
|
+
return true;
|
|
40
57
|
};
|
|
41
|
-
export {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
58
|
+
export const cookieMutatorsFactory = ({ collection }) => {
|
|
59
|
+
return {
|
|
60
|
+
upsertCookie: (payload) => upsertCookie(collection, payload),
|
|
61
|
+
deleteCookie: (payload) => deleteCookie(collection, payload),
|
|
62
|
+
};
|
|
45
63
|
};
|
|
46
|
-
//# sourceMappingURL=cookie.js.map
|
|
@@ -1,73 +1,111 @@
|
|
|
1
|
-
import { mergeObjects } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { mergeObjects } from '../helpers/merge-object.js';
|
|
2
|
+
/**
|
|
3
|
+
* Updates the "watch mode" state of the given document.
|
|
4
|
+
*
|
|
5
|
+
* @param document WorkspaceDocument or null – The document to modify.
|
|
6
|
+
* @param watchMode boolean – True enables watch mode, false disables it.
|
|
7
|
+
*
|
|
8
|
+
* If document is null, does nothing.
|
|
9
|
+
*/
|
|
10
|
+
export const updateWatchMode = (document, watchMode) => {
|
|
11
|
+
if (!document) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
// Set (or unset) the x-scalar-watch-mode property on the document
|
|
15
|
+
document['x-scalar-watch-mode'] = watchMode;
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Updates the document's info object (typically, title, description, version, etc.).
|
|
19
|
+
*
|
|
20
|
+
* Uses a shallow merge: only properties present in payload will be overwritten or added.
|
|
21
|
+
*
|
|
22
|
+
* @param document WorkspaceDocument | null – The document whose info should be updated.
|
|
23
|
+
* @param payload DocumentEvents['document:update:info'] – Partial info fields to update/merge.
|
|
24
|
+
*
|
|
25
|
+
* If document is null, does nothing.
|
|
26
|
+
*/
|
|
27
|
+
export const updateDocumentInfo = (document, payload) => {
|
|
28
|
+
if (!document) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// Merge the given payload into the document's info object
|
|
32
|
+
mergeObjects(document.info, payload);
|
|
33
|
+
// Update the document title if it is present and the navigation object is present
|
|
34
|
+
// We do this because we don't want to rebuild the entire navigation object if only the title is changed
|
|
35
|
+
// Normalize like traverseDocument: trim and treat whitespace-only as empty so we show "Untitled Document"
|
|
36
|
+
if (document['x-scalar-navigation'] && payload.title !== undefined) {
|
|
37
|
+
document['x-scalar-navigation'].title = payload.title?.trim() || 'Untitled Document';
|
|
38
|
+
}
|
|
23
39
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
await store.addDocument({
|
|
33
|
-
name: payload.name,
|
|
34
|
-
document: {
|
|
35
|
-
openapi: "3.1.0",
|
|
36
|
-
info: { title: payload.name, version: "1.0.0" },
|
|
37
|
-
paths: {
|
|
38
|
-
"/": {
|
|
39
|
-
get: {}
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
"x-scalar-icon": payload.icon
|
|
40
|
+
/**
|
|
41
|
+
* Update the document icon and also update the corresponding sidebar entry
|
|
42
|
+
*
|
|
43
|
+
* Does not perform a sidebar rebuild for performance benefit
|
|
44
|
+
*/
|
|
45
|
+
export const updateDocumentIcon = (document, icon) => {
|
|
46
|
+
if (!document || !document['x-scalar-navigation']) {
|
|
47
|
+
return;
|
|
43
48
|
}
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
// Update the document icon
|
|
50
|
+
document['x-scalar-icon'] = icon;
|
|
51
|
+
// Update the sidebar document icon
|
|
52
|
+
document['x-scalar-navigation'].icon = icon;
|
|
46
53
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Creates an empty OpenAPI document and adds it to the workspace.
|
|
56
|
+
*
|
|
57
|
+
* - If the store is null, this is a no-op.
|
|
58
|
+
* - The document name must be unique; if already present, callback is called with `false`.
|
|
59
|
+
* - On success, a new OpenAPI 3.1.0 document is added with a basic path and info.
|
|
60
|
+
* - Callback is called with `true` if document is created.
|
|
61
|
+
*
|
|
62
|
+
* @param store WorkspaceStore | null – The workspace store to add the document to.
|
|
63
|
+
* @param payload DocumentEvents['document:create:empty-document'] – Contains name, icon, and callback.
|
|
64
|
+
*/
|
|
65
|
+
export const createEmptyDocument = async (store, payload) => {
|
|
66
|
+
if (!store) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// Check if the document already exists by name for uniqueness
|
|
70
|
+
if (store.workspace.documents[payload.name]) {
|
|
71
|
+
// Document name already exists, call callback with false
|
|
72
|
+
payload.callback?.(false);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// Add a new empty OpenAPI 3.1.0 document with minimal info and icon
|
|
76
|
+
await store.addDocument({
|
|
77
|
+
name: payload.name,
|
|
78
|
+
document: {
|
|
79
|
+
openapi: '3.1.0',
|
|
80
|
+
info: { title: payload.name, version: '1.0.0' },
|
|
81
|
+
paths: {
|
|
82
|
+
'/': {
|
|
83
|
+
get: {},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
'x-scalar-icon': payload.icon,
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
// Notify success via callback
|
|
90
|
+
payload.callback?.(true);
|
|
52
91
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
deleteDocument
|
|
63
|
-
};
|
|
92
|
+
/**
|
|
93
|
+
* Deletes a document from the workspace by its name.
|
|
94
|
+
*
|
|
95
|
+
* Safely no-ops if the store is null.
|
|
96
|
+
*/
|
|
97
|
+
export const deleteDocument = (store, payload) => {
|
|
98
|
+
if (!store) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
store.deleteDocument(payload.name);
|
|
64
102
|
};
|
|
65
|
-
export {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
103
|
+
export const documentMutatorsFactory = ({ document, store, }) => {
|
|
104
|
+
return {
|
|
105
|
+
updateDocumentInfo: (payload) => updateDocumentInfo(document, payload),
|
|
106
|
+
updateWatchMode: (payload) => updateWatchMode(document, payload),
|
|
107
|
+
updateDocumentIcon: (payload) => updateDocumentIcon(document, payload),
|
|
108
|
+
createEmptyDocument: (payload) => createEmptyDocument(store, payload),
|
|
109
|
+
deleteDocument: (payload) => deleteDocument(store, payload),
|
|
110
|
+
};
|
|
72
111
|
};
|
|
73
|
-
//# sourceMappingURL=document.js.map
|
|
@@ -1,79 +1,104 @@
|
|
|
1
|
-
import { unpackProxyObject } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
collection["x-scalar-environments"][environmentName] = parsed;
|
|
20
|
-
if (oldEnvironmentName && oldEnvironmentName !== environmentName) {
|
|
21
|
-
delete collection["x-scalar-environments"][oldEnvironmentName];
|
|
22
|
-
if (workspace["x-scalar-active-environment"] === oldEnvironmentName) {
|
|
23
|
-
workspace["x-scalar-active-environment"] = environmentName;
|
|
1
|
+
import { unpackProxyObject } from '../helpers/unpack-proxy.js';
|
|
2
|
+
import { xScalarEnvVarSchema, xScalarEnvironmentSchema, } from '../schemas/extensions/document/x-scalar-environments.js';
|
|
3
|
+
import { coerceValue } from '../schemas/typebox-coerce.js';
|
|
4
|
+
/**
|
|
5
|
+
* Adds OR updates an environment to the document or workspace.
|
|
6
|
+
*
|
|
7
|
+
* @param document - current document if available
|
|
8
|
+
* @param workspace - current workspace if available
|
|
9
|
+
* @param environmentName - Name of the environment to add
|
|
10
|
+
* @param payload - The environment configuration to add
|
|
11
|
+
* @param oldEnvironmentName - Only needed when renaming the environment
|
|
12
|
+
* @returns the parsed environment that was added or updated or undefined if the collection is not found
|
|
13
|
+
*/
|
|
14
|
+
export const upsertEnvironment = (workspace, collection, { environmentName, payload, oldEnvironmentName }) => {
|
|
15
|
+
/** Discriminating between document and workspace */
|
|
16
|
+
if (!collection || !workspace) {
|
|
17
|
+
return;
|
|
24
18
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
if (!collection['x-scalar-environments']) {
|
|
20
|
+
collection['x-scalar-environments'] = {};
|
|
21
|
+
}
|
|
22
|
+
// Check if this is a new environment before we create it
|
|
23
|
+
const isNewEnvironment = !collection['x-scalar-environments'][oldEnvironmentName ?? environmentName];
|
|
24
|
+
// Ensure we parse the payload but keep the old variables
|
|
25
|
+
const parsed = coerceValue(xScalarEnvironmentSchema, {
|
|
26
|
+
...unpackProxyObject(collection['x-scalar-environments'][oldEnvironmentName ?? environmentName], { depth: 1 }),
|
|
27
|
+
...payload,
|
|
28
|
+
});
|
|
29
|
+
collection['x-scalar-environments'][environmentName] = parsed;
|
|
30
|
+
// If we are renaming the environment, we need to delete the old one
|
|
31
|
+
if (oldEnvironmentName && oldEnvironmentName !== environmentName) {
|
|
32
|
+
delete collection['x-scalar-environments'][oldEnvironmentName];
|
|
33
|
+
// If the old environment was active, we need to set the new environment as active
|
|
34
|
+
if (workspace['x-scalar-active-environment'] === oldEnvironmentName) {
|
|
35
|
+
workspace['x-scalar-active-environment'] = environmentName;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Set the newly created workspace environment as active
|
|
39
|
+
if (isNewEnvironment) {
|
|
40
|
+
workspace['x-scalar-active-environment'] = environmentName;
|
|
41
|
+
}
|
|
42
|
+
return parsed;
|
|
36
43
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Deletes an environment from the given collection and handles active environment state.
|
|
46
|
+
*
|
|
47
|
+
* @param workspace - The workspace object, or null if unavailable.
|
|
48
|
+
* @param collection - The workspace document or workspace object, or null if unavailable.
|
|
49
|
+
* @param environmentName - The name of the environment to delete.
|
|
50
|
+
*/
|
|
51
|
+
export const deleteEnvironment = (workspace, collection, { environmentName }) => {
|
|
52
|
+
if (!collection || !workspace) {
|
|
53
|
+
return;
|
|
47
54
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
collection["x-scalar-environments"][environmentName].variables.push(parsed);
|
|
51
|
-
}
|
|
52
|
-
return parsed;
|
|
55
|
+
// Trigegr the change event for the active environment
|
|
56
|
+
delete collection['x-scalar-environments']?.[environmentName];
|
|
53
57
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Adds OR updates an environment variable to the document or workspace.
|
|
60
|
+
*
|
|
61
|
+
* @param collection - Workspace OR document
|
|
62
|
+
* @param environmentName - Name of the environment to add the variable to
|
|
63
|
+
* @param variableName - Name of the variable to add
|
|
64
|
+
* @param value - Value of the variable to add
|
|
65
|
+
* @returns the parsed variable that was added or updated or undefined if the collection is not found
|
|
66
|
+
*/
|
|
67
|
+
export const upsertEnvironmentVariable = (collection, { environmentName, variable, index }) => {
|
|
68
|
+
// The environment should exist by now if we are upserting a variable
|
|
69
|
+
if (!collection?.['x-scalar-environments']?.[environmentName]) {
|
|
70
|
+
console.error('Environment not found', environmentName);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
// Ensure we parse the variable for type safety
|
|
74
|
+
const parsed = coerceValue(xScalarEnvVarSchema, variable);
|
|
75
|
+
if (index !== undefined) {
|
|
76
|
+
// Delete the row if the name is empty
|
|
77
|
+
if (parsed.name === '') {
|
|
78
|
+
collection['x-scalar-environments'][environmentName].variables.splice(index, 1);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
// Update
|
|
82
|
+
collection['x-scalar-environments'][environmentName].variables[index] = parsed;
|
|
83
|
+
}
|
|
84
|
+
// Add
|
|
85
|
+
else {
|
|
86
|
+
collection['x-scalar-environments'][environmentName].variables.push(parsed);
|
|
87
|
+
}
|
|
88
|
+
return parsed;
|
|
60
89
|
};
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
deleteEnvironment: (payload) => deleteEnvironment(workspace, collection, payload),
|
|
68
|
-
upsertEnvironmentVariable: (payload) => upsertEnvironmentVariable(collection, payload),
|
|
69
|
-
deleteEnvironmentVariable: (payload) => deleteEnvironmentVariable(collection, payload)
|
|
70
|
-
};
|
|
90
|
+
export const deleteEnvironmentVariable = (collection, { environmentName, index }) => {
|
|
91
|
+
if (!collection?.['x-scalar-environments']?.[environmentName]) {
|
|
92
|
+
console.error('Environment not found', environmentName);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
collection['x-scalar-environments']?.[environmentName]?.variables?.splice(index, 1);
|
|
71
96
|
};
|
|
72
|
-
export {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
97
|
+
export const environmentMutatorsFactory = ({ workspace, collection, }) => {
|
|
98
|
+
return {
|
|
99
|
+
upsertEnvironment: (payload) => upsertEnvironment(workspace, collection, payload),
|
|
100
|
+
deleteEnvironment: (payload) => deleteEnvironment(workspace, collection, payload),
|
|
101
|
+
upsertEnvironmentVariable: (payload) => upsertEnvironmentVariable(collection, payload),
|
|
102
|
+
deleteEnvironmentVariable: (payload) => deleteEnvironmentVariable(collection, payload),
|
|
103
|
+
};
|
|
78
104
|
};
|
|
79
|
-
//# sourceMappingURL=environment.js.map
|
package/dist/mutators/helpers.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
const getDocument = (store, documentName) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
export const getDocument = (store, documentName) => {
|
|
2
|
+
if (!store) {
|
|
3
|
+
return null;
|
|
4
|
+
}
|
|
5
|
+
const document = store.workspace.documents[documentName];
|
|
6
|
+
if (!document) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return document;
|
|
10
10
|
};
|
|
11
|
-
export {
|
|
12
|
-
getDocument
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=helpers.js.map
|
package/dist/mutators/index.js
CHANGED
|
@@ -1,55 +1,68 @@
|
|
|
1
|
-
import { authMutatorsFactory } from
|
|
2
|
-
import { cookieMutatorsFactory } from
|
|
3
|
-
import { documentMutatorsFactory } from
|
|
4
|
-
import { environmentMutatorsFactory } from
|
|
5
|
-
import { getDocument } from
|
|
6
|
-
import { operationMutatorsFactory } from
|
|
7
|
-
import { serverMutatorsFactory } from
|
|
8
|
-
import { tabsMutatorsFactory } from
|
|
9
|
-
import { tagMutatorsFactory } from
|
|
10
|
-
import { workspaceMutatorsFactory } from
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
server: serverMutatorsFactory({ document }),
|
|
19
|
-
tag: tagMutatorsFactory({ store }),
|
|
20
|
-
environment: environmentMutatorsFactory({ workspace: store?.workspace ?? null, collection: document })
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
const workspaceMutators = () => {
|
|
24
|
-
return {
|
|
25
|
-
cookie: cookieMutatorsFactory({ collection: store?.workspace ?? null }),
|
|
26
|
-
tabs: tabsMutatorsFactory({ workspace: store?.workspace ?? null }),
|
|
27
|
-
workspace: workspaceMutatorsFactory({ workspace: store?.workspace ?? null }),
|
|
28
|
-
environment: environmentMutatorsFactory({
|
|
29
|
-
workspace: store?.workspace ?? null,
|
|
30
|
-
collection: store?.workspace ?? null
|
|
31
|
-
})
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
return {
|
|
1
|
+
import { authMutatorsFactory } from '../mutators/auth.js';
|
|
2
|
+
import { cookieMutatorsFactory } from '../mutators/cookie.js';
|
|
3
|
+
import { documentMutatorsFactory } from '../mutators/document.js';
|
|
4
|
+
import { environmentMutatorsFactory } from '../mutators/environment.js';
|
|
5
|
+
import { getDocument } from '../mutators/helpers.js';
|
|
6
|
+
import { operationMutatorsFactory } from '../mutators/operation/index.js';
|
|
7
|
+
import { serverMutatorsFactory } from '../mutators/server.js';
|
|
8
|
+
import { tabsMutatorsFactory } from '../mutators/tabs.js';
|
|
9
|
+
import { tagMutatorsFactory } from '../mutators/tag.js';
|
|
10
|
+
import { workspaceMutatorsFactory } from '../mutators/workspace.js';
|
|
11
|
+
/**
|
|
12
|
+
* Generates a set of mutators for managing OpenAPI document and workspace state.
|
|
13
|
+
*
|
|
14
|
+
* @param store - The workspace store containing all documents and workspace-level data
|
|
15
|
+
* @returns An object with mutators for the workspace, the active document, and any named document
|
|
16
|
+
*/
|
|
17
|
+
export function generateClientMutators(store) {
|
|
35
18
|
/**
|
|
36
|
-
* Returns mutators for
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
* Returns mutators for the currently active document.
|
|
41
|
-
* Falls back to the first document if no active document is set.
|
|
19
|
+
* Returns mutators for a specific document by name.
|
|
20
|
+
*
|
|
21
|
+
* @param documentName - The name of the document to get mutators for
|
|
22
|
+
* @returns An object containing mutators for requests, request examples, security schemes, environments, and cookies
|
|
42
23
|
*/
|
|
43
|
-
|
|
24
|
+
const documentMutators = (document) => {
|
|
25
|
+
return {
|
|
26
|
+
auth: authMutatorsFactory({ store, document }),
|
|
27
|
+
cookie: cookieMutatorsFactory({ collection: document }),
|
|
28
|
+
document: documentMutatorsFactory({ document, store }),
|
|
29
|
+
operation: operationMutatorsFactory({ document, store }),
|
|
30
|
+
server: serverMutatorsFactory({ document }),
|
|
31
|
+
tag: tagMutatorsFactory({ store }),
|
|
32
|
+
environment: environmentMutatorsFactory({ workspace: store?.workspace ?? null, collection: document }),
|
|
33
|
+
};
|
|
34
|
+
};
|
|
44
35
|
/**
|
|
45
|
-
* Returns mutators for
|
|
36
|
+
* Returns mutators for the workspace-level configuration.
|
|
46
37
|
*
|
|
47
|
-
* @
|
|
38
|
+
* @returns An object containing mutators for environments and cookies at the workspace level
|
|
48
39
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
const workspaceMutators = () => {
|
|
41
|
+
return {
|
|
42
|
+
cookie: cookieMutatorsFactory({ collection: store?.workspace ?? null }),
|
|
43
|
+
tabs: tabsMutatorsFactory({ workspace: store?.workspace ?? null }),
|
|
44
|
+
workspace: workspaceMutatorsFactory({ workspace: store?.workspace ?? null }),
|
|
45
|
+
environment: environmentMutatorsFactory({
|
|
46
|
+
workspace: store?.workspace ?? null,
|
|
47
|
+
collection: store?.workspace ?? null,
|
|
48
|
+
}),
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
/**
|
|
53
|
+
* Returns mutators for the workspace-level configuration.
|
|
54
|
+
*/
|
|
55
|
+
workspace: () => workspaceMutators(),
|
|
56
|
+
/**
|
|
57
|
+
* Returns mutators for the currently active document.
|
|
58
|
+
* Falls back to the first document if no active document is set.
|
|
59
|
+
*/
|
|
60
|
+
active: () => documentMutators(store?.workspace.activeDocument ?? null),
|
|
61
|
+
/**
|
|
62
|
+
* Returns mutators for a specific document by name.
|
|
63
|
+
*
|
|
64
|
+
* @param name - The name of the document
|
|
65
|
+
*/
|
|
66
|
+
doc: (name) => documentMutators(getDocument(store, name)),
|
|
67
|
+
};
|
|
51
68
|
}
|
|
52
|
-
export {
|
|
53
|
-
generateClientMutators
|
|
54
|
-
};
|
|
55
|
-
//# sourceMappingURL=index.js.map
|