@frontmcp/sdk 0.4.1 → 0.5.1
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/README.md +30 -18
- package/package.json +20 -5
- package/src/app/app.registry.d.ts +3 -2
- package/src/app/app.registry.js +3 -1
- package/src/app/app.registry.js.map +1 -1
- package/src/app/instances/app.local.instance.js +2 -2
- package/src/app/instances/app.local.instance.js.map +1 -1
- package/src/auth/auth.registry.d.ts +34 -2
- package/src/auth/auth.registry.js +162 -24
- package/src/auth/auth.registry.js.map +1 -1
- package/src/auth/auth.utils.js +8 -9
- package/src/auth/auth.utils.js.map +1 -1
- package/src/auth/authorization/authorization.class.d.ts +125 -0
- package/src/auth/authorization/authorization.class.js +224 -0
- package/src/auth/authorization/authorization.class.js.map +1 -0
- package/src/auth/authorization/authorization.types.d.ts +300 -0
- package/src/auth/authorization/authorization.types.js +79 -0
- package/src/auth/authorization/authorization.types.js.map +1 -0
- package/src/auth/authorization/index.d.ts +5 -0
- package/src/auth/authorization/index.js +19 -0
- package/src/auth/authorization/index.js.map +1 -0
- package/src/auth/authorization/orchestrated.authorization.d.ts +242 -0
- package/src/auth/authorization/orchestrated.authorization.js +306 -0
- package/src/auth/authorization/orchestrated.authorization.js.map +1 -0
- package/src/auth/authorization/public.authorization.d.ts +91 -0
- package/src/auth/authorization/public.authorization.js +132 -0
- package/src/auth/authorization/public.authorization.js.map +1 -0
- package/src/auth/authorization/transparent.authorization.d.ts +130 -0
- package/src/auth/authorization/transparent.authorization.js +147 -0
- package/src/auth/authorization/transparent.authorization.js.map +1 -0
- package/src/auth/consent/consent.types.d.ts +111 -0
- package/src/auth/consent/consent.types.js +119 -0
- package/src/auth/consent/consent.types.js.map +1 -0
- package/src/auth/consent/index.d.ts +1 -0
- package/src/auth/consent/index.js +13 -0
- package/src/auth/consent/index.js.map +1 -0
- package/src/auth/detection/auth-provider-detection.d.ts +84 -0
- package/src/auth/detection/auth-provider-detection.js +230 -0
- package/src/auth/detection/auth-provider-detection.js.map +1 -0
- package/src/auth/detection/index.d.ts +1 -0
- package/src/auth/detection/index.js +15 -0
- package/src/auth/detection/index.js.map +1 -0
- package/src/auth/flows/auth.verify.flow.d.ts +110 -0
- package/src/auth/flows/auth.verify.flow.js +379 -0
- package/src/auth/flows/auth.verify.flow.js.map +1 -0
- package/src/auth/flows/oauth.authorize.flow.d.ts +118 -164
- package/src/auth/flows/oauth.authorize.flow.js +701 -33
- package/src/auth/flows/oauth.authorize.flow.js.map +1 -1
- package/src/auth/flows/oauth.callback.flow.d.ts +117 -0
- package/src/auth/flows/oauth.callback.flow.js +357 -0
- package/src/auth/flows/oauth.callback.flow.js.map +1 -0
- package/src/auth/flows/oauth.register.flow.d.ts +32 -125
- package/src/auth/flows/oauth.token.flow.d.ts +52 -154
- package/src/auth/flows/oauth.token.flow.js +193 -55
- package/src/auth/flows/oauth.token.flow.js.map +1 -1
- package/src/auth/flows/session.verify.flow.d.ts +66 -321
- package/src/auth/flows/session.verify.flow.js +107 -18
- package/src/auth/flows/session.verify.flow.js.map +1 -1
- package/src/auth/flows/well-known.jwks.flow.d.ts +34 -205
- package/src/auth/flows/well-known.jwks.flow.js +15 -8
- package/src/auth/flows/well-known.jwks.flow.js.map +1 -1
- package/src/auth/flows/well-known.oauth-authorization-server.flow.d.ts +48 -223
- package/src/auth/flows/well-known.oauth-authorization-server.flow.js +2 -3
- package/src/auth/flows/well-known.oauth-authorization-server.flow.js.map +1 -1
- package/src/auth/flows/well-known.prm.flow.d.ts +19 -120
- package/src/auth/flows/well-known.prm.flow.js +3 -4
- package/src/auth/flows/well-known.prm.flow.js.map +1 -1
- package/src/auth/instances/instance.local-primary-auth.d.ts +91 -4
- package/src/auth/instances/instance.local-primary-auth.js +236 -6
- package/src/auth/instances/instance.local-primary-auth.js.map +1 -1
- package/src/auth/instances/instance.remote-primary-auth.d.ts +4 -3
- package/src/auth/instances/instance.remote-primary-auth.js +2 -2
- package/src/auth/instances/instance.remote-primary-auth.js.map +1 -1
- package/src/auth/session/authorization-vault.d.ts +611 -0
- package/src/auth/session/authorization-vault.js +817 -0
- package/src/auth/session/authorization-vault.js.map +1 -0
- package/src/auth/session/authorization.store.d.ts +301 -0
- package/src/auth/session/authorization.store.js +323 -0
- package/src/auth/session/authorization.store.js.map +1 -0
- package/src/auth/session/encrypted-authorization-vault.d.ts +181 -0
- package/src/auth/session/encrypted-authorization-vault.js +493 -0
- package/src/auth/session/encrypted-authorization-vault.js.map +1 -0
- package/src/auth/session/index.d.ts +4 -4
- package/src/auth/session/index.js +11 -7
- package/src/auth/session/index.js.map +1 -1
- package/src/auth/session/session.schema.d.ts +1 -1
- package/src/auth/session/session.service.d.ts +1 -1
- package/src/auth/session/transport-session.manager.d.ts +101 -0
- package/src/auth/session/transport-session.manager.js +300 -0
- package/src/auth/session/transport-session.manager.js.map +1 -0
- package/src/auth/session/transport-session.types.d.ts +457 -0
- package/src/auth/session/transport-session.types.js +110 -0
- package/src/auth/session/transport-session.types.js.map +1 -0
- package/src/auth/session/utils/session-id.utils.d.ts +14 -2
- package/src/auth/session/utils/session-id.utils.js +68 -19
- package/src/auth/session/utils/session-id.utils.js.map +1 -1
- package/src/auth/session/vault-encryption.d.ts +189 -0
- package/src/auth/session/vault-encryption.js +263 -0
- package/src/auth/session/vault-encryption.js.map +1 -0
- package/src/auth/ui/base-layout.d.ts +188 -0
- package/src/auth/ui/base-layout.js +292 -0
- package/src/auth/ui/base-layout.js.map +1 -0
- package/src/auth/ui/htmx-templates.d.ts +135 -0
- package/src/auth/ui/htmx-templates.js +433 -0
- package/src/auth/ui/htmx-templates.js.map +1 -0
- package/src/auth/ui/index.d.ts +11 -0
- package/src/auth/ui/index.js +35 -0
- package/src/auth/ui/index.js.map +1 -0
- package/src/auth/utils/audience.validator.d.ts +129 -0
- package/src/auth/utils/audience.validator.js +196 -0
- package/src/auth/utils/audience.validator.js.map +1 -0
- package/src/auth/utils/index.d.ts +2 -0
- package/src/auth/utils/index.js +7 -0
- package/src/auth/utils/index.js.map +1 -0
- package/src/auth/utils/www-authenticate.utils.d.ts +97 -0
- package/src/auth/utils/www-authenticate.utils.js +183 -0
- package/src/auth/utils/www-authenticate.utils.js.map +1 -0
- package/src/common/common.schema.d.ts +2 -16
- package/src/common/constants.d.ts +3 -0
- package/src/common/constants.js +6 -1
- package/src/common/constants.js.map +1 -1
- package/src/common/decorators/decorator-utils.d.ts +131 -0
- package/src/common/decorators/decorator-utils.js +195 -0
- package/src/common/decorators/decorator-utils.js.map +1 -0
- package/src/common/decorators/front-mcp.decorator.js +3 -2
- package/src/common/decorators/front-mcp.decorator.js.map +1 -1
- package/src/common/decorators/hook.decorator.d.ts +58 -2
- package/src/common/decorators/hook.decorator.js +127 -17
- package/src/common/decorators/hook.decorator.js.map +1 -1
- package/src/common/decorators/plugin.decorator.d.ts +1 -1
- package/src/common/decorators/plugin.decorator.js +11 -10
- package/src/common/decorators/plugin.decorator.js.map +1 -1
- package/src/common/decorators/resource.decorator.d.ts +32 -3
- package/src/common/decorators/resource.decorator.js +46 -4
- package/src/common/decorators/resource.decorator.js.map +1 -1
- package/src/common/decorators/tool.decorator.d.ts +54 -5
- package/src/common/decorators/tool.decorator.js.map +1 -1
- package/src/common/dynamic/dynamic.plugin.d.ts +22 -11
- package/src/common/dynamic/dynamic.plugin.js +7 -1
- package/src/common/dynamic/dynamic.plugin.js.map +1 -1
- package/src/common/entries/prompt.entry.d.ts +46 -2
- package/src/common/entries/prompt.entry.js +10 -0
- package/src/common/entries/prompt.entry.js.map +1 -1
- package/src/common/entries/resource.entry.d.ts +69 -6
- package/src/common/entries/resource.entry.js +27 -3
- package/src/common/entries/resource.entry.js.map +1 -1
- package/src/common/entries/scope.entry.d.ts +5 -1
- package/src/common/entries/scope.entry.js +3 -3
- package/src/common/entries/scope.entry.js.map +1 -1
- package/src/common/flow/flow.utils.d.ts +56 -0
- package/src/common/flow/flow.utils.js +96 -0
- package/src/common/flow/flow.utils.js.map +1 -0
- package/src/common/index.d.ts +2 -2
- package/src/common/index.js +2 -2
- package/src/common/index.js.map +1 -1
- package/src/common/interfaces/execution-context.interface.d.ts +59 -0
- package/src/common/interfaces/execution-context.interface.js +81 -0
- package/src/common/interfaces/execution-context.interface.js.map +1 -0
- package/src/common/interfaces/flow.interface.d.ts +1 -1
- package/src/common/interfaces/flow.interface.js.map +1 -1
- package/src/common/interfaces/index.d.ts +1 -0
- package/src/common/interfaces/index.js +1 -0
- package/src/common/interfaces/index.js.map +1 -1
- package/src/common/interfaces/internal/primary-auth-provider.interface.d.ts +17 -2
- package/src/common/interfaces/internal/primary-auth-provider.interface.js +52 -4
- package/src/common/interfaces/internal/primary-auth-provider.interface.js.map +1 -1
- package/src/common/interfaces/internal/registry.interface.d.ts +16 -2
- package/src/common/interfaces/internal/registry.interface.js.map +1 -1
- package/src/common/interfaces/plugin.interface.js.map +1 -1
- package/src/common/interfaces/prompt.interface.d.ts +53 -4
- package/src/common/interfaces/prompt.interface.js +78 -0
- package/src/common/interfaces/prompt.interface.js.map +1 -1
- package/src/common/interfaces/resource.interface.d.ts +47 -17
- package/src/common/interfaces/resource.interface.js +53 -0
- package/src/common/interfaces/resource.interface.js.map +1 -1
- package/src/common/interfaces/tool.interface.d.ts +39 -22
- package/src/common/interfaces/tool.interface.js +61 -34
- package/src/common/interfaces/tool.interface.js.map +1 -1
- package/src/common/metadata/adapter.metadata.d.ts +1 -9
- package/src/common/metadata/app.metadata.d.ts +425 -730
- package/src/common/metadata/auth-provider.metadata.d.ts +2 -12
- package/src/common/metadata/flow.metadata.d.ts +10 -25
- package/src/common/metadata/front-mcp.metadata.d.ts +602 -1023
- package/src/common/metadata/front-mcp.metadata.js +6 -4
- package/src/common/metadata/front-mcp.metadata.js.map +1 -1
- package/src/common/metadata/hook.metadata.d.ts +1 -1
- package/src/common/metadata/hook.metadata.js.map +1 -1
- package/src/common/metadata/index.d.ts +1 -0
- package/src/common/metadata/index.js +1 -0
- package/src/common/metadata/index.js.map +1 -1
- package/src/common/metadata/logger.metadata.d.ts +1 -9
- package/src/common/metadata/plugin.metadata.d.ts +8 -30
- package/src/common/metadata/prompt.metadata.d.ts +4 -161
- package/src/common/metadata/provider.metadata.d.ts +2 -12
- package/src/common/metadata/resource.metadata.d.ts +6 -98
- package/src/common/metadata/resource.metadata.js +15 -6
- package/src/common/metadata/resource.metadata.js.map +1 -1
- package/src/common/metadata/tool-ui.metadata.d.ts +10 -0
- package/src/common/metadata/tool-ui.metadata.js +12 -0
- package/src/common/metadata/tool-ui.metadata.js.map +1 -0
- package/src/common/metadata/tool.metadata.d.ts +110 -199
- package/src/common/metadata/tool.metadata.js +11 -14
- package/src/common/metadata/tool.metadata.js.map +1 -1
- package/src/common/providers/base-config.provider.d.ts +84 -0
- package/src/common/providers/base-config.provider.js +128 -0
- package/src/common/providers/base-config.provider.js.map +1 -0
- package/src/common/records/plugin.record.d.ts +5 -6
- package/src/common/records/plugin.record.js.map +1 -1
- package/src/common/records/prompt.record.js.map +1 -1
- package/src/common/records/resource.record.d.ts +17 -1
- package/src/common/records/resource.record.js +12 -6
- package/src/common/records/resource.record.js.map +1 -1
- package/src/common/records/tool.record.js.map +1 -1
- package/src/common/schemas/annotated-class.schema.d.ts +9 -9
- package/src/common/schemas/annotated-class.schema.js +92 -27
- package/src/common/schemas/annotated-class.schema.js.map +1 -1
- package/src/common/schemas/http-input.schema.d.ts +6 -30
- package/src/common/schemas/http-output.schema.d.ts +336 -1632
- package/src/common/schemas/http-output.schema.js +39 -1
- package/src/common/schemas/http-output.schema.js.map +1 -1
- package/src/common/tokens/front-mcp.tokens.js +4 -1
- package/src/common/tokens/front-mcp.tokens.js.map +1 -1
- package/src/common/tokens/resource.tokens.d.ts +2 -0
- package/src/common/tokens/resource.tokens.js +4 -1
- package/src/common/tokens/resource.tokens.js.map +1 -1
- package/src/common/tokens/tool.tokens.d.ts +2 -0
- package/src/common/tokens/tool.tokens.js +2 -0
- package/src/common/tokens/tool.tokens.js.map +1 -1
- package/src/common/types/auth/jwt.types.d.ts +5 -31
- package/src/common/types/auth/session.types.d.ts +97 -192
- package/src/common/types/auth/session.types.js +24 -11
- package/src/common/types/auth/session.types.js.map +1 -1
- package/src/common/types/options/auth.options.d.ts +1013 -490
- package/src/common/types/options/auth.options.js +554 -36
- package/src/common/types/options/auth.options.js.map +1 -1
- package/src/common/types/options/http.options.d.ts +1 -9
- package/src/common/types/options/logging.options.d.ts +7 -13
- package/src/common/types/options/logging.options.js +4 -0
- package/src/common/types/options/logging.options.js.map +1 -1
- package/src/common/types/options/server-info.options.d.ts +3 -31
- package/src/common/types/options/session.options.d.ts +90 -10
- package/src/common/types/options/session.options.js +26 -3
- package/src/common/types/options/session.options.js.map +1 -1
- package/src/common/utils/decide-request-intent.utils.d.ts +8 -46
- package/src/common/utils/decide-request-intent.utils.js +88 -23
- package/src/common/utils/decide-request-intent.utils.js.map +1 -1
- package/src/completion/flows/complete.flow.d.ts +89 -0
- package/src/completion/flows/complete.flow.js +199 -0
- package/src/completion/flows/complete.flow.js.map +1 -0
- package/src/errors/authorization-required.error.d.ts +189 -0
- package/src/errors/authorization-required.error.js +274 -0
- package/src/errors/authorization-required.error.js.map +1 -0
- package/src/errors/index.d.ts +2 -1
- package/src/errors/index.js +17 -1
- package/src/errors/index.js.map +1 -1
- package/src/errors/mcp.error.d.ts +101 -1
- package/src/errors/mcp.error.js +147 -2
- package/src/errors/mcp.error.js.map +1 -1
- package/src/flows/flow.instance.js +4 -3
- package/src/flows/flow.instance.js.map +1 -1
- package/src/flows/flow.registry.js.map +1 -1
- package/src/flows/flow.stages.js +14 -11
- package/src/flows/flow.stages.js.map +1 -1
- package/src/front-mcp/front-mcp.providers.d.ts +464 -102
- package/src/front-mcp/front-mcp.providers.js +3 -5
- package/src/front-mcp/front-mcp.providers.js.map +1 -1
- package/src/hooks/hook.instance.d.ts +1 -1
- package/src/hooks/hook.instance.js +5 -2
- package/src/hooks/hook.instance.js.map +1 -1
- package/src/hooks/hook.registry.js +7 -5
- package/src/hooks/hook.registry.js.map +1 -1
- package/src/index.d.ts +28 -9
- package/src/index.js +5 -1
- package/src/index.js.map +1 -1
- package/src/logger/instances/instance.logger.js +3 -2
- package/src/logger/instances/instance.logger.js.map +1 -1
- package/src/logger/logger.registry.js +7 -2
- package/src/logger/logger.registry.js.map +1 -1
- package/src/logging/flows/set-level.flow.d.ts +77 -0
- package/src/logging/flows/set-level.flow.js +108 -0
- package/src/logging/flows/set-level.flow.js.map +1 -0
- package/src/mcp-apps/csp.d.ts +111 -0
- package/src/mcp-apps/csp.js +267 -0
- package/src/mcp-apps/csp.js.map +1 -0
- package/src/mcp-apps/index.d.ts +23 -0
- package/src/mcp-apps/index.js +91 -0
- package/src/mcp-apps/index.js.map +1 -0
- package/src/mcp-apps/schemas.d.ts +403 -0
- package/src/mcp-apps/schemas.js +345 -0
- package/src/mcp-apps/schemas.js.map +1 -0
- package/src/mcp-apps/template.d.ts +94 -0
- package/src/mcp-apps/template.js +419 -0
- package/src/mcp-apps/template.js.map +1 -0
- package/src/mcp-apps/types.d.ts +323 -0
- package/src/mcp-apps/types.js +59 -0
- package/src/mcp-apps/types.js.map +1 -0
- package/src/notification/index.d.ts +1 -0
- package/src/notification/index.js +13 -0
- package/src/notification/index.js.map +1 -0
- package/src/notification/notification.service.d.ts +378 -0
- package/src/notification/notification.service.js +727 -0
- package/src/notification/notification.service.js.map +1 -0
- package/src/plugin/plugin.registry.js +12 -9
- package/src/plugin/plugin.registry.js.map +1 -1
- package/src/prompt/flows/get-prompt.flow.d.ts +248 -0
- package/src/prompt/flows/get-prompt.flow.js +214 -0
- package/src/prompt/flows/get-prompt.flow.js.map +1 -0
- package/src/prompt/flows/prompts-list.flow.d.ts +78 -0
- package/src/prompt/flows/prompts-list.flow.js +176 -0
- package/src/prompt/flows/prompts-list.flow.js.map +1 -0
- package/src/prompt/index.d.ts +7 -0
- package/src/prompt/index.js +17 -0
- package/src/prompt/index.js.map +1 -0
- package/src/prompt/prompt.events.d.ts +17 -0
- package/src/prompt/prompt.events.js +25 -0
- package/src/prompt/prompt.events.js.map +1 -0
- package/src/prompt/prompt.instance.d.ts +30 -0
- package/src/prompt/prompt.instance.js +120 -0
- package/src/prompt/prompt.instance.js.map +1 -0
- package/src/prompt/prompt.registry.d.ts +79 -12
- package/src/prompt/prompt.registry.js +360 -15
- package/src/prompt/prompt.registry.js.map +1 -1
- package/src/prompt/prompt.types.d.ts +26 -0
- package/src/prompt/prompt.types.js +11 -0
- package/src/prompt/prompt.types.js.map +1 -0
- package/src/prompt/prompt.utils.d.ts +26 -0
- package/src/prompt/prompt.utils.js +136 -0
- package/src/prompt/prompt.utils.js.map +1 -0
- package/src/provider/provider.registry.d.ts +12 -5
- package/src/provider/provider.registry.js +30 -138
- package/src/provider/provider.registry.js.map +1 -1
- package/src/regsitry/registry.base.d.ts +1 -1
- package/src/regsitry/registry.base.js.map +1 -1
- package/src/resource/flows/read-resource.flow.d.ts +110 -0
- package/src/resource/flows/read-resource.flow.js +270 -0
- package/src/resource/flows/read-resource.flow.js.map +1 -0
- package/src/resource/flows/resource-templates-list.flow.d.ts +83 -0
- package/src/resource/flows/resource-templates-list.flow.js +191 -0
- package/src/resource/flows/resource-templates-list.flow.js.map +1 -0
- package/src/resource/flows/resources-list.flow.d.ts +83 -0
- package/src/resource/flows/resources-list.flow.js +196 -0
- package/src/resource/flows/resources-list.flow.js.map +1 -0
- package/src/resource/flows/subscribe-resource.flow.d.ts +60 -0
- package/src/resource/flows/subscribe-resource.flow.js +123 -0
- package/src/resource/flows/subscribe-resource.flow.js.map +1 -0
- package/src/resource/flows/unsubscribe-resource.flow.d.ts +59 -0
- package/src/resource/flows/unsubscribe-resource.flow.js +107 -0
- package/src/resource/flows/unsubscribe-resource.flow.js.map +1 -0
- package/src/resource/index.d.ts +8 -0
- package/src/resource/index.js +20 -0
- package/src/resource/index.js.map +1 -0
- package/src/resource/resource.events.d.ts +24 -0
- package/src/resource/resource.events.js +17 -0
- package/src/resource/resource.events.js.map +1 -0
- package/src/resource/resource.instance.d.ts +35 -0
- package/src/resource/resource.instance.js +163 -0
- package/src/resource/resource.instance.js.map +1 -0
- package/src/resource/resource.registry.d.ts +106 -12
- package/src/resource/resource.registry.js +449 -13
- package/src/resource/resource.registry.js.map +1 -1
- package/src/resource/resource.types.d.ts +35 -0
- package/src/resource/resource.types.js +11 -0
- package/src/resource/resource.types.js.map +1 -0
- package/src/resource/resource.utils.d.ts +30 -0
- package/src/resource/resource.utils.js +151 -0
- package/src/resource/resource.utils.js.map +1 -0
- package/src/scope/flows/http.request.flow.d.ts +48 -330
- package/src/scope/flows/http.request.flow.js +306 -78
- package/src/scope/flows/http.request.flow.js.map +1 -1
- package/src/scope/scope.instance.d.ts +12 -0
- package/src/scope/scope.instance.js +145 -15
- package/src/scope/scope.instance.js.map +1 -1
- package/src/tool/flows/call-tool.flow.d.ts +161 -1112
- package/src/tool/flows/call-tool.flow.js +303 -15
- package/src/tool/flows/call-tool.flow.js.map +1 -1
- package/src/tool/flows/tools-list.flow.d.ts +51 -474
- package/src/tool/flows/tools-list.flow.js +121 -40
- package/src/tool/flows/tools-list.flow.js.map +1 -1
- package/src/tool/tool.events.d.ts +8 -1
- package/src/tool/tool.events.js.map +1 -1
- package/src/tool/tool.instance.d.ts +3 -1
- package/src/tool/tool.instance.js +17 -3
- package/src/tool/tool.instance.js.map +1 -1
- package/src/tool/tool.registry.d.ts +7 -1
- package/src/tool/tool.registry.js +26 -10
- package/src/tool/tool.registry.js.map +1 -1
- package/src/tool/tool.types.d.ts +4 -4
- package/src/tool/tool.types.js.map +1 -1
- package/src/tool/tool.utils.d.ts +3 -12
- package/src/tool/tool.utils.js +39 -193
- package/src/tool/tool.utils.js.map +1 -1
- package/src/tool/ui/index.d.ts +22 -0
- package/src/tool/ui/index.js +63 -0
- package/src/tool/ui/index.js.map +1 -0
- package/src/tool/ui/platform-adapters.d.ts +10 -0
- package/src/tool/ui/platform-adapters.js +18 -0
- package/src/tool/ui/platform-adapters.js.map +1 -0
- package/src/tool/ui/template-helpers.d.ts +46 -0
- package/src/tool/ui/template-helpers.js +112 -0
- package/src/tool/ui/template-helpers.js.map +1 -0
- package/src/tool/ui/ui-resource-template.d.ts +34 -0
- package/src/tool/ui/ui-resource-template.js +64 -0
- package/src/tool/ui/ui-resource-template.js.map +1 -0
- package/src/tool/ui/ui-resource.handler.d.ts +74 -0
- package/src/tool/ui/ui-resource.handler.js +129 -0
- package/src/tool/ui/ui-resource.handler.js.map +1 -0
- package/src/transport/adapters/transport.local.adapter.d.ts +2 -2
- package/src/transport/adapters/transport.local.adapter.js +28 -7
- package/src/transport/adapters/transport.local.adapter.js.map +1 -1
- package/src/transport/adapters/transport.sse.adapter.d.ts +2 -2
- package/src/transport/adapters/transport.sse.adapter.js +4 -3
- package/src/transport/adapters/transport.sse.adapter.js.map +1 -1
- package/src/transport/adapters/transport.streamable-http.adapter.d.ts +10 -3
- package/src/transport/adapters/transport.streamable-http.adapter.js +54 -8
- package/src/transport/adapters/transport.streamable-http.adapter.js.map +1 -1
- package/src/transport/flows/handle.sse.flow.d.ts +29 -63
- package/src/transport/flows/handle.sse.flow.js +78 -10
- package/src/transport/flows/handle.sse.flow.js.map +1 -1
- package/src/transport/flows/handle.stateless-http.flow.d.ts +29 -0
- package/src/transport/flows/handle.stateless-http.flow.js +102 -0
- package/src/transport/flows/handle.stateless-http.flow.js.map +1 -0
- package/src/transport/flows/handle.streamable-http.flow.d.ts +32 -64
- package/src/transport/flows/handle.streamable-http.flow.js +158 -26
- package/src/transport/flows/handle.streamable-http.flow.js.map +1 -1
- package/src/transport/legacy/legacy.sse.tranporter.d.ts +9 -0
- package/src/transport/legacy/legacy.sse.tranporter.js +17 -2
- package/src/transport/legacy/legacy.sse.tranporter.js.map +1 -1
- package/src/transport/mcp-handlers/call-tool-request.handler.js +27 -1
- package/src/transport/mcp-handlers/call-tool-request.handler.js.map +1 -1
- package/src/transport/mcp-handlers/complete-request.handler.d.ts +95 -0
- package/src/transport/mcp-handlers/complete-request.handler.js +11 -0
- package/src/transport/mcp-handlers/complete-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/get-prompt-request.handler.d.ts +138 -0
- package/src/transport/mcp-handlers/get-prompt-request.handler.js +11 -0
- package/src/transport/mcp-handlers/get-prompt-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/index.d.ts +922 -207
- package/src/transport/mcp-handlers/index.js +39 -2
- package/src/transport/mcp-handlers/index.js.map +1 -1
- package/src/transport/mcp-handlers/initialize-request.handler.d.ts +1 -1
- package/src/transport/mcp-handlers/initialize-request.handler.js +73 -7
- package/src/transport/mcp-handlers/initialize-request.handler.js.map +1 -1
- package/src/transport/mcp-handlers/list-prompts-request.handler.d.ts +80 -0
- package/src/transport/mcp-handlers/list-prompts-request.handler.js +11 -0
- package/src/transport/mcp-handlers/list-prompts-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/list-resource-templates-request.handler.d.ts +82 -0
- package/src/transport/mcp-handlers/list-resource-templates-request.handler.js +12 -0
- package/src/transport/mcp-handlers/list-resource-templates-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/list-resources-request.handler.d.ts +82 -0
- package/src/transport/mcp-handlers/list-resources-request.handler.js +12 -0
- package/src/transport/mcp-handlers/list-resources-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/list-tools-request.handler.d.ts +47 -145
- package/src/transport/mcp-handlers/logging-set-level-request.handler.d.ts +66 -0
- package/src/transport/mcp-handlers/logging-set-level-request.handler.js +34 -0
- package/src/transport/mcp-handlers/logging-set-level-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/mcp-handlers.types.d.ts +3 -7
- package/src/transport/mcp-handlers/mcp-handlers.types.js.map +1 -1
- package/src/transport/mcp-handlers/read-resource-request.handler.d.ts +72 -0
- package/src/transport/mcp-handlers/read-resource-request.handler.js +12 -0
- package/src/transport/mcp-handlers/read-resource-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/roots-list-changed-notification.handler.d.ts +11 -0
- package/src/transport/mcp-handlers/roots-list-changed-notification.handler.js +26 -0
- package/src/transport/mcp-handlers/roots-list-changed-notification.handler.js.map +1 -0
- package/src/transport/mcp-handlers/subscribe-request.handler.d.ts +57 -0
- package/src/transport/mcp-handlers/subscribe-request.handler.js +34 -0
- package/src/transport/mcp-handlers/subscribe-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/unsubscribe-request.handler.d.ts +57 -0
- package/src/transport/mcp-handlers/unsubscribe-request.handler.js +34 -0
- package/src/transport/mcp-handlers/unsubscribe-request.handler.js.map +1 -0
- package/src/transport/transport.local.js +7 -2
- package/src/transport/transport.local.js.map +1 -1
- package/src/transport/transport.registry.d.ts +30 -0
- package/src/transport/transport.registry.js +84 -1
- package/src/transport/transport.registry.js.map +1 -1
- package/src/transport/transport.types.d.ts +3 -3
- package/src/transport/transport.types.js.map +1 -1
- package/src/utils/content.utils.d.ts +48 -0
- package/src/utils/content.utils.js +194 -0
- package/src/utils/content.utils.js.map +1 -0
- package/src/utils/index.d.ts +8 -0
- package/src/utils/index.js +55 -0
- package/src/utils/index.js.map +1 -0
- package/src/utils/lineage.utils.d.ts +40 -0
- package/src/utils/lineage.utils.js +82 -0
- package/src/utils/lineage.utils.js.map +1 -0
- package/src/utils/naming.utils.d.ts +46 -0
- package/src/utils/naming.utils.js +136 -0
- package/src/utils/naming.utils.js.map +1 -0
- package/src/utils/types.utils.d.ts +2 -2
- package/src/utils/types.utils.js.map +1 -1
- package/src/utils/uri-template.utils.d.ts +57 -0
- package/src/utils/uri-template.utils.js +113 -0
- package/src/utils/uri-template.utils.js.map +1 -0
- package/src/utils/uri-validation.utils.d.ts +40 -0
- package/src/utils/uri-validation.utils.js +76 -0
- package/src/utils/uri-validation.utils.js.map +1 -0
- package/src/__test-utils__/fixtures/hook.fixtures.d.ts +0 -46
- package/src/__test-utils__/fixtures/hook.fixtures.js +0 -114
- package/src/__test-utils__/fixtures/hook.fixtures.js.map +0 -1
- package/src/__test-utils__/fixtures/index.d.ts +0 -7
- package/src/__test-utils__/fixtures/index.js +0 -11
- package/src/__test-utils__/fixtures/index.js.map +0 -1
- package/src/__test-utils__/fixtures/plugin.fixtures.d.ts +0 -46
- package/src/__test-utils__/fixtures/plugin.fixtures.js +0 -127
- package/src/__test-utils__/fixtures/plugin.fixtures.js.map +0 -1
- package/src/__test-utils__/fixtures/provider.fixtures.d.ts +0 -69
- package/src/__test-utils__/fixtures/provider.fixtures.js +0 -131
- package/src/__test-utils__/fixtures/provider.fixtures.js.map +0 -1
- package/src/__test-utils__/fixtures/scope.fixtures.d.ts +0 -14
- package/src/__test-utils__/fixtures/scope.fixtures.js +0 -59
- package/src/__test-utils__/fixtures/scope.fixtures.js.map +0 -1
- package/src/__test-utils__/fixtures/tool.fixtures.d.ts +0 -36
- package/src/__test-utils__/fixtures/tool.fixtures.js +0 -91
- package/src/__test-utils__/fixtures/tool.fixtures.js.map +0 -1
- package/src/__test-utils__/helpers/assertion.helpers.d.ts +0 -45
- package/src/__test-utils__/helpers/assertion.helpers.js +0 -153
- package/src/__test-utils__/helpers/assertion.helpers.js.map +0 -1
- package/src/__test-utils__/helpers/async.helpers.d.ts +0 -48
- package/src/__test-utils__/helpers/async.helpers.js +0 -112
- package/src/__test-utils__/helpers/async.helpers.js.map +0 -1
- package/src/__test-utils__/helpers/index.d.ts +0 -6
- package/src/__test-utils__/helpers/index.js +0 -10
- package/src/__test-utils__/helpers/index.js.map +0 -1
- package/src/__test-utils__/helpers/setup.helpers.d.ts +0 -54
- package/src/__test-utils__/helpers/setup.helpers.js +0 -106
- package/src/__test-utils__/helpers/setup.helpers.js.map +0 -1
- package/src/__test-utils__/index.d.ts +0 -9
- package/src/__test-utils__/index.js +0 -14
- package/src/__test-utils__/index.js.map +0 -1
- package/src/__test-utils__/mocks/flow-instance.mock.d.ts +0 -50
- package/src/__test-utils__/mocks/flow-instance.mock.js +0 -72
- package/src/__test-utils__/mocks/flow-instance.mock.js.map +0 -1
- package/src/__test-utils__/mocks/hook-registry.mock.d.ts +0 -25
- package/src/__test-utils__/mocks/hook-registry.mock.js +0 -65
- package/src/__test-utils__/mocks/hook-registry.mock.js.map +0 -1
- package/src/__test-utils__/mocks/index.d.ts +0 -8
- package/src/__test-utils__/mocks/index.js +0 -12
- package/src/__test-utils__/mocks/index.js.map +0 -1
- package/src/__test-utils__/mocks/plugin-registry.mock.d.ts +0 -43
- package/src/__test-utils__/mocks/plugin-registry.mock.js +0 -70
- package/src/__test-utils__/mocks/plugin-registry.mock.js.map +0 -1
- package/src/__test-utils__/mocks/provider-registry.mock.d.ts +0 -39
- package/src/__test-utils__/mocks/provider-registry.mock.js +0 -72
- package/src/__test-utils__/mocks/provider-registry.mock.js.map +0 -1
- package/src/__test-utils__/mocks/tool-registry.mock.d.ts +0 -43
- package/src/__test-utils__/mocks/tool-registry.mock.js +0 -79
- package/src/__test-utils__/mocks/tool-registry.mock.js.map +0 -1
- package/src/auth/path.utils.d.ts +0 -20
- package/src/auth/path.utils.js +0 -71
- package/src/auth/path.utils.js.map +0 -1
- package/src/common/decorators-old/async-with.decorator.d.ts +0 -10
- package/src/common/decorators-old/async-with.decorator.js +0 -24
- package/src/common/decorators-old/async-with.decorator.js.map +0 -1
- package/src/common/decorators-old/auth-hook.decorator.d.ts +0 -14
- package/src/common/decorators-old/auth-hook.decorator.js +0 -27
- package/src/common/decorators-old/auth-hook.decorator.js.map +0 -1
- package/src/common/decorators-old/session-hook.decorator.d.ts +0 -14
- package/src/common/decorators-old/session-hook.decorator.js +0 -27
- package/src/common/decorators-old/session-hook.decorator.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.utils.js","sourceRoot":"","sources":["../../../src/utils/types.utils.ts"],"names":[],"mappings":"","sourcesContent":["import { z,
|
|
1
|
+
{"version":3,"file":"types.utils.js","sourceRoot":"","sources":["../../../src/utils/types.utils.ts"],"names":[],"mappings":"","sourcesContent":["import { z, ZodType } from 'zod';\n\ntype Primitive = string | number | boolean | bigint | null | undefined;\ntype Flatten<T> = T extends Primitive\n ? T\n : T extends Array<infer U>\n ? Array<Flatten<U>>\n : T extends Set<infer U>\n ? Set<Flatten<U>>\n : T extends Map<infer K, infer V>\n ? Map<Flatten<K>, Flatten<V>>\n : T extends object\n ? {\n [K in keyof T]: Flatten<T[K]>;\n }\n : T;\nexport type Infer<Schema extends ZodType> = Flatten<z.infer<Schema>>;\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parsed URI template information
|
|
3
|
+
*/
|
|
4
|
+
export interface ParsedUriTemplate {
|
|
5
|
+
pattern: RegExp;
|
|
6
|
+
paramNames: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Parse a URI template (RFC 6570 Level 1) into a regex pattern and parameter names.
|
|
10
|
+
* Supports simple string substitution: {param}
|
|
11
|
+
*
|
|
12
|
+
* Note: This implements RFC 6570 Level 1 only (simple string substitution).
|
|
13
|
+
* Advanced operators like {+path}, {#fragment}, or {?query} are not supported.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* parseUriTemplate("file:///{path}") => { pattern: /^file:\/\/\/([^/]+)$/, paramNames: ["path"] }
|
|
17
|
+
* parseUriTemplate("users/{userId}/posts/{postId}") => { pattern: /^users\/([^/]+)\/posts\/([^/]+)$/, paramNames: ["userId", "postId"] }
|
|
18
|
+
*
|
|
19
|
+
* @throws Error if template is too long (>1000 chars) or has too many parameters (>50)
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseUriTemplate(template: string): ParsedUriTemplate;
|
|
22
|
+
/**
|
|
23
|
+
* Match a URI against a URI template and extract parameters.
|
|
24
|
+
* Returns null if no match, or an object with extracted parameters.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* matchUriTemplate("file:///{path}", "file:///documents/readme.txt")
|
|
28
|
+
* => { path: "documents" } // Note: only captures first segment
|
|
29
|
+
*
|
|
30
|
+
* matchUriTemplate("users/{userId}/posts/{postId}", "users/123/posts/456")
|
|
31
|
+
* => { userId: "123", postId: "456" }
|
|
32
|
+
*/
|
|
33
|
+
export declare function matchUriTemplate(template: string, uri: string): Record<string, string> | null;
|
|
34
|
+
/**
|
|
35
|
+
* Expand a URI template with the given parameters.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* expandUriTemplate("file:///{path}", { path: "documents/readme.txt" })
|
|
39
|
+
* => "file:///documents%2Freadme.txt"
|
|
40
|
+
*
|
|
41
|
+
* expandUriTemplate("users/{userId}/posts/{postId}", { userId: "123", postId: "456" })
|
|
42
|
+
* => "users/123/posts/456"
|
|
43
|
+
*
|
|
44
|
+
* @throws Error if a required parameter is missing
|
|
45
|
+
*/
|
|
46
|
+
export declare function expandUriTemplate(template: string, params: Record<string, string>): string;
|
|
47
|
+
/**
|
|
48
|
+
* Extract parameter names from a URI template.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* extractTemplateParams("users/{userId}/posts/{postId}") => ["userId", "postId"]
|
|
52
|
+
*/
|
|
53
|
+
export declare function extractTemplateParams(template: string): string[];
|
|
54
|
+
/**
|
|
55
|
+
* Check if a string is a URI template (contains {param} placeholders).
|
|
56
|
+
*/
|
|
57
|
+
export declare function isUriTemplate(uri: string): boolean;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// file: libs/sdk/src/utils/uri-template.utils.ts
|
|
3
|
+
// RFC 6570 Level 1 URI Template utilities
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.parseUriTemplate = parseUriTemplate;
|
|
6
|
+
exports.matchUriTemplate = matchUriTemplate;
|
|
7
|
+
exports.expandUriTemplate = expandUriTemplate;
|
|
8
|
+
exports.extractTemplateParams = extractTemplateParams;
|
|
9
|
+
exports.isUriTemplate = isUriTemplate;
|
|
10
|
+
/**
|
|
11
|
+
* Parse a URI template (RFC 6570 Level 1) into a regex pattern and parameter names.
|
|
12
|
+
* Supports simple string substitution: {param}
|
|
13
|
+
*
|
|
14
|
+
* Note: This implements RFC 6570 Level 1 only (simple string substitution).
|
|
15
|
+
* Advanced operators like {+path}, {#fragment}, or {?query} are not supported.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* parseUriTemplate("file:///{path}") => { pattern: /^file:\/\/\/([^/]+)$/, paramNames: ["path"] }
|
|
19
|
+
* parseUriTemplate("users/{userId}/posts/{postId}") => { pattern: /^users\/([^/]+)\/posts\/([^/]+)$/, paramNames: ["userId", "postId"] }
|
|
20
|
+
*
|
|
21
|
+
* @throws Error if template is too long (>1000 chars) or has too many parameters (>50)
|
|
22
|
+
*/
|
|
23
|
+
function parseUriTemplate(template) {
|
|
24
|
+
if (template.length > 1000) {
|
|
25
|
+
throw new Error('URI template too long (max 1000 characters)');
|
|
26
|
+
}
|
|
27
|
+
const paramCount = (template.match(/\{[^}]+\}/g) || []).length;
|
|
28
|
+
if (paramCount > 50) {
|
|
29
|
+
throw new Error('URI template has too many parameters (max 50)');
|
|
30
|
+
}
|
|
31
|
+
const paramNames = [];
|
|
32
|
+
// Escape special regex characters, but handle {param} placeholders
|
|
33
|
+
let regexStr = template.replace(/[.*+?^${}()|[\]\\]/g, (match) => {
|
|
34
|
+
// Don't escape { and } yet - we'll handle them for parameters
|
|
35
|
+
if (match === '{' || match === '}')
|
|
36
|
+
return match;
|
|
37
|
+
return '\\' + match;
|
|
38
|
+
});
|
|
39
|
+
// Replace {param} with capture groups
|
|
40
|
+
regexStr = regexStr.replace(/\{([^}]+)\}/g, (_, paramName) => {
|
|
41
|
+
paramNames.push(paramName);
|
|
42
|
+
// Match any non-empty string segment (stops at /)
|
|
43
|
+
return '([^/]+)';
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
pattern: new RegExp(`^${regexStr}$`),
|
|
47
|
+
paramNames,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Match a URI against a URI template and extract parameters.
|
|
52
|
+
* Returns null if no match, or an object with extracted parameters.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* matchUriTemplate("file:///{path}", "file:///documents/readme.txt")
|
|
56
|
+
* => { path: "documents" } // Note: only captures first segment
|
|
57
|
+
*
|
|
58
|
+
* matchUriTemplate("users/{userId}/posts/{postId}", "users/123/posts/456")
|
|
59
|
+
* => { userId: "123", postId: "456" }
|
|
60
|
+
*/
|
|
61
|
+
function matchUriTemplate(template, uri) {
|
|
62
|
+
const { pattern, paramNames } = parseUriTemplate(template);
|
|
63
|
+
const match = uri.match(pattern);
|
|
64
|
+
if (!match)
|
|
65
|
+
return null;
|
|
66
|
+
const params = {};
|
|
67
|
+
paramNames.forEach((name, index) => {
|
|
68
|
+
params[name] = decodeURIComponent(match[index + 1]);
|
|
69
|
+
});
|
|
70
|
+
return params;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Expand a URI template with the given parameters.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* expandUriTemplate("file:///{path}", { path: "documents/readme.txt" })
|
|
77
|
+
* => "file:///documents%2Freadme.txt"
|
|
78
|
+
*
|
|
79
|
+
* expandUriTemplate("users/{userId}/posts/{postId}", { userId: "123", postId: "456" })
|
|
80
|
+
* => "users/123/posts/456"
|
|
81
|
+
*
|
|
82
|
+
* @throws Error if a required parameter is missing
|
|
83
|
+
*/
|
|
84
|
+
function expandUriTemplate(template, params) {
|
|
85
|
+
return template.replace(/\{([^}]+)\}/g, (_, paramName) => {
|
|
86
|
+
const value = params[paramName];
|
|
87
|
+
if (value === undefined) {
|
|
88
|
+
throw new Error(`Missing parameter '${paramName}' for URI template '${template}'`);
|
|
89
|
+
}
|
|
90
|
+
return encodeURIComponent(value);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Extract parameter names from a URI template.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* extractTemplateParams("users/{userId}/posts/{postId}") => ["userId", "postId"]
|
|
98
|
+
*/
|
|
99
|
+
function extractTemplateParams(template) {
|
|
100
|
+
const params = [];
|
|
101
|
+
template.replace(/\{([^}]+)\}/g, (_, paramName) => {
|
|
102
|
+
params.push(paramName);
|
|
103
|
+
return '';
|
|
104
|
+
});
|
|
105
|
+
return params;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Check if a string is a URI template (contains {param} placeholders).
|
|
109
|
+
*/
|
|
110
|
+
function isUriTemplate(uri) {
|
|
111
|
+
return /\{[^}]+\}/.test(uri);
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=uri-template.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uri-template.utils.js","sourceRoot":"","sources":["../../../src/utils/uri-template.utils.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,0CAA0C;;AAuB1C,4CA6BC;AAaD,4CAYC;AAcD,8CAQC;AAQD,sDAOC;AAKD,sCAEC;AA/GD;;;;;;;;;;;;GAYG;AACH,SAAgB,gBAAgB,CAAC,QAAgB;IAC/C,IAAI,QAAQ,CAAC,MAAM,GAAG,IAAI,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IACD,MAAM,UAAU,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IAC/D,IAAI,UAAU,GAAG,EAAE,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IAED,MAAM,UAAU,GAAa,EAAE,CAAC;IAEhC,mEAAmE;IACnE,IAAI,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,KAAK,EAAE,EAAE;QAC/D,8DAA8D;QAC9D,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,GAAG;YAAE,OAAO,KAAK,CAAC;QACjD,OAAO,IAAI,GAAG,KAAK,CAAC;IACtB,CAAC,CAAC,CAAC;IAEH,sCAAsC;IACtC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE;QAC3D,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3B,kDAAkD;QAClD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,IAAI,MAAM,CAAC,IAAI,QAAQ,GAAG,CAAC;QACpC,UAAU;KACX,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,gBAAgB,CAAC,QAAgB,EAAE,GAAW;IAC5D,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC3D,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAEjC,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAExB,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACjC,MAAM,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,iBAAiB,CAAC,QAAgB,EAAE,MAA8B;IAChF,OAAO,QAAQ,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE;QACvD,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;QAChC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,sBAAsB,SAAS,uBAAuB,QAAQ,GAAG,CAAC,CAAC;QACrF,CAAC;QACD,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,QAAgB;IACpD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE;QAChD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,GAAW;IACvC,OAAO,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["// file: libs/sdk/src/utils/uri-template.utils.ts\n// RFC 6570 Level 1 URI Template utilities\n\n/**\n * Parsed URI template information\n */\nexport interface ParsedUriTemplate {\n pattern: RegExp;\n paramNames: string[];\n}\n\n/**\n * Parse a URI template (RFC 6570 Level 1) into a regex pattern and parameter names.\n * Supports simple string substitution: {param}\n *\n * Note: This implements RFC 6570 Level 1 only (simple string substitution).\n * Advanced operators like {+path}, {#fragment}, or {?query} are not supported.\n *\n * @example\n * parseUriTemplate(\"file:///{path}\") => { pattern: /^file:\\/\\/\\/([^/]+)$/, paramNames: [\"path\"] }\n * parseUriTemplate(\"users/{userId}/posts/{postId}\") => { pattern: /^users\\/([^/]+)\\/posts\\/([^/]+)$/, paramNames: [\"userId\", \"postId\"] }\n *\n * @throws Error if template is too long (>1000 chars) or has too many parameters (>50)\n */\nexport function parseUriTemplate(template: string): ParsedUriTemplate {\n if (template.length > 1000) {\n throw new Error('URI template too long (max 1000 characters)');\n }\n const paramCount = (template.match(/\\{[^}]+\\}/g) || []).length;\n if (paramCount > 50) {\n throw new Error('URI template has too many parameters (max 50)');\n }\n\n const paramNames: string[] = [];\n\n // Escape special regex characters, but handle {param} placeholders\n let regexStr = template.replace(/[.*+?^${}()|[\\]\\\\]/g, (match) => {\n // Don't escape { and } yet - we'll handle them for parameters\n if (match === '{' || match === '}') return match;\n return '\\\\' + match;\n });\n\n // Replace {param} with capture groups\n regexStr = regexStr.replace(/\\{([^}]+)\\}/g, (_, paramName) => {\n paramNames.push(paramName);\n // Match any non-empty string segment (stops at /)\n return '([^/]+)';\n });\n\n return {\n pattern: new RegExp(`^${regexStr}$`),\n paramNames,\n };\n}\n\n/**\n * Match a URI against a URI template and extract parameters.\n * Returns null if no match, or an object with extracted parameters.\n *\n * @example\n * matchUriTemplate(\"file:///{path}\", \"file:///documents/readme.txt\")\n * => { path: \"documents\" } // Note: only captures first segment\n *\n * matchUriTemplate(\"users/{userId}/posts/{postId}\", \"users/123/posts/456\")\n * => { userId: \"123\", postId: \"456\" }\n */\nexport function matchUriTemplate(template: string, uri: string): Record<string, string> | null {\n const { pattern, paramNames } = parseUriTemplate(template);\n const match = uri.match(pattern);\n\n if (!match) return null;\n\n const params: Record<string, string> = {};\n paramNames.forEach((name, index) => {\n params[name] = decodeURIComponent(match[index + 1]);\n });\n\n return params;\n}\n\n/**\n * Expand a URI template with the given parameters.\n *\n * @example\n * expandUriTemplate(\"file:///{path}\", { path: \"documents/readme.txt\" })\n * => \"file:///documents%2Freadme.txt\"\n *\n * expandUriTemplate(\"users/{userId}/posts/{postId}\", { userId: \"123\", postId: \"456\" })\n * => \"users/123/posts/456\"\n *\n * @throws Error if a required parameter is missing\n */\nexport function expandUriTemplate(template: string, params: Record<string, string>): string {\n return template.replace(/\\{([^}]+)\\}/g, (_, paramName) => {\n const value = params[paramName];\n if (value === undefined) {\n throw new Error(`Missing parameter '${paramName}' for URI template '${template}'`);\n }\n return encodeURIComponent(value);\n });\n}\n\n/**\n * Extract parameter names from a URI template.\n *\n * @example\n * extractTemplateParams(\"users/{userId}/posts/{postId}\") => [\"userId\", \"postId\"]\n */\nexport function extractTemplateParams(template: string): string[] {\n const params: string[] = [];\n template.replace(/\\{([^}]+)\\}/g, (_, paramName) => {\n params.push(paramName);\n return '';\n });\n return params;\n}\n\n/**\n * Check if a string is a URI template (contains {param} placeholders).\n */\nexport function isUriTemplate(uri: string): boolean {\n return /\\{[^}]+\\}/.test(uri);\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate that a URI has a valid scheme per RFC 3986.
|
|
3
|
+
*
|
|
4
|
+
* @param uri - The URI to validate
|
|
5
|
+
* @returns true if the URI has a valid scheme, false otherwise
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* isValidMcpUri('file:///path/to/file') // true
|
|
9
|
+
* isValidMcpUri('https://example.com/resource') // true
|
|
10
|
+
* isValidMcpUri('custom://my-resource') // true
|
|
11
|
+
* isValidMcpUri('/path/to/file') // false (no scheme)
|
|
12
|
+
* isValidMcpUri('123://invalid') // false (scheme must start with letter)
|
|
13
|
+
*/
|
|
14
|
+
export declare function isValidMcpUri(uri: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Extract the scheme from a URI.
|
|
17
|
+
*
|
|
18
|
+
* @param uri - The URI to extract the scheme from
|
|
19
|
+
* @returns The scheme in lowercase, or null if no valid scheme found
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* extractUriScheme('file:///path') // 'file'
|
|
23
|
+
* extractUriScheme('HTTPS://example.com') // 'https'
|
|
24
|
+
* extractUriScheme('/no/scheme') // null
|
|
25
|
+
*/
|
|
26
|
+
export declare function extractUriScheme(uri: string): string | null;
|
|
27
|
+
/**
|
|
28
|
+
* Validate that a URI template has a valid scheme per RFC 3986.
|
|
29
|
+
* URI templates follow RFC 6570 and can contain template expressions like {var}.
|
|
30
|
+
* The scheme portion should still be a valid static scheme.
|
|
31
|
+
*
|
|
32
|
+
* @param uriTemplate - The URI template to validate
|
|
33
|
+
* @returns true if the URI template has a valid scheme, false otherwise
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* isValidMcpUriTemplate('users://{userId}/profile') // true
|
|
37
|
+
* isValidMcpUriTemplate('file:///{path}') // true
|
|
38
|
+
* isValidMcpUriTemplate('{scheme}://dynamic') // false (scheme must be static)
|
|
39
|
+
*/
|
|
40
|
+
export declare function isValidMcpUriTemplate(uriTemplate: string): boolean;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// file: libs/sdk/src/utils/uri-validation.utils.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.isValidMcpUri = isValidMcpUri;
|
|
5
|
+
exports.extractUriScheme = extractUriScheme;
|
|
6
|
+
exports.isValidMcpUriTemplate = isValidMcpUriTemplate;
|
|
7
|
+
/**
|
|
8
|
+
* URI validation utilities for MCP resource URIs.
|
|
9
|
+
*
|
|
10
|
+
* Per MCP specification, resource URIs should follow RFC 3986 and include
|
|
11
|
+
* a valid scheme (e.g., file://, https://, custom://).
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* RFC 3986 compliant URI scheme pattern.
|
|
15
|
+
* scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
|
|
16
|
+
*
|
|
17
|
+
* The pattern validates that the URI:
|
|
18
|
+
* 1. Starts with a letter (case insensitive)
|
|
19
|
+
* 2. Followed by any combination of letters, digits, +, -, or .
|
|
20
|
+
* 3. Followed by ://
|
|
21
|
+
*/
|
|
22
|
+
const RFC_3986_SCHEME_PATTERN = /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//;
|
|
23
|
+
/**
|
|
24
|
+
* Pattern to extract the scheme from a URI.
|
|
25
|
+
*/
|
|
26
|
+
const SCHEME_EXTRACT_PATTERN = /^([a-zA-Z][a-zA-Z0-9+.-]*):/;
|
|
27
|
+
/**
|
|
28
|
+
* Validate that a URI has a valid scheme per RFC 3986.
|
|
29
|
+
*
|
|
30
|
+
* @param uri - The URI to validate
|
|
31
|
+
* @returns true if the URI has a valid scheme, false otherwise
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* isValidMcpUri('file:///path/to/file') // true
|
|
35
|
+
* isValidMcpUri('https://example.com/resource') // true
|
|
36
|
+
* isValidMcpUri('custom://my-resource') // true
|
|
37
|
+
* isValidMcpUri('/path/to/file') // false (no scheme)
|
|
38
|
+
* isValidMcpUri('123://invalid') // false (scheme must start with letter)
|
|
39
|
+
*/
|
|
40
|
+
function isValidMcpUri(uri) {
|
|
41
|
+
return RFC_3986_SCHEME_PATTERN.test(uri);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Extract the scheme from a URI.
|
|
45
|
+
*
|
|
46
|
+
* @param uri - The URI to extract the scheme from
|
|
47
|
+
* @returns The scheme in lowercase, or null if no valid scheme found
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* extractUriScheme('file:///path') // 'file'
|
|
51
|
+
* extractUriScheme('HTTPS://example.com') // 'https'
|
|
52
|
+
* extractUriScheme('/no/scheme') // null
|
|
53
|
+
*/
|
|
54
|
+
function extractUriScheme(uri) {
|
|
55
|
+
const match = uri.match(SCHEME_EXTRACT_PATTERN);
|
|
56
|
+
return match ? match[1].toLowerCase() : null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Validate that a URI template has a valid scheme per RFC 3986.
|
|
60
|
+
* URI templates follow RFC 6570 and can contain template expressions like {var}.
|
|
61
|
+
* The scheme portion should still be a valid static scheme.
|
|
62
|
+
*
|
|
63
|
+
* @param uriTemplate - The URI template to validate
|
|
64
|
+
* @returns true if the URI template has a valid scheme, false otherwise
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* isValidMcpUriTemplate('users://{userId}/profile') // true
|
|
68
|
+
* isValidMcpUriTemplate('file:///{path}') // true
|
|
69
|
+
* isValidMcpUriTemplate('{scheme}://dynamic') // false (scheme must be static)
|
|
70
|
+
*/
|
|
71
|
+
function isValidMcpUriTemplate(uriTemplate) {
|
|
72
|
+
// For templates, we just need to check if it starts with a valid scheme
|
|
73
|
+
// The template expressions come after the scheme
|
|
74
|
+
return RFC_3986_SCHEME_PATTERN.test(uriTemplate);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=uri-validation.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uri-validation.utils.js","sourceRoot":"","sources":["../../../src/utils/uri-validation.utils.ts"],"names":[],"mappings":";AAAA,mDAAmD;;AAsCnD,sCAEC;AAaD,4CAGC;AAeD,sDAIC;AAzED;;;;;GAKG;AAEH;;;;;;;;GAQG;AACH,MAAM,uBAAuB,GAAG,+BAA+B,CAAC;AAEhE;;GAEG;AACH,MAAM,sBAAsB,GAAG,6BAA6B,CAAC;AAE7D;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa,CAAC,GAAW;IACvC,OAAO,uBAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,gBAAgB,CAAC,GAAW;IAC1C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAChD,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,qBAAqB,CAAC,WAAmB;IACvD,wEAAwE;IACxE,iDAAiD;IACjD,OAAO,uBAAuB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACnD,CAAC","sourcesContent":["// file: libs/sdk/src/utils/uri-validation.utils.ts\n\n/**\n * URI validation utilities for MCP resource URIs.\n *\n * Per MCP specification, resource URIs should follow RFC 3986 and include\n * a valid scheme (e.g., file://, https://, custom://).\n */\n\n/**\n * RFC 3986 compliant URI scheme pattern.\n * scheme = ALPHA *( ALPHA / DIGIT / \"+\" / \"-\" / \".\" )\n *\n * The pattern validates that the URI:\n * 1. Starts with a letter (case insensitive)\n * 2. Followed by any combination of letters, digits, +, -, or .\n * 3. Followed by ://\n */\nconst RFC_3986_SCHEME_PATTERN = /^[a-zA-Z][a-zA-Z0-9+.-]*:\\/\\//;\n\n/**\n * Pattern to extract the scheme from a URI.\n */\nconst SCHEME_EXTRACT_PATTERN = /^([a-zA-Z][a-zA-Z0-9+.-]*):/;\n\n/**\n * Validate that a URI has a valid scheme per RFC 3986.\n *\n * @param uri - The URI to validate\n * @returns true if the URI has a valid scheme, false otherwise\n *\n * @example\n * isValidMcpUri('file:///path/to/file') // true\n * isValidMcpUri('https://example.com/resource') // true\n * isValidMcpUri('custom://my-resource') // true\n * isValidMcpUri('/path/to/file') // false (no scheme)\n * isValidMcpUri('123://invalid') // false (scheme must start with letter)\n */\nexport function isValidMcpUri(uri: string): boolean {\n return RFC_3986_SCHEME_PATTERN.test(uri);\n}\n\n/**\n * Extract the scheme from a URI.\n *\n * @param uri - The URI to extract the scheme from\n * @returns The scheme in lowercase, or null if no valid scheme found\n *\n * @example\n * extractUriScheme('file:///path') // 'file'\n * extractUriScheme('HTTPS://example.com') // 'https'\n * extractUriScheme('/no/scheme') // null\n */\nexport function extractUriScheme(uri: string): string | null {\n const match = uri.match(SCHEME_EXTRACT_PATTERN);\n return match ? match[1].toLowerCase() : null;\n}\n\n/**\n * Validate that a URI template has a valid scheme per RFC 3986.\n * URI templates follow RFC 6570 and can contain template expressions like {var}.\n * The scheme portion should still be a valid static scheme.\n *\n * @param uriTemplate - The URI template to validate\n * @returns true if the URI template has a valid scheme, false otherwise\n *\n * @example\n * isValidMcpUriTemplate('users://{userId}/profile') // true\n * isValidMcpUriTemplate('file:///{path}') // true\n * isValidMcpUriTemplate('{scheme}://dynamic') // false (scheme must be static)\n */\nexport function isValidMcpUriTemplate(uriTemplate: string): boolean {\n // For templates, we just need to check if it starts with a valid scheme\n // The template expressions come after the scheme\n return RFC_3986_SCHEME_PATTERN.test(uriTemplate);\n}\n"]}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test fixtures for hooks
|
|
3
|
-
*/
|
|
4
|
-
import { HookMetadata } from '../../common/metadata';
|
|
5
|
-
import { Token } from '../../common/interfaces';
|
|
6
|
-
/**
|
|
7
|
-
* Test token for hook target
|
|
8
|
-
*/
|
|
9
|
-
export declare const TEST_HOOK_TARGET: Token;
|
|
10
|
-
/**
|
|
11
|
-
* Creates a simple hook metadata object
|
|
12
|
-
*/
|
|
13
|
-
export declare function createHookMetadata(overrides?: Partial<HookMetadata>): HookMetadata;
|
|
14
|
-
/**
|
|
15
|
-
* Creates a "will" stage hook metadata
|
|
16
|
-
*/
|
|
17
|
-
export declare function createWillHookMetadata(flow?: string, stage?: string): HookMetadata;
|
|
18
|
-
/**
|
|
19
|
-
* Creates a "did" stage hook metadata
|
|
20
|
-
*/
|
|
21
|
-
export declare function createDidHookMetadata(flow?: string, stage?: string): HookMetadata;
|
|
22
|
-
/**
|
|
23
|
-
* Creates an "around" stage hook metadata
|
|
24
|
-
*/
|
|
25
|
-
export declare function createAroundHookMetadata(flow?: string, stage?: string): HookMetadata;
|
|
26
|
-
/**
|
|
27
|
-
* Mock hook class for testing
|
|
28
|
-
*/
|
|
29
|
-
export declare class MockHookClass {
|
|
30
|
-
onExecute: jest.Mock<Promise<void>, [ctx: any], any>;
|
|
31
|
-
willExecute: jest.Mock<Promise<void>, [ctx: any], any>;
|
|
32
|
-
didExecute: jest.Mock<Promise<void>, [ctx: any], any>;
|
|
33
|
-
aroundExecute: jest.Mock<Promise<any>, [ctx: any, next: () => Promise<any>], any>;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Creates a mock hook instance for testing
|
|
37
|
-
*/
|
|
38
|
-
export declare function createMockHookInstance(metadata?: Partial<HookMetadata>): {
|
|
39
|
-
metadata: HookMetadata<keyof ExtendFlows, string, any>;
|
|
40
|
-
instance: MockHookClass;
|
|
41
|
-
execute: jest.Mock<Promise<void>, [ctx: any], any>;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Creates multiple hooks with different priorities
|
|
45
|
-
*/
|
|
46
|
-
export declare function createPriorityHooks(priorities: number[]): HookMetadata[];
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/// <reference types="jest" />
|
|
3
|
-
/**
|
|
4
|
-
* Test fixtures for hooks
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.MockHookClass = exports.TEST_HOOK_TARGET = void 0;
|
|
8
|
-
exports.createHookMetadata = createHookMetadata;
|
|
9
|
-
exports.createWillHookMetadata = createWillHookMetadata;
|
|
10
|
-
exports.createDidHookMetadata = createDidHookMetadata;
|
|
11
|
-
exports.createAroundHookMetadata = createAroundHookMetadata;
|
|
12
|
-
exports.createMockHookInstance = createMockHookInstance;
|
|
13
|
-
exports.createPriorityHooks = createPriorityHooks;
|
|
14
|
-
/**
|
|
15
|
-
* Test token for hook target
|
|
16
|
-
*/
|
|
17
|
-
exports.TEST_HOOK_TARGET = Symbol('TEST_HOOK_TARGET');
|
|
18
|
-
/**
|
|
19
|
-
* Creates a simple hook metadata object
|
|
20
|
-
*/
|
|
21
|
-
function createHookMetadata(overrides = {}) {
|
|
22
|
-
return {
|
|
23
|
-
type: 'stage',
|
|
24
|
-
flow: 'CallToolFlow',
|
|
25
|
-
stage: 'execute',
|
|
26
|
-
target: exports.TEST_HOOK_TARGET,
|
|
27
|
-
method: 'onExecute',
|
|
28
|
-
priority: 0,
|
|
29
|
-
...overrides,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Creates a "will" stage hook metadata
|
|
34
|
-
*/
|
|
35
|
-
function createWillHookMetadata(flow = 'CallToolFlow', stage = 'execute') {
|
|
36
|
-
return {
|
|
37
|
-
type: 'will',
|
|
38
|
-
flow: flow,
|
|
39
|
-
stage,
|
|
40
|
-
target: exports.TEST_HOOK_TARGET,
|
|
41
|
-
method: 'willExecute',
|
|
42
|
-
priority: 0,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Creates a "did" stage hook metadata
|
|
47
|
-
*/
|
|
48
|
-
function createDidHookMetadata(flow = 'CallToolFlow', stage = 'execute') {
|
|
49
|
-
return {
|
|
50
|
-
type: 'did',
|
|
51
|
-
flow: flow,
|
|
52
|
-
stage,
|
|
53
|
-
target: exports.TEST_HOOK_TARGET,
|
|
54
|
-
method: 'didExecute',
|
|
55
|
-
priority: 0,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Creates an "around" stage hook metadata
|
|
60
|
-
*/
|
|
61
|
-
function createAroundHookMetadata(flow = 'CallToolFlow', stage = 'execute') {
|
|
62
|
-
return {
|
|
63
|
-
type: 'around',
|
|
64
|
-
flow: flow,
|
|
65
|
-
stage,
|
|
66
|
-
target: exports.TEST_HOOK_TARGET,
|
|
67
|
-
method: 'aroundExecute',
|
|
68
|
-
priority: 0,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Mock hook class for testing
|
|
73
|
-
*/
|
|
74
|
-
class MockHookClass {
|
|
75
|
-
onExecute = jest.fn(async (ctx) => {
|
|
76
|
-
// Mock hook implementation
|
|
77
|
-
});
|
|
78
|
-
willExecute = jest.fn(async (ctx) => {
|
|
79
|
-
// Mock will hook implementation
|
|
80
|
-
});
|
|
81
|
-
didExecute = jest.fn(async (ctx) => {
|
|
82
|
-
// Mock did hook implementation
|
|
83
|
-
});
|
|
84
|
-
aroundExecute = jest.fn(async (ctx, next) => {
|
|
85
|
-
// Mock around hook implementation
|
|
86
|
-
return await next();
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
exports.MockHookClass = MockHookClass;
|
|
90
|
-
/**
|
|
91
|
-
* Creates a mock hook instance for testing
|
|
92
|
-
*/
|
|
93
|
-
function createMockHookInstance(metadata) {
|
|
94
|
-
const mockClass = new MockHookClass();
|
|
95
|
-
return {
|
|
96
|
-
metadata: createHookMetadata(metadata),
|
|
97
|
-
instance: mockClass,
|
|
98
|
-
execute: mockClass.onExecute,
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Creates multiple hooks with different priorities
|
|
103
|
-
*/
|
|
104
|
-
function createPriorityHooks(priorities) {
|
|
105
|
-
return priorities.map((priority, index) => ({
|
|
106
|
-
type: 'stage',
|
|
107
|
-
flow: 'CallToolFlow',
|
|
108
|
-
stage: 'execute',
|
|
109
|
-
target: Symbol(`HOOK_${index}`),
|
|
110
|
-
method: 'onExecute',
|
|
111
|
-
priority,
|
|
112
|
-
}));
|
|
113
|
-
}
|
|
114
|
-
//# sourceMappingURL=hook.fixtures.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hook.fixtures.js","sourceRoot":"","sources":["../../../../src/__test-utils__/fixtures/hook.fixtures.ts"],"names":[],"mappings":";AAAA,8BAA8B;AAC9B;;GAEG;;;AAaH,gDAYC;AAKD,wDAYC;AAKD,sDAYC;AAKD,4DAYC;AA2BD,wDAOC;AAKD,kDASC;AAvHD;;GAEG;AACU,QAAA,gBAAgB,GAAU,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAElE;;GAEG;AACH,SAAgB,kBAAkB,CAChC,YAAmC,EAAE;IAErC,OAAO;QACL,IAAI,EAAE,OAAwB;QAC9B,IAAI,EAAE,cAAqB;QAC3B,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,wBAAgB;QACxB,MAAM,EAAE,WAAW;QACnB,QAAQ,EAAE,CAAC;QACX,GAAG,SAAS;KACb,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CACpC,OAAe,cAAc,EAC7B,QAAgB,SAAS;IAEzB,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,IAAW;QACjB,KAAK;QACL,MAAM,EAAE,wBAAgB;QACxB,MAAM,EAAE,aAAa;QACrB,QAAQ,EAAE,CAAC;KACZ,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CACnC,OAAe,cAAc,EAC7B,QAAgB,SAAS;IAEzB,OAAO;QACL,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,IAAW;QACjB,KAAK;QACL,MAAM,EAAE,wBAAgB;QACxB,MAAM,EAAE,YAAY;QACpB,QAAQ,EAAE,CAAC;KACZ,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,wBAAwB,CACtC,OAAe,cAAc,EAC7B,QAAgB,SAAS;IAEzB,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,IAAW;QACjB,KAAK;QACL,MAAM,EAAE,wBAAgB;QACxB,MAAM,EAAE,eAAe;QACvB,QAAQ,EAAE,CAAC;KACZ,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAa,aAAa;IACxB,SAAS,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,GAAQ,EAAE,EAAE;QACrC,2BAA2B;IAC7B,CAAC,CAAC,CAAC;IAEH,WAAW,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,GAAQ,EAAE,EAAE;QACvC,gCAAgC;IAClC,CAAC,CAAC,CAAC;IAEH,UAAU,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,GAAQ,EAAE,EAAE;QACtC,+BAA+B;IACjC,CAAC,CAAC,CAAC;IAEH,aAAa,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,GAAQ,EAAE,IAAwB,EAAE,EAAE;QACnE,kCAAkC;QAClC,OAAO,MAAM,IAAI,EAAE,CAAC;IACtB,CAAC,CAAC,CAAC;CACJ;AAjBD,sCAiBC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CAAC,QAAgC;IACrE,MAAM,SAAS,GAAG,IAAI,aAAa,EAAE,CAAC;IACtC,OAAO;QACL,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,CAAC;QACtC,QAAQ,EAAE,SAAS;QACnB,OAAO,EAAE,SAAS,CAAC,SAAS;KAC7B,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CAAC,UAAoB;IACtD,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,EAAE,OAAwB;QAC9B,IAAI,EAAE,cAAqB;QAC3B,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,MAAM,CAAC,QAAQ,KAAK,EAAE,CAAC;QAC/B,MAAM,EAAE,WAAW;QACnB,QAAQ;KACT,CAAC,CAAC,CAAC;AACN,CAAC","sourcesContent":["/// <reference types=\"jest\" />\n/**\n * Test fixtures for hooks\n */\n\nimport { HookMetadata, HookStageType } from '../../common/metadata';\nimport { Token } from '../../common/interfaces';\n\n/**\n * Test token for hook target\n */\nexport const TEST_HOOK_TARGET: Token = Symbol('TEST_HOOK_TARGET');\n\n/**\n * Creates a simple hook metadata object\n */\nexport function createHookMetadata(\n overrides: Partial<HookMetadata> = {}\n): HookMetadata {\n return {\n type: 'stage' as HookStageType,\n flow: 'CallToolFlow' as any,\n stage: 'execute',\n target: TEST_HOOK_TARGET,\n method: 'onExecute',\n priority: 0,\n ...overrides,\n };\n}\n\n/**\n * Creates a \"will\" stage hook metadata\n */\nexport function createWillHookMetadata(\n flow: string = 'CallToolFlow',\n stage: string = 'execute'\n): HookMetadata {\n return {\n type: 'will',\n flow: flow as any,\n stage,\n target: TEST_HOOK_TARGET,\n method: 'willExecute',\n priority: 0,\n };\n}\n\n/**\n * Creates a \"did\" stage hook metadata\n */\nexport function createDidHookMetadata(\n flow: string = 'CallToolFlow',\n stage: string = 'execute'\n): HookMetadata {\n return {\n type: 'did',\n flow: flow as any,\n stage,\n target: TEST_HOOK_TARGET,\n method: 'didExecute',\n priority: 0,\n };\n}\n\n/**\n * Creates an \"around\" stage hook metadata\n */\nexport function createAroundHookMetadata(\n flow: string = 'CallToolFlow',\n stage: string = 'execute'\n): HookMetadata {\n return {\n type: 'around',\n flow: flow as any,\n stage,\n target: TEST_HOOK_TARGET,\n method: 'aroundExecute',\n priority: 0,\n };\n}\n\n/**\n * Mock hook class for testing\n */\nexport class MockHookClass {\n onExecute = jest.fn(async (ctx: any) => {\n // Mock hook implementation\n });\n\n willExecute = jest.fn(async (ctx: any) => {\n // Mock will hook implementation\n });\n\n didExecute = jest.fn(async (ctx: any) => {\n // Mock did hook implementation\n });\n\n aroundExecute = jest.fn(async (ctx: any, next: () => Promise<any>) => {\n // Mock around hook implementation\n return await next();\n });\n}\n\n/**\n * Creates a mock hook instance for testing\n */\nexport function createMockHookInstance(metadata?: Partial<HookMetadata>) {\n const mockClass = new MockHookClass();\n return {\n metadata: createHookMetadata(metadata),\n instance: mockClass,\n execute: mockClass.onExecute,\n };\n}\n\n/**\n * Creates multiple hooks with different priorities\n */\nexport function createPriorityHooks(priorities: number[]): HookMetadata[] {\n return priorities.map((priority, index) => ({\n type: 'stage' as HookStageType,\n flow: 'CallToolFlow' as any,\n stage: 'execute',\n target: Symbol(`HOOK_${index}`),\n method: 'onExecute',\n priority,\n }));\n}\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Test fixtures for common SDK entities
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const tslib_1 = require("tslib");
|
|
7
|
-
tslib_1.__exportStar(require("./plugin.fixtures"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./tool.fixtures"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./hook.fixtures"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./provider.fixtures"), exports);
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/__test-utils__/fixtures/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,4DAAkC;AAClC,0DAAgC;AAChC,0DAAgC;AAChC,8DAAoC","sourcesContent":["/**\n * Test fixtures for common SDK entities\n */\n\nexport * from './plugin.fixtures';\nexport * from './tool.fixtures';\nexport * from './hook.fixtures';\nexport * from './provider.fixtures';\n"]}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test fixtures for plugins
|
|
3
|
-
*/
|
|
4
|
-
import { PluginMetadata } from '../../common/metadata';
|
|
5
|
-
import { PluginInterface } from '../../common/interfaces';
|
|
6
|
-
/**
|
|
7
|
-
* Creates a simple plugin metadata object
|
|
8
|
-
*/
|
|
9
|
-
export declare function createPluginMetadata(overrides?: Partial<PluginMetadata>): PluginMetadata;
|
|
10
|
-
/**
|
|
11
|
-
* Creates a plugin with providers
|
|
12
|
-
*/
|
|
13
|
-
export declare function createPluginWithProviders(): PluginMetadata;
|
|
14
|
-
/**
|
|
15
|
-
* Creates a plugin with tools
|
|
16
|
-
*/
|
|
17
|
-
export declare function createPluginWithTools(): PluginMetadata;
|
|
18
|
-
/**
|
|
19
|
-
* Creates a plugin with nested plugins
|
|
20
|
-
*/
|
|
21
|
-
export declare function createPluginWithNestedPlugins(): PluginMetadata;
|
|
22
|
-
/**
|
|
23
|
-
* Mock plugin class for testing
|
|
24
|
-
*/
|
|
25
|
-
export declare class MockPluginClass implements PluginInterface {
|
|
26
|
-
static readonly metadata: PluginMetadata;
|
|
27
|
-
constructor();
|
|
28
|
-
onInit?(): Promise<void>;
|
|
29
|
-
onDestroy?(): Promise<void>;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Creates a mock plugin instance
|
|
33
|
-
*/
|
|
34
|
-
export declare function createMockPluginInstance(metadata?: Partial<PluginMetadata>): {
|
|
35
|
-
metadata: PluginMetadata;
|
|
36
|
-
onInit: jest.Mock<Promise<void>, [], any>;
|
|
37
|
-
onDestroy: jest.Mock<Promise<void>, [], any>;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Creates multiple plugins for dependency testing
|
|
41
|
-
*/
|
|
42
|
-
export declare function createPluginDependencyChain(): {
|
|
43
|
-
pluginA: PluginMetadata;
|
|
44
|
-
pluginB: PluginMetadata;
|
|
45
|
-
pluginC: PluginMetadata;
|
|
46
|
-
};
|