@scalar/workspace-store 0.40.2 → 0.40.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/client.d.ts +7 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +820 -681
- package/dist/entities/auth/index.js +96 -101
- package/dist/entities/auth/schema.d.ts +10 -0
- package/dist/entities/auth/schema.d.ts.map +1 -1
- package/dist/entities/auth/schema.js +42 -116
- package/dist/entities/history/index.js +80 -60
- package/dist/entities/history/schema.js +94 -88
- package/dist/events/bus.js +146 -93
- package/dist/events/definitions/analytics.js +1 -1
- package/dist/events/definitions/auth.js +1 -1
- package/dist/events/definitions/common.js +1 -1
- package/dist/events/definitions/cookie.js +1 -1
- package/dist/events/definitions/document.js +1 -1
- package/dist/events/definitions/environment.js +1 -1
- package/dist/events/definitions/hooks.js +1 -1
- package/dist/events/definitions/index.js +1 -1
- package/dist/events/definitions/meta.js +1 -1
- package/dist/events/definitions/operation.js +1 -1
- package/dist/events/definitions/server.js +1 -1
- package/dist/events/definitions/tabs.js +1 -1
- package/dist/events/definitions/tag.js +1 -1
- package/dist/events/definitions/ui.js +1 -1
- package/dist/events/definitions/workspace.js +1 -1
- package/dist/events/index.js +3 -9
- package/dist/events/listeners.js +20 -22
- package/dist/events/old-definitions.js +15 -12
- package/dist/helpers/deep-clone.js +33 -17
- package/dist/helpers/detect-changes-proxy.js +95 -57
- package/dist/helpers/general.js +78 -23
- package/dist/helpers/generate-unique-value.js +77 -45
- package/dist/helpers/get-fetch.js +12 -10
- package/dist/helpers/get-resolved-ref.js +11 -10
- package/dist/helpers/is-non-optional-security-requirement.js +3 -6
- package/dist/helpers/merge-object.js +71 -30
- package/dist/helpers/overrides-proxy.js +98 -58
- package/dist/helpers/unpack-proxy.js +60 -58
- package/dist/mutators/auth.js +358 -230
- package/dist/mutators/cookie.js +59 -42
- package/dist/mutators/document.js +104 -66
- package/dist/mutators/environment.js +97 -72
- package/dist/mutators/helpers.js +9 -13
- package/dist/mutators/index.js +62 -49
- package/dist/mutators/operation/body.js +88 -57
- package/dist/mutators/operation/extensions.js +20 -12
- package/dist/mutators/operation/helpers/fetch-request-to-har.js +144 -107
- package/dist/mutators/operation/helpers/fetch-response-to-har.js +143 -95
- package/dist/mutators/operation/helpers/get-parameter-position.js +12 -12
- package/dist/mutators/operation/helpers/har-to-operation.js +169 -132
- package/dist/mutators/operation/helpers/sync-path-parameters.js +109 -60
- package/dist/mutators/operation/history.js +60 -64
- package/dist/mutators/operation/index.js +25 -49
- package/dist/mutators/operation/operation.js +349 -240
- package/dist/mutators/operation/parameters.js +157 -93
- package/dist/mutators/server.js +213 -152
- package/dist/mutators/tabs.js +173 -130
- package/dist/mutators/tag.js +131 -97
- package/dist/mutators/workspace.js +72 -42
- package/dist/navigation/get-navigation-options.js +97 -84
- package/dist/navigation/helpers/get-openapi-object.js +46 -29
- package/dist/navigation/helpers/get-operation-entries.js +72 -32
- package/dist/navigation/helpers/get-parent-entry.js +16 -12
- package/dist/navigation/helpers/get-tag-entries.js +56 -29
- package/dist/navigation/helpers/get-tag.js +22 -23
- package/dist/navigation/helpers/get-x-keys.js +13 -9
- package/dist/navigation/helpers/traverse-description.js +90 -72
- package/dist/navigation/helpers/traverse-document.js +111 -98
- package/dist/navigation/helpers/traverse-examples.js +35 -31
- package/dist/navigation/helpers/traverse-paths.js +118 -106
- package/dist/navigation/helpers/traverse-schemas.js +65 -64
- package/dist/navigation/helpers/traverse-tags.js +158 -129
- package/dist/navigation/helpers/traverse-webhooks.js +96 -90
- package/dist/navigation/helpers/update-order-ids.js +59 -51
- package/dist/navigation/helpers/utils.js +71 -21
- package/dist/navigation/index.js +5 -13
- package/dist/navigation/types.js +1 -1
- package/dist/persistence/index.js +283 -285
- package/dist/persistence/indexdb.js +263 -126
- package/dist/plugins/bundler/helpers.js +21 -12
- package/dist/plugins/bundler/index.d.ts +7 -0
- package/dist/plugins/bundler/index.d.ts.map +1 -1
- package/dist/plugins/bundler/index.js +305 -171
- package/dist/plugins/client/index.js +1 -5
- package/dist/plugins/client/persistence.js +95 -90
- package/dist/resolve.js +18 -25
- package/dist/schemas/compose.js +6 -7
- package/dist/schemas/extensions/document/x-internal.js +3 -7
- package/dist/schemas/extensions/document/x-scalar-environments.js +16 -22
- package/dist/schemas/extensions/document/x-scalar-icon.js +3 -7
- package/dist/schemas/extensions/document/x-scalar-ignore.js +3 -7
- package/dist/schemas/extensions/document/x-scalar-is-dirty.js +21 -8
- package/dist/schemas/extensions/document/x-scalar-original-document-hash.js +17 -8
- package/dist/schemas/extensions/document/x-scalar-registry-meta.js +15 -21
- package/dist/schemas/extensions/document/x-scalar-sdk-installation.js +5 -13
- package/dist/schemas/extensions/document/x-scalar-watch-mode.js +4 -8
- package/dist/schemas/extensions/document/x-tags.js +3 -7
- package/dist/schemas/extensions/example/x-disabled.js +17 -7
- package/dist/schemas/extensions/general/x-scalar-active-environment.js +4 -7
- package/dist/schemas/extensions/general/x-scalar-cookies.js +9 -14
- package/dist/schemas/extensions/general/x-scalar-order.js +8 -7
- package/dist/schemas/extensions/operation/index.js +4 -23
- package/dist/schemas/extensions/operation/x-badge.js +42 -50
- package/dist/schemas/extensions/operation/x-code-samples.js +8 -12
- package/dist/schemas/extensions/operation/x-draft-examples.js +3 -7
- package/dist/schemas/extensions/operation/x-post-response.js +18 -7
- package/dist/schemas/extensions/operation/x-scalar-disable-parameters.js +57 -13
- package/dist/schemas/extensions/operation/x-scalar-selected-content-type.js +9 -7
- package/dist/schemas/extensions/operation/x-scalar-stability.js +15 -14
- package/dist/schemas/extensions/parameter/x-global.js +12 -7
- package/dist/schemas/extensions/schema/x-additional-properties-name.js +10 -7
- package/dist/schemas/extensions/schema/x-enum-descriptions.js +17 -12
- package/dist/schemas/extensions/schema/x-enum-varnames.js +21 -8
- package/dist/schemas/extensions/schema/x-examples.js +3 -7
- package/dist/schemas/extensions/schema/x-variable.js +3 -7
- package/dist/schemas/extensions/security/index.js +1 -1
- package/dist/schemas/extensions/security/x-default-scopes.js +16 -7
- package/dist/schemas/extensions/security/x-scalar-credentials-location.js +16 -7
- package/dist/schemas/extensions/security/x-scalar-security-body.js +14 -7
- package/dist/schemas/extensions/security/x-scalar-security-query.js +14 -7
- package/dist/schemas/extensions/security/x-scalar-security-secrets.js +66 -37
- package/dist/schemas/extensions/security/x-tokenName.js +11 -7
- package/dist/schemas/extensions/security/x-use-pkce.js +6 -10
- package/dist/schemas/extensions/server/x-scalar-selected-server.js +3 -7
- package/dist/schemas/extensions/tag/index.js +1 -1
- package/dist/schemas/extensions/tag/x-display-name.js +11 -7
- package/dist/schemas/extensions/tag/x-tag-groups.js +13 -15
- package/dist/schemas/extensions/workspace/index.js +2 -11
- package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js +13 -7
- package/dist/schemas/extensions/workspace/x-scalar-tabs.js +15 -13
- package/dist/schemas/extensions.js +11 -15
- package/dist/schemas/inmemory-workspace.d.ts +6 -0
- package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
- package/dist/schemas/inmemory-workspace.js +13 -21
- package/dist/schemas/navigation.js +48 -85
- package/dist/schemas/reference-config/appearance.js +15 -22
- package/dist/schemas/reference-config/features.js +14 -21
- package/dist/schemas/reference-config/index.d.ts +2 -0
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/index.js +42 -44
- package/dist/schemas/reference-config/meta.js +11 -18
- package/dist/schemas/reference-config/routing.js +7 -14
- package/dist/schemas/reference-config/settings.d.ts +2 -0
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.js +10 -17
- package/dist/schemas/typebox-coerce.js +23 -6
- package/dist/schemas/v3.1/strict/callback.js +6 -12
- package/dist/schemas/v3.1/strict/components.js +26 -48
- package/dist/schemas/v3.1/strict/contact.js +9 -12
- package/dist/schemas/v3.1/strict/discriminator.js +11 -10
- package/dist/schemas/v3.1/strict/encoding.js +15 -12
- package/dist/schemas/v3.1/strict/example.js +11 -13
- package/dist/schemas/v3.1/strict/external-documentation.js +7 -10
- package/dist/schemas/v3.1/strict/header.js +27 -28
- package/dist/schemas/v3.1/strict/info.js +10 -16
- package/dist/schemas/v3.1/strict/license.js +9 -12
- package/dist/schemas/v3.1/strict/link.js +22 -19
- package/dist/schemas/v3.1/strict/media-type.js +17 -16
- package/dist/schemas/v3.1/strict/oauth-flow.js +28 -62
- package/dist/schemas/v3.1/strict/oauthflows.js +14 -20
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +70 -0
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.js +126 -210
- package/dist/schemas/v3.1/strict/operation.js +16 -43
- package/dist/schemas/v3.1/strict/parameter.d.ts +6 -0
- package/dist/schemas/v3.1/strict/parameter.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/parameter.js +29 -35
- package/dist/schemas/v3.1/strict/path-item.js +36 -40
- package/dist/schemas/v3.1/strict/paths.js +8 -11
- package/dist/schemas/v3.1/strict/ref-definitions.js +76 -100
- package/dist/schemas/v3.1/strict/reference.js +18 -21
- package/dist/schemas/v3.1/strict/request-body.js +8 -16
- package/dist/schemas/v3.1/strict/response.js +12 -16
- package/dist/schemas/v3.1/strict/responses.js +13 -11
- package/dist/schemas/v3.1/strict/schema.js +149 -157
- package/dist/schemas/v3.1/strict/security-requirement.js +13 -12
- package/dist/schemas/v3.1/strict/security-scheme.js +29 -41
- package/dist/schemas/v3.1/strict/server-variable.js +9 -12
- package/dist/schemas/v3.1/strict/server.js +10 -13
- package/dist/schemas/v3.1/strict/tag.js +11 -20
- package/dist/schemas/v3.1/strict/type-guards.js +20 -20
- package/dist/schemas/v3.1/strict/xml.js +17 -16
- package/dist/schemas/workspace-specification/index.js +11 -23
- package/dist/schemas/workspace-specification/info.js +4 -8
- package/dist/schemas/workspace.d.ts +6 -0
- package/dist/schemas/workspace.d.ts.map +1 -1
- package/dist/schemas/workspace.js +25 -51
- package/dist/schemas.js +2 -6
- package/dist/server.js +286 -176
- package/dist/workspace-plugin.js +1 -1
- package/package.json +13 -19
- package/dist/client.js.map +0 -7
- package/dist/entities/auth/index.js.map +0 -7
- package/dist/entities/auth/schema.js.map +0 -7
- package/dist/entities/history/index.js.map +0 -7
- package/dist/entities/history/schema.js.map +0 -7
- package/dist/events/bus.js.map +0 -7
- package/dist/events/definitions/analytics.js.map +0 -7
- package/dist/events/definitions/auth.js.map +0 -7
- package/dist/events/definitions/common.js.map +0 -7
- package/dist/events/definitions/cookie.js.map +0 -7
- package/dist/events/definitions/document.js.map +0 -7
- package/dist/events/definitions/environment.js.map +0 -7
- package/dist/events/definitions/hooks.js.map +0 -7
- package/dist/events/definitions/index.js.map +0 -7
- package/dist/events/definitions/meta.js.map +0 -7
- package/dist/events/definitions/operation.js.map +0 -7
- package/dist/events/definitions/server.js.map +0 -7
- package/dist/events/definitions/tabs.js.map +0 -7
- package/dist/events/definitions/tag.js.map +0 -7
- package/dist/events/definitions/ui.js.map +0 -7
- package/dist/events/definitions/workspace.js.map +0 -7
- package/dist/events/index.js.map +0 -7
- package/dist/events/listeners.js.map +0 -7
- package/dist/events/old-definitions.js.map +0 -7
- package/dist/helpers/apply-selective-updates.d.ts +0 -19
- package/dist/helpers/apply-selective-updates.d.ts.map +0 -1
- package/dist/helpers/apply-selective-updates.js +0 -37
- package/dist/helpers/apply-selective-updates.js.map +0 -7
- package/dist/helpers/deep-clone.js.map +0 -7
- package/dist/helpers/detect-changes-proxy.js.map +0 -7
- package/dist/helpers/general.js.map +0 -7
- package/dist/helpers/generate-unique-value.js.map +0 -7
- package/dist/helpers/get-fetch.js.map +0 -7
- package/dist/helpers/get-resolved-ref.js.map +0 -7
- package/dist/helpers/is-non-optional-security-requirement.js.map +0 -7
- package/dist/helpers/merge-object.js.map +0 -7
- package/dist/helpers/overrides-proxy.js.map +0 -7
- package/dist/helpers/unpack-proxy.js.map +0 -7
- package/dist/mutators/auth.js.map +0 -7
- package/dist/mutators/cookie.js.map +0 -7
- package/dist/mutators/document.js.map +0 -7
- package/dist/mutators/environment.js.map +0 -7
- package/dist/mutators/helpers.js.map +0 -7
- package/dist/mutators/index.js.map +0 -7
- package/dist/mutators/operation/body.js.map +0 -7
- package/dist/mutators/operation/extensions.js.map +0 -7
- package/dist/mutators/operation/helpers/fetch-request-to-har.js.map +0 -7
- package/dist/mutators/operation/helpers/fetch-response-to-har.js.map +0 -7
- package/dist/mutators/operation/helpers/get-parameter-position.js.map +0 -7
- package/dist/mutators/operation/helpers/har-to-operation.js.map +0 -7
- package/dist/mutators/operation/helpers/sync-path-parameters.js.map +0 -7
- package/dist/mutators/operation/history.js.map +0 -7
- package/dist/mutators/operation/index.js.map +0 -7
- package/dist/mutators/operation/operation.js.map +0 -7
- package/dist/mutators/operation/parameters.js.map +0 -7
- package/dist/mutators/server.js.map +0 -7
- package/dist/mutators/tabs.js.map +0 -7
- package/dist/mutators/tag.js.map +0 -7
- package/dist/mutators/workspace.js.map +0 -7
- package/dist/navigation/get-navigation-options.js.map +0 -7
- package/dist/navigation/helpers/get-openapi-object.js.map +0 -7
- package/dist/navigation/helpers/get-operation-entries.js.map +0 -7
- package/dist/navigation/helpers/get-parent-entry.js.map +0 -7
- package/dist/navigation/helpers/get-tag-entries.js.map +0 -7
- package/dist/navigation/helpers/get-tag.js.map +0 -7
- package/dist/navigation/helpers/get-x-keys.js.map +0 -7
- package/dist/navigation/helpers/traverse-description.js.map +0 -7
- package/dist/navigation/helpers/traverse-document.js.map +0 -7
- package/dist/navigation/helpers/traverse-examples.js.map +0 -7
- package/dist/navigation/helpers/traverse-paths.js.map +0 -7
- package/dist/navigation/helpers/traverse-schemas.js.map +0 -7
- package/dist/navigation/helpers/traverse-tags.js.map +0 -7
- package/dist/navigation/helpers/traverse-webhooks.js.map +0 -7
- package/dist/navigation/helpers/update-order-ids.js.map +0 -7
- package/dist/navigation/helpers/utils.js.map +0 -7
- package/dist/navigation/index.js.map +0 -7
- package/dist/navigation/types.js.map +0 -7
- package/dist/persistence/index.js.map +0 -7
- package/dist/persistence/indexdb.js.map +0 -7
- package/dist/plugins/bundler/helpers.js.map +0 -7
- package/dist/plugins/bundler/index.js.map +0 -7
- package/dist/plugins/client/index.js.map +0 -7
- package/dist/plugins/client/persistence.js.map +0 -7
- package/dist/resolve.js.map +0 -7
- package/dist/schemas/compose.js.map +0 -7
- package/dist/schemas/extensions/document/x-internal.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-environments.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-icon.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-ignore.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-is-dirty.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-original-document-hash.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-registry-meta.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-sdk-installation.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-watch-mode.js.map +0 -7
- package/dist/schemas/extensions/document/x-tags.js.map +0 -7
- package/dist/schemas/extensions/example/x-disabled.js.map +0 -7
- package/dist/schemas/extensions/general/x-scalar-active-environment.js.map +0 -7
- package/dist/schemas/extensions/general/x-scalar-cookies.js.map +0 -7
- package/dist/schemas/extensions/general/x-scalar-order.js.map +0 -7
- package/dist/schemas/extensions/operation/index.js.map +0 -7
- package/dist/schemas/extensions/operation/x-badge.js.map +0 -7
- package/dist/schemas/extensions/operation/x-code-samples.js.map +0 -7
- package/dist/schemas/extensions/operation/x-draft-examples.js.map +0 -7
- package/dist/schemas/extensions/operation/x-post-response.js.map +0 -7
- package/dist/schemas/extensions/operation/x-scalar-disable-parameters.js.map +0 -7
- package/dist/schemas/extensions/operation/x-scalar-selected-content-type.js.map +0 -7
- package/dist/schemas/extensions/operation/x-scalar-stability.js.map +0 -7
- package/dist/schemas/extensions/parameter/x-global.js.map +0 -7
- package/dist/schemas/extensions/schema/x-additional-properties-name.js.map +0 -7
- package/dist/schemas/extensions/schema/x-enum-descriptions.js.map +0 -7
- package/dist/schemas/extensions/schema/x-enum-varnames.js.map +0 -7
- package/dist/schemas/extensions/schema/x-examples.js.map +0 -7
- package/dist/schemas/extensions/schema/x-variable.js.map +0 -7
- package/dist/schemas/extensions/security/index.js.map +0 -7
- package/dist/schemas/extensions/security/x-default-scopes.js.map +0 -7
- package/dist/schemas/extensions/security/x-scalar-credentials-location.js.map +0 -7
- package/dist/schemas/extensions/security/x-scalar-security-body.js.map +0 -7
- package/dist/schemas/extensions/security/x-scalar-security-query.js.map +0 -7
- package/dist/schemas/extensions/security/x-scalar-security-secrets.js.map +0 -7
- package/dist/schemas/extensions/security/x-tokenName.js.map +0 -7
- package/dist/schemas/extensions/security/x-use-pkce.js.map +0 -7
- package/dist/schemas/extensions/server/x-scalar-selected-server.js.map +0 -7
- package/dist/schemas/extensions/tag/index.js.map +0 -7
- package/dist/schemas/extensions/tag/x-display-name.js.map +0 -7
- package/dist/schemas/extensions/tag/x-tag-groups.js.map +0 -7
- package/dist/schemas/extensions/workspace/index.js.map +0 -7
- package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js.map +0 -7
- package/dist/schemas/extensions/workspace/x-scalar-tabs.js.map +0 -7
- package/dist/schemas/extensions.js.map +0 -7
- package/dist/schemas/inmemory-workspace.js.map +0 -7
- package/dist/schemas/navigation.js.map +0 -7
- package/dist/schemas/reference-config/appearance.js.map +0 -7
- package/dist/schemas/reference-config/features.js.map +0 -7
- package/dist/schemas/reference-config/index.js.map +0 -7
- package/dist/schemas/reference-config/meta.js.map +0 -7
- package/dist/schemas/reference-config/routing.js.map +0 -7
- package/dist/schemas/reference-config/settings.js.map +0 -7
- package/dist/schemas/typebox-coerce.js.map +0 -7
- package/dist/schemas/v3.1/strict/callback.js.map +0 -7
- package/dist/schemas/v3.1/strict/components.js.map +0 -7
- package/dist/schemas/v3.1/strict/contact.js.map +0 -7
- package/dist/schemas/v3.1/strict/discriminator.js.map +0 -7
- package/dist/schemas/v3.1/strict/encoding.js.map +0 -7
- package/dist/schemas/v3.1/strict/example.js.map +0 -7
- package/dist/schemas/v3.1/strict/external-documentation.js.map +0 -7
- package/dist/schemas/v3.1/strict/header.js.map +0 -7
- package/dist/schemas/v3.1/strict/info.js.map +0 -7
- package/dist/schemas/v3.1/strict/license.js.map +0 -7
- package/dist/schemas/v3.1/strict/link.js.map +0 -7
- package/dist/schemas/v3.1/strict/media-type.js.map +0 -7
- package/dist/schemas/v3.1/strict/oauth-flow.js.map +0 -7
- package/dist/schemas/v3.1/strict/oauthflows.js.map +0 -7
- package/dist/schemas/v3.1/strict/openapi-document.js.map +0 -7
- package/dist/schemas/v3.1/strict/operation.js.map +0 -7
- package/dist/schemas/v3.1/strict/parameter.js.map +0 -7
- package/dist/schemas/v3.1/strict/path-item.js.map +0 -7
- package/dist/schemas/v3.1/strict/paths.js.map +0 -7
- package/dist/schemas/v3.1/strict/ref-definitions.js.map +0 -7
- package/dist/schemas/v3.1/strict/reference.js.map +0 -7
- package/dist/schemas/v3.1/strict/request-body.js.map +0 -7
- package/dist/schemas/v3.1/strict/response.js.map +0 -7
- package/dist/schemas/v3.1/strict/responses.js.map +0 -7
- package/dist/schemas/v3.1/strict/schema.js.map +0 -7
- package/dist/schemas/v3.1/strict/security-requirement.js.map +0 -7
- package/dist/schemas/v3.1/strict/security-scheme.js.map +0 -7
- package/dist/schemas/v3.1/strict/server-variable.js.map +0 -7
- package/dist/schemas/v3.1/strict/server.js.map +0 -7
- package/dist/schemas/v3.1/strict/tag.js.map +0 -7
- package/dist/schemas/v3.1/strict/type-guards.js.map +0 -7
- package/dist/schemas/v3.1/strict/xml.js.map +0 -7
- package/dist/schemas/workspace-specification/index.js.map +0 -7
- package/dist/schemas/workspace-specification/info.js.map +0 -7
- package/dist/schemas/workspace.js.map +0 -7
- package/dist/schemas.js.map +0 -7
- package/dist/server.js.map +0 -7
- package/dist/workspace-plugin.js.map +0 -7
|
@@ -1,133 +1,270 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Initializes and manages an IndexedDB database connection for table-based persistence.
|
|
3
|
+
*
|
|
4
|
+
* @param name - The database name. Defaults to 'scalar-workspace-store'.
|
|
5
|
+
* @param tables - Table definitions: the tables to create and their key schemas.
|
|
6
|
+
* @param version - The database version. Bump this to trigger upgrades (default: 1).
|
|
7
|
+
* @param migrations - Optional migration steps to run for version upgrades.
|
|
8
|
+
* @returns An object with the following methods:
|
|
9
|
+
* - `get(tableName)` — Get a wrapper to interact with the object store for the given table name.
|
|
10
|
+
* - `closeDatabase()` — Closes the database connection.
|
|
11
|
+
*
|
|
12
|
+
* Example usage:
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { Type } from '@scalar/typebox'
|
|
15
|
+
* import { createIndexDbConnection } from './indexdb.js'
|
|
16
|
+
*
|
|
17
|
+
* // Define a schema for a user
|
|
18
|
+
* const UserSchema = Type.Object({
|
|
19
|
+
* id: Type.String(),
|
|
20
|
+
* name: Type.String(),
|
|
21
|
+
* age: Type.Number(),
|
|
22
|
+
* })
|
|
23
|
+
*
|
|
24
|
+
* // Define tables in the database
|
|
25
|
+
* const dbConfig = {
|
|
26
|
+
* users: {
|
|
27
|
+
* schema: UserSchema,
|
|
28
|
+
* index: ['id'] as const,
|
|
29
|
+
* },
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* // Open the database connection and get table API
|
|
33
|
+
* const { get, closeDatabase } = await createIndexDbConnection({
|
|
34
|
+
* name: 'my-app-db',
|
|
35
|
+
* tables: dbConfig,
|
|
36
|
+
* version: 1,
|
|
37
|
+
* })
|
|
38
|
+
*
|
|
39
|
+
* // Get a strongly-typed users table API
|
|
40
|
+
* const usersTable = get('users')
|
|
41
|
+
*
|
|
42
|
+
* // Add a user
|
|
43
|
+
* await usersTable.addItem({ id: 'user-1' }, { name: 'Alice', age: 25 })
|
|
44
|
+
*
|
|
45
|
+
* // Retrieve a user by id
|
|
46
|
+
* const user = await usersTable.getItem({ id: 'user-1' })
|
|
47
|
+
*
|
|
48
|
+
* // Don't forget to close the database when done!
|
|
49
|
+
* closeDatabase()
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export const createIndexDbConnection = async ({ name = 'scalar-workspace-store', tables, version = 1, migrations = [], }) => {
|
|
53
|
+
const db = indexedDB.open(name, version);
|
|
54
|
+
db.onupgradeneeded = (e) => {
|
|
55
|
+
// Initial setup of object stores
|
|
56
|
+
if (e.oldVersion < 1) {
|
|
57
|
+
const database = db.result;
|
|
58
|
+
// Initialize all the tables
|
|
59
|
+
Object.entries(tables).forEach(([name, options]) => {
|
|
60
|
+
if (!database.objectStoreNames.contains(name)) {
|
|
61
|
+
const objectStore = database.createObjectStore(name, {
|
|
62
|
+
keyPath: options.keyPath.length === 1 ? options.keyPath[0] : options.keyPath,
|
|
63
|
+
});
|
|
64
|
+
// Create any indexes for the object store
|
|
65
|
+
Object.entries(options.indexes ?? {}).forEach(([indexName, indexPath]) => {
|
|
66
|
+
objectStore.createIndex(indexName, indexPath);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
});
|
|
19
70
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
71
|
+
// Run any future migrations here
|
|
72
|
+
migrations.forEach((migration) => {
|
|
73
|
+
if (e.oldVersion < migration.version) {
|
|
74
|
+
migration.exec(db.result, e);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
await new Promise((resolve, reject) => {
|
|
79
|
+
db.onsuccess = () => resolve(true);
|
|
80
|
+
db.onerror = () => reject(db.error);
|
|
26
81
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
closeDatabase: () => {
|
|
37
|
-
db.result.close();
|
|
38
|
-
}
|
|
39
|
-
};
|
|
82
|
+
return {
|
|
83
|
+
get: (name) => {
|
|
84
|
+
return createTableWrapper(name, db.result);
|
|
85
|
+
},
|
|
86
|
+
closeDatabase: () => {
|
|
87
|
+
db.result.close();
|
|
88
|
+
},
|
|
89
|
+
};
|
|
40
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* Utility wrapper for interacting with an IndexedDB object store, typed by the schema.
|
|
93
|
+
*
|
|
94
|
+
* Usage example:
|
|
95
|
+
* ```
|
|
96
|
+
* // Define a TypeBox schema for users
|
|
97
|
+
* const UserSchema = Type.Object({
|
|
98
|
+
* id: Type.String(),
|
|
99
|
+
* name: Type.String(),
|
|
100
|
+
* age: Type.Number(),
|
|
101
|
+
* })
|
|
102
|
+
*
|
|
103
|
+
* // Open or create the users table
|
|
104
|
+
* const usersTable = createTableWrapper<typeof UserSchema, 'id'>('users', openDatabase)
|
|
105
|
+
*
|
|
106
|
+
* // Add a user
|
|
107
|
+
await usersTable.addItem({ id: 'user-1' }, { name: 'Alice', age: 24 })
|
|
108
|
+
*
|
|
109
|
+
* // Get a user by id
|
|
110
|
+
* const alic = await usersTable.getItem({ id: 'user-1' })
|
|
111
|
+
*
|
|
112
|
+
* // Get users with a partial key (use [] if no composite key)
|
|
113
|
+
* const users = await usersTable.getRange(['user-1'])
|
|
114
|
+
*
|
|
115
|
+
* // Get all users
|
|
116
|
+
* const allUsers = await usersTable.getAll()
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @template T TypeBox schema type for objects in the store
|
|
120
|
+
* @template K Key property names that compose the primary key
|
|
121
|
+
*
|
|
122
|
+
* @param name - Object store name
|
|
123
|
+
* @param getDb - Function returning a Promise for the IDBDatabase
|
|
124
|
+
* @returns Methods to interact with the object store
|
|
125
|
+
*/
|
|
41
126
|
function createTableWrapper(name, db) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Gets the object store from the latest DB connection, for the given transaction mode.
|
|
129
|
+
*/
|
|
130
|
+
const getStore = (mode) => {
|
|
131
|
+
const tx = db.transaction(name, mode);
|
|
132
|
+
return tx.objectStore(name);
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Adds or updates an item in the store.
|
|
136
|
+
* @param key - The primary key values, as { key1, key2 }
|
|
137
|
+
* @param value - The value for the other properties, omitting keys
|
|
138
|
+
* @returns The full inserted/updated object
|
|
139
|
+
*/
|
|
140
|
+
async function addItem(key, value) {
|
|
141
|
+
const store = getStore('readwrite');
|
|
142
|
+
const finalValue = { ...value, ...key };
|
|
143
|
+
await requestAsPromise(store.put(finalValue));
|
|
144
|
+
return finalValue;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Retrieves a single item by composite key.
|
|
148
|
+
* @param key - Key values. For a single key: { id: '...' }
|
|
149
|
+
* @returns The found object or undefined
|
|
150
|
+
*/
|
|
151
|
+
function getItem(key) {
|
|
152
|
+
const store = getStore('readonly');
|
|
153
|
+
const keyValues = Object.values(key);
|
|
154
|
+
// For single keys, pass value directly; for compound keys, pass array
|
|
155
|
+
const keyToUse = keyValues.length === 1 ? keyValues[0] : keyValues;
|
|
156
|
+
return requestAsPromise(store.get(keyToUse));
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Returns all records matching a partial (prefix) key. Use for composite keys.
|
|
160
|
+
* For non-compound keys, pass single-element array: getRange(['some-id'])
|
|
161
|
+
* For prefix search, pass subset of key parts.
|
|
162
|
+
* @param partialKey - Array of partial key values
|
|
163
|
+
* @returns Matching objects
|
|
164
|
+
*
|
|
165
|
+
* Example (composite [a,b]):
|
|
166
|
+
* getRange(['foo']) // All with a === 'foo'
|
|
167
|
+
* getRange(['foo', 'bar']) // All with a === 'foo' and b === 'bar'
|
|
168
|
+
*/
|
|
169
|
+
function getRange(partialKey, indexName) {
|
|
170
|
+
const store = getStore('readonly');
|
|
171
|
+
const objectStoreOrIndex = indexName ? store.index(indexName) : store;
|
|
172
|
+
const results = [];
|
|
173
|
+
// Construct upper bound to match all keys starting with partialKey
|
|
174
|
+
const upperBound = [...partialKey];
|
|
175
|
+
upperBound.push([]); // ensures upper bound includes all keys with this prefix
|
|
176
|
+
const range = IDBKeyRange.bound(partialKey, upperBound, false, true);
|
|
177
|
+
return new Promise((resolve, reject) => {
|
|
178
|
+
const request = objectStoreOrIndex.openCursor(range);
|
|
179
|
+
request.onerror = () => reject(request.error);
|
|
180
|
+
request.onsuccess = (event) => {
|
|
181
|
+
const cursor = event.target.result;
|
|
182
|
+
if (cursor) {
|
|
183
|
+
results.push(cursor.value);
|
|
184
|
+
cursor.continue();
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
resolve(results);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Deletes an item from the store by its composite key.
|
|
194
|
+
* @param key - Key values. For a single key: { id: '...' }
|
|
195
|
+
* @returns void
|
|
196
|
+
*/
|
|
197
|
+
async function deleteItem(key) {
|
|
198
|
+
const store = getStore('readwrite');
|
|
199
|
+
const keyValues = Object.values(key);
|
|
200
|
+
// For single keys, pass value directly; for compound keys, pass array
|
|
201
|
+
const keyToUse = keyValues.length === 1 ? keyValues[0] : keyValues;
|
|
202
|
+
await requestAsPromise(store.delete(keyToUse));
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Deletes all records matching a partial (prefix) key. Use for composite keys.
|
|
206
|
+
* For non-compound keys, pass single-element array: deleteRange(['some-id'])
|
|
207
|
+
* For prefix deletion, pass subset of key parts.
|
|
208
|
+
* @param partialKey - Array of partial key values
|
|
209
|
+
* @returns Number of deleted items
|
|
210
|
+
*
|
|
211
|
+
* Example (composite [a,b]):
|
|
212
|
+
* deleteRange(['foo']) // Delete all with a === 'foo'
|
|
213
|
+
* deleteRange(['foo', 'bar']) // Delete all with a === 'foo' and b === 'bar'
|
|
214
|
+
*/
|
|
215
|
+
function deleteRange(partialKey) {
|
|
216
|
+
const store = getStore('readwrite');
|
|
217
|
+
let deletedCount = 0;
|
|
218
|
+
// Construct upper bound to match all keys starting with partialKey
|
|
219
|
+
const upperBound = [...partialKey];
|
|
220
|
+
upperBound.push([]); // ensures upper bound includes all keys with this prefix
|
|
221
|
+
const range = IDBKeyRange.bound(partialKey, upperBound, false, true);
|
|
222
|
+
return new Promise((resolve, reject) => {
|
|
223
|
+
const request = store.openCursor(range);
|
|
224
|
+
request.onerror = () => reject(request.error);
|
|
225
|
+
request.onsuccess = (event) => {
|
|
226
|
+
const cursor = event.target.result;
|
|
227
|
+
if (cursor) {
|
|
228
|
+
cursor.delete();
|
|
229
|
+
deletedCount++;
|
|
230
|
+
cursor.continue();
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
resolve(deletedCount);
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Deletes all items from the table.
|
|
240
|
+
* @returns void
|
|
241
|
+
*/
|
|
242
|
+
async function deleteAll() {
|
|
243
|
+
const store = getStore('readwrite');
|
|
244
|
+
await requestAsPromise(store.clear());
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Retrieves all items from the table.
|
|
248
|
+
* @returns Array of all objects in the store
|
|
249
|
+
*/
|
|
250
|
+
function getAll() {
|
|
251
|
+
const store = getStore('readonly');
|
|
252
|
+
return requestAsPromise(store.getAll());
|
|
253
|
+
}
|
|
254
|
+
return {
|
|
255
|
+
addItem,
|
|
256
|
+
getItem,
|
|
257
|
+
getRange,
|
|
258
|
+
deleteItem,
|
|
259
|
+
deleteRange,
|
|
260
|
+
getAll,
|
|
261
|
+
deleteAll,
|
|
262
|
+
};
|
|
123
263
|
}
|
|
264
|
+
// ---- Utility ----
|
|
124
265
|
function requestAsPromise(req) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
266
|
+
return new Promise((resolve, reject) => {
|
|
267
|
+
req.onsuccess = () => resolve(req.result);
|
|
268
|
+
req.onerror = () => reject(req.error);
|
|
269
|
+
});
|
|
129
270
|
}
|
|
130
|
-
export {
|
|
131
|
-
createIndexDbConnection
|
|
132
|
-
};
|
|
133
|
-
//# sourceMappingURL=indexdb.js.map
|
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
import { getValueAtPath } from
|
|
2
|
-
import { getSegmentsFromPath } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { getValueAtPath } from '@scalar/helpers/object/get-value-at-path';
|
|
2
|
+
import { getSegmentsFromPath } from '@scalar/json-magic/helpers/get-segments-from-path';
|
|
3
|
+
/**
|
|
4
|
+
* Recursively resolves the value behind a $ref pointer within the current document tree.
|
|
5
|
+
* For example, given a node with { $ref: '#/some/path' }, this will locate and return
|
|
6
|
+
* the referenced node, following the $ref chain if necessary.
|
|
7
|
+
*
|
|
8
|
+
* @param node - The node that may be a $ref object. If not, returns the node as is.
|
|
9
|
+
* @returns The resolved node if a $ref chain exists, otherwise the original node.
|
|
10
|
+
*/
|
|
11
|
+
export const getResolvedRef = (node, context) => {
|
|
12
|
+
if (node &&
|
|
13
|
+
typeof node === 'object' &&
|
|
14
|
+
'$ref' in node &&
|
|
15
|
+
typeof node['$ref'] === 'string' &&
|
|
16
|
+
node['$ref'].startsWith('#')) {
|
|
17
|
+
const segments = getSegmentsFromPath(node['$ref'].slice(1));
|
|
18
|
+
return getResolvedRef(getValueAtPath(context.rootNode, segments), context);
|
|
19
|
+
}
|
|
20
|
+
// If this node isn't a $ref, return it as the resolved value
|
|
21
|
+
return node;
|
|
9
22
|
};
|
|
10
|
-
export {
|
|
11
|
-
getResolvedRef
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=helpers.js.map
|
|
@@ -104,4 +104,11 @@ export declare const normalizeRefs: () => LifecyclePlugin;
|
|
|
104
104
|
* even after bundling or other transformations.
|
|
105
105
|
*/
|
|
106
106
|
export declare const syncPathParameters: () => LifecyclePlugin;
|
|
107
|
+
/**
|
|
108
|
+
* Lifecycle plugin to remove extra Scalar internal keys from nodes.
|
|
109
|
+
*
|
|
110
|
+
* This plugin is used to remove extra Scalar internal keys from nodes during the bundling process.
|
|
111
|
+
* These keys are used for internal purposes and are not needed in the final bundled document.
|
|
112
|
+
*/
|
|
113
|
+
export declare const removeExtraScalarKeys: () => LifecyclePlugin;
|
|
107
114
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAShE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAO,eAahC,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,QAAO,eA+BxC,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,QAAO,eAwCjC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,mBAAmB,QAAO,eAuBtC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,oBAAoB,QAAO,eAuBvC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAO,eAmBhC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,QAAO,eAkFrC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAShE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAO,eAahC,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,QAAO,eA+BxC,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,QAAO,eAwCjC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,mBAAmB,QAAO,eAuBtC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,oBAAoB,QAAO,eAuBvC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAO,eAmBhC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,QAAO,eAkFrC,CAAA;AAKD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAAO,eAaxC,CAAA"}
|